Medusa  1.1
Coordinate Free Mehless Method implementation
BallShape_fwd.hpp
Go to the documentation of this file.
1 #ifndef MEDUSA_BITS_DOMAINS_BALLSHAPE_FWD_HPP_
2 #define MEDUSA_BITS_DOMAINS_BALLSHAPE_FWD_HPP_
3 
11 #include <medusa/Config.hpp>
13 #include "DomainShape_fwd.hpp"
14 
15 namespace mm {
23 template <typename vec_t>
24 class BallShape : public DomainShape<vec_t> {
25  vec_t center_;
26  double radius_;
28 
29  public:
30  using typename DomainShape<vec_t>::scalar_t;
41  BallShape(const vec_t& center, double radius) : center_(center), radius_(radius) {}
43  const vec_t& center() const { return center_; }
45  scalar_t radius() const { return radius_; }
46 
47  bool contains(const vec_t& point) const override {
48  return (center_ - point).squaredNorm() < (radius_ + margin_)*(radius_ + margin_);
49  }
50 
51  std::pair<vec_t, vec_t> bbox() const override {
52  return {center_ - vec_t(radius_), center_ + vec_t(radius_)};
53  }
54 
57  scalar_t step, int internal_type, int boundary_type) const override;
59  const std::function<scalar_t(vec_t)>& dr, int type) const override;
60 
61  BallShape<vec_t>* clone() const override { return new BallShape<vec_t>(*this); }
62  std::ostream& print(std::ostream& os) const override;
63 };
64 
65 } // namespace mm
66 
67 #endif // MEDUSA_BITS_DOMAINS_BALLSHAPE_FWD_HPP_
mm::DomainShape::margin_
scalar_t margin_
Tolerance for the geometric operation of the domain.
Definition: DomainShape_fwd.hpp:64
mm::BallShape
Class for working with ball shaped domains.
Definition: BallShape_fwd.hpp:24
mm
Root namespace for the whole library.
Definition: Gaussian.hpp:14
mm::BallShape::radius_
double radius_
Radius of the ball.
Definition: BallShape_fwd.hpp:26
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
mm::BallShape::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: BallShape.hpp:19
mm::BallShape::bbox
std::pair< vec_t, vec_t > bbox() const override
Return the bounding box of the domain.
Definition: BallShape_fwd.hpp:51
mm::BallShape::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: BallShape.hpp:33
mm::BallShape::center
const vec_t & center() const
Returns the position of the centre of the ball.
Definition: BallShape_fwd.hpp:43
mm::DomainShape
Base class for geometric shapes of domains.
Definition: DomainShape_fwd.hpp:52
Config.hpp
mm::BallShape::print
std::ostream & print(std::ostream &os) const override
Output information about this shape to given output stream os.
Definition: BallShape.hpp:64
Vec_fwd.hpp
mm::BallShape::clone
BallShape< vec_t > * clone() const override
Polymorphic clone pattern.
Definition: BallShape_fwd.hpp:61
mm::BallShape::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: BallShape.hpp:70
mm::BallShape::contains
bool contains(const vec_t &point) const override
Return true if point is not more than margin() outside the domain.
Definition: BallShape_fwd.hpp:47
mm::BallShape::BallShape
BallShape(const vec_t &center, double radius)
Constructs a d-dimensional ball defined by its center and radius.
Definition: BallShape_fwd.hpp:41
mm::BallShape::center_
vec_t center_
Center of the ball.
Definition: BallShape_fwd.hpp:25
mm::DomainShape::scalar_t
vec_t::Scalar scalar_t
Scalar data type used in computation.
Definition: DomainShape_fwd.hpp:55
DomainShape_fwd.hpp
mm::BallShape::radius
scalar_t radius() const
Returns the radius of the ball.
Definition: BallShape_fwd.hpp:45