ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new_design/OOPSE-2.0/src/io/EAMAtomTypesSectionParser.cpp
(Generate patch)

Comparing branches/new_design/OOPSE-2.0/src/io/EAMAtomTypesSectionParser.cpp (file contents):
Revision 1788 by tim, Wed Nov 24 22:12:12 2004 UTC vs.
Revision 1789 by tim, Mon Nov 29 15:27:43 2004 UTC

# Line 25 | Line 25
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() {
# Line 45 | Line 46 | void EAMAtomTypesSectionParser::parseLine(ForceField&
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;
# Line 117 | Line 111 | void EAMAtomTypesSectionParser::parseEAMParamFile(Atom
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;
# Line 137 | Line 131 | void EAMAtomTypesSectionParser::parseEAMArray(ifstrstr
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  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines