ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/trunk/src/applications/hydrodynamics/Hydro.cpp
(Generate patch)

Comparing trunk/src/applications/hydrodynamics/Hydro.cpp (file contents):
Revision 891 by tim, Wed Feb 22 20:35:16 2006 UTC vs.
Revision 892 by tim, Thu Feb 23 23:16:43 2006 UTC

# Line 58 | Line 58 | void registerHydrodynamicsModels();
58   /** Register different hydrodynamics models */
59   void registerHydrodynamicsModels();
60  
61 < bool calcHydrodynamicsProp(const std::string& modelType, Molecule* mol, const DynamicProperty& param, const std::string& prefix,double viscosity);
61 > bool calcHydrodynamicsProp(const std::string& modelType, StuntDouble* sd, const DynamicProperty& param, std::ostream& os,  const std::string& prefix);
62  
63   int main(int argc, char* argv[]){
64    //register force fields
# Line 91 | Line 91 | int main(int argc, char* argv[]){
91    } else {
92      prefix = "hydro";    
93    }
94 +  std::string outputFilename = prefix + ".diff";
95  
96    DynamicProperty param;
97 +  param.insert(DynamicProperty::value_type("Viscosity", args_info.viscosity_arg));
98 +  param.insert(DynamicProperty::value_type("Temperature", args_info.temperature_arg));
99 +  
100    if (args_info.sigma_given) {
101      param.insert(DynamicProperty::value_type("Sigma", args_info.sigma_arg));
102    }
# Line 104 | Line 108 | int main(int argc, char* argv[]){
108      
109    SimInfo::MoleculeIterator mi;
110    Molecule* mol;
111 <  Molecule::RigidBodyIterator ri;
112 <  RigidBody* rb;
113 <    //update atoms of rigidbody
111 >  Molecule::IntegrableObjectIterator  ii;
112 >  StuntDouble* integrableObject;
113 >  Mat3x3d identMat;
114 >  identMat(0,0) = 1.0;
115 >  identMat(1,1) = 1.0;
116 >  identMat(2,2) = 1.0;
117 >  
118 >
119 >  std::map<std::string, StuntDouble*> uniqueStuntDoubles;
120 >  
121    for (mol = info->beginMolecule(mi); mol != NULL; mol = info->nextMolecule(mi)) {
122 <      
123 <      //change the positions of atoms which belong to the rigidbodies
124 <      for (rb = mol->beginRigidBody(ri); rb != NULL; rb = mol->nextRigidBody(ri)) {
125 <        rb->updateAtoms();
126 <      }
122 >      for (integrableObject = mol->beginIntegrableObject(ii); integrableObject != NULL;
123 >           integrableObject = mol->nextIntegrableObject(ii)) {
124 >          if (uniqueStuntDoubles.find(integrableObject->getType()) ==  uniqueStuntDoubles.end()) {
125 >            uniqueStuntDoubles.insert(std::map<std::string, StuntDouble*>::value_type(integrableObject->getType(), integrableObject));
126 >            integrableObject->setPos(V3Zero);
127 >            integrableObject->setA(identMat);
128 >            if (integrableObject->isRigidBody()) {
129 >                RigidBody* rb = static_cast<RigidBody*>(integrableObject);
130 >                rb->updateAtoms();
131 >            }
132 >          }
133 >        }
134    }
135 <    
136 <  for (mol = info->beginMolecule(mi); mol != NULL; mol = info->nextMolecule(mi)) {
137 <    calcHydrodynamicsProp(args_info.model_arg, mol, param, prefix, args_info.viscosity_arg);
135 >
136 >  std::map<std::string, StuntDouble*>::iterator iter;
137 >  std::ofstream outputDiff(outputFilename.c_str());
138 >  for (iter = uniqueStuntDoubles.begin(); iter != uniqueStuntDoubles.end(); ++iter) {
139 >    calcHydrodynamicsProp(args_info.model_arg, iter->second, param, outputDiff, prefix);
140    }
141    
142    delete info;
# Line 129 | Line 149 | void registerHydrodynamicsModels() {
149  
150   }
151  
152 < bool calcHydrodynamicsProp(const std::string& modelType, Molecule* mol, const DynamicProperty& param, const std::string& prefix,double viscosity) {
153 <    HydrodynamicsModel* hydroModel = HydrodynamicsModelFactory::getInstance()->createHydrodynamicsModel(modelType, mol, param);
152 > bool calcHydrodynamicsProp(const std::string& modelType, StuntDouble* sd, const DynamicProperty& param, std::ostream& os, const std::string& prefix) {
153 >    HydrodynamicsModel* hydroModel = HydrodynamicsModelFactory::getInstance()->createHydrodynamicsModel(modelType, sd, param);
154      bool ret = false;
155      if (hydroModel == NULL) {
156          std::cout << "Integrator Factory can not create " << modelType <<std::endl;
157      }    
158  
159 <    if (hydroModel->calcHydrodyanmicsProps(viscosity)) {
160 <        ret = true;
161 <        std::stringstream outputDiffTensor;
162 <        outputDiffTensor << prefix << "_" << mol->getType() << ".diff";
159 >    if (hydroModel->calcHydrodyanmicsProps()) {
160 >        ret = true;        
161 >        hydroModel->writeDiffCenterAndDiffTensor(os);
162 >
163          std::ofstream ofs;
144        ofs.open(outputDiffTensor.str().c_str());
145        hydroModel->writeDiffCenterAndDiffTensor(ofs);
146        ofs.close();
147        
164          std::stringstream outputBeads;
165 <        outputBeads << prefix << "_" << mol->getType() << ".xyz";
165 >        outputBeads << prefix << "_" << sd->getType() << ".xyz";
166          ofs.open(outputBeads.str().c_str());
167          hydroModel->writeBeads(ofs);
168          ofs.close();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines