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