"wrappers/vscode:/vscode.git/clone" did not exist on "1644cc458aa7f3efb5a0583abed5b6bcda829724"
customCVForce.cc 1.6 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
/**
 * Copy the positions and velocities to the inner context.
 */
KERNEL void copyState(GLOBAL real4* RESTRICT posq, GLOBAL real4* RESTRICT innerPosq,
#ifdef USE_MIXED_PRECISION
        GLOBAL real4* RESTRICT posqCorrection, GLOBAL real4* RESTRICT innerPosqCorrection,
#endif
        GLOBAL mixed4* RESTRICT velm, GLOBAL mixed4* RESTRICT innerVelm, GLOBAL int* RESTRICT atomOrder, GLOBAL int* RESTRICT innerInvAtomOrder, int numAtoms) {
    for (int i = GLOBAL_ID; i < numAtoms; i += GLOBAL_SIZE) {
        int index = innerInvAtomOrder[atomOrder[i]];
11
12
13
14
15
16
        real4 p = posq[i];
        p.w = innerPosq[index].w;
        innerPosq[index] = p;
        mixed4 v = velm[i];
        v.w = innerVelm[index].w;
        innerVelm[index] = v;
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#ifdef USE_MIXED_PRECISION
        innerPosqCorrection[index] = posqCorrection[i];
#endif
    }
}

/**
 * Copy the forces back to the main context.
 */
KERNEL void copyForces(GLOBAL mm_long* RESTRICT forces, GLOBAL int* RESTRICT invAtomOrder, GLOBAL mm_long* RESTRICT innerForces,
        GLOBAL int* RESTRICT innerAtomOrder, int numAtoms, int paddedNumAtoms) {
    for (int i = GLOBAL_ID; i < numAtoms; i += GLOBAL_SIZE) {
        int index = invAtomOrder[innerAtomOrder[i]];
        forces[index] = innerForces[i];
        forces[index+paddedNumAtoms] = innerForces[i+paddedNumAtoms];
        forces[index+paddedNumAtoms*2] = innerForces[i+paddedNumAtoms*2];
    }
}

/**
 * Add all the forces from the CVs.
 */
KERNEL void addForces(GLOBAL mm_long* RESTRICT forces, int bufferSize
    PARAMETER_ARGUMENTS) {
    for (int i = GLOBAL_ID; i < bufferSize; i += GLOBAL_SIZE) {
        ADD_FORCES
    }
}