www.mooseframework.org
Public Member Functions | Private Attributes | List of all members
ElementFragmentAlgorithm Class Reference

#include <ElementFragmentAlgorithm.h>

Public Member Functions

 ElementFragmentAlgorithm (std::ostream &os)
 Constructor. More...
 
 ~ElementFragmentAlgorithm ()
 
unsigned int add2DElements (std::vector< std::vector< unsigned int >> &quads)
 
EFAElementadd2DElement (std::vector< unsigned int > quad, unsigned int id)
 
EFAElementadd3DElement (std::vector< unsigned int > quad, unsigned int id)
 
void updateEdgeNeighbors ()
 
void initCrackTipTopology ()
 
void addElemEdgeIntersection (unsigned int elemid, unsigned int edgeid, double position)
 
void addElemNodeIntersection (unsigned int elemid, unsigned int nodeid)
 
bool addFragEdgeIntersection (unsigned int elemid, unsigned int frag_edge_id, double position)
 
void addElemFaceIntersection (unsigned int elemid, unsigned int faceid, std::vector< unsigned int > edgeid, std::vector< double > position)
 
void addFragFaceIntersection (unsigned int ElemID, unsigned int FragFaceID, std::vector< unsigned int > FragFaceEdgeID, std::vector< double > position)
 
void updatePhysicalLinksAndFragments ()
 
void updateTopology (bool mergeUncutVirtualEdges=true)
 
void reset ()
 
void clearAncestry ()
 
void restoreFragmentInfo (EFAElement *const elem, const EFAElement *const from_elem)
 
void createChildElements ()
 
void connectFragments (bool mergeUncutVirtualEdges)
 
void sanityCheck ()
 
void updateCrackTipElements ()
 
void printMesh ()
 
void error (const std::string &error_string)
 
const std::vector< EFAElement * > & getChildElements ()
 
const std::vector< EFAElement * > & getParentElements ()
 
const std::vector< EFANode * > & getNewNodes ()
 
const std::set< EFAElement * > & getCrackTipElements ()
 
const std::map< unsigned int, EFANode * > & getPermanentNodes ()
 
const std::map< unsigned int, EFANode * > & getTempNodes ()
 
const std::map< unsigned int, EFANode * > & getEmbeddedNodes ()
 
EFAElementgetElemByID (unsigned int id)
 
unsigned int getElemIdByNodes (unsigned int *node_id)
 
void clearPotentialIsolatedNodes ()
 

Private Attributes

std::ostream & _ostream
 
std::map< unsigned int, EFANode * > _permanent_nodes
 
std::map< unsigned int, EFANode * > _embedded_nodes
 
std::map< unsigned int, EFANode * > _temp_nodes
 
std::map< unsigned int, EFANode * > _embedded_permanent_nodes
 
std::map< unsigned int, EFAElement * > _elements
 
std::set< EFAElement * > _crack_tip_elements
 
std::vector< EFANode * > _new_nodes
 
std::vector< EFANode * > _deleted_nodes
 
std::vector< EFAElement * > _child_elements
 
std::vector< EFAElement * > _parent_elements
 
std::map< EFANode *, std::set< EFAElement * > > _inverse_connectivity
 

Detailed Description

Definition at line 20 of file ElementFragmentAlgorithm.h.

Constructor & Destructor Documentation

◆ ElementFragmentAlgorithm()

ElementFragmentAlgorithm::ElementFragmentAlgorithm ( std::ostream &  os)

Constructor.

Definition at line 30 of file ElementFragmentAlgorithm.C.

30 : _ostream(os) {}

◆ ~ElementFragmentAlgorithm()

ElementFragmentAlgorithm::~ElementFragmentAlgorithm ( )

Definition at line 32 of file ElementFragmentAlgorithm.C.

33 {
34  std::map<unsigned int, EFANode *>::iterator mit;
35  for (mit = _permanent_nodes.begin(); mit != _permanent_nodes.end(); ++mit)
36  {
37  delete mit->second;
38  mit->second = NULL;
39  }
40  for (mit = _embedded_nodes.begin(); mit != _embedded_nodes.end(); ++mit)
41  {
42  delete mit->second;
43  mit->second = NULL;
44  }
45  for (mit = _embedded_permanent_nodes.begin(); mit != _embedded_permanent_nodes.end(); ++mit)
46  {
47  delete mit->second;
48  mit->second = NULL;
49  }
50  for (mit = _temp_nodes.begin(); mit != _temp_nodes.end(); ++mit)
51  {
52  delete mit->second;
53  mit->second = NULL;
54  }
55  std::map<unsigned int, EFAElement *>::iterator eit;
56  for (eit = _elements.begin(); eit != _elements.end(); ++eit)
57  {
58  delete eit->second;
59  eit->second = NULL;
60  }
61 }
std::map< unsigned int, EFAElement * > _elements
std::map< unsigned int, EFANode * > _embedded_permanent_nodes
std::map< unsigned int, EFANode * > _temp_nodes
std::map< unsigned int, EFANode * > _embedded_nodes
std::map< unsigned int, EFANode * > _permanent_nodes

Member Function Documentation

◆ add2DElement()

EFAElement * ElementFragmentAlgorithm::add2DElement ( std::vector< unsigned int >  quad,
unsigned int  id 
)

Definition at line 102 of file ElementFragmentAlgorithm.C.

Referenced by XFEM::buildEFAMesh().

