ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/trunk/OOPSE-4/src/integrators/VelocityVerletIntegrator.cpp
(Generate patch)

Comparing trunk/OOPSE-4/src/integrators/VelocityVerletIntegrator.cpp (file contents):
Revision 1960 by tim, Wed Jan 26 15:26:47 2005 UTC vs.
Revision 2380 by tim, Mon Oct 17 23:13:44 2005 UTC

# Line 1 | Line 1
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
# Line 52 | Line 52 | VelocityVerletIntegrator::VelocityVerletIntegrator(Sim
52   #include "utils/StringUtils.hpp"
53  
54   namespace oopse {
55 < VelocityVerletIntegrator::VelocityVerletIntegrator(SimInfo *info) : Integrator(info), rotAlgo(NULL) {
55 >  VelocityVerletIntegrator::VelocityVerletIntegrator(SimInfo *info) : Integrator(info), rotAlgo(NULL) {
56      dt2 = 0.5 * dt;
57      rotAlgo = new DLM();
58      rattle = new Rattle(info);
59 < }
60 <
61 < VelocityVerletIntegrator::~VelocityVerletIntegrator() {
59 >  }
60 >  
61 >  VelocityVerletIntegrator::~VelocityVerletIntegrator() {
62      delete rotAlgo;
63      delete rattle;
64 < }
65 <
66 < void VelocityVerletIntegrator::initialize(){
67 <
64 >  }
65 >  
66 >  void VelocityVerletIntegrator::initialize(){
67 >    
68      forceMan_->init();
69 <
69 >    
70      // remove center of mass drift velocity (in case we passed in a configuration
71      // that was drifting
72      velocitizer_->removeComDrift();
73 <
73 >    
74      // initialize the forces before the first step
75      calcForce(true, true);
76 <
76 >    
77      //execute constraint algorithm to make sure at the very beginning the system is constrained  
78      if (info_->getNGlobalConstraints() > 0) {
79 <        rattle->constraintA();
80 <        calcForce(true, true);
81 <        rattle->constraintB();        
82 <        info_->getSnapshotManager()->advance();//copy the current snapshot to previous snapshot
79 >      rattle->constraintA();
80 >      calcForce(true, true);
81 >      rattle->constraintB();        
82 >      info_->getSnapshotManager()->advance();//copy the current snapshot to previous snapshot
83      }
84 <
84 >    
85      if (needVelocityScaling) {
86 <        velocitizer_->velocitize(targetScalingTemp);
86 >      velocitizer_->velocitize(targetScalingTemp);
87      }
88      
89      dumpWriter = createDumpWriter();
90 <    eorWriter = createEorWriter();
90 >    
91      statWriter = createStatWriter();
92
93    dumpWriter->writeDump();
94    eorWriter->writeDump();
92      
93 +    if (simParams->getUseSolidThermInt()) {
94 +      restWriter = createRestWriter();
95 +      restWriter->writeZangle();
96 +    }
97 +    
98 +    dumpWriter->writeDumpAndEor();
99 +    
100 +    
101      //save statistics, before writeStat,  we must save statistics
102      thermo.saveStat();
103      saveConservedQuantity();
104      statWriter->writeStat(currentSnapshot_->statData);
105 <
105 >    
106      currSample = sampleTime + currentSnapshot_->getTime();
107      currStatus =  statusTime + currentSnapshot_->getTime();;
108 <    currThermal = thermalTime +  + currentSnapshot_->getTime();
108 >    currThermal = thermalTime + currentSnapshot_->getTime();
109 >    if (needReset) {
110 >      currReset = resetTime + currentSnapshot_->getTime();
111 >    }
112      needPotential = false;
113      needStress = false;      
114 <  
115 < }
108 <        
109 < void VelocityVerletIntegrator::doIntegrate() {
114 >    
115 >  }
116  
117 <
117 >  void VelocityVerletIntegrator::doIntegrate() {
118 >  
119 >  
120      initialize();
121 <
121 >  
122      while (currentSnapshot_->getTime() < runTime) {
123 <        
124 <        preStep();
123 >    
124 >      preStep();
125 >    
126 >      integrateStep();
127 >    
128 >      postStep();
129 >    
130 >    }
131 >  
132 >    finalize();
133 >  
134 >  }
135  
118        integrateStep();
119        
120        postStep();
136  
137 +  void VelocityVerletIntegrator::preStep() {
138 +    double difference = currentSnapshot_->getTime() + dt - currStatus;
139 +  
140 +    if (difference > 0 || fabs(difference) < oopse::epsilon) {
141 +      needPotential = true;
142 +      needStress = true;  
143      }
144 +  
145 +  }
146  
147 <    finalize();
147 >  void VelocityVerletIntegrator::postStep() {
148 >  
149 >    //save snapshot
150 >    info_->getSnapshotManager()->advance();
151 >  
152 >    //increase time
153 >    currentSnapshot_->increaseTime(dt);        
154 >  
155 >    if (needVelocityScaling) {
156 >      if (currentSnapshot_->getTime() >= currThermal) {
157 >        velocitizer_->velocitize(targetScalingTemp);
158 >        currThermal += thermalTime;
159 >      }
160 >    }
161 >  
162 >    if (currentSnapshot_->getTime() >= currSample) {
163 >      dumpWriter->writeDumpAndEor();
164      
165 < }
165 >      if (simParams->getUseSolidThermInt())
166 >        restWriter->writeZangle();
167 >    
168 >      currSample += sampleTime;
169 >    }
170 >  
171 >    if (currentSnapshot_->getTime() >= currStatus) {
172 >      //save statistics, before writeStat,  we must save statistics
173 >      thermo.saveStat();
174 >      saveConservedQuantity();
175 >      statWriter->writeStat(currentSnapshot_->statData);
176 >    
177 >      needPotential = false;
178 >      needStress = false;
179 >      currStatus += statusTime;
180 >    }
181  
182 +      if (needReset && currentSnapshot_->getTime() >= currReset) {    
183 +        resetIntegrator();
184 +        currReset += resetTime;
185 +      }
186 +  
187 +  }
188  
129 void VelocityVerletIntegrator::preStep() {
130        double difference = currentSnapshot_->getTime() + dt - currStatus;
189  
190 <        if (difference > 0 || fabs(difference) < oopse::epsilon) {
191 <            needPotential = true;
192 <            needStress = true;  
193 <        }
194 <
195 < }
196 <
197 < void VelocityVerletIntegrator::postStep() {
198 <
141 <        //save snapshot
142 <        info_->getSnapshotManager()->advance();
143 <
144 <        //increase time
145 <        currentSnapshot_->increaseTime(dt);        
146 <        
147 <        if (needVelocityScaling) {
148 <            if (currentSnapshot_->getTime() >= currThermal) {
149 <                velocitizer_->velocitize(targetScalingTemp);
150 <                currThermal += thermalTime;
151 <            }
152 <        }
153 <
154 <        if (currentSnapshot_->getTime() >= currSample) {
155 <            dumpWriter->writeDump();
156 <            eorWriter->writeDump();
157 <            currSample += sampleTime;
158 <        }
159 <
160 <        if (currentSnapshot_->getTime() >= currStatus) {
161 <            //save statistics, before writeStat,  we must save statistics
162 <            thermo.saveStat();
163 <            saveConservedQuantity();
164 <            statWriter->writeStat(currentSnapshot_->statData);
165 <
166 <            needPotential = false;
167 <            needStress = false;
168 <            currStatus += statusTime;
169 <        }
170 <
171 <        
172 < }
173 <
174 <
175 < void VelocityVerletIntegrator::finalize() {
176 <
177 <    dumpWriter->writeDump();
178 <    eorWriter->writeDump();
179 <
190 >  void VelocityVerletIntegrator::finalize() {
191 >    dumpWriter->writeEor();
192 >  
193 >    if (simParams->getUseSolidThermInt()) {
194 >      restWriter->writeZangle();
195 >      delete restWriter;
196 >      restWriter = NULL;
197 >    }
198 >  
199      delete dumpWriter;
181    delete eorWriter;
200      delete statWriter;
201 <
201 >  
202      dumpWriter = NULL;
185    eorWriter = NULL;
203      statWriter = NULL;
204 <    
205 < }
204 >  
205 >  }
206  
207 < void VelocityVerletIntegrator::integrateStep() {
208 <
207 >  void VelocityVerletIntegrator::integrateStep() {
208 >  
209      moveA();
210      calcForce(needPotential, needStress);
211      moveB();
212 < }
212 >  }
213  
214  
215 < void VelocityVerletIntegrator::calcForce(bool needPotential,
216 <                                         bool needStress) {
215 >  void VelocityVerletIntegrator::calcForce(bool needPotential,
216 >                                           bool needStress) {
217      forceMan_->calcForces(needPotential, needStress);
218 < }
218 >  }
219  
220 < DumpWriter* VelocityVerletIntegrator::createDumpWriter() {
221 <    return new DumpWriter(info_, info_->getDumpFileName());
222 < }
220 >  DumpWriter* VelocityVerletIntegrator::createDumpWriter() {
221 >    return new DumpWriter(info_);
222 >  }
223  
224 < DumpWriter* VelocityVerletIntegrator::createEorWriter() {
208 <    return new DumpWriter(info_, getPrefix(info_->getDumpFileName()) + ".eor");
209 < }
224 >  StatWriter* VelocityVerletIntegrator::createStatWriter() {
225  
226 < StatWriter* VelocityVerletIntegrator::createStatWriter() {
227 <    return new StatWriter(info_->getStatFileName());
228 < }
226 >    std::string statFileFormatString = simParams->getStatFileFormat();
227 >    StatsBitSet mask = parseStatFileFormat(statFileFormatString);
228 >    
229 >    // if solidThermInt is true, add extra information to the statfile
230 >    if (simParams->getUseSolidThermInt()){
231 >      mask.set(Stats::VRAW);
232 >      mask.set(Stats::VHARM);
233 >    }
234  
235 +    if (simParams->havePrintPressureTensor() && simParams->getPrintPressureTensor()){
236 +        mask.set(Stats::PRESSURE_TENSOR_X);
237 +        mask.set(Stats::PRESSURE_TENSOR_Y);
238 +        mask.set(Stats::PRESSURE_TENSOR_Z);
239 +    }
240 +    
241 +     return new StatWriter(info_->getStatFileName(), mask);
242 +  }
243  
244 +  RestWriter* VelocityVerletIntegrator::createRestWriter(){
245 +    return new RestWriter(info_);
246 +  }
247 +
248 +
249   } //end namespace oopse

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines