PeriDEM 0.3.0
PeriDEM -- Peridynamics-based high-fidelity model for granular media
Loading...
Searching...
No Matches
geom::AnnulusGeomObject Class Reference

Defines annulus rectangle. More...

#include <complexGeomObjects.h>

Inheritance diagram for geom::AnnulusGeomObject:
Collaboration diagram for geom::AnnulusGeomObject:

Public Member Functions

 AnnulusGeomObject ()
 Constructor.
 
 AnnulusGeomObject (GeomObject *in, GeomObject *out, std::string description="")
 Constructor.
 
 AnnulusGeomObject (const AnnulusGeomObject &other)
 Copy constructor.
 
 ~AnnulusGeomObject ()
 Destructor.
 
AnnulusGeomObjectoperator= (const AnnulusGeomObject &other)
 Assignment operator.
 
void transform (const util::Point &translation, const double &scale, const double &angle, const util::Point &axis, const util::Point *rotationPoint) override
 Similarity about pivot \(\mathbf p\) (default: old center d_x), then rigid displacement \(\mathbf t\) = translation: \(\mathbf y = \mathbf p + s\,\mathbf R(\mathbf x-\mathbf p) + \mathbf t\). When \(\theta=0\) and \(s=1\), \(\mathbf y = \mathbf x + \mathbf t\) for every point and the center.
 
double volume () const override
 Computes the volume (area in 2d, length in 1d) of object.
 
util::Point center () const override
 Computes the center of object.
 
std::pair< util::Point, util::Pointbox () const override
 Computes the bounding box of object.
 
std::pair< util::Point, util::Pointbox (const double &tol) const override
 Computes the bounding box of object.
 
double inscribedRadius () const override
 Computes the radius of biggest circle/sphere completely within the object.
 
double boundingRadius () const override
 Computes the radius of smallest circle/sphere such that object can be fit into it.
 
std::string printStr (int nt, int lvl) const override
 Returns the string containing printable information about the object.
 
void print (int nt, int lvl) const override
 Prints the information about the object.
 
void print () const override
 Prints the information about the object.
 
Interaction with point
bool isInside (const util::Point &x) const override
 Checks if point is inside this object.
 
bool isOutside (const util::Point &x) const override
 Checks if point is outside of this object.
 
bool isNear (const util::Point &x, const double &tol) const override
 Checks if point is within given distance of this object.
 
bool isNearBoundary (const util::Point &x, const double &tol, const bool &within) const override
 cons
 
bool doesIntersect (const util::Point &x) const override
 Checks if point lies exactly on the boundary.
 
Interaction with box
bool isInside (const std::pair< util::Point, util::Point > &box) const override
 Checks if box is completely inside.
 
bool isOutside (const std::pair< util::Point, util::Point > &box) const override
 Checks if box is outside of the object.
 
bool isNear (const std::pair< util::Point, util::Point > &box, const double &tol) const override
 Checks if box is within given distance of this object.
 
bool doesIntersect (const std::pair< util::Point, util::Point > &box) const override
 Checks if box intersects this object.
 
- Public Member Functions inherited from geom::GeomObject
 GeomObject (std::string name="", std::string description="")
 Constructor.
 
virtual bool wallContactQuery (const util::Point &x, WallContactHit &hit) const
 Closest-point / signed-gap query for analytical wall contact. Default: unsupported (returns false, clears hit).
 

Data Fields

GeomObjectd_outObj_p
 Outer object.
 
GeomObjectd_inObj_p
 Inner object.
 
size_t d_dim
 Dimension objects live in.
 
- Data Fields inherited from geom::GeomObject
const std::string d_name
 name of object
 
const std::string d_description
 Further description of object.
 
std::vector< std::string > d_tags
 Tags/attributes about the object.
 

Detailed Description

Defines annulus rectangle.

Definition at line 27 of file complexGeomObjects.h.

Constructor & Destructor Documentation

