18template <
typename Predicate>
21 const std::vector<std::vector<std::size_t>> &neighbors,
22 const std::vector<std::size_t> &nodeParticleId, std::size_t particleId,
24 if (neighbors.size() > xRef.size() ||
25 nodeParticleId.size() < neighbors.size())
26 throw std::invalid_argument(
27 "prenotch: node arrays are inconsistent with the neighbour list");
29 std::size_t broken = 0;
30 for (std::size_t i = 0; i < neighbors.size(); ++i) {
31 if (nodeParticleId[i] != particleId)
33 const auto &xi = xRef[i];
34 for (std::size_t k = 0; k < neighbors[i].size(); ++k) {
35 const std::size_t j = neighbors[i][k];
36 if (j >= nodeParticleId.size() || nodeParticleId[j] != particleId)
38 const auto &xj = xRef[j];
39 if (crosses(xi.d_x, xi.d_y, xj.d_x, xj.d_y)) {
53 double xLine,
double yLo,
double yHi) {
56 if ((x0 - xLine) * (x1 - xLine) >= 0.)
58 const double t = (xLine - x0) / (x1 - x0);
59 const double y = y0 + t * (y1 - y0);
60 return y >= yLo && y <= yHi;
64 double xCenter,
double halfWidth,
double yLo,
65 double yHi,
int nSamples) {
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;
70 if (inSlot(x0, y0) || inSlot(x1, y1))
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)))
85 Fracture &fracture,
const std::vector<util::Point> &xRef,
86 const std::vector<std::vector<std::size_t>> &neighbors,
87 const std::vector<std::size_t> &nodeParticleId, std::size_t particleId,
88 const std::vector<double> &xLines,
double yLo,
double yHi) {
90 fracture, xRef, neighbors, nodeParticleId, particleId,
91 [&](
double x0,
double y0,
double x1,
double y1) {
92 for (
double xl : xLines)
100 Fracture &fracture,
const std::vector<util::Point> &xRef,
101 const std::vector<std::vector<std::size_t>> &neighbors,
102 const std::vector<std::size_t> &nodeParticleId, std::size_t particleId,
103 const std::vector<double> &xCenters,
double width,
double yLo,
106 throw std::invalid_argument(
"prenotch: slot width must not be negative");
107 const double hw = 0.5 * width;
109 fracture, xRef, neighbors, nodeParticleId, particleId,
110 [&](
double x0,
double y0,
double x1,
double y1) {
111 for (
double xc : xCenters)
A class for fracture state of bonds.
void setBondState(const std::size_t &i, const std::size_t &j, const bool &state)
Sets the bond state.
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)
Collection of methods and data related to geometry.
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)
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.