Nektar++
ProcessExtractTetPrismInterface.cpp
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // File: ProcessExtractTetPrismInterface.cpp
4 //
5 // For more information, please see: http://www.nektar.info/
6 //
7 // The MIT License
8 //
9 // Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10 // Department of Aeronautics, Imperial College London (UK), and Scientific
11 // Computing and Imaging Institute, University of Utah (USA).
12 //
13 // License for the specific language governing rights and limitations under
14 // Permission is hereby granted, free of charge, to any person obtaining a
15 // copy of this software and associated documentation files (the "Software"),
16 // to deal in the Software without restriction, including without limitation
17 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 // and/or sell copies of the Software, and to permit persons to whom the
19 // Software is furnished to do so, subject to the following conditions:
20 //
21 // The above copyright notice and this permission notice shall be included
22 // in all copies or substantial portions of the Software.
23 //
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30 // DEALINGS IN THE SOFTWARE.
31 //
32 // Description: Extract the interface between prismatic and tetrahedral
33 // elements.
34 //
35 ////////////////////////////////////////////////////////////////////////////////
36 
37 #include "../MeshElements.h"
39 
42 
43 #include <vector>
44 using namespace std;
45 
46 namespace Nektar
47 {
48 namespace Utilities
49 {
50 
51 ModuleKey ProcessExtractTetPrismInterface::className =
53  ModuleKey(eProcessModule, "extracttetprism"),
54  ProcessExtractTetPrismInterface::create,
55  "Process elements to extract the faces between "
56  "tets and prisms.");
57 
58 ProcessExtractTetPrismInterface::ProcessExtractTetPrismInterface(
60 {
61 }
62 
64 {
65 }
66 
68 {
69  if (m_mesh->m_verbose)
70  {
71  cout << "ProcessExtractTetPrismInterface: Extracting tet-prism "
72  << "interface... " << endl;
73  }
74 
75  ASSERTL0(m_mesh->m_expDim == 3, "The prism-tet interface module"
76  " only works for three-dimensional meshes.");
77 
78  // Copy 3D elements and 2D boundary elements and clear existing.
79  vector<ElementSharedPtr> el = m_mesh->m_element[m_mesh->m_expDim];
80  vector<ElementSharedPtr> bndEl = m_mesh->m_element[
81  m_mesh->m_expDim-1];
82  m_mesh->m_element[m_mesh->m_expDim].clear();
83  m_mesh->m_element[m_mesh->m_expDim-1].clear();
84 
85  // Extract prismatic elements.
86  for (int i = 0; i < el.size(); ++i)
87  {
88  ElementSharedPtr elmt = el[i];
89 
90  if (elmt->GetConf().m_e == LibUtilities::ePrism)
91  {
92  m_mesh->m_element[m_mesh->m_expDim].push_back(elmt);
93  }
94  }
95 
96  ASSERTL0(m_mesh->m_element[m_mesh->m_expDim].size() > 0,
97  "Mesh does not contain any prismatic elements!");
98 
100 
101  // Extract boundary region already associated with prisms
102  // (i.e. outer wall of the computational domain)
103  for (fIt = m_mesh->m_faceSet.begin();
104  fIt != m_mesh->m_faceSet.end(); fIt++)
105  {
106  if ((*fIt)->m_elLink.size() == 1)
107  {
108  ElementSharedPtr el = (*fIt)->m_elLink[0].first;
109 
110  if (el->GetConf().m_e != LibUtilities::eTetrahedron)
111  {
112  m_mesh->m_element[m_mesh->m_expDim-1].push_back(
113  bndEl[el->GetBoundaryLink(
114  (*fIt)->m_elLink[0].second)]);
115  }
116  }
117  }
118 
119  // Now extract prismatic faces that are not connected to any other
120  // elements, which denotes the prism/tet boundary.
121  for (fIt = m_mesh->m_faceSet.begin();
122  fIt != m_mesh->m_faceSet.end(); fIt++)
123  {
124  if ((*fIt)->m_elLink.size() != 1)
125  {
126  ElementSharedPtr el1 = (*fIt)->m_elLink[0].first;
127  ElementSharedPtr el2 = (*fIt)->m_elLink[1].first;
128 
129  if ((el1->GetConf().m_e == LibUtilities::ePrism &&
130  el2->GetConf().m_e == LibUtilities::eTetrahedron) ||
131  (el2->GetConf().m_e == LibUtilities::ePrism &&
132  el1->GetConf().m_e == LibUtilities::eTetrahedron))
133  {
134  // Create a new linear triangle from face for boundary.
135  vector<NodeSharedPtr> nodeList(3);
136  vector<int> tags(1);
137  tags[0] = m_mesh->m_composite.size();
138 
139  nodeList = (*fIt)->m_vertexList;
140  ElmtConfig conf(
141  LibUtilities::eTriangle, 1, false, false, false);
143  CreateInstance(
144  LibUtilities::eTriangle, conf, nodeList, tags);
145 
146  m_mesh->m_element[m_mesh->m_expDim-1].push_back(tri);
147  }
148  }
149  }
150 
151  ProcessVertices();
152  ProcessEdges();
153  ProcessFaces();
154  ProcessElements();
156 }
157 
158 }
159 }
160 
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:161
pair< ModuleType, string > ModuleKey
STL namespace.
MeshSharedPtr m_mesh
Mesh object.
virtual void ProcessEdges(bool ReprocessEdges=true)
Extract element edges.
boost::shared_ptr< Element > ElementSharedPtr
Shared pointer to an element.
Definition: MeshElements.h:63
virtual void ProcessVertices()
Extract element vertices.
virtual void ProcessElements()
Generate element IDs.
boost::shared_ptr< Mesh > MeshSharedPtr
Shared pointer to a mesh.
Basic information about an element.
Definition: MeshElements.h:583
virtual void ProcessComposites()
Generate composites.
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
virtual void ProcessFaces(bool ReprocessFaces=true)
Extract element faces.
ElementFactory & GetElementFactory()
ModuleFactory & GetModuleFactory()
Abstract base class for processing modules.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:215