103 {
104  unsigned int num_nodes = quad.size();
105 
106  std::map<unsigned int, EFAElement *>::iterator mit = _elements.find(id);
107  if (mit != _elements.end())
108  EFAError("In add2DElement element with id: ", id, " already exists");
109 
110  EFAElement2D * newElem = new EFAElement2D(id, num_nodes);
111  _elements.insert(std::make_pair(id, newElem));
112 
113  for (unsigned int j = 0; j < num_nodes; ++j)
114  {
115  EFANode * currNode = NULL;
116  std::map<unsigned int, EFANode *>::iterator mit = _permanent_nodes.find(quad[j]);
117  if (mit == _permanent_nodes.end())
118  {
119  currNode = new EFANode(quad[j], EFANode::N_CATEGORY_PERMANENT);
120  _permanent_nodes.insert(std::make_pair(quad[j], currNode));
121  }
122  else
123  currNode = mit->second;
124 
125  newElem->setNode(j, currNode);
126  _inverse_connectivity[currNode].insert(newElem);
127  }
128  newElem->createEdges();
129  return newElem;
130 }
std::map< unsigned int, EFAElement * > _elements
std::map< EFANode *, std::set< EFAElement * > > _inverse_connectivity
std::map< unsigned int, EFANode * > _permanent_nodes
void setNode(unsigned int node_id, EFANode *node)
Definition: EFAElement.C:40
void createEdges()

◆ add2DElements()

unsigned int ElementFragmentAlgorithm::add2DElements ( std::vector< std::vector< unsigned int >> &  quads)

Definition at line 64 of file ElementFragmentAlgorithm.C.

65 {
66  unsigned int first_id = 0;
67  unsigned int num_nodes = quads[0].size();
68 
69  if (quads.size() == 0)
70  EFAError("add2DElements called with empty vector of quads");
71 
72  for (unsigned int i = 0; i < quads.size(); ++i)
73  {
74  unsigned int new_elem_id = Efa::getNewID(_elements);
75  EFAElement2D * newElem = new EFAElement2D(new_elem_id, num_nodes);
76  _elements.insert(std::make_pair(new_elem_id, newElem));
77 
78  if (i == 0)
79  first_id = new_elem_id;
80 
81  for (unsigned int j = 0; j < num_nodes; ++j)
82  {
83  EFANode * currNode = NULL;
84  std::map<unsigned int, EFANode *>::iterator mit = _permanent_nodes.find(quads[i][j]);
85  if (mit == _permanent_nodes.end())
86  {
87  currNode = new EFANode(quads[i][j], EFANode::N_CATEGORY_PERMANENT);
88  _permanent_nodes.insert(std::make_pair(quads[i][j], currNode));
89  }
90  else
91  currNode = mit->second;
92 
93  newElem->setNode(j, currNode);
94  _inverse_connectivity[currNode].insert(newElem);
95  }
96  newElem->createEdges();
97  }
98  return first_id;
99 }
unsigned int getNewID(std::map< unsigned int, T *> &theMap)
Definition: EFAFuncs.h:39
std::map< unsigned int, EFAElement * > _elements
std::map< EFANode *, std::set< EFAElement * > > _inverse_connectivity
std::map< unsigned int, EFANode * > _permanent_nodes
void setNode(unsigned int node_id, EFANode *node)
Definition: EFAElement.C:40
void createEdges()

◆ add3DElement()

EFAElement * ElementFragmentAlgorithm::add3DElement ( std::vector< unsigned int >  quad,
unsigned int  id 
)

Definition at line 133 of file ElementFragmentAlgorithm.C.

Referenced by XFEM::buildEFAMesh().

134 {
135  unsigned int num_nodes = quad.size();
136  unsigned int num_faces = 0;
137  if (num_nodes == 27)
138  num_faces = 6;
139  else if (num_nodes == 20)
140  num_faces = 6;
141  else if (num_nodes == 8)
142  num_faces = 6;
143  else if (num_nodes == 4)
144  num_faces = 4;
145  else if (num_nodes == 10)
146  num_faces = 4;
147  else
148  EFAError("In add3DElement element with id: ", id, " has invalid num_nodes");
149 
150  std::map<unsigned int, EFAElement *>::iterator mit = _elements.find(id);
151  if (mit != _elements.end())
152  EFAError("In add3DElement element with id: ", id, " already exists");
153 
154  EFAElement3D * newElem = new EFAElement3D(id, num_nodes, num_faces);
155  _elements.insert(std::make_pair(id, newElem));
156 
157  for (unsigned int j = 0; j < num_nodes; ++j)
158  {
159  EFANode * currNode = NULL;
160  std::map<unsigned int, EFANode *>::iterator mit = _permanent_nodes.find(quad[j]);
161  if (mit == _permanent_nodes.end())
162  {
163  currNode = new EFANode(quad[j], EFANode::N_CATEGORY_PERMANENT);
164  _permanent_nodes.insert(std::make_pair(quad[j], currNode));
165  }
166  else
167  currNode = mit->second;
168 
169  newElem->setNode(j, currNode);
170  _inverse_connectivity[currNode].insert(newElem);
171  }
172  newElem->createFaces();
173  return newElem;
174 }
void createFaces()
std::map< unsigned int, EFAElement * > _elements
std::map< EFANode *, std::set< EFAElement * > > _inverse_connectivity
std::map< unsigned int, EFANode * > _permanent_nodes
void setNode(unsigned int node_id, EFANode *node)
Definition: EFAElement.C:40

◆ addElemEdgeIntersection()

void ElementFragmentAlgorithm::addElemEdgeIntersection ( unsigned int  elemid,
unsigned int  edgeid,
double  position 
)

Definition at line 212 of file ElementFragmentAlgorithm.C.

Referenced by XFEM::markCutEdgesByGeometry(), and XFEM::markCutEdgesByState().

215 {
216  // this method is called when we are marking cut edges
217  std::map<unsigned int, EFAElement *>::iterator eit = _elements.find(elemid);
218  if (eit == _elements.end())
219  EFAError("Could not find element with id: ", elemid, " in addEdgeIntersection");
220 
221  EFAElement2D * curr_elem = dynamic_cast<EFAElement2D *>(eit->second);
222  if (!curr_elem)
223  EFAError("addElemEdgeIntersection: elem ", elemid, " is not of type EFAelement2D");
224  curr_elem->addEdgeCut(edgeid, position, NULL, _embedded_nodes, true);
225 }
void addEdgeCut(unsigned int edge_id, double position, EFANode *embedded_node, std::map< unsigned int, EFANode *> &EmbeddedNodes, bool add_to_neighbor)
std::map< unsigned int, EFAElement * > _elements
std::map< unsigned int, EFANode * > _embedded_nodes

◆ addElemFaceIntersection()

void ElementFragmentAlgorithm::addElemFaceIntersection ( unsigned int  elemid,
unsigned int  faceid,
std::vector< unsigned int >  edgeid,
std::vector< double >  position 
)

Definition at line 261 of file ElementFragmentAlgorithm.C.

Referenced by XFEM::markCutFacesByGeometry().

265 {
266  // this method is called when we are marking cut edges
267  std::map<unsigned int, EFAElement *>::iterator eit = _elements.find(elemid);
268  if (eit == _elements.end())
269  EFAError("Could not find element with id: ", elemid, " in addEdgeIntersection");
270 
271  EFAElement3D * curr_elem = dynamic_cast<EFAElement3D *>(eit->second);
272  if (!curr_elem)
273  EFAError("addElemEdgeIntersection: elem ", elemid, " is not of type EFAelement2D");
274 
275  // add cuts to two face edges at the same time
276  curr_elem->addFaceEdgeCut(faceid, edgeid[0], position[0], NULL, _embedded_nodes, true, true);
277  curr_elem->addFaceEdgeCut(faceid, edgeid[1], position[1], NULL, _embedded_nodes, true, true);
278 }
std::map< unsigned int, EFAElement * > _elements
std::map< unsigned int, EFANode * > _embedded_nodes
void addFaceEdgeCut(unsigned int face_id, unsigned int edge_id, double position, EFANode *embedded_node, std::map< unsigned int, EFANode *> &EmbeddedNodes, bool add_to_neighbor, bool add_to_adjacent)

◆ addElemNodeIntersection()

void ElementFragmentAlgorithm::addElemNodeIntersection ( unsigned int  elemid,
unsigned int  nodeid 
)

Definition at line 228 of file ElementFragmentAlgorithm.C.

Referenced by XFEM::markCutEdgesByGeometry().

229 {
230  // this method is called when we are marking cut nodes
231  std::map<unsigned int, EFAElement *>::iterator eit = _elements.find(elemid);
232  if (eit == _elements.end())
233  EFAError("Could not find element with id: ", elemid, " in addElemNodeIntersection");
234 
235  EFAElement2D * curr_elem = dynamic_cast<EFAElement2D *>(eit->second);
236  if (!curr_elem)
237  EFAError("addElemNodeIntersection: elem ", elemid, " is not of type EFAelement2D");
238 
239  // Only add cut node when the curr_elem does not have any fragment
240  if (curr_elem->numFragments() == 0)
241  curr_elem->addNodeCut(nodeid, NULL, _permanent_nodes, _embedded_permanent_nodes);
242 }
virtual unsigned int numFragments() const
Definition: EFAElement2D.C:202
std::map< unsigned int, EFAElement * > _elements
std::map< unsigned int, EFANode * > _embedded_permanent_nodes
void addNodeCut(unsigned int node_id, EFANode *embedded_permanent_node, std::map< unsigned int, EFANode *> &PermanentNodes, std::map< unsigned int, EFANode *> &EmbeddedPermanentNodes)
std::map< unsigned int, EFANode * > _permanent_nodes

◆ addFragEdgeIntersection()

bool ElementFragmentAlgorithm::addFragEdgeIntersection ( unsigned int  elemid,
unsigned int  frag_edge_id,
double  position 
)

Definition at line 245 of file ElementFragmentAlgorithm.C.

Referenced by XFEM::markCutEdgesByGeometry(), and XFEM::markCutEdgesByState().

248 {
249  // N.B. this method must be called after addEdgeIntersection
250  std::map<unsigned int, EFAElement *>::iterator eit = _elements.find(elemid);
251  if (eit == _elements.end())
252  EFAError("Could not find element with id: ", elemid, " in addFragEdgeIntersection");
253 
254  EFAElement2D * elem = dynamic_cast<EFAElement2D *>(eit->second);
255  if (!elem)
256  EFAError("addFragEdgeIntersection: elem ", elemid, " is not of type EFAelement2D");
257  return elem->addFragmentEdgeCut(frag_edge_id, position, _embedded_nodes);
258 }
bool addFragmentEdgeCut(unsigned int frag_edge_id, double position, std::map< unsigned int, EFANode *> &EmbeddedNodes)
std::map< unsigned int, EFAElement * > _elements
std::map< unsigned int, EFANode * > _embedded_nodes