◆ AnnulusGeomObject() [1/3]

geom::AnnulusGeomObject::AnnulusGeomObject ( )
inline

Constructor.

Definition at line 42 of file complexGeomObjects.h.

43 : GeomObject("annulus_object", ""),
44 d_outObj_p(nullptr),
45 d_inObj_p(nullptr),
46 d_dim(0) {
47 };
GeomObject * d_outObj_p
Outer object.
size_t d_dim
Dimension objects live in.
GeomObject * d_inObj_p
Inner object.
GeomObject(std::string name="", std::string description="")
Constructor.

◆ AnnulusGeomObject() [2/3]

geom::AnnulusGeomObject::AnnulusGeomObject ( GeomObject in,
GeomObject out,
std::string  description = "" 
)
inline

Constructor.

Parameters
inInner object
outOuter object
descriptionDescription of object (e.g., further classification or any tag)

Definition at line 56 of file complexGeomObjects.h.

57 : GeomObject("annulus_object", description),
58 d_outObj_p(out),
59 d_inObj_p(in),
60 d_dim(0) {
61 d_dim = getGeomTypeToDim(d_outObj_p->d_name); // assume all types have same dim
62 };
const std::string d_name
name of object
size_t getGeomTypeToDim(std::string type)
Returns list of acceptable geometries for PeriDEM simulation.
Definition geomObjects.h:47

References d_dim, geom::GeomObject::d_name, d_outObj_p, and geom::getGeomTypeToDim().

Here is the call graph for this function:

◆ AnnulusGeomObject() [3/3]

geom::AnnulusGeomObject::AnnulusGeomObject ( const AnnulusGeomObject other)
inline

Copy constructor.

Parameters
otherObject to copy from
Note
This performs a deep copy of the inner and outer objects

Definition at line 69 of file complexGeomObjects.h.

70 : GeomObject(other.d_name, other.d_description),
71 d_outObj_p(nullptr),
72 d_inObj_p(nullptr),
73 d_dim(other.d_dim) {
74 // Copy tags from base class
75 d_tags = other.d_tags;
76
77 // Deep copy inner and outer objects using utility function
78 d_inObj_p = createGeomDeepCopy(other.d_inObj_p);
79 d_outObj_p = createGeomDeepCopy(other.d_outObj_p);
80 }
std::vector< std::string > d_tags
Tags/attributes about the object.
GeomObject * createGeomDeepCopy(GeomObject *obj)
Creates a deep copy of a geometric object.

References geom::createGeomDeepCopy(), d_inObj_p, d_outObj_p, and geom::GeomObject::d_tags.

Here is the call graph for this function:

◆ ~AnnulusGeomObject()

geom::AnnulusGeomObject::~AnnulusGeomObject ( )
inline

Destructor.

Definition at line 85 of file complexGeomObjects.h.

85 {
86 delete d_inObj_p;
87 delete d_outObj_p;
88 }

References d_inObj_p, and d_outObj_p.

Member Function Documentation

◆ boundingRadius()

double geom::AnnulusGeomObject::boundingRadius ( ) const
overridevirtual

Computes the radius of smallest circle/sphere such that object can be fit into it.

Returns
Radius Radius of bounding circle/sphere

Reimplemented from geom::GeomObject.

Definition at line 77 of file complexGeomObjects.cpp.

77 {
78
79 return d_outObj_p->boundingRadius();
80 }
virtual double boundingRadius() const
Computes the radius of smallest circle/sphere such that object can be fit into it.

References geom::GeomObject::boundingRadius(), and d_outObj_p.

Here is the call graph for this function:

◆ box() [1/2]

std::pair< util::Point, util::Point > geom::AnnulusGeomObject::box ( ) const
overridevirtual

Computes the bounding box of object.

Returns
Pair Left-bottom-back and right-top-front corner points of box

Reimplemented from geom::GeomObject.

Definition at line 62 of file complexGeomObjects.cpp.

