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

#include <EFAFragment3D.h>

Inheritance diagram for EFAFragment3D:
[legend]

Public Member Functions

 EFAFragment3D (EFAElement3D *host, bool create_faces, const EFAElement3D *from_host, unsigned int frag_id=std::numeric_limits< unsigned int >::max())
 
 ~EFAFragment3D ()
 
virtual void switchNode (EFANode *new_node, EFANode *old_node)
 
virtual bool containsNode (EFANode *node) const
 
virtual unsigned int getNumCuts () const
 
virtual unsigned int getNumCutNodes () const
 
virtual std::set< EFANode * > getAllNodes () const
 
virtual bool isConnected (EFAFragment *other_fragment) const
 
virtual bool isEdgeConnected (EFAFragment *other_fragment) const
 
virtual void removeInvalidEmbeddedNodes (std::map< unsigned int, EFANode *> &EmbeddedNodes)
 
void combine_tip_faces ()
 
bool isFaceInterior (unsigned int face_id) const
 
std::vector< unsigned int > get_interior_face_id () const
 
bool isThirdInteriorFace (unsigned int face_id) const
 
unsigned int numFaces () const
 
EFAFacegetFace (unsigned int face_id) const
 
unsigned int getFaceID (EFAFace *face) const
 
void addFace (EFAFace *new_face)
 
std::set< EFANode * > getFaceNodes (unsigned int face_id) const
 
EFAElement3DgetHostElement () const
 
std::vector< EFAFragment3D * > split ()
 
void findFacesAdjacentToFaces ()
 
EFAFacegetAdjacentFace (unsigned int face_id, unsigned int edge_id) const
 
void removeEmbeddedNode (EFANode *emb_node)
 
bool hasFaceWithOneCut () const
 
void getNodeInfo (std::vector< std::vector< unsigned int >> &face_node_indices, std::vector< EFANode *> &nodes) const
 
std::vector< EFANode * > getCommonNodes (EFAFragment *other) const
 

Private Member Functions

EFAFragment3DconnectSubfaces (EFAFace *start_face, unsigned int startOldFaceID, std::vector< std::vector< EFAFace *>> &subfaces)
 
EFAEdgeloneEdgeOnFace (unsigned int face_id) const
 
void combine_two_faces (unsigned int face_id1, unsigned int face_id2, const EFAFace *elem_face)
 

Private Attributes

EFAElement3D_host_elem
 
std::vector< EFAFace * > _faces
 
std::vector< std::vector< EFAFace * > > _faces_adjacent_to_faces
 

Detailed Description

Definition at line 21 of file EFAFragment3D.h.

Constructor & Destructor Documentation

◆ EFAFragment3D()

EFAFragment3D::EFAFragment3D ( EFAElement3D host,
bool  create_faces,
const EFAElement3D from_host,
unsigned int  frag_id = std::numeric_limits<unsigned int>::max() 
)

Definition at line 20 of file EFAFragment3D.C.

Referenced by connectSubfaces(), and split().

24  : EFAFragment(), _host_elem(host)
25 {
26  if (create_faces)
27  {
28  if (!from_host)
29  EFAError("EFAfragment3D constructor must have a from_host to copy from");
30  if (frag_id == std::numeric_limits<unsigned int>::max()) // copy the from_host itself
31  {
32  for (unsigned int i = 0; i < from_host->numFaces(); ++i)
33  _faces.push_back(new EFAFace(*from_host->getFace(i)));
34  }
35  else
36  {
37  if (frag_id > from_host->numFragments() - 1)
38  EFAError("In EFAfragment3D constructor fragment_copy_index out of bounds");
39  for (unsigned int i = 0; i < from_host->getFragment(frag_id)->numFaces(); ++i)
40  _faces.push_back(new EFAFace(*from_host->getFragmentFace(frag_id, i)));
41  }
42  findFacesAdjacentToFaces(); // IMPORTANT
43  }
44 }
EFAFragment3D * getFragment(unsigned int frag_id) const
EFAFace * getFace(unsigned int face_id) const
void findFacesAdjacentToFaces()
virtual unsigned int numFragments() const
Definition: EFAElement3D.C:269
unsigned int numFaces() const
EFAElement3D * _host_elem
Definition: EFAFragment3D.h:31
EFAFace * getFragmentFace(unsigned int frag_id, unsigned int face_id) const
std::vector< EFAFace * > _faces
Definition: EFAFragment3D.h:32
unsigned int numFaces() const

