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 18 of file EFAFace.h.

Constructor & Destructor Documentation

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

Definition at line 17 of file EFAFace.C.

Referenced by combineWithFace(), and split().

18  : _num_nodes(n_nodes),
19  _nodes(_num_nodes, NULL),
21  _edges(_num_edges, NULL),
22  _face_interior_nodes(num_interior_face_nodes, NULL)
23 {
24 }
std::vector< EFAEdge * > _edges
Definition: EFAFace.h:31
std::vector< EFANode * > _face_interior_nodes
Definition: EFAFace.h:33
unsigned int _num_edges
Definition: EFAFace.h:30
std::vector< EFANode * > _nodes
Definition: EFAFace.h:29
unsigned int _num_nodes
Definition: EFAFace.h:28
EFAFace::EFAFace ( const EFAFace other_face)

Definition at line 26 of file EFAFace.C.

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

Definition at line 41 of file EFAFace.C.

42  : _num_nodes(frag->numEdges()),
43  _nodes(_num_nodes, NULL),
45  _edges(_num_edges, NULL)
46 {
47  for (unsigned int k = 0; k < frag->numEdges(); ++k)
48  {
49  EFANode * node = frag->getEdge(k)->getNode(0);
50  unsigned int kprev(k > 0 ? (k - 1) : (frag->numEdges() - 1));
51  if (!frag->getEdge(kprev)->containsNode(node))
52  node = getEdge(k)->getNode(1);
53  _nodes[k] = node;
54  _edges[k] = new EFAEdge(*frag->getEdge(k));
55  }
56 }
unsigned int numEdges() const
EFAEdge * getEdge(unsigned int edge_id) const
Definition: EFAFace.C:258
bool containsNode(const EFANode *node) const
Definition: EFAEdge.C:375
std::vector< EFAEdge * > _edges
Definition: EFAFace.h:31
EFANode * getNode(unsigned int index) const
Definition: EFAEdge.C:177
unsigned int _num_edges
Definition: EFAFace.h:30
std::vector< EFANode * > _nodes
Definition: EFAFace.h:29
EFAEdge * getEdge(unsigned int edge_id) const
unsigned int _num_nodes
Definition: EFAFace.h:28
EFAFace::~EFAFace ( )

Definition at line 58 of file EFAFace.C.

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

Member Function Documentation

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

Definition at line 642 of file EFAFace.C.

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

643 {
644  if (isAdjacent(other_face))
645  {
646  for (unsigned int i = 0; i < _num_edges; ++i)
647  if (other_face->ownsEdge(_edges[i]))
648  return i;
649  }
650  else
651  EFAError("this face is not adjacent with other_face");
652  return 99999;
653 }
bool ownsEdge(const EFAEdge *other_edge) const
Definition: EFAFace.C:430
std::vector< EFAEdge * > _edges
Definition: EFAFace.h:31
unsigned int _num_edges
Definition: EFAFace.h:30
bool isAdjacent(const EFAFace *other_face) const
Definition: EFAFace.C:627
void EFAFace::combineTwoEdges ( unsigned int  edge_id1,
unsigned int  edge_id2 
)

Definition at line 286 of file EFAFace.C.

Referenced by EFAFragment3D::combine_two_faces().

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

Definition at line 488 of file EFAFace.C.

Referenced by getInteriorFaceNode().

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

Definition at line 415 of file EFAFace.C.

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

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

Definition at line 389 of file EFAFace.C.

Referenced by combineTwoEdges(), containsFace(), getEdgeNodeParametricCoords(), getInteriorFaceNode(), getMasterInfo(), and sortEdges().

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

Definition at line 616 of file EFAFace.C.

Referenced by getInteriorFaceNode().

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

Definition at line 270 of file EFAFace.C.

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

Definition at line 240 of file EFAFace.C.

Referenced by EFAFragment3D::connectSubfaces().

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

Definition at line 365 of file EFAFace.C.

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

366 {
367  unsigned int counter = 0; // counter number of equal nodes
368  bool overlap = false;
369  if (_num_nodes == other_face->_num_nodes)
370  {
371  for (unsigned int i = 0; i < _num_nodes; ++i)
372  {
373  for (unsigned int j = 0; j < other_face->_num_nodes; ++j)
374  {
375  if (_nodes[i] == other_face->_nodes[j])
376  {
377  counter += 1;
378  break;
379  }
380  } // j
381  } // i
382  if (counter == _num_nodes)
383  overlap = true;
384  }
385  return overlap;
386 }
std::vector< EFANode * > _nodes
Definition: EFAFace.h:29
static unsigned int counter
unsigned int _num_nodes
Definition: EFAFace.h:28
EFAEdge * EFAFace::getEdge ( unsigned int  edge_id) const
bool EFAFace::getEdgeNodeParametricCoords ( EFANode node,
std::vector< double > &  xi_2d 
) const

Definition at line 181 of file EFAFace.C.

Referenced by getFaceNodeParametricCoords().

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

Definition at line 208 of file EFAFace.C.

Referenced by resetEdgeIntersection().

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

