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

#include <EFAFace.h>

Public Member Functions

 EFAFace (unsigned int n_nodes, unsigned int num_interior_face_nodes=0)
 
 EFAFace (const EFAFace &other_face)
 
 EFAFace (const EFAFragment2D *frag)
 
 ~EFAFace ()
 
unsigned int numNodes () const
 
void setNode (unsigned int node_id, EFANode *node)
 
EFANodegetNode (unsigned int node_id) const
 
void switchNode (EFANode *new_node, EFANode *old_node)
 
bool getMasterInfo (EFANode *node, std::vector< EFANode *> &master_nodes, std::vector< double > &master_weights) const
 
bool getEdgeNodeParametricCoords (EFANode *node, std::vector< double > &xi_2d) const
 
bool getFaceNodeParametricCoords (EFANode *node, std::vector< double > &xi_2d) const
 
unsigned int numInteriorNodes () const
 
void createNodes ()
 
unsigned int numEdges () const
 
EFAEdgegetEdge (unsigned int edge_id) const
 
void setEdge (unsigned int edge_id, EFAEdge *new_edge)
 
void createEdges ()
 
void combineTwoEdges (unsigned int edge_id1, unsigned int edge_id2)
 
void sortEdges ()
 
void reverseEdges ()
 
bool isTriOrQuad () const
 
EFANodegetInteriorFaceNode (unsigned int i) const
 
void setInteriorFaceNode (unsigned int i, EFANode *node)
 
bool equivalent (const EFAFace *other_face) const
 
bool containsNode (const EFANode *node) const
 
bool containsFace (const EFAFace *other_face) const
 
bool ownsEdge (const EFAEdge *other_edge) const
 
void removeEmbeddedNode (EFANode *emb_node)
 
std::vector< EFAFace * > split () const
 
EFAFacecombineWithFace (const EFAFace *other_face) const
 
void resetEdgeIntersection (const EFAFace *ref_face)
 
unsigned int getNumCuts () const
 
bool hasIntersection () const
 
void copyIntersection (const EFAFace &from_face)
 
bool isAdjacent (const EFAFace *other_face) const
 
unsigned int adjacentCommonEdge (const EFAFace *other_face) const
 
bool hasSameOrientation (const EFAFace *other_face) const
 
EFAFaceNodegetInteriorNode (unsigned int index) const
 

Private Member Functions

void mapParametricCoordsFrom1DTo2D (unsigned int edge_id, double xi_1d, std::vector< double > &xi_2d) const
 

Private Attributes

unsigned int _num_nodes
 
std::vector< EFANode * > _nodes
 
unsigned int _num_edges
 
std::vector< EFAEdge * > _edges
 
std::vector< EFAFaceNode * > _interior_nodes
 
std::vector< EFANode * > _face_interior_nodes
 

Detailed Description

Definition at line 20 of file EFAFace.h.

Constructor & Destructor Documentation

◆ EFAFace() [1/3]

EFAFace::EFAFace ( unsigned int  n_nodes,
unsigned int  num_interior_face_nodes = 0 
)

Definition at line 19 of file EFAFace.C.

Referenced by combineWithFace(), and split().

20  : _num_nodes(n_nodes),
21  _nodes(_num_nodes, NULL),
23  _edges(_num_edges, NULL),
24  _face_interior_nodes(num_interior_face_nodes, NULL)
25 {
26 }
std::vector< EFAEdge * > _edges
Definition: EFAFace.h:33
std::vector< EFANode * > _face_interior_nodes
Definition: EFAFace.h:35
unsigned int _num_edges
Definition: EFAFace.h:32
std::vector< EFANode * > _nodes
Definition: EFAFace.h:31
unsigned int _num_nodes
Definition: EFAFace.h:30

◆ EFAFace() [2/3]

EFAFace::EFAFace ( const EFAFace other_face)

Definition at line 28 of file EFAFace.C.

29  : _num_nodes(other_face._num_nodes),
30  _nodes(_num_nodes, NULL),
32  _edges(_num_edges, NULL)
33 {
34  for (unsigned int k = 0; k < other_face._num_nodes; ++k)
35  {
36  _nodes[k] = other_face._nodes[k];
37  _edges[k] = new EFAEdge(*other_face._edges[k]);
38  }
39  for (unsigned int k = 0; k < other_face._interior_nodes.size(); ++k)
40  _interior_nodes.push_back(new EFAFaceNode(*other_face._interior_nodes[k]));
41 }
std::vector< EFAEdge * > _edges
Definition: EFAFace.h:33
unsigned int _num_edges
Definition: EFAFace.h:32
std::vector< EFAFaceNode * > _interior_nodes
Definition: EFAFace.h:34
std::vector< EFANode * > _nodes
Definition: EFAFace.h:31
unsigned int _num_nodes
Definition: EFAFace.h:30

◆ EFAFace() [3/3]

EFAFace::EFAFace ( const EFAFragment2D frag)

Definition at line 43 of file EFAFace.C.