◆ addFragFaceIntersection()

void ElementFragmentAlgorithm::addFragFaceIntersection ( unsigned int  ElemID,
unsigned int  FragFaceID,
std::vector< unsigned int >  FragFaceEdgeID,
std::vector< double >  position 
)

Definition at line 281 of file ElementFragmentAlgorithm.C.

Referenced by XFEM::markCutFacesByGeometry().

285 {
286  // TODO: need to finish this for 3D problems
287 }

◆ clearAncestry()

void ElementFragmentAlgorithm::clearAncestry ( )

Definition at line 367 of file ElementFragmentAlgorithm.C.

368 {
369  _inverse_connectivity.clear();
370  for (unsigned int i = 0; i < _parent_elements.size(); ++i)
371  {
373  EFAError("Attempted to delete parent element: ",
374  _parent_elements[i]->id(),
375  " from _elements, but couldn't find it");
376  }
377  _parent_elements.clear();
378 
379  std::map<unsigned int, EFAElement *>::iterator eit;
380  for (eit = _elements.begin(); eit != _elements.end(); ++eit)
381  {
382  EFAElement * curr_elem = eit->second;
383  curr_elem->clearParentAndChildren();
384  for (unsigned int j = 0; j < curr_elem->numNodes(); j++)
385  {
386  EFANode * curr_node = curr_elem->getNode(j);
387  _inverse_connectivity[curr_node].insert(curr_elem);
388  }
389  }
390 
391  std::map<unsigned int, EFANode *>::iterator mit;
392  for (mit = _permanent_nodes.begin(); mit != _permanent_nodes.end(); ++mit)
393  mit->second->removeParent();
394 
395  for (mit = _temp_nodes.begin(); mit != _temp_nodes.end(); ++mit)
396  {
397  delete mit->second;
398  mit->second = NULL;
399  }
400  _temp_nodes.clear();
401 
402  _new_nodes.clear();
403  _child_elements.clear();
404 
405  // TODO: Sanity check to make sure that there are no nodes that are not connected
406  // to an element -- there shouldn't be any
407 }
void clearParentAndChildren()
Definition: EFAElement.C:209
bool deleteFromMap(std::map< unsigned int, T *> &theMap, T *elemToDelete, bool delete_elem=true)
Definition: EFAFuncs.h:23
std::vector< EFAElement * > _child_elements
std::vector< EFAElement * > _parent_elements
std::map< unsigned int, EFAElement * > _elements
EFANode * getNode(unsigned int node_id) const
Definition: EFAElement.C:46
std::vector< EFANode * > _new_nodes
std::map< EFANode *, std::set< EFAElement * > > _inverse_connectivity
std::map< unsigned int, EFANode * > _temp_nodes
unsigned int numNodes() const
Definition: EFAElement.C:34
std::map< unsigned int, EFANode * > _permanent_nodes

◆ clearPotentialIsolatedNodes()

void ElementFragmentAlgorithm::clearPotentialIsolatedNodes ( )

Definition at line 622 of file ElementFragmentAlgorithm.C.

Referenced by updateTopology().

623 {
624  // Collect all parent nodes that will be isolated
625  std::map<EFANode *, std::vector<EFANode *>> isolate_parent_to_child;
626  for (unsigned int i = 0; i < _new_nodes.size(); ++i)
627  {
628  EFANode * parent_node = _new_nodes[i]->parent();
629  if (!parent_node)
630  EFAError("a new permanent node must have a parent node!");
631  bool isParentNodeInNewElem = false;
632  for (unsigned int j = 0; j < _child_elements.size(); ++j)
633  {
634  if (_child_elements[j]->containsNode(parent_node))
635  {
636  isParentNodeInNewElem = true;
637  break;
638  }
639  }
640  if (!isParentNodeInNewElem)
641  isolate_parent_to_child[parent_node].push_back(_new_nodes[i]);
642  }
643 
644  // For each isolated parent node, pick one of its child new node
645  // Then, switch that child with its parent for all new elems
646  std::map<EFANode *, std::vector<EFANode *>>::iterator mit;
647  for (mit = isolate_parent_to_child.begin(); mit != isolate_parent_to_child.end(); ++mit)
648  {
649  EFANode * parent_node = mit->first;
650  EFANode * child_node = (mit->second)[0]; // need to discard it and swap it back to its parent
651  for (unsigned int i = 0; i < _child_elements.size(); ++i)
652  {
653  if (_child_elements[i]->containsNode(child_node))
654  _child_elements[i]->switchNode(parent_node, child_node, true);
655  }
656  _new_nodes.erase(std::remove(_new_nodes.begin(), _new_nodes.end(), child_node),
657  _new_nodes.end());
659  }
660 }
bool deleteFromMap(std::map< unsigned int, T *> &theMap, T *elemToDelete, bool delete_elem=true)
Definition: EFAFuncs.h:23
std::vector< EFAElement * > _child_elements
std::vector< EFANode * > _new_nodes
std::map< unsigned int, EFANode * > _permanent_nodes

