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 #include "SolidMechanicsAppTypes.h"
16 
17 #include "libmesh/libmesh_common.h"
18 #include "libmesh/libmesh.h" // libMesh::invalid_uint
19 #include "libmesh/elem.h"
20 
21 using namespace libMesh;
22 
23 class XFEM;
24 
25 namespace Xfem
26 {
28 struct CutEdge
29 {
31  unsigned int _id1;
33  unsigned int _id2;
37  unsigned int _host_side_id;
38 };
39 
47 inline bool
48 operator<(const CutEdge & lhs, const CutEdge & rhs)
49 {
50  if (lhs._id1 != rhs._id1)
51  return lhs._id1 < rhs._id1;
52  else
53  return lhs._id2 < rhs._id2;
54 }
55 
57 struct CutNode
58 {
60  unsigned int _id;
62  unsigned int _host_id;
63 };
64 
66 struct CutFace
67 {
69  unsigned int _face_id;
71  std::vector<unsigned int> _face_edge;
73  std::vector<Real> _position;
74 };
75 
78 {
80  std::vector<CutEdge> _elem_cut_edges;
82  std::vector<CutNode> _elem_cut_nodes;
84  std::vector<CutEdge> _frag_cut_edges;
86  std::vector<std::vector<Point>> _frag_edges;
87 };
88 
91 {
93  std::vector<CutFace> _elem_cut_faces;
95  std::vector<CutFace> _frag_cut_faces;
97  std::vector<std::vector<Point>> _frag_faces;
98 };
99 
100 } // namespace Xfem
101 
103 {
104 public:
109  static InputParameters validParams();
110 
111  GeometricCutUserObject(const InputParameters & parameters, const bool uses_mesh = false);
112 
113  virtual void initialize() override;
114  virtual void execute() override;
115  virtual void threadJoin(const UserObject & y) override;
116  virtual void finalize() override;
117 
126  virtual bool cutElementByGeometry(const Elem * elem,
127  std::vector<Xfem::CutEdge> & cut_edges,
128  std::vector<Xfem::CutNode> & cut_nodes) const = 0;
129 
137  virtual bool cutElementByGeometry(const Elem * elem,
138  std::vector<Xfem::CutFace> & cut_faces) const = 0;
139 
146  virtual bool cutFragmentByGeometry(std::vector<std::vector<Point>> & frag_edges,
147  std::vector<Xfem::CutEdge> & cut_edges) const = 0;
148 
155  virtual bool cutFragmentByGeometry(std::vector<std::vector<Point>> & frag_faces,
156  std::vector<Xfem::CutFace> & cut_faces) const = 0;
157 
162  unsigned int getInterfaceID() const { return _interface_id; };
163 
168  void setInterfaceID(unsigned int interface_id) { _interface_id = interface_id; };
169 
175  bool shouldHealMesh() const { return _heal_always; };
176 
184  virtual CutSubdomainID getCutSubdomainID(const Node * /*node*/) const
185  {
186  mooseError("Objects that inherit from GeometricCutUserObject should override the "
187  "getCutSubdomainID method");
188  return 0;
189  }
190 
196  CutSubdomainID getCutSubdomainID(const Elem * elem) const;
197 
198 protected:
200  std::shared_ptr<XFEM> _xfem;
201 
203  unsigned int _interface_id;
204 
207 
210 
212  std::map<unsigned int, std::vector<Xfem::GeomMarkedElemInfo2D>> _marked_elems_2d;
213  std::map<unsigned int, std::vector<Xfem::GeomMarkedElemInfo3D>> _marked_elems_3d;
215 
217  void serialize(std::string & serialized_buffer);
218  void deserialize(std::vector<std::string> & serialized_buffers);
220 };
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:14
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