www.mooseframework.org
Public Member Functions | Protected Attributes | List of all members
GeometricCutUserObject Class Referenceabstract

#include <GeometricCutUserObject.h>

Inheritance diagram for GeometricCutUserObject:
[legend]

Public Member Functions

 GeometricCutUserObject (const InputParameters &parameters)
 Factory constructor, takes parameters so that all derived classes can be built using the same constructor. More...
 
virtual void initialize () override
 
virtual void execute () override
 
virtual void threadJoin (const UserObject &y) override
 
virtual void finalize () override
 
virtual bool cutElementByGeometry (const Elem *elem, std::vector< Xfem::CutEdge > &cut_edges, std::vector< Xfem::CutNode > &cut_nodes, Real time) const =0
 Check to see whether a specified 2D element should be cut based on geometric conditions. More...
 
virtual bool cutElementByGeometry (const Elem *elem, std::vector< Xfem::CutFace > &cut_faces, Real time) const =0
 Check to see whether a specified 3D element should be cut based on geometric conditions. More...
 
virtual bool cutFragmentByGeometry (std::vector< std::vector< Point >> &frag_edges, std::vector< Xfem::CutEdge > &cut_edges, Real time) const =0
 Check to see whether a fragment of a 2D element should be cut based on geometric conditions. More...
 
virtual bool cutFragmentByGeometry (std::vector< std::vector< Point >> &frag_faces, std::vector< Xfem::CutFace > &cut_faces, Real time) const =0
 Check to see whether a fragment of a 3D element should be cut based on geometric conditions. More...
 
unsigned int getInterfaceID () const
 Get the interface ID for this cutting object. More...
 
void setInterfaceID (unsigned int interface_id)
 Set the interface ID for this cutting object. More...
 
bool shouldHealMesh () const
 Should the elements cut by this cutting object be healed in the current time step? More...
 
virtual const std::vector< Point > getCrackFrontPoints (unsigned int) const =0
 get a set of points along a crack front from a XFEM GeometricCutUserObject More...
 

Protected Member Functions

void serialize (std::string &serialized_buffer)
 Methods to pack/unpack the _marked_elems_2d and _marked_elems_3d data into a structure suitable for parallel communication. More...
 
void deserialize (std::vector< std::string > &serialized_buffers)
 

Protected Attributes

std::shared_ptr< XFEM_xfem
 Pointer to the XFEM controller object. More...
 
unsigned int _interface_id
 Associated interface id. More...
 
bool _heal_always
 Heal the mesh. More...
 
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. More...
 
std::map< unsigned int, std::vector< Xfem::GeomMarkedElemInfo3D > > _marked_elems_3d
 

Detailed Description

Definition at line 107 of file GeometricCutUserObject.h.

Constructor & Destructor Documentation

◆ GeometricCutUserObject()

GeometricCutUserObject::GeometricCutUserObject ( const InputParameters &  parameters)

Factory constructor, takes parameters so that all derived classes can be built using the same constructor.

Definition at line 39 of file GeometricCutUserObject.C.

40  : CrackFrontPointsProvider(parameters), _heal_always(getParam<bool>("heal_always"))
41 {
42  _xfem = MooseSharedNamespace::dynamic_pointer_cast<XFEM>(_fe_problem.getXFEM());
43  if (_xfem == nullptr)
44  mooseError("Problem casting to XFEM in GeometricCutUserObject");
45 
46  _xfem->addGeometricCut(this);
47 
48  auto new_xfem_epl = std::make_shared<XFEMElementPairLocator>(_xfem, _interface_id);
49  _fe_problem.geomSearchData().addElementPairLocator(_interface_id, new_xfem_epl);
50 
51  if (_fe_problem.getDisplacedProblem() != NULL)
52  {
53  auto new_xfem_epl2 = std::make_shared<XFEMElementPairLocator>(_xfem, _interface_id, true);
54  _fe_problem.getDisplacedProblem()->geomSearchData().addElementPairLocator(_interface_id,
55  new_xfem_epl2);
56  }
57 }
CrackFrontPointsProvider(const InputParameters &parameters)
unsigned int _interface_id
Associated interface id.
bool _heal_always
Heal the mesh.
This is the XFEM class.
Definition: XFEM.h:62
std::shared_ptr< XFEM > _xfem
Pointer to the XFEM controller object.