◆ connectFragments()

void ElementFragmentAlgorithm::connectFragments ( bool  mergeUncutVirtualEdges)

Definition at line 440 of file ElementFragmentAlgorithm.C.

Referenced by updateTopology().

441 {
442  // now perform the comparison on the children
443  for (unsigned int elem_iter = 0; elem_iter < _child_elements.size(); elem_iter++)
444  {
445  EFAElement * childElem = _child_elements[elem_iter];
446  childElem->connectNeighbors(
447  _permanent_nodes, _temp_nodes, _inverse_connectivity, mergeUncutVirtualEdges);
448  childElem->updateFragmentNode();
449  } // loop over child elements
450 
451  std::vector<EFAElement *>::iterator vit;
452  for (vit = _child_elements.begin(); vit != _child_elements.end();)
453  {
454  if (*vit == NULL)
455  vit = _child_elements.erase(vit);
456  else
457  ++vit;
458  }
459 }
virtual void connectNeighbors(std::map< unsigned int, EFANode *> &PermanentNodes, std::map< unsigned int, EFANode *> &TempNodes, std::map< EFANode *, std::set< EFAElement *>> &InverseConnectivityMap, bool merge_phantom_edges)=0
std::vector< EFAElement * > _child_elements
virtual void updateFragmentNode()=0
std::map< EFANode *, std::set< EFAElement * > > _inverse_connectivity
std::map< unsigned int, EFANode * > _temp_nodes
std::map< unsigned int, EFANode * > _permanent_nodes

◆ createChildElements()

void ElementFragmentAlgorithm::createChildElements ( )

Definition at line 417 of file ElementFragmentAlgorithm.C.

Referenced by updateTopology().

418 {
419  // temporary container for new elements -- will be merged with Elements
420  std::map<unsigned int, EFAElement *> newChildElements;
421 
422  // loop over the original elements in the mesh
423  std::map<unsigned int, EFAElement *>::iterator eit;
424  std::map<unsigned int, EFAElement *>::iterator ElementsEnd = _elements.end();
425  for (eit = _elements.begin(); eit != ElementsEnd; ++eit)
426  {
427  EFAElement * curr_elem = eit->second;
428  curr_elem->createChild(_crack_tip_elements,
429  _elements,
430  newChildElements,
433  _temp_nodes);
434  } // loop over elements
435  // Merge newChildElements back in with Elements
436  _elements.insert(newChildElements.begin(), newChildElements.end());
437 }
std::vector< EFAElement * > _child_elements
std::vector< EFAElement * > _parent_elements
std::map< unsigned int, EFAElement * > _elements
virtual void createChild(const std::set< EFAElement *> &CrackTipElements, std::map< unsigned int, EFAElement *> &Elements, std::map< unsigned int, EFAElement *> &newChildElements, std::vector< EFAElement *> &ChildElements, std::vector< EFAElement *> &ParentElements, std::map< unsigned int, EFANode *> &TempNodes)=0
std::set< EFAElement * > _crack_tip_elements
std::map< unsigned int, EFANode * > _temp_nodes

◆ error()

void ElementFragmentAlgorithm::error ( const std::string &  error_string)

◆ getChildElements()

const std::vector<EFAElement *>& ElementFragmentAlgorithm::getChildElements ( )
inline

Definition at line 80 of file ElementFragmentAlgorithm.h.

Referenced by XFEM::cutMeshWithEFA().

80 { return _child_elements; };
std::vector< EFAElement * > _child_elements

◆ getCrackTipElements()

const std::set<EFAElement *>& ElementFragmentAlgorithm::getCrackTipElements ( )
inline

Definition at line 83 of file ElementFragmentAlgorithm.h.

Referenced by XFEM::cutMeshWithEFA(), and XFEM::storeCrackTipOriginAndDirection().

83 { return _crack_tip_elements; };
std::set< EFAElement * > _crack_tip_elements

◆ getElemByID()

EFAElement * ElementFragmentAlgorithm::getElemByID ( unsigned int  id)

Definition at line 590 of file ElementFragmentAlgorithm.C.

Referenced by XFEM::buildEFAMesh(), XFEM::getEFAElem2D(), and XFEM::getEFAElem3D().

591 {
592  std::map<unsigned int, EFAElement *>::iterator mit = _elements.find(id);
593  if (mit == _elements.end())
594  EFAError("in getElemByID() could not find element: ", id);
595  return mit->second;
596 }
std::map< unsigned int, EFAElement * > _elements

◆ getElemIdByNodes()

unsigned int ElementFragmentAlgorithm::getElemIdByNodes ( unsigned int *  node_id)

Definition at line 599 of file ElementFragmentAlgorithm.C.

600 {
601  unsigned int elem_id = 99999;
602  std::map<unsigned int, EFAElement *>::iterator eit;
603  for (eit = _elements.begin(); eit != _elements.end(); ++eit)
604  {
605  EFAElement * curr_elem = eit->second;
606  unsigned int counter = 0;
607  for (unsigned int i = 0; i < curr_elem->numNodes(); ++i)
608  {
609  if (curr_elem->getNode(i)->id() == node_id[i])
610  counter += 1;
611  }
612  if (counter == curr_elem->numNodes())
613  {
614  elem_id = curr_elem->id();
615  break;
616  }
617  }
618  return elem_id;
619 }
unsigned int id() const
Definition: EFAElement.C:28
std::map< unsigned int, EFAElement * > _elements
EFANode * getNode(unsigned int node_id) const
Definition: EFAElement.C:46
unsigned int numNodes() const
Definition: EFAElement.C:34
static unsigned int counter
unsigned int id() const
Definition: EFANode.C:36

