DomainHandler.h
Go to the documentation of this file.
1 //Copyright (c) 2013-2023, The MercuryDPM Developers Team. All rights reserved.
2 //For the list of developers, see <http://www.MercuryDPM.org/Team>.
3 //
4 //Redistribution and use in source and binary forms, with or without
5 //modification, are permitted provided that the following conditions are met:
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution.
11 // * Neither the name MercuryDPM nor the
12 // names of its contributors may be used to endorse or promote products
13 // derived from this software without specific prior written permission.
14 //
15 //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 //ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 //DISCLAIMED. IN NO EVENT SHALL THE MERCURYDPM DEVELOPERS TEAM BE LIABLE FOR ANY
19 //DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 //LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 //ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 //(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 
31 #ifndef DOMAINHANDLER_H
32 #define DOMAINHANDLER_H
33 
34 #include "BaseHandler.h"
36 #include "Domain.h"
37 
46 class DomainHandler final : public BaseHandler<Domain>
47 {
48 public:
52  DomainHandler();
53 
57  DomainHandler(const DomainHandler& DH);
58 
63 
67  ~DomainHandler() final;
68 
72  void createMesh(std::vector<Mdouble>& simulationMin, std::vector<Mdouble>& simulationMax,
73  std::vector<unsigned>& numberOfDomains, bool open);
74 
78  void createDomains(std::vector<Mdouble> domainMin, std::vector<Mdouble> domainMax,
79  std::vector<unsigned>& globalMeshIndex, std::vector<unsigned>& numberOfDomains, int dimCounter,
80  std::vector<Mdouble>& meshSize, bool open);
81 
85  void addObject(Domain* D) final;
86 
90  void readAndAddObject(std::istream& is) final;
91 
95  void readOldObject(std::istream& is);
96 
100  std::string getName() const final;
101 
105  void setCurrentDomainIndex(unsigned int index);
106 
111  const Domain* getCurrentDomain() const;
112 
116  unsigned int getCurrentDomainIndex() const;
117 
121  void setNumberOfDomains(std::vector<unsigned>& numberOfdomains);
122 
126  std::vector<unsigned> getNumberOfDomains();
127 
131  void setInteractionDistance(Mdouble interactionDistance);
132 
137 
141 
143  int getParticleProcessor(int globalIndex);
144 
146  Domain* getParticleDomain(int globalIndex);
147 
148  void updateStatus(std::set<BaseParticle*>& particlesToBeDeleted);
149 
150  void updateVelocity();
151 
152  void addNewParticles();
153 
154  void initialise();
155 
156 private:
157 
161  unsigned int currentDomainIndex_;
162 
166  std::vector<int> globalIndexToProcessorList_;
167 
171  std::vector<unsigned> numberOfDomains_;
172 
177 };
178 
179 #endif
180 
dominoes D
Definition: Domino.cpp:76
Container to store the pointers to all objects that one creates in a simulation.
Definition: BaseHandler.h:51
Definition: BaseParticle.h:54
Container to store all Domain.
Definition: DomainHandler.h:47
void createDomains(std::vector< Mdouble > domainMin, std::vector< Mdouble > domainMax, std::vector< unsigned > &globalMeshIndex, std::vector< unsigned > &numberOfDomains, int dimCounter, std::vector< Mdouble > &meshSize, bool open)
Recursive function that creates the domains for a 3D mesh.
Definition: DomainHandler.cc:156
std::string getName() const final
returns the name of the class
Definition: DomainHandler.cc:230
void setCurrentDomainIndex(unsigned int index)
This sets a domain to the processor.
Definition: DomainHandler.cc:240
DomainHandler()
Default constructor, it creates an empty DomainHandler.
Definition: DomainHandler.cc:40
Mdouble getInteractionDistance()
Gets the interaction distance of the domain handler.
Definition: DomainHandler.cc:324
int getParticleDomainGlobalIndex(BaseParticle *particle)
Definition: DomainHandler.cc:330
void updateVelocity()
Definition: DomainHandler.cc:424
void setInteractionDistance(Mdouble interactionDistance)
Sets the interaction distance of the domain handler.
Definition: DomainHandler.cc:299
unsigned int currentDomainIndex_
Index to the particular domain of this process.
Definition: DomainHandler.h:161
void initialise()
Definition: DomainHandler.cc:434
unsigned int getCurrentDomainIndex() const
Gets the domain index assigned to the processor.
Definition: DomainHandler.cc:265
void addNewParticles()
Definition: DomainHandler.cc:429
void addObject(Domain *D) final
Adds a Domain to the DomainHandler.
Definition: DomainHandler.cc:203
void readOldObject(std::istream &is)
reads an old domain object
Definition: DomainHandler.cc:223
std::vector< unsigned > getNumberOfDomains()
Gets the number of domains in the domain handler.
Definition: DomainHandler.cc:287
Domain * getParticleDomain(int globalIndex)
Definition: DomainHandler.cc:414
void readAndAddObject(std::istream &is) final
reads a domain object
Definition: DomainHandler.cc:215
std::vector< unsigned > numberOfDomains_
vector containing the number of domains in Cartesian direction
Definition: DomainHandler.h:171
Mdouble interactionDistance_
Interaction distance between a domain boundary and the communication zone boundary.
Definition: DomainHandler.h:176
Domain * getCurrentDomain()
Gets the domain assigned to the processor.
Definition: DomainHandler.cc:250
std::vector< int > globalIndexToProcessorList_
look-up table to find the processor of a domain given the globalIndex of the domain
Definition: DomainHandler.h:166
~DomainHandler() final
Destructor, it destructs the DomainHandler and all Domain it contains.
Definition: DomainHandler.cc:78
void updateStatus(std::set< BaseParticle * > &particlesToBeDeleted)
Definition: DomainHandler.cc:419
DomainHandler & operator=(const DomainHandler &rhs)
Assignment operator.
Definition: DomainHandler.cc:64
void setNumberOfDomains(std::vector< unsigned > &numberOfdomains)
Sets the number of domains in the domain handler.
Definition: DomainHandler.cc:276
int getParticleProcessor(int globalIndex)
Definition: DomainHandler.cc:409
void createMesh(std::vector< Mdouble > &simulationMin, std::vector< Mdouble > &simulationMax, std::vector< unsigned > &numberOfDomains, bool open)
Creates a Cartesian square mesh in 3D.
Definition: DomainHandler.cc:93
The simulation can be subdivided into Domain's used in parallel code.
Definition: Domain.h:64