Member Function Documentation

◆ cutElementByGeometry() [1/2]

virtual bool GeometricCutUserObject::cutElementByGeometry ( const Elem *  elem,
std::vector< Xfem::CutEdge > &  cut_edges,
std::vector< Xfem::CutNode > &  cut_nodes,
Real  time 
) const
pure virtual

Check to see whether a specified 2D element should be cut based on geometric conditions.

Parameters
elemPointer to the libMesh element to be considered for cutting
cut_edgesData structure filled with information about edges to be cut
cut_nodesData structure filled with information about nodes to be cut
timeCurrent simulation time
Returns
bool true if element is to be cut

Implemented in MeshCut3DUserObject, GeometricCut3DUserObject, GeometricCut2DUserObject, and LevelSetCutUserObject.

Referenced by execute().

◆ cutElementByGeometry() [2/2]

virtual bool GeometricCutUserObject::cutElementByGeometry ( const Elem *  elem,
std::vector< Xfem::CutFace > &  cut_faces,
Real  time 
) const
pure virtual

Check to see whether a specified 3D element should be cut based on geometric conditions.

Parameters
elemPointer to the libMesh element to be considered for cutting
cut_facesData structure filled with information about edges to be cut
timeCurrent simulation time
Returns
bool true if element is to be cut

Implemented in MeshCut3DUserObject, GeometricCut3DUserObject, GeometricCut2DUserObject, and LevelSetCutUserObject.

◆ cutFragmentByGeometry() [1/2]

virtual bool GeometricCutUserObject::cutFragmentByGeometry ( std::vector< std::vector< Point >> &  frag_edges,
std::vector< Xfem::CutEdge > &  cut_edges,
Real  time 
) const
pure virtual

Check to see whether a fragment of a 2D element should be cut based on geometric conditions.

Parameters
frag_edgesData structure defining the current fragment to be considered
cut_edgesData structure filled with information about fragment edges to be cut
timeCurrent simulation time
Returns
bool true if fragment is to be cut

Implemented in MeshCut3DUserObject, GeometricCut3DUserObject, GeometricCut2DUserObject, and LevelSetCutUserObject.

Referenced by execute().

◆ cutFragmentByGeometry() [2/2]

virtual bool GeometricCutUserObject::cutFragmentByGeometry ( std::vector< std::vector< Point >> &  frag_faces,
std::vector< Xfem::CutFace > &  cut_faces,
Real  time 
) const
pure virtual

Check to see whether a fragment of a 3D element should be cut based on geometric conditions.

Parameters
frag_facesData structure defining the current fragment to be considered
cut_facesData structure filled with information about fragment faces to be cut
timeCurrent simulation time
Returns
bool true if fragment is to be cut

Implemented in MeshCut3DUserObject, GeometricCut3DUserObject, GeometricCut2DUserObject, and LevelSetCutUserObject.

◆ deserialize()

void GeometricCutUserObject::deserialize ( std::vector< std::string > &  serialized_buffers)
protected

Definition at line 222 of file GeometricCutUserObject.C.

Referenced by finalize().

