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

#include <EFAElement2D.h>

Inheritance diagram for EFAElement2D:
[legend]

Public Member Functions

 EFAElement2D (unsigned int eid, unsigned int n_nodes)
 
 EFAElement2D (const EFAElement2D *from_elem, bool convert_to_local)
 
 EFAElement2D (const EFAFace *from_face)
 
 ~EFAElement2D ()
 
virtual unsigned int numFragments () const
 
virtual bool isPartial () const
 
virtual void getNonPhysicalNodes (std::set< EFANode *> &non_physical_nodes) const
 
virtual void switchNode (EFANode *new_node, EFANode *old_node, bool descend_to_parent)
 
virtual void switchEmbeddedNode (EFANode *new_node, EFANode *old_node)
 
virtual void updateFragmentNode ()
 
virtual void getMasterInfo (EFANode *node, std::vector< EFANode *> &master_nodes, std::vector< double > &master_weights) const
 
virtual unsigned int numInteriorNodes () const
 
bool overlaysElement (const EFAElement2D *other_elem) const
 
virtual unsigned int getNeighborIndex (const EFAElement *neighbor_elem) const
 
virtual void clearNeighbors ()
 
virtual void setupNeighbors (std::map< EFANode *, std::set< EFAElement *>> &InverseConnectivityMap)
 
virtual void neighborSanityCheck () const
 
virtual void initCrackTip (std::set< EFAElement *> &CrackTipElements)
 
virtual bool shouldDuplicateForCrackTip (const std::set< EFAElement *> &CrackTipElements)
 
virtual bool shouldDuplicateCrackTipSplitElement (const std::set< EFAElement *> &CrackTipElements)
 
virtual bool shouldDuplicateForPhantomCorner ()
 
virtual bool willCrackTipExtend (std::vector< unsigned int > &split_neighbors) const
 
virtual bool isCrackTipElement () const
 
virtual unsigned int getNumCuts () const
 
virtual bool isFinalCut () const
 
virtual void updateFragments (const std::set< EFAElement *> &CrackTipElements, std::map< unsigned int, EFANode *> &EmbeddedNodes)
 
virtual void fragmentSanityCheck (unsigned int n_old_frag_edges, unsigned int n_old_frag_cuts) const
 
virtual void restoreFragment (const EFAElement *const from_elem)
 
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)
 
virtual void removePhantomEmbeddedNode ()
 
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)
 
virtual void printElement (std::ostream &ostream)
 
EFAFragment2DgetFragment (unsigned int frag_id) const
 
std::set< EFANode * > getEdgeNodes (unsigned int edge_id) const
 
bool getEdgeNodeParametricCoordinate (EFANode *node, std::vector< double > &para_coor) const
 
EFAFaceNodegetInteriorNode (unsigned int interior_node_id) const
 
void deleteInteriorNodes ()
 
unsigned int numEdges () const
 
void setEdge (unsigned int edge_id, EFAEdge *edge)
 
void createEdges ()
 
EFAEdgegetEdge (unsigned int edge_id) const
 
EFAEdgegetFragmentEdge (unsigned int frag_id, unsigned int edge_id) const
 
std::set< EFANode * > getPhantomNodeOnEdge (unsigned int edge_id) const
 
bool getFragmentEdgeID (unsigned int elem_edge_id, unsigned int &frag_edge_id) const
 
bool isEdgePhantom (unsigned int edge_id) const
 
unsigned int numEdgeNeighbors (unsigned int edge_id) const
 
EFAElement2DgetEdgeNeighbor (unsigned int edge_id, unsigned int neighbor_id) const
 
unsigned int getCrackTipSplitElementID () const
 
bool fragmentHasTipEdges () const
 
unsigned int getTipEdgeID () const
 
EFANodegetTipEmbeddedNode () const
 
bool edgeContainsTip (unsigned int edge_id) const
 
bool fragmentEdgeAlreadyCut (unsigned int ElemEdgeID) const
 
void addEdgeCut (unsigned int edge_id, double position, EFANode *embedded_node, std::map< unsigned int, EFANode *> &EmbeddedNodes, bool add_to_neighbor)
 
void addNodeCut (unsigned int node_id, EFANode *embedded_permanent_node, std::map< unsigned int, EFANode *> &PermanentNodes, std::map< unsigned int, EFANode *> &EmbeddedPermanentNodes)
 
bool addFragmentEdgeCut (unsigned int frag_edge_id, double position, std::map< unsigned int, EFANode *> &EmbeddedNodes)
 
std::vector< EFAFragment2D * > branchingSplit (std::map< unsigned int, EFANode *> &EmbeddedNodes)
 
std::vector< EFANode * > getCommonNodes (const EFAElement2D *other_elem) const
 
unsigned int id () const
 
unsigned int numNodes () const
 
void setNode (unsigned int node_id, EFANode *node)
 
EFANodegetNode (unsigned int node_id) const
 
bool containsNode (EFANode *node) const
 
void printNodes (std::ostream &ostream) const
 
EFANodecreateLocalNodeFromGlobalNode (const EFANode *global_node) const
 
EFANodegetGlobalNodeFromLocalNode (const EFANode *local_node) const
 
unsigned int getLocalNodeIndex (EFANode *node) const
 
void setCrackTipSplit ()
 
bool isCrackTipSplit () const
 
unsigned int numCrackTipNeighbors () const
 
unsigned int getCrackTipNeighbor (unsigned int index) const
 
void addCrackTipNeighbor (EFAElement *neighbor_elem)
 
EFAElementgetParent () const
 
EFAElementgetChild (unsigned int child_id) const
 
void setParent (EFAElement *parent)
 
unsigned int numChildren () const
 
void addChild (EFAElement *child)
 
void clearParentAndChildren ()
 
void findGeneralNeighbors (std::map< EFANode *, std::set< EFAElement *>> &InverseConnectivity)
 
EFAElementgetGeneralNeighbor (unsigned int index) const
 
unsigned int numGeneralNeighbors () const
 

Protected Member Functions

void mergeNodes (EFANode *&childNode, EFANode *&childOfNeighborNode, EFAElement *childOfNeighborElem, std::map< unsigned int, EFANode *> &PermanentNodes, std::map< unsigned int, EFANode *> &TempNodes)
 

Protected Attributes

unsigned int _id
 
unsigned int _num_nodes
 
std::vector< EFANode * > _nodes
 
std::vector< EFANode * > _local_nodes
 
EFAElement_parent
 
std::vector< EFAElement * > _children
 
bool _crack_tip_split_element
 
std::vector< unsigned int > _crack_tip_neighbors
 
std::vector< EFAElement * > _general_neighbors
 

Private Member Functions

void mapParametricCoordFrom1Dto2D (unsigned int edge_id, double xi_1d, std::vector< double > &para_coor) const
 
void setLocalCoordinates ()
 

Private Attributes

unsigned int _num_edges
 
std::vector< EFAEdge * > _edges
 
std::vector< EFAFaceNode * > _interior_nodes
 
std::vector< std::vector< EFAElement2D * > > _edge_neighbors
 
std::vector< EFAFragment2D * > _fragments
 
std::vector< EFAPoint_local_node_coor
 

Detailed Description

Definition at line 21 of file EFAElement2D.h.

Constructor & Destructor Documentation

◆ EFAElement2D() [1/3]

EFAElement2D::EFAElement2D ( unsigned int  eid,
unsigned int  n_nodes 
)

Definition at line 23 of file EFAElement2D.C.

Referenced by createChild().

23  : EFAElement(eid, n_nodes)
24 {
25  if (n_nodes == 4 || n_nodes == 8 || n_nodes == 9)
26  _num_edges = 4;
27  else if (n_nodes == 3 || n_nodes == 6)
28  _num_edges = 3;
29  else
30  EFAError("In EFAelement2D the supported element types are QUAD4, QUAD8, QUAD9, TRI3 and TRI6");
32  _edges = std::vector<EFAEdge *>(_num_edges, NULL);
34  std::vector<std::vector<EFAElement2D *>>(_num_edges, std::vector<EFAElement2D *>(1, NULL));
35 }
std::vector< std::vector< EFAElement2D * > > _edge_neighbors
Definition: EFAElement2D.h:34
std::vector< EFAEdge * > _edges
Definition: EFAElement2D.h:32
EFAElement(unsigned int eid, unsigned int n_nodes)
Definition: EFAElement.C:16
void setLocalCoordinates()
Definition: EFAElement2D.C:141
unsigned int _num_edges
Definition: EFAElement2D.h:31

◆ EFAElement2D() [2/3]

EFAElement2D::EFAElement2D ( const EFAElement2D from_elem,
bool  convert_to_local 
)

Definition at line 37 of file EFAElement2D.C.

38  : EFAElement(from_elem->_id, from_elem->_num_nodes),
39  _num_edges(from_elem->_num_edges),
40  _edges(_num_edges, NULL),
41  _edge_neighbors(_num_edges, std::vector<EFAElement2D *>(1, NULL))
42 {
43  if (convert_to_local)
44  {
45  // build local nodes from global nodes
46  for (unsigned int i = 0; i < _num_nodes; ++i)
47  {
48  if (from_elem->_nodes[i]->category() == EFANode::N_CATEGORY_PERMANENT ||
49  from_elem->_nodes[i]->category() == EFANode::N_CATEGORY_TEMP ||
50  from_elem->_nodes[i]->category() == EFANode::N_CATEGORY_EMBEDDED_PERMANENT)
51  {
52  _nodes[i] = from_elem->createLocalNodeFromGlobalNode(from_elem->_nodes[i]);
53  _local_nodes.push_back(_nodes[i]); // convenient to delete local nodes
54  }
55  else
56  EFAError("In EFAelement2D ",
57  from_elem->id(),
58  " the copy constructor must have from_elem w/ global nodes. node: ",
59  i,
60  " category: ",
61  from_elem->_nodes[i]->category());
62  }
63 
64  // copy edges, fragments and interior nodes from from_elem
65  for (unsigned int i = 0; i < _num_edges; ++i)
66  _edges[i] = new EFAEdge(*from_elem->_edges[i]);
67  for (unsigned int i = 0; i < from_elem->_fragments.size(); ++i)
68  _fragments.push_back(new EFAFragment2D(this, true, from_elem, i));
69  for (unsigned int i = 0; i < from_elem->_interior_nodes.size(); ++i)
70  _interior_nodes.push_back(new EFAFaceNode(*from_elem->_interior_nodes[i]));
71 
72  // replace all global nodes with local nodes
73  for (unsigned int i = 0; i < _num_nodes; ++i)
74  {
75  if (_nodes[i]->category() == EFANode::N_CATEGORY_LOCAL_INDEX)
76  switchNode(
77  _nodes[i],
78  from_elem->_nodes[i],
79  false); // when save to _cut_elem_map, the EFAelement is not a child of any parent
80  else
81  EFAError("In EFAelement2D copy constructor this elem's nodes must be local");
82  }
83 
85  }
86  else
87  EFAError("this EFAelement2D constructor only converts global nodes to local nodes");
88 }
unsigned int id() const
Definition: EFAElement.C:28
std::vector< EFAFaceNode * > _interior_nodes
Definition: EFAElement2D.h:33
unsigned int _id
Definition: EFAElement.h:28
std::vector< std::vector< EFAElement2D * > > _edge_neighbors
Definition: EFAElement2D.h:34
std::vector< EFAEdge * > _edges
Definition: EFAElement2D.h:32
EFAElement(unsigned int eid, unsigned int n_nodes)
Definition: EFAElement.C:16
virtual void switchNode(EFANode *new_node, EFANode *old_node, bool descend_to_parent)
Definition: EFAElement2D.C:262
std::vector< EFANode * > _nodes
Definition: EFAElement.h:30
unsigned int _num_nodes
Definition: EFAElement.h:29
std::vector< EFAPoint > _local_node_coor
Definition: EFAElement2D.h:36
EFANode * createLocalNodeFromGlobalNode(const EFANode *global_node) const
Definition: EFAElement.C:70
unsigned int _num_edges
Definition: EFAElement2D.h:31
std::vector< EFAFragment2D * > _fragments
Definition: EFAElement2D.h:35
std::vector< EFANode * > _local_nodes
Definition: EFAElement.h:31

◆ EFAElement2D() [3/3]

EFAElement2D::EFAElement2D ( const EFAFace from_face)

Definition at line 90 of file EFAElement2D.C.

91  : EFAElement(0, from_face->numNodes()),
92  _num_edges(from_face->numEdges()),
93  _edges(_num_edges, NULL),
94  _edge_neighbors(_num_edges, std::vector<EFAElement2D *>(1, NULL))
95 {
96  for (unsigned int i = 0; i < _num_nodes; ++i)
97  _nodes[i] = from_face->getNode(i);
98  for (unsigned int i = 0; i < _num_edges; ++i)
99  _edges[i] = new EFAEdge(*from_face->getEdge(i));
100  for (unsigned int i = 0; i < from_face->numInteriorNodes(); ++i)
101  _interior_nodes.push_back(new EFAFaceNode(*from_face->getInteriorNode(i)));
102 }
unsigned int numEdges() const
Definition: EFAFace.C:254
std::vector< EFAFaceNode * > _interior_nodes
Definition: EFAElement2D.h:33
std::vector< std::vector< EFAElement2D * > > _edge_neighbors
Definition: EFAElement2D.h:34
std::vector< EFAEdge * > _edges
Definition: EFAElement2D.h:32
EFAElement(unsigned int eid, unsigned int n_nodes)
Definition: EFAElement.C:16
EFANode * getNode(unsigned int node_id) const
Definition: EFAFace.C:99
std::vector< EFANode * > _nodes
Definition: EFAElement.h:30
unsigned int numNodes() const
Definition: EFAFace.C:87
EFAEdge * getEdge(unsigned int edge_id) const
Definition: EFAFace.C:260
unsigned int _num_nodes
Definition: EFAElement.h:29
EFAFaceNode * getInteriorNode(unsigned int index) const
Definition: EFAFace.C:684
unsigned int numInteriorNodes() const
Definition: EFAFace.C:236
unsigned int _num_edges
Definition: EFAElement2D.h:31

◆ ~EFAElement2D()

EFAElement2D::~EFAElement2D ( )

Definition at line 104 of file EFAElement2D.C.

105 {
106  for (unsigned int i = 0; i < _fragments.size(); ++i)
107  {
108  if (_fragments[i])
109  {
110  delete _fragments[i];
111  _fragments[i] = NULL;
112  }
113  }
114  for (unsigned int i = 0; i < _edges.size(); ++i)
115  {
116  if (_edges[i])
117  {
118  delete _edges[i];
119  _edges[i] = NULL;
120  }
121  }
122  for (unsigned int i = 0; i < _interior_nodes.size(); ++i)
123  {
124  if (_interior_nodes[i])
125  {
126  delete _interior_nodes[i];
127  _interior_nodes[i] = NULL;
128  }
129  }
130  for (unsigned int i = 0; i < _local_nodes.size(); ++i)
131  {
132  if (_local_nodes[i])
133  {
134  delete _local_nodes[i];
135  _local_nodes[i] = NULL;
136  }
137  }
138 }
std::vector< EFAFaceNode * > _interior_nodes
Definition: EFAElement2D.h:33
std::vector< EFAEdge * > _edges
Definition: EFAElement2D.h:32
std::vector< EFAFragment2D * > _fragments
Definition: EFAElement2D.h:35
std::vector< EFANode * > _local_nodes
Definition: EFAElement.h:31

Member Function Documentation

◆ addChild()

void EFAElement::addChild ( EFAElement child)
inherited

Definition at line 203 of file EFAElement.C.

204 {
205  _children.push_back(child);
206 }
std::vector< EFAElement * > _children
Definition: EFAElement.h:33

◆ addCrackTipNeighbor()

void EFAElement::addCrackTipNeighbor ( EFAElement neighbor_elem)
inherited

Definition at line 157 of file EFAElement.C.

158 {
159  // Find out what side the specified element is on, and add it as a crack tip neighbor
160  // element for that side.
161  unsigned int neighbor_index = getNeighborIndex(neighbor_elem);
162  bool crack_tip_neighbor_exist = false;
163  for (unsigned int i = 0; i < _crack_tip_neighbors.size(); ++i)
164  {
165  if (_crack_tip_neighbors[i] == neighbor_index)
166  {
167  crack_tip_neighbor_exist = true;
168  break;
169  }
170  }
171  if (!crack_tip_neighbor_exist)
172  _crack_tip_neighbors.push_back(neighbor_index);
173 }
virtual unsigned int getNeighborIndex(const EFAElement *neighbor_elem) const =0
std::vector< unsigned int > _crack_tip_neighbors
Definition: EFAElement.h:35

◆ addEdgeCut()

void EFAElement2D::addEdgeCut ( unsigned int  edge_id,
double  position,
EFANode embedded_node,
std::map< unsigned int, EFANode *> &  EmbeddedNodes,
bool  add_to_neighbor 
)

Definition at line 1710 of file EFAElement2D.C.

Referenced by addEdgeCut(), and ElementFragmentAlgorithm::addElemEdgeIntersection().

