ls1-MarDyn
ls1-MarDyn molecular dynamics code
ParticleContainer.h
1/***************************************************************************
2 * Copyright (C) 2010 by Martin Bernreuther <bernreuther@hlrs.de> et al. *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
18 ***************************************************************************/
19
20#ifndef PARTICLECONTAINER_H_
21#define PARTICLECONTAINER_H_
22
23#include <list>
24#include <variant>
25#include <vector>
26#include "ParticleCell.h"
27#include "ParticleIterator.h"
28#include "RegionParticleIterator.h"
29#include "io/MemoryProfiler.h"
30#include "molecules/MoleculeForwardDeclaration.h"
31
32class CellProcessor;
34class XMLfileUnits;
35
70private:
71 /* Copy operator private */
72 ParticleContainer& operator=(const ParticleContainer&);
73
74public:
78 ParticleContainer(double bBoxMin[3], double bBoxMax[3]);
79
83 virtual ~ParticleContainer() {}
84
85 virtual void readXML(XMLfileUnits& xmlconfig) = 0;
86
96 virtual bool rebuild(double bBoxMin[3], double bBoxMax[3]);
97
105 virtual void update() = 0;
106
117 virtual bool addParticle(Molecule& particle, bool inBoxCheckedAlready = false, bool checkWhetherDuplicate = false, const bool& rebuildCaches=false) = 0;
118
129 virtual bool addHaloParticle(Molecule& particle, bool inBoxCheckedAlready = false, bool checkWhetherDuplicate = false,
130 const bool& rebuildCaches = false);
131
134 virtual void addParticles(std::vector<Molecule>& particles, bool checkWhetherDuplicate=false) = 0;
135
152// virtual void traversePairs(ParticlePairsHandler* particlePairsHandler) = 0;
153
154 virtual void traverseCells(CellProcessor& cellProcessor) = 0;
155
156 virtual void traverseNonInnermostCells(CellProcessor& cellProcessor) = 0;
157
158 virtual void traversePartialInnermostCells(CellProcessor& cellProcessor, unsigned int stage, int stageCount) = 0;
159
160 virtual ParticleIterator iterator (ParticleIterator::Type t) = 0;
161 virtual RegionParticleIterator regionIterator (const double startCorner[3], const double endCorner[3], ParticleIterator::Type t) = 0;
162
167 virtual unsigned long getNumberOfParticles() = 0;
168
172 virtual double getBoundingBoxMin(int dimension) const;
173
177 virtual bool isInBoundingBox(double r[3]) const;
178
179 virtual int getHaloWidthNumCells();
183 virtual double getBoundingBoxMax(int dimension) const;
184
186 virtual void clear() = 0;
187
188 /* TODO can we combine this with the update method? */
190 virtual void deleteOuterParticles() = 0;
191
195 virtual double get_halo_L(int index) const = 0;
196
197
198 virtual double getCutoff() const = 0;
199
200 virtual double getSkin() const {return 0.;}
201
202 /* TODO: Have a look on this */
203 virtual void deleteMolecule(ParticleIterator& moleculeIter, const bool& rebuildCaches) = 0;
204
205 /* TODO goes into grand canonical ensemble */
206 virtual double getEnergy(ParticlePairsHandler* particlePairsHandler, Molecule* m1, CellProcessor& cellProcessor) = 0;
207
211 virtual void updateInnerMoleculeCaches() = 0;
212
217
219 virtual void updateMoleculeCaches() = 0;
220
226 virtual std::variant<ParticleIterator, SingleCellIterator<ParticleCell>> getMoleculeAtPosition(const double pos[3]) = 0;
227
228 // @brief Should the domain decomposition exchange calculated forces at the boundaries,
229 // or does this particle container calculate all forces.
230 virtual bool requiresForceExchange() const {return false;}
231
232 virtual unsigned long initCubicGrid(std::array<unsigned long, 3> numMoleculesPerDimension, std::array<double, 3> simBoxLength, size_t seed_offset) = 0;
233
234 virtual double* getCellLength() = 0;
235
240 virtual double* getHaloSize() {
241 return getCellLength();
242 };
243
248 virtual std::vector<unsigned long> getParticleCellStatistics() {return std::vector<unsigned long>();}
249
254 virtual void setCutoff(double rc){};
255
256 virtual std::vector<Molecule> getInvalidParticles() { return {}; }
257
258 virtual bool isInvalidParticleReturner() { return false; }
259
270
271protected:
272
277
278};
279
280#endif /* PARTICLECONTAINER_H_ */
Definition: CellProcessor.h:29
FullMolecule modeled as LJ sphere with point polarities.
Definition: FullMolecule.h:18
Definition: MemoryProfiler.h:13
This Interface is used to get access to particles and pairs of particles.
Definition: ParticleContainer.h:69
virtual ~ParticleContainer()
The destructor.
Definition: ParticleContainer.h:83
virtual void setCutoff(double rc)
Definition: ParticleContainer.h:254
virtual double get_halo_L(int index) const =0
returns the width of the halo stripe (for the given dimension index)
virtual std::vector< unsigned long > getParticleCellStatistics()
Definition: ParticleContainer.h:248
virtual double getBoundingBoxMin(int dimension) const
returns one coordinate of the lower corner of the bounding box
Definition: ParticleContainer.cpp:29
virtual std::variant< ParticleIterator, SingleCellIterator< ParticleCell > > getMoleculeAtPosition(const double pos[3])=0
Gets a molecule by its position.
virtual void traverseCells(CellProcessor &cellProcessor)=0
traverse pairs which are close to each other
virtual void updateMoleculeCaches()=0
Update the caches of the molecules.
virtual void updateInnerMoleculeCaches()=0
Update the caches of the molecules, that lie in inner cells. The caches of boundary and halo cells is...
virtual void addParticles(std::vector< Molecule > &particles, bool checkWhetherDuplicate=false)=0
adds a whole vector of particles
ParticleContainer()
Default constructor.
Definition: ParticleContainer.h:81
double _boundingBoxMin[3]
coordinates of the left, lower, front corner of the bounding box
Definition: ParticleContainer.h:274
virtual void deleteOuterParticles()=0
delete all Particles which are not within the bounding box
virtual bool rebuild(double bBoxMin[3], double bBoxMax[3])
rebuild the datastructure
Definition: ParticleContainer.cpp:16
virtual double * getHaloSize()
Definition: ParticleContainer.h:240
virtual bool isInBoundingBox(double r[3]) const
checks, whether given coordinates are within the bounding box
Definition: ParticleContainer.cpp:37
virtual void updateBoundaryAndHaloMoleculeCaches()=0
Update the caches of the molecules, that lie in the boundary or halo cells. The caches of boundary an...
virtual void update()=0
do necessary updates resulting from changed particle positions
virtual bool addParticle(Molecule &particle, bool inBoxCheckedAlready=false, bool checkWhetherDuplicate=false, const bool &rebuildCaches=false)=0
add a single Molecule to the ParticleContainer.
virtual void clear()=0
Delete all molecules in container.
virtual double getBoundingBoxMax(int dimension) const
returns one coordinate of the higher corner of the bounding box
Definition: ParticleContainer.cpp:33
virtual std::string getConfigurationAsString()=0
virtual bool addHaloParticle(Molecule &particle, bool inBoxCheckedAlready=false, bool checkWhetherDuplicate=false, const bool &rebuildCaches=false)
add a single Molecule to the ParticleContainer, ensures that it is added in the halo.
Definition: ParticleContainer.cpp:50
virtual unsigned long getNumberOfParticles()=0
double _boundingBoxMax[3]
coordinates of the right, upper, back corner of the bounding box
Definition: ParticleContainer.h:276
Definition: ParticleIterator.h:50
interface for defining the action performed when processing a pair
Definition: ParticlePairsHandler.h:38
Definition: RegionParticleIterator.h:33
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: FakedOptFFT.h:23