PeriDEM 0.2.0
PeriDEM -- Peridynamics-based high-fidelity model for granular media
Loading...
Searching...
No Matches
util::geometry::AnnulusGeomObject Class Reference

Defines annulus rectangle. More...

#include <geomObjects.h>

Inheritance diagram for util::geometry::AnnulusGeomObject:
Collaboration diagram for util::geometry::AnnulusGeomObject:

Public Member Functions

 AnnulusGeomObject ()
 Constructor.
 
 AnnulusGeomObject (GeomObject *in, GeomObject *out, size_t dim, std::string description="")
 Constructor.
 
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 util::geometry::GeomObject
 GeomObject (std::string name="", std::string description="")
 Constructor.
 

Data Fields

util::geometry::GeomObjectd_outObj_p
 Outer object.
 
util::geometry::GeomObjectd_inObj_p
 Inner object.
 
size_t d_dim
 Dimension objects live in.
 
- Data Fields inherited from util::geometry::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 2400 of file geomObjects.h.

Constructor & Destructor Documentation

◆ AnnulusGeomObject() [1/2]

util::geometry::AnnulusGeomObject::AnnulusGeomObject ( )
inline

Constructor.

Definition at line 2406 of file geomObjects.h.

2407 : GeomObject("annulus_object", ""),
2408 d_outObj_p(nullptr),
2409 d_inObj_p(nullptr),
2410 d_dim(0) {};
size_t d_dim
Dimension objects live in.
util::geometry::GeomObject * d_inObj_p
Inner object.
util::geometry::GeomObject * d_outObj_p
Outer object.
GeomObject(std::string name="", std::string description="")
Constructor.
Definition geomObjects.h:39

◆ AnnulusGeomObject() [2/2]

util::geometry::AnnulusGeomObject::AnnulusGeomObject ( GeomObject in,
GeomObject out,
size_t  dim,
std::string  description = "" 
)
inline

Constructor.

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

Definition at line 2420 of file geomObjects.h.

2422 : GeomObject("annulus_object", description),
2423 d_outObj_p(out),
2424 d_inObj_p(in),
2425 d_dim(dim) {};

Member Function Documentation

◆ boundingRadius()

double util::geometry::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 util::geometry::GeomObject.

Definition at line 1735 of file geomObjects.cpp.

1735 {
1736
1737 return d_outObj_p->boundingRadius();
1738 }
virtual double boundingRadius() const
Computes the radius of smallest circle/sphere such that object can be fit into it.
Definition geomObjects.h:85

◆ box() [1/2]

std::pair< util::Point, util::Point > util::geometry::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 util::geometry::GeomObject.

Definition at line 1720 of file geomObjects.cpp.

1721 {
1722 return d_outObj_p->box();
1723 }
virtual std::pair< util::Point, util::Point > box() const
Computes the bounding box of object.
Definition geomObjects.h:59

◆ box() [2/2]

std::pair< util::Point, util::Point > util::geometry::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 util::geometry::GeomObject.

Definition at line 1725 of file geomObjects.cpp.

1726 {
1727 return d_outObj_p->box(tol);
1728 }

◆ center()

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

Computes the center of object.

Returns
Point Coordinates of center

Reimplemented from util::geometry::GeomObject.

Definition at line 1706 of file geomObjects.cpp.

1706 {
1707
1708 // we use the formula for centroid of composite objects
1709 // x = sum_i sign(i) V_i x_i / sum_i sign(i) V_i
1710 // where sign(i) = +1 if object is filling
1711 // sign(i) = -1 if object is empty
1712 auto vol = volume();
1713 if (util::isGreater(vol, 0.))
1714 return (1./vol) * (d_outObj_p->volume() * d_outObj_p->center()
1715 - d_inObj_p->volume() * d_inObj_p->center());
1716 else
1717 return d_outObj_p->center();
1718 }
double volume() const override
Computes the volume (area in 2d, length in 1d) of object.
virtual util::Point center() const
Computes the center of object.
Definition geomObjects.h:53
virtual double volume() const
Computes the volume (area in 2d, length in 1d) of object.
Definition geomObjects.h:47
bool isGreater(const double &a, const double &b)
Returns true if a > b.
Definition function.cpp:15

References util::isGreater().

Here is the call graph for this function:

◆ doesIntersect() [1/2]

bool util::geometry::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 util::geometry::GeomObject.

Definition at line 1800 of file geomObjects.cpp.

1801 {
1802
1803 // need to check all four corner points
1804 for (auto p: util::getCornerPoints(d_dim, box))
1805 if (this->isInside(p))
1806 return true;
1807
1808 return false;
1809 }
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.
Collection of methods useful in simulation.
std::vector< util::Point > getCornerPoints(size_t dim, const std::pair< util::Point, util::Point > &box)
Returns all corner points in the box.
Definition geom.cpp:14

References util::getCornerPoints().

Here is the call graph for this function:

◆ doesIntersect() [2/2]

bool util::geometry::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 util::geometry::GeomObject.

Definition at line 1767 of file geomObjects.cpp.

1768 {
1769
1770 return isNearBoundary(x, 1.0E-8, false);
1771 }
bool isNearBoundary(const util::Point &x, const double &tol, const bool &within) const override
cons

◆ inscribedRadius()

double util::geometry::AnnulusGeomObject::inscribedRadius ( ) const
overridevirtual

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

