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 // Permission is hereby granted, free of charge, to any person obtaining a
14 // copy of this software and associated documentation files (the "Software"),
15 // to deal in the Software without restriction, including without limitation
16 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
17 // and/or sell copies of the Software, and to permit persons to whom the
18 // Software is furnished to do so, subject to the following conditions:
19 //
20 // The above copyright notice and this permission notice shall be included
21 // in all copies or substantial portions of the Software.
22 //
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29 // DEALINGS IN THE SOFTWARE.
30 //
31 // Description: Extract the interface between prismatic and tetrahedral
32 // elements.
33 //
34 ////////////////////////////////////////////////////////////////////////////////
35 
38 
40 
42 
43 using namespace std;
44 using namespace Nektar::NekMeshUtils;
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(
59  MeshSharedPtr m)
60  : ProcessModule(m)
61 {
62 }
63 
65 {
66 }
67 
69 {
70  if (m_mesh->m_verbose)
71  {
72  cout << "ProcessExtractTetPrismInterface: Extracting tet-prism "
73  << "interface... " << endl;
74  }
75 
76  ASSERTL0(m_mesh->m_expDim == 3,
77  "The prism-tet interface module"
78  " only works for three-dimensional meshes.");
79 
80  // Copy 3D elements and 2D boundary elements and clear existing.
81  vector<ElementSharedPtr> el = m_mesh->m_element[m_mesh->m_expDim];
82  vector<ElementSharedPtr> bndEl = m_mesh->m_element[m_mesh->m_expDim - 1];
83  m_mesh->m_element[m_mesh->m_expDim].clear();
84  m_mesh->m_element[m_mesh->m_expDim - 1].clear();
85 
86  // Extract prismatic elements.
87  for (int i = 0; i < el.size(); ++i)
88  {
89  ElementSharedPtr elmt = el[i];
90 
91  if (elmt->GetConf().m_e == LibUtilities::ePrism)
92  {
93  m_mesh->m_element[m_mesh->m_expDim].push_back(elmt);
94  }
95  }
96 
97  ASSERTL0(m_mesh->m_element[m_mesh->m_expDim].size() > 0,
98  "Mesh does not contain any prismatic elements!");
99 
100  // Extract boundary region already associated with prisms
101  // (i.e. outer wall of the computational domain)
102  for (auto &face : m_mesh->m_faceSet)
103  {
104  if (face->m_elLink.size() == 1)
105  {
106  ElementSharedPtr el = face->m_elLink[0].first;
107 
108  if (el->GetConf().m_e != LibUtilities::eTetrahedron)
109  {
110  m_mesh->m_element[m_mesh->m_expDim - 1].push_back(
111  bndEl[el->GetBoundaryLink(face->m_elLink[0].second)]);
112  }
113  }
114  }
115 
116  // Now extract prismatic faces that are not connected to any other
117  // elements, which denotes the prism/tet boundary.
118  for (auto &face : m_mesh->m_faceSet)
119  {
120  if (face->m_elLink.size() != 1)
121  {
122  ElementSharedPtr el1 = face->m_elLink[0].first;
123  ElementSharedPtr el2 = face->m_elLink[1].first;
124 
125  if ((el1->GetConf().m_e == LibUtilities::ePrism &&
126  el2->GetConf().m_e == LibUtilities::eTetrahedron) ||
127  (el2->GetConf().m_e == LibUtilities::ePrism &&
128  el1->GetConf().m_e == LibUtilities::eTetrahedron))
129  {
130  // Create a new linear triangle from face for boundary.
131  vector<NodeSharedPtr> nodeList(3);
132  vector<int> tags(1);
133  tags[0] = m_mesh->m_composite.size();
134 
135  nodeList = face->m_vertexList;
136  ElmtConfig conf(
137  LibUtilities::eTriangle, 1, false, false, false);
139  LibUtilities::eTriangle, conf, nodeList, tags);
140 
141  m_mesh->m_element[m_mesh->m_expDim - 1].push_back(tri);
142  }
143  }
144  }
145 
146  ProcessVertices();
147  ProcessEdges();
148  ProcessFaces();
149  ProcessElements();
151 }
152 }
153 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
Basic information about an element.
Definition: ElementConfig.h:49
STL namespace.
std::shared_ptr< Mesh > MeshSharedPtr
Shared pointer to a mesh.
Definition: Mesh.h:156
ElementFactory & GetElementFactory()
Definition: Element.cpp:44
tBaseSharedPtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
Definition: NekFactory.hpp:144
std::pair< ModuleType, std::string > ModuleKey
virtual NEKMESHUTILS_EXPORT void ProcessFaces(bool ReprocessFaces=true)
Extract element faces.
std::shared_ptr< Element > ElementSharedPtr
Definition: Edge.h:49
virtual NEKMESHUTILS_EXPORT void ProcessElements()
Generate element IDs.
Abstract base class for processing modules.
virtual NEKMESHUTILS_EXPORT void ProcessVertices()
Extract element vertices.
virtual NEKMESHUTILS_EXPORT void ProcessEdges(bool ReprocessEdges=true)
Extract element edges.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:199
std::pair< ModuleType, std::string > ModuleKey
virtual NEKMESHUTILS_EXPORT void ProcessComposites()
Generate composites.
ModuleFactory & GetModuleFactory()