1715 {
1716  EFANode * local_embedded = NULL;
1717  EFANode * edge_node1 = _edges[edge_id]->getNode(0);
1718  if (embedded_node) // use the existing embedded node if it was passed in
1719  local_embedded = embedded_node;
1720 
1721  if (_edges[edge_id]->hasIntersectionAtPosition(position, edge_node1) && position > Xfem::tol &&
1722  position < 1.0 - Xfem::tol)
1723  {
1724  unsigned int emb_id = _edges[edge_id]->getEmbeddedNodeIndex(position, edge_node1);
1725  EFANode * old_emb = _edges[edge_id]->getEmbeddedNode(emb_id);
1726  if (embedded_node && embedded_node != old_emb)
1727  {
1728  EFAError("Attempting to add edge intersection when one already exists with different node.",
1729  " elem: ",
1730  _id,
1731  " edge: ",
1732  edge_id,
1733  " position: ",
1734  position);
1735  }
1736  local_embedded = old_emb;
1737  }
1738  else // if no cut exists at the input position
1739  {
1740  bool add2elem = true;
1741 
1742  // check if it is necessary to add cuts to fragment
1743  unsigned int frag_edge_id = 99999; // the id of the partially overlapping fragment edge
1744  EFAEdge * frag_edge = NULL;
1745  EFANode * frag_edge_node1 = NULL;
1746  double frag_pos = -1.0;
1747  bool add2frag = false;
1748 
1749  if (getFragmentEdgeID(edge_id, frag_edge_id)) // elem edge contains a frag edge
1750  {
1751  frag_edge = getFragmentEdge(0, frag_edge_id);
1752  if (!fragmentEdgeAlreadyCut(edge_id))
1753  {
1754  double xi[2] = {-1.0, -1.0}; // relative coords of two frag edge nodes
1755  xi[0] = _edges[edge_id]->distanceFromNode1(frag_edge->getNode(0));
1756  xi[1] = _edges[edge_id]->distanceFromNode1(frag_edge->getNode(1));
1757  if ((position - xi[0]) * (position - xi[1]) <
1758  0.0) // the cut to be added is within the real part of the edge
1759  {
1760  frag_edge_node1 = frag_edge->getNode(0);
1761  frag_pos = (position - xi[0]) / (xi[1] - xi[0]);
1762  add2frag = true;
1763  }
1764  else // the emb node to be added is in the phantom part of the elem edge
1765  add2elem = false; // DO NOT ADD INTERSECT IN THIS CASE
1766  }
1767  else
1768  {
1769  EFAWarning("attempting to add new cut to a cut fragment edge");
1770  add2elem = false; // DO NOT ADD INTERSECT IN THIS CASE
1771  }
1772  }
1773 
1774  // If elem edge has 2 cuts but they have not been restored yet, it's OK because
1775  // getFragmentEdgeID = false so we won't add anything to the restored fragment.
1776  // add to elem edge (IMPORTANT to do it AFTER the above fragment check)
1777  if (add2elem)
1778  {
1779  if (!local_embedded) // need to create new embedded node
1780  {
1781  unsigned int new_node_id = Efa::getNewID(EmbeddedNodes);
1782  local_embedded = new EFANode(new_node_id, EFANode::N_CATEGORY_EMBEDDED);
1783  EmbeddedNodes.insert(std::make_pair(new_node_id, local_embedded));
1784  }
1785  _edges[edge_id]->addIntersection(position, local_embedded, edge_node1);
1786  if (_edges[edge_id]->numEmbeddedNodes() > 2)
1787  EFAError("element edge can't have >2 embedded nodes");
1788  }
1789 
1790  // add to frag edge
1791  if (add2frag)
1792  {
1793  frag_edge->addIntersection(frag_pos, local_embedded, frag_edge_node1);
1794  if (frag_edge->numEmbeddedNodes() > 1)
1795  EFAError("fragment edge can't have >1 embedded nodes");
1796  }
1797  } // IF the input embedded node already exists on this elem edge
1798 
1799  if (add_to_neighbor)
1800  {
1801  for (unsigned int en_iter = 0; en_iter < numEdgeNeighbors(edge_id); ++en_iter)
1802  {
1803  EFAElement2D * edge_neighbor = getEdgeNeighbor(edge_id, en_iter);
1804  unsigned int neighbor_edge_id = edge_neighbor->getNeighborIndex(this);
1805  if (edge_neighbor->getEdge(neighbor_edge_id)->getNode(0) == edge_node1) // same direction
1806  EFAError("neighbor edge has the same direction as this edge");
1807  double neigh_pos = 1.0 - position; // get emb node's postion on neighbor edge
1808  edge_neighbor->addEdgeCut(neighbor_edge_id, neigh_pos, local_embedded, EmbeddedNodes, false);
1809  }
1810  } // If add_to_neighbor required
1811 }
unsigned int numEdgeNeighbors(unsigned int edge_id) const
void addEdgeCut(unsigned int edge_id, double position, EFANode *embedded_node, std::map< unsigned int, EFANode *> &EmbeddedNodes, bool add_to_neighbor)
unsigned int getNewID(std::map< unsigned int, T *> &theMap)
Definition: EFAFuncs.h:39
unsigned int _id
Definition: EFAElement.h:28
virtual unsigned int getNeighborIndex(const EFAElement *neighbor_elem) const
Definition: EFAElement2D.C:447
EFAEdge * getEdge(unsigned int edge_id) const
bool fragmentEdgeAlreadyCut(unsigned int ElemEdgeID) const
std::vector< EFAEdge * > _edges
Definition: EFAElement2D.h:32
bool getFragmentEdgeID(unsigned int elem_edge_id, unsigned int &frag_edge_id) const
static const double tol
Definition: XFEMFuncs.h:21
EFAElement2D * getEdgeNeighbor(unsigned int edge_id, unsigned int neighbor_id) const
unsigned int numEmbeddedNodes() const
Definition: EFAEdge.C:339
void addIntersection(double position, EFANode *embedded_node_tmp, EFANode *from_node)
Definition: EFAEdge.C:130
EFANode * getNode(unsigned int index) const
Definition: EFAEdge.C:179
EFAEdge * getFragmentEdge(unsigned int frag_id, unsigned int edge_id) const

◆ addFragmentEdgeCut()

bool EFAElement2D::addFragmentEdgeCut ( unsigned int  frag_edge_id,
double  position,
std::map< unsigned int, EFANode *> &  EmbeddedNodes 
)

Definition at line 1837 of file EFAElement2D.C.

Referenced by ElementFragmentAlgorithm::addFragEdgeIntersection().

1840 {
1841  if (_fragments.size() != 1)
1842  EFAError("Element: ", _id, " should have only 1 fragment in addFragEdgeIntersection");
1843  EFANode * local_embedded = NULL;
1844 
1845  // check if this intersection coincide with any embedded node on this edge
1846  bool isValidIntersection = true;
1847  EFAEdge * frag_edge = getFragmentEdge(0, frag_edge_id); // we're considering this edge
1848  EFANode * edge_node1 = frag_edge->getNode(0);
1849  EFANode * edge_node2 = frag_edge->getNode(1);
1850  if ((std::abs(position) < Xfem::tol && edge_node1->category() == EFANode::N_CATEGORY_EMBEDDED) ||
1851  (std::abs(1.0 - position) < Xfem::tol &&
1852  edge_node2->category() == EFANode::N_CATEGORY_EMBEDDED))
1853  isValidIntersection = false;
1854 
1855  // TODO: do not allow to cut fragment's node
1856  if (std::abs(position) < Xfem::tol || std::abs(1.0 - position) < Xfem::tol)
1857  isValidIntersection = false;
1858 
1859  // add valid intersection point to an edge
1860  if (isValidIntersection)
1861  {
1862  if (frag_edge->hasIntersection())
1863  {
1864  if (!frag_edge->hasIntersectionAtPosition(position, edge_node1))
1865  EFAError("Attempting to add fragment edge intersection when one already exists with "
1866  "different position.",
1867  " elem: ",
1868  _id,
1869  " edge: ",
1870  frag_edge_id,
1871  " position: ",
1872  position,
1873  " old position: ",
1874  frag_edge->getIntersection(0, edge_node1));
1875  }
1876  else // blank edge - in fact, it can only be a blank element interior edge
1877  {
1878  if (!_fragments[0]->isEdgeInterior(frag_edge_id) ||
1879  _fragments[0]->isSecondaryInteriorEdge(frag_edge_id))
1880  EFAError("Attemping to add intersection to an invalid fragment edge. Element: ",
1881  _id,
1882  " fragment_edge: ",
1883  frag_edge_id);
1884 
1885  // create the embedded node and add it to the fragment's boundary edge
1886  unsigned int new_node_id = Efa::getNewID(EmbeddedNodes);
1887  local_embedded = new EFANode(new_node_id, EFANode::N_CATEGORY_EMBEDDED);
1888  EmbeddedNodes.insert(std::make_pair(new_node_id, local_embedded));
1889  frag_edge->addIntersection(position, local_embedded, edge_node1);
1890 
1891  // save this interior embedded node to FaceNodes
1892  // TODO: for unstructured elements, the following calution gives you inaccurate position of
1893  // face nodes
1894  // must solve this issue for 3D!
1895  std::vector<double> node1_para_coor(2, 0.0);
1896  std::vector<double> node2_para_coor(2, 0.0);
1897  if (getEdgeNodeParametricCoordinate(edge_node1, node1_para_coor) &&
1898  getEdgeNodeParametricCoordinate(edge_node2, node2_para_coor))
1899  {
1900  double xi = (1.0 - position) * node1_para_coor[0] + position * node2_para_coor[0];
1901  double eta = (1.0 - position) * node1_para_coor[1] + position * node2_para_coor[1];
1902  _interior_nodes.push_back(new EFAFaceNode(local_embedded, xi, eta));
1903  }
1904  else
1905  EFAError("elem: ", _id, " cannot get the parametric coords of two end embedded nodes");
1906  }
1907  // no need to add intersection for neighbor fragment - if this fragment has a
1908  // neighbor fragment, the neighbor has already been treated in addEdgeIntersection;
1909  // for an interior edge, there is no neighbor fragment
1910  }
1911 
1912  return isValidIntersection;
1913 }
unsigned int getNewID(std::map< unsigned int, T *> &theMap)
Definition: EFAFuncs.h:39
bool getEdgeNodeParametricCoordinate(EFANode *node, std::vector< double > &para_coor) const
double getIntersection(unsigned int emb_id, EFANode *from_node) const
Definition: EFAEdge.C:237
std::vector< EFAFaceNode * > _interior_nodes
Definition: EFAElement2D.h:33
unsigned int _id
Definition: EFAElement.h:28
bool hasIntersection() const
Definition: EFAEdge.C:198
static const double tol
Definition: XFEMFuncs.h:21
bool hasIntersectionAtPosition(double position, EFANode *from_node) const
Definition: EFAEdge.C:211
void addIntersection(double position, EFANode *embedded_node_tmp, EFANode *from_node)
Definition: EFAEdge.C:130
EFANode * getNode(unsigned int index) const
Definition: EFAEdge.C:179
EFAEdge * getFragmentEdge(unsigned int frag_id, unsigned int edge_id) const
std::vector< EFAFragment2D * > _fragments
Definition: EFAElement2D.h:35
N_CATEGORY category() const
Definition: EFANode.C:42

◆ addNodeCut()

void EFAElement2D::addNodeCut ( unsigned int  node_id,
EFANode embedded_permanent_node,
std::map< unsigned int, EFANode *> &  PermanentNodes,
std::map< unsigned int, EFANode *> &  EmbeddedPermanentNodes 
)

Definition at line 1814 of file EFAElement2D.C.

Referenced by ElementFragmentAlgorithm::addElemNodeIntersection().

1818 {
1819  EFANode * local_embedded_permanent = NULL;
1820  EFANode * node = _nodes[node_id];
1821  if (embedded_permanent_node) // use the existing embedded node if it was passed in
1822  local_embedded_permanent = embedded_permanent_node;
1823 
1824  if (node->category() == EFANode::N_CATEGORY_PERMANENT)
1825  {
1827  local_embedded_permanent = node;
1828  EmbeddedPermanentNodes.insert(std::make_pair(node->id(), local_embedded_permanent));
1829  if (!Efa::deleteFromMap(PermanentNodes, local_embedded_permanent, false))
1830  EFAError("Attempted to delete node: ",
1831  local_embedded_permanent->id(),
1832  " from PermanentNodes, but couldn't find it");
1833  }
1834 }
bool deleteFromMap(std::map< unsigned int, T *> &theMap, T *elemToDelete, bool delete_elem=true)
Definition: EFAFuncs.h:23
std::vector< EFANode * > _nodes
Definition: EFAElement.h:30
void setCategory(EFANode::N_CATEGORY category)
Definition: EFANode.C:60
unsigned int id() const
Definition: EFANode.C:36
N_CATEGORY category() const
Definition: EFANode.C:42

◆ branchingSplit()

std::vector< EFAFragment2D * > EFAElement2D::branchingSplit ( std::map< unsigned int, EFANode *> &  EmbeddedNodes)

Definition at line 1916 of file EFAElement2D.C.

Referenced by updateFragments().

1917 {
1918  if (isPartial())
1919  EFAError("branching is only allowed for an uncut element");
1920 
1921  // collect all emb nodes counterclockwise
1922  std::vector<EFANode *> three_nodes;
1923  for (unsigned int i = 0; i < _edges.size(); ++i)
1924  {
1925  EFANode * node1 = _edges[i]->getNode(0);
1926  if (_edges[i]->numEmbeddedNodes() == 1)
1927  three_nodes.push_back(_edges[i]->getEmbeddedNode(0));
1928  else if (_edges[i]->numEmbeddedNodes() == 2)
1929  {
1930  unsigned int id0(
1931  _edges[i]->getIntersection(0, node1) < _edges[i]->getIntersection(1, node1) ? 0 : 1);
1932  unsigned int id1 = 1 - id0;
1933  three_nodes.push_back(_edges[i]->getEmbeddedNode(id0));
1934  three_nodes.push_back(_edges[i]->getEmbeddedNode(id1));
1935  }
1936  }
1937  if (three_nodes.size() != 3)
1938  EFAError("three_nodes.size() != 3");
1939 
1940  // get the parent coords of the braycenter of the three nodes
1941  // TODO: may need a better way to compute this "branching point"
1942  std::vector<double> center_xi(2, 0.0);
1943  for (unsigned int i = 0; i < 3; ++i)
1944  {
1945  std::vector<double> xi_2d(2, 0.0);
1946  getEdgeNodeParametricCoordinate(three_nodes[i], xi_2d);
1947  center_xi[0] += xi_2d[0];
1948  center_xi[1] += xi_2d[1];
1949  }
1950  center_xi[0] /= 3.0;
1951  center_xi[1] /= 3.0;
1952 
1953  // create a new interior node for current element
1954  unsigned int new_node_id = Efa::getNewID(EmbeddedNodes);
1955  EFANode * new_emb = new EFANode(new_node_id, EFANode::N_CATEGORY_EMBEDDED);
1956  EmbeddedNodes.insert(std::make_pair(new_node_id, new_emb));
1957  _interior_nodes.push_back(new EFAFaceNode(new_emb, center_xi[0], center_xi[1]));
1958 
1959  // generate the three fragments
1960  std::vector<EFAFragment2D *> new_fragments;
1961  for (unsigned int i = 0; i < 3; ++i) // loop over 3 sectors
1962  {
1963  EFAFragment2D * new_frag = new EFAFragment2D(this, false, NULL);
1964  unsigned int iplus1(i < 2 ? i + 1 : 0);
1965  new_frag->addEdge(new EFAEdge(three_nodes[iplus1], new_emb));
1966  new_frag->addEdge(new EFAEdge(new_emb, three_nodes[i]));
1967 
1968  unsigned int iedge = 0;
1969  bool add_more_edges = true;
1970  for (unsigned int j = 0; j < _edges.size(); ++j)
1971  {
1972  if (_edges[j]->containsNode(three_nodes[i]))
1973  {
1974  if (_edges[j]->containsNode(three_nodes[iplus1]))
1975  {
1976  new_frag->addEdge(new EFAEdge(three_nodes[i], three_nodes[iplus1]));
1977  add_more_edges = false;
1978  }
1979  else
1980  {
1981  new_frag->addEdge(new EFAEdge(three_nodes[i], _edges[j]->getNode(1)));
1982  }
1983  iedge = j;
1984  break;
1985  }
1986  } // j
1987  while (add_more_edges)
1988  {
1989  iedge += 1;
1990  if (iedge == _edges.size())
1991  iedge = 0;
1992  if (_edges[iedge]->containsNode(three_nodes[iplus1]))
1993  {
1994  new_frag->addEdge(new EFAEdge(_edges[iedge]->getNode(0), three_nodes[iplus1]));
1995  add_more_edges = false;
1996  }
1997  else
1998  new_frag->addEdge(new EFAEdge(_edges[iedge]->getNode(0), _edges[iedge]->getNode(1)));
1999  }
2000  new_fragments.push_back(new_frag);
2001  } // i
2002  return new_fragments;
2003 }
unsigned int getNewID(std::map< unsigned int, T *> &theMap)
Definition: EFAFuncs.h:39
bool getEdgeNodeParametricCoordinate(EFANode *node, std::vector< double > &para_coor) const
std::vector< EFAFaceNode * > _interior_nodes
Definition: EFAElement2D.h:33
void addEdge(EFAEdge *new_edge)
std::vector< EFAEdge * > _edges
Definition: EFAElement2D.h:32
bool containsNode(EFANode *node) const
Definition: EFAElement.C:52
EFANode * getNode(unsigned int node_id) const
Definition: EFAElement.C:46
virtual bool isPartial() const
Definition: EFAElement2D.C:208

◆ clearNeighbors()

void EFAElement2D::clearNeighbors ( )
virtual

Implements EFAElement.

Definition at line 459 of file EFAElement2D.C.

460 {
461  _general_neighbors.clear();
462  for (unsigned int edge_iter = 0; edge_iter < _num_edges; ++edge_iter)
463  _edge_neighbors[edge_iter] = std::vector<EFAElement2D *>(1, NULL);
464 }
std::vector< std::vector< EFAElement2D * > > _edge_neighbors
Definition: EFAElement2D.h:34
unsigned int _num_edges
Definition: EFAElement2D.h:31
std::vector< EFAElement * > _general_neighbors
Definition: EFAElement.h:37

◆ clearParentAndChildren()

void EFAElement::clearParentAndChildren ( )
inherited

Definition at line 209 of file EFAElement.C.

Referenced by ElementFragmentAlgorithm::clearAncestry().

210 {
211  _parent = NULL;
212  _children.clear();
213 }
EFAElement * _parent
Definition: EFAElement.h:32
std::vector< EFAElement * > _children
Definition: EFAElement.h:33

