ls1-MarDyn
ls1-MarDyn molecular dynamics code
InMemoryCheckpointing.h
1/*
2 * InMemoryCheckpointing.h
3 *
4 * Created on: 3 Jul 2018
5 * Author: tchipevn
6 */
7
8#ifndef SRC_PLUGINS_INMEMORYCHECKPOINTING_H_
9#define SRC_PLUGINS_INMEMORYCHECKPOINTING_H_
10
11#include "PluginBase.h"
12#include "molecules/MoleculeForwardDeclaration.h"
13
14#include <vector>
15
16class Snapshot;
17
19public:
21 virtual ~~InMemoryCheckpointing() {}
22
23 void init(ParticleContainer* particleContainer,
24 DomainDecompBase* domainDecomp, Domain* domain) {}
25
26 void readXML(XMLfileUnits& xmlconfig);
27
32 ParticleContainer* particleContainer, DomainDecompBase* domainDecomp,
33 unsigned long simstep
34 );
35
37 ParticleContainer* particleContainer, DomainDecompBase* domainDecomp,
38 unsigned long simstep
39 ){}
40
45 ParticleContainer* particleContainer, DomainDecompBase* domainDecomp,
46 unsigned long simstep
47 ) {}
48
49 void endStep(
50 ParticleContainer* particleContainer, DomainDecompBase* domainDecomp,
51 Domain* domain, unsigned long simstep);
52
53 void finish(ParticleContainer* particleContainer,
54 DomainDecompBase* domainDecomp, Domain* domain){}
55
57 return std::string("InMemoryCheckpointing");
58 }
59
60 static PluginBase* createInstance() { return new InMemoryCheckpointing(); }
61
62 class Snapshot {
63 public:
64 void addMolecule(const Molecule& m) {
65 _molecules.push_back(m);
66 }
67
68 double getCurrentTime() const {
69 return _currentTime;
70 }
71
72 void setCurrentTime(double currentTime) {
73 _currentTime = currentTime;
74 }
75
76 const std::array<double, 3>& getBoxDims() const {
77 return _boxDims;
78 }
79
80 void setBoxDims(const std::array<double, 3>& boxDims) {
81 _boxDims = boxDims;
82 }
83
84 unsigned long getGlobalNumberOfMolecules() const {
85 return _globalNumberOfMolecules;
86 }
87
88 void setGlobalNumberOfMolecules(unsigned long globalNumberOfMolecules) {
89 _globalNumberOfMolecules = globalNumberOfMolecules;
90 }
91
92 double getTemperature() const {
93 return _temperature;
94 }
95
96 void setTemperature(double temperature) {
97 _temperature = temperature;
98 }
99
100 int getRank() const {
101 return _rank;
102 }
103
104 void setRank(int rank) {
105 _rank = rank;
106 }
107
108 const std::vector<Molecule>& getMolecules() const {
109 return _molecules;
110 }
111
112 void clearMolecules() {
113 _molecules.clear();
114 }
115
116 private:
117 std::vector<Molecule> _molecules;
118 double _currentTime;
119 int _rank; // who do these molecules belong to?
120
121 // the following fields are maybe unnecessary, but leaving them here now for consistency to written headers in file-checkpoints
122 unsigned long _globalNumberOfMolecules;
123 double _temperature; // maybe not necessary; for consistency to currently written headers
124 std::array<double, 3> _boxDims; // maybe not necessary; for consistency to currently written headers
125
126 };
127
128private:
129 Snapshot _snapshot; // make an std::vector eventually
130 unsigned long _writeFrequency;
131 unsigned long _restartAtIteration;
132};
133
134#endif /* SRC_PLUGINS_INMEMORYCHECKPOINTING_H_ */
handle boundary region and multiple processes
Definition: DomainDecompBase.h:51
This class is used to read in the phasespace and to handle macroscopic values.
Definition: Domain.h:47
FullMolecule modeled as LJ sphere with point polarities.
Definition: FullMolecule.h:18
Definition: InMemoryCheckpointing.h:62
Definition: InMemoryCheckpointing.h:18
void finish(ParticleContainer *particleContainer, DomainDecompBase *domainDecomp, Domain *domain)
Method finish will be called at the end of the simulation.
Definition: InMemoryCheckpointing.h:53
void readXML(XMLfileUnits &xmlconfig)
Method readXML will be called once for each plugin section in the input file.
Definition: InMemoryCheckpointing.cpp:19
void beforeEventNewTimestep(ParticleContainer *particleContainer, DomainDecompBase *domainDecomp, unsigned long simstep)
restarting takes place here
Definition: InMemoryCheckpointing.cpp:29
void endStep(ParticleContainer *particleContainer, DomainDecompBase *domainDecomp, Domain *domain, unsigned long simstep)
Method endStep will be called at the end of each time step.
Definition: InMemoryCheckpointing.cpp:63
void init(ParticleContainer *particleContainer, DomainDecompBase *domainDecomp, Domain *domain)
Method init will be called at the begin of the simulation.
Definition: InMemoryCheckpointing.h:23
void beforeForces(ParticleContainer *particleContainer, DomainDecompBase *domainDecomp, unsigned long simstep)
Method beforeForces will be called before forcefields have been applied no alterations w....
Definition: InMemoryCheckpointing.h:36
std::string getPluginName()
return the name of the plugin
Definition: InMemoryCheckpointing.h:56
void afterForces(ParticleContainer *particleContainer, DomainDecompBase *domainDecomp, unsigned long simstep)
writing takes place here
Definition: InMemoryCheckpointing.h:44
This Interface is used to get access to particles and pairs of particles.
Definition: ParticleContainer.h:69
The PluginBase class provides the interface for any kind of output/plugin classes - called "(output) ...
Definition: PluginBase.h:47
XML file with unit attributes abstraction.
Definition: xmlfileUnits.h:25
::xsd::cxx::tree::string< char, simple_type > string
C++ type corresponding to the string XML Schema built-in type.
Definition: vtk-punstructured.h:270