13#include "libmesh/string_to_enum.h"
22 "level_set_var",
"The name of level set variable used to represent the interface");
25 "negative_id", 0,
"The CutSubdomainID corresponding to a non-positive signed distance");
27 "positive_id", 1,
"The CutSubdomainID corresponding to a positive signed distance");
33 _level_set_var_number(_subproblem
35 parameters.get<VariableName>(
"level_set_var"),
36 Moose::VarKindType::VAR_ANY,
37 Moose::VarFieldType::VAR_FIELD_STANDARD)
39 _system(_subproblem.getSystem(getParam<VariableName>(
"level_set_var"))),
40 _solution(*_system.current_local_solution.get()),
45 "LevelSetCutUserObject expects different CutSubdomainIDs for the "
46 "negative_id and the positive_id.");
51 std::vector<Xfem::CutEdge> & cut_edges,
52 std::vector<Xfem::CutNode> & )
const
54 bool cut_elem =
false;
56 unsigned int n_sides = elem->n_sides();
58 for (
unsigned int i = 0; i < n_sides; ++i)
60 std::unique_ptr<const Elem> curr_side = elem->side_ptr(i);
62 if (curr_side->type() != EDGE2)
63 mooseError(
"In LevelSetCutUserObject element side must be EDGE2, but type is: ",
65 " base element type is: ",
68 const Node * node1 = curr_side->node_ptr(0);
69 const Node * node2 = curr_side->node_ptr(1);
74 Number ls_node_1 =
_solution(ls_dof_id_1);
75 Number ls_node_2 =
_solution(ls_dof_id_2);
77 if (ls_node_1 * ls_node_2 < 0)
81 mycut.
_id1 = node1->id();
82 mycut.
_id2 = node2->id();
83 Real seg_int_frac = std::abs(ls_node_1) / std::abs(ls_node_1 - ls_node_2);
86 cut_edges.push_back(mycut);
95 std::vector<Xfem::CutFace> & cut_faces)
const
97 bool cut_elem =
false;
99 for (
unsigned int i = 0; i < elem->n_sides(); ++i)
101 std::unique_ptr<const Elem> curr_side = elem->side_ptr(i);
102 if (curr_side->dim() != 2)
103 mooseError(
"In LevelSetCutUserObject dimension of side must be 2, but it is ",
105 unsigned int n_edges = curr_side->n_sides();
107 std::vector<unsigned int> cut_edges;
108 std::vector<Real> cut_pos;
110 for (
unsigned int j = 0; j < n_edges; j++)
113 std::unique_ptr<const Elem> curr_edge = curr_side->side_ptr(j);
114 if (curr_edge->type() != EDGE2)
115 mooseError(
"In LevelSetCutUserObject face edge must be EDGE2, but type is: ",
117 " base element type is: ",
120 const Node * node1 = curr_edge->node_ptr(0);
121 const Node * node2 = curr_edge->node_ptr(1);
126 Number ls_node_1 =
_solution(ls_dof_id_1);
127 Number ls_node_2 =
_solution(ls_dof_id_2);
129 if (ls_node_1 * ls_node_2 < 0)
131 Real seg_int_frac = std::abs(ls_node_1) / std::abs(ls_node_1 - ls_node_2);
132 cut_edges.push_back(j);
133 cut_pos.push_back(seg_int_frac);
137 if (cut_edges.size() == 2)
146 cut_faces.push_back(mycut);
154 std::vector<Xfem::CutEdge> & )
const
161 std::vector<Xfem::CutFace> & )
const
163 mooseError(
"cutFragmentByGeometry not yet implemented for 3d level set cutting");
167const std::vector<Point>
170 mooseError(
"getCrackFrontPoints() is not implemented for this object.");
173const std::vector<RealVectorValue>
176 mooseError(
"getCrackPlaneNormals() is not implemented for this object.");
registerMooseObject("XFEMApp", LevelSetCutUserObject)
unsigned int CutSubdomainID
static InputParameters validParams()
Factory constructor, takes parameters so that all derived classes can be built using the same constru...
const System & _system
System reference.
virtual bool cutFragmentByGeometry(std::vector< std::vector< Point > > &frag_edges, std::vector< Xfem::CutEdge > &cut_edges) const override
static InputParameters validParams()
const CutSubdomainID _negative_id
The ID for the negative side of the cut.
const unsigned int _level_set_var_number
The variable number of the level set variable we using to define the cuts.
virtual const std::vector< RealVectorValue > getCrackPlaneNormals(unsigned int num_crack_front_points) const override
get a set of normal vectors along a crack front from a XFEM GeometricCutUserObject
LevelSetCutUserObject(const InputParameters ¶meters)
const NumericVector< Number > & _solution
The subproblem solution vector.
virtual bool cutElementByGeometry(const Elem *elem, std::vector< Xfem::CutEdge > &cut_edges, std::vector< Xfem::CutNode > &cut_nodes) const override
const CutSubdomainID _positive_id
The ID for the positive side of the cut.
virtual CutSubdomainID getCutSubdomainID(const Node *node) const override
If the levelset value is positive, return 1, otherwise return 0.
virtual const std::vector< Point > getCrackFrontPoints(unsigned int num_crack_front_points) const override
get a set of points along a crack front from a XFEM GeometricCutUserObject
void mooseError(Args &&... args) const
std::string enum_to_string(const T e)
Data structure defining a cut on an element edge.
unsigned int _id1
ID of the first node on the edge.
Real _distance
Fractional distance along the edge (from node 1 to 2) where the cut is located.
unsigned int _id2
ID of the second node on the edge.
unsigned int _host_side_id
Local ID of this side in the host element.
Data structure defining a cut through a face.
unsigned int _face_id
ID of the cut face.
std::vector< Real > _position
Fractional distance along the cut edges where the cut is located.
std::vector< unsigned int > _face_edge
IDs of all cut faces.