question about custom property

satri
satri Altair Community Member
edited February 28 in Community Q&A

Hello

I am trying to create meta particles with two different diameters with a custom factory and particle replacement API.

During this i have defined a custom property called particle type which will assign it a value of 1 when diameter 2 needs to be created. based on this custom property i go to the cRemoval.cpp file and change the particle cluster. 

But as per the sequence of the runtime of EDEM particle factory is supposed to run first and then c removal but when i run the program goes directly to the CRemoval.cpp 

so what i don't understand here is should i have same name for the custom property in CReplacementFactory and CRemoval.cpp?

this is a custom prop i have created in CReplacementFactory API

image

In the external force API, I am trying to get its value

image

and then change the cluster type

image

so i am not able to understand two things

1 why does the program directly go to Cremove API by skipping replacement API?

2 do i need to remain consistent with the names of custom properties in the custom factory API and body force API?

Please let me know

Tagged:

Answers

  • Stephen Cole
    Stephen Cole
    Altair Employee
    edited February 26

    Hi Shyam,

     

    For the custom property definition (name, type, number of elements) it should be identical in the Factory and Body Force areas.  

     

    The factory is always called first but your code, if it is not entering the factory code for custom properties I'd make sure your break point is right at the start of the factory, it may just not be entering due to the IF loops in the code.  Otherwise best to make sure the updated compiled library file is loaded into the custom factory area in the EDEM Creator.

     

    Regards

    Stephen

  • satri
    satri Altair Community Member
    edited February 26

    If i give the same name i will get an error like this

    image

    For reference i will attach snips of the places where i have defined custom properties in CReplacementFactory.cpp please tell me what could be going wrong here.

    CReplacementFactory.cpp

    image

    image

    if factory produces particle type 1 then assign m_pt2 value as 0

    image

    image

    image

    image

    CRemoval.cpp

    image

    image

    image

    image

    image

  • satri
    satri Altair Community Member
    edited February 26

    Could you please help me figure out what could be wrong here? I am giving the same name for the custom property as you see in both CReplacementFactory.cpp and CRemoval.cpp.

    I have a breakpoint at the beginning of the if statement too. 

    One thing i noticed is there is no function called starting in the particle factory program so i don't know at which stage the custom property is getting initiated. If the sequence of runs is like this

    particleFactory->bodyForce

    then i should initiate the custom property in the fileCReplacementFactory.cpp because i am going to be using a different Particle_Cluster file for the second type of meta particle. but if you look at the code i am assigning the custom property inside the starting function of CRemoval.cpp

    so i am kinda confused here. what should be the flow of logic here>

     

     

  • Stephen Cole
    Stephen Cole
    Altair Employee
    edited February 26

    Could you please help me figure out what could be wrong here? I am giving the same name for the custom property as you see in both CReplacementFactory.cpp and CRemoval.cpp.

    I have a breakpoint at the beginning of the if statement too. 

    One thing i noticed is there is no function called starting in the particle factory program so i don't know at which stage the custom property is getting initiated. If the sequence of runs is like this

    particleFactory->bodyForce

    then i should initiate the custom property in the fileCReplacementFactory.cpp because i am going to be using a different Particle_Cluster file for the second type of meta particle. but if you look at the code i am assigning the custom property inside the starting function of CRemoval.cpp

    so i am kinda confused here. what should be the flow of logic here>

     

     

    Hi Shyam, It looks like neither the factory or particle body force is loading due to a clash with existing custom properties in the simulation you are opening..  This is likely due to a change in the custom property at some point in the file you are loading.  Once a custom property is loaded into a simulation then this simulation doesn't allow any different custom properties under the same name.  

     

    A new simulation should work or if you want to use your existing simulation go to the Analyst > Time = 0 > File > Export > Simulation Deck .  Make sure 'export Custom Properties' is not selected and then save the file under a new name.  You should be able to load your model into this file.

     

    Regards

    Stephen

  • satri
    satri Altair Community Member
    edited February 26

    Yes i did that i think it was clashing with the keyword i changed.

    Now i am not getting that error i showed earlier. 

    image

    But after the change, i see something like this

    This statement is supposed to apply a value 1 for one particle of diameter 2 but it keeps accumulating many times even though i am doing the assignment once

    image

    But i don't see 1 it keeps accumulating more values in this custom property

    image

    why does this happen? i am only calling the value.

  • Stephen Cole
    Stephen Cole
    Altair Employee
    edited February 26

    Yes i did that i think it was clashing with the keyword i changed.

    Now i am not getting that error i showed earlier. 

    image

    But after the change, i see something like this

    This statement is supposed to apply a value 1 for one particle of diameter 2 but it keeps accumulating many times even though i am doing the assignment once

    image

    But i don't see 1 it keeps accumulating more values in this custom property

    image

    why does this happen? i am only calling the value.

    Hi Shyam,

     

    Custom properties have a 'Delta' and a 'Value' and we can only change the Delta value (permanent changes that is).

     

    If you change the Value of the custom property in your code EDEM will always just overwrite that value the next time-step to it's original value.  You can change the Delta though and next time-step the Value(t+1) = Value(t) + Sum ( Delta(t) )

    Regards

    Stephen

  • satri
    satri Altair Community Member
    edited February 26

    Hi Shyam,

     

    Custom properties have a 'Delta' and a 'Value' and we can only change the Delta value (permanent changes that is).

     

    If you change the Value of the custom property in your code EDEM will always just overwrite that value the next time-step to it's original value.  You can change the Delta though and next time-step the Value(t+1) = Value(t) + Sum ( Delta(t) )

    Regards

    Stephen

    So I want it to constantly hold the value 1 or value 7.5 at every single time step

     

    hence i am doing this

    The moment i enter the particle creation function i am getting the delta value

    image

    then I assign it a value of 1 for pt2 and 7.5 for pt3 in the CReplacementFactory.cpp

    image

    Next, when the flow moves to particle body force I am only trying to get the value of the variable inside the body force function

    image

    So I am hoping the custom property will either have a value of 1 or 7.5 but when i look the log the variables pt2 and pt3 have 6 and 7 respectively. how is this possible? i am writing a value of 1 and 7.5 in those variables.

    Please let me know how i can hold the value of 1 or 7.5 in the custom property when the flow moves to CRemoval.cpp

  • satri
    satri Altair Community Member
    edited February 27

    Hi Shyam,

     

    Custom properties have a 'Delta' and a 'Value' and we can only change the Delta value (permanent changes that is).

     

    If you change the Value of the custom property in your code EDEM will always just overwrite that value the next time-step to it's original value.  You can change the Delta though and next time-step the Value(t+1) = Value(t) + Sum ( Delta(t) )

    Regards

    Stephen

    I am thinking that i should reset the custom properties at every time step as given in the tutorial "EDEMAPI Tutorial 7 - HM with Pressure Calculation" But this gives an error not sure why.

    image

    i have not given an override command in the header file

    image

    don't know which is correct among lines 17 or 18.

  • satri
    satri Altair Community Member
    edited February 27

    I am thinking that i should reset the custom properties at every time step as given in the tutorial "EDEMAPI Tutorial 7 - HM with Pressure Calculation" But this gives an error not sure why.

    image

    i have not given an override command in the header file

    image

    don't know which is correct among lines 17 or 18.

    I think the problem is  the data is not being transferred from CReplacementFactory.cpp to CRemoval.cpp.  The reason i say that is when i put a breakpoint and monitor the m_pt2 i see the value that i am assigning.

    Added to this i have a confusion too. Which is not clear from the "EDEMAPI Tutorial 7 - HM with Pressure Calculation" tutorial. I still don't understand completely how the custom property functions. and i am not able to understand from other examples i see. Please explain this to me here.

    When you declare a custom property these are the following things that needs to be done in the code in general

    in the header file you declare this integer as a index (step 1)

    image

    in the main file

    you initialize this name for custom property (step 2)

    image

    you couple the index from header file with the name you declared earlier (step 3)

    image

    you declare a new variable inside the body force function that uses the index created to get the delta value (step 4)

    image

    now use the new variable created such that you can modify the variable

    this is how you assign a value to a custom property.

    Now in my case, I have a custom Factory

    I will do step 1 and step 2 but i cant do step 3 as there is no starting function then i directly do step 4 in CReplacemetFactory.cpp

    now when i go to CRemoval.cpp

    I do step 1,step2,step3 and step4.

    So where is the link between CRemoval.cpp and CReplacementFactory.cpp? In which set should i keep the variables common? please give me an explanation about this.

     

  • Stephen Cole
    Stephen Cole
    Altair Employee
    edited February 27

    I think the problem is  the data is not being transferred from CReplacementFactory.cpp to CRemoval.cpp.  The reason i say that is when i put a breakpoint and monitor the m_pt2 i see the value that i am assigning.

    Added to this i have a confusion too. Which is not clear from the "EDEMAPI Tutorial 7 - HM with Pressure Calculation" tutorial. I still don't understand completely how the custom property functions. and i am not able to understand from other examples i see. Please explain this to me here.

    When you declare a custom property these are the following things that needs to be done in the code in general

    in the header file you declare this integer as a index (step 1)

    image

    in the main file

    you initialize this name for custom property (step 2)

    image

    you couple the index from header file with the name you declared earlier (step 3)

    image

    you declare a new variable inside the body force function that uses the index created to get the delta value (step 4)

    image

    now use the new variable created such that you can modify the variable

    this is how you assign a value to a custom property.

    Now in my case, I have a custom Factory

    I will do step 1 and step 2 but i cant do step 3 as there is no starting function then i directly do step 4 in CReplacemetFactory.cpp

    now when i go to CRemoval.cpp

    I do step 1,step2,step3 and step4.

    So where is the link between CRemoval.cpp and CReplacementFactory.cpp? In which set should i keep the variables common? please give me an explanation about this.

     

    Hi,
     
    For custom properties you need to define getNumberOfRequiredProperties and getDetailsForProperty, if you have a factory and body force then these need to be set for both and to be identical.
     
    getNumberOfRequiredProperties is just the number of particle, contact, geometry or simulation properties to be set as an Integer, however it's important to get this correct otherwise you will see strange memory errors.

     

    image


    getDetailsForProperty requires inputs including the property name as a string, as you define in Step 2.

    image


     
    You can then call the property Value (getValue) or the Delta (getDelta).  You can call the Value or Delta based on the Name or the Index of the property.  

     

    image

     

    In your method you are getting the property index (getPropertyIndex) in the Starting function by passing it the property name.  Calling the property Value or Delta with the Name (a string) is much slower than calling by the Index (an integer), which is why this is done once in the Starting function to convert the string to an integer. The body force is called every time-step for every particle so can be a time consuming code which is why this method is used, but it's not essential.

    Both methods return the same Value or Delta regardless, and the Factory is only called once per time-step rather than once per time-step per particle like the body force so even if you use the slower method it is much less computationally expensive.

     

    If you are seeing strange values (i.e. memory errors) I would check that you have defined the properties correct , correct number of Properties for example and that these are particle properties, or that you are querying the correct particle and that the delta isn't updated elsewhere.

     

    Regards

    Stephen

  • satri
    satri Altair Community Member
    edited February 27
    Hey I have defined those already..I forgot to put it on screenshots let's say we will call it step 5. Still I get error. I don't know why
  • satri
    satri Altair Community Member
    edited February 27
    I don't think the disconnect is in what I am defining.. I am defining all the functions required for custom properties else the simulation would crash. My simulation is running. It's a logical error in the name which connects Replacement factory with removal. Please tell me what could go wrong there amongst all step1-5
  • satri
    satri Altair Community Member
    edited February 27

    This is the index and variable declaration in CReplacementFactory.cpp

    image

    image

    Here is the index and variable definition in CRemoval.cpp

    image

    image

    Both have identical information. So now tell me why the information is not getting transferred from

    CReplacementFactory.cpp to CRemoval.cpp? This is the question i am asking..why is the body force API not seeing the custom property created in the factory API?

  • satri
    satri Altair Community Member
    edited February 28

    Hi,
     
    For custom properties you need to define getNumberOfRequiredProperties and getDetailsForProperty, if you have a factory and body force then these need to be set for both and to be identical.
     
    getNumberOfRequiredProperties is just the number of particle, contact, geometry or simulation properties to be set as an Integer, however it's important to get this correct otherwise you will see strange memory errors.

     

    image


    getDetailsForProperty requires inputs including the property name as a string, as you define in Step 2.

    image


     
    You can then call the property Value (getValue) or the Delta (getDelta).  You can call the Value or Delta based on the Name or the Index of the property.  

     

    image

     

    In your method you are getting the property index (getPropertyIndex) in the Starting function by passing it the property name.  Calling the property Value or Delta with the Name (a string) is much slower than calling by the Index (an integer), which is why this is done once in the Starting function to convert the string to an integer. The body force is called every time-step for every particle so can be a time consuming code which is why this method is used, but it's not essential.

    Both methods return the same Value or Delta regardless, and the Factory is only called once per time-step rather than once per time-step per particle like the body force so even if you use the slower method it is much less computationally expensive.

     

    If you are seeing strange values (i.e. memory errors) I would check that you have defined the properties correct , correct number of Properties for example and that these are particle properties, or that you are querying the correct particle and that the delta isn't updated elsewhere.

     

    Regards

    Stephen

    Hey I have defined all the things properly. I don't think i am making any syntax error by not defining the custom property.

    So why am i still seeing this logical error? the number is not getting transferred from custom factory to particle body force?

  • Stephen Cole
    Stephen Cole
    Altair Employee
    edited February 28

    This is the index and variable declaration in CReplacementFactory.cpp

    image

    image

    Here is the index and variable definition in CRemoval.cpp

    image

    image

    Both have identical information. So now tell me why the information is not getting transferred from

    CReplacementFactory.cpp to CRemoval.cpp? This is the question i am asking..why is the body force API not seeing the custom property created in the factory API?

    Hi Shyam,


    Do you have the resetCustomProperty function set for your code?  I don't think you need it in this case.  If it is set once in the factory to the specified value you shouldn't have to then reset to zero using this function at any point. 

     

    Custom properties can also be modified in the EDEM factory, so just to check you haven't specified any value in the factory?


    Regards

    Stephen 

  • satri
    satri Altair Community Member
    edited February 28

    Hi Shyam,


    Do you have the resetCustomProperty function set for your code?  I don't think you need it in this case.  If it is set once in the factory to the specified value you shouldn't have to then reset to zero using this function at any point. 

     

    Custom properties can also be modified in the EDEM factory, so just to check you haven't specified any value in the factory?


    Regards

    Stephen 

    No, i do not have reset custom property in my code.

     

  • Stephen Cole
    Stephen Cole
    Altair Employee
    edited February 28

    No, i do not have reset custom property in my code.

     

    I would suggest debugging the code to check what the issue is.  If I understand the issue you create particles with a custom property, which would default to 0.

    Then you set the custom property to 1 or 7.5 and the outcome is values of 6 or 7?  It seems like there is data been set for the custom properties coming from somewhere in the code, otherwise without any input custom properties would all be 0.

    If it's difficult to check in the debugger I'd change the values you set (1 and 7.5) to 0's to check the impact, and then change only 1 of the 0's to a 1 to check the impact.  Other areas to check is all getValue and setValue data all relates to the correct custom property as it can be easy to set or get the wrong property, especially if the names are similar.


    Regards

    Stephen