223 {
224  mooseAssert(serialized_buffers.size() == _app.n_processors(),
225  "Unexpected size of serialized_buffers: " << serialized_buffers.size());
226 
227  // The input string stream used for deserialization
228  std::istringstream iss;
229 
230  // Loop over all datastructures for all processors to perfrom the gather operation
231  for (unsigned int rank = 0; rank < serialized_buffers.size(); ++rank)
232  {
233  // skip the current processor (its data is already in the structures)
234  if (rank == processor_id())
235  continue;
236 
237  // populate the stream with a new buffer and reset stream state
238  iss.clear();
239  iss.str(serialized_buffers[rank]);
240 
241  // Load the communicated data into temporary structures
242  std::map<unsigned int, std::vector<Xfem::GeomMarkedElemInfo2D>> other_marked_elems_2d;
243  std::map<unsigned int, std::vector<Xfem::GeomMarkedElemInfo3D>> other_marked_elems_3d;
244  dataLoad(iss, other_marked_elems_2d, this);
245  dataLoad(iss, other_marked_elems_3d, this);
246 
247  // merge the data in with the current processor's data
248  _marked_elems_2d.insert(other_marked_elems_2d.begin(), other_marked_elems_2d.end());
249  _marked_elems_3d.insert(other_marked_elems_3d.begin(), other_marked_elems_3d.end());
250  }
251 }
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...
void dataLoad(std::istream &stream, Xfem::CutFace &cf, void *context)
std::map< unsigned int, std::vector< Xfem::GeomMarkedElemInfo3D > > _marked_elems_3d

◆ execute()

void GeometricCutUserObject::execute ( )
overridevirtual

Reimplemented in MovingLineSegmentCutSetUserObject.

Definition at line 67 of file GeometricCutUserObject.C.

Referenced by MovingLineSegmentCutSetUserObject::execute().

68 {
69  if (_current_elem->dim() == 2)
70  {
71  std::vector<Xfem::CutEdge> elem_cut_edges;
72  std::vector<Xfem::CutNode> elem_cut_nodes;
73  std::vector<Xfem::CutEdge> frag_cut_edges;
74  std::vector<std::vector<Point>> frag_edges;
75 
76  EFAElement2D * EFAElem = _xfem->getEFAElem2D(_current_elem);
77 
78  // Don't cut again if elem has been already cut twice
79  if (!EFAElem->isFinalCut())
80  {
81  // get fragment edges
82  _xfem->getFragmentEdges(_current_elem, EFAElem, frag_edges);
83 
84  // mark cut edges for the element and its fragment
85  bool cut = cutElementByGeometry(_current_elem, elem_cut_edges, elem_cut_nodes, _t);
86  if (EFAElem->numFragments() > 0)
87  cut |= cutFragmentByGeometry(frag_edges, frag_cut_edges, _t);
88 
89  if (cut)
90  {
92  gmei2d._elem_cut_edges = elem_cut_edges;
93  gmei2d._elem_cut_nodes = elem_cut_nodes;
94  gmei2d._frag_cut_edges = frag_cut_edges;
95  gmei2d._frag_edges = frag_edges;
96  _marked_elems_2d[_current_elem->id()].push_back(gmei2d);
97  }
98  }
99  }
100  else if (_current_elem->dim() == 3)
101  {
102  std::vector<Xfem::CutFace> elem_cut_faces;
103  std::vector<Xfem::CutFace> frag_cut_faces;
104  std::vector<std::vector<Point>> frag_faces;
105 
106  EFAElement3D * EFAElem = _xfem->getEFAElem3D(_current_elem);
107 
108  // Don't cut again if elem has been already cut twice
109  if (!EFAElem->isFinalCut())
110  {
111  // get fragment edges
112  _xfem->getFragmentFaces(_current_elem, EFAElem, frag_faces);
113 
114  // mark cut faces for the element and its fragment
115  bool cut = cutElementByGeometry(_current_elem, elem_cut_faces, _t);
116  // TODO: This would be done for branching, which is not yet supported in 3D
117  // if (EFAElem->numFragments() > 0)
118  // cut |= cutFragmentByGeometry(frag_faces, frag_cut_faces, _t);
119 
120  if (cut)
121  {
123  gmei3d._elem_cut_faces = elem_cut_faces;
124  gmei3d._frag_cut_faces = frag_cut_faces;
125  gmei3d._frag_faces = frag_faces;
126  _marked_elems_3d[_current_elem->id()].push_back(gmei3d);
127  }
128  }
129  }
130 }
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 describing geometrically described cut through 3D element.
virtual bool cutFragmentByGeometry(std::vector< std::vector< Point >> &frag_edges, std::vector< Xfem::CutEdge > &cut_edges, Real time) const =0
Check to see whether a fragment of a 2D element should be cut based on geometric conditions.
virtual unsigned int numFragments() const
Definition: EFAElement2D.C:202
virtual bool cutElementByGeometry(const Elem *elem, std::vector< Xfem::CutEdge > &cut_edges, std::vector< Xfem::CutNode > &cut_nodes, Real time) const =0
Check to see whether a specified 2D element should be cut based on geometric conditions.
std::vector< CutNode > _elem_cut_nodes
Container for data about all cut nodes 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.
virtual bool isFinalCut() const
Definition: EFAElement2D.C:791
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.
std::shared_ptr< XFEM > _xfem
Pointer to the XFEM controller object.
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.
std::map< unsigned int, std::vector< Xfem::GeomMarkedElemInfo3D > > _marked_elems_3d
virtual bool isFinalCut() const
Definition: EFAElement3D.C:838