◆ getEmbeddedNodes()

const std::map<unsigned int, EFANode *>& ElementFragmentAlgorithm::getEmbeddedNodes ( )
inline

Definition at line 86 of file ElementFragmentAlgorithm.h.

86 { return _embedded_nodes; }
std::map< unsigned int, EFANode * > _embedded_nodes

◆ getNewNodes()

const std::vector<EFANode *>& ElementFragmentAlgorithm::getNewNodes ( )
inline

Definition at line 82 of file ElementFragmentAlgorithm.h.

Referenced by XFEM::cutMeshWithEFA().

82 { return _new_nodes; };
std::vector< EFANode * > _new_nodes

◆ getParentElements()

const std::vector<EFAElement *>& ElementFragmentAlgorithm::getParentElements ( )
inline

Definition at line 81 of file ElementFragmentAlgorithm.h.

Referenced by XFEM::cutMeshWithEFA().

81 { return _parent_elements; };
std::vector< EFAElement * > _parent_elements

◆ getPermanentNodes()

const std::map<unsigned int, EFANode *>& ElementFragmentAlgorithm::getPermanentNodes ( )
inline

Definition at line 84 of file ElementFragmentAlgorithm.h.

84 { return _permanent_nodes; }
std::map< unsigned int, EFANode * > _permanent_nodes

◆ getTempNodes()

const std::map<unsigned int, EFANode *>& ElementFragmentAlgorithm::getTempNodes ( )
inline

Definition at line 85 of file ElementFragmentAlgorithm.h.

85 { return _temp_nodes; }
std::map< unsigned int, EFANode * > _temp_nodes

◆ initCrackTipTopology()

void ElementFragmentAlgorithm::initCrackTipTopology ( )

Definition at line 200 of file ElementFragmentAlgorithm.C.

Referenced by XFEM::buildEFAMesh().

201 {
202  _crack_tip_elements.clear(); // re-build CrackTipElements!
203  std::map<unsigned int, EFAElement *>::iterator eit;
204  for (eit = _elements.begin(); eit != _elements.end(); ++eit)
205  {
206  EFAElement * curr_elem = eit->second;
207  curr_elem->initCrackTip(_crack_tip_elements); // CrackTipElements changed here
208  }
209 }
std::map< unsigned int, EFAElement * > _elements
std::set< EFAElement * > _crack_tip_elements
virtual void initCrackTip(std::set< EFAElement *> &CrackTipElements)=0

◆ printMesh()

void ElementFragmentAlgorithm::printMesh ( )

Definition at line 504 of file ElementFragmentAlgorithm.C.

Referenced by sanityCheck().

505 {
506  _ostream << "============================================================"
507  << "==================================================" << std::endl;
508  _ostream << " CutElemMesh Data" << std::endl;
509  _ostream << "============================================================"
510  << "==================================================" << std::endl;
511  _ostream << "Permanent Nodes:" << std::endl;
512  std::map<unsigned int, EFANode *>::iterator mit;
513  unsigned int counter = 0;
514  for (mit = _permanent_nodes.begin(); mit != _permanent_nodes.end(); ++mit)
515  {
516  _ostream << " " << mit->second->id();
517  counter += 1;
518  if (counter % 10 == 0)
519  _ostream << std::endl;
520  }
521  _ostream << std::endl;
522  _ostream << "Temp Nodes:" << std::endl;
523  counter = 0;
524  for (mit = _temp_nodes.begin(); mit != _temp_nodes.end(); ++mit)
525  {
526  _ostream << " " << mit->second->id();
527  counter += 1;
528  if (counter % 10 == 0)
529  _ostream << std::endl;
530  }
531  _ostream << std::endl;
532  _ostream << "Embedded Nodes:" << std::endl;
533  counter = 0;
534  for (mit = _embedded_nodes.begin(); mit != _embedded_nodes.end(); ++mit)
535  {
536  _ostream << " " << mit->second->id();
537  counter += 1;
538  if (counter % 10 == 0)
539  _ostream << std::endl;
540  }
541  _ostream << std::endl;
542  _ostream << "Embedded Permanent Nodes:" << std::endl;
543  counter = 0;
544  for (mit = _embedded_permanent_nodes.begin(); mit != _embedded_permanent_nodes.end(); ++mit)
545  {
546  _ostream << " " << mit->second->id();
547  counter += 1;
548  if (counter % 10 == 0)
549  _ostream << std::endl;
550  }
551  _ostream << std::endl;
552  _ostream << "Parent Elements:" << std::endl;
553  counter = 0;
554  for (unsigned int i = 0; i < _parent_elements.size(); ++i)
555  {
556  _ostream << " " << _parent_elements[i]->id();
557  counter += 1;
558  if (counter % 10 == 0)
559  _ostream << std::endl;
560  }
561  _ostream << std::endl;
562  _ostream << "Child Elements:" << std::endl;
563  counter = 0;
564  for (unsigned int i = 0; i < _child_elements.size(); ++i)
565  {
566  _ostream << " " << _child_elements[i]->id();
567  counter += 1;
568  if (counter % 10 == 0)
569  _ostream << std::endl;
570  }
571  _ostream << std::endl;
572  _ostream << "Elements:" << std::endl;
573  _ostream << " id "
574  << "| nodes "
575  << "| embedded nodes "
576  << "| edge neighbors "
577  << "| frag "
578  << "| frag link ... " << std::endl;
579  _ostream << "------------------------------------------------------------"
580  << "--------------------------------------------------" << std::endl;
581  std::map<unsigned int, EFAElement *>::iterator eit;
582  for (eit = _elements.begin(); eit != _elements.end(); ++eit)
583  {
584  EFAElement * currElem = eit->second;
585  currElem->printElement(_ostream);
586  }
587 }
std::vector< EFAElement * > _child_elements
std::vector< EFAElement * > _parent_elements
std::map< unsigned int, EFAElement * > _elements
std::map< unsigned int, EFANode * > _embedded_permanent_nodes
virtual void printElement(std::ostream &ostream)=0
std::map< unsigned int, EFANode * > _temp_nodes
std::map< unsigned int, EFANode * > _embedded_nodes
std::map< unsigned int, EFANode * > _permanent_nodes
static unsigned int counter

