1 |
+ |
/* |
2 |
+ |
* Copyright (c) 2005 The University of Notre Dame. All Rights Reserved. |
3 |
+ |
* |
4 |
+ |
* The University of Notre Dame grants you ("Licensee") a |
5 |
+ |
* non-exclusive, royalty free, license to use, modify and |
6 |
+ |
* redistribute this software in source and binary code form, provided |
7 |
+ |
* that the following conditions are met: |
8 |
+ |
* |
9 |
+ |
* 1. Acknowledgement of the program authors must be made in any |
10 |
+ |
* publication of scientific results based in part on use of the |
11 |
+ |
* program. An acceptable form of acknowledgement is citation of |
12 |
+ |
* the article in which the program was described (Matthew |
13 |
+ |
* A. Meineke, Charles F. Vardeman II, Teng Lin, Christopher |
14 |
+ |
* J. Fennell and J. Daniel Gezelter, "OOPSE: An Object-Oriented |
15 |
+ |
* Parallel Simulation Engine for Molecular Dynamics," |
16 |
+ |
* J. Comput. Chem. 26, pp. 252-271 (2005)) |
17 |
+ |
* |
18 |
+ |
* 2. Redistributions of source code must retain the above copyright |
19 |
+ |
* notice, this list of conditions and the following disclaimer. |
20 |
+ |
* |
21 |
+ |
* 3. Redistributions in binary form must reproduce the above copyright |
22 |
+ |
* notice, this list of conditions and the following disclaimer in the |
23 |
+ |
* documentation and/or other materials provided with the |
24 |
+ |
* distribution. |
25 |
+ |
* |
26 |
+ |
* This software is provided "AS IS," without a warranty of any |
27 |
+ |
* kind. All express or implied conditions, representations and |
28 |
+ |
* warranties, including any implied warranty of merchantability, |
29 |
+ |
* fitness for a particular purpose or non-infringement, are hereby |
30 |
+ |
* excluded. The University of Notre Dame and its licensors shall not |
31 |
+ |
* be liable for any damages suffered by licensee as a result of |
32 |
+ |
* using, modifying or distributing the software or its |
33 |
+ |
* derivatives. In no event will the University of Notre Dame or its |
34 |
+ |
* licensors be liable for any lost revenue, profit or data, or for |
35 |
+ |
* direct, indirect, special, consequential, incidental or punitive |
36 |
+ |
* damages, however caused and regardless of the theory of liability, |
37 |
+ |
* arising out of the use of or inability to use software, even if the |
38 |
+ |
* University of Notre Dame has been advised of the possibility of |
39 |
+ |
* such damages. |
40 |
+ |
*/ |
41 |
+ |
|
42 |
|
#include "types/ShapeAtomType.hpp" |
43 |
+ |
#include "UseTheForce/DarkSide/shapes_interface.h" |
44 |
|
|
45 |
< |
using namespace oopse; |
4 |
< |
|
5 |
< |
ShapeAtomType::~ShapeAtomType() { |
6 |
< |
vector<RealSphericalHarmonic*>::iterator iter; |
7 |
< |
for (iter = contactFuncs.begin(); iter != contactFuncs.end(); ++iter) |
8 |
< |
delete (*iter); |
9 |
< |
for (iter = rangeFuncs.begin(); iter != rangeFuncs.end(); ++iter) |
10 |
< |
delete (*iter); |
11 |
< |
for (iter = strengthFuncs.begin(); iter != strengthFuncs.end(); ++iter) |
12 |
< |
delete (*iter); |
13 |
< |
contactFuncs.clear(); |
14 |
< |
rangeFuncs.clear(); |
15 |
< |
strengthFuncs.clear(); |
16 |
< |
} |
17 |
< |
|
18 |
< |
double ShapeAtomType::getContactValueAt(double costheta, double phi) { |
45 |
> |
namespace oopse { |
46 |
|
|
47 |
< |
vector<RealSphericalHarmonic*>::iterator contactIter; |
48 |
< |
double contactVal; |
47 |
> |
ShapeAtomType::~ShapeAtomType() { |
48 |
> |
std::vector<RealSphericalHarmonic*>::iterator iter; |
49 |
> |
for (iter = contactFuncs.begin(); iter != contactFuncs.end(); ++iter) |
50 |
> |
delete (*iter); |
51 |
> |
for (iter = rangeFuncs.begin(); iter != rangeFuncs.end(); ++iter) |
52 |
> |
delete (*iter); |
53 |
> |
for (iter = strengthFuncs.begin(); iter != strengthFuncs.end(); ++iter) |
54 |
> |
delete (*iter); |
55 |
> |
contactFuncs.clear(); |
56 |
> |
rangeFuncs.clear(); |
57 |
> |
strengthFuncs.clear(); |
58 |
> |
} |
59 |
|
|
60 |
< |
contactVal = 0.0; |
60 |
> |
double ShapeAtomType::getContactValueAt(double costheta, double phi) { |
61 |
> |
|
62 |
> |
std::vector<RealSphericalHarmonic*>::iterator contactIter; |
63 |
> |
double contactVal; |
64 |
> |
|
65 |
> |
contactVal = 0.0; |
66 |
> |
|
67 |
> |
for(contactIter = contactFuncs.begin(); contactIter != contactFuncs.end(); |
68 |
> |
++contactIter) |
69 |
> |
contactVal += (*contactIter)->getValueAt(costheta, phi); |
70 |
> |
|
71 |
> |
return contactVal; |
72 |
> |
} |
73 |
|
|
74 |
< |
for(contactIter = contactFuncs.begin(); contactIter != contactFuncs.end(); |
75 |
< |
++contactIter) |
76 |
< |
contactVal += (*contactIter)->getValueAt(costheta, phi); |
74 |
> |
double ShapeAtomType::getRangeValueAt(double costheta, double phi) { |
75 |
> |
|
76 |
> |
std::vector<RealSphericalHarmonic*>::iterator rangeIter; |
77 |
> |
double rangeVal; |
78 |
> |
|
79 |
> |
rangeVal = 0.0; |
80 |
> |
|
81 |
> |
for(rangeIter = rangeFuncs.begin(); rangeIter != rangeFuncs.end(); |
82 |
> |
++rangeIter) |
83 |
> |
rangeVal += (*rangeIter)->getValueAt(costheta, phi); |
84 |
> |
|
85 |
> |
return rangeVal; |
86 |
> |
} |
87 |
|
|
88 |
< |
return contactVal; |
89 |
< |
} |
90 |
< |
|
91 |
< |
double ShapeAtomType::getRangeValueAt(double costheta, double phi) { |
88 |
> |
double ShapeAtomType::getStrengthValueAt(double costheta, double phi) { |
89 |
> |
|
90 |
> |
std::vector<RealSphericalHarmonic*>::iterator strengthIter; |
91 |
> |
double strengthVal; |
92 |
> |
|
93 |
> |
strengthVal = 0.0; |
94 |
> |
|
95 |
> |
for(strengthIter = strengthFuncs.begin(); |
96 |
> |
strengthIter != strengthFuncs.end(); |
97 |
> |
++strengthIter) |
98 |
> |
strengthVal += (*strengthIter)->getValueAt(costheta, phi); |
99 |
> |
|
100 |
> |
return strengthVal; |
101 |
> |
} |
102 |
|
|
103 |
< |
vector<RealSphericalHarmonic*>::iterator rangeIter; |
104 |
< |
double rangeVal; |
105 |
< |
|
106 |
< |
rangeVal = 0.0; |
107 |
< |
|
108 |
< |
for(rangeIter = rangeFuncs.begin(); rangeIter != rangeFuncs.end(); |
109 |
< |
++rangeIter) |
110 |
< |
rangeVal += (*rangeIter)->getValueAt(costheta, phi); |
111 |
< |
|
112 |
< |
return rangeVal; |
113 |
< |
} |
103 |
> |
void ShapeAtomType::complete() { |
104 |
> |
|
105 |
> |
// first complete all the non-shape atomTypes |
106 |
> |
DirectionalAtomType::complete(); |
107 |
> |
|
108 |
> |
int isError = 0; |
109 |
> |
|
110 |
> |
//setup dipole atom type in fortran side |
111 |
> |
if (isShape()) { |
112 |
> |
// vectors for shape transfer to fortran |
113 |
> |
std::vector<RealSphericalHarmonic*> tempSHVector; |
114 |
> |
std::vector<int> contactL; |
115 |
> |
std::vector<int> contactM; |
116 |
> |
std::vector<int> contactFunc; |
117 |
> |
std::vector<double> contactCoeff; |
118 |
> |
std::vector<int> rangeL; |
119 |
> |
std::vector<int> rangeM; |
120 |
> |
std::vector<int> rangeFunc; |
121 |
> |
std::vector<double> rangeCoeff; |
122 |
> |
std::vector<int> strengthL; |
123 |
> |
std::vector<int> strengthM; |
124 |
> |
std::vector<int> strengthFunc; |
125 |
> |
std::vector<double> strengthCoeff; |
126 |
> |
|
127 |
> |
tempSHVector.clear(); |
128 |
> |
contactL.clear(); |
129 |
> |
contactM.clear(); |
130 |
> |
contactFunc.clear(); |
131 |
> |
contactCoeff.clear(); |
132 |
> |
|
133 |
> |
tempSHVector = getContactFuncs(); |
134 |
> |
|
135 |
> |
int nContact = tempSHVector.size(); |
136 |
> |
for (int i=0; i<nContact; i++){ |
137 |
> |
contactL.push_back(tempSHVector[i]->getL()); |
138 |
> |
contactM.push_back(tempSHVector[i]->getM()); |
139 |
> |
contactFunc.push_back(tempSHVector[i]->getFunctionType()); |
140 |
> |
contactCoeff.push_back(tempSHVector[i]->getCoefficient()); |
141 |
> |
} |
142 |
> |
|
143 |
> |
tempSHVector.clear(); |
144 |
> |
rangeL.clear(); |
145 |
> |
rangeM.clear(); |
146 |
> |
rangeFunc.clear(); |
147 |
> |
rangeCoeff.clear(); |
148 |
> |
|
149 |
> |
tempSHVector = getRangeFuncs(); |
150 |
> |
|
151 |
> |
int nRange = tempSHVector.size(); |
152 |
> |
for (int i=0; i<nRange; i++){ |
153 |
> |
rangeL.push_back(tempSHVector[i]->getL()); |
154 |
> |
rangeM.push_back(tempSHVector[i]->getM()); |
155 |
> |
rangeFunc.push_back(tempSHVector[i]->getFunctionType()); |
156 |
> |
rangeCoeff.push_back(tempSHVector[i]->getCoefficient()); |
157 |
> |
} |
158 |
> |
|
159 |
> |
tempSHVector.clear(); |
160 |
> |
strengthL.clear(); |
161 |
> |
strengthM.clear(); |
162 |
> |
strengthFunc.clear(); |
163 |
> |
strengthCoeff.clear(); |
164 |
> |
|
165 |
> |
tempSHVector = getStrengthFuncs(); |
166 |
> |
|
167 |
> |
int nStrength = tempSHVector.size(); |
168 |
> |
for (int i=0; i<nStrength; i++){ |
169 |
> |
strengthL.push_back(tempSHVector[i]->getL()); |
170 |
> |
strengthM.push_back(tempSHVector[i]->getM()); |
171 |
> |
strengthFunc.push_back(tempSHVector[i]->getFunctionType()); |
172 |
> |
strengthCoeff.push_back(tempSHVector[i]->getCoefficient()); |
173 |
> |
} |
174 |
> |
|
175 |
> |
int myATID = getIdent(); |
176 |
> |
|
177 |
> |
|
178 |
> |
std::cout << "calling makeShape with myATID = " << myATID << "\n"; |
179 |
|
|
180 |
< |
double ShapeAtomType::getStrengthValueAt(double costheta, double phi) { |
181 |
< |
|
182 |
< |
vector<RealSphericalHarmonic*>::iterator strengthIter; |
183 |
< |
double strengthVal; |
184 |
< |
|
185 |
< |
strengthVal = 0.0; |
186 |
< |
|
187 |
< |
for(strengthIter = strengthFuncs.begin(); |
188 |
< |
strengthIter != strengthFuncs.end(); |
189 |
< |
++strengthIter) |
190 |
< |
strengthVal += (*strengthIter)->getValueAt(costheta, phi); |
191 |
< |
|
192 |
< |
return strengthVal; |
180 |
> |
makeShape( &nContact, &contactL[0], &contactM[0], &contactFunc[0], |
181 |
> |
&contactCoeff[0], |
182 |
> |
&nRange, &rangeL[0], &rangeM[0], &rangeFunc[0], &rangeCoeff[0], |
183 |
> |
&nStrength, &strengthL[0], &strengthM[0], &strengthFunc[0], |
184 |
> |
&strengthCoeff[0], |
185 |
> |
&myATID, |
186 |
> |
&isError); |
187 |
> |
|
188 |
> |
if( isError ){ |
189 |
> |
sprintf( painCave.errMsg, |
190 |
> |
"Error initializing the \"%s\" shape in fortran\n", |
191 |
> |
(getName()).c_str() ); |
192 |
> |
painCave.severity = OOPSE_ERROR; |
193 |
> |
painCave.isFatal = 1; |
194 |
> |
simError(); |
195 |
> |
} |
196 |
> |
} |
197 |
> |
} |
198 |
|
} |