44  : _num_nodes(frag->numEdges()),
45  _nodes(_num_nodes, NULL),
47  _edges(_num_edges, NULL)
48 {
49  for (unsigned int k = 0; k < frag->numEdges(); ++k)
50  {
51  EFANode * node = frag->getEdge(k)->getNode(0);
52  unsigned int kprev(k > 0 ? (k - 1) : (frag->numEdges() - 1));
53  if (!frag->getEdge(kprev)->containsNode(node))
54  node = getEdge(k)->getNode(1);
55  _nodes[k] = node;
56  _edges[k] = new EFAEdge(*frag->getEdge(k));
57  }
58 }
unsigned int numEdges() const
std::vector< EFAEdge * > _edges
Definition: EFAFace.h:33
EFAEdge * getEdge(unsigned int edge_id) const
Definition: EFAFace.C:260
unsigned int _num_edges
Definition: EFAFace.h:32
bool containsNode(const EFANode *node) const
Definition: EFAEdge.C:377
std::vector< EFANode * > _nodes
Definition: EFAFace.h:31
EFAEdge * getEdge(unsigned int edge_id) const
EFANode * getNode(unsigned int index) const
Definition: EFAEdge.C:179
unsigned int _num_nodes
Definition: EFAFace.h:30

◆ ~EFAFace()

EFAFace::~EFAFace ( )

Definition at line 60 of file EFAFace.C.

61 {
62  for (unsigned int i = 0; i < _edges.size(); ++i)
63  {
64  if (_edges[i])
65  {
66  delete _edges[i];
67  _edges[i] = NULL;
68  }
69  }
70  for (unsigned int i = 0; i < _interior_nodes.size(); ++i)
71  {
72  if (_interior_nodes[i])
73  {
74  delete _interior_nodes[i];
75  _interior_nodes[i] = NULL;
76  }
77  }
78 }
std::vector< EFAEdge * > _edges
Definition: EFAFace.h:33
std::vector< EFAFaceNode * > _interior_nodes
Definition: EFAFace.h:34

Member Function Documentation

◆ adjacentCommonEdge()

unsigned int EFAFace::adjacentCommonEdge ( const EFAFace other_face) const

Definition at line 644 of file EFAFace.C.

Referenced by EFAElement3D::addFaceEdgeCut(), EFAFragment3D::combine_two_faces(), and combineWithFace().

645 {
646  if (isAdjacent(other_face))
647  {
648  for (unsigned int i = 0; i < _num_edges; ++i)
649  if (other_face->ownsEdge(_edges[i]))
650  return i;
651  }
652  else
653  EFAError("this face is not adjacent with other_face");
654  return 99999;
655 }
bool isAdjacent(const EFAFace *other_face) const
Definition: EFAFace.C:629
std::vector< EFAEdge * > _edges
Definition: EFAFace.h:33
bool ownsEdge(const EFAEdge *other_edge) const
Definition: EFAFace.C:432
unsigned int _num_edges
Definition: EFAFace.h:32

◆ combineTwoEdges()

void EFAFace::combineTwoEdges ( unsigned int  edge_id1,
unsigned int  edge_id2 
)

Definition at line 288 of file EFAFace.C.

Referenced by EFAFragment3D::combine_two_faces().

289 {
290  if (_edges[edge_id1]->containsNode(_edges[edge_id2]->getNode(0)) ||
291  _edges[edge_id1]->containsNode(_edges[edge_id2]->getNode(1)))
292  {
293  // edge_id1 must precede edge_id2
294  unsigned int edge1_next(edge_id1 < (_num_edges - 1) ? edge_id1 + 1 : 0);
295  if (edge1_next != edge_id2) // if not, swap
296  {
297  unsigned int itmp = edge_id1;
298  edge_id1 = edge_id2;
299  edge_id2 = itmp;
300  }
301 
302  // build new edge and delete old ones
303  EFANode * new_node1 = _edges[edge_id1]->getNode(0);
304  EFANode * emb_node = _edges[edge_id1]->getNode(1);
305  EFANode * new_node2 = _edges[edge_id2]->getNode(1);
306  if (emb_node != _edges[edge_id2]->getNode(0))
307  EFAError("in combine_two_edges face edges are not correctly set up");
308 
309  EFAEdge * full_edge = new EFAEdge(new_node1, new_node2);
310  full_edge->addIntersection(-1.0, emb_node, new_node1); // dummy intersection_x
311 
312  delete _edges[edge_id1];
313  delete _edges[edge_id2];
314  _edges[edge_id1] = full_edge;
315  _edges.erase(_edges.begin() + edge_id2);
316 
317  // update face memeber variables
318  _num_edges -= 1;
319  _num_nodes -= 1;
320  _nodes.resize(_num_nodes, NULL);
321  for (unsigned int k = 0; k < _num_edges; ++k)
322  _nodes[k] = _edges[k]->getNode(0);
323  }
324  else
325  EFAError("two edges to be combined are not ajacent to each other");
326 }
bool containsNode(const EFANode *node) const
Definition: EFAFace.C:391
std::vector< EFAEdge * > _edges
Definition: EFAFace.h:33
EFANode * getNode(unsigned int node_id) const
Definition: EFAFace.C:99
unsigned int _num_edges
Definition: EFAFace.h:32
std::vector< EFANode * > _nodes
Definition: EFAFace.h:31
void addIntersection(double position, EFANode *embedded_node_tmp, EFANode *from_node)
Definition: EFAEdge.C:130
unsigned int _num_nodes
Definition: EFAFace.h:30

◆ combineWithFace()

EFAFace * EFAFace::combineWithFace ( const EFAFace other_face) const

Definition at line 490 of file EFAFace.C.