◆ reset()

void ElementFragmentAlgorithm::reset ( )

Definition at line 330 of file ElementFragmentAlgorithm.C.

Referenced by XFEM::buildEFAMesh().

331 {
332  _new_nodes.clear();
333  _child_elements.clear();
334  _parent_elements.clear();
335  // _merged_edge_map.clear();
336  _crack_tip_elements.clear();
337  _inverse_connectivity.clear();
338 
339  std::map<unsigned int, EFANode *>::iterator mit;
340  for (mit = _permanent_nodes.begin(); mit != _permanent_nodes.end(); ++mit)
341  {
342  delete mit->second;
343  mit->second = NULL;
344  }
345  _permanent_nodes.clear();
346  // for (mit = EmbeddedNodes.begin(); mit != EmbeddedNodes.end(); ++mit )
347  // {
348  // delete mit->second;
349  // mit->second = NULL;
350  // }
351  for (mit = _temp_nodes.begin(); mit != _temp_nodes.end(); ++mit)
352  {
353  delete mit->second;
354  mit->second = NULL;
355  }
356  _temp_nodes.clear();
357  std::map<unsigned int, EFAElement *>::iterator eit;
358  for (eit = _elements.begin(); eit != _elements.end(); ++eit)
359  {
360  delete eit->second;
361  eit->second = NULL;
362  }
363  _elements.clear();
364 }
std::vector< EFAElement * > _child_elements
std::vector< EFAElement * > _parent_elements
std::map< unsigned int, EFAElement * > _elements
std::set< EFAElement * > _crack_tip_elements
std::vector< EFANode * > _new_nodes
std::map< EFANode *, std::set< EFAElement * > > _inverse_connectivity
std::map< unsigned int, EFANode * > _temp_nodes
std::map< unsigned int, EFANode * > _permanent_nodes

◆ restoreFragmentInfo()

void ElementFragmentAlgorithm::restoreFragmentInfo ( EFAElement *const  elem,
const EFAElement *const  from_elem 
)

Definition at line 410 of file ElementFragmentAlgorithm.C.

Referenced by XFEM::buildEFAMesh().

412 {
413  elem->restoreFragment(from_elem);
414 }
virtual void restoreFragment(const EFAElement *const from_elem)=0

◆ sanityCheck()

void ElementFragmentAlgorithm::sanityCheck ( )

Definition at line 462 of file ElementFragmentAlgorithm.C.

Referenced by updateTopology().

463 {
464  // Make sure there are no remaining TempNodes
465  if (_temp_nodes.size() > 0)
466  {
467  _ostream << "_temp_nodes size > 0. size=" << _temp_nodes.size() << std::endl;
468  printMesh();
469  exit(1);
470  }
471 }
std::map< unsigned int, EFANode * > _temp_nodes

◆ updateCrackTipElements()

void ElementFragmentAlgorithm::updateCrackTipElements ( )

Definition at line 474 of file ElementFragmentAlgorithm.C.

Referenced by updateTopology().

475 {
476  std::set<EFAElement *>::iterator sit;
477  // Delete all elements that were previously flagged as crack tip elements if they have
478  // been split (and hence appear in ParentElements).
479  for (unsigned int i = 0; i < _parent_elements.size(); ++i)
480  {
481  sit = _crack_tip_elements.find(_parent_elements[i]);
482  if (sit != _crack_tip_elements.end())
483  _crack_tip_elements.erase(sit);
484  }
485 
486  // Go through new child elements to find elements that are newly at the crack tip due to
487  // crack growth.
488  for (unsigned int elem_iter = 0; elem_iter < _child_elements.size(); elem_iter++)
489  {
490  EFAElement * childElem = _child_elements[elem_iter];
491  if (childElem->isCrackTipElement())
492  _crack_tip_elements.insert(childElem);
493  } // loop over (new) child elements
494 
495  //_ostream << "Crack tip elements: ";
496  // for (sit=CrackTipElements.begin(); sit!=CrackTipElements.end(); ++sit)
497  //{
498  // _ostream << (*sit)->id<<" ";
499  //}
500  //_ostream << std::endl;
501 }
virtual bool isCrackTipElement() const =0
std::vector< EFAElement * > _child_elements
std::vector< EFAElement * > _parent_elements
std::set< EFAElement * > _crack_tip_elements

