Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
39 
41 
43 
44 using namespace std;
45 using namespace Nektar::NekMeshUtils;
46 
47 namespace Nektar
48 {
49 namespace Utilities
50 {
51 
52 ModuleKey ProcessExtractTetPrismInterface::className =
54  ModuleKey(eProcessModule, "extracttetprism"),
55  ProcessExtractTetPrismInterface::create,
56  "Process elements to extract the faces between "
57  "tets and prisms.");
58 
59 ProcessExtractTetPrismInterface::ProcessExtractTetPrismInterface(
60  MeshSharedPtr m)
61  : ProcessModule(m)
62 {
63 }
64 
66 {
67 }
68 
70 {
71  if (m_mesh->m_verbose)
72  {
73  cout << "ProcessExtractTetPrismInterface: Extracting tet-prism "
74  << "interface... " << endl;
75  }
76 
77  ASSERTL0(m_mesh->m_expDim == 3,
78  "The prism-tet interface module"
79  " only works for three-dimensional meshes.");
80 
81  // Copy 3D elements and 2D boundary elements and clear existing.
82  vector<ElementSharedPtr> el = m_mesh->m_element[m_mesh->m_expDim];
83  vector<ElementSharedPtr> bndEl = m_mesh->m_element[m_mesh->m_expDim - 1];
84  m_mesh->m_element[m_mesh->m_expDim].clear();
85  m_mesh->m_element[m_mesh->m_expDim - 1].clear();
86 
87  // Extract prismatic elements.
88  for (int i = 0; i < el.size(); ++i)
89  {
90  ElementSharedPtr elmt = el[i];
91 
92  if (elmt->GetConf().m_e == LibUtilities::ePrism)
93  {
94  m_mesh->m_element[m_mesh->m_expDim].push_back(elmt);
95  }
96  }
97 
98  ASSERTL0(m_mesh->m_element[m_mesh->m_expDim].size() > 0,
99  "Mesh does not contain any prismatic elements!");
100 
101  FaceSet::iterator fIt;
102 
103  // Extract boundary region already associated with prisms
104  // (i.e. outer wall of the computational domain)
105  for (fIt = m_mesh->m_faceSet.begin(); fIt != m_mesh->m_faceSet.end(); fIt++)
106  {
107  if ((*fIt)->m_elLink.size() == 1)
108  {
109  ElementSharedPtr el = (*fIt)->m_elLink[0].first;
110 
111  if (el->GetConf().m_e != LibUtilities::eTetrahedron)
112  {
113  m_mesh->m_element[m_mesh->m_expDim - 1].push_back(
114  bndEl[el->GetBoundaryLink((*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(); fIt != m_mesh->m_faceSet.end(); fIt++)
122  {
123  if ((*fIt)->m_elLink.size() != 1)
124  {
125  ElementSharedPtr el1 = (*fIt)->m_elLink[0].first;
126  ElementSharedPtr el2 = (*fIt)->m_elLink[1].first;
127 
128  if ((el1->GetConf().m_e == LibUtilities::ePrism &&
129  el2->GetConf().m_e == LibUtilities::eTetrahedron) ||
130  (el2->GetConf().m_e == LibUtilities::ePrism &&
131  el1->GetConf().m_e == LibUtilities::eTetrahedron))
132  {
133  // Create a new linear triangle from face for boundary.
134  vector<NodeSharedPtr> nodeList(3);
135  vector<int> tags(1);
136  tags[0] = m_mesh->m_composite.size();
137 
138  nodeList = (*fIt)->m_vertexList;
139  ElmtConfig conf(
140  LibUtilities::eTriangle, 1, false, false, false);
142  LibUtilities::eTriangle, conf, nodeList, tags);
143 
144  m_mesh->m_element[m_mesh->m_expDim - 1].push_back(tri);
145  }
146  }
147  }
148 
149  ProcessVertices();
150  ProcessEdges();
151  ProcessFaces();
152  ProcessElements();
154 }
155 }
156 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:188
Basic information about an element.
Definition: Element.h:58
pair< ModuleType, string > ModuleKey
tBaseSharedPtr CreateInstance(tKey idKey BOOST_PP_COMMA_IF(MAX_PARAM) BOOST_PP_ENUM_BINARY_PARAMS(MAX_PARAM, tParam, x))
Create an instance of the class referred to by idKey.
Definition: NekFactory.hpp:162
STL namespace.
MeshSharedPtr m_mesh
Mesh object.
ElementFactory & GetElementFactory()
Definition: Element.cpp:47
virtual void ProcessEdges(bool ReprocessEdges=true)
Extract element edges.
virtual void ProcessVertices()
Extract element vertices.
virtual void ProcessElements()
Generate element IDs.
virtual void ProcessComposites()
Generate composites.
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
boost::shared_ptr< Mesh > MeshSharedPtr
Shared pointer to a mesh.
Definition: Mesh.h:137
virtual void ProcessFaces(bool ReprocessFaces=true)
Extract element faces.
boost::shared_ptr< Element > ElementSharedPtr
Definition: Edge.h:52
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