LBIBCell
 All Classes Functions Variables Friends Pages
GeometryHandler.hpp
1 /* Copyright (c) 2013 David Sichau <mail"at"sichau"dot"eu>
2  * 2013-2015 Simon Tanaka <tanakas"at"gmx"dot"ch>
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20  * THE SOFTWARE.
21  */
22 #ifndef GEOMETRY_GEOMETRYHANDLER_HPP
23 #define GEOMETRY_GEOMETRYHANDLER_HPP
24 
25 #include <LbmLib/include/geometry/Connection.hpp>
26 #include <LbmLib/include/geometry/Geometry.hpp>
27 #include <iostream>
28 #include <list>
29 #include <memory>
30 #include <ostream>
31 #include <string>
32 #include <vector>
33 #include <unordered_set>
34 
35 namespace LbmLib {
36 namespace nodes {
37 class PhysicalNode;
38 class GeometryNode;
39 class BoundaryNode;
40 }
41 
42 namespace geometry {
47  public:
52  explicit GeometryHandler(const Geometry& geometry);
53 
54 
58  void moveLattice();
59 
64  unsigned int remeshBoundary();
65 
69  void coarsenBoundary();
70 
75 
80  const std::vector<std::vector<nodes::PhysicalNode*> >& getPhysicalNodes()
81  const {
82  return physicalGrid_;
83  }
84 
89  const Geometry& getGeometry() const {
90  return geometry_;
91  }
92 
97  const std::unordered_set<nodes::BoundaryNode*>& getBoundaryNodes() const {
98  return boundaryNodes_;
99  }
100 
105  const std::map<unsigned int,double> computeAreas() const;
106 
112  std::map<unsigned int,double> computeAccumulatedDomainConcentrations(const std::string& name) const;
113 
117  void cureLattice();
118 
125  unsigned int createGeometryNode(const double xpos,const double ypos);
126 
134  void createConnection(std::shared_ptr<nodes::GeometryNode> const p1,
135  std::shared_ptr<nodes::GeometryNode> const p2,
136  const std::map<std::string, std::vector<std::string> > boundaryconditiondescriptor,
137  const unsigned int domainidentifier);
138 
143  void eraseConnection(std::shared_ptr<Connection> toErase);
144 
150  const std::shared_ptr<nodes::GeometryNode> returnGeometryNode(const unsigned int nodeID) const;
151 
155  void checkLatticeIntegrity();
156 
161 
166  void copyCellTypeToPhysicalNodes(std::map<unsigned int,unsigned int> &celltrackermap);
167 
173  void copyCellTypeToPhysicalNodes(unsigned int domainidentifier,unsigned int celltype);
174 
179  std::map<unsigned int,unsigned int>&
180  getCellTypeTrackerMap(void);
181 
186  bool checkGeometryIntegrity(void) const;
187 
188 
189  private:
193  void perturbConnections();
194 
198  void generateBoundaryNodes();
199 
203  void generatePhysicalGrid();
204 
208  void makePhysicalGridConnections();
209 
213  void makePeriodicBoundary();
214 
219  void connectGeometryNodesToPhysicalNodes(std::shared_ptr<nodes::GeometryNode> pt);
220 
224  void connectGeometryNodesToPhysicalNodes();
225 
229  void updateDomainIdentifier();
230 
234  void updateAllDomainIdentifiers();
235 
239  std::map<unsigned int,unsigned int> cellTypeTrackerMap_;
240 
244  std::vector<std::vector<nodes::PhysicalNode*> > physicalGrid_;
248  std::unordered_set<nodes::BoundaryNode*> boundaryNodes_;
249 
250  const Geometry& geometry_;
251 };
252 } // end namespace
253 } // end namespace
254 
255 #endif // GEOMETRY_GEOMETRYHANDLER_HPP
void copyCellTypeToPhysicalNodes(std::map< unsigned int, unsigned int > &celltrackermap)
update the celltypes of all *PhysicalNode*s with domainid
void eraseConnection(std::shared_ptr< Connection > toErase)
Erases the Connection.
void checkLatticeIntegrity()
Check lattice integrity.
const std::shared_ptr< nodes::GeometryNode > returnGeometryNode(const unsigned int nodeID) const
returnGeometryNode
~GeometryHandler()
~GeometryHandler Destroyes all nodes.
std::map< unsigned int, double > computeAccumulatedDomainConcentrations(const std::string &name) const
Compute the accumulated concentrations of species name in all domains.
bool checkGeometryIntegrity(void) const
checkGeometryIntegrity
void createConnection(std::shared_ptr< nodes::GeometryNode > const p1, std::shared_ptr< nodes::GeometryNode > const p2, const std::map< std::string, std::vector< std::string > > boundaryconditiondescriptor, const unsigned int domainidentifier)
Create a new connection.
void coarsenBoundary()
If *Connection*s are too short, a GeometryNode is remove.
void moveLattice()
moveLattcie Updates the Lattice after the Geometric Points have been moved
const Geometry & getGeometry() const
getter for the geometry
void cureLattice()
Cure the Lattice: update *BoundaryNode*s, DomainIdentifier, and IB connections.
const std::map< unsigned int, double > computeAreas() const
Compute the areas of the domains by using the domainIdentifiers.
unsigned int remeshBoundary()
If a Connection is too long, a GeometryNode is added and linked.
void checkBoundaryNodeIntegrity()
checkBoundaryNodeIntegrity Checks the integrity of the boundary node pairs.
unsigned int createGeometryNode(const double xpos, const double ypos)
Add a new GeometryNode.
const std::unordered_set< nodes::BoundaryNode * > & getBoundaryNodes() const
Getter for the Boundary nodes.
GeometryHandler(const Geometry &geometry)
GeometryHandler Constructs the simulation grid.
class representing the external geometry
Definition: Geometry.hpp:68
std::map< unsigned int, unsigned int > & getCellTypeTrackerMap(void)
Returns a reference to the cellTypeTrackerMap.
const std::vector< std::vector< nodes::PhysicalNode * > > & getPhysicalNodes() const
getPhysicalNodes Getter method for the physical node grid
class responsible for generating the internal geometry representation