Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ProcessLinear.cpp
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // File: ProcessLinear.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: linearises mesh.
33 //
34 ////////////////////////////////////////////////////////////////////////////////
35 
37 #include "ProcessLinear.h"
38 
39 using namespace std;
40 
41 namespace Nektar
42 {
43 namespace Utilities
44 {
45 ModuleKey ProcessLinear::className = GetModuleFactory().RegisterCreatorFunction(
46  ModuleKey(eProcessModule, "linearise"),
47  ProcessLinear::create,
48  "Linearises mesh.");
49 
50 ProcessLinear::ProcessLinear(MeshSharedPtr m) : ProcessModule(m)
51 {
52  m_config["all"] =
53  ConfigOption(true, "0", "remove curve nodes for all elements.");
54  m_config["invalid"] =
55  ConfigOption(true, "0", "remove curve nodes if element is invalid.");
56 }
57 
59 {
60 }
61 
63 {
64  if (m_mesh->m_verbose)
65  {
66  cout << "ProcessLinear: Linearising mesh... " << endl;
67  }
68 
69  bool all = m_config["all"].as<bool>();
70  bool invalid = m_config["invalid"].as<bool>();
71 
72  ASSERTL0(all || invalid, "must specify option all or invalid");
73 
74  if (all)
75  {
77  for (eit = m_mesh->m_edgeSet.begin(); eit != m_mesh->m_edgeSet.end();
78  eit++)
79  {
80  (*eit)->m_edgeNodes.clear();
81  }
82 
84  for (fit = m_mesh->m_faceSet.begin(); fit != m_mesh->m_faceSet.end();
85  fit++)
86  {
87  (*fit)->m_faceNodes.clear();
88  }
89 
90  for (int i = 0; i < m_mesh->m_element[m_mesh->m_expDim].size(); i++)
91  {
92  vector<NodeSharedPtr> empty;
93  m_mesh->m_element[m_mesh->m_expDim][i]->SetVolumeNodes(empty);
94  }
95  }
96  else if (invalid)
97  {
98  if (m_mesh->m_expDim == 3)
99  {
100  FaceSet::iterator fit;
101  for (fit = m_mesh->m_faceSet.begin();
102  fit != m_mesh->m_faceSet.end();
103  fit++)
104  {
105  ASSERTL0((*fit)->m_faceNodes.size() == 0,
106  "has not be setup to handle face curvature yet");
107  }
108  }
109 
110  vector<ElementSharedPtr> el = m_mesh->m_element[m_mesh->m_expDim];
111  // Iterate over list of elements of expansion dimension.
112  for (int i = 0; i < el.size(); ++i)
113  {
114  // Create elemental geometry.
116  el[i]->GetGeom(m_mesh->m_spaceDim);
117 
118  // Generate geometric factors.
119  SpatialDomains::GeomFactorsSharedPtr gfac = geom->GetGeomFactors();
120 
121  // Get the Jacobian and, if it is negative, print a warning
122  // message.
123  if (!gfac->IsValid())
124  {
125 
126  vector<FaceSharedPtr> f = el[i]->GetFaceList();
127  for (int j = 0; j < f.size(); j++)
128  {
129  vector<EdgeSharedPtr> e = f[j]->m_edgeList;
130  for (int k = 0; k < e.size(); k++)
131  {
132  if (e[k]->m_edgeNodes.size())
133  {
134  vector<NodeSharedPtr> zeroNodes;
135  e[k]->m_edgeNodes = zeroNodes;
136  }
137  }
138  }
139  }
140  }
141  }
142 }
143 }
144 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:188
pair< ModuleType, string > ModuleKey
virtual void Process()
Write mesh to output file.
map< string, ConfigOption > m_config
List of configuration values.
STL namespace.
MeshSharedPtr m_mesh
Mesh object.
Represents a command-line configuration option.
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
boost::shared_ptr< GeomFactors > GeomFactorsSharedPtr
Pointer to a GeomFactors object.
Definition: GeomFactors.h:62
boost::shared_ptr< Geometry > GeometrySharedPtr
Definition: Geometry.h:53
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