◆ connectNeighbors()

void EFAElement2D::connectNeighbors ( std::map< unsigned int, EFANode *> &  PermanentNodes,
std::map< unsigned int, EFANode *> &  TempNodes,
std::map< EFANode *, std::set< EFAElement *>> &  InverseConnectivityMap,
bool  merge_phantom_edges 
)
virtual

Implements EFAElement.

Definition at line 1171 of file EFAElement2D.C.

1175 {
1176  // N.B. "this" must point to a child element that was just created
1177  if (!_parent)
1178  EFAError("no parent element for child element ", _id, " in connect_neighbors");
1179  EFAElement2D * parent2d = dynamic_cast<EFAElement2D *>(_parent);
1180  if (!parent2d)
1181  EFAError("cannot dynamic cast to parent2d in connect_neighbors");
1182 
1183  // First loop through edges and merge nodes with neighbors as appropriate
1184  for (unsigned int j = 0; j < _num_edges; ++j)
1185  {
1186  for (unsigned int k = 0; k < parent2d->numEdgeNeighbors(j); ++k)
1187  {
1188  EFAElement2D * NeighborElem = parent2d->getEdgeNeighbor(j, k);
1189  unsigned int neighbor_edge_id = NeighborElem->getNeighborIndex(parent2d);
1190 
1191  if (_edges[j]->hasIntersection())
1192  {
1193  for (unsigned int l = 0; l < NeighborElem->numChildren(); ++l)
1194  {
1195  EFAElement2D * childOfNeighborElem =
1196  dynamic_cast<EFAElement2D *>(NeighborElem->getChild(l));
1197  if (!childOfNeighborElem)
1198  EFAError("dynamic cast childOfNeighborElem fails");
1199 
1200  // Check to see if the nodes are already merged. There's nothing else to do in that case.
1201  EFAEdge * neighborChildEdge = childOfNeighborElem->getEdge(neighbor_edge_id);
1202  if (_edges[j]->equivalent(*neighborChildEdge))
1203  continue;
1204 
1205  if (_fragments[0]->isConnected(childOfNeighborElem->getFragment(0)))
1206  {
1207  unsigned int num_edge_nodes = 2;
1208  for (unsigned int i = 0; i < num_edge_nodes; ++i)
1209  {
1210  unsigned int childNodeIndex = i;
1211  unsigned int neighborChildNodeIndex = num_edge_nodes - 1 - childNodeIndex;
1212 
1213  EFANode * childNode = _edges[j]->getNode(childNodeIndex);
1214  EFANode * childOfNeighborNode = neighborChildEdge->getNode(neighborChildNodeIndex);
1215 
1216  mergeNodes(
1217  childNode, childOfNeighborNode, childOfNeighborElem, PermanentNodes, TempNodes);
1218  }
1219 
1220  EFANode * childNode = _edges[j]->getInteriorNode();
1221  EFANode * childOfNeighborNode = neighborChildEdge->getInteriorNode();
1222 
1223  mergeNodes(
1224  childNode, childOfNeighborNode, childOfNeighborElem, PermanentNodes, TempNodes);
1225  }
1226  } // l, loop over NeighborElem's children
1227  }
1228  else // No edge intersection -- optionally merge non-material nodes if they share a common
1229  // parent
1230  {
1231  if (merge_phantom_edges)
1232  {
1233  for (unsigned int l = 0; l < NeighborElem->numChildren(); ++l)
1234  {
1235  EFAElement2D * childOfNeighborElem =
1236  dynamic_cast<EFAElement2D *>(NeighborElem->getChild(l));
1237  if (!childOfNeighborElem)
1238  EFAError("dynamic cast childOfNeighborElem fails");
1239 
1240  EFAEdge * neighborChildEdge = childOfNeighborElem->getEdge(neighbor_edge_id);
1241  if (!neighborChildEdge->hasIntersection()) // neighbor edge must NOT have
1242  // intersection either
1243  {
1244  // Check to see if the nodes are already merged. There's nothing else to do in that
1245  // case.
1246  unsigned int num_edge_nodes = 2;
1247  for (unsigned int i = 0; i < num_edge_nodes; ++i)
1248  {
1249  unsigned int childNodeIndex = i;
1250  unsigned int neighborChildNodeIndex = num_edge_nodes - 1 - childNodeIndex;
1251 
1252  EFANode * childNode = _edges[j]->getNode(childNodeIndex);
1253  EFANode * childOfNeighborNode = neighborChildEdge->getNode(neighborChildNodeIndex);
1254 
1255  if (childNode->parent() != NULL &&
1256  childNode->parent() ==
1257  childOfNeighborNode
1258  ->parent()) // non-material node and both come from same parent
1259  mergeNodes(childNode,
1260  childOfNeighborNode,
1261  childOfNeighborElem,
1262  PermanentNodes,
1263  TempNodes);
1264  } // i
1265  }
1266  } // loop over NeighborElem's children
1267  } // if (merge_phantom_edges)
1268  } // IF edge-j has_intersection()
1269  } // k, loop over neighbors on edge j
1270  } // j, loop over all edges
1271 
1272  // Now do a second loop through edges and convert remaining nodes to permanent nodes.
1273  // Important: temp nodes are not shared by any neighbor, so no need to switch nodes on neighbors
1274  for (unsigned int j = 0; j < _num_nodes; ++j)
1275  {
1276  EFANode * childNode = _nodes[j];
1277  if (childNode->category() == EFANode::N_CATEGORY_TEMP)
1278  {
1279  // if current child element does not have siblings, and if current temp node is a lone one
1280  // this temp node should be merged back to its parent permanent node. Otherwise we would have
1281  // permanent nodes that are not connected to any element
1282  std::set<EFAElement *> patch_elems = InverseConnectivityMap[childNode->parent()];
1283  if (parent2d->numFragments() == 1 && patch_elems.size() == 1)
1284  switchNode(childNode->parent(), childNode, false);
1285  else
1286  {
1287  unsigned int new_node_id = Efa::getNewID(PermanentNodes);
1288  EFANode * newNode =
1289  new EFANode(new_node_id, EFANode::N_CATEGORY_PERMANENT, childNode->parent());
1290  PermanentNodes.insert(std::make_pair(new_node_id, newNode));
1291  switchNode(newNode, childNode, false);
1292  }
1293  if (!Efa::deleteFromMap(TempNodes, childNode))
1294  EFAError(
1295  "Attempted to delete node: ", childNode->id(), " from TempNodes, but couldn't find it");
1296  }
1297  }
1298 }
unsigned int numEdgeNeighbors(unsigned int edge_id) const
unsigned int numChildren() const
Definition: EFAElement.C:197
unsigned int getNewID(std::map< unsigned int, T *> &theMap)
Definition: EFAFuncs.h:39
unsigned int _id
Definition: EFAElement.h:28
virtual unsigned int getNeighborIndex(const EFAElement *neighbor_elem) const
Definition: EFAElement2D.C:447
EFAEdge * getEdge(unsigned int edge_id) const
std::vector< EFAEdge * > _edges
Definition: EFAElement2D.h:32
bool hasIntersection() const
Definition: EFAEdge.C:198
bool deleteFromMap(std::map< unsigned int, T *> &theMap, T *elemToDelete, bool delete_elem=true)
Definition: EFAFuncs.h:23
virtual unsigned int numFragments() const
Definition: EFAElement2D.C:202
EFAElement * getChild(unsigned int child_id) const
Definition: EFAElement.C:182
virtual void switchNode(EFANode *new_node, EFANode *old_node, bool descend_to_parent)
Definition: EFAElement2D.C:262
std::vector< EFANode * > _nodes
Definition: EFAElement.h:30
EFAFragment2D * getFragment(unsigned int frag_id) const
unsigned int _num_nodes
Definition: EFAElement.h:29
EFAElement * _parent
Definition: EFAElement.h:32
EFANode * getInteriorNode() const
Definition: EFAEdge.h:45
void mergeNodes(EFANode *&childNode, EFANode *&childOfNeighborNode, EFAElement *childOfNeighborElem, std::map< unsigned int, EFANode *> &PermanentNodes, std::map< unsigned int, EFANode *> &TempNodes)
Definition: EFAElement.C:248
EFAElement2D * getEdgeNeighbor(unsigned int edge_id, unsigned int neighbor_id) const
unsigned int _num_edges
Definition: EFAElement2D.h:31
EFANode * parent() const
Definition: EFANode.C:48
EFANode * getNode(unsigned int index) const
Definition: EFAEdge.C:179
unsigned int id() const
Definition: EFANode.C:36
std::vector< EFAFragment2D * > _fragments
Definition: EFAElement2D.h:35
N_CATEGORY category() const
Definition: EFANode.C:42

◆ containsNode()

bool EFAElement::containsNode ( EFANode node) const
inherited

◆ createChild()

void EFAElement2D::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 
)
virtual

Implements EFAElement.

Definition at line 985 of file EFAElement2D.C.

991 {
992  if (_children.size() != 0)
993  EFAError("Element cannot have existing children in createChildElements");
994 
995  bool shouldDuplicateForCutNodeElement = false;
996  for (unsigned int j = 0; j < _num_nodes; ++j)
997  {
998  if (_nodes[j]->category() == EFANode::N_CATEGORY_EMBEDDED_PERMANENT)
999  shouldDuplicateForCutNodeElement = true;
1000  }
1001 
1002  if (_fragments.size() > 1 || shouldDuplicateForCrackTip(CrackTipElements) ||
1003  shouldDuplicateForCutNodeElement)
1004  {
1005  if (_fragments.size() > 3)
1006  EFAError("More than 3 fragments not yet supported");
1007 
1008  // set up the children
1009  ParentElements.push_back(this);
1010  for (unsigned int ichild = 0; ichild < _fragments.size(); ++ichild)
1011  {
1012  unsigned int new_elem_id;
1013  if (newChildElements.size() == 0)
1014  new_elem_id = Efa::getNewID(Elements);
1015  else
1016  new_elem_id = Efa::getNewID(newChildElements);
1017 
1018  EFAElement2D * childElem = new EFAElement2D(new_elem_id, this->numNodes());
1019  newChildElements.insert(std::make_pair(new_elem_id, childElem));
1020 
1021  ChildElements.push_back(childElem);
1022  childElem->setParent(this);
1023  _children.push_back(childElem);
1024 
1025  std::vector<EFAPoint> local_embedded_node_coor;
1026 
1027  for (unsigned int i = 0; i < this->getFragment(ichild)->numEdges(); ++i)
1028  {
1029  if (this->getFragment(ichild)->isEdgeInterior(i))
1030  {
1031  std::vector<EFANode *> master_nodes;
1032  std::vector<double> master_weights;
1033 
1034  for (unsigned int j = 0; j < 2; ++j)
1035  {
1036  this->getMasterInfo(
1037  this->getFragmentEdge(ichild, i)->getNode(j), master_nodes, master_weights);
1038  EFAPoint coor(0.0, 0.0, 0.0);
1039  for (unsigned int k = 0; k < master_nodes.size(); ++k)
1040  {
1041  EFANode * local = this->createLocalNodeFromGlobalNode(master_nodes[k]);
1042  coor += _local_node_coor[local->id()] * master_weights[k];
1043  delete local;
1044  }
1045  local_embedded_node_coor.push_back(coor);
1046  }
1047  }
1048  }
1049 
1050  EFAPoint normal(0.0, 0.0, 0.0);
1051  EFAPoint origin(0.0, 0.0, 0.0);
1052  EFAPoint normal2(0.0, 0.0, 0.0);
1053  EFAPoint origin2(0.0, 0.0, 0.0);
1054 
1055  if (local_embedded_node_coor.size())
1056  {
1057  EFAPoint cut_line = local_embedded_node_coor[1] - local_embedded_node_coor[0];
1058  normal = EFAPoint(cut_line(1), -cut_line(0), 0.0);
1059  Xfem::normalizePoint(normal);
1060  origin = (local_embedded_node_coor[0] + local_embedded_node_coor[1]) * 0.5;
1061  }
1062 
1063  if (local_embedded_node_coor.size() == 4)
1064  {
1065  EFAPoint cut_line = local_embedded_node_coor[3] - local_embedded_node_coor[2];
1066  normal2 = EFAPoint(cut_line(1), -cut_line(0), 0.0);
1067  Xfem::normalizePoint(normal2);
1068  origin2 = (local_embedded_node_coor[2] + local_embedded_node_coor[3]) * 0.5;
1069  }
1070 
1071  // get child element's nodes
1072  for (unsigned int j = 0; j < _num_nodes; ++j)
1073  {
1074  EFAPoint p(0.0, 0.0, 0.0);
1075  p = _local_node_coor[j];
1076 
1077  EFAPoint origin_to_point = p - origin;
1078  EFAPoint origin2_to_point = p - origin2;
1079 
1080  if (_fragments.size() == 1 &&
1081  _nodes[j]->category() == EFANode::N_CATEGORY_EMBEDDED_PERMANENT) // create temp node for
1082  // embedded permanent
1083  // node
1084  {
1085  unsigned int new_node_id = Efa::getNewID(TempNodes);
1086  EFANode * newNode = new EFANode(new_node_id, EFANode::N_CATEGORY_TEMP, _nodes[j]);
1087  TempNodes.insert(std::make_pair(new_node_id, newNode));
1088  childElem->setNode(j, newNode); // be a temp node
1089  }
1090  else if (_fragments.size() == 1 && !shouldDuplicateForCrackTip(CrackTipElements))
1091  {
1092  childElem->setNode(j, _nodes[j]); // inherit parent's node
1093  }
1094  else if (std::abs(origin_to_point * normal) < Xfem::tol &&
1095  _fragments.size() > 1) // cut through node case
1096  {
1097  unsigned int new_node_id = Efa::getNewID(TempNodes);
1098  EFANode * newNode = new EFANode(new_node_id, EFANode::N_CATEGORY_TEMP, _nodes[j]);
1099  TempNodes.insert(std::make_pair(new_node_id, newNode));
1100  childElem->setNode(j, newNode); // be a temp node
1101  }
1102  else if (origin_to_point * normal < Xfem::tol && origin2_to_point * normal2 < Xfem::tol &&
1103  (_fragments.size() > 1 || shouldDuplicateForCrackTip(CrackTipElements)))
1104  {
1105  childElem->setNode(j, _nodes[j]); // inherit parent's node
1106  }
1107  else if (normal.norm() < Xfem::tol && normal2.norm() < Xfem::tol &&
1108  _fragments.size() == 1) // cut along edge case
1109  {
1110  childElem->setNode(j, _nodes[j]); // inherit parent's node
1111  }
1112  else if ((_fragments.size() > 1 ||
1114  CrackTipElements))) // parent element's node is not in fragment
1115  {
1116  unsigned int new_node_id = Efa::getNewID(TempNodes);
1117  EFANode * newNode = new EFANode(new_node_id, EFANode::N_CATEGORY_TEMP, _nodes[j]);
1118  TempNodes.insert(std::make_pair(new_node_id, newNode));
1119  childElem->setNode(j, newNode); // be a temp node
1120  }
1121  }
1122 
1123  // get child element's fragments
1124  EFAFragment2D * new_frag = new EFAFragment2D(childElem, true, this, ichild);
1125  childElem->_fragments.push_back(new_frag);
1126 
1127  // get child element's edges
1128  for (unsigned int j = 0; j < _num_edges; ++j)
1129  {
1130  unsigned int jplus1(j < (_num_edges - 1) ? j + 1 : 0);
1131  EFAEdge * new_edge = new EFAEdge(childElem->getNode(j), childElem->getNode(jplus1));
1132  if (_edges[j]->hasIntersection())
1133  new_edge->copyIntersection(*_edges[j], 0);
1134  if ((_num_edges == 4 && _num_nodes > 4) || (_num_edges == 3 && _num_nodes > 3))
1135  new_edge->setInteriorNode(childElem->getNode(_num_edges + j));
1136  childElem->setEdge(j, new_edge);
1137  }
1138  childElem->removePhantomEmbeddedNode(); // IMPORTANT
1139 
1140  // inherit old interior nodes
1141  for (unsigned int j = 0; j < _interior_nodes.size(); ++j)
1142  childElem->_interior_nodes.push_back(new EFAFaceNode(*_interior_nodes[j]));
1143  }
1144  }
1145  else // num_links == 1 || num_links == 0
1146  // child is itself - but don't insert into the list of ChildElements!!!
1147  _children.push_back(this);
1148 }
unsigned int getNewID(std::map< unsigned int, T *> &theMap)
Definition: EFAFuncs.h:39
std::vector< EFAFaceNode * > _interior_nodes
Definition: EFAElement2D.h:33
unsigned int numEdges() const
virtual bool shouldDuplicateForCrackTip(const std::set< EFAElement *> &CrackTipElements)
Definition: EFAElement2D.C:615
void setEdge(unsigned int edge_id, EFAEdge *edge)
std::vector< EFAEdge * > _edges
Definition: EFAElement2D.h:32
bool isEdgeInterior(unsigned int edge_id) const
std::vector< EFANode * > _nodes
Definition: EFAElement.h:30
EFAFragment2D * getFragment(unsigned int frag_id) const
void setParent(EFAElement *parent)
Definition: EFAElement.C:191
unsigned int _num_nodes
Definition: EFAElement.h:29
virtual void removePhantomEmbeddedNode()
EFANode * getNode(unsigned int node_id) const
Definition: EFAElement.C:46
void setInteriorNode(EFANode *node)
Definition: EFAEdge.h:46
static const double tol
Definition: XFEMFuncs.h:21
void copyIntersection(const EFAEdge &other, unsigned int from_node_id)
Definition: EFAEdge.C:160
std::vector< EFAPoint > _local_node_coor
Definition: EFAElement2D.h:36
EFANode * createLocalNodeFromGlobalNode(const EFANode *global_node) const
Definition: EFAElement.C:70
virtual void getMasterInfo(EFANode *node, std::vector< EFANode *> &master_nodes, std::vector< double > &master_weights) const
Definition: EFAElement2D.C:300
void normalizePoint(Point &p)
Definition: XFEMFuncs.C:621
unsigned int _num_edges
Definition: EFAElement2D.h:31
unsigned int numNodes() const
Definition: EFAElement.C:34
std::vector< EFAElement * > _children
Definition: EFAElement.h:33
EFAElement2D(unsigned int eid, unsigned int n_nodes)
Definition: EFAElement2D.C:23
unsigned int id() const
Definition: EFANode.C:36
EFAEdge * getFragmentEdge(unsigned int frag_id, unsigned int edge_id) const
std::vector< EFAFragment2D * > _fragments
Definition: EFAElement2D.h:35
void setNode(unsigned int node_id, EFANode *node)
Definition: EFAElement.C:40