491 {
492  // combine this face with another adjacent face
493  EFAFace * new_face = NULL;
494  if (isAdjacent(other_face))
495  {
496  unsigned int this_common_edge_id = adjacentCommonEdge(other_face);
497  std::vector<EFANode *> common_nodes;
498  common_nodes.push_back(_edges[this_common_edge_id]->getNode(0));
499  common_nodes.push_back(_edges[this_common_edge_id]->getNode(1));
500 
501  unsigned int other_common_edge_id = other_face->adjacentCommonEdge(this);
502  unsigned int new_n_nodes = _num_edges + other_face->_num_edges - 4;
503  EFAFragment2D * new_frag = new EFAFragment2D(NULL, false, NULL); // temp fragment
504 
505  unsigned int this_edge_id0(this_common_edge_id > 0 ? this_common_edge_id - 1
506  : _num_edges - 1); // common_nodes[0]
507  unsigned int this_edge_id1(this_common_edge_id < (_num_edges - 1) ? this_common_edge_id + 1
508  : 0); // common_nodes[1]
509  unsigned int other_edge_id0(
510  other_common_edge_id < (other_face->_num_edges - 1) ? other_common_edge_id + 1 : 0);
511  unsigned int other_edge_id1(other_common_edge_id > 0 ? other_common_edge_id - 1
512  : other_face->_num_edges - 1);
513 
514  EFAEdge * new_edge0 = new EFAEdge(_edges[this_edge_id0]->getNode(0),
515  other_face->_edges[other_edge_id0]->getNode(1));
516  new_edge0->addIntersection(
517  -1.0, common_nodes[0], new_edge0->getNode(0)); // dummy intersection_x
518  new_frag->addEdge(new_edge0); // common_nodes[0]'s edge
519 
520  unsigned int other_iedge(other_edge_id0 < (other_face->_num_edges - 1) ? other_edge_id0 + 1
521  : 0);
522  while (!other_face->_edges[other_iedge]->equivalent(*other_face->_edges[other_edge_id1]))
523  {
524  new_frag->addEdge(new EFAEdge(*other_face->_edges[other_iedge]));
525  other_iedge += 1;
526  if (other_iedge == other_face->_num_edges)
527  other_iedge = 0;
528  } // loop over other_face's edges
529 
530  EFAEdge * new_edge1 = new EFAEdge(other_face->_edges[other_edge_id1]->getNode(0),
531  _edges[this_edge_id1]->getNode(1));
532  new_edge1->addIntersection(
533  -1.0, common_nodes[1], new_edge1->getNode(0)); // dummy intersection_x
534  new_frag->addEdge(new_edge1);
535 
536  unsigned int this_iedge(this_edge_id1 < (_num_edges - 1) ? this_edge_id1 + 1 : 0);
537  while (!_edges[this_iedge]->equivalent(*_edges[this_edge_id0])) // common_nodes[1]'s edge
538  {
539  new_frag->addEdge(new EFAEdge(*_edges[this_iedge]));
540  this_iedge += 1;
541  if (this_iedge == _num_edges)
542  this_iedge = 0;
543  } // loop over this_face's edges
544 
545  new_face = new EFAFace(new_frag);
546  delete new_frag;
547  if (new_face->numNodes() != new_n_nodes)
548  EFAError("combine_with() sanity check fails");
549  }
550  return new_face;
551 }
bool isAdjacent(const EFAFace *other_face) const
Definition: EFAFace.C:629
void addEdge(EFAEdge *new_edge)
bool equivalent(const EFAFace *other_face) const
Definition: EFAFace.C:367
std::vector< EFAEdge * > _edges
Definition: EFAFace.h:33
EFANode * getNode(unsigned int node_id) const
Definition: EFAFace.C:99
unsigned int numNodes() const
Definition: EFAFace.C:87
unsigned int _num_edges
Definition: EFAFace.h:32
void addIntersection(double position, EFANode *embedded_node_tmp, EFANode *from_node)
Definition: EFAEdge.C:130
unsigned int adjacentCommonEdge(const EFAFace *other_face) const
Definition: EFAFace.C:644
EFAFace(unsigned int n_nodes, unsigned int num_interior_face_nodes=0)
Definition: EFAFace.C:19
EFANode * getNode(unsigned int index) const
Definition: EFAEdge.C:179

◆ containsFace()

bool EFAFace::containsFace ( const EFAFace other_face) const

Definition at line 417 of file EFAFace.C.

Referenced by EFAFragment3D::combine_tip_faces(), and EFAFragment3D::isFaceInterior().

418 {
419  unsigned int counter = 0;
420  for (unsigned int i = 0; i < other_face->_num_nodes; ++i)
421  {
422  if (containsNode(other_face->_nodes[i]))
423  counter += 1;
424  }
425  if (counter == other_face->_num_nodes)
426  return true;
427  else
428  return false;
429 }
bool containsNode(const EFANode *node) const
Definition: EFAFace.C:391
std::vector< EFANode * > _nodes
Definition: EFAFace.h:31
static unsigned int counter
unsigned int _num_nodes
Definition: EFAFace.h:30

◆ containsNode()

bool EFAFace::containsNode ( const EFANode node) const

Definition at line 391 of file EFAFace.C.

Referenced by combineTwoEdges(), XFEMCutElem3D::computePhysicalFaceAreaFraction(), containsFace(), getEdgeNodeParametricCoords(), getMasterInfo(), and sortEdges().

