GPU CUDA Main Functions
The main function naming in the CUDA API follows a convention where the file name should not prefix the main function names.
Examples of main functions inputs
__device__
void calculateForce(NCudaApiTypesV1_0_0::CApiElement& element1,
NCudaApiTypesV1_0_0::CApiElement& element2,
NCudaApiTypesV1_0_0::CApiInteraction& interaction,
NCudaApiTypesV1_0_0::CApiContact& contactData,
NCudaApiTypesV1_0_0::CApiSimulation& simulationData,
NCudaApiTypesV1_0_0::CApiContactResults& contactResult)
{
}
Particle Body Force models must contain the following function:
__device__
void externalForce(NCudaApiTypesV1_0_0::CApiParticle& particle,
NCudaApiTypesV1_0_0::CApiSimulation& simulation,
NCudaApiTypesV1_0_0::CApiFieldData& fieldData,
NCudaApiTypesV1_0_0::CApiTotalForce& result){..}
{
}
In addition to these functions, the configForTimestep
functions
allow custom functionality to be modified at each Time Step. Even if they are not
used, it is mandatory to include the following functions:
__device__
void configForTimeStepParticleProperty(NCudaApiTypesV1_0_0::CApiCustomPropertyData& particleProperties)
{
}
__device__
void configForTimeStepTriangleProperty(NCudaApiTypesV1_0_0::CApiCustomPropertyData& triangleProperties)
{
}
The configForTimeStepParticleProperty
is used for both contact and
external force models, so when it is used in a plugin that combines
calculateForce
and externalForce
models, those
models must have the same custom properties and custom property order, otherwise the
wrong values can get modified.
The configForTimeStepTriangleProperty
does not get the actual
element custom property values, rather the difference between values between Time
Steps (this is not the same as triangle contact deltas). This was done for easier
mGPU implementation as the triangle custom property values are unused in any
calculations and are intended for post-simulation analysis.