1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 package ffx.potential.nonbonded.pme;
39
40 import edu.rit.pj.IntegerForLoop;
41 import edu.rit.pj.IntegerSchedule;
42 import edu.rit.pj.ParallelRegion;
43 import edu.rit.pj.ParallelTeam;
44 import ffx.crystal.Crystal;
45 import ffx.crystal.SymOp;
46 import ffx.potential.bonded.Atom;
47 import java.util.List;
48 import java.util.logging.Level;
49 import java.util.logging.Logger;
50
51
52
53
54
55
56
57
58 public class ExpandInducedDipolesRegion extends ParallelRegion {
59
60 private static final Logger logger = Logger.getLogger(ExpandInducedDipolesRegion.class.getName());
61 private final ExpandInducedDipoleLoop[] expandInducedDipoleLoop;
62
63 public double[][][] inducedDipole;
64
65 public double[][][] inducedDipoleCR;
66
67 private Atom[] atoms;
68
69 private Crystal crystal;
70
71 public ExpandInducedDipolesRegion(int maxThreads) {
72 expandInducedDipoleLoop = new ExpandInducedDipoleLoop[maxThreads];
73 for (int i = 0; i < maxThreads; i++) {
74 expandInducedDipoleLoop[i] = new ExpandInducedDipoleLoop();
75 }
76 }
77
78
79
80
81
82
83 public void executeWith(ParallelTeam parallelTeam) {
84 try {
85 parallelTeam.execute(this);
86 } catch (Exception e) {
87 String message = " Exception expanding induced dipoles.\n";
88 logger.log(Level.WARNING, message, e);
89 }
90 }
91
92 public void init(
93 Atom[] atoms, Crystal crystal, double[][][] inducedDipole, double[][][] inducedDipoleCR) {
94
95 this.atoms = atoms;
96 this.crystal = crystal;
97
98 this.inducedDipole = inducedDipole;
99 this.inducedDipoleCR = inducedDipoleCR;
100 }
101
102 @Override
103 public void run() {
104 try {
105 int nAtoms = atoms.length;
106 execute(0, nAtoms - 1, expandInducedDipoleLoop[getThreadIndex()]);
107 } catch (Exception e) {
108 String message =
109 "Fatal exception expanding coordinates in thread: " + getThreadIndex() + "\n";
110 logger.log(Level.SEVERE, message, e);
111 }
112 }
113
114 private class ExpandInducedDipoleLoop extends IntegerForLoop {
115
116 @Override
117 public void run(int lb, int ub) {
118 List<SymOp> symOps = crystal.spaceGroup.symOps;
119 int nSymm = symOps.size();
120 for (int s = 1; s < nSymm; s++) {
121 SymOp symOp = symOps.get(s);
122 for (int ii = lb; ii <= ub; ii++) {
123 crystal.applySymRot(inducedDipole[0][ii], inducedDipole[s][ii], symOp);
124 crystal.applySymRot(inducedDipoleCR[0][ii], inducedDipoleCR[s][ii], symOp);
125 }
126 }
127 }
128
129 @Override
130 public IntegerSchedule schedule() {
131 return IntegerSchedule.fixed();
132 }
133 }
134 }