◆ finalize()

void GeometricCutUserObject::finalize ( )
overridevirtual

Reimplemented in MovingLineSegmentCutSetUserObject.

Definition at line 254 of file GeometricCutUserObject.C.

Referenced by MovingLineSegmentCutSetUserObject::finalize().

255 {
256  // for single processor runs we do not need to do anything here
257  if (_app.n_processors() > 1)
258  {
259  // create send buffer
260  std::string send_buffer;
261 
262  // create byte buffers for the streams received from all processors
263  std::vector<std::string> recv_buffers;
264 
265  // pack the complex datastructures into the string stream
266  serialize(send_buffer);
267 
268  // broadcast serialized data to and receive from all processors
269  _communicator.allgather(send_buffer, recv_buffers);
270 
271  // unpack the received data and merge it into the local data structures
272  deserialize(recv_buffers);
273  }
274 
275  for (const auto & it : _marked_elems_2d)
276  for (const auto & gmei : it.second)
277  _xfem->addGeomMarkedElem2D(it.first, gmei, _interface_id);
278 
279  for (const auto & it : _marked_elems_3d)
280  for (const auto & gmei : it.second)
281  _xfem->addGeomMarkedElem3D(it.first, gmei, _interface_id);
282 
283  _marked_elems_2d.clear();
284  _marked_elems_3d.clear();
285 }
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...
unsigned int _interface_id
Associated interface id.
void deserialize(std::vector< std::string > &serialized_buffers)
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...
std::shared_ptr< XFEM > _xfem
Pointer to the XFEM controller object.
std::map< unsigned int, std::vector< Xfem::GeomMarkedElemInfo3D > > _marked_elems_3d

◆ getCrackFrontPoints()

virtual const std::vector<Point> CrackFrontPointsProvider::getCrackFrontPoints ( unsigned  int) const
pure virtualinherited

◆ getInterfaceID()

unsigned int GeometricCutUserObject::getInterfaceID ( ) const
inline

Get the interface ID for this cutting object.

Returns
the interface ID

Definition at line 173 of file GeometricCutUserObject.h.

173 { return _interface_id; };
unsigned int _interface_id
Associated interface id.

◆ initialize()

void GeometricCutUserObject::initialize ( )
overridevirtual

Reimplemented in MeshCut3DUserObject, and MovingLineSegmentCutSetUserObject.

Definition at line 60 of file GeometricCutUserObject.C.

61 {
62  _marked_elems_2d.clear();
63  _marked_elems_3d.clear();
64 }
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...
std::map< unsigned int, std::vector< Xfem::GeomMarkedElemInfo3D > > _marked_elems_3d

◆ serialize()

