ls1-MarDyn
ls1-MarDyn molecular dynamics code
ReplicaGenerator.h
1#ifndef REPLICA_GENERATOR_H
2#define REPLICA_GENERATOR_H
3
4#include "io/InputBase.h"
5#include "molecules/Molecule.h"
6#include "molecules/Component.h"
7#include <fstream>
8#include <vector>
9#include <string>
10#include <iostream>
11#include <cstdint>
12
13using namespace std;
14
15enum SystemTypes : uint8_t {
16 ST_UNKNOWN = 0,
17 ST_HOMOGENEOUS = 1,
18 ST_HETEROGENEOUS_VAPOR_LIQUID_VAPOR = 2,
19 ST_HETEROGENEOUS_LIQUID_VAPOR = 3,
20};
21
22struct SubDomain {
23 std::string strFilePathHeader;
24 std::string strFilePathData;
25 std::vector<Molecule> vecParticles;
26 uint64_t numParticles;
27 std::array<double, 3> arrBoxLength;
28 double dVolume;
29 double dDensity;
30};
31
37
39
41public:
43
45
46 void readPhaseSpaceHeader(Domain* /*domain*/, double /*timestep*/) {}
47
48 unsigned long readPhaseSpace(ParticleContainer* particleContainer, Domain* domain, DomainDecompBase* domainDecomp);
49
58 void readXML(XMLfileUnits& xmlconfig);
59
60private:
61 void init();
62
63 void readReplicaPhaseSpaceHeader(SubDomain& subDomain);
64
65 void readReplicaPhaseSpaceData(SubDomain& subDomain, DomainDecompBase* domainDecomp);
66
67private:
68 std::vector<SubDomain> _vecSubDomains;
69 uint64_t _numParticlesTotal;
70 uint32_t _numBlocksXZ;
71 uint32_t _numBlocksLiqY;
72 uint32_t _numBlocksVapY;
73 uint32_t _nIndexLiqBeginY;
74 uint32_t _nIndexLiqEndY;
75 uint32_t _nMoleculeFormat;
76 MoleculeDataReader* _moleculeDataReader;
77 double _dMoleculeDiameter;
78 double _fspY[6]; // free space positions
79 uint8_t _nSystemType;
80 std::vector<uint32_t> _vecChangeCompIDsVap;
81 std::vector<uint32_t> _vecChangeCompIDsLiq;
82};
83
85protected:
87
88public:
89 virtual ~~MoleculeDataReader() {};
90
91 virtual void read(std::ifstream& ifs, Molecule& mol, std::vector<Component>& components) = 0;
92};
93
95public:
97
98public:
99 virtual ~~MoleculeDataReaderICRVQD() {};
100
101 virtual void read(std::ifstream& ifs, Molecule& mol, std::vector<Component>& components) {
102 double rx, ry, rz, vx, vy, vz, q0, q1, q2, q3, Dx, Dy, Dz;
103 rx = ry = rz = vx = vy = vz = q0 = q1 = q2 = q3 = Dx = Dy = Dz = 0.;
104 uint64_t id = 0;
105 uint32_t cid = 0;
106
107 ifs.read(reinterpret_cast<char*> (&id), 8);
108 ifs.read(reinterpret_cast<char*> (&cid), 4);
109 ifs.read(reinterpret_cast<char*> (&rx), 8);
110 ifs.read(reinterpret_cast<char*> (&ry), 8);
111 ifs.read(reinterpret_cast<char*> (&rz), 8);
112 ifs.read(reinterpret_cast<char*> (&vx), 8);
113 ifs.read(reinterpret_cast<char*> (&vy), 8);
114 ifs.read(reinterpret_cast<char*> (&vz), 8);
115 ifs.read(reinterpret_cast<char*> (&q0), 8);
116 ifs.read(reinterpret_cast<char*> (&q1), 8);
117 ifs.read(reinterpret_cast<char*> (&q2), 8);
118 ifs.read(reinterpret_cast<char*> (&q3), 8);
119 ifs.read(reinterpret_cast<char*> (&Dx), 8);
120 ifs.read(reinterpret_cast<char*> (&Dy), 8);
121 ifs.read(reinterpret_cast<char*> (&Dz), 8);
122
123 Component* component = &components.at(cid - 1);
124 Molecule tmp(id, component,
125 rx, ry, rz,
126 vx, vy, vz,
127 q0, q1, q2, q3,
128 Dx, Dy, Dz);
129 mol = tmp;
130 }
131};
132
134public:
136
137public:
138 virtual ~~MoleculeDataReaderICRV() {};
139
140 virtual void read(std::ifstream& ifs, Molecule& mol, std::vector<Component>& components) {
141 double rx, ry, rz, vx, vy, vz, q0, q1, q2, q3, Dx, Dy, Dz;
142 rx = ry = rz = vx = vy = vz = q0 = q1 = q2 = q3 = Dx = Dy = Dz = 0.;
143 uint64_t id = 0;
144 uint32_t cid = 0;
145
146 ifs.read(reinterpret_cast<char*> (&id), 8);
147 ifs.read(reinterpret_cast<char*> (&cid), 4);
148 ifs.read(reinterpret_cast<char*> (&rx), 8);
149 ifs.read(reinterpret_cast<char*> (&ry), 8);
150 ifs.read(reinterpret_cast<char*> (&rz), 8);
151 ifs.read(reinterpret_cast<char*> (&vx), 8);
152 ifs.read(reinterpret_cast<char*> (&vy), 8);
153 ifs.read(reinterpret_cast<char*> (&vz), 8);
154
155 Component* component = &components.at(cid - 1);
156 Molecule tmp(id, component,
157 rx, ry, rz,
158 vx, vy, vz,
159 q0, q1, q2, q3,
160 Dx, Dy, Dz);
161 mol = tmp;
162 }
163};
164
166public:
168
169public:
170 virtual ~~MoleculeDataReaderIRV() {};
171
172 virtual void read(std::ifstream& ifs, Molecule& mol, std::vector<Component>& components) {
173 double rx, ry, rz, vx, vy, vz, q0, q1, q2, q3, Dx, Dy, Dz;
174 rx = ry = rz = vx = vy = vz = q0 = q1 = q2 = q3 = Dx = Dy = Dz = 0.;
175 uint64_t id = 0;
176 uint32_t cid = 0;
177
178 ifs.read(reinterpret_cast<char*> (&id), 8);
179 ifs.read(reinterpret_cast<char*> (&rx), 8);
180 ifs.read(reinterpret_cast<char*> (&ry), 8);
181 ifs.read(reinterpret_cast<char*> (&rz), 8);
182 ifs.read(reinterpret_cast<char*> (&vx), 8);
183 ifs.read(reinterpret_cast<char*> (&vy), 8);
184 ifs.read(reinterpret_cast<char*> (&vz), 8);
185
186 Component* component = &components.at(0);
187 Molecule tmp(id, component,
188 rx, ry, rz,
189 vx, vy, vz,
190 q0, q1, q2, q3,
191 Dx, Dy, Dz);
192 mol = tmp;
193 }
194};
195
196#endif /* REPLICA_GENERATOR_H */
197
Class implementing molecules as rigid rotators consisting out of different interaction sites (LJcente...
Definition: Component.h:14
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
interface for any kind of input class
Definition: InputBase.h:18
Definition: ReplicaGenerator.h:94
Definition: ReplicaGenerator.h:133
Definition: ReplicaGenerator.h:165
Definition: ReplicaGenerator.h:84
This Interface is used to get access to particles and pairs of particles.
Definition: ParticleContainer.h:69
Definition: ReplicaGenerator.h:40
void readPhaseSpaceHeader(Domain *, double)
read the phase space components and header information
Definition: ReplicaGenerator.h:46
unsigned long readPhaseSpace(ParticleContainer *particleContainer, Domain *domain, DomainDecompBase *domainDecomp)
read the actual phase space information
Definition: ReplicaGenerator.cpp:380
void readXML(XMLfileUnits &xmlconfig)
Read in XML configuration for MkesferaGenerator and all its included objects.
Definition: ReplicaGenerator.cpp:178
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
Definition: ReplicaGenerator.h:22