◆ createEdges()

void EFAElement2D::createEdges ( )

Definition at line 1459 of file EFAElement2D.C.

Referenced by ElementFragmentAlgorithm::add2DElement(), and ElementFragmentAlgorithm::add2DElements().

1460 {
1461  for (unsigned int i = 0; i < _num_edges; ++i)
1462  {
1463  unsigned int i_plus1(i < (_num_edges - 1) ? i + 1 : 0);
1464  EFAEdge * new_edge = new EFAEdge(_nodes[i], _nodes[i_plus1]);
1465 
1466  if ((_num_edges == 4 && _num_nodes > 4) || (_num_edges == 3 && _num_nodes > 3))
1467  new_edge->setInteriorNode(
1468  _nodes[i + _num_edges]); // '_num_edges' is the offset of interior edge node numbering
1469 
1470  _edges[i] = new_edge;
1471  }
1472 }
std::vector< EFAEdge * > _edges
Definition: EFAElement2D.h:32
std::vector< EFANode * > _nodes
Definition: EFAElement.h:30
unsigned int _num_nodes
Definition: EFAElement.h:29
void setInteriorNode(EFANode *node)
Definition: EFAEdge.h:46
unsigned int _num_edges
Definition: EFAElement2D.h:31

◆ createLocalNodeFromGlobalNode()

EFANode * EFAElement::createLocalNodeFromGlobalNode ( const EFANode global_node) const
inherited

Definition at line 70 of file EFAElement.C.

Referenced by createChild(), EFAElement3D::createChild(), EFAElement2D(), and EFAElement3D::EFAElement3D().