◆ updateEdgeNeighbors()

void ElementFragmentAlgorithm::updateEdgeNeighbors ( )

Definition at line 177 of file ElementFragmentAlgorithm.C.

Referenced by XFEM::buildEFAMesh().

178 {
179  std::map<unsigned int, EFAElement *>::iterator eit;
180  for (eit = _elements.begin(); eit != _elements.end(); ++eit)
181  {
182  EFAElement * elem = eit->second;
183  elem->clearNeighbors();
184  }
185 
186  for (eit = _elements.begin(); eit != _elements.end(); ++eit)
187  {
188  EFAElement * curr_elem = eit->second;
190  } // loop over all elements
191 
192  for (eit = _elements.begin(); eit != _elements.end(); ++eit)
193  {
194  EFAElement * curr_elem = eit->second;
195  curr_elem->neighborSanityCheck();
196  }
197 }
std::map< unsigned int, EFAElement * > _elements
virtual void neighborSanityCheck() const =0
virtual void setupNeighbors(std::map< EFANode *, std::set< EFAElement *>> &InverseConnectivityMap)=0
virtual void clearNeighbors()=0
std::map< EFANode *, std::set< EFAElement * > > _inverse_connectivity

◆ updatePhysicalLinksAndFragments()

void ElementFragmentAlgorithm::updatePhysicalLinksAndFragments ( )

Definition at line 290 of file ElementFragmentAlgorithm.C.

Referenced by XFEM::cutMeshWithEFA().

291 {
292  // loop over the elements in the mesh
293  std::map<unsigned int, EFAElement *>::iterator eit;
294  for (eit = _elements.begin(); eit != _elements.end(); ++eit)
295  {
296  EFAElement * curr_elem = eit->second;
298  } // loop over all elements
299 }
std::map< unsigned int, EFAElement * > _elements
std::set< EFAElement * > _crack_tip_elements
virtual void updateFragments(const std::set< EFAElement *> &CrackTipElements, std::map< unsigned int, EFANode *> &EmbeddedNodes)=0
std::map< unsigned int, EFANode * > _embedded_nodes

◆ updateTopology()

void ElementFragmentAlgorithm::updateTopology ( bool  mergeUncutVirtualEdges = true)

Definition at line 302 of file ElementFragmentAlgorithm.C.

Referenced by XFEM::cutMeshWithEFA().

303 {
304  // If mergeUncutVirtualEdges=true, this algorithm replicates the
305  // behavior of classical XFEM. If false, it gives the behavior of
306  // the Richardson et. al. (2011) paper
307 
308  _new_nodes.clear();
309  _child_elements.clear();
310  _parent_elements.clear();
311  // _merged_edge_map.clear();
312 
313  unsigned int first_new_node_id = Efa::getNewID(_permanent_nodes);
314 
316  connectFragments(mergeUncutVirtualEdges);
317  sanityCheck();
319 
320  std::map<unsigned int, EFANode *>::iterator mit;
321  for (mit = _permanent_nodes.begin(); mit != _permanent_nodes.end(); ++mit)
322  {
323  if (mit->first >= first_new_node_id)
324  _new_nodes.push_back(mit->second);
325  }
326  clearPotentialIsolatedNodes(); // _new_nodes and _permanent_nodes may change here
327 }
unsigned int getNewID(std::map< unsigned int, T *> &theMap)
Definition: EFAFuncs.h:39
void connectFragments(bool mergeUncutVirtualEdges)
std::vector< EFAElement * > _child_elements
std::vector< EFAElement * > _parent_elements
std::vector< EFANode * > _new_nodes
std::map< unsigned int, EFANode * > _permanent_nodes

Member Data Documentation

◆ _child_elements

std::vector<EFAElement *> ElementFragmentAlgorithm::_child_elements
private

◆ _crack_tip_elements

std::set<EFAElement *> ElementFragmentAlgorithm::_crack_tip_elements
private

◆ _deleted_nodes

std::vector<EFANode *> ElementFragmentAlgorithm::_deleted_nodes
private

Definition at line 41 of file ElementFragmentAlgorithm.h.

◆ _elements

std::map<unsigned int, EFAElement *> ElementFragmentAlgorithm::_elements
private

◆ _embedded_nodes

std::map<unsigned int, EFANode *> ElementFragmentAlgorithm::_embedded_nodes
private

◆ _embedded_permanent_nodes

std::map<unsigned int, EFANode *> ElementFragmentAlgorithm::_embedded_permanent_nodes
private

◆ _inverse_connectivity

std::map<EFANode *, std::set<EFAElement *> > ElementFragmentAlgorithm::_inverse_connectivity
private

◆ _new_nodes

std::vector<EFANode *> ElementFragmentAlgorithm::_new_nodes
private

◆ _ostream

std::ostream& ElementFragmentAlgorithm::_ostream
private

Definition at line 31 of file ElementFragmentAlgorithm.h.

Referenced by printMesh(), and sanityCheck().

◆ _parent_elements

std::vector<EFAElement *> ElementFragmentAlgorithm::_parent_elements
private

◆ _permanent_nodes

std::map<unsigned int, EFANode *> ElementFragmentAlgorithm::_permanent_nodes
private

◆ _temp_nodes

std::map<unsigned int, EFANode *> ElementFragmentAlgorithm::_temp_nodes
private

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