25 |
|
|
26 |
|
#include "io/EAMAtomTypesSectionParser.hpp" |
27 |
|
#include "types/AtomType.hpp" |
28 |
< |
|
28 |
> |
#include "UseTheForce/ForceField.hpp" |
29 |
> |
#include "utils/simError.h" |
30 |
|
namespace oopse { |
31 |
|
|
32 |
|
EAMAtomTypesSectionParser::EAMAtomTypesSectionParser() { |
46 |
|
AtomType* atomType = ff.getAtomType(atomTypeName); |
47 |
|
if (atomType != NULL) { |
48 |
|
atomType->setEAM(); |
49 |
< |
parseEAMParamFile(atomType, potentialParamFile, atomType->getIdent()); |
49 |
> |
parseEAMParamFile(ff, atomType, potentialParamFile, atomType->getIdent()); |
50 |
|
} else { |
51 |
|
|
52 |
|
} |
53 |
|
|
54 |
|
} else { |
55 |
< |
sprintf( painCave.errMsg, |
55 |
< |
"Not enough tokens when parsing EAM Force Field : %s\n" |
56 |
< |
"in line %d : %s\n", |
57 |
< |
filename.c_str(), lineNo, line); |
58 |
< |
painCave.severity = OOPSE_ERROR; |
59 |
< |
painCave.isFatal = 1; |
60 |
< |
simError(); |
55 |
> |
|
56 |
|
} |
57 |
|
|
58 |
|
|
59 |
|
} |
60 |
|
|
61 |
< |
void EAMAtomTypesSectionParser::parseEAMParamFile(AtomType* atomType, |
61 |
> |
void EAMAtomTypesSectionParser::parseEAMParamFile(ForceField& ff, AtomType* atomType, |
62 |
|
const std::string& potentialParamFile, int ident) { |
63 |
|
|
64 |
< |
ifstrstream* ppfStream; |
70 |
< |
ppfStream = openForceFieldFile(potentialParamFile); |
64 |
> |
ifstrstream* ppfStream = ff.openForceFieldFile(potentialParamFile); |
65 |
|
const int bufferSize = 65535; |
66 |
|
char buffer[bufferSize]; |
67 |
|
std::string line; |
111 |
|
|
112 |
|
} |
113 |
|
|
114 |
< |
parseEAMArray(ppfStream, eamParam.rvals, eamParam.nr); |
115 |
< |
parseEAMArray(ppfStream, eamParam.rhovals, eamParam.nr); |
116 |
< |
parseEAMArray(ppfStream, eamParam.Frhovals, eamParam.nrho); |
114 |
> |
parseEAMArray(*ppfStream, eamParam.rvals, eamParam.nr); |
115 |
> |
parseEAMArray(*ppfStream, eamParam.rhovals, eamParam.nr); |
116 |
> |
parseEAMArray(*ppfStream, eamParam.Frhovals, eamParam.nrho); |
117 |
|
|
118 |
< |
atomType->addProperty(EAMParamGenericData("EAM", eamParam)); |
118 |
> |
atomType->addProperty(new EAMParamGenericData("EAM", eamParam)); |
119 |
|
} |
120 |
|
|
121 |
< |
void EAMAtomTypesSectionParser::parseEAMArray(ifstrstream* ppfStream, |
121 |
> |
void EAMAtomTypesSectionParser::parseEAMArray(std::istream& input, |
122 |
|
std::vector<double>& array, int num) { |
123 |
|
|
124 |
|
const int dataPerLine = 5; |
131 |
|
std::string line; |
132 |
|
int readLines = num/dataPerLine; |
133 |
|
int lineCount = 0; |
134 |
< |
while(ffStream.getline(buffer, bufferSize) && lineCount < num){ |
134 |
> |
while(input.getline(buffer, bufferSize) && lineCount < num){ |
135 |
|
|
136 |
|
StringTokenizer tokenizer(buffer); |
137 |
|
if (tokenizer.countTokens() >= dataPerLine) { |
138 |
|
for (int i = 0; i < dataPerLine; ++i) { |
139 |
< |
array.push_back(tokenizer.nextTokenAsDouble())); |
139 |
> |
array.push_back(tokenizer.nextTokenAsDouble()); |
140 |
|
} |
141 |
|
} else { |
142 |
|
|