PeriDEM 0.3.0
PeriDEM -- Peridynamics-based high-fidelity model for granular media
Loading...
Searching...
No Matches
geometry Namespace Reference

Collection of methods and data related to geometry. More...

Data Structures

class  Fracture
 A class for fracture state of bonds. More...
 

Functions

bool segmentCrossesVerticalLine (double x0, double y0, double x1, double y1, double xLine, double yLo, double yHi)
 Pre-notch by breaking peridynamic bonds.
 
bool segmentEntersSlot (double x0, double y0, double x1, double y1, double xCenter, double halfWidth, double yLo, double yHi, int nSamples=8)
 Checks whether the segment enters the open slot centred on xCenter.
 
std::size_t breakBondsCrossingVerticalLines (Fracture &fracture, const std::vector< util::Point > &xRef, const std::vector< std::vector< std::size_t > > &neighbors, const std::vector< std::size_t > &nodeParticleId, std::size_t particleId, const std::vector< double > &xLines, double yLo, double yHi)
 Break the bonds of one particle that cross vertical cut lines.
 
std::size_t breakBondsInSlots (Fracture &fracture, const std::vector< util::Point > &xRef, const std::vector< std::vector< std::size_t > > &neighbors, const std::vector< std::size_t > &nodeParticleId, std::size_t particleId, const std::vector< double > &xCenters, double width, double yLo, double yHi)
 Break the bonds of one particle that enter open notch slots.
 

Detailed Description

Collection of methods and data related to geometry.

Function Documentation

◆ breakBondsCrossingVerticalLines()

std::size_t geometry::breakBondsCrossingVerticalLines ( Fracture &  fracture,
const std::vector< util::Point > &  xRef,
const std::vector< std::vector< std::size_t > > &  neighbors,
const std::vector< std::size_t > &  nodeParticleId,
std::size_t  particleId,
const std::vector< double > &  xLines,
double  yLo,
double  yHi 
)

Break the bonds of one particle that cross vertical cut lines.

This is the zero-width pre-notch: a cut along each line in xLines between yLo and yHi. A V-notch seeded on its midplane is the same geometric test and uses this function.

Only bonds with both ends in particle particleId are considered.

Parameters
fractureBond-state store to modify
xRefReference coordinates of all nodes
neighborsPeridynamic neighbour list
nodeParticleIdParticle id of each node
particleIdParticle to cut
xLinesPositions of the cut lines
yLoLower end of the cuts
yHiUpper end of the cuts
Returns
n Number of bonds broken

Definition at line 84 of file prenotch.cpp.

88 {
89 return breakBondsIf(
90 fracture, xRef, neighbors, nodeParticleId, particleId,
91 [&](double x0, double y0, double x1, double y1) {
92 for (double xl : xLines)
93 if (segmentCrossesVerticalLine(x0, y0, x1, y1, xl, yLo, yHi))
94 return true;
95 return false;
96 });
97}
std::size_t breakBondsIf(geometry::Fracture &fracture, const std::vector< util::Point > &xRef, const std::vector< std::vector< std::size_t > > &neighbors, const std::vector< std::size_t > &nodeParticleId, std::size_t particleId, Predicate crosses)
Definition prenotch.cpp:19
bool segmentCrossesVerticalLine(double x0, double y0, double x1, double y1, double xLine, double yLo, double yHi)
Pre-notch by breaking peridynamic bonds.
Definition prenotch.cpp:52

References segmentCrossesVerticalLine().

Referenced by anonymous_namespace{main.cpp}::applyNotches(), and anonymous_namespace{main.cpp}::applyNotchMidplanes().

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

◆ breakBondsInSlots()

std::size_t geometry::breakBondsInSlots ( Fracture &  fracture,
const std::vector< util::Point > &  xRef,
const std::vector< std::vector< std::size_t > > &  neighbors,
const std::vector< std::size_t > &  nodeParticleId,
std::size_t  particleId,
const std::vector< double > &  xCenters,
double  width,
double  yLo,
double  yHi 
)

Break the bonds of one particle that enter open notch slots.

This is the finite-width pre-notch: each slot is width across, centred on an entry of xCenters, spanning yLo to yHi.

Only bonds with both ends in particle particleId are considered.

Parameters
fractureBond-state store to modify
xRefReference coordinates of all nodes
neighborsPeridynamic neighbour list
nodeParticleIdParticle id of each node
particleIdParticle to cut
xCentersSlot centrelines
widthFull slot width
yLoLower end of the slots
yHiUpper end of the slots
Returns
n Number of bonds broken