void GeometricCutUserObject::serialize ( std::string &  serialized_buffer)
protected

Methods to pack/unpack the _marked_elems_2d and _marked_elems_3d data into a structure suitable for parallel communication.

Definition at line 209 of file GeometricCutUserObject.C.

Referenced by finalize().

210 {
211  // stream for serializing the _marked_elems_2d and _marked_elems_3d data structures to a byte
212  // stream
213  std::ostringstream oss;
214  dataStore(oss, _marked_elems_2d, this);
215  dataStore(oss, _marked_elems_3d, this);
216 
217  // Populate the passed in string pointer with the string stream's buffer contents
218  serialized_buffer.assign(oss.str());
219 }
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...
void dataStore(std::ostream &stream, Xfem::CutFace &cf, void *context)
std::map< unsigned int, std::vector< Xfem::GeomMarkedElemInfo3D > > _marked_elems_3d

◆ setInterfaceID()

void GeometricCutUserObject::setInterfaceID ( unsigned int  interface_id)
inline

Set the interface ID for this cutting object.

Parameters
theinterface ID

Definition at line 179 of file GeometricCutUserObject.h.

Referenced by XFEM::addGeometricCut().

179 { _interface_id = interface_id; };
unsigned int _interface_id
Associated interface id.

◆ shouldHealMesh()

bool GeometricCutUserObject::shouldHealMesh ( ) const
inline

Should the elements cut by this cutting object be healed in the current time step?

Returns
true if the cut element should be healed

Definition at line 186 of file GeometricCutUserObject.h.

186 { return _heal_always; };
bool _heal_always
Heal the mesh.

◆ threadJoin()

void GeometricCutUserObject::threadJoin ( const UserObject &  y)
overridevirtual

Definition at line 133 of file GeometricCutUserObject.C.

134 {
135  const GeometricCutUserObject & gcuo = dynamic_cast<const GeometricCutUserObject &>(y);
136 
137  for (const auto & it : gcuo._marked_elems_2d)
138  {
139  mooseAssert(_marked_elems_2d.find(it.first) == _marked_elems_2d.end(),
140  "Element already inserted in map from a different thread");
141  _marked_elems_2d[it.first] = it.second;
142  }
143  for (const auto & it : gcuo._marked_elems_3d)
144  {
145  mooseAssert(_marked_elems_3d.find(it.first) == _marked_elems_3d.end(),
146  "Element already inserted in map from a different thread");
147  _marked_elems_3d[it.first] = it.second;
148  }
149 }
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...
std::map< unsigned int, std::vector< Xfem::GeomMarkedElemInfo3D > > _marked_elems_3d

Member Data Documentation

◆ _heal_always

bool GeometricCutUserObject::_heal_always
protected

Heal the mesh.

Definition at line 196 of file GeometricCutUserObject.h.

◆ _interface_id

unsigned int GeometricCutUserObject::_interface_id
protected

Associated interface id.

Definition at line 193 of file GeometricCutUserObject.h.

Referenced by finalize(), and GeometricCutUserObject().

◆ _marked_elems_2d

std::map<unsigned int, std::vector<Xfem::GeomMarkedElemInfo2D> > GeometricCutUserObject::_marked_elems_2d
protected

Containers with information about all 2D and 3D elements marked for cutting by this object.

Definition at line 199 of file GeometricCutUserObject.h.

Referenced by deserialize(), execute(), finalize(), initialize(), serialize(), and threadJoin().

◆ _marked_elems_3d

std::map<unsigned int, std::vector<Xfem::GeomMarkedElemInfo3D> > GeometricCutUserObject::_marked_elems_3d
protected

◆ _xfem

std::shared_ptr<XFEM> GeometricCutUserObject::_xfem
protected

Pointer to the XFEM controller object.

Definition at line 186 of file GeometricCutUserObject.h.

Referenced by execute(), finalize(), and GeometricCutUserObject().


The documentation for this class was generated from the following files: