1 |
< |
/* |
1 |
> |
/* |
2 |
|
* Copyright (c) 2005 The University of Notre Dame. All Rights Reserved. |
3 |
|
* |
4 |
|
* The University of Notre Dame grants you ("Licensee") a |
45 |
|
#include "utils/simError.h" |
46 |
|
namespace oopse { |
47 |
|
|
48 |
< |
DirectionalAtomTypesSectionParser::DirectionalAtomTypesSectionParser() { |
48 |
> |
DirectionalAtomTypesSectionParser::DirectionalAtomTypesSectionParser() { |
49 |
|
setSectionName("DirectionalAtomTypes"); |
50 |
< |
} |
50 |
> |
} |
51 |
|
|
52 |
< |
void DirectionalAtomTypesSectionParser::parseLine(ForceField& ff,const std::string& line, int lineNo){ |
52 |
> |
void DirectionalAtomTypesSectionParser::parseLine(ForceField& ff,const std::string& line, int lineNo){ |
53 |
|
StringTokenizer tokenizer(line); |
54 |
|
int nTokens = tokenizer.countTokens(); |
55 |
|
|
56 |
|
//in AtomTypeSection, a line at least contains 2 tokens |
57 |
|
//atomTypeName and mass |
58 |
|
if (nTokens < 4) { |
59 |
< |
sprintf(painCave.errMsg, "DirectionalAtomTypesSectionParser Error: Not enough tokens at line %d\n", |
60 |
< |
lineNo); |
61 |
< |
painCave.isFatal = 1; |
62 |
< |
simError(); |
59 |
> |
sprintf(painCave.errMsg, "DirectionalAtomTypesSectionParser Error: Not enough tokens at line %d\n", |
60 |
> |
lineNo); |
61 |
> |
painCave.isFatal = 1; |
62 |
> |
simError(); |
63 |
|
|
64 |
|
} else { |
65 |
|
|
66 |
< |
std::string atomTypeName = tokenizer.nextToken(); |
67 |
< |
AtomType* atomType = ff.getAtomType(atomTypeName); |
68 |
< |
DirectionalAtomType* dAtomType; |
69 |
< |
if (atomType == NULL) { |
70 |
< |
dAtomType = new DirectionalAtomType(); |
71 |
< |
int ident = ff.getNAtomType() + 1; |
72 |
< |
dAtomType->setIdent(ident); |
73 |
< |
dAtomType->setName(atomTypeName); |
74 |
< |
ff.addAtomType(atomTypeName, dAtomType); |
75 |
< |
} else { |
76 |
< |
dAtomType = dynamic_cast<DirectionalAtomType*>(atomType); |
77 |
< |
if (dAtomType == NULL) { |
78 |
< |
sprintf(painCave.errMsg,"DirectionalAtomTypesSectionParser:: Can not cast to DirectionalAtomType"); |
79 |
< |
painCave.isFatal = 1; |
80 |
< |
simError(); |
81 |
< |
} |
82 |
< |
} |
66 |
> |
std::string atomTypeName = tokenizer.nextToken(); |
67 |
> |
AtomType* atomType = ff.getAtomType(atomTypeName); |
68 |
> |
DirectionalAtomType* dAtomType; |
69 |
> |
if (atomType == NULL) { |
70 |
> |
dAtomType = new DirectionalAtomType(); |
71 |
> |
int ident = ff.getNAtomType() + 1; |
72 |
> |
dAtomType->setIdent(ident); |
73 |
> |
dAtomType->setName(atomTypeName); |
74 |
> |
ff.addAtomType(atomTypeName, dAtomType); |
75 |
> |
} else { |
76 |
> |
dAtomType = dynamic_cast<DirectionalAtomType*>(atomType); |
77 |
> |
if (dAtomType == NULL) { |
78 |
> |
sprintf(painCave.errMsg,"DirectionalAtomTypesSectionParser:: Can not cast to DirectionalAtomType"); |
79 |
> |
painCave.isFatal = 1; |
80 |
> |
simError(); |
81 |
> |
} |
82 |
> |
} |
83 |
|
|
84 |
< |
double Ixx = tokenizer.nextTokenAsDouble(); |
85 |
< |
double Iyy = tokenizer.nextTokenAsDouble(); |
86 |
< |
double Izz = tokenizer.nextTokenAsDouble(); |
87 |
< |
Mat3x3d inertialMat; |
88 |
< |
inertialMat(0, 0) = Ixx; |
89 |
< |
inertialMat(1, 1) = Iyy; |
90 |
< |
inertialMat(2, 2) = Izz; |
91 |
< |
dAtomType->setI(inertialMat); |
84 |
> |
double Ixx = tokenizer.nextTokenAsDouble(); |
85 |
> |
double Iyy = tokenizer.nextTokenAsDouble(); |
86 |
> |
double Izz = tokenizer.nextTokenAsDouble(); |
87 |
> |
Mat3x3d inertialMat; |
88 |
> |
inertialMat(0, 0) = Ixx; |
89 |
> |
inertialMat(1, 1) = Iyy; |
90 |
> |
inertialMat(2, 2) = Izz; |
91 |
> |
dAtomType->setI(inertialMat); |
92 |
|
|
93 |
|
} |
94 |
|
|
95 |
< |
} |
95 |
> |
} |
96 |
|
|
97 |
|
} //end namespace oopse |