◆ ~EFAFragment3D()

EFAFragment3D::~EFAFragment3D ( )

Definition at line 46 of file EFAFragment3D.C.

47 {
48  for (unsigned int i = 0; i < _faces.size(); ++i)
49  {
50  if (_faces[i])
51  {
52  delete _faces[i];
53  _faces[i] = NULL;
54  }
55  }
56 }
std::vector< EFAFace * > _faces
Definition: EFAFragment3D.h:32

Member Function Documentation

◆ addFace()

void EFAFragment3D::addFace ( EFAFace new_face)

Definition at line 295 of file EFAFragment3D.C.

Referenced by connectSubfaces(), and split().

296 {
297  _faces.push_back(new_face);
298 }
std::vector< EFAFace * > _faces
Definition: EFAFragment3D.h:32

◆ combine_tip_faces()

void EFAFragment3D::combine_tip_faces ( )

Definition at line 200 of file EFAFragment3D.C.

201 {
202  if (!_host_elem)
203  EFAError("In combine_tip_faces() the frag must have host_elem");
204 
205  for (unsigned int i = 0; i < _host_elem->numFaces(); ++i)
206  {
207  std::vector<unsigned int> frag_tip_face_id;
208  for (unsigned int j = 0; j < _faces.size(); ++j)
209  {
210  if (_host_elem->getFace(i)->containsFace(_faces[j]))
211  frag_tip_face_id.push_back(j);
212  }
213  if (frag_tip_face_id.size() == 2) // combine the two frag faces on this elem face
214  combine_two_faces(frag_tip_face_id[0], frag_tip_face_id[1], _host_elem->getFace(i));
215  }
216  // TODO: may need to combine other frag faces that have tip edges
217 }
EFAFace * getFace(unsigned int face_id) const
unsigned int numFaces() const
bool containsFace(const EFAFace *other_face) const
Definition: EFAFace.C:417
EFAElement3D * _host_elem
Definition: EFAFragment3D.h:31
void combine_two_faces(unsigned int face_id1, unsigned int face_id2, const EFAFace *elem_face)
std::vector< EFAFace * > _faces
Definition: EFAFragment3D.h:32

◆ combine_two_faces()

void EFAFragment3D::combine_two_faces ( unsigned int  face_id1,
unsigned int  face_id2,
const EFAFace elem_face 
)
private

Definition at line 506 of file EFAFragment3D.C.

Referenced by combine_tip_faces().

509 {
510  // get the new full face
511  EFAFace * full_face = _faces[face_id1]->combineWithFace(_faces[face_id2]);
512  full_face->resetEdgeIntersection(elem_face); // IMPORTANT
513 
514  // take care of the common adjacent faces (combine their tip edges)
515  std::set<EFAFace *> face1_neigh;
516  face1_neigh.insert(_faces_adjacent_to_faces[face_id1].begin(),
517  _faces_adjacent_to_faces[face_id1].end());
518  std::set<EFAFace *> face2_neigh;
519  face2_neigh.insert(_faces_adjacent_to_faces[face_id2].begin(),
520  _faces_adjacent_to_faces[face_id2].end());
521  std::vector<EFAFace *> common_adjacent_faces = Efa::getCommonElems(face1_neigh, face2_neigh);
522 
523  for (unsigned int i = 0; i < common_adjacent_faces.size(); ++i)
524  {
525  EFAFace * comm_face = common_adjacent_faces[i];
526  if (comm_face != NULL)
527  {
528  unsigned int edge_id1 = comm_face->adjacentCommonEdge(_faces[face_id1]);
529  unsigned int edge_id2 = comm_face->adjacentCommonEdge(_faces[face_id2]);
530  comm_face->combineTwoEdges(edge_id1, edge_id2);
531  comm_face->resetEdgeIntersection(elem_face); // IMPORTANT
532  }
533  }
534 
535  // delete old faces and update private members of EFAfragment3D
536  delete _faces[face_id1];
537  delete _faces[face_id2];
538  _faces[face_id1] = full_face;
539  _faces.erase(_faces.begin() + face_id2);
540  findFacesAdjacentToFaces(); // rebuild _adjacent_face_ix: IMPORTANT
541 }
void findFacesAdjacentToFaces()
void resetEdgeIntersection(const EFAFace *ref_face)
Definition: EFAFace.C:554
std::vector< std::vector< EFAFace * > > _faces_adjacent_to_faces
Definition: EFAFragment3D.h:33
void combineTwoEdges(unsigned int edge_id1, unsigned int edge_id2)
Definition: EFAFace.C:288
std::vector< T > getCommonElems(std::set< T > &v1, std::set< T > &v2)
Definition: EFAFuncs.h:70
unsigned int adjacentCommonEdge(const EFAFace *other_face) const
Definition: EFAFace.C:644
std::vector< EFAFace * > _faces
Definition: EFAFragment3D.h:32

