26 for (
const auto & elem :
_cutter_mesh->element_ptr_range())
27 if (elem->type() !=
EDGE2)
29 "InterfaceMeshCut2DUserObject currently only supports EDGE2 element in the cut mesh.");
37 for (
const auto & elem :
_cutter_mesh->element_ptr_range())
39 Point
a = elem->node_ref(1);
40 Point
b = elem->node_ref(0);
42 Point normal_ab = Point(-(
b -
a)(1), (
b -
a)(0), 0);
43 normal_ab /= normal_ab.norm();
56 const auto & elem =
_cutter_mesh->elem_ref(node_neigh_elem_id);
58 Point
a = elem.node_ref(1);
59 Point
b = elem.node_ref(0);
61 Point normal_ab = Point(-(
b -
a)(1), (
b -
a)(0), 0);
62 normal_ab /= normal_ab.norm();
70 mooseError(
"InterfaceMeshCut2DUserObject, the node is not found in node_to_elem_map in " 71 "calculting its normal.");
78 std::vector<Xfem::CutEdge> & cut_edges,
79 std::vector<Xfem::CutNode> & cut_nodes)
const 81 mooseAssert(elem->dim() == 2,
"Dimension of element to be cut must be 2");
83 bool elem_cut =
false;
85 for (
const auto & cut_elem :
_cutter_mesh->element_ptr_range())
87 unsigned int n_sides = elem->n_sides();
89 for (
unsigned int i = 0; i < n_sides; ++i)
91 std::unique_ptr<const Elem> curr_side = elem->side_ptr(i);
93 mooseAssert(curr_side->type() ==
EDGE2,
"Element side type must be EDGE2.");
95 const Node * node1 = curr_side->node_ptr(0);
96 const Node * node2 = curr_side->node_ptr(1);
97 Real seg_int_frac = 0.0;
99 const std::pair<Point, Point> elem_endpoints(cut_elem->node_ref(0), cut_elem->node_ref(1));
107 mycut.
_id1 = node1->id();
108 mycut.
_id2 = node2->id();
111 cut_edges.push_back(mycut);
117 mycut.
_id = node1->id();
119 cut_nodes.push_back(mycut);
129 std::vector<Xfem::CutFace> & )
const 131 mooseError(
"invalid method for InterfaceMeshCut2DUserObject");
137 std::vector<std::vector<Point>> & ,
138 std::vector<Xfem::CutEdge> & )
const 140 mooseError(
"cutFragmentByGeometry not yet implemented for InterfaceMeshCut2DUserObject");
146 std::vector<std::vector<Point>> & ,
147 std::vector<Xfem::CutFace> & )
const 149 mooseError(
"invalid method for InterfaceMeshCut2DUserObject");
156 Real min_dist = std::numeric_limits<Real>::max();
158 for (
const auto & cut_elem :
_cutter_mesh->element_ptr_range())
160 Point
a = cut_elem->node_ref(0);
161 Point
b = cut_elem->node_ref(1);
164 Point
v = (
b -
a) / (
b -
a).norm();
173 dist = (p -
a).
norm();
178 dist = (p -
b).
norm();
184 dist = (p -
a -
v).
norm();
185 nearest_point = (
a +
v);
188 Point p_nearest_point = nearest_point - p;
190 Point normal_ab = Point(-(
b -
a)(1), (
b -
a)(0), 0);
192 if (normal_ab * p_nearest_point < 0)
195 if (std::abs(dist) < std::abs(min_dist))
Data structure defining a cut through a node.
InterfaceMeshCut2DUserObject(const InputParameters ¶meters)
virtual void calculateNormals() override
calculate the element normal values for all of the elements.
unsigned int _host_id
Local ID of this node in the host element.
static InputParameters validParams()
virtual Point nodeNormal(const unsigned int &node_id) override
return the normal at a node in the cutting mesh
virtual bool cutFragmentByGeometry(std::vector< std::vector< Point >> &frag_edges, std::vector< Xfem::CutEdge > &cut_edges) const override
Data structure defining a cut on an element edge.
unsigned int _id1
ID of the first node on the edge.
virtual Real calculateSignedDistance(Point p) const override
Calculate the signed distance for a given point relative to the surface.
static InputParameters validParams()
virtual bool cutElementByGeometry(const Elem *elem, std::vector< Xfem::CutEdge > &cut_edges, std::vector< Xfem::CutNode > &cut_nodes) const override
bool intersectSegmentWithCutLine(const Point &segment_point1, const Point &segment_point2, const std::pair< Point, Point > &cutting_line_points, const Real &cutting_line_fraction, Real &segment_intersection_fraction)
Determine whether a line segment is intersected by a cutting line, and compute the fraction along tha...
std::shared_ptr< MeshBase > _cutter_mesh
The cutter mesh.
Real _distance
Fractional distance along the edge (from node 1 to 2) where the cut is located.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static const std::string v
std::unordered_map< unsigned int, Point > _element_normals
Map of element normal.
unsigned int _id2
ID of the second node on the edge.
void mooseError(Args &&... args) const
unsigned int _host_side_id
Local ID of this side in the host element.
registerMooseObject("XFEMApp", InterfaceMeshCut2DUserObject)
std::unordered_map< dof_id_type, std::vector< dof_id_type > > _node_to_elem_map
node to element map of cut mesh
unsigned int _id
ID of the cut node.