Definition at line 99 of file prenotch.cpp.

104 {
105 if (width < 0.)
106 throw std::invalid_argument("prenotch: slot width must not be negative");
107 const double hw = 0.5 * width;
108 return breakBondsIf(
109 fracture, xRef, neighbors, nodeParticleId, particleId,
110 [&](double x0, double y0, double x1, double y1) {
111 for (double xc : xCenters)
112 if (segmentEntersSlot(x0, y0, x1, y1, xc, hw, yLo, yHi))
113 return true;
114 return false;
115 });
116}
bool segmentEntersSlot(double x0, double y0, double x1, double y1, double xCenter, double halfWidth, double yLo, double yHi, int nSamples)
Checks whether the segment enters the open slot centred on xCenter.
Definition prenotch.cpp:63

References segmentEntersSlot().

Referenced by anonymous_namespace{main.cpp}::applyNotchSlots().

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

◆ segmentCrossesVerticalLine()

bool geometry::segmentCrossesVerticalLine ( double  x0,
double  y0,
double  x1,
double  y1,
double  xLine,
double  yLo,
double  yHi 
)

Pre-notch by breaking peridynamic bonds.

Removing the notch from the mesh does not by itself open it. The horizon is wider than the notch in the cases here, so bonds still span the gap and carry force across it. These functions break those bonds, after the model is initialised and before the time loop starts.

They take the node data rather than a model object, so that src/ does not depend on the driver. Call them with data.d_xRef, data.d_neighPd, data.d_ptId and *data.d_fracture_p.

Checks whether the segment (x0,y0)-(x1,y1) crosses the vertical line x = xLine within [yLo, yHi]

Parameters
x0First endpoint x
y0First endpoint y
x1Second endpoint x
y1Second endpoint y
xLinePosition of the cut line
yLoLower end of the cut
yHiUpper end of the cut
Returns
bool True if the segment crosses the cut

Definition at line 52 of file prenotch.cpp.

53 {
54 // The endpoints lie on opposite sides of the line. This excludes x1 == x0,
55 // so the division is defined and the parameter lies in (0, 1).
56 if ((x0 - xLine) * (x1 - xLine) >= 0.)
57 return false;
58 const double t = (xLine - x0) / (x1 - x0);
59 const double y = y0 + t * (y1 - y0);
60 return y >= yLo && y <= yHi;
61}

Referenced by breakBondsCrossingVerticalLines(), main(), and segmentEntersSlot().

Here is the caller graph for this function:

◆ segmentEntersSlot()

bool geometry::segmentEntersSlot ( double  x0,
double  y0,
double  x1,
double  y1,
double  xCenter,
double  halfWidth,
double  yLo,
double  yHi,
int  nSamples = 8 
)

Checks whether the segment enters the open slot centred on xCenter.

The slot spans xCenter +/- halfWidth and yLo to yHi. The segment is sampled at nSamples interior points, so that a bond with an endpoint inside the slot is detected and not only one that crosses the slot entirely.

Parameters
x0First endpoint x
y0First endpoint y
x1Second endpoint x
y1Second endpoint y
xCenterSlot centreline
halfWidthHalf of the slot width
yLoLower end of the slot
yHiUpper end of the slot
nSamplesNumber of interior samples along the segment
Returns
bool True if the segment enters the slot

Definition at line 63 of file prenotch.cpp.

65 {
66 const double xa = xCenter - halfWidth, xb = xCenter + halfWidth;
67 auto inSlot = [&](double x, double y) {
68 return x >= xa && x <= xb && y >= yLo && y <= yHi;
69 };
70 if (inSlot(x0, y0) || inSlot(x1, y1))
71 return true;
72 if (nSamples > 0) {
73 for (int s = 0; s <= nSamples; ++s) {
74 const double t = static_cast<double>(s) / nSamples;
75 if (inSlot(x0 + t * (x1 - x0), y0 + t * (y1 - y0)))
76 return true;
77 }
78 }
79 // A slot narrower than the sample spacing can be crossed with no sample
80 // inside it.
81 return segmentCrossesVerticalLine(x0, y0, x1, y1, xCenter, yLo, yHi);
82}

References segmentCrossesVerticalLine().

Referenced by breakBondsInSlots().

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