◆ connectSubfaces()

EFAFragment3D * EFAFragment3D::connectSubfaces ( EFAFace start_face,
unsigned int  startOldFaceID,
std::vector< std::vector< EFAFace *>> &  subfaces 
)
private

Definition at line 428 of file EFAFragment3D.C.

Referenced by split().

431 {
432  // this method is only called in EFAfragment3D::split()
433  std::vector<bool> contributed(subfaces.size(), false);
434  contributed[startOldFaceID] = true;
435  unsigned int num_contrib_faces = 1;
436  unsigned int old_num_contrib = 1;
437  std::vector<EFAFace *> frag_faces(1, start_face);
438 
439  // collect all subfaces connected to start_face
440  do
441  {
442  old_num_contrib = num_contrib_faces;
443  for (unsigned int i = 0; i < subfaces.size(); ++i)
444  {
445  if (!contributed[i]) // old face not contributed to new fragment yet
446  {
447  bool adjacent_found = false;
448  for (unsigned int j = 0; j < subfaces[i].size(); ++j)
449  {
450  for (unsigned int k = 0; k < frag_faces.size(); ++k)
451  {
452  if (subfaces[i][j]->isAdjacent(frag_faces[k]))
453  {
454  adjacent_found = true;
455  contributed[i] = true;
456  frag_faces.push_back(subfaces[i][j]);
457  num_contrib_faces += 1;
458  break;
459  }
460  } // k
461  if (adjacent_found)
462  break;
463  } // j
464  }
465  } // i, loop over all old faces
466  } while (num_contrib_faces != old_num_contrib);
467 
468  // get the cut plane face
469  std::vector<EFAEdge *> cut_plane_edges;
470  EFAFragment3D * new_frag = new EFAFragment3D(_host_elem, false, NULL);
471  for (unsigned int i = 0; i < frag_faces.size(); ++i)
472  new_frag->addFace(frag_faces[i]);
473  new_frag->findFacesAdjacentToFaces();
474 
475  for (unsigned int i = 0; i < new_frag->numFaces(); ++i)
476  {
477  EFAEdge * lone_edge = new_frag->loneEdgeOnFace(i);
478  if (lone_edge != NULL) // valid edge
479  cut_plane_edges.push_back(new EFAEdge(*lone_edge));
480  }
481 
482  EFAFace * cut_face = new EFAFace(cut_plane_edges.size());
483  for (unsigned int i = 0; i < cut_plane_edges.size(); ++i)
484  cut_face->setEdge(i, cut_plane_edges[i]);
485  cut_face->sortEdges();
486  cut_face->reverseEdges();
487  cut_face->createNodes();
488 
489  // finalize the new fragment
490  new_frag->addFace(cut_face);
491  new_frag->findFacesAdjacentToFaces();
492  return new_frag;
493 }
void setEdge(unsigned int edge_id, EFAEdge *new_edge)
Definition: EFAFace.C:266
void findFacesAdjacentToFaces()
EFAEdge * loneEdgeOnFace(unsigned int face_id) const
EFAFragment3D(EFAElement3D *host, bool create_faces, const EFAElement3D *from_host, unsigned int frag_id=std::numeric_limits< unsigned int >::max())
Definition: EFAFragment3D.C:20
void sortEdges()
Definition: EFAFace.C:329
EFAElement3D * _host_elem
Definition: EFAFragment3D.h:31
void addFace(EFAFace *new_face)
void reverseEdges()
Definition: EFAFace.C:349
void createNodes()
Definition: EFAFace.C:242
unsigned int numFaces() const

◆ containsNode()

