MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DomainHandler.h
Go to the documentation of this file.
1 //Copyright (c) 2013-2020, 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 
Domain * getParticleDomain(int globalIndex)
DomainHandler & operator=(const DomainHandler &rhs)
Assignment operator.
void setNumberOfDomains(std::vector< unsigned > &numberOfdomains)
Sets the number of domains in the domain handler.
DomainHandler()
Default constructor, it creates an empty DomainHandler.
~DomainHandler() final
Destructor, it destructs the DomainHandler and all Domain it contains.
double Mdouble
Definition: GeneralDefine.h:34
void readAndAddObject(std::istream &is) final
reads a domain object
void readOldObject(std::istream &is)
reads an old domain object
unsigned int currentDomainIndex_
Index to the particular domain of this process.
unsigned int getCurrentDomainIndex() const
Gets the domain index assigned to the processor.
Mdouble getInteractionDistance()
Gets the interaction distance of the domain handler.
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.
std::string getName() const final
returns the name of the class
void addNewParticles()
void setCurrentDomainIndex(unsigned int index)
This sets a domain to the processor.
void addObject(Domain *D) final
Adds a Domain to the DomainHandler.
Container to store the pointers to all objects that one creates in a simulation.
Definition: BaseHandler.h:50
int getParticleDomainGlobalIndex(BaseParticle *particle)
The simulation can be subdivided into Domain's used in parallel code.
Definition: Domain.h:63
Domain * getCurrentDomain()
Gets the domain assigned to the processor.
int getParticleProcessor(int globalIndex)
Container to store all Domain.
Definition: DomainHandler.h:46
void setInteractionDistance(Mdouble interactionDistance)
Sets the interaction distance of the domain handler.
std::vector< unsigned > getNumberOfDomains()
Gets the number of domains in the domain handler.
std::vector< unsigned > numberOfDomains_
vector containing the number of domains in Cartesian direction
Mdouble interactionDistance_
Interaction distance between a domain boundary and the communication zone boundary.
void updateStatus(std::set< BaseParticle * > &particlesToBeDeleted)
void updateVelocity()
void createMesh(std::vector< Mdouble > &simulationMin, std::vector< Mdouble > &simulationMax, std::vector< unsigned > &numberOfDomains, bool open)
Creates a Cartesian square mesh in 3D.
std::vector< int > globalIndexToProcessorList_
look-up table to find the processor of a domain given the globalIndex of the domain ...