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(); \ 47 template<
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
49 unsigned boundaryElementIndex)
51 SEEK_TO_CONTENT(GetFaceData, GetNextFaceData, boundaryElementIndex);
54 template<
unsigned DIM>
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);
84 assert(p_element->GetNumNodes()==DIM+1);
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];
95 p_element->AddNode(p_node);
103 template<
unsigned DIM>
122 AddNodesToBoundaryElements(pMesh, pMeshReader);
127 template<
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");
245 template<
unsigned DIM>
249 unsigned expected_num_nodes = DIM*(DIM+1)/2;
255 assert((*iter)->GetNumNodes() == expected_num_nodes);
260 template<
unsigned DIM>
274 pBoundaryElement->
AddNode(pNode);
277 template<
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);
290 template<
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);
346 template<
unsigned DIM>
349 unsigned node0,
unsigned node1,
unsigned node2,
398 template<
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);
static void AddNodesToBoundaryElements(AbstractTetrahedralMesh< DIM, DIM > *pMesh, AbstractMeshReader< DIM, DIM > *pMeshReader)
ElementIterator GetElementIteratorBegin()
ElementIterator GetElementIteratorBegin(bool skipDeletedElements=true)
std::vector< Node< SPACE_DIM > * > mBoundaryNodes
virtual unsigned GetNumLocalBoundaryElements() const
static void AddInternalNodesToElements(AbstractTetrahedralMesh< DIM, DIM > *pMesh, AbstractMeshReader< DIM, DIM > *pMeshReader)
void SetAsBoundaryNode(bool value=true)
BoundaryElementIterator GetBoundaryElementIteratorBegin() const
unsigned GetNodeGlobalIndex(unsigned localIndex) const
virtual Node< SPACE_DIM > * GetNodeOrHaloNode(unsigned index) const
unsigned ContainingElement
const std::vector< unsigned > & rGetNodePermutation() const
static void AddInternalNodesToBoundaryElements(AbstractTetrahedralMesh< DIM, DIM > *pMesh, AbstractMeshReader< DIM, DIM > *pMeshReader)
ElementIterator GetElementIteratorEnd()
bool IsBoundaryNode() const
#define EXCEPTION(message)
static void AddExtraBoundaryNodes(AbstractTetrahedralMesh< DIM, DIM > *pMesh, BoundaryElement< DIM-1, DIM > *pBoundaryElement, Element< DIM, DIM > *pElement, unsigned nodeIndexOppositeToFace)
Element< ELEMENT_DIM, SPACE_DIM > * GetElement(unsigned index) const
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 HelperMethod1(unsigned boundaryElemNode0, unsigned boundaryElemNode1, Element< DIM, DIM > *pElement, unsigned node0, unsigned node1, unsigned node2, unsigned &rOffset, bool &rReverse)
virtual unsigned GetNumLocalElements() const
virtual ElementData GetNextFaceData()=0
Node< SPACE_DIM > * GetNode(unsigned localIndex) const
ElementIterator GetElementIteratorEnd()
ContainingElementIterator ContainingElementsBegin() const
virtual bool GetReadContainingElementOfBoundaryElement()
void AddElement(unsigned index)
virtual unsigned GetOrderOfBoundaryElements()
void AddNode(Node< SPACE_DIM > *pNode)
unsigned GetIndex() const
static void CheckBoundaryElements(AbstractTetrahedralMesh< DIM, DIM > *pMesh)
ContainingElementIterator ContainingElementsEnd() const
static void AddNodeToBoundaryElement(AbstractTetrahedralMesh< DIM, DIM > *pMesh, BoundaryElement< DIM-1, DIM > *pBoundaryElement, Element< DIM, DIM > *pElement, unsigned internalNode)
BoundaryElementIterator GetBoundaryElementIteratorEnd() const