bool EFAFragment3D::containsNode ( EFANode node) const
virtual

Implements EFAFragment.

Definition at line 66 of file EFAFragment3D.C.

Referenced by isThirdInteriorFace().

67 {
68  bool contains = false;
69  for (unsigned int i = 0; i < _faces.size(); ++i)
70  {
71  if (_faces[i]->containsNode(node))
72  {
73  contains = true;
74  break;
75  }
76  }
77  return contains;
78 }
virtual bool containsNode(EFANode *node) const
Definition: EFAFragment3D.C:66
std::vector< EFAFace * > _faces
Definition: EFAFragment3D.h:32

◆ findFacesAdjacentToFaces()

void EFAFragment3D::findFacesAdjacentToFaces ( )

Definition at line 362 of file EFAFragment3D.C.

Referenced by combine_two_faces(), connectSubfaces(), EFAFragment3D(), and split().

363 {
364  _faces_adjacent_to_faces.clear();
365  for (unsigned int i = 0; i < _faces.size(); ++i)
366  {
367  std::vector<EFAFace *> face_adjacents(_faces[i]->numEdges(), NULL);
368  for (unsigned int j = 0; j < _faces.size(); ++j)
369  {
370  if (_faces[j] != _faces[i] && _faces[i]->isAdjacent(_faces[j]))
371  {
372  unsigned int adj_edge = _faces[i]->adjacentCommonEdge(_faces[j]);
373  face_adjacents[adj_edge] = _faces[j];
374  }
375  } // j
376  _faces_adjacent_to_faces.push_back(face_adjacents);
377  } // i
378 }
std::vector< std::vector< EFAFace * > > _faces_adjacent_to_faces
Definition: EFAFragment3D.h:33
std::vector< EFAFace * > _faces
Definition: EFAFragment3D.h:32

◆ get_interior_face_id()

std::vector< unsigned int > EFAFragment3D::get_interior_face_id ( ) const

Definition at line 241 of file EFAFragment3D.C.

242 {
243  std::vector<unsigned int> interior_face_id;
244  for (unsigned int i = 0; i < _faces.size(); ++i)
245  {
246  if (isFaceInterior(i))
247  interior_face_id.push_back(i);
248  }
249  return interior_face_id;
250 }
bool isFaceInterior(unsigned int face_id) const
std::vector< EFAFace * > _faces
Definition: EFAFragment3D.h:32

◆ getAdjacentFace()

EFAFace * EFAFragment3D::getAdjacentFace ( unsigned int  face_id,
unsigned int  edge_id 
) const

Definition at line 381 of file EFAFragment3D.C.

382 {
383  return _faces_adjacent_to_faces[face_id][edge_id]; // possibly NULL
384 }
std::vector< std::vector< EFAFace * > > _faces_adjacent_to_faces
Definition: EFAFragment3D.h:33

◆ getAllNodes()

std::set< EFANode * > EFAFragment3D::getAllNodes ( ) const
virtual

Implements EFAFragment.

Definition at line 97 of file EFAFragment3D.C.

Referenced by getNodeInfo().

98 {
99  std::set<EFANode *> all_nodes;
100  for (unsigned int i = 0; i < _faces.size(); ++i)
101  for (unsigned int j = 0; j < _faces[i]->numNodes(); ++j)
102  all_nodes.insert(_faces[i]->getNode(j));
103  return all_nodes;
104 }
std::vector< EFAFace * > _faces
Definition: EFAFragment3D.h:32

◆ getCommonNodes()

std::vector< EFANode * > EFAFragment::getCommonNodes ( EFAFragment other) const
inherited

Definition at line 20 of file EFAFragment.C.

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

21 {
22  std::set<EFANode *> frag1_nodes = getAllNodes();
23  std::set<EFANode *> frag2_nodes = other->getAllNodes();
24  std::vector<EFANode *> common_nodes = Efa::getCommonElems(frag1_nodes, frag2_nodes);
25  return common_nodes;
26 }
virtual std::set< EFANode * > getAllNodes() const =0
std::vector< T > getCommonElems(std::set< T > &v1, std::set< T > &v2)
Definition: EFAFuncs.h:70

◆ getFace()

EFAFace * EFAFragment3D::getFace ( unsigned int  face_id) const

Definition at line 277 of file EFAFragment3D.C.

