https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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"
16
17#include "libmesh/libmesh_common.h"
18#include "libmesh/libmesh.h" // libMesh::invalid_uint
19#include "libmesh/elem.h"
20
21class XFEM;
22
23namespace Xfem
24{
26struct CutEdge
27{
29 unsigned int _id1;
31 unsigned int _id2;
35 unsigned int _host_side_id;
36};
37
45inline bool
46operator<(const CutEdge & lhs, const CutEdge & rhs)
47{
48 if (lhs._id1 != rhs._id1)
49 return lhs._id1 < rhs._id1;
50 else
51 return lhs._id2 < rhs._id2;
52}
53
55struct CutNode
56{
58 unsigned int _id;
60 unsigned int _host_id;
61};
62
64struct CutFace
65{
67 unsigned int _face_id;
69 std::vector<unsigned int> _face_edge;
71 std::vector<Real> _position;
72};
73
76{
78 std::vector<CutEdge> _elem_cut_edges;
80 std::vector<CutNode> _elem_cut_nodes;
82 std::vector<CutEdge> _frag_cut_edges;
84 std::vector<std::vector<Point>> _frag_edges;
85};
86
89{
91 std::vector<CutFace> _elem_cut_faces;
93 std::vector<CutFace> _frag_cut_faces;
95 std::vector<std::vector<Point>> _frag_faces;
96};
97
98} // namespace Xfem
99
101{
102public:
108
109 GeometricCutUserObject(const InputParameters & parameters, const bool uses_mesh = false);
110
111 virtual void initialize() override;
112 virtual void execute() override;
113 virtual void threadJoin(const UserObject & y) override;
114 virtual void finalize() override;
115
116 virtual unsigned int getNumberOfCrackFrontPoints() const override
117 {
118 mooseError("getNumberOfCrackFrontPoints() is not implemented for this object.");
119 }
120
129 virtual bool cutElementByGeometry(const Elem * elem,
130 std::vector<Xfem::CutEdge> & cut_edges,
131 std::vector<Xfem::CutNode> & cut_nodes) const = 0;
132
140 virtual bool cutElementByGeometry(const Elem * elem,
141 std::vector<Xfem::CutFace> & cut_faces) const = 0;
142
149 virtual bool cutFragmentByGeometry(std::vector<std::vector<Point>> & frag_edges,
150 std::vector<Xfem::CutEdge> & cut_edges) const = 0;
151
158 virtual bool cutFragmentByGeometry(std::vector<std::vector<Point>> & frag_faces,
159 std::vector<Xfem::CutFace> & cut_faces) const = 0;
160
165 unsigned int getInterfaceID() const { return _interface_id; };
166
171 void setInterfaceID(unsigned int interface_id) { _interface_id = interface_id; };
172
178 bool shouldHealMesh() const { return _heal_always; };
179
187 virtual CutSubdomainID getCutSubdomainID(const Node * /*node*/) const
188 {
189 mooseError("Objects that inherit from GeometricCutUserObject should override the "
190 "getCutSubdomainID method");
191 return 0;
192 }
193
199 CutSubdomainID getCutSubdomainID(const Elem * elem) const;
200
201protected:
203 std::shared_ptr<XFEM> _xfem;
204
206 unsigned int _interface_id;
207
210
213
215 std::map<unsigned int, std::vector<Xfem::GeomMarkedElemInfo2D>> _marked_elems_2d;
216 std::map<unsigned int, std::vector<Xfem::GeomMarkedElemInfo3D>> _marked_elems_3d;
218
220 void serialize(std::string & serialized_buffer);
221 void deserialize(std::vector<std::string> & serialized_buffers);
223};
const std::vector< double > y
unsigned int CutSubdomainID
Base class for crack front points provider.
std::map< unsigned int, std::vector< Xfem::GeomMarkedElemInfo3D > > _marked_elems_3d
virtual void threadJoin(const UserObject &y) override
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.
static InputParameters validParams()
Factory constructor, takes parameters so that all derived classes can be built using the same constru...
virtual void execute() override
unsigned int _interface_id
Associated interface id.
virtual unsigned int getNumberOfCrackFrontPoints() const override
Get the current number of crack front points.
void serialize(std::string &serialized_buffer)
Methods to pack/unpack the _marked_elems_2d and _marked_elems_3d data into a structure suitable for p...
virtual bool cutFragmentByGeometry(std::vector< std::vector< Point > > &frag_edges, std::vector< Xfem::CutEdge > &cut_edges) const =0
Check to see whether a fragment of a 2D element should be cut based on geometric conditions.
bool shouldHealMesh() const
Should the elements cut by this cutting object be healed in the current time step?
void setInterfaceID(unsigned int interface_id)
Set the interface ID for this cutting object.
void deserialize(std::vector< std::string > &serialized_buffers)
virtual bool cutElementByGeometry(const Elem *elem, std::vector< Xfem::CutEdge > &cut_edges, std::vector< Xfem::CutNode > &cut_nodes) const =0
Check to see whether a specified 2D element should be cut based on geometric conditions.
virtual bool cutFragmentByGeometry(std::vector< std::vector< Point > > &frag_faces, std::vector< Xfem::CutFace > &cut_faces) const =0
Check to see whether a fragment of a 3D element should be cut based on geometric conditions.
virtual void initialize() override
virtual CutSubdomainID getCutSubdomainID(const Node *) const
Get CutSubdomainID telling which side the node belongs to relative to the cut.
virtual void finalize() override
std::shared_ptr< XFEM > _xfem
Pointer to the XFEM controller object.
virtual bool cutElementByGeometry(const Elem *elem, std::vector< Xfem::CutFace > &cut_faces) const =0
Check to see whether a specified 3D element should be cut based on geometric conditions.
int _last_step_initialized
Time step information needed to advance a 3D crack only at the real beginning of a time step.
unsigned int getInterfaceID() const
Get the interface ID for this cutting object.
const InputParameters & parameters() const
void mooseError(Args &&... args) const
This is the XFEM class.
Definition XFEM.h:108
Definition XFEM.h:26
bool operator<(const CutEdge &lhs, const CutEdge &rhs)
Operator < for two CutEdge Objects Needed to allow the use of std::set<CutEdge>
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.
Data structure defining a cut through a node.
unsigned int _id
ID of the cut node.
unsigned int _host_id
Local ID of this node in the host element.
Data structure describing geometrically described cut through 2D element.
std::vector< CutNode > _elem_cut_nodes
Container for data about all cut nodes in this element.
std::vector< CutEdge > _frag_cut_edges
Container for data about all cut fragments in this element.
std::vector< CutEdge > _elem_cut_edges
Container for data about all cut edges in this element.
std::vector< std::vector< Point > > _frag_edges
Container for data about all cut edges in cut fragments in this element.
Data structure describing geometrically described cut through 3D element.
std::vector< CutFace > _frag_cut_faces
Container for data about all faces this element's fragment.
std::vector< CutFace > _elem_cut_faces
Container for data about all cut faces in this element.
std::vector< std::vector< Point > > _frag_faces
Container for data about all cut faces in cut fragments in this element.