392 {
393  bool contains = false;
394  for (unsigned int i = 0; i < _num_edges; ++i)
395  {
396  if (_edges[i]->containsNode(node))
397  {
398  contains = true;
399  break;
400  }
401  }
402  if (!contains)
403  {
404  for (unsigned int i = 0; i < _interior_nodes.size(); ++i)
405  {
406  if (_interior_nodes[i]->getNode() == node)
407  {
408  contains = true;
409  break;
410  }
411  }
412  }
413  return contains;
414 }
bool containsNode(const EFANode *node) const
Definition: EFAFace.C:391
std::vector< EFAEdge * > _edges
Definition: EFAFace.h:33
EFANode * getNode(unsigned int node_id) const
Definition: EFAFace.C:99
unsigned int _num_edges
Definition: EFAFace.h:32
std::vector< EFAFaceNode * > _interior_nodes
Definition: EFAFace.h:34

◆ copyIntersection()

void EFAFace::copyIntersection ( const EFAFace from_face)

Definition at line 618 of file EFAFace.C.

619 {
620  for (unsigned int i = 0; i < _edges.size(); ++i)
621  if (from_face._edges[i]->hasIntersection())
622  _edges[i]->copyIntersection(*from_face._edges[i], 0);
623 
624  if (from_face.numInteriorNodes() > 0)
625  _interior_nodes = from_face._interior_nodes;
626 }
void copyIntersection(const EFAFace &from_face)
Definition: EFAFace.C:618
std::vector< EFAEdge * > _edges
Definition: EFAFace.h:33
std::vector< EFAFaceNode * > _interior_nodes
Definition: EFAFace.h:34
unsigned int numInteriorNodes() const
Definition: EFAFace.C:236

◆ createEdges()

void EFAFace::createEdges ( )

Definition at line 272 of file EFAFace.C.

273 {
274  for (unsigned int i = 0; i < _num_nodes; ++i)
275  {
276  unsigned int i_plus1(i < (_num_nodes - 1) ? i + 1 : 0);
277  if (_nodes[i] != NULL && _nodes[i_plus1] != NULL)
278  {
279  EFAEdge * new_edge = new EFAEdge(_nodes[i], _nodes[i_plus1]);
280  _edges[i] = new_edge;
281  }
282  else
283  EFAError("EFAface::createEdges requires exsiting _nodes");
284  }
285 }
std::vector< EFAEdge * > _edges
Definition: EFAFace.h:33
std::vector< EFANode * > _nodes
Definition: EFAFace.h:31
unsigned int _num_nodes
Definition: EFAFace.h:30

◆ createNodes()

void EFAFace::createNodes ( )

Definition at line 242 of file EFAFace.C.

Referenced by EFAFragment3D::connectSubfaces().

243 {
244  for (unsigned int i = 0; i < _edges.size(); ++i)
245  {
246  if (_edges[i] != NULL)
247  _nodes[i] = _edges[i]->getNode(0);
248  else
249  EFAError("in EFAface::createNodes() _edges[i] does not exist");
250  }
251 }
std::vector< EFAEdge * > _edges
Definition: EFAFace.h:33
std::vector< EFANode * > _nodes
Definition: EFAFace.h:31

◆ equivalent()

bool EFAFace::equivalent ( const EFAFace other_face) const

Definition at line 367 of file EFAFace.C.

Referenced by combineWithFace(), hasSameOrientation(), ownsEdge(), EFAElement3D::shouldDuplicateForPhantomCorner(), and sortEdges().

368 {
369  unsigned int counter = 0; // counter number of equal nodes
370  bool overlap = false;
371  if (_num_nodes == other_face->_num_nodes)
372  {
373  for (unsigned int i = 0; i < _num_nodes; ++i)
374  {
375  for (unsigned int j = 0; j < other_face->_num_nodes; ++j)
376  {
377  if (_nodes[i] == other_face->_nodes[j])
378  {
379  counter += 1;
380  break;
381  }
382  } // j
383  } // i
384  if (counter == _num_nodes)
385  overlap = true;
386  }
387  return overlap;
388 }
std::vector< EFANode * > _nodes
Definition: EFAFace.h:31
static unsigned int counter
unsigned int _num_nodes
Definition: EFAFace.h:30

◆ getEdge()

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

◆ getEdgeNodeParametricCoords()

bool EFAFace::getEdgeNodeParametricCoords ( EFANode node,
std::vector< double > &  xi_2d 
) const

Definition at line 183 of file EFAFace.C.

Referenced by getFaceNodeParametricCoords().

184 {
185  // get the parametric coords of a node in an edge
186  bool edge_found = false;
187  unsigned int edge_id;
188  if (!isTriOrQuad())
189  EFAError("EFAface::getEdgeNodeParaCoor can only work for quad or tri faces");
190 
191  for (unsigned int i = 0; i < _num_edges; ++i)
192  {
193  if (_edges[i]->containsNode(node))
194  {
195  edge_id = i;
196  edge_found = true;
197  break;
198  }
199  }
200  if (edge_found)
201  {
202  double rel_dist = _edges[edge_id]->distanceFromNode1(node);
203  double xi_1d = 2.0 * rel_dist - 1.0; // translate to [-1,1] parent coord syst
204  mapParametricCoordsFrom1DTo2D(edge_id, xi_1d, xi_2d);
205  }
206  return edge_found;
207 }
bool containsNode(const EFANode *node) const
Definition: EFAFace.C:391
void mapParametricCoordsFrom1DTo2D(unsigned int edge_id, double xi_1d, std::vector< double > &xi_2d) const
Definition: EFAFace.C:690
bool isTriOrQuad() const
Definition: EFAFace.C:358
std::vector< EFAEdge * > _edges
Definition: EFAFace.h:33
unsigned int _num_edges
Definition: EFAFace.h:32

◆ getFaceNodeParametricCoords()

bool EFAFace::getFaceNodeParametricCoords ( EFANode node,
std::vector< double > &  xi_2d 
) const

Definition at line 210 of file EFAFace.C.

Referenced by resetEdgeIntersection().

211 {
212  bool node_in_face = false;
213  if (!isTriOrQuad())
214  EFAError("EFAface::getFaceNodeParaCoor can only work for quad or tri faces");
215 
216  if (getEdgeNodeParametricCoords(node, xi_2d))
217  node_in_face = true;
218  else
219  {
220  for (unsigned int i = 0; i < _interior_nodes.size(); ++i)
221  {
222  if (_interior_nodes[i]->getNode() == node)
223  {
224  xi_2d.resize(2, 0.0);
225  xi_2d[0] = _interior_nodes[i]->getParametricCoordinates(0);
226  xi_2d[1] = _interior_nodes[i]->getParametricCoordinates(1);
227  node_in_face = true;
228  break;
229  }
230  } // i
231  }
232  return node_in_face;
233 }
bool isTriOrQuad() const
Definition: EFAFace.C:358
EFANode * getNode(unsigned int node_id) const
Definition: EFAFace.C:99
bool getEdgeNodeParametricCoords(EFANode *node, std::vector< double > &xi_2d) const
Definition: EFAFace.C:183
std::vector< EFAFaceNode * > _interior_nodes
Definition: EFAFace.h:34

◆ getInteriorFaceNode()

EFANode* EFAFace::getInteriorFaceNode ( unsigned int  i) const
inline

Definition at line 59 of file EFAFace.h.

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

59 { return _face_interior_nodes[i]; };
std::vector< EFANode * > _face_interior_nodes
Definition: EFAFace.h:35

◆ getInteriorNode()

EFAFaceNode * EFAFace::getInteriorNode ( unsigned int  index) const

Definition at line 684 of file EFAFace.C.

Referenced by EFAElement2D::EFAElement2D().

685 {
686  return _interior_nodes[index];
687 }
std::vector< EFAFaceNode * > _interior_nodes
Definition: EFAFace.h:34

◆ getMasterInfo()

bool EFAFace::getMasterInfo ( EFANode node,
std::vector< EFANode *> &  master_nodes,
std::vector< double > &  master_weights 
) const

Definition at line 132 of file EFAFace.C.

135 {
136  // Given a EFAnode, find the element edge or fragment edge that contains it
137  // Return its master nodes and weights
138  master_nodes.clear();
139  master_weights.clear();
140  bool masters_found = false;
141  for (unsigned int i = 0; i < _num_edges; ++i) // check element exterior edges
142  {
143  if (_edges[i]->containsNode(node))
144  {
145  masters_found = _edges[i]->getNodeMasters(node, master_nodes, master_weights);
146  if (masters_found)
147  break;
148  else
149  EFAError("In getMasterInfo: cannot find master nodes in element edges");
150  }
151  }
152 
153  if (!masters_found) // check element interior embedded nodes
154  {
155  for (unsigned int i = 0; i < _interior_nodes.size(); ++i)
156  {
157  if (_interior_nodes[i]->getNode() == node)
158  {
159  std::vector<double> emb_xi(2, 0.0);
160  emb_xi[0] = _interior_nodes[i]->getParametricCoordinates(0);
161  emb_xi[1] = _interior_nodes[i]->getParametricCoordinates(1);
162  for (unsigned int j = 0; j < _num_nodes; ++j)
163  {
164  master_nodes.push_back(_nodes[j]);
165  double weight = 0.0;
166  if (_num_nodes == 4)
167  weight = Efa::linearQuadShape2D(j, emb_xi);
168  else if (_num_nodes == 3)
169  weight = Efa::linearTriShape2D(j, emb_xi);
170  else
171  EFAError("EFAface::getMasterInfo() only works for quad and tri EFAface");
172  master_weights.push_back(weight);
173  }
174  masters_found = true;
175  break;
176  }
177  }
178  }
179  return masters_found;
180 }
bool containsNode(const EFANode *node) const
Definition: EFAFace.C:391
std::vector< EFAEdge * > _edges
Definition: EFAFace.h:33
EFANode * getNode(unsigned int node_id) const
Definition: EFAFace.C:99
double linearQuadShape2D(unsigned int node_id, std::vector< double > &xi_2d)
Definition: EFAFuncs.C:16
unsigned int _num_edges
Definition: EFAFace.h:32
std::vector< EFAFaceNode * > _interior_nodes
Definition: EFAFace.h:34
std::vector< EFANode * > _nodes
Definition: EFAFace.h:31
double linearTriShape2D(unsigned int node_id, std::vector< double > &xi_2d)
Definition: EFAFuncs.C:23
unsigned int _num_nodes
Definition: EFAFace.h:30

◆ getNode()

EFANode * EFAFace::getNode ( unsigned int  node_id) const

◆ getNumCuts()

unsigned int EFAFace::getNumCuts ( ) const

Definition at line 597 of file EFAFace.C.

Referenced by hasIntersection(), and split().

598 {
599  unsigned int num_cuts = 0;
600  for (unsigned int i = 0; i < _edges.size(); ++i)
601  {
602  if (_edges[i]->hasIntersection())
603  num_cuts += _edges[i]->numEmbeddedNodes();
604  }
605  return num_cuts;
606 }
bool hasIntersection() const
Definition: EFAFace.C:609
std::vector< EFAEdge * > _edges
Definition: EFAFace.h:33