Referenced by EFAElement3D::createChild(), XFEMCutElem3D::getCutPlaneNormal(), XFEMCutElem3D::getCutPlaneOrigin(), and XFEMCutElem3D::getIntersectionInfo().

278 {
279  if (face_id > _faces.size() - 1)
280  EFAError("in EFAfragment3D::get_face, index out of bounds");
281  return _faces[face_id];
282 }
std::vector< EFAFace * > _faces
Definition: EFAFragment3D.h:32

◆ getFaceID()

unsigned int EFAFragment3D::getFaceID ( EFAFace face) const

Definition at line 285 of file EFAFragment3D.C.

Referenced by removeInvalidEmbeddedNodes().

286 {
287  for (unsigned int i = 0; i < _faces.size(); ++i)
288  if (_faces[i] == face)
289  return i;
290  EFAError("face not found in get_face_id()");
291  return 99999;
292 }
std::vector< EFAFace * > _faces
Definition: EFAFragment3D.h:32

◆ getFaceNodes()

std::set< EFANode * > EFAFragment3D::getFaceNodes ( unsigned int  face_id) const

Definition at line 301 of file EFAFragment3D.C.

302 {
303  std::set<EFANode *> face_nodes;
304  for (unsigned int i = 0; i < _faces[face_id]->numNodes(); ++i)
305  face_nodes.insert(_faces[face_id]->getNode(i));
306  return face_nodes;
307 }
std::vector< EFAFace * > _faces
Definition: EFAFragment3D.h:32

◆ getHostElement()

EFAElement3D * EFAFragment3D::getHostElement ( ) const

Definition at line 310 of file EFAFragment3D.C.

311 {
312  return _host_elem;
313 }
EFAElement3D * _host_elem
Definition: EFAFragment3D.h:31

◆ getNodeInfo()

void EFAFragment3D::getNodeInfo ( std::vector< std::vector< unsigned int >> &  face_node_indices,
std::vector< EFANode *> &  nodes 
) const

Definition at line 404 of file EFAFragment3D.C.

Referenced by XFEMCutElem3D::computePhysicalFaceAreaFraction(), and XFEMCutElem3D::computePhysicalVolumeFraction().

406 {
407  // get all nodes' pointers - a vector
408  std::set<EFANode *> all_node_set = getAllNodes();
409  nodes.resize(all_node_set.size());
410  std::copy(all_node_set.begin(), all_node_set.end(), nodes.begin());
411 
412  // get face connectivity
413  face_node_indices.clear();
414  for (unsigned int i = 0; i < _faces.size(); ++i)
415  {
416  std::vector<unsigned int> line_face_indices;
417  for (unsigned int j = 0; j < _faces[i]->numNodes(); ++j)
418  {
419  EFANode * node = _faces[i]->getNode(j);
420  unsigned int vec_index = std::find(nodes.begin(), nodes.end(), node) - nodes.begin();
421  line_face_indices.push_back(vec_index);
422  }
423  face_node_indices.push_back(line_face_indices);
424  }
425 }
std::vector< EFAFace * > _faces
Definition: EFAFragment3D.h:32
virtual std::set< EFANode * > getAllNodes() const
Definition: EFAFragment3D.C:97

◆ getNumCutNodes()

unsigned int EFAFragment3D::getNumCutNodes ( ) const
virtual

Implements EFAFragment.

Definition at line 91 of file EFAFragment3D.C.

92 {
93  mooseError("Not implemented yet for 3D.");
94 }

◆ getNumCuts()

unsigned int EFAFragment3D::getNumCuts ( ) const
virtual

Implements EFAFragment.

Definition at line 81 of file EFAFragment3D.C.

Referenced by hasFaceWithOneCut().

82 {
83  unsigned int num_cut_faces = 0;
84  for (unsigned int i = 0; i < _faces.size(); ++i)
85  if (_faces[i]->hasIntersection())
86  num_cut_faces += 1;
87  return num_cut_faces;
88 }
std::vector< EFAFace * > _faces
Definition: EFAFragment3D.h:32

◆ hasFaceWithOneCut()

bool EFAFragment3D::hasFaceWithOneCut ( ) const

Definition at line 394 of file EFAFragment3D.C.

Referenced by removeInvalidEmbeddedNodes(), and split().