Definition at line 57 of file EFAFace.h.

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

57 { return _face_interior_nodes[i]; };
std::vector< EFANode * > _face_interior_nodes
Definition: EFAFace.h:33
EFAFaceNode * EFAFace::getInteriorNode ( unsigned int  index) const

Definition at line 682 of file EFAFace.C.

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

683 {
684  return _interior_nodes[index];
685 }
std::vector< EFAFaceNode * > _interior_nodes
Definition: EFAFace.h:32
bool EFAFace::getMasterInfo ( EFANode node,
std::vector< EFANode * > &  master_nodes,
std::vector< double > &  master_weights 
) const

Definition at line 130 of file EFAFace.C.

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

Definition at line 595 of file EFAFace.C.

Referenced by getInteriorFaceNode(), hasIntersection(), and split().

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

Definition at line 607 of file EFAFace.C.

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

608 {
609  if (getNumCuts() > 1)
610  return true;
611  else
612  return false;
613 }
unsigned int getNumCuts() const
Definition: EFAFace.C:595
bool EFAFace::hasSameOrientation ( const EFAFace other_face) const

Definition at line 656 of file EFAFace.C.

Referenced by getInteriorFaceNode(), and EFAElement3D::overlaysElement().

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

Definition at line 627 of file EFAFace.C.

Referenced by adjacentCommonEdge(), combineWithFace(), and getInteriorFaceNode().

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

Definition at line 356 of file EFAFace.C.

Referenced by getEdgeNodeParametricCoords(), and getFaceNodeParametricCoords().

357 {
358  if (_num_edges == 3 || _num_edges == 4)
359  return true;
360  else
361  return false;
362 }
unsigned int _num_edges
Definition: EFAFace.h:30
void EFAFace::mapParametricCoordsFrom1DTo2D ( unsigned int  edge_id,
double  xi_1d,
std::vector< double > &  xi_2d 
) const
private

Definition at line 688 of file EFAFace.C.

Referenced by getEdgeNodeParametricCoords(), and getInteriorFaceNode().

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

Definition at line 252 of file EFAFace.C.

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

253 {
254  return _edges.size();
255 }
std::vector< EFAEdge * > _edges
Definition: EFAFace.h:31
unsigned int EFAFace::numInteriorNodes ( ) const

Definition at line 234 of file EFAFace.C.

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

235 {
236  return _interior_nodes.size();
237 }
std::vector< EFAFaceNode * > _interior_nodes
Definition: EFAFace.h:32
unsigned int EFAFace::numNodes ( ) const
bool EFAFace::ownsEdge ( const EFAEdge other_edge) const

Definition at line 430 of file EFAFace.C.

Referenced by adjacentCommonEdge(), getInteriorFaceNode(), and isAdjacent().

431 {
432  for (unsigned int i = 0; i < _edges.size(); ++i)
433  if (_edges[i]->equivalent(*other_edge))
434  return true;
435  return false;
436 }
bool equivalent(const EFAFace *other_face) const
Definition: EFAFace.C:365
std::vector< EFAEdge * > _edges
Definition: EFAFace.h:31
void EFAFace::removeEmbeddedNode ( EFANode emb_node)

Definition at line 439 of file EFAFace.C.

Referenced by getInteriorFaceNode().

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

Definition at line 552 of file EFAFace.C.

Referenced by EFAFragment3D::combine_two_faces(), and getInteriorFaceNode().

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

Definition at line 347 of file EFAFace.C.

Referenced by EFAFragment3D::connectSubfaces().

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

Definition at line 264 of file EFAFace.C.

Referenced by EFAFragment3D::connectSubfaces().

265 {
266  _edges[edge_id] = new_edge;
267 }
std::vector< EFAEdge * > _edges
Definition: EFAFace.h:31
void EFAFace::setInteriorFaceNode ( unsigned int  i,
EFANode node 
)

Definition at line 79 of file EFAFace.C.

Referenced by getInteriorFaceNode().

80 {
81  _face_interior_nodes[i] = node;
82 }
std::vector< EFANode * > _face_interior_nodes
Definition: EFAFace.h:33
void EFAFace::setNode ( unsigned int  node_id,
EFANode node 
)

Definition at line 91 of file EFAFace.C.

92 {
93  _nodes[node_id] = node;
94 }
std::vector< EFANode * > _nodes
Definition: EFAFace.h:29
void EFAFace::sortEdges ( )

Definition at line 327 of file EFAFace.C.

Referenced by EFAFragment3D::connectSubfaces().

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

Definition at line 463 of file EFAFace.C.

Referenced by getInteriorFaceNode().

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

Definition at line 103 of file EFAFace.C.

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

Member Data Documentation

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

Definition at line 33 of file EFAFace.h.

Referenced by setInteriorFaceNode(), and switchNode().

std::vector<EFAFaceNode *> EFAFace::_interior_nodes
private
std::vector<EFANode *> EFAFace::_nodes
private
unsigned int EFAFace::_num_edges
private
unsigned int EFAFace::_num_nodes
private

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