Returns
Radius Radius of inscribed circle/sphere

Reimplemented from util::geometry::GeomObject.

Definition at line 1730 of file geomObjects.cpp.

1730 {
1731
1732 return d_outObj_p->inscribedRadius();
1733 }
virtual double inscribedRadius() const
Computes the radius of biggest circle/sphere completely within the object.
Definition geomObjects.h:78

◆ isInside() [1/2]

bool util::geometry::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 util::geometry::GeomObject.

Definition at line 1773 of file geomObjects.cpp.

1774 {
1775
1776 for (auto p: util::getCornerPoints(d_dim, box))
1777 if (!this->isInside(p))
1778 return false;
1779
1780 return true;
1781 }

References util::getCornerPoints().

Here is the call graph for this function:

◆ isInside() [2/2]

bool util::geometry::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 util::geometry::GeomObject.

Definition at line 1741 of file geomObjects.cpp.

1741 {
1742
1743 // should be outside inner object and inside outer object
1744 return !d_inObj_p->isInside(x) && d_outObj_p->isInside(x);
1745 }
virtual bool isInside(const util::Point &x) const
Checks if point is inside this object.
Definition geomObjects.h:96

◆ isNear() [1/2]

bool util::geometry::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 util::geometry::GeomObject.

Definition at line 1793 of file geomObjects.cpp.

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

◆ isNear() [2/2]

bool util::geometry::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 util::geometry::GeomObject.

Definition at line 1752 of file geomObjects.cpp.

1753 {
1754
1755 return d_outObj_p->isNear(x, tol) || d_inObj_p->isNear(x, tol);
1756 }

◆ isNearBoundary()

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

cons

cons

Reimplemented from util::geometry::GeomObject.

Definition at line 1758 of file geomObjects.cpp.

1761 {
1762
1763 return d_outObj_p->isNearBoundary(x, tol, within) ||
1765 }
virtual bool isNearBoundary(const util::Point &x, const double &tol, const bool &within) const
Checks if point is within given distance of this object.

◆ isOutside() [1/2]

bool util::geometry::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 util::geometry::GeomObject.

Definition at line 1783 of file geomObjects.cpp.

1784 {
1785
1786 bool intersect = false;
1787 for (auto p: util::getCornerPoints(d_dim, box))
1789
1790 return !intersect;
1791 }

References util::getCornerPoints().

Here is the call graph for this function:

◆ isOutside() [2/2]

bool util::geometry::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 util::geometry::GeomObject.

Definition at line 1748 of file geomObjects.cpp.

1748 {
1749 return !isInside(x);
1750 }

◆ print() [1/2]

void util::geometry::AnnulusGeomObject::print ( ) const
inlineoverridevirtual

Prints the information about the object.

Reimplemented from util::geometry::GeomObject.

Definition at line 2544 of file geomObjects.h.

2544{ 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 util::geometry::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 util::geometry::GeomObject.

Definition at line 2537 of file geomObjects.h.

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

References d_dim, and printStr().

Here is the call graph for this function:

◆ printStr()

std::string util::geometry::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 util::geometry::GeomObject.

Definition at line 1812 of file geomObjects.cpp.

1812 {
1813
1814 auto tabS = util::io::getTabS(nt);
1815
1816 std::ostringstream oss;
1817
1818 oss << tabS << "------- AnnulusGeomObject --------" << std::endl
1819 << std::endl;
1820 oss << tabS << "Name = " << d_name << std::endl;
1821 oss << tabS << "Center = " << center().printStr() << std::endl;
1822 oss << tabS << "Inner object info:" << std::endl;
1823 oss << d_inObj_p->printStr(nt + 1, lvl);
1824 oss << tabS << "Outer object info:" << std::endl;
1825 oss << d_outObj_p->printStr(nt + 1, lvl);
1826
1827 if (lvl > 0)
1828 oss << tabS << "Bounding box: "
1829 << util::io::printBoxStr(box(0.), nt + 1);
1830
1831 if (lvl == 0)
1832 oss << std::endl;
1833
1834 return oss.str();
1835 }
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.
const std::string d_name
name of 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:168
std::string getTabS(int nt)
Returns tab spaces of given size.
Definition io.h:40
std::string printStr(int nt=0, int lvl=0) const
Returns the string containing printable information about the object.
Definition point.h:94

References util::io::getTabS(), and util::io::printBoxStr().

Referenced by print().

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

◆ volume()

double util::geometry::AnnulusGeomObject::volume ( ) const
overridevirtual

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

Returns
Volume Volume of object

Reimplemented from util::geometry::GeomObject.

Definition at line 1702 of file geomObjects.cpp.

1702 {
1703 return d_outObj_p->volume() - d_inObj_p->volume();
1704 }

Field Documentation

◆ d_dim

size_t util::geometry::AnnulusGeomObject::d_dim

Dimension objects live in.

Definition at line 2553 of file geomObjects.h.

Referenced by print().

◆ d_inObj_p

util::geometry::GeomObject* util::geometry::AnnulusGeomObject::d_inObj_p

Inner object.

Definition at line 2550 of file geomObjects.h.

◆ d_outObj_p

util::geometry::GeomObject* util::geometry::AnnulusGeomObject::d_outObj_p

Outer object.

Definition at line 2547 of file geomObjects.h.


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