LBIBCell
 All Classes Functions Variables Friends Pages
Geometry.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_GEOMETRY_HPP
23 #define GEOMETRY_GEOMETRY_HPP
24 
25 #include <LbmLib/include/nodes/GeometryNode.hpp>
26 #include <LbmLib/include/Constants.hpp>
27 #include <UtilLib/include/geometry/FastNeighborList.hpp>
28 #include <map>
29 #include <memory>
30 #include <string>
31 #include <vector>
32 #include <boost/geometry/geometry.hpp>
33 #include <boost/geometry/geometries/register/point.hpp>
34 #include <boost/geometry/index/rtree.hpp>
35 
36 BOOST_GEOMETRY_REGISTER_POINT_2D_GET_SET(LbmLib::nodes::GeometryNode,
37  double,
38  cs::cartesian,
43 
44 namespace boost {
45 namespace geometry {
46 namespace index {
47 
48 //specializing indexable to store shared_ptr in rtree:
49 template <typename Value>
50 struct indexable <std::shared_ptr<Value> >
51 {
52  typedef Value const& result_type;
53  result_type operator() (std::shared_ptr<Value> const& v) const { return *v; }
54 };
55 
56 } // end namespace index
57 } // end namespace geometry
58 } // end namespace boost
59 
60 namespace LbmLib {
61 namespace geometry {
62 
63 class Connection;
64 
68 class Geometry {
69  public:
74  explicit Geometry(const std::string& filename);
75 
79  ~Geometry();
80 
85  void writeGeometry(const std::string& fileName) const;
86 
91  const std::map<unsigned int,
92  std::shared_ptr<nodes::GeometryNode> >& getGeometryNodes() const {
93  return geometryNodes_;
94  }
95 
103  const std::vector<std::shared_ptr<nodes::GeometryNode> > getGeometryNodesWithinRadius(const double x,
104  const double y,
105  const double radius) const;
106 
107 
108 
117  const std::vector<std::shared_ptr<nodes::GeometryNode> > getGeometryNodesWithinRadiusWithAvoidance(const double x,
118  const double y,
119  const double radius,
120  const unsigned int avoidDomainID) const;
129  std::shared_ptr<nodes::GeometryNode> getGeometryNodesWithinRadiusWithAvoidanceClosest(const double x,
130  const double y,
131  const double radius,
132  const unsigned int avoidDomainID) const;
133 
138  const std::vector<std::shared_ptr<Connection> >& getConnections() const;
139 
146  unsigned int addGeometryNode(const double x,const double y);
147 
153  unsigned int removeGeometryNode(const unsigned int nodeid);
154 
159  void eraseConnection(std::shared_ptr<Connection> toDelete);
160 
168  void addConnection(std::shared_ptr<nodes::GeometryNode> p1,
169  std::shared_ptr<nodes::GeometryNode> p2,
170  const std::map<std::string, std::vector<std::string> > boundaryConditionDescriptor,
171  const unsigned int domainIdentifier);
172 
176  void moveGeometryNodes();
177 
182  bool checkGeometryIntegrity() const;
183 
188 
193 
198  std::map<unsigned int, unsigned int> getCellTypeTrackerMap(void) const;
199 
200 private:
205  void loadGeometryTXT(const std::string& fileName);
206 
211  void loadGeometryVTK(const std::string& fileName);
212 
216  std::vector<std::shared_ptr<Connection> > connections_;
217 
222  std::map<unsigned int,
223  std::shared_ptr<nodes::GeometryNode> > geometryNodes_;
224 
229 
233  mutable bool isValidRangeQueryDataStructure_;
234 
239  std::map<unsigned int,unsigned int> cellTypeTrackerMap_;
240 };
241 
242 } // end namespace
243 } // end namespace
244 #endif // GEOMETRY_GEOMETRY_HPP
const std::vector< std::shared_ptr< nodes::GeometryNode > > getGeometryNodesWithinRadiusWithAvoidance(const double x, const double y, const double radius, const unsigned int avoidDomainID) const
getGeometryNodesWithinRadiusWithAvoidance Range query, but only nodes with domainID different from av...
Definition: Geometry.cpp:341
unsigned int removeGeometryNode(const unsigned int nodeid)
removeGeometryNode Removes the GeometryNode with nodeid. One of the connections is removed...
Definition: Geometry.cpp:416
void setYPos(double y)
setYPos Set a new y position.
const std::map< unsigned int, std::shared_ptr< nodes::GeometryNode > > & getGeometryNodes() const
Getter for the geometry nodes.
Definition: Geometry.hpp:92
void moveGeometryNodes()
Geometry::moveGeometryNodes moves the *GeometryNode*s according to the local velocity field...
Definition: Geometry.cpp:469
class representing a geometry node
double getYPos() const
getYPos Getter for the Y position
void setXPos(double x)
setXPos Set a new x position.
The fastneighborlist class is a class template putting objects of type T into a celllist data structu...
unsigned int addGeometryNode(const double x, const double y)
addGeometryNode Add a GeometryNode. The NodeID is bumped automatically.
Definition: Geometry.cpp:396
Geometry(const std::string &filename)
Geometry constructs the geometry of the simulation.
Definition: Geometry.cpp:56
void reconstructRangeQueryDataStructure() const
reconstructRangeQueryDataStructure
Definition: Geometry.cpp:546
const std::vector< std::shared_ptr< Connection > > & getConnections() const
getConnections Getter for connections
Definition: Geometry.cpp:391
bool checkGeometryIntegrity() const
checkGeometryIntegrity
Definition: Geometry.cpp:508
~Geometry()
~Geometry Plain.
Definition: Geometry.cpp:74
void addConnection(std::shared_ptr< nodes::GeometryNode > p1, std::shared_ptr< nodes::GeometryNode > p2, const std::map< std::string, std::vector< std::string > > boundaryConditionDescriptor, const unsigned int domainIdentifier)
addConnection Add a Connection.
Definition: Geometry.cpp:448
double getXPos() const
getXPos Getter for the X position
class representing the external geometry
Definition: Geometry.hpp:68
void writeGeometry(const std::string &fileName) const
writeGeometry Writes the geometry to the file
Definition: Geometry.cpp:77
void eraseConnection(std::shared_ptr< Connection > toDelete)
eraseConnection Erase the connection.
Definition: Geometry.cpp:486
const std::vector< std::shared_ptr< nodes::GeometryNode > > getGeometryNodesWithinRadius(const double x, const double y, const double radius) const
getGeometryNodesWithinRadius Range query
Definition: Geometry.cpp:324
std::shared_ptr< nodes::GeometryNode > getGeometryNodesWithinRadiusWithAvoidanceClosest(const double x, const double y, const double radius, const unsigned int avoidDomainID) const
getGeometryNodesWithinRadiusWithAvoidanceClosest Return closest GeometryNode, but only nodes with dom...
Definition: Geometry.cpp:366
void invalidateRangeQueryDataStructure()
invalidateRangeQueryDataStructure Sets the internal flag to false.
Definition: Geometry.cpp:541
std::map< unsigned int, unsigned int > getCellTypeTrackerMap(void) const
Returns a reference to the cellTypeTrackerMap.
Definition: Geometry.cpp:552