https://mooseframework.inl.gov
GeometricCutUserObject.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #pragma once
11 
12 // MOOSE includes
14 #include "XFEMAppTypes.h"
15 
16 #include "libmesh/libmesh_common.h"
17 #include "libmesh/libmesh.h" // libMesh::invalid_uint
18 #include "libmesh/elem.h"
19 
20 using namespace libMesh;
21 
22 class XFEM;
23 
24 namespace Xfem
25 {
27 struct CutEdge
28 {
30  unsigned int _id1;
32  unsigned int _id2;
36  unsigned int _host_side_id;
37 };
38 
46 inline bool
47 operator<(const CutEdge & lhs, const CutEdge & rhs)
48 {
49  if (lhs._id1 != rhs._id1)
50  return lhs._id1 < rhs._id1;
51  else
52  return lhs._id2 < rhs._id2;
53 }
54 
56 struct CutNode
57 {
59  unsigned int _id;
61  unsigned int _host_id;
62 };
63 
65 struct CutFace
66 {
68  unsigned int _face_id;
70  std::vector<unsigned int> _face_edge;
72  std::vector<Real> _position;
73 };
74 
77 {
79  std::vector<CutEdge> _elem_cut_edges;
81  std::vector<CutNode> _elem_cut_nodes;
83  std::vector<CutEdge> _frag_cut_edges;
85  std::vector<std::vector<Point>> _frag_edges;
86 };
87 
90 {
92  std::vector<CutFace> _elem_cut_faces;
94  std::vector<CutFace> _frag_cut_faces;
96  std::vector<std::vector<Point>> _frag_faces;
97 };
98 
99 } // namespace Xfem
100 
102 {
103 public:
108  static InputParameters validParams();
109 
110  GeometricCutUserObject(const InputParameters & parameters, const bool uses_mesh = false);
111 
112  virtual void initialize() override;
113  virtual void execute() override;
114  virtual void threadJoin(const UserObject & y) override;
115  virtual void finalize() override;
116 
125  virtual bool cutElementByGeometry(const Elem * elem,
126  std::vector<Xfem::CutEdge> & cut_edges,
127  std::vector<Xfem::CutNode> & cut_nodes) const = 0;
128 
136  virtual bool cutElementByGeometry(const Elem * elem,
137  std::vector<Xfem::CutFace> & cut_faces) const = 0;
138 
145  virtual bool cutFragmentByGeometry(std::vector<std::vector<Point>> & frag_edges,
146  std::vector<Xfem::CutEdge> & cut_edges) const = 0;
147 
154  virtual bool cutFragmentByGeometry(std::vector<std::vector<Point>> & frag_faces,
155  std::vector<Xfem::CutFace> & cut_faces) const = 0;
156 
161  unsigned int getInterfaceID() const { return _interface_id; };
162 
167  void setInterfaceID(unsigned int interface_id) { _interface_id = interface_id; };
168 
174  bool shouldHealMesh() const { return _heal_always; };
175 
183  virtual CutSubdomainID getCutSubdomainID(const Node * /*node*/) const
184  {
185  mooseError("Objects that inherit from GeometricCutUserObject should override the "
186  "getCutSubdomainID method");
187  return 0;
188  }
189 
195  CutSubdomainID getCutSubdomainID(const Elem * elem) const;
196 
197 protected:
199  std::shared_ptr<XFEM> _xfem;
200 
202  unsigned int _interface_id;
203 
206 
209 
211  std::map<unsigned int, std::vector<Xfem::GeomMarkedElemInfo2D>> _marked_elems_2d;
212  std::map<unsigned int, std::vector<Xfem::GeomMarkedElemInfo3D>> _marked_elems_3d;
214 
216  void serialize(std::string & serialized_buffer);
217  void deserialize(std::vector<std::string> & serialized_buffers);
219 };
int _last_step_initialized
Time step information needed to advance a 3D crack only at the real beginning of a time step...
std::map< unsigned int, std::vector< Xfem::GeomMarkedElemInfo2D > > _marked_elems_2d
Containers with information about all 2D and 3D elements marked for cutting by this object...
Data structure defining a cut through a node.
Data structure describing geometrically described cut through 3D element.
bool shouldHealMesh() const
Should the elements cut by this cutting object be healed in the current time step?
void mooseError(Args &&... args)
unsigned int _interface_id
Associated interface id.
bool operator<(const OrderWrapper &lhs, const OrderWrapper &rhs)
unsigned int _host_id
Local ID of this node in the host element.
bool _heal_always
Heal the mesh.
const std::vector< double > y
The following methods are specializations for using the Parallel::packed_range_* routines for a vecto...
std::vector< Real > _position
Fractional distance along the cut edges where the cut is located.
This is the XFEM class.
Definition: XFEM.h:107
void initialize(EquationSystems &es, const std::string &system_name)
std::vector< CutNode > _elem_cut_nodes
Container for data about all cut nodes in this element.
Data structure defining a cut through a face.
std::vector< CutEdge > _elem_cut_edges
Container for data about all cut edges in this element.
unsigned int CutSubdomainID
Definition: XFEMAppTypes.h:18
Data structure defining a cut on an element edge.
std::vector< std::vector< Point > > _frag_edges
Container for data about all cut edges in cut fragments in this element.
InputParameters validParams()
unsigned int _id1
ID of the first node on the edge.
Definition: XFEM.h:25
Base class for crack front points provider.
std::vector< CutEdge > _frag_cut_edges
Container for data about all cut fragments in this element.
Data structure describing geometrically described cut through 2D element.
virtual CutSubdomainID getCutSubdomainID(const Node *) const
Get CutSubdomainID telling which side the node belongs to relative to the cut.
std::shared_ptr< XFEM > _xfem
Pointer to the XFEM controller object.
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
unsigned int _id2
ID of the second node on the edge.
unsigned int getInterfaceID() const
Get the interface ID for this cutting object.
unsigned int _host_side_id
Local ID of this side in the host element.
std::vector< CutFace > _frag_cut_faces
Container for data about all faces this element&#39;s fragment.
std::vector< std::vector< Point > > _frag_faces
Container for data about all cut faces in cut fragments in this element.
std::vector< CutFace > _elem_cut_faces
Container for data about all cut faces in this element.
unsigned int _id
ID of the cut node.
void setInterfaceID(unsigned int interface_id)
Set the interface ID for this cutting object.
std::vector< unsigned int > _face_edge
IDs of all cut faces.
unsigned int _face_id
ID of the cut face.
std::map< unsigned int, std::vector< Xfem::GeomMarkedElemInfo3D > > _marked_elems_3d