◆ hasIntersection()

bool EFAFace::hasIntersection ( ) const

Definition at line 609 of file EFAFace.C.

Referenced by EFAElement3D::fragmentFaceAlreadyCut(), getNumCuts(), and resetEdgeIntersection().

610 {
611  if (getNumCuts() > 1)
612  return true;
613  else
614  return false;
615 }
unsigned int getNumCuts() const
Definition: EFAFace.C:597

◆ hasSameOrientation()

bool EFAFace::hasSameOrientation ( const EFAFace other_face) const

Definition at line 658 of file EFAFace.C.

Referenced by EFAElement3D::overlaysElement().

659 {
660  bool same_order = false;
661  if (equivalent(other_face))
662  {
663  for (unsigned int i = 0; i < other_face->numNodes(); ++i)
664  {
665  if (other_face->_nodes[i] == _nodes[0])
666  {
667  unsigned int iplus1(i < (other_face->_num_nodes - 1) ? i + 1 : 0);
668  if (other_face->_nodes[iplus1] == _nodes[1])
669  {
670  same_order = true;
671  break;
672  }
673  else if (other_face->_nodes[iplus1] != _nodes[_num_nodes - 1])
674  EFAError("two faces overlap but can't find correct common nodes");
675  }
676  }
677  }
678  else
679  EFAWarning("in hasSameOrientation two faces does not overlap");
680  return same_order;
681 }
bool equivalent(const EFAFace *other_face) const
Definition: EFAFace.C:367
unsigned int numNodes() const
Definition: EFAFace.C:87
std::vector< EFANode * > _nodes
Definition: EFAFace.h:31
unsigned int _num_nodes
Definition: EFAFace.h:30

◆ isAdjacent()

bool EFAFace::isAdjacent ( const EFAFace other_face) const

Definition at line 629 of file EFAFace.C.

Referenced by adjacentCommonEdge(), and combineWithFace().

630 {
631  // two faces are adjacent if they only share one common edge
632  unsigned int counter = 0;
633  for (unsigned int i = 0; i < _num_edges; ++i)
634  if (other_face->ownsEdge(_edges[i]))
635  counter += 1;
636 
637  if (counter == 1)
638  return true;
639  else
640  return false;
641 }
std::vector< EFAEdge * > _edges
Definition: EFAFace.h:33
bool ownsEdge(const EFAEdge *other_edge) const
Definition: EFAFace.C:432
unsigned int _num_edges
Definition: EFAFace.h:32
static unsigned int counter

◆ isTriOrQuad()

bool EFAFace::isTriOrQuad ( ) const

Definition at line 358 of file EFAFace.C.

Referenced by getEdgeNodeParametricCoords(), and getFaceNodeParametricCoords().

359 {
360  if (_num_edges == 3 || _num_edges == 4)
361  return true;
362  else
363  return false;
364 }
unsigned int _num_edges
Definition: EFAFace.h:32

◆ mapParametricCoordsFrom1DTo2D()

void EFAFace::mapParametricCoordsFrom1DTo2D ( unsigned int  edge_id,
double  xi_1d,
std::vector< double > &  xi_2d 
) const
private

Definition at line 690 of file EFAFace.C.

Referenced by getEdgeNodeParametricCoords().

693 {
694  // given the 1D parent coord of a point in an 2D element edge, translate it to 2D para coords
695  xi_2d.resize(2, 0.0);
696  if (_num_edges == 4)
697  {
698  if (edge_id == 0)
699  {
700  xi_2d[0] = xi_1d;
701  xi_2d[1] = -1.0;
702  }
703  else if (edge_id == 1)
704  {
705  xi_2d[0] = 1.0;
706  xi_2d[1] = xi_1d;
707  }
708  else if (edge_id == 2)
709  {
710  xi_2d[0] = -xi_1d;
711  xi_2d[1] = 1.0;
712  }
713  else if (edge_id == 3)
714  {
715  xi_2d[0] = -1.0;
716  xi_2d[1] = -xi_1d;
717  }
718  else
719  EFAError("edge_id out of bounds");
720  }
721  else if (_num_edges == 3)
722  {
723  if (edge_id == 0)
724  {
725  xi_2d[0] = 0.5 * (1.0 - xi_1d);
726  xi_2d[1] = 0.5 * (1.0 + xi_1d);
727  }
728  else if (edge_id == 1)
729  {
730  xi_2d[0] = 0.0;
731  xi_2d[1] = 0.5 * (1.0 - xi_1d);
732  }
733  else if (edge_id == 2)
734  {
735  xi_2d[0] = 0.5 * (1.0 + xi_1d);
736  xi_2d[1] = 0.0;
737  }
738  else
739  EFAError("edge_id out of bounds");
740  }
741  else
742  EFAError("the EFAface::mapParametricCoordsFrom1DTo2D only works for quad and tri faces");
743 }
unsigned int _num_edges
Definition: EFAFace.h:32

◆ numEdges()

unsigned int EFAFace::numEdges ( ) const

Definition at line 254 of file EFAFace.C.

Referenced by EFAFragment2D::EFAFragment2D(), EFAElement3D::getFragmentFaceEdgeID(), EFAElement3D::getNeighborEdgeIndex(), and EFAElement3D::getNeighborFaceEdgeID().

