11 |
|
#include <stdio.h> |
12 |
|
#include <string.h> |
13 |
|
#include <map> |
14 |
+ |
#include <cmath> |
15 |
|
#include <iostream> |
16 |
|
|
16 |
– |
using namespace std; |
17 |
– |
using namespace oopse; |
18 |
– |
|
17 |
|
#ifdef IS_MPI |
18 |
|
#include <mpi.h> |
19 |
|
#endif //is_mpi |
21 |
|
#include "UseTheForce/ForceFields.hpp" |
22 |
|
#include "primitives/SRI.hpp" |
23 |
|
#include "utils/simError.h" |
24 |
+ |
#include "utils/StringUtils.hpp" |
25 |
|
#include "io/basic_ifstrstream.hpp" |
26 |
|
#include "math/RealSphericalHarmonic.hpp" |
27 |
|
#include "math/SquareMatrix3.hpp" |
28 |
< |
|
28 |
> |
#include "types/ShapeAtomType.hpp" |
29 |
|
#include "UseTheForce/DarkSide/atype_interface.h" |
30 |
|
#include "UseTheForce/DarkSide/shapes_interface.h" |
31 |
|
|
33 |
|
#include "UseTheForce/mpiForceField.h" |
34 |
|
#endif // is_mpi |
35 |
|
|
36 |
< |
Shapes_FF::Shapes_FF() { |
37 |
< |
Shapes_FF(""); |
39 |
< |
} |
36 |
> |
using namespace std; |
37 |
> |
using namespace oopse; |
38 |
|
|
41 |
– |
Shapes_FF::Shapes_FF(char* the_variant){ |
42 |
– |
ffPath_env = "FORCE_PARAM_PATH"; |
43 |
– |
|
44 |
– |
} |
45 |
– |
|
39 |
|
Shapes_FF::~Shapes_FF(){ |
40 |
|
|
41 |
|
#ifdef IS_MPI |
42 |
|
if( worldRank == 0 ){ |
43 |
|
#endif // is_mpi |
44 |
|
|
45 |
< |
fclose( frcFile ); |
45 |
> |
forceFile.close(); |
46 |
|
|
47 |
|
#ifdef IS_MPI |
48 |
|
} |
66 |
|
} |
67 |
|
|
68 |
|
|
69 |
< |
void Shapes_FF::readForceFile( void ){ |
69 |
> |
void Shapes_FF::readParams( void ){ |
70 |
|
|
71 |
|
char readLine[1024]; |
72 |
< |
char fileName[200]; |
73 |
< |
char temp[200]; |
74 |
< |
char* ffPath; |
75 |
< |
char *shapeFileName; |
72 |
> |
|
73 |
> |
string fileName; |
74 |
> |
string shapeFileName; |
75 |
> |
string tempString; |
76 |
> |
|
77 |
|
char *nameToken; |
78 |
|
char *delim = " ,;\t\n"; |
79 |
|
int nTokens, i; |
81 |
|
int nRange = 0; |
82 |
|
int nStrength = 0; |
83 |
|
int myATID; |
84 |
+ |
int isError; |
85 |
|
string nameString; |
86 |
< |
ShapeType* st; |
87 |
< |
map<string, AtomType*> atomTypeMap; |
86 |
> |
AtomType* at; |
87 |
> |
DirectionalAtomType* dat; |
88 |
> |
ShapeAtomType* st; |
89 |
> |
|
90 |
|
map<string, AtomType*>::iterator iter; |
91 |
|
|
92 |
|
// vectors for shape transfer to fortran |
93 |
< |
vector<RealSphericalHarmonic> tempSHVector; |
93 |
> |
vector<RealSphericalHarmonic*> tempSHVector; |
94 |
|
vector<int> contactL; |
95 |
|
vector<int> contactM; |
96 |
|
vector<int> contactFunc; |
103 |
|
vector<int> strengthM; |
104 |
|
vector<int> strengthFunc; |
105 |
|
vector<double> strengthCoeff; |
109 |
– |
|
110 |
– |
// build a basic file reader |
111 |
– |
ifstrsteam frcReader; |
106 |
|
|
107 |
|
// generate the force file name |
108 |
< |
strcpy( fileName, "Shapes.frc" ); |
108 |
> |
fileName = "Shapes.frc"; |
109 |
|
|
110 |
|
// attempt to open the file in the current directory first. |
111 |
< |
frcReader.open( fileName ); |
111 |
> |
forceFile.open( fileName.c_str() ); |
112 |
|
|
113 |
< |
if( frcReader == NULL ){ |
113 |
> |
if( forceFile == NULL ){ |
114 |
|
|
115 |
< |
// next see if the force path enviorment variable is set |
115 |
> |
tempString = ffPath; |
116 |
> |
tempString += "/"; |
117 |
> |
tempString += fileName; |
118 |
> |
fileName = tempString; |
119 |
|
|
120 |
< |
ffPath = getenv( ffPath_env ); |
124 |
< |
if( ffPath == NULL ) { |
125 |
< |
STR_DEFINE(ffPath, FRC_PATH ); |
126 |
< |
} |
127 |
< |
|
128 |
< |
strcpy( temp, ffPath ); |
129 |
< |
strcat( temp, "/" ); |
130 |
< |
strcat( temp, fileName ); |
131 |
< |
strcpy( fileName, temp ); |
120 |
> |
forceFile.open( fileName.c_str() ); |
121 |
|
|
122 |
< |
frcReader.open( fileName ); |
134 |
< |
|
135 |
< |
if( frcFile == NULL ){ |
122 |
> |
if( forceFile == NULL ){ |
123 |
|
|
124 |
|
sprintf( painCave.errMsg, |
125 |
|
"Error opening the force field parameter file:\n" |
126 |
|
"\t%s\n" |
127 |
|
"\tHave you tried setting the FORCE_PARAM_PATH environment " |
128 |
|
"variable?\n", |
129 |
< |
fileName ); |
129 |
> |
fileName.c_str() ); |
130 |
|
painCave.severity = OOPSE_ERROR; |
131 |
|
painCave.isFatal = 1; |
132 |
|
simError(); |
135 |
|
|
136 |
|
// read in the shape types. |
137 |
|
|
138 |
< |
findBegin( "ShapeTypes" ); |
138 |
> |
findBegin( forceFile, "ShapeTypes" ); |
139 |
|
|
140 |
< |
while( !frcReader.eof() ){ |
141 |
< |
frcReader.getline( readLine, sizeof(readLine) ); |
140 |
> |
while( !forceFile.eof() ){ |
141 |
> |
forceFile.getline( readLine, sizeof(readLine) ); |
142 |
|
|
143 |
|
// toss comment lines |
144 |
|
if( readLine[0] != '!' && readLine[0] != '#' ){ |
145 |
|
|
146 |
|
if (isEndLine(readLine)) break; |
147 |
|
|
148 |
< |
nTokens = count_tokens(readLine, " ,;\t"); |
148 |
> |
nTokens = countTokens(readLine, " ,;\t"); |
149 |
|
if (nTokens != 0) { |
150 |
|
if (nTokens < 2) { |
151 |
|
sprintf( painCave.errMsg, |
152 |
< |
"Not enough data on a ShapeTypes line in file: %s\n" |
153 |
< |
fileName ); |
152 |
> |
"Not enough data on a ShapeTypes line in file: %s\n", |
153 |
> |
fileName.c_str() ); |
154 |
|
painCave.severity = OOPSE_ERROR; |
155 |
|
painCave.isFatal = 1; |
156 |
|
simError(); |
167 |
|
if (iter == atomTypeMap.end()) { |
168 |
|
// no, it doesn't, so we may proceed: |
169 |
|
|
170 |
< |
st = new ShapeType(); |
170 |
> |
st = new ShapeAtomType(); |
171 |
|
|
172 |
|
st->setName(nameString); |
173 |
|
myATID = atomTypeMap.size(); |
181 |
|
// declared in a previous block, and we just need to add |
182 |
|
// the shape-specific information for this AtomType: |
183 |
|
|
184 |
< |
st = (ShapeType*)(iter->second); |
184 |
> |
st = (ShapeAtomType*)(iter->second); |
185 |
|
parseShapeFile(shapeFileName, st); |
186 |
|
} |
187 |
|
} |
200 |
|
// pack up and send the necessary info to fortran |
201 |
|
for (iter = atomTypeMap.begin(); iter != atomTypeMap.end(); ++iter){ |
202 |
|
|
203 |
< |
at = (AtomType*)(iter.second); |
203 |
> |
at = (AtomType*)(iter->second); |
204 |
|
|
205 |
|
if (at->isDirectional()) { |
206 |
|
|
219 |
|
|
220 |
|
nContact = tempSHVector.size(); |
221 |
|
for (i=0; i<nContact; i++){ |
222 |
< |
contactL.push_back(tempSHVector[i].getL()); |
223 |
< |
contactM.push_back(tempSHVector[i].getM()); |
224 |
< |
contactFunc.push_back(tempSHVector[i].getFunctionType()); |
225 |
< |
contactCoeff.push_back(tempSHVector[i].getCoefficient()); |
222 |
> |
contactL.push_back(tempSHVector[i]->getL()); |
223 |
> |
contactM.push_back(tempSHVector[i]->getM()); |
224 |
> |
contactFunc.push_back(tempSHVector[i]->getFunctionType()); |
225 |
> |
contactCoeff.push_back(tempSHVector[i]->getCoefficient()); |
226 |
|
} |
227 |
|
|
228 |
|
rangeL.clear(); |
234 |
|
|
235 |
|
nRange = tempSHVector.size(); |
236 |
|
for (i=0; i<nRange; i++){ |
237 |
< |
rangeL.push_back(tempSHVector[i].getL()); |
238 |
< |
rangeM.push_back(tempSHVector[i].getM()); |
239 |
< |
rangeFunc.push_back(tempSHVector[i].getFunctionType()); |
240 |
< |
rangeCoeff.push_back(tempSHVector[i].getCoefficient()); |
237 |
> |
rangeL.push_back(tempSHVector[i]->getL()); |
238 |
> |
rangeM.push_back(tempSHVector[i]->getM()); |
239 |
> |
rangeFunc.push_back(tempSHVector[i]->getFunctionType()); |
240 |
> |
rangeCoeff.push_back(tempSHVector[i]->getCoefficient()); |
241 |
|
} |
242 |
|
|
243 |
|
strengthL.clear(); |
249 |
|
|
250 |
|
nStrength = tempSHVector.size(); |
251 |
|
for (i=0; i<nStrength; i++){ |
252 |
< |
strengthL.push_back(tempSHVector[i].getL()); |
253 |
< |
strengthM.push_back(tempSHVector[i].getM()); |
254 |
< |
strengthFunc.push_back(tempSHVector[i].getFunctionType()); |
255 |
< |
strengthCoeff.push_back(tempSHVector[i].getCoefficient()); |
252 |
> |
strengthL.push_back(tempSHVector[i]->getL()); |
253 |
> |
strengthM.push_back(tempSHVector[i]->getM()); |
254 |
> |
strengthFunc.push_back(tempSHVector[i]->getFunctionType()); |
255 |
> |
strengthCoeff.push_back(tempSHVector[i]->getCoefficient()); |
256 |
|
} |
257 |
|
|
258 |
|
isError = 0; |
259 |
|
myATID = at->getIdent(); |
260 |
< |
makeShape( &nContact, &contactL, &contactM, &contactFunc, |
261 |
< |
&contactCoeff, |
262 |
< |
&nRange, &rangeL, &rangeM, &rangeFunc, &rangeCoeff, |
263 |
< |
&nStrength, &strengthL, &strengthM, |
264 |
< |
&strengthFunc, &strengthCoeff, |
260 |
> |
makeShape( &nContact, &contactL[0], &contactM[0], &contactFunc[0], |
261 |
> |
&contactCoeff[0], |
262 |
> |
&nRange, &rangeL[0], &rangeM[0], &rangeFunc[0], |
263 |
> |
&rangeCoeff[0], |
264 |
> |
&nStrength, &strengthL[0], &strengthM[0], |
265 |
> |
&strengthFunc[0], &strengthCoeff[0], |
266 |
|
&myATID, |
267 |
|
&isError); |
268 |
|
if( isError ){ |
269 |
|
sprintf( painCave.errMsg, |
270 |
|
"Error initializing the \"%s\" shape in fortran\n", |
271 |
< |
marker->first ); |
271 |
> |
(iter->first).c_str() ); |
272 |
|
painCave.isFatal = 1; |
273 |
|
simError(); |
274 |
|
} |
284 |
|
|
285 |
|
} |
286 |
|
|
287 |
< |
void SHAPES_FF::initializeAtoms( int nAtoms, Atom** the_atoms ){ |
287 |
> |
void Shapes_FF::cleanMe( void ){ |
288 |
> |
|
289 |
> |
} |
290 |
> |
|
291 |
> |
void Shapes_FF::initializeAtoms( int nAtoms, Atom** the_atoms ){ |
292 |
|
|
293 |
|
int i,j,k; |
294 |
+ |
map<string, AtomType*>::iterator iter; |
295 |
|
|
296 |
|
// initialize the atoms |
297 |
|
DirectionalAtom* dAtom; |
298 |
|
AtomType* at; |
299 |
|
DirectionalAtomType* dat; |
300 |
< |
double mySigma; |
300 |
> |
ShapeAtomType* sat; |
301 |
> |
double sigma; |
302 |
|
double ji[3]; |
303 |
|
double inertialMat[3][3]; |
304 |
|
Mat3x3d momInt; |
321 |
|
|
322 |
|
the_atoms[i]->setMass( at->getMass() ); |
323 |
|
the_atoms[i]->setIdent( at->getIdent() ); |
324 |
+ |
|
325 |
+ |
if ( at->isShape() ) { |
326 |
+ |
|
327 |
+ |
sat = (ShapeAtomType*)at; |
328 |
+ |
sigma = findLargestContactDistance(sat); |
329 |
+ |
if (sigma > bigSigma) bigSigma = sigma; |
330 |
|
|
331 |
– |
if( at->isLennardJones() ) { |
332 |
– |
mySigma = at->properties->getPropertyByName("sigma"); |
333 |
– |
if( bigSigma < mySigma ) bigSigma = mySigma; |
331 |
|
} |
332 |
|
|
333 |
|
the_atoms[i]->setHasCharge(at->isCharge()); |
336 |
|
|
337 |
|
dat = (DirectionalAtomType*)at; |
338 |
|
dAtom = (DirectionalAtom *) the_atoms[i]; |
339 |
< |
|
339 |
> |
|
340 |
|
momInt = dat->getI(); |
341 |
|
|
342 |
|
// zero out the moments of inertia matrix |
392 |
|
} |
393 |
|
} |
394 |
|
|
395 |
< |
int Shapes_FF::parseShapeFile(char *shapeFile, ShapeAtomType* st){ |
395 |
> |
void Shapes_FF::parseShapeFile(string shapeFileName, ShapeAtomType* st){ |
396 |
|
const int MAXLEN = 1024; |
397 |
|
char inLine[MAXLEN]; |
398 |
|
char *token; |
399 |
|
char *delim = " ,;\t\n"; |
400 |
+ |
int nTokens; |
401 |
|
Mat3x3d momInert; |
402 |
< |
RealSphericalHarmonic tempHarmonic; |
403 |
< |
vector<RealSphericalHarmonic> functionVector; |
406 |
< |
|
402 |
> |
RealSphericalHarmonic* rsh; |
403 |
> |
vector<RealSphericalHarmonic*> functionVector; |
404 |
|
ifstrstream shapeFile; |
405 |
+ |
string tempString; |
406 |
+ |
|
407 |
+ |
shapeFile.open( shapeFileName.c_str() ); |
408 |
+ |
|
409 |
+ |
if( shapeFile == NULL ){ |
410 |
+ |
|
411 |
+ |
tempString = ffPath; |
412 |
+ |
tempString += "/"; |
413 |
+ |
tempString += shapeFileName; |
414 |
+ |
shapeFileName = tempString; |
415 |
+ |
|
416 |
+ |
shapeFile.open( shapeFileName.c_str() ); |
417 |
+ |
|
418 |
+ |
if( shapeFile == NULL ){ |
419 |
+ |
|
420 |
+ |
sprintf( painCave.errMsg, |
421 |
+ |
"Error opening the shape file:\n" |
422 |
+ |
"\t%s\n" |
423 |
+ |
"\tHave you tried setting the FORCE_PARAM_PATH environment " |
424 |
+ |
"variable?\n", |
425 |
+ |
shapeFileName.c_str() ); |
426 |
+ |
painCave.severity = OOPSE_ERROR; |
427 |
+ |
painCave.isFatal = 1; |
428 |
+ |
simError(); |
429 |
+ |
} |
430 |
+ |
} |
431 |
|
|
432 |
+ |
// read in the shape types. |
433 |
+ |
|
434 |
|
// first grab the values in the ShapeInfo section |
435 |
< |
findBegin(shapeFile, "ShapeInfo"); |
435 |
> |
findBegin( shapeFile, "ShapeInfo"); |
436 |
|
|
437 |
|
shapeFile.getline(inLine, MAXLEN); |
438 |
|
while( !shapeFile.eof() ) { |
441 |
|
// end marks section completion |
442 |
|
if (isEndLine(inLine)) break; |
443 |
|
|
444 |
< |
nTokens = count_tokens(inLine, delim); |
444 |
> |
nTokens = countTokens(inLine, delim); |
445 |
|
if (nTokens != 0) { |
446 |
|
if (nTokens < 5) { |
447 |
|
sprintf( painCave.errMsg, |
448 |
< |
"Not enough data on a ShapeInfo line in file: %s\n" |
449 |
< |
fileName ); |
448 |
> |
"Not enough data on a ShapeInfo line in file: %s\n", |
449 |
> |
shapeFileName.c_str() ); |
450 |
|
painCave.severity = OOPSE_ERROR; |
451 |
|
painCave.isFatal = 1; |
452 |
|
simError(); |
464 |
|
} |
465 |
|
} |
466 |
|
} |
467 |
+ |
shapeFile.getline(inLine, MAXLEN); |
468 |
|
} |
469 |
|
|
470 |
|
// now grab the contact functions |
478 |
|
// end marks section completion |
479 |
|
if (isEndLine(inLine)) break; |
480 |
|
|
481 |
< |
nTokens = count_tokens(inLine, delim); |
481 |
> |
nTokens = countTokens(inLine, delim); |
482 |
|
if (nTokens != 0) { |
483 |
|
if (nTokens < 4) { |
484 |
|
sprintf( painCave.errMsg, |
485 |
< |
"Not enough data on a ContactFunctions line in file: %s\n" |
486 |
< |
fileName ); |
485 |
> |
"Not enough data on a ContactFunctions line in file: %s\n", |
486 |
> |
shapeFileName.c_str() ); |
487 |
|
painCave.severity = OOPSE_ERROR; |
488 |
|
painCave.isFatal = 1; |
489 |
|
simError(); |
490 |
|
|
491 |
|
// read in a spherical harmonic function |
492 |
|
token = strtok(inLine, delim); |
493 |
< |
tempHarmonic.setL(atoi(token)); |
493 |
> |
rsh = new RealSphericalHarmonic(); |
494 |
> |
rsh->setL(atoi(token)); |
495 |
|
token = strtok(NULL, delim); |
496 |
< |
tempHarmonic.setM(atoi(token)); |
496 |
> |
rsh->setM(atoi(token)); |
497 |
|
token = strtok(NULL, delim); |
498 |
|
if (!strcasecmp("sin",token)) |
499 |
< |
tempHarmonic.makeSinFunction(); |
499 |
> |
rsh->makeSinFunction(); |
500 |
|
else |
501 |
< |
tempHarmonic.makeCosFunction(); |
501 |
> |
rsh->makeCosFunction(); |
502 |
|
token = strtok(NULL, delim); |
503 |
< |
tempHarmonic.setCoefficient(atof(token)); |
503 |
> |
rsh->setCoefficient(atof(token)); |
504 |
|
|
505 |
< |
functionVector.push_back(tempHarmonic); |
505 |
> |
functionVector.push_back(rsh); |
506 |
|
} |
507 |
|
} |
508 |
|
} |
509 |
+ |
shapeFile.getline(inLine, MAXLEN); |
510 |
|
} |
511 |
|
|
512 |
|
// pass contact functions to ShapeType |
523 |
|
// end marks section completion |
524 |
|
if (isEndLine(inLine)) break; |
525 |
|
|
526 |
< |
nTokens = count_tokens(inLine, delim); |
526 |
> |
nTokens = countTokens(inLine, delim); |
527 |
|
if (nTokens != 0) { |
528 |
|
if (nTokens < 4) { |
529 |
|
sprintf( painCave.errMsg, |
530 |
< |
"Not enough data on a RangeFunctions line in file: %s\n" |
531 |
< |
fileName ); |
530 |
> |
"Not enough data on a RangeFunctions line in file: %s\n", |
531 |
> |
shapeFileName.c_str() ); |
532 |
|
painCave.severity = OOPSE_ERROR; |
533 |
|
painCave.isFatal = 1; |
534 |
|
simError(); |
535 |
|
|
536 |
|
// read in a spherical harmonic function |
537 |
|
token = strtok(inLine, delim); |
538 |
< |
tempHarmonic.setL(atoi(token)); |
538 |
> |
|
539 |
> |
rsh = new RealSphericalHarmonic(); |
540 |
> |
rsh->setL(atoi(token)); |
541 |
|
token = strtok(NULL, delim); |
542 |
< |
tempHarmonic.setM(atoi(token)); |
542 |
> |
rsh->setM(atoi(token)); |
543 |
|
token = strtok(NULL, delim); |
544 |
|
if (!strcasecmp("sin",token)) |
545 |
< |
tempHarmonic.makeSinFunction(); |
545 |
> |
rsh->makeSinFunction(); |
546 |
|
else |
547 |
< |
tempHarmonic.makeCosFunction(); |
547 |
> |
rsh->makeCosFunction(); |
548 |
|
token = strtok(NULL, delim); |
549 |
< |
tempHarmonic.setCoefficient(atof(token)); |
549 |
> |
rsh->setCoefficient(atof(token)); |
550 |
|
|
551 |
< |
functionVector.push_back(tempHarmonic); |
551 |
> |
functionVector.push_back(rsh); |
552 |
|
} |
553 |
|
} |
554 |
|
} |
555 |
+ |
shapeFile.getline(inLine, MAXLEN); |
556 |
|
} |
557 |
|
|
558 |
|
// pass range functions to ShapeType |
569 |
|
// end marks section completion |
570 |
|
if (isEndLine(inLine)) break; |
571 |
|
|
572 |
< |
nTokens = count_tokens(inLine, delim); |
572 |
> |
nTokens = countTokens(inLine, delim); |
573 |
|
if (nTokens != 0) { |
574 |
|
if (nTokens < 4) { |
575 |
|
sprintf( painCave.errMsg, |
576 |
< |
"Not enough data on a StrengthFunctions line in file: %s\n" |
577 |
< |
fileName ); |
576 |
> |
"Not enough data on a StrengthFunctions line in file: %s\n", |
577 |
> |
shapeFileName.c_str() ); |
578 |
|
painCave.severity = OOPSE_ERROR; |
579 |
|
painCave.isFatal = 1; |
580 |
|
simError(); |
581 |
|
|
582 |
|
// read in a spherical harmonic function |
583 |
|
token = strtok(inLine, delim); |
584 |
< |
tempHarmonic.setL(atoi(token)); |
584 |
> |
rsh = new RealSphericalHarmonic(); |
585 |
> |
rsh->setL(atoi(token)); |
586 |
|
token = strtok(NULL, delim); |
587 |
< |
tempHarmonic.setM(atoi(token)); |
587 |
> |
rsh->setM(atoi(token)); |
588 |
|
token = strtok(NULL, delim); |
589 |
|
if (!strcasecmp("sin",token)) |
590 |
< |
tempHarmonic.makeSinFunction(); |
590 |
> |
rsh->makeSinFunction(); |
591 |
|
else |
592 |
< |
tempHarmonic.makeCosFunction(); |
592 |
> |
rsh->makeCosFunction(); |
593 |
|
token = strtok(NULL, delim); |
594 |
< |
tempHarmonic.setCoefficient(atof(token)); |
594 |
> |
rsh->setCoefficient(atof(token)); |
595 |
|
|
596 |
< |
functionVector.push_back(tempHarmonic); |
596 |
> |
functionVector.push_back(rsh); |
597 |
|
} |
598 |
|
} |
599 |
|
} |
600 |
+ |
shapeFile.getline(inLine, MAXLEN); |
601 |
|
} |
602 |
|
|
603 |
|
// pass strength functions to ShapeType |
605 |
|
|
606 |
|
// we're done reading from this file |
607 |
|
shapeFile.close(); |
575 |
– |
return 0; |
608 |
|
} |
609 |
|
|
610 |
+ |
double Shapes_FF::findLargestContactDistance(ShapeAtomType* st) { |
611 |
+ |
int i, j, nSteps; |
612 |
+ |
double theta, thetaStep, thetaMin, costheta; |
613 |
+ |
double phi, phiStep; |
614 |
+ |
double sigma, bigSigma; |
615 |
+ |
|
616 |
+ |
nSteps = 16; |
617 |
+ |
|
618 |
+ |
thetaStep = M_PI / nSteps; |
619 |
+ |
thetaMin = thetaStep / 2.0; |
620 |
+ |
phiStep = thetaStep * 2.0; |
621 |
+ |
bigSigma = 0.0; |
622 |
+ |
|
623 |
+ |
for (i = 0; i < nSteps; i++) { |
624 |
+ |
|
625 |
+ |
theta = thetaMin + i * thetaStep; |
626 |
+ |
costheta = cos(theta); |
627 |
+ |
|
628 |
+ |
for (j = 0; j < nSteps; j++) { |
629 |
+ |
|
630 |
+ |
phi = j*phiStep; |
631 |
+ |
|
632 |
+ |
sigma = st->getContactValueAt(costheta, phi); |
633 |
+ |
|
634 |
+ |
if (sigma > bigSigma) bigSigma = sigma; |
635 |
+ |
} |
636 |
+ |
} |
637 |
+ |
|
638 |
+ |
return bigSigma; |
639 |
+ |
} |