71 {
72  // Given a global node, create a new local node
73  if (global_node->category() != EFANode::N_CATEGORY_PERMANENT &&
74  global_node->category() != EFANode::N_CATEGORY_TEMP &&
76  EFAError("In createLocalNodeFromGlobalNode node is not global");
77 
78  EFANode * new_local_node = NULL;
79  unsigned int inode = 0;
80  for (; inode < _nodes.size(); ++inode)
81  {
82  if (_nodes[inode] == global_node)
83  {
84  new_local_node = new EFANode(inode, EFANode::N_CATEGORY_LOCAL_INDEX);
85  break;
86  }
87  }
88  if (!new_local_node)
89  EFAError("In createLocalNodeFromGlobalNode could not find global node");
90 
91  return new_local_node;
92 }
std::vector< EFANode * > _nodes
Definition: EFAElement.h:30
N_CATEGORY category() const
Definition: EFANode.C:42

◆ deleteInteriorNodes()

void EFAElement2D::deleteInteriorNodes ( )

Definition at line 1439 of file EFAElement2D.C.

Referenced by EFAFragment2D::removeInvalidEmbeddedNodes().

1440 {
1441  for (unsigned int i = 0; i < _interior_nodes.size(); ++i)
1442  delete _interior_nodes[i];
1443  _interior_nodes.clear();
1444 }
std::vector< EFAFaceNode * > _interior_nodes
Definition: EFAElement2D.h:33

◆ edgeContainsTip()

bool EFAElement2D::edgeContainsTip ( unsigned int  edge_id) const

Definition at line 1669 of file EFAElement2D.C.

Referenced by fragmentEdgeAlreadyCut().

1670 {
1671  bool contains_tip = false;
1672  if (_fragments.size() == 1)
1673  {
1674  unsigned int num_frag_edges = 0; // count how many fragment edges this element edge contains
1675  if (_edges[edge_id]->hasIntersection())
1676  {
1677  for (unsigned int j = 0; j < _fragments[0]->numEdges(); ++j)
1678  {
1679  if (_edges[edge_id]->containsEdge(*_fragments[0]->getEdge(j)))
1680  num_frag_edges += 1;
1681  } // j
1682  if (num_frag_edges == 2)
1683  contains_tip = true;
1684  }
1685  }
1686  return contains_tip;
1687 }
EFAEdge * getEdge(unsigned int edge_id) const
std::vector< EFAEdge * > _edges
Definition: EFAElement2D.h:32
std::vector< EFAFragment2D * > _fragments
Definition: EFAElement2D.h:35

◆ findGeneralNeighbors()

void EFAElement::findGeneralNeighbors ( std::map< EFANode *, std::set< EFAElement *>> &  InverseConnectivity)
inherited

Definition at line 216 of file EFAElement.C.

Referenced by setupNeighbors(), and EFAElement3D::setupNeighbors().

217 {
218  _general_neighbors.clear();
219  std::set<EFAElement *> patch_elements;
220  for (unsigned int inode = 0; inode < _num_nodes; ++inode)
221  {
222  std::set<EFAElement *> this_node_connected_elems = InverseConnectivity[_nodes[inode]];
223  patch_elements.insert(this_node_connected_elems.begin(), this_node_connected_elems.end());
224  }
225 
226  std::set<EFAElement *>::iterator eit2;
227  for (eit2 = patch_elements.begin(); eit2 != patch_elements.end(); ++eit2)
228  {
229  EFAElement * neigh_elem = *eit2;
230  if (neigh_elem != this)
231  _general_neighbors.push_back(neigh_elem);
232  }
233 }
std::vector< EFANode * > _nodes
Definition: EFAElement.h:30
unsigned int _num_nodes
Definition: EFAElement.h:29
std::vector< EFAElement * > _general_neighbors
Definition: EFAElement.h:37

◆ fragmentEdgeAlreadyCut()

bool EFAElement2D::fragmentEdgeAlreadyCut ( unsigned int  ElemEdgeID) const

Definition at line 1690 of file EFAElement2D.C.

Referenced by addEdgeCut().

1691 {
1692  // when marking cuts, check if the corresponding frag edge already has been cut
1693  bool has_cut = false;
1694  if (edgeContainsTip(ElemEdgeID))
1695  has_cut = true;
1696  else
1697  {
1698  unsigned int FragEdgeID = 99999;
1699  if (getFragmentEdgeID(ElemEdgeID, FragEdgeID))
1700  {
1701  EFAEdge * frag_edge = getFragmentEdge(0, FragEdgeID);
1702  if (frag_edge->hasIntersection())
1703  has_cut = true;
1704  }
1705  }
1706  return has_cut;
1707 }
bool edgeContainsTip(unsigned int edge_id) const
bool hasIntersection() const
Definition: EFAEdge.C:198
bool getFragmentEdgeID(unsigned int elem_edge_id, unsigned int &frag_edge_id) const
EFAEdge * getFragmentEdge(unsigned int frag_id, unsigned int edge_id) const

◆ fragmentHasTipEdges()

bool EFAElement2D::fragmentHasTipEdges ( ) const

Definition at line 1581 of file EFAElement2D.C.

Referenced by isCrackTipElement().

1582 {
1583  bool has_tip_edges = false;
1584  if (_fragments.size() == 1)
1585  {
1586  for (unsigned int i = 0; i < _num_edges; ++i)
1587  {
1588  unsigned int num_frag_edges = 0; // count how many fragment edges this element edge contains
1589  if (_edges[i]->hasIntersection())
1590  {
1591  for (unsigned int j = 0; j < _fragments[0]->numEdges(); ++j)
1592  {
1593  if (_edges[i]->containsEdge(*_fragments[0]->getEdge(j)))
1594  num_frag_edges += 1;
1595  } // j
1596  if (num_frag_edges == 2)
1597  {
1598  has_tip_edges = true;
1599  break;
1600  }
1601  }
1602  } // i
1603  }
1604  return has_tip_edges;
1605 }
EFAEdge * getEdge(unsigned int edge_id) const
std::vector< EFAEdge * > _edges
Definition: EFAElement2D.h:32
unsigned int _num_edges
Definition: EFAElement2D.h:31
std::vector< EFAFragment2D * > _fragments
Definition: EFAElement2D.h:35

◆ fragmentSanityCheck()

void EFAElement2D::fragmentSanityCheck ( unsigned int  n_old_frag_edges,
unsigned int  n_old_frag_cuts 
) const
virtual

Implements EFAElement.

Definition at line 871 of file EFAElement2D.C.

Referenced by updateFragments().

872 {
873  if (n_old_frag_cuts > 3)
874  EFAError("Sanity check: in element ", _id, " frag has more than 3 cut edges");
875 
876  // count permanent and embedded nodes for new fragments
877  std::vector<unsigned int> num_emb;
878  std::vector<unsigned int> num_perm;
879  std::vector<unsigned int> num_emb_perm;
880  for (unsigned int i = 0; i < _fragments.size(); ++i)
881  {
882  num_emb.push_back(0);
883  num_perm.push_back(0);
884  num_emb_perm.push_back(0);
885  std::set<EFANode *> perm_nodes;
886  std::set<EFANode *> emb_nodes;
887  std::set<EFANode *> emb_perm_nodes;
888  for (unsigned int j = 0; j < _fragments[i]->numEdges(); ++j)
889  {
890  for (unsigned int k = 0; k < 2; ++k)
891  {
892  EFANode * temp_node = _fragments[i]->getEdge(j)->getNode(k);
893  if (temp_node->category() == EFANode::N_CATEGORY_PERMANENT)
894  perm_nodes.insert(temp_node);
895  else if (temp_node->category() == EFANode::N_CATEGORY_EMBEDDED)
896  emb_nodes.insert(temp_node);
897  else if (temp_node->category() == EFANode::N_CATEGORY_EMBEDDED_PERMANENT)
898  emb_perm_nodes.insert(temp_node);
899  else
900  EFAError("Invalid node category");
901  }
902  }
903  num_perm[i] = perm_nodes.size();
904  num_emb[i] = emb_nodes.size();
905  num_emb_perm[i] = emb_perm_nodes.size();
906  }
907 
908  // TODO: For cut-node case, how to check fragment sanity
909  for (unsigned int i = 0; i < _fragments.size(); ++i)
910  if (num_emb_perm[i] != 0)
911  return;
912 
913  unsigned int n_interior_nodes = numInteriorNodes();
914  if (n_interior_nodes > 0 && n_interior_nodes != 1)
915  EFAError("After update_fragments this element has ", n_interior_nodes, " interior nodes");
916 
917  if (n_old_frag_cuts == 0)
918  {
919  if (_fragments.size() != 1 || _fragments[0]->numEdges() != n_old_frag_edges)
920  EFAError("Incorrect link size for element with 0 cuts");
921  }
922  else if (n_old_frag_cuts == 1) // crack tip case
923  {
924  if (_fragments.size() != 1 || _fragments[0]->numEdges() != n_old_frag_edges + 1)
925  EFAError("Incorrect link size for element with 1 cut");
926  }
927  else if (n_old_frag_cuts == 2)
928  {
929  if (_fragments.size() != 2 ||
930  (_fragments[0]->numEdges() + _fragments[1]->numEdges()) != n_old_frag_edges + 4)
931  EFAError("Incorrect link size for element with 2 cuts");
932  }
933  else if (n_old_frag_cuts == 3)
934  {
935  if (_fragments.size() != 3 || (_fragments[0]->numEdges() + _fragments[1]->numEdges() +
936  _fragments[2]->numEdges()) != n_old_frag_edges + 9)
937  EFAError("Incorrect link size for element with 3 cuts");
938  }
939  else
940  EFAError("Unexpected number of old fragment cuts");
941 }
unsigned int _id
Definition: EFAElement.h:28
virtual unsigned int numInteriorNodes() const
Definition: EFAElement2D.C:353
std::vector< EFAFragment2D * > _fragments
Definition: EFAElement2D.h:35
N_CATEGORY category() const
Definition: EFANode.C:42

◆ getChild()

EFAElement * EFAElement::getChild ( unsigned int  child_id) const
inherited

Definition at line 182 of file EFAElement.C.

Referenced by connectNeighbors(), EFAElement3D::connectNeighbors(), switchNode(), and EFAElement3D::switchNode().

183 {
184  if (child_id < _children.size())
185  return _children[child_id];
186  else
187  EFAError("child_id out of bounds");
188 }
std::vector< EFAElement * > _children
Definition: EFAElement.h:33

◆ getCommonNodes()

std::vector< EFANode * > EFAElement2D::getCommonNodes ( const EFAElement2D other_elem) const

Definition at line 2061 of file EFAElement2D.C.

Referenced by overlaysElement(), and setupNeighbors().

2062 {
2063  std::set<EFANode *> e1nodes(_nodes.begin(),
2064  _nodes.begin() + _num_edges); // only account for corner nodes
2065  std::set<EFANode *> e2nodes(other_elem->_nodes.begin(), other_elem->_nodes.begin() + _num_edges);
2066  std::vector<EFANode *> common_nodes = Efa::getCommonElems(e1nodes, e2nodes);
2067  return common_nodes;
2068 }
std::vector< EFANode * > _nodes
Definition: EFAElement.h:30
std::vector< T > getCommonElems(std::set< T > &v1, std::set< T > &v2)
Definition: EFAFuncs.h:70
unsigned int _num_edges
Definition: EFAElement2D.h:31

◆ getCrackTipNeighbor()

unsigned int EFAElement::getCrackTipNeighbor ( unsigned int  index) const
inherited

Definition at line 148 of file EFAElement.C.

149 {
150  if (index < _crack_tip_neighbors.size())
151  return _crack_tip_neighbors[index];
152  else
153  EFAError("in getCrackTipNeighbor index out of bounds");
154 }
std::vector< unsigned int > _crack_tip_neighbors
Definition: EFAElement.h:35

◆ getCrackTipSplitElementID()

unsigned int EFAElement2D::getCrackTipSplitElementID ( ) const

Definition at line 594 of file EFAElement2D.C.

Referenced by XFEM::storeCrackTipOriginAndDirection().

595 {
596  if (isCrackTipElement())
597  {
598  for (unsigned int edge_iter = 0; edge_iter < _num_edges; ++edge_iter)
599  {
600  if ((_edge_neighbors[edge_iter].size() == 2) && (_edges[edge_iter]->hasIntersection()))
601  {
602  if (_edge_neighbors[edge_iter][0] != NULL &&
603  _edge_neighbors[edge_iter][0]->isCrackTipSplit())
604  {
605  return _edge_neighbors[edge_iter][0]->id();
606  }
607  }
608  }
609  }
610  EFAError("In getCrackTipSplitElementID could not find element id");
611  return 0;
612 }
bool isCrackTipSplit() const
Definition: EFAElement.C:136
std::vector< std::vector< EFAElement2D * > > _edge_neighbors
Definition: EFAElement2D.h:34
virtual bool isCrackTipElement() const
Definition: EFAElement2D.C:775
std::vector< EFAEdge * > _edges
Definition: EFAElement2D.h:32
unsigned int _num_edges
Definition: EFAElement2D.h:31

◆ getEdge()

EFAEdge * EFAElement2D::getEdge ( unsigned int  edge_id) const

◆ getEdgeNeighbor()

EFAElement2D * EFAElement2D::getEdgeNeighbor ( unsigned int  edge_id,
unsigned int  neighbor_id 
) const

Definition at line 1572 of file EFAElement2D.C.

Referenced by addEdgeCut(), connectNeighbors(), neighborSanityCheck(), and printElement().

1573 {
1574  if (_edge_neighbors[edge_id][0] != NULL && neighbor_id < _edge_neighbors[edge_id].size())
1575  return _edge_neighbors[edge_id][neighbor_id];
1576  else
1577  EFAError("edge neighbor does not exist");
1578 }
std::vector< std::vector< EFAElement2D * > > _edge_neighbors
Definition: EFAElement2D.h:34

◆ getEdgeNodeParametricCoordinate()

bool EFAElement2D::getEdgeNodeParametricCoordinate ( EFANode node,
std::vector< double > &  para_coor 
) const

Definition at line 1406 of file EFAElement2D.C.

Referenced by addFragmentEdgeCut(), and branchingSplit().

1407 {
1408  // get the parametric coords of a node in an element edge
1409  unsigned int edge_id = 99999;
1410  bool edge_found = false;
1411  for (unsigned int i = 0; i < _num_edges; ++i)
1412  {
1413  if (_edges[i]->containsNode(node))
1414  {
1415  edge_id = i;
1416  edge_found = true;
1417  break;
1418  }
1419  }
1420  if (edge_found)
1421  {
1422  double rel_dist = _edges[edge_id]->distanceFromNode1(node);
1423  double xi_1d = 2.0 * rel_dist - 1.0; // translate to [-1,1] parent coord syst
1424  mapParametricCoordFrom1Dto2D(edge_id, xi_1d, para_coor);
1425  }
1426  return edge_found;
1427 }
void mapParametricCoordFrom1Dto2D(unsigned int edge_id, double xi_1d, std::vector< double > &para_coor) const
std::vector< EFAEdge * > _edges
Definition: EFAElement2D.h:32
bool containsNode(EFANode *node) const
Definition: EFAElement.C:52
unsigned int _num_edges
Definition: EFAElement2D.h:31

◆ getEdgeNodes()

std::set< EFANode * > EFAElement2D::getEdgeNodes ( unsigned int  edge_id) const

Definition at line 1397 of file EFAElement2D.C.

Referenced by setupNeighbors(), and shouldDuplicateCrackTipSplitElement().

1398 {
1399  std::set<EFANode *> edge_nodes;
1400  edge_nodes.insert(_edges[edge_id]->getNode(0));
1401  edge_nodes.insert(_edges[edge_id]->getNode(1));
1402  return edge_nodes;
1403 }
std::vector< EFAEdge * > _edges
Definition: EFAElement2D.h:32
EFANode * getNode(unsigned int node_id) const
Definition: EFAElement.C:46

◆ getFragment()

EFAFragment2D * EFAElement2D::getFragment ( unsigned int  frag_id) const

◆ getFragmentEdge()

EFAEdge * EFAElement2D::getFragmentEdge ( unsigned int  frag_id,
unsigned int  edge_id 
) const

◆ getFragmentEdgeID()

bool EFAElement2D::getFragmentEdgeID ( unsigned int  elem_edge_id,
unsigned int &  frag_edge_id 
) const

Definition at line 1514 of file EFAElement2D.C.

Referenced by addEdgeCut(), and fragmentEdgeAlreadyCut().

1515 {
1516  // find the fragment edge that is contained by given element edge
1517  // N.B. if the elem edge contains two frag edges, this method will only return
1518  // the first frag edge ID
1519  bool frag_edge_found = false;
1520  frag_edge_id = 99999;
1521  if (_fragments.size() == 1)
1522  {
1523  for (unsigned int j = 0; j < _fragments[0]->numEdges(); ++j)
1524  {
1525  if (_edges[elem_edge_id]->containsEdge(*_fragments[0]->getEdge(j)))
1526  {
1527  frag_edge_id = j;
1528  frag_edge_found = true;
1529  break;
1530  }
1531  }
1532  }
1533  return frag_edge_found;
1534 }
EFAEdge * getEdge(unsigned int edge_id) const
std::vector< EFAEdge * > _edges
Definition: EFAElement2D.h:32
std::vector< EFAFragment2D * > _fragments
Definition: EFAElement2D.h:35

◆ getGeneralNeighbor()

EFAElement * EFAElement::getGeneralNeighbor ( unsigned int  index) const
inherited

Definition at line 236 of file EFAElement.C.

Referenced by switchNode(), and EFAElement3D::switchNode().

237 {
238  return _general_neighbors[index];
239 }
std::vector< EFAElement * > _general_neighbors
Definition: EFAElement.h:37

◆ getGlobalNodeFromLocalNode()

EFANode * EFAElement::getGlobalNodeFromLocalNode ( const EFANode local_node) const
inherited

Definition at line 95 of file EFAElement.C.

96 {
97  // Given a local node, find the global node corresponding to that node
98  if (local_node->category() != EFANode::N_CATEGORY_LOCAL_INDEX)
99  EFAError("In getGlobalNodeFromLocalNode node passed in is not local");
100 
101  EFANode * global_node = _nodes[local_node->id()];
102 
103  if (global_node->category() != EFANode::N_CATEGORY_PERMANENT &&
104  global_node->category() != EFANode::N_CATEGORY_TEMP)
105  EFAError("In getGlobalNodeFromLocalNode, the node stored by the element is not global");
106 
107  return global_node;
108 }
std::vector< EFANode * > _nodes
Definition: EFAElement.h:30
unsigned int id() const
Definition: EFANode.C:36
N_CATEGORY category() const
Definition: EFANode.C:42

◆ getInteriorNode()

EFAFaceNode * EFAElement2D::getInteriorNode ( unsigned int  interior_node_id) const

Definition at line 1430 of file EFAElement2D.C.

Referenced by EFAFragment2D::isSecondaryInteriorEdge().

1431 {
1432  if (interior_node_id < _interior_nodes.size())
1433  return _interior_nodes[interior_node_id];
1434  else
1435  EFAError("interior_node_id out of bounds");
1436 }
std::vector< EFAFaceNode * > _interior_nodes
Definition: EFAElement2D.h:33

◆ getLocalNodeIndex()

unsigned int EFAElement::getLocalNodeIndex ( EFANode node) const
inherited

Definition at line 111 of file EFAElement.C.

Referenced by XFEM::getEFANodeCoords().

112 {
113  unsigned int local_node_id = 99999;
114  bool found_local_node = false;
115  for (unsigned int i = 0; i < _num_nodes; ++i)
116  {
117  if (_nodes[i] == node)
118  {
119  found_local_node = true;
120  local_node_id = i;
121  break;
122  }
123  }
124  if (!found_local_node)
125  EFAError("In EFAelement::getLocalNodeIndex, cannot find the given node");
126  return local_node_id;
127 }
std::vector< EFANode * > _nodes
Definition: EFAElement.h:30
unsigned int _num_nodes
Definition: EFAElement.h:29

◆ getMasterInfo()

void EFAElement2D::getMasterInfo ( EFANode node,
std::vector< EFANode *> &  master_nodes,
std::vector< double > &  master_weights 
) const
virtual

Implements EFAElement.

Definition at line 300 of file EFAElement2D.C.

Referenced by createChild(), and XFEMCutElem2D::getNodeCoordinates().

303 {
304  // Given a EFANode, find the element edge or fragment edge that contains it
305  // Return its master nodes and weights
306  master_nodes.clear();
307  master_weights.clear();
308  bool masters_found = false;
309  for (unsigned int i = 0; i < _num_edges; ++i) // check element exterior edges
310  {
311  if (_edges[i]->containsNode(node))
312  {
313  masters_found = _edges[i]->getNodeMasters(node, master_nodes, master_weights);
314  if (masters_found)
315  break;
316  else
317  EFAError("In getMasterInfo: cannot find master nodes in element edges");
318  }
319  }
320 
321  if (!masters_found) // check element interior embedded nodes
322  {
323  for (unsigned int i = 0; i < _interior_nodes.size(); ++i)
324  {
325  if (_interior_nodes[i]->getNode() == node)
326  {
327  std::vector<double> emb_xi(2, 0.0);
328  emb_xi[0] = _interior_nodes[i]->getParametricCoordinates(0);
329  emb_xi[1] = _interior_nodes[i]->getParametricCoordinates(1);
330  for (unsigned int j = 0; j < _num_edges; ++j)
331  {
332  master_nodes.push_back(_nodes[j]);
333  double weight = 0.0;
334  if (_num_edges == 4)
335  weight = Efa::linearQuadShape2D(j, emb_xi);
336  else if (_num_edges == 3)
337  weight = Efa::linearTriShape2D(j, emb_xi);
338  else
339  EFAError("unknown 2D element");
340  master_weights.push_back(weight);
341  }
342  masters_found = true;
343  break;
344  }
345  }
346  }
347 
348  if (!masters_found)
349  EFAError("In EFAelement2D::getMaterInfo, cannot find the given EFAnode");
350 }
std::vector< EFAFaceNode * > _interior_nodes
Definition: EFAElement2D.h:33
std::vector< EFAEdge * > _edges
Definition: EFAElement2D.h:32
bool containsNode(EFANode *node) const
Definition: EFAElement.C:52
std::vector< EFANode * > _nodes
Definition: EFAElement.h:30
EFANode * getNode(unsigned int node_id) const
Definition: EFAElement.C:46
double linearQuadShape2D(unsigned int node_id, std::vector< double > &xi_2d)
Definition: EFAFuncs.C:16
unsigned int _num_edges
Definition: EFAElement2D.h:31
double linearTriShape2D(unsigned int node_id, std::vector< double > &xi_2d)
Definition: EFAFuncs.C:23

◆ getNeighborIndex()

unsigned int EFAElement2D::getNeighborIndex ( const EFAElement neighbor_elem) const
virtual

Implements EFAElement.

Definition at line 447 of file EFAElement2D.C.

Referenced by addEdgeCut(), and connectNeighbors().

448 {
449  for (unsigned int i = 0; i < _num_edges; ++i)
450  for (unsigned int j = 0; j < _edge_neighbors[i].size(); ++j)
451  if (_edge_neighbors[i][j] == neighbor_elem)
452  return i;
453 
454  EFAError(
455  "in get_neighbor_index() element: ", _id, " does not have neighbor: ", neighbor_elem->id());
456 }
unsigned int id() const
Definition: EFAElement.C:28
unsigned int _id
Definition: EFAElement.h:28
std::vector< std::vector< EFAElement2D * > > _edge_neighbors
Definition: EFAElement2D.h:34
unsigned int _num_edges
Definition: EFAElement2D.h:31

◆ getNode()

EFANode * EFAElement::getNode ( unsigned int  node_id) const
inherited

◆ getNonPhysicalNodes()

void EFAElement2D::getNonPhysicalNodes ( std::set< EFANode *> &  non_physical_nodes) const
virtual

Implements EFAElement.

Definition at line 235 of file EFAElement2D.C.

Referenced by shouldDuplicateCrackTipSplitElement().

236 {
237  // Any nodes that don't belong to any fragment are non-physical
238  // First add all nodes in the element to the set
239  for (unsigned int i = 0; i < _nodes.size(); ++i)
240  non_physical_nodes.insert(_nodes[i]);
241 
242  // Now delete any nodes that are contained in fragments
243  std::set<EFANode *>::iterator sit;
244  for (sit = non_physical_nodes.begin(); sit != non_physical_nodes.end();)
245  {
246  bool erased = false;
247  for (unsigned int i = 0; i < _fragments.size(); ++i)
248  {
249  if (_fragments[i]->containsNode(*sit))
250  {
251  non_physical_nodes.erase(sit++);
252  erased = true;
253  break;
254  }
255  }
256  if (!erased)
257  ++sit;
258  }
259 }
bool containsNode(EFANode *node) const
Definition: EFAElement.C:52
std::vector< EFANode * > _nodes
Definition: EFAElement.h:30
std::vector< EFAFragment2D * > _fragments
Definition: EFAElement2D.h:35

◆ getNumCuts()

unsigned int EFAElement2D::getNumCuts ( ) const
virtual

Implements EFAElement.

Definition at line 781 of file EFAElement2D.C.

Referenced by restoreFragment().

782 {
783  unsigned int num_cuts = 0;
784  for (unsigned int i = 0; i < _num_edges; ++i)
785  if (_edges[i]->hasIntersection())
786  num_cuts += _edges[i]->numEmbeddedNodes();
787  return num_cuts;
788 }
std::vector< EFAEdge * > _edges
Definition: EFAElement2D.h:32
unsigned int _num_edges
Definition: EFAElement2D.h:31

◆ getParent()

EFAElement * EFAElement::getParent ( ) const
inherited

Definition at line 176 of file EFAElement.C.

177 {
178  return _parent;
179 }
EFAElement * _parent
Definition: EFAElement.h:32

◆ getPhantomNodeOnEdge()

std::set< EFANode * > EFAElement2D::getPhantomNodeOnEdge ( unsigned int  edge_id) const

Definition at line 1490 of file EFAElement2D.C.

Referenced by shouldDuplicateForPhantomCorner().

1491 {
1492  std::set<EFANode *> phantom_nodes;
1493  if (_fragments.size() > 0)
1494  {
1495  for (unsigned int j = 0; j < 2; ++j) // loop ove 2 edge nodes
1496  {
1497  bool node_in_frag = false;
1498  for (unsigned int k = 0; k < _fragments.size(); ++k)
1499  {
1500  if (_fragments[k]->containsNode(_edges[edge_id]->getNode(j)))
1501  {
1502  node_in_frag = true;
1503  break;
1504  }
1505  }
1506  if (!node_in_frag)
1507  phantom_nodes.insert(_edges[edge_id]->getNode(j));
1508  }
1509  }
1510  return phantom_nodes;
1511 }
std::vector< EFAEdge * > _edges
Definition: EFAElement2D.h:32
bool containsNode(EFANode *node) const
Definition: EFAElement.C:52
EFANode * getNode(unsigned int node_id) const
Definition: EFAElement.C:46
std::vector< EFAFragment2D * > _fragments
Definition: EFAElement2D.h:35

◆ getTipEdgeID()

unsigned int EFAElement2D::getTipEdgeID ( ) const

Definition at line 1608 of file EFAElement2D.C.

Referenced by XFEM::markCutEdgesByState().

1609 {
1610  // if this element is a crack tip element, returns the crack tip edge's ID
1611  unsigned int tip_edge_id = 99999;
1612  if (_fragments.size() == 1) // crack tip element with a partial fragment saved
1613  {
1614  for (unsigned int i = 0; i < _num_edges; ++i)
1615  {
1616  unsigned int num_frag_edges = 0; // count how many fragment edges this element edge contains
1617  if (_edges[i]->hasIntersection())
1618  {
1619  for (unsigned int j = 0; j < _fragments[0]->numEdges(); ++j)
1620  {
1621  if (_edges[i]->containsEdge(*_fragments[0]->getEdge(j)))
1622  num_frag_edges += 1;
1623  }
1624  if (num_frag_edges == 2) // element edge contains two fragment edges
1625  {
1626  tip_edge_id = i;
1627  break;
1628  }
1629  }
1630  }
1631  }
1632  return tip_edge_id;
1633 }
EFAEdge * getEdge(unsigned int edge_id) const
std::vector< EFAEdge * > _edges
Definition: EFAElement2D.h:32
unsigned int _num_edges
Definition: EFAElement2D.h:31
std::vector< EFAFragment2D * > _fragments
Definition: EFAElement2D.h:35

◆ getTipEmbeddedNode()

EFANode * EFAElement2D::getTipEmbeddedNode ( ) const

Definition at line 1636 of file EFAElement2D.C.

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

1637 {
1638  // if this element is a crack tip element, returns the crack tip edge's ID
1639  EFANode * tip_emb = NULL;
1640  if (_fragments.size() == 1) // crack tip element with a partial fragment saved
1641  {
1642  for (unsigned int i = 0; i < _num_edges; ++i)
1643  {
1644  std::vector<EFAEdge *> frag_edges; // count how many fragment edges this element edge contains
1645  if (_edges[i]->hasIntersection())
1646  {
1647  for (unsigned int j = 0; j < _fragments[0]->numEdges(); ++j)
1648  {
1649  if (_edges[i]->containsEdge(*_fragments[0]->getEdge(j)))
1650  frag_edges.push_back(_fragments[0]->getEdge(j));
1651  } // j
1652  if (frag_edges.size() == 2) // element edge contains two fragment edges
1653  {
1654  if (frag_edges[1]->containsNode(frag_edges[0]->getNode(1)))
1655  tip_emb = frag_edges[0]->getNode(1);
1656  else if (frag_edges[1]->containsNode(frag_edges[0]->getNode(0)))
1657  tip_emb = frag_edges[0]->getNode(0);
1658  else
1659  EFAError("Common node can't be found between 2 tip frag edges");
1660  break;
1661  }
1662  }
1663  }
1664  }
1665  return tip_emb;
1666 }
EFAEdge * getEdge(unsigned int edge_id) const
std::vector< EFAEdge * > _edges
Definition: EFAElement2D.h:32
bool containsNode(EFANode *node) const
Definition: EFAElement.C:52
EFANode * getNode(unsigned int node_id) const
Definition: EFAElement.C:46
unsigned int _num_edges
Definition: EFAElement2D.h:31
std::vector< EFAFragment2D * > _fragments
Definition: EFAElement2D.h:35

◆ id()

unsigned int EFAElement::id ( ) const
inherited

◆ initCrackTip()

void EFAElement2D::initCrackTip ( std::set< EFAElement *> &  CrackTipElements)
virtual

Implements EFAElement.

Definition at line 556 of file EFAElement2D.C.

557 {
558  if (isCrackTipElement())
559  {
560  CrackTipElements.insert(this);
561  for (unsigned int edge_iter = 0; edge_iter < _num_edges; ++edge_iter)
562  {
563  if ((_edge_neighbors[edge_iter].size() == 2) && (_edges[edge_iter]->hasIntersection()))
564  {
565  // Neither neighbor overlays current element. We are on the uncut element ahead of the tip.
566  // Flag neighbors as crack tip split elements and add this element as their crack tip
567  // neighbor.
568  if (_edge_neighbors[edge_iter][0]->overlaysElement(this) ||
569  _edge_neighbors[edge_iter][1]->overlaysElement(this))
570  EFAError("Element has a neighbor that overlays itself");
571 
572  // Make sure the current elment hasn't been flagged as a tip element
574  EFAError("crack_tip_split_element already flagged. In elem: ",
575  _id,
576  " flags: ",
578  " ",
579  _edge_neighbors[edge_iter][0]->isCrackTipSplit(),
580  " ",
581  _edge_neighbors[edge_iter][1]->isCrackTipSplit());
582 
583  _edge_neighbors[edge_iter][0]->setCrackTipSplit();
584  _edge_neighbors[edge_iter][1]->setCrackTipSplit();
585 
586  _edge_neighbors[edge_iter][0]->addCrackTipNeighbor(this);
587  _edge_neighbors[edge_iter][1]->addCrackTipNeighbor(this);
588  }
589  } // edge_iter
590  }
591 }
bool isCrackTipSplit() const
Definition: EFAElement.C:136
unsigned int _id
Definition: EFAElement.h:28
std::vector< std::vector< EFAElement2D * > > _edge_neighbors
Definition: EFAElement2D.h:34
virtual bool isCrackTipElement() const
Definition: EFAElement2D.C:775
std::vector< EFAEdge * > _edges
Definition: EFAElement2D.h:32
bool overlaysElement(const EFAElement2D *other_elem) const
Definition: EFAElement2D.C:359
unsigned int _num_edges
Definition: EFAElement2D.h:31
bool _crack_tip_split_element
Definition: EFAElement.h:34

◆ isCrackTipElement()

bool EFAElement2D::isCrackTipElement ( ) const
virtual

Implements EFAElement.

Definition at line 775 of file EFAElement2D.C.

Referenced by getCrackTipSplitElementID(), initCrackTip(), and shouldDuplicateForCrackTip().

776 {
777  return fragmentHasTipEdges();
778 }
bool fragmentHasTipEdges() const

◆ isCrackTipSplit()

bool EFAElement::isCrackTipSplit ( ) const
inherited

Definition at line 136 of file EFAElement.C.

Referenced by getCrackTipSplitElementID(), initCrackTip(), and EFAElement3D::initCrackTip().

137 {
139 }
bool _crack_tip_split_element
Definition: EFAElement.h:34

◆ isEdgePhantom()

bool EFAElement2D::isEdgePhantom ( unsigned int  edge_id) const

Definition at line 1537 of file EFAElement2D.C.

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

1538 {
1539  bool is_phantom = false;
1540  if (_fragments.size() > 0)
1541  {
1542  bool contain_frag_edge = false;
1543  for (unsigned int i = 0; i < _fragments.size(); ++i)
1544  {
1545  for (unsigned int j = 0; j < _fragments[i]->numEdges(); ++j)
1546  {
1547  if (_edges[edge_id]->containsEdge(*_fragments[i]->getEdge(j)))
1548  {
1549  contain_frag_edge = true;
1550  break;
1551  }
1552  } // j
1553  if (contain_frag_edge)
1554  break;
1555  } // i
1556  if (!contain_frag_edge)
1557  is_phantom = true;
1558  }
1559  return is_phantom;
1560 }
EFAEdge * getEdge(unsigned int edge_id) const
std::vector< EFAEdge * > _edges
Definition: EFAElement2D.h:32
std::vector< EFAFragment2D * > _fragments
Definition: EFAElement2D.h:35

◆ isFinalCut()

bool EFAElement2D::isFinalCut ( ) const
virtual

Implements EFAElement.

Definition at line 791 of file EFAElement2D.C.

Referenced by GeometricCutUserObject::execute(), and XFEM::markCutEdgesByState().

792 {
793  // if an element has been cut twice its fragment must have two interior edges
794  bool cut_twice = false;
795  if (_fragments.size() > 0)
796  {
797  unsigned int num_interior_edges = 0;
798  for (unsigned int i = 0; i < _fragments[0]->numEdges(); ++i)
799  {
800  if (_fragments[0]->isEdgeInterior(i))
801  num_interior_edges += 1;
802  }
803  if (num_interior_edges == 2)
804  cut_twice = true;
805  }
806  return cut_twice;
807 }
std::vector< EFAFragment2D * > _fragments
Definition: EFAElement2D.h:35

◆ isPartial()

bool EFAElement2D::isPartial ( ) const
virtual

Implements EFAElement.

Definition at line 208 of file EFAElement2D.C.

Referenced by branchingSplit(), XFEMCutElem2D::computeMomentFittingWeights(), and updateFragments().

209 {
210  bool partial = false;
211  if (_fragments.size() > 0)
212  {
213  for (unsigned int i = 0; i < _num_edges; ++i)
214  {
215  bool node_in_frag = false;
216  for (unsigned int j = 0; j < _fragments.size(); ++j)
217  {
218  if (_fragments[j]->containsNode(_nodes[i]))
219  {
220  node_in_frag = true;
221  break;
222  }
223  } // j
224  if (!node_in_frag)
225  {
226  partial = true;
227  break;
228  }
229  } // i
230  }
231  return partial;
232 }
bool containsNode(EFANode *node) const
Definition: EFAElement.C:52
std::vector< EFANode * > _nodes
Definition: EFAElement.h:30
unsigned int _num_edges
Definition: EFAElement2D.h:31
std::vector< EFAFragment2D * > _fragments
Definition: EFAElement2D.h:35

◆ mapParametricCoordFrom1Dto2D()

void EFAElement2D::mapParametricCoordFrom1Dto2D ( unsigned int  edge_id,
double  xi_1d,
std::vector< double > &  para_coor 
) const
private

Definition at line 2006 of file EFAElement2D.C.

Referenced by getEdgeNodeParametricCoordinate().

2009 {
2010  para_coor.resize(2, 0.0);
2011  if (_num_edges == 4)
2012  {
2013  if (edge_id == 0)
2014  {
2015  para_coor[0] = xi_1d;
2016  para_coor[1] = -1.0;
2017  }
2018  else if (edge_id == 1)
2019  {
2020  para_coor[0] = 1.0;
2021  para_coor[1] = xi_1d;
2022  }
2023  else if (edge_id == 2)
2024  {
2025  para_coor[0] = -xi_1d;
2026  para_coor[1] = 1.0;
2027  }
2028  else if (edge_id == 3)
2029  {
2030  para_coor[0] = -1.0;
2031  para_coor[1] = -xi_1d;
2032  }
2033  else
2034  EFAError("edge_id out of bounds");
2035  }
2036  else if (_num_edges == 3)
2037  {
2038  if (edge_id == 0)
2039  {
2040  para_coor[0] = 0.5 * (1.0 - xi_1d);
2041  para_coor[1] = 0.5 * (1.0 + xi_1d);
2042  }
2043  else if (edge_id == 1)
2044  {
2045  para_coor[0] = 0.0;
2046  para_coor[1] = 0.5 * (1.0 - xi_1d);
2047  }
2048  else if (edge_id == 2)
2049  {
2050  para_coor[0] = 0.5 * (1.0 + xi_1d);
2051  para_coor[1] = 0.0;
2052  }
2053  else
2054  EFAError("edge_id out of bounds");
2055  }
2056  else
2057  EFAError("unknown element for 2D");
2058 }
unsigned int _num_edges
Definition: EFAElement2D.h:31

◆ mergeNodes()

void EFAElement::mergeNodes ( EFANode *&  childNode,
EFANode *&  childOfNeighborNode,
EFAElement childOfNeighborElem,
std::map< unsigned int, EFANode *> &  PermanentNodes,
std::map< unsigned int, EFANode *> &  TempNodes 
)
protectedinherited

Definition at line 248 of file EFAElement.C.

Referenced by connectNeighbors(), and EFAElement3D::connectNeighbors().

253 {
254  // Important: this must be run only on child elements that were just created
255  if (!_parent)
256  EFAError("no getParent element for child element ", _id, " in mergeNodes");
257 
258  EFAElement * childElem = this;
259  if (childNode != childOfNeighborNode)
260  {
261  if (childNode->category() == EFANode::N_CATEGORY_PERMANENT)
262  {
263  if (childOfNeighborNode->category() == EFANode::N_CATEGORY_PERMANENT)
264  {
265  if (childOfNeighborNode->parent() == childNode) // merge into childNode
266  {
267  childOfNeighborElem->switchNode(childNode, childOfNeighborNode, true);
268  if (!Efa::deleteFromMap(PermanentNodes, childOfNeighborNode))
269  {
270  EFAError("Attempted to delete node: ",
271  childOfNeighborNode->id(),
272  " from PermanentNodes, but couldn't find it");
273  }
274  childOfNeighborNode = childNode;
275  }
276  else if (childNode->parent() == childOfNeighborNode) // merge into childOfNeighborNode
277  {
278  childElem->switchNode(childOfNeighborNode, childNode, true);
279  if (!Efa::deleteFromMap(PermanentNodes, childNode))
280  {
281  EFAError("Attempted to delete node: ",
282  childNode->id(),
283  " from PermanentNodes, but couldn't find it");
284  }
285  childNode = childOfNeighborNode;
286  }
287  else if (childNode->parent() != NULL &&
288  childNode->parent() == childOfNeighborNode->parent())
289  {
290  // merge into childNode if both nodes are child permanent
291  childOfNeighborElem->switchNode(childNode, childOfNeighborNode, true);
292  if (!Efa::deleteFromMap(PermanentNodes,
293  childOfNeighborNode)) // delete childOfNeighborNode
294  {
295  EFAError("Attempted to delete node: ",
296  childOfNeighborNode->id(),
297  " from PermanentNodes, but couldn't find it");
298  }
299  childOfNeighborNode = childNode;
300  }
301  else
302  {
303  EFAError("Attempting to merge nodes: ",
304  childNode->id(),
305  " and ",
306  childOfNeighborNode->id(),
307  " but both are permanent themselves");
308  }
309  }
310  else
311  {
312  if (childOfNeighborNode->parent() != childNode &&
313  childOfNeighborNode->parent() != childNode->parent())
314  {
315  EFAError("Attempting to merge nodes ",
316  childOfNeighborNode->idCatString(),
317  " and ",
318  childNode->idCatString(),
319  " but neither the 2nd node nor its parent is parent of the 1st");
320  }
321  childOfNeighborElem->switchNode(childNode, childOfNeighborNode, true);
322  if (!Efa::deleteFromMap(TempNodes, childOfNeighborNode))
323  EFAError("Attempted to delete node: ",
324  childOfNeighborNode->id(),
325  " from TempNodes, but couldn't find it");
326  childOfNeighborNode = childNode;
327  }
328  }
329  else if (childOfNeighborNode->category() == EFANode::N_CATEGORY_PERMANENT)
330  {
331  if (childNode->parent() != childOfNeighborNode &&
332  childNode->parent() != childOfNeighborNode->parent())
333  {
334  EFAError("Attempting to merge nodes ",
335  childNode->id(),
336  " and ",
337  childOfNeighborNode->id(),
338  " but neither the 2nd node nor its parent is parent of the 1st");
339  }
340  childElem->switchNode(childOfNeighborNode, childNode, true);
341  if (!Efa::deleteFromMap(TempNodes, childNode))
342  EFAError(
343  "Attempted to delete node: ", childNode->id(), " from TempNodes, but couldn't find it");
344  childNode = childOfNeighborNode;
345  }
346  else // both nodes are temporary -- create new permanent node and delete temporary nodes
347  {
348  unsigned int new_node_id = Efa::getNewID(PermanentNodes);
349  EFANode * newNode =
350  new EFANode(new_node_id, EFANode::N_CATEGORY_PERMANENT, childNode->parent());
351  PermanentNodes.insert(std::make_pair(new_node_id, newNode));
352 
353  childOfNeighborElem->switchNode(newNode, childOfNeighborNode, true);
354  childElem->switchNode(newNode, childNode, true);
355 
356  if (childNode->parent() != childOfNeighborNode->parent())
357  {
358  EFAError("Attempting to merge nodes ",
359  childNode->id(),
360  " and ",
361  childOfNeighborNode->id(),
362  " but they don't share a common parent");
363  }
364 
365  if (!Efa::deleteFromMap(TempNodes, childOfNeighborNode))
366  EFAError("Attempted to delete node: ",
367  childOfNeighborNode->id(),
368  " from TempNodes, but couldn't find it");
369  if (!Efa::deleteFromMap(TempNodes, childNode))
370  EFAError(
371  "Attempted to delete node: ", childNode->id(), " from TempNodes, but couldn't find it");
372  childOfNeighborNode = newNode;
373  childNode = newNode;
374  }
375  }
376 }
unsigned int getNewID(std::map< unsigned int, T *> &theMap)
Definition: EFAFuncs.h:39
unsigned int _id
Definition: EFAElement.h:28
std::string idCatString()
Definition: EFANode.C:20
bool deleteFromMap(std::map< unsigned int, T *> &theMap, T *elemToDelete, bool delete_elem=true)
Definition: EFAFuncs.h:23
virtual void switchNode(EFANode *new_node, EFANode *old_node, bool descend_to_parent)=0
EFAElement * _parent
Definition: EFAElement.h:32
EFANode * parent() const
Definition: EFANode.C:48
unsigned int id() const
Definition: EFANode.C:36
N_CATEGORY category() const
Definition: EFANode.C:42

◆ neighborSanityCheck()

void EFAElement2D::neighborSanityCheck ( ) const
virtual

Implements EFAElement.

Definition at line 523 of file EFAElement2D.C.

524 {
525  for (unsigned int edge_iter = 0; edge_iter < _num_edges; ++edge_iter)
526  {
527  for (unsigned int en_iter = 0; en_iter < _edge_neighbors[edge_iter].size(); ++en_iter)
528  {
529  EFAElement2D * neigh_elem = _edge_neighbors[edge_iter][en_iter];
530  if (neigh_elem != NULL)
531  {
532  bool found_neighbor = false;
533  for (unsigned int edge_iter2 = 0; edge_iter2 < neigh_elem->numEdges(); ++edge_iter2)
534  {
535  for (unsigned int en_iter2 = 0; en_iter2 < neigh_elem->numEdgeNeighbors(edge_iter2);
536  ++en_iter2)
537  {
538  if (neigh_elem->getEdgeNeighbor(edge_iter2, en_iter2) == this)
539  {
540  if ((en_iter2 > 1) && (en_iter > 1))
541  EFAError(
542  "Element and neighbor element cannot both have >1 neighbors on a common edge");
543  found_neighbor = true;
544  break;
545  }
546  }
547  }
548  if (!found_neighbor)
549  EFAError("Neighbor element doesn't recognize current element as neighbor");
550  }
551  }
552  }
553 }
unsigned int numEdgeNeighbors(unsigned int edge_id) const
std::vector< std::vector< EFAElement2D * > > _edge_neighbors
Definition: EFAElement2D.h:34
unsigned int numEdges() const
EFAElement2D * getEdgeNeighbor(unsigned int edge_id, unsigned int neighbor_id) const
unsigned int _num_edges
Definition: EFAElement2D.h:31

◆ numChildren()

unsigned int EFAElement::numChildren ( ) const
inherited

Definition at line 197 of file EFAElement.C.

Referenced by connectNeighbors(), EFAElement3D::connectNeighbors(), switchNode(), and EFAElement3D::switchNode().

198 {
199  return _children.size();
200 }
std::vector< EFAElement * > _children
Definition: EFAElement.h:33

◆ numCrackTipNeighbors()

unsigned int EFAElement::numCrackTipNeighbors ( ) const
inherited

Definition at line 142 of file EFAElement.C.

143 {
144  return _crack_tip_neighbors.size();
145 }
std::vector< unsigned int > _crack_tip_neighbors
Definition: EFAElement.h:35

◆ numEdgeNeighbors()

unsigned int EFAElement2D::numEdgeNeighbors ( unsigned int  edge_id) const

Definition at line 1563 of file EFAElement2D.C.

Referenced by addEdgeCut(), connectNeighbors(), neighborSanityCheck(), printElement(), shouldDuplicateCrackTipSplitElement(), shouldDuplicateForPhantomCorner(), and willCrackTipExtend().

1564 {
1565  unsigned int num_neighbors = 0;
1566  if (_edge_neighbors[edge_id][0])
1567  num_neighbors = _edge_neighbors[edge_id].size();
1568  return num_neighbors;
1569 }
std::vector< std::vector< EFAElement2D * > > _edge_neighbors
Definition: EFAElement2D.h:34

◆ numEdges()

unsigned int EFAElement2D::numEdges ( ) const

◆ numFragments()

unsigned int EFAElement2D::numFragments ( ) const
virtual

◆ numGeneralNeighbors()

unsigned int EFAElement::numGeneralNeighbors ( ) const
inherited

Definition at line 242 of file EFAElement.C.

Referenced by switchNode(), and EFAElement3D::switchNode().

243 {
244  return _general_neighbors.size();
245 }
std::vector< EFAElement * > _general_neighbors
Definition: EFAElement.h:37

◆ numInteriorNodes()

unsigned int EFAElement2D::numInteriorNodes ( ) const
virtual

Implements EFAElement.

Definition at line 353 of file EFAElement2D.C.

Referenced by fragmentSanityCheck(), EFAFragment2D::isSecondaryInteriorEdge(), and EFAFragment2D::removeInvalidEmbeddedNodes().

354 {
355  return _interior_nodes.size();
356 }
std::vector< EFAFaceNode * > _interior_nodes
Definition: EFAElement2D.h:33

◆ numNodes()

unsigned int EFAElement::numNodes ( ) const
inherited

◆ overlaysElement()

bool EFAElement2D::overlaysElement ( const EFAElement2D other_elem) const

Definition at line 359 of file EFAElement2D.C.

Referenced by initCrackTip(), and setupNeighbors().

360 {
361  bool overlays = false;
362 
363  if (other_elem->numEdges() != _num_edges)
364  return overlays;
365 
366  std::vector<EFANode *> common_nodes = getCommonNodes(other_elem);
367 
368  // Find indices of common nodes
369  if (common_nodes.size() == 2)
370  {
371  std::vector<EFANode *> common_nodes_vec(common_nodes.begin(), common_nodes.end());
372 
373  unsigned int e1n1idx = _num_edges + 1;
374  unsigned int e1n2idx = _num_edges + 1;
375  for (unsigned int i = 0; i < _num_edges; ++i)
376  {
377  if (_nodes[i] == common_nodes_vec[0])
378  {
379  e1n1idx = i;
380  }
381  else if (_nodes[i] == common_nodes_vec[1])
382  {
383  e1n2idx = i;
384  }
385  }
386 
387  if (e1n1idx > _num_edges || e1n2idx > _num_edges)
388  EFAError("in overlays_elem() couldn't find common node");
389 
390  bool e1ascend = false;
391  unsigned int e1n1idx_plus1(e1n1idx < (_num_edges - 1) ? e1n1idx + 1 : 0);
392  unsigned int e1n1idx_minus1(e1n1idx > 0 ? e1n1idx - 1 : _num_edges - 1);
393  if (e1n2idx == e1n1idx_plus1)
394  {
395  e1ascend = true;
396  }
397  else
398  {
399  if (e1n2idx != e1n1idx_minus1)
400  EFAError("in overlays_elem() common nodes must be adjacent to each other");
401  }
402 
403  unsigned int e2n1idx = _num_edges + 1;
404  unsigned int e2n2idx = _num_edges + 1;
405  for (unsigned int i = 0; i < _num_edges; ++i)
406  {
407  if (other_elem->getNode(i) == common_nodes_vec[0])
408  {
409  e2n1idx = i;
410  }
411  else if (other_elem->getNode(i) == common_nodes_vec[1])
412  {
413  e2n2idx = i;
414  }
415  }
416  if (e2n1idx > other_elem->numNodes() || e2n2idx > other_elem->numNodes())
417  EFAError("in overlays_elem() couldn't find common node");
418 
419  bool e2ascend = false;
420  unsigned int e2n1idx_plus1(e2n1idx < (_num_edges - 1) ? e2n1idx + 1 : 0);
421  unsigned int e2n1idx_minus1(e2n1idx > 0 ? e2n1idx - 1 : _num_edges - 1);
422  if (e2n2idx == e2n1idx_plus1)
423  {
424  e2ascend = true;
425  }
426  else
427  {
428  if (e2n2idx != e2n1idx_minus1)
429  EFAError("in overlays_elem() common nodes must be adjacent to each other");
430  }
431 
432  // if indices both ascend or descend, they overlay
433  if ((e1ascend && e2ascend) || (!e1ascend && !e2ascend))
434  {
435  overlays = true;
436  }
437  }
438  else if (common_nodes.size() > 2)
439  {
440  // TODO: We probably need more error checking here.
441  overlays = true;
442  }
443  return overlays;
444 }
std::vector< EFANode * > getCommonNodes(const EFAElement2D *other_elem) const
unsigned int numEdges() const
std::vector< EFANode * > _nodes
Definition: EFAElement.h:30
EFANode * getNode(unsigned int node_id) const
Definition: EFAElement.C:46
unsigned int _num_edges
Definition: EFAElement2D.h:31
unsigned int numNodes() const
Definition: EFAElement.C:34

◆ printElement()

void EFAElement2D::printElement ( std::ostream &  ostream)
virtual

Implements EFAElement.

Definition at line 1312 of file EFAElement2D.C.

1313 {
1314  ostream << std::setw(4);
1315  ostream << _id << " | ";
1316  for (unsigned int j = 0; j < _num_nodes; ++j)
1317  {
1318  ostream << std::setw(5) << _nodes[j]->idCatString();
1319  }
1320 
1321  ostream << " | ";
1322  for (unsigned int j = 0; j < _num_edges; ++j)
1323  {
1324  ostream << std::setw(4);
1325  if (_edges[j]->hasIntersection())
1326  {
1327  if (_edges[j]->numEmbeddedNodes() > 1)
1328  {
1329  ostream << "[";
1330  for (unsigned int k = 0; k < _edges[j]->numEmbeddedNodes(); ++k)
1331  {
1332  ostream << _edges[j]->getEmbeddedNode(k)->id();
1333  if (k == _edges[j]->numEmbeddedNodes() - 1)
1334  ostream << "]";
1335  else
1336  ostream << " ";
1337  }
1338  }
1339  else
1340  ostream << _edges[j]->getEmbeddedNode(0)->id() << " ";
1341  }
1342  else
1343  ostream << " -- ";
1344  }
1345  ostream << " | ";
1346  for (unsigned int j = 0; j < _num_edges; ++j)
1347  {
1348  if (numEdgeNeighbors(j) > 1)
1349  {
1350  ostream << "[";
1351  for (unsigned int k = 0; k < numEdgeNeighbors(j); ++k)
1352  {
1353  ostream << getEdgeNeighbor(j, k)->id();
1354  if (k == numEdgeNeighbors(j) - 1)
1355  ostream << "]";
1356  else
1357  ostream << " ";
1358  }
1359  ostream << " ";
1360  }
1361  else
1362  {
1363  ostream << std::setw(4);
1364  if (numEdgeNeighbors(j) == 1)
1365  ostream << getEdgeNeighbor(j, 0)->id() << " ";
1366  else
1367  ostream << " -- ";
1368  }
1369  }
1370  ostream << " | ";
1371  for (unsigned int j = 0; j < _fragments.size(); ++j)
1372  {
1373  ostream << std::setw(4);
1374  ostream << " " << j << " | ";
1375  for (unsigned int k = 0; k < _fragments[j]->numEdges(); ++k)
1376  {
1377  EFANode * prt_node = getFragmentEdge(j, k)->getNode(0);
1378  unsigned int kprev(k > 0 ? k - 1 : _fragments[j]->numEdges() - 1);
1379  if (!getFragmentEdge(j, kprev)->containsNode(prt_node))
1380  prt_node = getFragmentEdge(j, k)->getNode(1);
1381  ostream << std::setw(5) << prt_node->idCatString();
1382  }
1383  }
1384  ostream << std::endl;
1385 }
unsigned int numEdgeNeighbors(unsigned int edge_id) const
unsigned int id() const
Definition: EFAElement.C:28
unsigned int _id
Definition: EFAElement.h:28
std::string idCatString()
Definition: EFANode.C:20
std::vector< EFAEdge * > _edges
Definition: EFAElement2D.h:32
unsigned int numEdges() const
bool containsNode(EFANode *node) const
Definition: EFAElement.C:52
std::vector< EFANode * > _nodes
Definition: EFAElement.h:30
unsigned int _num_nodes
Definition: EFAElement.h:29
EFAElement2D * getEdgeNeighbor(unsigned int edge_id, unsigned int neighbor_id) const
unsigned int _num_edges
Definition: EFAElement2D.h:31
EFANode * getNode(unsigned int index) const
Definition: EFAEdge.C:179
EFAEdge * getFragmentEdge(unsigned int frag_id, unsigned int edge_id) const
std::vector< EFAFragment2D * > _fragments
Definition: EFAElement2D.h:35

◆ printNodes()

void EFAElement::printNodes ( std::ostream &  ostream) const
inherited

Definition at line 61 of file EFAElement.C.

62 {
63  ostream << "***** nodes for element " << _id << " *****" << std::endl;
64  for (unsigned int i = 0; i < _num_nodes; ++i)
65  ostream << "addr " << _nodes[i] << ", ID " << _nodes[i]->idCatString() << ", category "
66  << _nodes[i]->category() << std::endl;
67 }
unsigned int _id
Definition: EFAElement.h:28
std::vector< EFANode * > _nodes
Definition: EFAElement.h:30
unsigned int _num_nodes
Definition: EFAElement.h:29

◆ removePhantomEmbeddedNode()

void EFAElement2D::removePhantomEmbeddedNode ( )
virtual

Implements EFAElement.

Definition at line 1151 of file EFAElement2D.C.

Referenced by createChild().

1152 {
1153  // remove the embedded nodes on edge that are not inside the real part
1154  if (_fragments.size() > 0)
1155  {
1156  for (unsigned int i = 0; i < _num_edges; ++i)
1157  {
1158  std::vector<EFANode *> nodes_to_delete;
1159  for (unsigned int j = 0; j < _edges[i]->numEmbeddedNodes(); ++j)
1160  {
1161  if (!_fragments[0]->containsNode(_edges[i]->getEmbeddedNode(j)))
1162  nodes_to_delete.push_back(_edges[i]->getEmbeddedNode(j));
1163  }
1164  for (unsigned int j = 0; j < nodes_to_delete.size(); ++j)
1165  _edges[i]->removeEmbeddedNode(nodes_to_delete[j]);
1166  } // i
1167  }
1168 }
std::vector< EFAEdge * > _edges
Definition: EFAElement2D.h:32
bool containsNode(EFANode *node) const
Definition: EFAElement.C:52
unsigned int _num_edges
Definition: EFAElement2D.h:31
std::vector< EFAFragment2D * > _fragments
Definition: EFAElement2D.h:35

◆ restoreFragment()

void EFAElement2D::restoreFragment ( const EFAElement *const  from_elem)
virtual

Implements EFAElement.

Definition at line 944 of file EFAElement2D.C.

945 {
946  const EFAElement2D * from_elem2d = dynamic_cast<const EFAElement2D *>(from_elem);
947  if (!from_elem2d)
948  EFAError("from_elem is not of EFAelement2D type");
949 
950  // restore fragments
951  if (_fragments.size() != 0)
952  EFAError("in restoreFragmentInfo elements must not have any pre-existing fragments");
953  for (unsigned int i = 0; i < from_elem2d->numFragments(); ++i)
954  _fragments.push_back(new EFAFragment2D(this, true, from_elem2d, i));
955 
956  // restore interior nodes
957  if (_interior_nodes.size() != 0)
958  EFAError("in restoreFragmentInfo elements must not have any pre-exsiting interior nodes");
959  for (unsigned int i = 0; i < from_elem2d->_interior_nodes.size(); ++i)
960  _interior_nodes.push_back(new EFAFaceNode(*from_elem2d->_interior_nodes[i]));
961 
962  // restore edge intersections
963  if (getNumCuts() != 0)
964  EFAError("In restoreEdgeIntersection: edge cuts already exist in element ", _id);
965  for (unsigned int i = 0; i < _num_edges; ++i)
966  {
967  if (from_elem2d->_edges[i]->hasIntersection())
968  _edges[i]->copyIntersection(*from_elem2d->_edges[i], 0);
969  if (_edges[i]->numEmbeddedNodes() > 2)
970  EFAError("elem ", _id, " has an edge with >2 cuts");
971  }
972 
973  // replace all local nodes with global nodes
974  for (unsigned int i = 0; i < from_elem2d->numNodes(); ++i)
975  {
976  if (from_elem2d->_nodes[i]->category() == EFANode::N_CATEGORY_LOCAL_INDEX)
977  switchNode(
978  _nodes[i], from_elem2d->_nodes[i], false); // EFAelement is not a child of any parent
979  else
980  EFAError("In restoreFragmentInfo all of from_elem's nodes must be local");
981  }
982 }
std::vector< EFAFaceNode * > _interior_nodes
Definition: EFAElement2D.h:33
unsigned int _id
Definition: EFAElement.h:28
std::vector< EFAEdge * > _edges
Definition: EFAElement2D.h:32
virtual unsigned int numFragments() const
Definition: EFAElement2D.C:202
virtual void switchNode(EFANode *new_node, EFANode *old_node, bool descend_to_parent)
Definition: EFAElement2D.C:262
std::vector< EFANode * > _nodes
Definition: EFAElement.h:30
virtual unsigned int getNumCuts() const
Definition: EFAElement2D.C:781
unsigned int _num_edges
Definition: EFAElement2D.h:31
unsigned int numNodes() const
Definition: EFAElement.C:34
std::vector< EFAFragment2D * > _fragments
Definition: EFAElement2D.h:35

◆ setCrackTipSplit()

void EFAElement::setCrackTipSplit ( )
inherited

Definition at line 130 of file EFAElement.C.

131 {
133 }
bool _crack_tip_split_element
Definition: EFAElement.h:34

◆ setEdge()

void EFAElement2D::setEdge ( unsigned int  edge_id,
EFAEdge edge 
)

Definition at line 1453 of file EFAElement2D.C.

Referenced by createChild().

1454 {
1455  _edges[edge_id] = edge;
1456 }
std::vector< EFAEdge * > _edges
Definition: EFAElement2D.h:32

◆ setLocalCoordinates()

void EFAElement2D::setLocalCoordinates ( )
private

Definition at line 141 of file EFAElement2D.C.

Referenced by EFAElement2D().

142 {
143  if (_num_edges == 4)
144  {
145  /*
146  3 6 2
147  QUAD9(QUAD8): o-----o-----o
148  | |
149  | 8 |
150  7 o o o 5
151  | |
152  | |
153  o-----o-----o
154  0 4 1
155 
156  */
158  _local_node_coor[0] = EFAPoint(0.0, 0.0, 0.0);
159  _local_node_coor[1] = EFAPoint(1.0, 0.0, 0.0);
160  _local_node_coor[2] = EFAPoint(1.0, 1.0, 0.0);
161  _local_node_coor[3] = EFAPoint(0.0, 1.0, 0.0);
162 
163  if (_num_nodes > 4)
164  {
165  _local_node_coor[4] = EFAPoint(0.5, 0.0, 0.0);
166  _local_node_coor[5] = EFAPoint(1.0, 0.5, 0.0);
167  _local_node_coor[6] = EFAPoint(0.5, 1.0, 0.0);
168  _local_node_coor[7] = EFAPoint(0.0, 0.5, 0.0);
169  }
170 
171  if (_num_nodes > 8)
172  _local_node_coor[8] = EFAPoint(0.5, 0.5, 0.0);
173  }
174  else
175  {
176  /*
177  TRI6: 2
178  o
179  | \
180  | \
181  5 o o 4
182  | \
183  | \
184  o-----o-----o
185  0 3 1
186  */
188  _local_node_coor[0] = EFAPoint(0.0, 0.0, 0.0);
189  _local_node_coor[1] = EFAPoint(1.0, 0.0, 0.0);
190  _local_node_coor[2] = EFAPoint(0.0, 1.0, 0.0);
191 
192  if (_num_nodes > 3)
193  {
194  _local_node_coor[3] = EFAPoint(0.5, 0.0, 0.0);
195  _local_node_coor[4] = EFAPoint(0.5, 0.5, 0.0);
196  _local_node_coor[5] = EFAPoint(0.0, 0.5, 0.0);
197  }
198  }
199 }
unsigned int _num_nodes
Definition: EFAElement.h:29
std::vector< EFAPoint > _local_node_coor
Definition: EFAElement2D.h:36
unsigned int _num_edges
Definition: EFAElement2D.h:31

◆ setNode()

void EFAElement::setNode ( unsigned int  node_id,
EFANode node 
)
inherited

◆ setParent()

void EFAElement::setParent ( EFAElement parent)
inherited

Definition at line 191 of file EFAElement.C.

Referenced by createChild(), and EFAElement3D::createChild().

192 {
193  _parent = parent;
194 }
EFAElement * _parent
Definition: EFAElement.h:32

◆ setupNeighbors()

void EFAElement2D::setupNeighbors ( std::map< EFANode *, std::set< EFAElement *>> &  InverseConnectivityMap)
virtual

Implements EFAElement.

Definition at line 467 of file EFAElement2D.C.

468 {
469  findGeneralNeighbors(InverseConnectivityMap);
470  for (unsigned int eit2 = 0; eit2 < _general_neighbors.size(); ++eit2)
471  {
472  EFAElement2D * neigh_elem = dynamic_cast<EFAElement2D *>(_general_neighbors[eit2]);
473  if (!neigh_elem)
474  EFAError("neighbor_elem is not of EFAelement2D type");
475 
476  std::vector<EFANode *> common_nodes = getCommonNodes(neigh_elem);
477  if (common_nodes.size() >= 2)
478  {
479  for (unsigned int edge_iter = 0; edge_iter < _num_edges; ++edge_iter)
480  {
481  std::set<EFANode *> edge_nodes = getEdgeNodes(edge_iter);
482  bool is_edge_neighbor = false;
483 
484  // Must share nodes on this edge
485  if (Efa::numCommonElems(edge_nodes, common_nodes) == 2 && (!overlaysElement(neigh_elem)))
486  {
487  // Fragments must match up.
488  if ((_fragments.size() > 1) || (neigh_elem->numFragments() > 1))
489  EFAError("in updateEdgeNeighbors: Cannot have more than 1 fragment");
490  else if ((_fragments.size() == 1) && (neigh_elem->numFragments() == 1))
491  {
492  if (_fragments[0]->isConnected(neigh_elem->getFragment(0)))
493  is_edge_neighbor = true;
494  }
495  else // If there are no fragments to match up, consider them neighbors
496  is_edge_neighbor = true;
497  }
498 
499  if (is_edge_neighbor)
500  {
501  if (_edge_neighbors[edge_iter][0])
502  {
503  if (_edge_neighbors[edge_iter].size() > 1)
504  {
505  EFAError("Element ",
506  _id,
507  " already has 2 edge neighbors: ",
508  _edge_neighbors[edge_iter][0]->id(),
509  " ",
510  _edge_neighbors[edge_iter][1]->id());
511  }
512  _edge_neighbors[edge_iter].push_back(neigh_elem);
513  }
514  else
515  _edge_neighbors[edge_iter][0] = neigh_elem;
516  }
517  }
518  }
519  }
520 }
std::vector< EFANode * > getCommonNodes(const EFAElement2D *other_elem) const
unsigned int _id
Definition: EFAElement.h:28
std::vector< std::vector< EFAElement2D * > > _edge_neighbors
Definition: EFAElement2D.h:34
void findGeneralNeighbors(std::map< EFANode *, std::set< EFAElement *>> &InverseConnectivity)
Definition: EFAElement.C:216
virtual unsigned int numFragments() const
Definition: EFAElement2D.C:202
EFAFragment2D * getFragment(unsigned int frag_id) const
std::set< EFANode * > getEdgeNodes(unsigned int edge_id) const
unsigned int numCommonElems(std::set< T > &v1, std::set< T > &v2)
Definition: EFAFuncs.h:50
bool overlaysElement(const EFAElement2D *other_elem) const
Definition: EFAElement2D.C:359
unsigned int _num_edges
Definition: EFAElement2D.h:31
std::vector< EFAElement * > _general_neighbors
Definition: EFAElement.h:37
std::vector< EFAFragment2D * > _fragments
Definition: EFAElement2D.h:35

◆ shouldDuplicateCrackTipSplitElement()

bool EFAElement2D::shouldDuplicateCrackTipSplitElement ( const std::set< EFAElement *> &  CrackTipElements)
virtual

Implements EFAElement.

Definition at line 639 of file EFAElement2D.C.

Referenced by shouldDuplicateForCrackTip().

640 {
641  // Determine whether element at crack tip should be duplicated. It should be duplicated
642  // if the crack will extend into the next element, or if it has a non-physical node
643  // connected to a face where a crack terminates, but will extend.
644 
645  bool should_duplicate = false;
646  if (_fragments.size() == 1)
647  {
648  std::vector<unsigned int> split_neighbors;
649  if (willCrackTipExtend(split_neighbors))
650  should_duplicate = true;
651  else
652  {
653  // The element may not be at the crack tip, but could have a non-physical node
654  // connected to a crack tip face (on a neighbor element) that will be split. We need to
655  // duplicate in that case as well.
656  std::set<EFANode *> non_physical_nodes;
657  getNonPhysicalNodes(non_physical_nodes);
658 
659  for (unsigned int eit = 0; eit < _general_neighbors.size(); ++eit)
660  {
661  EFAElement2D * neigh_elem = dynamic_cast<EFAElement2D *>(_general_neighbors[eit]);
662  if (!neigh_elem)
663  EFAError("general elem is not of type EFAelement2D");
664 
665  // check if a general neighbor is an old crack tip element and will be split
666  std::set<EFAElement *>::iterator sit;
667  sit = CrackTipElements.find(neigh_elem);
668  if (sit != CrackTipElements.end() && neigh_elem->numFragments() > 1)
669  {
670  for (unsigned int i = 0; i < neigh_elem->numEdges(); ++i)
671  {
672  std::set<EFANode *> neigh_edge_nodes = neigh_elem->getEdgeNodes(i);
673  if (neigh_elem->numEdgeNeighbors(i) == 2 &&
674  Efa::numCommonElems(neigh_edge_nodes, non_physical_nodes) > 0)
675  {
676  should_duplicate = true;
677  break;
678  }
679  } // i
680  }
681  if (should_duplicate)
682  break;
683  } // eit
684  }
685  } // IF one fragment
686  return should_duplicate;
687 }
unsigned int numEdgeNeighbors(unsigned int edge_id) const
virtual void getNonPhysicalNodes(std::set< EFANode *> &non_physical_nodes) const
Definition: EFAElement2D.C:235
unsigned int numEdges() const
virtual unsigned int numFragments() const
Definition: EFAElement2D.C:202
std::set< EFANode * > getEdgeNodes(unsigned int edge_id) const
unsigned int numCommonElems(std::set< T > &v1, std::set< T > &v2)
Definition: EFAFuncs.h:50
virtual bool willCrackTipExtend(std::vector< unsigned int > &split_neighbors) const
Definition: EFAElement2D.C:729
std::vector< EFAElement * > _general_neighbors
Definition: EFAElement.h:37
std::vector< EFAFragment2D * > _fragments
Definition: EFAElement2D.h:35

◆ shouldDuplicateForCrackTip()

bool EFAElement2D::shouldDuplicateForCrackTip ( const std::set< EFAElement *> &  CrackTipElements)
virtual

Implements EFAElement.

Definition at line 615 of file EFAElement2D.C.

Referenced by createChild().

616 {
617  // This method is called in createChildElements()
618  // Only duplicate when
619  // 1) currElem will be a NEW crack tip element
620  // 2) currElem is a crack tip split element at last time step and the tip will extend
621  // 3) currElem is the neighbor of a to-be-second-split element which has another neighbor
622  // sharing a phantom node with currElem
623  bool should_duplicate = false;
624  if (_fragments.size() == 1)
625  {
626  std::set<EFAElement *>::iterator sit;
627  sit = CrackTipElements.find(this);
628  if (sit == CrackTipElements.end() && isCrackTipElement())
629  should_duplicate = true;
630  else if (shouldDuplicateCrackTipSplitElement(CrackTipElements))
631  should_duplicate = true;
633  should_duplicate = true;
634  }
635  return should_duplicate;
636 }
virtual bool shouldDuplicateForPhantomCorner()
Definition: EFAElement2D.C:690
virtual bool isCrackTipElement() const
Definition: EFAElement2D.C:775
virtual bool shouldDuplicateCrackTipSplitElement(const std::set< EFAElement *> &CrackTipElements)
Definition: EFAElement2D.C:639
std::vector< EFAFragment2D * > _fragments
Definition: EFAElement2D.h:35

◆ shouldDuplicateForPhantomCorner()

bool EFAElement2D::shouldDuplicateForPhantomCorner ( )
virtual

Implements EFAElement.

Definition at line 690 of file EFAElement2D.C.

Referenced by shouldDuplicateForCrackTip().

691 {
692  // if a partial element will be split for a second time and it has two neighbor elements
693  // sharing one phantom node with the aforementioned partial element, then the two neighbor
694  // elements should be duplicated
695  bool should_duplicate = false;
696  if (_fragments.size() == 1 && (!_crack_tip_split_element))
697  {
698  for (unsigned int i = 0; i < _num_edges; ++i)
699  {
700  std::set<EFANode *> phantom_nodes = getPhantomNodeOnEdge(i);
701  if (phantom_nodes.size() > 0 && numEdgeNeighbors(i) == 1)
702  {
703  EFAElement2D * neighbor_elem = _edge_neighbors[i][0];
704  if (neighbor_elem->numFragments() > 1) // neighbor will be split
705  {
706  for (unsigned int j = 0; j < neighbor_elem->numEdges(); ++j)
707  {
708  if (!neighbor_elem->getEdge(j)->equivalent(*_edges[i]) &&
709  neighbor_elem->numEdgeNeighbors(j) > 0)
710  {
711  std::set<EFANode *> neigh_phantom_nodes = neighbor_elem->getPhantomNodeOnEdge(j);
712  if (Efa::numCommonElems(phantom_nodes, neigh_phantom_nodes) > 0)
713  {
714  should_duplicate = true;
715  break;
716  }
717  }
718  } // j
719  }
720  }
721  if (should_duplicate)
722  break;
723  } // i
724  }
725  return should_duplicate;
726 }
unsigned int numEdgeNeighbors(unsigned int edge_id) const
std::vector< std::vector< EFAElement2D * > > _edge_neighbors
Definition: EFAElement2D.h:34
EFAEdge * getEdge(unsigned int edge_id) const
std::vector< EFAEdge * > _edges
Definition: EFAElement2D.h:32
unsigned int numEdges() const
virtual unsigned int numFragments() const
Definition: EFAElement2D.C:202
unsigned int numCommonElems(std::set< T > &v1, std::set< T > &v2)
Definition: EFAFuncs.h:50
bool equivalent(const EFAEdge &other) const
Definition: EFAEdge.C:38
std::set< EFANode * > getPhantomNodeOnEdge(unsigned int edge_id) const
unsigned int _num_edges
Definition: EFAElement2D.h:31
bool _crack_tip_split_element
Definition: EFAElement.h:34
std::vector< EFAFragment2D * > _fragments
Definition: EFAElement2D.h:35

◆ switchEmbeddedNode()

void EFAElement2D::switchEmbeddedNode ( EFANode new_node,
EFANode old_node 
)
virtual

Implements EFAElement.

Definition at line 289 of file EFAElement2D.C.

290 {
291  for (unsigned int i = 0; i < _num_edges; ++i)
292  _edges[i]->switchNode(new_emb_node, old_emb_node);
293  for (unsigned int i = 0; i < _interior_nodes.size(); ++i)
294  _interior_nodes[i]->switchNode(new_emb_node, old_emb_node);
295  for (unsigned int i = 0; i < _fragments.size(); ++i)
296  _fragments[i]->switchNode(new_emb_node, old_emb_node);
297 }
std::vector< EFAFaceNode * > _interior_nodes
Definition: EFAElement2D.h:33
std::vector< EFAEdge * > _edges
Definition: EFAElement2D.h:32
virtual void switchNode(EFANode *new_node, EFANode *old_node, bool descend_to_parent)
Definition: EFAElement2D.C:262
unsigned int _num_edges
Definition: EFAElement2D.h:31
std::vector< EFAFragment2D * > _fragments
Definition: EFAElement2D.h:35

◆ switchNode()

void EFAElement2D::switchNode ( EFANode new_node,
EFANode old_node,
bool  descend_to_parent 
)
virtual

Implements EFAElement.

Definition at line 262 of file EFAElement2D.C.

Referenced by connectNeighbors(), EFAElement2D(), restoreFragment(), switchEmbeddedNode(), and updateFragmentNode().

263 {
264  // We are not switching any embedded nodes here
265  for (unsigned int i = 0; i < _num_nodes; ++i)
266  {
267  if (_nodes[i] == old_node)
268  _nodes[i] = new_node;
269  }
270  for (unsigned int i = 0; i < _fragments.size(); ++i)
271  _fragments[i]->switchNode(new_node, old_node);
272 
273  for (unsigned int i = 0; i < _edges.size(); ++i)
274  _edges[i]->switchNode(new_node, old_node);
275 
276  if (_parent && descend_to_parent)
277  {
278  _parent->switchNode(new_node, old_node, false);
279  for (unsigned int i = 0; i < _parent->numGeneralNeighbors(); ++i)
280  {
281  EFAElement * neigh_elem = _parent->getGeneralNeighbor(i); // generalized neighbor element
282  for (unsigned int k = 0; k < neigh_elem->numChildren(); ++k)
283  neigh_elem->getChild(k)->switchNode(new_node, old_node, false);
284  }
285  }
286 }
unsigned int numChildren() const
Definition: EFAElement.C:197
std::vector< EFAEdge * > _edges
Definition: EFAElement2D.h:32
unsigned int numGeneralNeighbors() const
Definition: EFAElement.C:242
EFAElement * getChild(unsigned int child_id) const
Definition: EFAElement.C:182
virtual void switchNode(EFANode *new_node, EFANode *old_node, bool descend_to_parent)
Definition: EFAElement2D.C:262
std::vector< EFANode * > _nodes
Definition: EFAElement.h:30
unsigned int _num_nodes
Definition: EFAElement.h:29
virtual void switchNode(EFANode *new_node, EFANode *old_node, bool descend_to_parent)=0
EFAElement * _parent
Definition: EFAElement.h:32
EFAElement * getGeneralNeighbor(unsigned int index) const
Definition: EFAElement.C:236
std::vector< EFAFragment2D * > _fragments
Definition: EFAElement2D.h:35

◆ updateFragmentNode()

void EFAElement2D::updateFragmentNode ( )
virtual

Implements EFAElement.

Definition at line 1301 of file EFAElement2D.C.

1302 {
1303  for (unsigned int j = 0; j < _num_nodes; ++j)
1304  {
1305  if (_nodes[j]->parent() != NULL &&
1306  _nodes[j]->parent()->category() == EFANode::N_CATEGORY_EMBEDDED_PERMANENT)
1307  switchNode(_nodes[j], _nodes[j]->parent(), false);
1308  }
1309 }
virtual void switchNode(EFANode *new_node, EFANode *old_node, bool descend_to_parent)
Definition: EFAElement2D.C:262
std::vector< EFANode * > _nodes
Definition: EFAElement.h:30
unsigned int _num_nodes
Definition: EFAElement.h:29

◆ updateFragments()

void EFAElement2D::updateFragments ( const std::set< EFAElement *> &  CrackTipElements,
std::map< unsigned int, EFANode *> &  EmbeddedNodes 
)
virtual

Implements EFAElement.

Definition at line 810 of file EFAElement2D.C.

812 {
813  // combine the crack-tip edges in a fragment to a single intersected edge
814  std::set<EFAElement *>::iterator sit;
815  sit = CrackTipElements.find(this);
816  if (sit != CrackTipElements.end()) // curr_elem is a crack tip element
817  {
818  if (_fragments.size() == 1)
819  _fragments[0]->combineTipEdges();
820  else
821  EFAError("crack tip elem ", _id, " must have 1 fragment");
822  }
823 
824  // if a fragment only has 1 intersection which is in an interior edge
825  // remove this embedded node (MUST DO THIS AFTER combine_tip_edges())
826  if (_fragments.size() == 1)
827  _fragments[0]->removeInvalidEmbeddedNodes(EmbeddedNodes);
828 
829  // for an element with no fragment, create one fragment identical to the element
830  if (_fragments.size() == 0)
831  _fragments.push_back(new EFAFragment2D(this, true, this));
832  if (_fragments.size() != 1)
833  EFAError("Element ", _id, " must have 1 fragment at this point");
834 
835  // count fragment's cut edges
836  unsigned int num_cut_frag_edges = _fragments[0]->getNumCuts();
837  unsigned int num_cut_nodes = _fragments[0]->getNumCutNodes();
838  unsigned int num_frag_edges = _fragments[0]->numEdges();
839  if (num_cut_frag_edges > 3)
840  EFAError("In element ", _id, " there are more than 2 cut fragment edges");
841 
842  if (num_cut_frag_edges == 0 && num_cut_nodes == 0)
843  {
844  if (!isPartial()) // delete the temp frag for an uncut elem
845  {
846  delete _fragments[0];
847  _fragments.clear();
848  }
849  // Element has already been cut. Don't recreate fragments because we
850  // would create multiple fragments to cover the entire element and
851  // lose the information about what part of this element is physical.
852  return;
853  }
854 
855  // split one fragment into one, two or three new fragments
856  std::vector<EFAFragment2D *> new_frags;
857  if (num_cut_frag_edges == 3)
858  new_frags = branchingSplit(EmbeddedNodes);
859  else
860  new_frags = _fragments[0]->split();
861 
862  delete _fragments[0]; // delete the old fragment
863  _fragments.clear();
864  for (unsigned int i = 0; i < new_frags.size(); ++i)
865  _fragments.push_back(new_frags[i]);
866 
867  fragmentSanityCheck(num_frag_edges, num_cut_frag_edges);
868 }
virtual void fragmentSanityCheck(unsigned int n_old_frag_edges, unsigned int n_old_frag_cuts) const
Definition: EFAElement2D.C:871
std::vector< EFAFragment2D * > branchingSplit(std::map< unsigned int, EFANode *> &EmbeddedNodes)
unsigned int _id
Definition: EFAElement.h:28
virtual bool isPartial() const
Definition: EFAElement2D.C:208
std::vector< EFAFragment2D * > _fragments
Definition: EFAElement2D.h:35

◆ willCrackTipExtend()

bool EFAElement2D::willCrackTipExtend ( std::vector< unsigned int > &  split_neighbors) const
virtual

Implements EFAElement.

Definition at line 729 of file EFAElement2D.C.

Referenced by shouldDuplicateCrackTipSplitElement().

730 {
731  // Determine whether the current element is a crack tip element for which the crack will
732  // extend into the next element.
733  // N.B. this is called at the beginning of createChildElements
734  bool will_extend = false;
735  if (_fragments.size() == 1 && _crack_tip_split_element)
736  {
737  for (unsigned int i = 0; i < _crack_tip_neighbors.size(); ++i)
738  {
739  unsigned int neigh_idx = _crack_tip_neighbors[i];
740  if (numEdgeNeighbors(neigh_idx) != 1)
741  EFAError("in will_crack_tip_extend() element: ",
742  _id,
743  " has: ",
744  _edge_neighbors[neigh_idx].size(),
745  " on edge: ",
746  neigh_idx);
747 
748  EFAElement2D * neighbor_elem = _edge_neighbors[neigh_idx][0];
749  if (neighbor_elem->numFragments() > 2)
750  EFAError("in will_crack_tip_extend() element: ",
751  neighbor_elem->id(),
752  " has: ",
753  neighbor_elem->numFragments(),
754  " fragments");
755  else if (neighbor_elem->numFragments() == 2)
756  {
757  EFAFragment2D * frag1 = neighbor_elem->getFragment(0);
758  EFAFragment2D * frag2 = neighbor_elem->getFragment(1);
759  std::vector<EFANode *> neigh_cut_nodes = frag1->getCommonNodes(frag2);
760  if (neigh_cut_nodes.size() != 2)
761  EFAError("2 frags in a elem does not share 2 common nodes");
762  if (_edges[neigh_idx]->isEmbeddedNode(neigh_cut_nodes[0]) ||
763  _edges[neigh_idx]->isEmbeddedNode(neigh_cut_nodes[1]))
764  {
765  split_neighbors.push_back(neigh_idx);
766  will_extend = true;
767  }
768  }
769  } // i
770  }
771  return will_extend;
772 }
unsigned int numEdgeNeighbors(unsigned int edge_id) const
unsigned int id() const
Definition: EFAElement.C:28
unsigned int _id
Definition: EFAElement.h:28
std::vector< std::vector< EFAElement2D * > > _edge_neighbors
Definition: EFAElement2D.h:34
std::vector< EFAEdge * > _edges
Definition: EFAElement2D.h:32
virtual unsigned int numFragments() const
Definition: EFAElement2D.C:202
std::vector< EFANode * > getCommonNodes(EFAFragment *other) const
Definition: EFAFragment.C:20
EFAFragment2D * getFragment(unsigned int frag_id) const
bool _crack_tip_split_element
Definition: EFAElement.h:34
std::vector< unsigned int > _crack_tip_neighbors
Definition: EFAElement.h:35
std::vector< EFAFragment2D * > _fragments
Definition: EFAElement2D.h:35

Member Data Documentation

◆ _children

std::vector<EFAElement *> EFAElement::_children
protectedinherited

◆ _crack_tip_neighbors

std::vector<unsigned int> EFAElement::_crack_tip_neighbors
protectedinherited

◆ _crack_tip_split_element

bool EFAElement::_crack_tip_split_element
protectedinherited

◆ _edge_neighbors

std::vector<std::vector<EFAElement2D *> > EFAElement2D::_edge_neighbors
private

◆ _edges

std::vector<EFAEdge *> EFAElement2D::_edges
private

◆ _fragments

std::vector<EFAFragment2D *> EFAElement2D::_fragments
private

◆ _general_neighbors

std::vector<EFAElement *> EFAElement::_general_neighbors
protectedinherited

◆ _id

unsigned int EFAElement::_id
protectedinherited

◆ _interior_nodes

std::vector<EFAFaceNode *> EFAElement2D::_interior_nodes
private

◆ _local_node_coor

std::vector<EFAPoint> EFAElement2D::_local_node_coor
private

Definition at line 36 of file EFAElement2D.h.

Referenced by createChild(), EFAElement2D(), and setLocalCoordinates().

◆ _local_nodes

std::vector<EFANode *> EFAElement::_local_nodes
protectedinherited

◆ _nodes

std::vector<EFANode *> EFAElement::_nodes
protectedinherited

◆ _num_edges

unsigned int EFAElement2D::_num_edges
private

◆ _num_nodes

unsigned int EFAElement::_num_nodes
protectedinherited

◆ _parent

EFAElement* EFAElement::_parent
protectedinherited

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