395 {
396  // N.B. this method can only be implemented when the fragment has just been marked
397  for (unsigned int i = 0; i < _faces.size(); ++i)
398  if (_faces[i]->getNumCuts() == 1)
399  return true;
400  return false;
401 }
virtual unsigned int getNumCuts() const
Definition: EFAFragment3D.C:81
std::vector< EFAFace * > _faces
Definition: EFAFragment3D.h:32

◆ isConnected()

bool EFAFragment3D::isConnected ( EFAFragment other_fragment) const
virtual

Implements EFAFragment.

Definition at line 107 of file EFAFragment3D.C.

108 {
109  bool is_connected = false;
110  EFAFragment3D * other_frag3d = dynamic_cast<EFAFragment3D *>(other_fragment);
111  if (!other_frag3d)
112  EFAError("in isConnected other_fragment is not of type EFAfragement3D");
113 
114  for (unsigned int i = 0; i < _faces.size(); ++i)
115  {
116  for (unsigned int j = 0; j < other_frag3d->numFaces(); ++j)
117  {
118  if (_faces[i]->equivalent(other_frag3d->_faces[j]))
119  {
120  is_connected = true;
121  break;
122  }
123  }
124  if (is_connected)
125  break;
126  } // i
127  return is_connected;
128 }
std::vector< EFAFace * > _faces
Definition: EFAFragment3D.h:32
unsigned int numFaces() const

◆ isEdgeConnected()

bool EFAFragment3D::isEdgeConnected ( EFAFragment other_fragment) const
virtual

Definition at line 131 of file EFAFragment3D.C.

132 {
133  EFAFragment3D * other_frag3d = dynamic_cast<EFAFragment3D *>(other_fragment);
134  if (!other_frag3d)
135  EFAError("in isEdgeConnected other_fragment is not of type EFAfragement3D");
136 
137  for (unsigned int i = 0; i < _faces.size(); ++i)
138  for (unsigned int j = 0; j < _faces[i]->numEdges(); ++j)
139  for (unsigned int k = 0; k < other_frag3d->numFaces(); ++k)
140  for (unsigned int l = 0; l < other_frag3d->_faces[k]->numEdges(); ++l)
141  if (_faces[i]->getEdge(j)->equivalent(*(other_frag3d->_faces[k]->getEdge(l))))
142  return true;
143 
144  return false;
145 }
std::vector< EFAFace * > _faces
Definition: EFAFragment3D.h:32
unsigned int numFaces() const

◆ isFaceInterior()

bool EFAFragment3D::isFaceInterior ( unsigned int  face_id) const

Definition at line 220 of file EFAFragment3D.C.

Referenced by EFAElement3D::createChild(), get_interior_face_id(), XFEMCutElem3D::getCutPlaneNormal(), XFEMCutElem3D::getCutPlaneOrigin(), XFEMCutElem3D::getIntersectionInfo(), XFEMCutElem3D::numCutPlanes(), and removeInvalidEmbeddedNodes().

221 {
222  if (!_host_elem)
223  EFAError("in isFaceInterior() fragment must have host elem");
224 
225  bool face_in_elem_face = false;
226  for (unsigned int i = 0; i < _host_elem->numFaces(); ++i)
227  {
228  if (_host_elem->getFace(i)->containsFace(_faces[face_id]))
229  {
230  face_in_elem_face = true;
231  break;
232  }
233  }
234  if (!face_in_elem_face)
235  return true; // yes, is interior
236  else
237  return false;
238 }
EFAFace * getFace(unsigned int face_id) const
unsigned int numFaces() const
bool containsFace(const EFAFace *other_face) const
Definition: EFAFace.C:417
EFAElement3D * _host_elem
Definition: EFAFragment3D.h:31
std::vector< EFAFace * > _faces
Definition: EFAFragment3D.h:32

◆ isThirdInteriorFace()

bool EFAFragment3D::isThirdInteriorFace ( unsigned int  face_id) const

Definition at line 253 of file EFAFragment3D.C.

Referenced by XFEM::markCutFacesByGeometry().

