Bembel
Geometry.hpp
1 // This file is part of Bembel, the higher order C++ boundary element library.
2 //
3 // Copyright (C) 2024 see <http://www.bembel.eu>
4 //
5 // It was written as part of a cooperation of J. Doelz, H. Harbrecht, S. Kurz,
6 // M. Multerer, S. Schoeps, and F. Wolf at Technische Universitaet Darmstadt,
7 // Universitaet Basel, and Universita della Svizzera italiana, Lugano. This
8 // source code is subject to the GNU General Public License version 3 and
9 // provided WITHOUT ANY WARRANTY, see <http://www.bembel.eu> for further
10 // information.
11 #ifndef BEMBEL_SRC_GEOMETRY_GEOMETRY_HPP_
12 #define BEMBEL_SRC_GEOMETRY_GEOMETRY_HPP_
13 
14 namespace Bembel {
20 class Geometry {
21  public:
23  // Constructors
25 
28  Geometry() {}
37  explicit Geometry(const std::string &filename) { init_Geometry(filename); }
41  Geometry(Geometry &&other) { geometry_ = std::move(other.geometry_); }
48  Geometry(const Geometry &other) {
49  geometry_ = std::make_shared<PatchVector>();
50  *geometry_ = *(other.geometry_);
51  }
60  explicit Geometry(const PatchVector &in) {
61  geometry_ = std::make_shared<PatchVector>();
62  *geometry_ = in;
63  }
73  std::swap(geometry_, other.geometry_);
74  return *this;
75  }
77  // init_Geometry
79 
89  inline void init_Geometry(const std::string &filename) {
90  std::string file_suffix = filename.substr(filename.find('.') + 1);
91  PatchVector tmp;
92 
93  if (file_suffix.compare("dat") == 0)
94  tmp = PatchShredder(LoadGeometryFileDAT(filename));
95  else if (file_suffix.compare("igs") == 0)
96  tmp = PatchShredder(LoadGeometryFileIGS(filename));
97  else
98  assert(!"File type unknown!");
99 
100  geometry_ = std::make_shared<PatchVector>();
101  *geometry_ = tmp;
102  }
104  // getters
106 
111  const PatchVector &get_geometry() const { return *geometry_; }
117  PatchVector &get_geometry() { return *geometry_; }
123  const std::shared_ptr<PatchVector> get_geometry_ptr() const {
124  return geometry_;
125  }
131  std::shared_ptr<PatchVector> get_geometry_ptr() { return geometry_; }
132 
138  int get_number_of_patches() const { return geometry_->size(); }
140  // private member variables
142  private:
143  std::shared_ptr<PatchVector> geometry_;
144 };
145 } // namespace Bembel
146 #endif // BEMBEL_SRC_GEOMETRY_GEOMETRY_HPP_
this class wraps a GeometryVector and provides some basic functionality, like reading Geometry files
Definition: Geometry.hpp:20
void init_Geometry(const std::string &filename)
Initialize the geometry from a geometry given by a file.
Definition: Geometry.hpp:89
Geometry(Geometry &&other)
Move constructor.
Definition: Geometry.hpp:41
Geometry(const PatchVector &in)
Copy constructor.
Definition: Geometry.hpp:60
Geometry(const std::string &filename)
Constructor.
Definition: Geometry.hpp:37
const std::shared_ptr< PatchVector > get_geometry_ptr() const
Return const pointer to the geometry.
Definition: Geometry.hpp:123
Geometry()
Default constructor.
Definition: Geometry.hpp:28
int get_number_of_patches() const
Get number of patches.
Definition: Geometry.hpp:138
PatchVector & get_geometry()
Return reference to the geometry.
Definition: Geometry.hpp:117
const PatchVector & get_geometry() const
Return const reference to the geometry.
Definition: Geometry.hpp:111
Geometry & operator=(Geometry other)
Copy assignment operator for the Geometry class.
Definition: Geometry.hpp:72
std::shared_ptr< PatchVector > get_geometry_ptr()
Return pointer to the geometry.
Definition: Geometry.hpp:131
Geometry(const Geometry &other)
Copy constructor.
Definition: Geometry.hpp:48
std::vector< Bembel::Patch > PatchVector
typedef for PatchVector
Definition: PatchVector.hpp:24
std::vector< Patch > LoadGeometryFileIGS(const std::string &file_name) noexcept
loads geometry from IGES file. Note that the direction of the normals must be consistent.
Definition: GeometryIGS.hpp:25
std::vector< Patch > LoadGeometryFileDAT(const std::string &file_name) noexcept
loads geometry from file with GEOPDE-format. Note that the direction of the normals must be consisten...
Definition: GeometryIO.hpp:25
Routines for the evalutation of pointwise errors.
Definition: AnsatzSpace.hpp:14
std::vector< Patch > PatchShredder(const Patch &patch) noexcept
This function cuts a patch along internal knots, if any.
Definition: Patch.hpp:386