255 {
256  return _edges.size();
257 }
std::vector< EFAEdge * > _edges
Definition: EFAFace.h:33

◆ numInteriorNodes()

unsigned int EFAFace::numInteriorNodes ( ) const

Definition at line 236 of file EFAFace.C.

Referenced by copyIntersection(), and EFAElement2D::EFAElement2D().

237 {
238  return _interior_nodes.size();
239 }
std::vector< EFAFaceNode * > _interior_nodes
Definition: EFAFace.h:34

◆ numNodes()

unsigned int EFAFace::numNodes ( ) const

◆ ownsEdge()

bool EFAFace::ownsEdge ( const EFAEdge other_edge) const

Definition at line 432 of file EFAFace.C.

Referenced by adjacentCommonEdge(), and isAdjacent().

433 {
434  for (unsigned int i = 0; i < _edges.size(); ++i)
435  if (_edges[i]->equivalent(*other_edge))
436  return true;
437  return false;
438 }
bool equivalent(const EFAFace *other_face) const
Definition: EFAFace.C:367
std::vector< EFAEdge * > _edges
Definition: EFAFace.h:33

◆ removeEmbeddedNode()

void EFAFace::removeEmbeddedNode ( EFANode emb_node)

Definition at line 441 of file EFAFace.C.

442 {
443  for (unsigned int i = 0; i < _num_edges; ++i)
444  _edges[i]->removeEmbeddedNode(emb_node);
445 
446  unsigned int index = 0;
447  bool node_found = false;
448  for (unsigned int i = 0; i < _interior_nodes.size(); ++i)
449  {
450  if (_interior_nodes[i]->getNode() == emb_node)
451  {
452  node_found = true;
453  index = i;
454  break;
455  }
456  }
457  if (node_found)
458  {
459  delete _interior_nodes[index];
460  _interior_nodes.erase(_interior_nodes.begin() + index);
461  }
462 }
std::vector< EFAEdge * > _edges
Definition: EFAFace.h:33
EFANode * getNode(unsigned int node_id) const
Definition: EFAFace.C:99
unsigned int _num_edges
Definition: EFAFace.h:32
std::vector< EFAFaceNode * > _interior_nodes
Definition: EFAFace.h:34
void removeEmbeddedNode(EFANode *emb_node)
Definition: EFAFace.C:441

◆ resetEdgeIntersection()

void EFAFace::resetEdgeIntersection ( const EFAFace ref_face)

Definition at line 554 of file EFAFace.C.

Referenced by EFAFragment3D::combine_two_faces().

555 {
556  // set up correct edge intersections based on the reference face
557  // the reference face must contain the edge of this face that is to be set up
558  // the reference face must be an element face
559  for (unsigned int j = 0; j < _num_edges; ++j)
560  {
561  if (_edges[j]->hasIntersection())
562  {
563  if (_edges[j]->numEmbeddedNodes() > 1)
564  EFAError("frag face edge can only have 1 emb node at this point");
565 
566  EFANode * edge_node1 = _edges[j]->getNode(0);
567  EFANode * edge_node2 = _edges[j]->getNode(1);
568  EFANode * emb_node = _edges[j]->getEmbeddedNode(0);
569  double inters_x = _edges[j]->getIntersection(0, edge_node1);
570  if (std::abs(inters_x + 1.0) < 1.0e-4) // invalid intersection found
571  {
572  std::vector<double> node1_xi2d(2, 0.0);
573  std::vector<double> node2_xi2d(2, 0.0);
574  std::vector<double> emb_xi2d(2, 0.0);
575  if (ref_face->getFaceNodeParametricCoords(edge_node1, node1_xi2d) &&
576  ref_face->getFaceNodeParametricCoords(edge_node2, node2_xi2d) &&
577  ref_face->getFaceNodeParametricCoords(emb_node, emb_xi2d))
578  {
579  // TODO: this is not correct for unstructured elements. Need a fix
580  double dist2node1 =
581  std::sqrt((emb_xi2d[0] - node1_xi2d[0]) * (emb_xi2d[0] - node1_xi2d[0]) +
582  (emb_xi2d[1] - node1_xi2d[1]) * (emb_xi2d[1] - node1_xi2d[1]));
583  double full_dist =
584  std::sqrt((node2_xi2d[0] - node1_xi2d[0]) * (node2_xi2d[0] - node1_xi2d[0]) +
585  (node2_xi2d[1] - node1_xi2d[1]) * (node2_xi2d[1] - node1_xi2d[1]));
586  inters_x = dist2node1 / full_dist;
587  }
588  else
589  EFAError("reference face does not contain the edge with invalid inters");
590  _edges[j]->resetIntersection(inters_x, emb_node, edge_node1);
591  }
592  }
593  }
594 }
bool hasIntersection() const
Definition: EFAFace.C:609
std::vector< EFAEdge * > _edges
Definition: EFAFace.h:33
bool getFaceNodeParametricCoords(EFANode *node, std::vector< double > &xi_2d) const
Definition: EFAFace.C:210
unsigned int _num_edges
Definition: EFAFace.h:32

◆ reverseEdges()

void EFAFace::reverseEdges ( )

Definition at line 349 of file EFAFace.C.

Referenced by EFAFragment3D::connectSubfaces().

350 {
351  // reverse the orientation of the face
352  for (unsigned int i = 0; i < _edges.size(); ++i)
353  _edges[i]->reverseNodes();
354  std::reverse(_edges.begin(), _edges.end());
355 }
std::vector< EFAEdge * > _edges
Definition: EFAFace.h:33

