36#include "QuadraticMeshHelper.hpp"
38#define SEEK_TO_CONTENT(methNameDirect, methNameIncrement, index) \
40 if (rMeshReader.IsFileFormatBinary()) { \
41 rMeshReader.methNameDirect(index - 1u); \
43 for (unsigned i=0; i<index-1u; ++i) { \
44 rMeshReader.methNameIncrement(); \
47template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
49 unsigned boundaryElementIndex)
51 SEEK_TO_CONTENT(GetFaceData, GetNextFaceData, boundaryElementIndex);
66 std::set<unsigned> owned_element_indices;
71 owned_element_indices.insert(iter->GetIndex());
81 std::vector<unsigned> nodes = iter->NodeIndices;
82 assert(nodes.size()==(DIM+1)*(DIM+2)/2);
87 for (
unsigned j=DIM+1; j<(DIM+1)*(DIM+2)/2; j++)
89 unsigned node_index = nodes[j];
90 if (!r_node_perm.empty())
92 node_index = r_node_perm[node_index];
103template<
unsigned DIM>
122 AddNodesToBoundaryElements(pMesh, pMeshReader);
127template<
unsigned DIM>
133 bool boundary_element_file_has_containing_element_info =
false;
142 if (boundary_element_file_has_containing_element_info)
144 pMeshReader->
Reset();
150 unsigned next_face_on_file = 0u;
159 std::set<unsigned> boundary_element_node_indices;
160 for (
unsigned i=0; i<DIM; i++)
162 boundary_element_node_indices.insert( (*iter)->GetNodeGlobalIndex(i) );
165 bool found_this_boundary_element =
false;
171 Node<DIM>* p_representative_node = (*iter)->GetNode(0);
176 unsigned elem_index = *element_iter;
179 if (boundary_element_file_has_containing_element_info)
181 unsigned face_index = (*iter)->
GetIndex();
188 while (face_index >= next_face_on_file);
194 for (
unsigned face=0; face<DIM+1; face++)
197 std::set<unsigned> node_indices;
198 for (
unsigned local_node_index=0; local_node_index<DIM+1; local_node_index++)
200 if (local_node_index != face)
206 assert(node_indices.size()==DIM);
209 if (node_indices == boundary_element_node_indices)
213 found_this_boundary_element =
true;
219 if (boundary_element_file_has_containing_element_info && !found_this_boundary_element)
223 EXCEPTION(
"Boundary element " << (*iter)->GetIndex()
224 <<
"wasn't found in the containing element given for it "
229 if (found_this_boundary_element)
235 if (!found_this_boundary_element)
238 EXCEPTION(
"Unable to find a face of an element which matches one of the boundary elements");
245template<
unsigned DIM>
249 unsigned expected_num_nodes = DIM*(DIM+1)/2;
255 assert((*iter)->GetNumNodes() == expected_num_nodes);
260template<
unsigned DIM>
274 pBoundaryElement->
AddNode(pNode);
277template<
unsigned DIM>
281 unsigned internalNode)
284 assert(internalNode >= DIM+1);
285 assert(internalNode < (DIM+1)*(DIM+2)/2);
287 AddNodeToBoundaryElement(pMesh, pBoundaryElement, p_internal_node);
290template<
unsigned DIM>
294 unsigned nodeIndexOppositeToFace)
299 assert(nodeIndexOppositeToFace<3);
301 AddNodeToBoundaryElement(pMesh, pBoundaryElement, pElement, nodeIndexOppositeToFace+3);
313 if (nodeIndexOppositeToFace==0)
316 HelperMethod1(b_elem_n0, b_elem_n1, pElement, 1, 2, 3, offset, reverse);
317 HelperMethod2(pMesh, pBoundaryElement, pElement, 9, 8, 5, offset, reverse);
319 else if (nodeIndexOppositeToFace==1)
322 HelperMethod1(b_elem_n0, b_elem_n1, pElement, 2, 0, 3, offset, reverse);
323 HelperMethod2(pMesh, pBoundaryElement, pElement, 7, 9, 6, offset, reverse);
325 else if (nodeIndexOppositeToFace==2)
328 HelperMethod1(b_elem_n0, b_elem_n1, pElement, 0, 1, 3, offset, reverse);
329 HelperMethod2(pMesh, pBoundaryElement, pElement, 8, 7, 4, offset, reverse);
333 assert(nodeIndexOppositeToFace==3);
335 HelperMethod1(b_elem_n0, b_elem_n1, pElement, 0, 1, 2, offset, reverse);
336 HelperMethod2(pMesh, pBoundaryElement, pElement, 5, 6, 4, offset, reverse);
346template<
unsigned DIM>
349 unsigned node0,
unsigned node1,
unsigned node2,
398template<
unsigned DIM>
402 unsigned internalNode0,
unsigned internalNode1,
unsigned internalNode2,
408 unsigned temp = internalNode0;
409 internalNode0 = internalNode1;
410 internalNode1 = internalNode2;
411 internalNode2 = temp;
413 else if (offset == 2)
415 unsigned temp = internalNode0;
416 internalNode0 = internalNode2;
417 internalNode2 = internalNode1;
418 internalNode1 = temp;
423 unsigned temp = internalNode1;
424 internalNode1 = internalNode2;
425 internalNode2 = temp;
428 AddNodeToBoundaryElement(pMesh, pBoundaryElement, pElement, internalNode0);
429 AddNodeToBoundaryElement(pMesh, pBoundaryElement, pElement, internalNode1);
430 AddNodeToBoundaryElement(pMesh, pBoundaryElement, pElement, internalNode2);
#define EXCEPTION(message)
Node< SPACE_DIM > * GetNode(unsigned localIndex) const
unsigned GetNumNodes() const
unsigned GetNodeGlobalIndex(unsigned localIndex) const
void AddNode(Node< SPACE_DIM > *pNode)
unsigned GetIndex() const
ElementIterator GetElementIteratorBegin()
virtual bool GetReadContainingElementOfBoundaryElement()
virtual unsigned GetOrderOfBoundaryElements()
virtual ElementData GetNextFaceData()=0
ElementIterator GetElementIteratorEnd()
virtual Node< SPACE_DIM > * GetNodeOrHaloNode(unsigned index) const
std::vector< Node< SPACE_DIM > * > mBoundaryNodes
const std::vector< unsigned > & rGetNodePermutation() const
virtual unsigned GetNumLocalBoundaryElements() const
ElementIterator GetElementIteratorBegin(bool skipDeletedElements=true)
std::vector< BoundaryElement< ELEMENT_DIM-1, SPACE_DIM > * >::const_iterator BoundaryElementIterator
virtual unsigned GetNumLocalElements() const
ElementIterator GetElementIteratorEnd()
Element< ELEMENT_DIM, SPACE_DIM > * GetElement(unsigned index) const
BoundaryElementIterator GetBoundaryElementIteratorBegin() const
BoundaryElementIterator GetBoundaryElementIteratorEnd() const
ContainingElementIterator ContainingElementsEnd() const
void AddElement(unsigned index)
ContainingElementIterator ContainingElementsBegin() const
bool IsBoundaryNode() const
unsigned GetIndex() const
void SetAsBoundaryNode(bool value=true)
static void AddExtraBoundaryNodes(AbstractTetrahedralMesh< DIM, DIM > *pMesh, BoundaryElement< DIM-1, DIM > *pBoundaryElement, Element< DIM, DIM > *pElement, unsigned nodeIndexOppositeToFace)
static void AddNodeToBoundaryElement(AbstractTetrahedralMesh< DIM, DIM > *pMesh, BoundaryElement< DIM-1, DIM > *pBoundaryElement, Element< DIM, DIM > *pElement, unsigned internalNode)
static void HelperMethod2(AbstractTetrahedralMesh< DIM, DIM > *pMesh, BoundaryElement< DIM-1, DIM > *pBoundaryElement, Element< DIM, DIM > *pElement, unsigned internalNode0, unsigned internalNode1, unsigned internalNode2, unsigned offset, bool reverse)
static void CheckBoundaryElements(AbstractTetrahedralMesh< DIM, DIM > *pMesh)
static void AddNodesToBoundaryElements(AbstractTetrahedralMesh< DIM, DIM > *pMesh, AbstractMeshReader< DIM, DIM > *pMeshReader)
static void HelperMethod1(unsigned boundaryElemNode0, unsigned boundaryElemNode1, Element< DIM, DIM > *pElement, unsigned node0, unsigned node1, unsigned node2, unsigned &rOffset, bool &rReverse)
static void AddInternalNodesToBoundaryElements(AbstractTetrahedralMesh< DIM, DIM > *pMesh, AbstractMeshReader< DIM, DIM > *pMeshReader)
static void AddInternalNodesToElements(AbstractTetrahedralMesh< DIM, DIM > *pMesh, AbstractMeshReader< DIM, DIM > *pMeshReader)
unsigned ContainingElement