Medusa  1.1
Coordinate Free Mehless Method implementation
ShapeUnion.hpp
Go to the documentation of this file.
1 #ifndef MEDUSA_BITS_DOMAINS_SHAPEUNION_HPP_
2 #define MEDUSA_BITS_DOMAINS_SHAPEUNION_HPP_
3 
4 #include "ShapeUnion_fwd.hpp"
6 #include <utility>
7 #include <cmath>
8 
14 namespace mm {
15 
16 template <typename vec_t>
18  int type) const {
19  auto d1 = sh1->discretizeBoundaryWithStep(step, type);
20  auto d2 = sh2->discretizeBoundaryWithStep(step, type);
21  return d1.add(d2);
22 }
23 
24 template <typename vec_t>
26  scalar_t step, int internal_type, int boundary_type) const {
27  auto d1 = sh1->discretizeWithStep(step, internal_type, boundary_type);
28  auto d2 = sh2->discretizeWithStep(step, internal_type, boundary_type);
29  return d1.add(d2);
30 }
31 
32 template <typename vec_t>
34  const std::function<scalar_t(vec_t)>& dr, int type) const {
35  auto d1 = sh1->discretizeBoundaryWithDensity(dr, type);
36  auto d2 = sh2->discretizeBoundaryWithDensity(dr, type);
37  return d1.add(d2);
38 }
39 
40 template <typename vec_t>
42  const std::function<scalar_t(vec_t)>& dr, int internal_type,
43  int boundary_type) const {
44  auto d1 = sh1->discretizeWithDensity(dr, internal_type, boundary_type);
45  auto d2 = sh2->discretizeWithDensity(dr, internal_type, boundary_type);
46  return d1.add(d2);
47 }
48 
49 template <typename vec_t>
50 std::pair<vec_t, vec_t> ShapeUnion<vec_t>::bbox() const {
51  vec_t lo, hi, lo1, hi1, lo2, hi2;
52  std::tie(lo1, hi1) = sh1->bbox();
53  std::tie(lo2, hi2) = sh2->bbox();
54  for (int i = 0; i < dim; ++i) {
55  lo[i] = std::min(lo1[i], lo2[i]);
56  hi[i] = std::max(hi1[i], hi2[i]);
57  }
58  return {lo, hi};
59 }
60 
61 template <typename vec_t>
62 std::ostream& ShapeUnion<vec_t>::print(std::ostream& os) const {
63  return os << "ShapeUnion(" << *sh1 << ", " << *sh2 << ")";
64 }
65 
66 } // namespace mm
67 
68 #endif // MEDUSA_BITS_DOMAINS_SHAPEUNION_HPP_
mm::sh::d1
static const shape_flags d1
Indicates to calculate d1 shapes.
Definition: shape_flags.hpp:23
mm
Root namespace for the whole library.
Definition: Gaussian.hpp:14
scalar_t
Scalar scalar_t
Type of the elements, alias of Scalar.
Definition: MatrixBaseAddons.hpp:16
mm::DomainDiscretization
Class representing domain discretization along with an associated shape.
Definition: DomainDiscretization_fwd.hpp:46
DomainDiscretization.hpp
mm::ShapeUnion::discretizeWithDensity
DomainDiscretization< vec_t > discretizeWithDensity(const std::function< scalar_t(vec_t)> &dr, int internal_type, int boundary_type) const override
Returns a discretization of the domain with spatially variable step.
Definition: ShapeUnion.hpp:41
mm::ShapeUnion::discretizeWithStep
DomainDiscretization< vec_t > discretizeWithStep(scalar_t step, int internal_type, int boundary_type) const override
Returns a discretization of this shape with approximately uniform distance step between nodes.
Definition: ShapeUnion.hpp:25
dim
@ dim
Number of elements of this matrix.
Definition: MatrixBaseAddons.hpp:14
mm::ShapeUnion::discretizeBoundaryWithStep
DomainDiscretization< vec_t > discretizeBoundaryWithStep(scalar_t step, int type) const override
Returns a discretization of the boundary of this shape with approximately uniform distance step betwe...
Definition: ShapeUnion.hpp:17
mm::sh::d2
static const shape_flags d2
Indicates to calculate d2 shapes.
Definition: shape_flags.hpp:25
ShapeUnion_fwd.hpp
mm::ShapeUnion::bbox
std::pair< vec_t, vec_t > bbox() const override
Return the bounding box of the domain.
Definition: ShapeUnion.hpp:50
mm::ShapeUnion::discretizeBoundaryWithDensity
DomainDiscretization< vec_t > discretizeBoundaryWithDensity(const std::function< scalar_t(vec_t)> &dr, int type) const override
Discretizes boundary with given density and fill engine.
Definition: ShapeUnion.hpp:33
mm::DomainShape::scalar_t
vec_t::Scalar scalar_t
Scalar data type used in computation.
Definition: DomainShape_fwd.hpp:55
mm::ShapeUnion::print
std::ostream & print(std::ostream &os) const override
Output information about this shape to given output stream os.
Definition: ShapeUnion.hpp:62