◆ setEdge()

void EFAFace::setEdge ( unsigned int  edge_id,
EFAEdge new_edge 
)

Definition at line 266 of file EFAFace.C.

Referenced by EFAFragment3D::connectSubfaces().

267 {
268  _edges[edge_id] = new_edge;
269 }
std::vector< EFAEdge * > _edges
Definition: EFAFace.h:33

◆ setInteriorFaceNode()

void EFAFace::setInteriorFaceNode ( unsigned int  i,
EFANode node 
)

Definition at line 81 of file EFAFace.C.

82 {
83  _face_interior_nodes[i] = node;
84 }
std::vector< EFANode * > _face_interior_nodes
Definition: EFAFace.h:35

◆ setNode()

void EFAFace::setNode ( unsigned int  node_id,
EFANode node 
)

Definition at line 93 of file EFAFace.C.

94 {
95  _nodes[node_id] = node;
96 }
std::vector< EFANode * > _nodes
Definition: EFAFace.h:31

◆ sortEdges()

void EFAFace::sortEdges ( )

Definition at line 329 of file EFAFace.C.

Referenced by EFAFragment3D::connectSubfaces().

330 {
331  std::vector<EFAEdge *> ordered_edges(_num_edges, NULL);
332  ordered_edges[0] = _edges[0];
333  for (unsigned int i = 1; i < _num_edges; ++i)
334  {
335  EFAEdge * last_edge = ordered_edges[i - 1];
336  for (unsigned int j = 0; j < _num_edges; ++j)
337  {
338  if (!_edges[j]->equivalent(*last_edge) && _edges[j]->containsNode(last_edge->getNode(1)))
339  {
340  ordered_edges[i] = _edges[j];
341  break;
342  }
343  } // j
344  } // i
345  _edges = ordered_edges;
346 }
bool containsNode(const EFANode *node) const
Definition: EFAFace.C:391
bool equivalent(const EFAFace *other_face) const
Definition: EFAFace.C:367
std::vector< EFAEdge * > _edges
Definition: EFAFace.h:33
unsigned int _num_edges
Definition: EFAFace.h:32
EFANode * getNode(unsigned int index) const
Definition: EFAEdge.C:179

◆ split()

std::vector< EFAFace * > EFAFace::split ( ) const

Definition at line 465 of file EFAFace.C.

466 {
467  std::vector<EFAFace *> new_faces;
468  if (getNumCuts() > 0)
469  {
470  // construct a fragment from this face
471  EFAFragment2D * frag_tmp = new EFAFragment2D(NULL, this);
472  std::vector<EFAFragment2D *> new_frags_tmp = frag_tmp->split();
473 
474  // copy new_frags to new_faces
475  for (unsigned int i = 0; i < new_frags_tmp.size(); ++i)
476  new_faces.push_back(new EFAFace(new_frags_tmp[i]));
477 
478  // delete frag_tmp and new_frags
479  delete frag_tmp;
480  for (unsigned int i = 0; i < new_frags_tmp.size(); ++i)
481  delete new_frags_tmp[i];
482  }
483  else
484  new_faces.push_back(new EFAFace(*this));
485 
486  return new_faces;
487 }
std::vector< EFAFragment2D * > split()
unsigned int getNumCuts() const
Definition: EFAFace.C:597
EFAFace(unsigned int n_nodes, unsigned int num_interior_face_nodes=0)
Definition: EFAFace.C:19

◆ switchNode()

void EFAFace::switchNode ( EFANode new_node,
EFANode old_node 
)

Definition at line 105 of file EFAFace.C.

106 {
107  bool is_face_node = true;
108  for (unsigned int i = 0; i < _num_nodes; ++i)
109  {
110  if (_nodes[i] == old_node)
111  {
112  _nodes[i] = new_node;
113  is_face_node = false;
114  }
115  }
116  if (is_face_node)
117  {
118  for (unsigned int i = 0; i < _face_interior_nodes.size(); ++i)
119  if (_face_interior_nodes[i] == old_node)
120  _face_interior_nodes[i] = new_node;
121  }
122  else
123  {
124  for (unsigned int i = 0; i < _edges.size(); ++i)
125  _edges[i]->switchNode(new_node, old_node);
126  for (unsigned int i = 0; i < _interior_nodes.size(); ++i)
127  _interior_nodes[i]->switchNode(new_node, old_node);
128  }
129 }
std::vector< EFAEdge * > _edges
Definition: EFAFace.h:33
std::vector< EFANode * > _face_interior_nodes
Definition: EFAFace.h:35
std::vector< EFAFaceNode * > _interior_nodes
Definition: EFAFace.h:34
void switchNode(EFANode *new_node, EFANode *old_node)
Definition: EFAFace.C:105
std::vector< EFANode * > _nodes
Definition: EFAFace.h:31
unsigned int _num_nodes
Definition: EFAFace.h:30

Member Data Documentation

◆ _edges

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

◆ _face_interior_nodes

std::vector<EFANode *> EFAFace::_face_interior_nodes
private

Definition at line 35 of file EFAFace.h.

Referenced by getInteriorFaceNode(), setInteriorFaceNode(), and switchNode().

◆ _interior_nodes

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

◆ _nodes

std::vector<EFANode *> EFAFace::_nodes
private

◆ _num_edges

unsigned int EFAFace::_num_edges
private

◆ _num_nodes

unsigned int EFAFace::_num_nodes
private

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