254 {
255  bool is_third_cut = false;
256  if (!_host_elem)
257  EFAError("in isThirdInteriorFace fragment must have host elem");
258 
259  for (unsigned int i = 0; i < _host_elem->numInteriorNodes(); ++i)
260  {
261  if (_faces[face_id]->containsNode(_host_elem->getInteriorNode(i)->getNode()))
262  {
263  is_third_cut = true;
264  break;
265  }
266  }
267  return is_third_cut;
268 }
virtual bool containsNode(EFANode *node) const
Definition: EFAFragment3D.C:66
virtual unsigned int numInteriorNodes() const
Definition: EFAElement3D.C:425
EFAElement3D * _host_elem
Definition: EFAFragment3D.h:31
EFANode * getNode()
Definition: EFAVolumeNode.C:31
std::vector< EFAFace * > _faces
Definition: EFAFragment3D.h:32
EFAVolumeNode * getInteriorNode(unsigned int interior_node_id) const

◆ loneEdgeOnFace()

EFAEdge * EFAFragment3D::loneEdgeOnFace ( unsigned int  face_id) const
private

Definition at line 496 of file EFAFragment3D.C.

Referenced by connectSubfaces().

497 {
498  // if any face edge is not shared by any other face, we call it a lone edge
499  for (unsigned int i = 0; i < _faces[face_id]->numEdges(); ++i)
500  if (_faces_adjacent_to_faces[face_id][i] == NULL)
501  return _faces[face_id]->getEdge(i);
502  return NULL;
503 }
std::vector< std::vector< EFAFace * > > _faces_adjacent_to_faces
Definition: EFAFragment3D.h:33
std::vector< EFAFace * > _faces
Definition: EFAFragment3D.h:32

◆ numFaces()

unsigned int EFAFragment3D::numFaces ( ) const

◆ removeEmbeddedNode()

void EFAFragment3D::removeEmbeddedNode ( EFANode emb_node)

Definition at line 387 of file EFAFragment3D.C.

388 {
389  for (unsigned int i = 0; i < _faces.size(); ++i)
390  _faces[i]->removeEmbeddedNode(emb_node);
391 }
void removeEmbeddedNode(EFANode *emb_node)
std::vector< EFAFace * > _faces
Definition: EFAFragment3D.h:32

◆ removeInvalidEmbeddedNodes()

void EFAFragment3D::removeInvalidEmbeddedNodes ( std::map< unsigned int, EFANode *> &  EmbeddedNodes)
virtual

Implements EFAFragment.

Definition at line 148 of file EFAFragment3D.C.

149 {
150  // N.B. this method is only called before we update fragments
151  // N.B. an embedded node is valid IF at least one of its host faces is exterior and has more than
152  // 1 cuts
153  // TODO: the invalid cases are generalized from 2D. The method may need improvements in 3D
154  if (hasFaceWithOneCut())
155  {
156  // build a local inverse map for all emb cut nodes in this fragment
157  std::map<EFANode *, std::vector<EFAFace *>> emb_inverse_map;
158  for (unsigned int i = 0; i < _faces.size(); ++i)
159  {
160  for (unsigned int j = 0; j < _faces[i]->numEdges(); ++j)
161  {
162  if (_faces[i]->getEdge(j)->hasIntersection())
163  {
164  EFANode * emb_node = _faces[i]->getEdge(j)->getEmbeddedNode(0);
165  emb_inverse_map[emb_node].push_back(_faces[i]);
166  }
167  } // i
168  } // j
169 
170  // find all invalid embedded nodes
171  std::vector<EFANode *> invalid_emb;
172  std::map<EFANode *, std::vector<EFAFace *>>::iterator it;
173  for (it = emb_inverse_map.begin(); it != emb_inverse_map.end(); ++it)
174  {
175  EFANode * emb_node = it->first;
176  std::vector<EFAFace *> & emb_faces = it->second;
177  if (emb_faces.size() != 2)
178  EFAError("one embedded node must be owned by 2 faces");
179  unsigned int counter = 0;
180  for (unsigned int i = 0; i < emb_faces.size(); ++i)
181  {
182  unsigned int face_id = getFaceID(emb_faces[i]);
183  if (!isFaceInterior(face_id) && emb_faces[i]->hasIntersection())
184  counter += 1; // count the appropriate emb's faces
185  }
186  if (counter == 0)
187  invalid_emb.push_back(emb_node);
188  }
189 
190  // delete all invalid emb nodes
191  for (unsigned int i = 0; i < invalid_emb.size(); ++i)
192  {
193  Efa::deleteFromMap(EmbeddedNodes, invalid_emb[i]);
194  _host_elem->removeEmbeddedNode(invalid_emb[i], true); // also remove from neighbors
195  } // i
196  }
197 }
unsigned int getFaceID(EFAFace *face) const
bool deleteFromMap(std::map< unsigned int, T *> &theMap, T *elemToDelete, bool delete_elem=true)
Definition: EFAFuncs.h:23
bool isFaceInterior(unsigned int face_id) const
EFAElement3D * _host_elem
Definition: EFAFragment3D.h:31
void removeEmbeddedNode(EFANode *emb_node, bool remove_for_neighbor)
bool hasFaceWithOneCut() const
std::vector< EFAFace * > _faces
Definition: EFAFragment3D.h:32
static unsigned int counter