63 {
64 return d_outObj_p->box();
65 }
virtual std::pair< util::Point, util::Point > box() const
Computes the bounding box of object.

References geom::GeomObject::box(), and d_outObj_p.

Referenced by doesIntersect(), isInside(), isNear(), isOutside(), and printStr().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ box() [2/2]

std::pair< util::Point, util::Point > geom::AnnulusGeomObject::box ( const double &  tol) const
overridevirtual

Computes the bounding box of object.

Parameters
tolTolerance/padding used in creating bounding box
Returns
Pair Left-bottom-back and right-top-front corner points of box

Reimplemented from geom::GeomObject.

Definition at line 67 of file complexGeomObjects.cpp.

68 {
69 return d_outObj_p->box(tol);
70 }

References geom::GeomObject::box(), and d_outObj_p.

Here is the call graph for this function:

◆ center()

util::Point geom::AnnulusGeomObject::center ( ) const
overridevirtual

Computes the center of object.

Returns
Point Coordinates of center

Reimplemented from geom::GeomObject.

Definition at line 48 of file complexGeomObjects.cpp.

48 {
49
50 // we use the formula for centroid of composite objects
51 // x = sum_i sign(i) V_i x_i / sum_i sign(i) V_i
52 // where sign(i) = +1 if object is filling
53 // sign(i) = -1 if object is empty
54 auto vol = volume();
55 if (util::isGreater(vol, 0.))
56 return (1./vol) * (d_outObj_p->volume() * d_outObj_p->center()
58 else
59 return d_outObj_p->center();
60 }
double volume() const override
Computes the volume (area in 2d, length in 1d) of object.
virtual double volume() const
Computes the volume (area in 2d, length in 1d) of object.
virtual util::Point center() const
Computes the center of object.
bool isGreater(const double &a, const double &b)
Returns true if a > b.
Definition function.cpp:15

References geom::GeomObject::center(), d_inObj_p, d_outObj_p, util::isGreater(), geom::GeomObject::volume(), and volume().

Referenced by mesh_gen::anonymous_namespace{annulusMesh2D.cpp}::embedPointInAnnulus2D(), mesh_gen::anonymous_namespace{annulusMesh3D.cpp}::embedPointInAnnulus3D(), printStr(), and transform().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ doesIntersect() [1/2]

bool geom::AnnulusGeomObject::doesIntersect ( const std::pair< util::Point, util::Point > &  box) const
overridevirtual

Checks if box intersects this object.

Parameters
boxBox
Returns
True True if intersects

Reimplemented from geom::GeomObject.

Definition at line 142 of file complexGeomObjects.cpp.

143 {
144
145 // need to check all four corner points
146 for (auto p: geom::getCornerPoints(d_dim, box))
147 if (this->isInside(p))
148 return true;
149
150 return false;
151 }
bool isInside(const util::Point &x) const override
Checks if point is inside this object.
std::pair< util::Point, util::Point > box() const override
Computes the bounding box of object.
std::vector< util::Point > getCornerPoints(size_t dim, const std::pair< util::Point, util::Point > &box)
Returns all corner points in the box.

References box(), d_dim, geom::getCornerPoints(), and isInside().

Here is the call graph for this function:

◆ doesIntersect() [2/2]

bool geom::AnnulusGeomObject::doesIntersect ( const util::Point x) const
overridevirtual

Checks if point lies exactly on the boundary.

Parameters
xPoint
Returns
True True if it lies on the boundary

Reimplemented from geom::GeomObject.

Definition at line 109 of file complexGeomObjects.cpp.

110 {
111
112 return isNearBoundary(x, 1.0E-8, false);
113 }
bool isNearBoundary(const util::Point &x, const double &tol, const bool &within) const override
cons

References isNearBoundary().

Here is the call graph for this function:

◆ inscribedRadius()

double geom::AnnulusGeomObject::inscribedRadius ( ) const
overridevirtual

Computes the radius of biggest circle/sphere completely within the object.

Returns
Radius Radius of inscribed circle/sphere

Reimplemented from geom::GeomObject.

Definition at line 72 of file complexGeomObjects.cpp.

72 {
73
75 }
virtual double inscribedRadius() const
Computes the radius of biggest circle/sphere completely within the object.

References d_outObj_p, and geom::GeomObject::inscribedRadius().

Here is the call graph for this function:

◆ isInside() [1/2]

bool geom::AnnulusGeomObject::isInside ( const std::pair< util::Point, util::Point > &  box) const
overridevirtual

Checks if box is completely inside.

Parameters
boxBox
Returns
True True if box lies inside

Reimplemented from geom::GeomObject.

Definition at line 115 of file complexGeomObjects.cpp.

116 {
117
118 for (auto p: geom::getCornerPoints(d_dim, box))
119 if (!this->isInside(p))
120 return false;
121
122 return true;
123 }

References box(), d_dim, geom::getCornerPoints(), and isInside().

Here is the call graph for this function:

◆ isInside() [2/2]

bool geom::AnnulusGeomObject::isInside ( const util::Point x) const
overridevirtual

Checks if point is inside this object.

Parameters
xPoint
Returns
True If point lies inside

Reimplemented from geom::GeomObject.

Definition at line 83 of file complexGeomObjects.cpp.

83 {
84
85 // should be outside inner object and inside outer object
86 return !d_inObj_p->isInside(x) && d_outObj_p->isInside(x);
87 }
virtual bool isInside(const util::Point &x) const
Checks if point is inside this object.

References d_inObj_p, d_outObj_p, and geom::GeomObject::isInside().

Referenced by doesIntersect(), isInside(), isOutside(), and isOutside().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isNear() [1/2]

bool geom::AnnulusGeomObject::isNear ( const std::pair< util::Point, util::Point > &  box,
const double &  tol 
) const
overridevirtual

Checks if box is within given distance of this object.

Parameters
boxBox
tolTolerance used in checking the nearness
Returns
True True if box is inside within the tol distance

Reimplemented from geom::GeomObject.

Definition at line 135 of file complexGeomObjects.cpp.

137 {
138
139 return d_outObj_p->isNear(box, tol) || d_inObj_p->isNear(box, tol);
140 }
virtual bool isNear(const util::Point &x, const double &tol) const
Checks if point is within given distance of this object.

References box(), d_inObj_p, d_outObj_p, and geom::GeomObject::isNear().

Here is the call graph for this function:

◆ isNear() [2/2]

bool geom::AnnulusGeomObject::isNear ( const util::Point x,
const double &  tol 
) const
overridevirtual

Checks if point is within given distance of this object.

Parameters
xPoint
tolTolerance used in checking the nearness
Returns
True True if within the tol distance

Reimplemented from geom::GeomObject.

Definition at line 94 of file complexGeomObjects.cpp.

95 {
96
97 return d_outObj_p->isNear(x, tol) || d_inObj_p->isNear(x, tol);
98 }

References d_inObj_p, d_outObj_p, and geom::GeomObject::isNear().

Here is the call graph for this function:

◆ isNearBoundary()

bool geom::AnnulusGeomObject::isNearBoundary ( const util::Point x,
const double &  tol,
const bool &  within 
) const
overridevirtual

cons

cons

Reimplemented from geom::GeomObject.

Definition at line 100 of file complexGeomObjects.cpp.

103 {
104
105 return d_outObj_p->isNearBoundary(x, tol, within) ||
106 d_inObj_p->isNearBoundary(x, tol, within);
107 }
virtual bool isNearBoundary(const util::Point &x, const double &tol, const bool &within) const
Checks if point is within given distance of this object.

References d_inObj_p, d_outObj_p, and geom::GeomObject::isNearBoundary().

Referenced by doesIntersect().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isOutside() [1/2]

bool geom::AnnulusGeomObject::isOutside ( const std::pair< util::Point, util::Point > &  box) const
overridevirtual

Checks if box is outside of the object.

Parameters
boxBox
Returns
True True if box lies outside

Reimplemented from geom::GeomObject.

Definition at line 125 of file complexGeomObjects.cpp.

126 {
127
128 bool intersect = false;
129 for (auto p: geom::getCornerPoints(d_dim, box))
130 intersect = this->isInside(p);
131
132 return !intersect;
133 }

References box(), d_dim, geom::getCornerPoints(), and isInside().

Here is the call graph for this function:

◆ isOutside() [2/2]

bool geom::AnnulusGeomObject::isOutside ( const util::Point x) const
overridevirtual

Checks if point is outside of this object.

Parameters
xPoint
Returns
True If point lies outside

Reimplemented from geom::GeomObject.

Definition at line 90 of file complexGeomObjects.cpp.

90 {
91 return !isInside(x);
92 }

References isInside().

Here is the call graph for this function:

◆ operator=()

AnnulusGeomObject & geom::AnnulusGeomObject::operator= ( const AnnulusGeomObject other)
inline

Assignment operator.

Parameters
otherObject to copy from
Returns
Reference to this object

Definition at line 95 of file complexGeomObjects.h.

95 {
96 if (this != &other) {
97 // Clean up existing objects
98 delete d_inObj_p;
99 delete d_outObj_p;
100 d_inObj_p = nullptr;
101 d_outObj_p = nullptr;
102
103 // Copy base class members
104 d_tags = other.d_tags;
105 d_dim = other.d_dim;
106
107 // Deep copy inner and outer objects using utility function
108 d_inObj_p = createGeomDeepCopy(other.d_inObj_p);
109 d_outObj_p = createGeomDeepCopy(other.d_outObj_p);
110 }
111 return *this;
112 }

References geom::createGeomDeepCopy(), d_dim, d_inObj_p, d_outObj_p, and geom::GeomObject::d_tags.

Here is the call graph for this function:

◆ print() [1/2]

void geom::AnnulusGeomObject::print ( ) const
inlineoverridevirtual

Prints the information about the object.

Reimplemented from geom::GeomObject.

Definition at line 257 of file complexGeomObjects.h.

257{ print(0, 0); };
void print() const override
Prints the information about the object.

References print().

Referenced by print().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ print() [2/2]

void geom::AnnulusGeomObject::print ( int  nt,
int  lvl 
) const
inlineoverridevirtual

Prints the information about the object.

Parameters
ntNumber of tabs to append before printing
lvlInformation level (higher means more information)

Reimplemented from geom::GeomObject.

Definition at line 250 of file complexGeomObjects.h.

250 {
251 std::cout << printStr(nt, lvl);
252 };
std::string printStr(int nt, int lvl) const override
Returns the string containing printable information about the object.

References printStr().

Here is the call graph for this function:

◆ printStr()

std::string geom::AnnulusGeomObject::printStr ( int  nt,
int  lvl 
) const
overridevirtual

Returns the string containing printable information about the object.

Parameters
ntNumber of tabs to append before printing
lvlInformation level (higher means more information)
Returns
string String containing printable information about the object

Reimplemented from geom::GeomObject.

Definition at line 154 of file complexGeomObjects.cpp.

154 {
155
156 auto tabS = util::io::getTabS(nt);
157
158 std::ostringstream oss;
159
160 oss << tabS << "------- AnnulusGeomObject --------" << std::endl
161 << std::endl;
162 oss << tabS << "Name = " << d_name << std::endl;
163 oss << tabS << "Center = " << center().printStr() << std::endl;
164 oss << tabS << "Inner object info:" << std::endl;
165 oss << d_inObj_p->printStr(nt + 1, lvl);
166 oss << tabS << "Outer object info:" << std::endl;
167 oss << d_outObj_p->printStr(nt + 1, lvl);
168
169 if (lvl > 0)
170 oss << tabS << "Bounding box: "
171 << util::io::printBoxStr(box(0.), nt + 1);
172
173 if (lvl == 0)
174 oss << std::endl;
175
176 return oss.str();
177 }
util::Point center() const override
Computes the center of object.
virtual std::string printStr(int nt, int lvl) const
Returns the string containing printable information about the object.
std::string printBoxStr(const std::pair< util::Point, util::Point > &box, int nt=print_default_tab)
Returns formatted string for output.
Definition io.h:188
std::string getTabS(int nt)
Returns tab spaces of a given size.
Definition io.h:39
std::string printStr(int nt=0, int lvl=0) const
Returns the string containing printable information about the object.
Definition point.h:94

References box(), center(), d_inObj_p, geom::GeomObject::d_name, d_outObj_p, util::io::getTabS(), util::io::printBoxStr(), geom::GeomObject::printStr(), and util::Point::printStr().

Referenced by print().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ transform()

void geom::AnnulusGeomObject::transform ( const util::Point translation,
const double &  scale,
const double &  angle,
const util::Point axis,
const util::Point rotationPoint 
)
inlineoverridevirtual

Similarity about pivot \(\mathbf p\) (default: old center d_x), then rigid displacement \(\mathbf t\) = translation: \(\mathbf y = \mathbf p + s\,\mathbf R(\mathbf x-\mathbf p) + \mathbf t\). When \(\theta=0\) and \(s=1\), \(\mathbf y = \mathbf x + \mathbf t\) for every point and the center.

Parameters
translationRigid translation vector \(\mathbf t\) (added after rotate+scale about \(\mathbf p\))
scaleUniform scale factor
angleRotation angle (radians)
axisAxis of rotation
rotationPointIf non-null, use as \(\mathbf p\); if null, use old d_x as pivot. If rotationPoint is null and both inner and outer exist, pivot is center() (composite centroid of the annular solid). If only one child is present, that child’s center() is used.

Reimplemented from geom::GeomObject.

Definition at line 119 of file complexGeomObjects.h.

121 {
122 const util::Point *pivot = rotationPoint;
123 util::Point pivotStore;
124 if (pivot == nullptr) {
125 if (d_inObj_p && d_outObj_p) {
126 pivotStore = center();
127 pivot = &pivotStore;
128 } else if (d_inObj_p) {
129 pivotStore = d_inObj_p->center();
130 pivot = &pivotStore;
131 } else if (d_outObj_p) {
132 pivotStore = d_outObj_p->center();
133 pivot = &pivotStore;
134 }
135 }
136 if (d_inObj_p) d_inObj_p->transform(translation, scale, angle, axis, pivot);
137 if (d_outObj_p) d_outObj_p->transform(translation, scale, angle, axis, pivot);
138 }
virtual void transform(const util::Point &translation, const double &scale, const double &angle, const util::Point &axis, const util::Point *rotationPoint=nullptr)
Similarity about pivot (default: old center d_x), then rigid displacement = translation: ....
A structure to represent 3d vectors.
Definition point.h:30

References geom::GeomObject::center(), center(), d_inObj_p, d_outObj_p, and geom::GeomObject::transform().

Here is the call graph for this function:

◆ volume()

double geom::AnnulusGeomObject::volume ( ) const
overridevirtual

Computes the volume (area in 2d, length in 1d) of object.

Returns
Volume Volume of object

Reimplemented from geom::GeomObject.

Definition at line 44 of file complexGeomObjects.cpp.

44 {
45 return d_outObj_p->volume() - d_inObj_p->volume();
46 }

References d_inObj_p, d_outObj_p, and geom::GeomObject::volume().

Referenced by center().

Here is the call graph for this function:
Here is the caller graph for this function:

Field Documentation

◆ d_dim

◆ d_inObj_p

◆ d_outObj_p


The documentation for this class was generated from the following files: