customExternalForce.cl 775 Bytes
Newer Older
1
2
3
4
5
/**
 * Compute custom external forces.
 */

__kernel void computeCustomExternalForces(int numTerms, __global float4* forceBuffers, __global float* energyBuffer,
6
        __global float4* posq, __global int* indices
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
        EXTRA_ARGUMENTS) {
    float energy = 0.0f;
    for (int index = get_global_id(0); index < numTerms; index += get_global_size(0)) {
        // Look up the data for this particle.

        int atom = indices[index];
        float4 pos = posq[atom];

        // Compute the force.

        COMPUTE_FORCE

        // Record the force on the atom.

        float4 force = forceBuffers[atom];
        force.x -= dEdX;
        force.y -= dEdY;
        force.z -= dEdZ;
        forceBuffers[atom] = force;
    }
    energyBuffer[get_global_id(0)] += energy;
}