How to pass a variable to a different __device__ in CUDA Code?
Hi,
i'm sure it's a rather simple question but i need to calculate the contact forces between the geometry and all particles interacting with this geometry. I use the following code in the calculateForce device:
However i now need to use the momentary (cumulated) value of the contact force to scale my particles. I think this is only possible in the externalForce device as it has the setScale-function. How can i pass the cumulated total Force to externalForce and use it to scale my particles?
Thank you
Best Answer
-
Hi,
Custom properties with the same name are the same custom property. By that I mean if you want to access your 'Force' custom property, that you have defined in your contact model, in a particle body force, then you simply need to setup the custom property again for a body force plugin. So if it's called "myForce" in the .cpp, register it again for a PBF plugin, access whatever the correct index is in externalForce( ) in the .cu file and use the value there.
Cheers,
Richard
1
Answers
-
Hi,
Custom properties with the same name are the same custom property. By that I mean if you want to access your 'Force' custom property, that you have defined in your contact model, in a particle body force, then you simply need to setup the custom property again for a body force plugin. So if it's called "myForce" in the .cpp, register it again for a PBF plugin, access whatever the correct index is in externalForce( ) in the .cu file and use the value there.
Cheers,
Richard
1 -
Hi Richard,
thanks seems to work just fine!
Is there a function to access the geometry directly and not via the ID function? I found a getTypeIndex (Returns the index of the particletype/geometry group. ) function but i don't know the index of my geometry group. Where can i find that?
Thank you
0 -
Clemens Lischka_21336 said:
Hi Richard,
thanks seems to work just fine!
Is there a function to access the geometry directly and not via the ID function? I found a getTypeIndex (Returns the index of the particletype/geometry group. ) function but i don't know the index of my geometry group. Where can i find that?
Thank you
Hi,
On CPU, through the geometryManager( ) you can access quite a few different helper functions. I think the one you're going to want to use is:
So what I'd do is something like:
1) Declare a member variable in my plugin to hold the manager, so I can use it anywhere in your plugin2) Initialise it in starting( ), with something like the following (although this is for a different manager that I'm using in the plugin I'm working on)
3) Pass in your geometry/geometries to the get geometry index call for whichever geometries you want. There is also a function to get all your geometry names in the manager too, to simplify this
4) Once you know which index is which, pass it across to the GPU through one of the parameterData functions and use it how you need.
Hopefully that makes sense, though I realise it's a little convoluted.Cheers,
Richard
Edit: I'm using v1.4 of the geometry manager here. Depending on which version of EDEM/the API you're using, you might not have all these functions.1 -
Richard Wood_20774 said:
Hi,
On CPU, through the geometryManager( ) you can access quite a few different helper functions. I think the one you're going to want to use is:
So what I'd do is something like:
1) Declare a member variable in my plugin to hold the manager, so I can use it anywhere in your plugin2) Initialise it in starting( ), with something like the following (although this is for a different manager that I'm using in the plugin I'm working on)
3) Pass in your geometry/geometries to the get geometry index call for whichever geometries you want. There is also a function to get all your geometry names in the manager too, to simplify this
4) Once you know which index is which, pass it across to the GPU through one of the parameterData functions and use it how you need.
Hopefully that makes sense, though I realise it's a little convoluted.Cheers,
Richard
Edit: I'm using v1.4 of the geometry manager here. Depending on which version of EDEM/the API you're using, you might not have all these functions.Thank you Richard, very much appreciate your help and answer.
I ended up using the ID and isParticle function approach, as it is working with CUDA as well. I forgot that "element.1" is always a particle, so it gave me weird results in the first run..
Works now!
Regards
1 -
Clemens Lischka_21336 said:
Thank you Richard, very much appreciate your help and answer.
I ended up using the ID and isParticle function approach, as it is working with CUDA as well. I forgot that "element.1" is always a particle, so it gave me weird results in the first run..
Works now!
Regards
Glad to hear you got it working
0