◆ split()

std::vector< EFAFragment3D * > EFAFragment3D::split ( )

Definition at line 316 of file EFAFragment3D.C.

317 {
318  // This method will split one existing fragment into one or two new fragments
319  std::vector<EFAFragment3D *> new_fragments;
320  std::vector<std::vector<EFAFace *>> all_subfaces;
321  for (unsigned int i = 0; i < _faces.size(); ++i)
322  {
323  std::vector<EFAFace *> subfaces = _faces[i]->split();
324  all_subfaces.push_back(subfaces);
325  }
326 
327  // build new frags
328  if (hasFaceWithOneCut()) // "fakely" cut fragment
329  {
330  EFAFragment3D * new_frag = new EFAFragment3D(_host_elem, false, NULL);
331  for (unsigned int i = 0; i < all_subfaces.size(); ++i)
332  for (unsigned int j = 0; j < all_subfaces[i].size(); ++j)
333  new_frag->addFace(all_subfaces[i][j]);
334  new_frag->findFacesAdjacentToFaces();
335  new_fragments.push_back(new_frag);
336  }
337  else // thoroughly cut fragment
338  {
339  // find the first face with 2 sub-faces
340  EFAFace * start_face1 = NULL;
341  EFAFace * start_face2 = NULL;
342  unsigned int startOldFaceID = 0;
343  for (unsigned int i = 0; i < _faces.size(); ++i)
344  {
345  if (all_subfaces[i].size() == 2)
346  {
347  start_face1 = all_subfaces[i][0];
348  start_face2 = all_subfaces[i][1];
349  startOldFaceID = i;
350  break;
351  }
352  } // i
353  EFAFragment3D * new_frag1 = connectSubfaces(start_face1, startOldFaceID, all_subfaces);
354  EFAFragment3D * new_frag2 = connectSubfaces(start_face2, startOldFaceID, all_subfaces);
355  new_fragments.push_back(new_frag1);
356  new_fragments.push_back(new_frag2);
357  }
358  return new_fragments;
359 }
void findFacesAdjacentToFaces()
EFAFragment3D(EFAElement3D *host, bool create_faces, const EFAElement3D *from_host, unsigned int frag_id=std::numeric_limits< unsigned int >::max())
Definition: EFAFragment3D.C:20
EFAFragment3D * connectSubfaces(EFAFace *start_face, unsigned int startOldFaceID, std::vector< std::vector< EFAFace *>> &subfaces)
EFAElement3D * _host_elem
Definition: EFAFragment3D.h:31
void addFace(EFAFace *new_face)
bool hasFaceWithOneCut() const
std::vector< EFAFace * > _faces
Definition: EFAFragment3D.h:32

◆ switchNode()

void EFAFragment3D::switchNode ( EFANode new_node,
EFANode old_node 
)
virtual

Implements EFAFragment.

Definition at line 59 of file EFAFragment3D.C.

60 {
61  for (unsigned int i = 0; i < _faces.size(); ++i)
62  _faces[i]->switchNode(new_node, old_node);
63 }
virtual void switchNode(EFANode *new_node, EFANode *old_node)
Definition: EFAFragment3D.C:59
std::vector< EFAFace * > _faces
Definition: EFAFragment3D.h:32

Member Data Documentation

◆ _faces

std::vector<EFAFace *> EFAFragment3D::_faces
private

◆ _faces_adjacent_to_faces

std::vector<std::vector<EFAFace *> > EFAFragment3D::_faces_adjacent_to_faces
private

◆ _host_elem

EFAElement3D* EFAFragment3D::_host_elem
private

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