Nektar++
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
Nektar::Utilities::ProcessInsertSurface Class Reference

This processing module calculates the Jacobian of elements using SpatialDomains::GeomFactors and the Element::GetGeom method. For now it simply prints a list of elements which have negative Jacobian. More...

#include <ProcessInsertSurface.h>

Inheritance diagram for Nektar::Utilities::ProcessInsertSurface:
[legend]

Public Member Functions

 ProcessInsertSurface (NekMeshUtils::MeshSharedPtr m)
 
virtual ~ProcessInsertSurface ()
 
virtual void Process ()
 Write mesh to output file. More...
 
- Public Member Functions inherited from Nektar::NekMeshUtils::ProcessModule
NEKMESHUTILS_EXPORT ProcessModule (MeshSharedPtr p_m)
 
- Public Member Functions inherited from Nektar::NekMeshUtils::Module
NEKMESHUTILS_EXPORT Module (MeshSharedPtr p_m)
 
NEKMESHUTILS_EXPORT void RegisterConfig (std::string key, std::string value=std::string())
 Register a configuration option with a module. More...
 
NEKMESHUTILS_EXPORT void PrintConfig ()
 Print out all configuration options for a module. More...
 
NEKMESHUTILS_EXPORT void SetDefaults ()
 Sets default configuration options for those which have not been set. More...
 
NEKMESHUTILS_EXPORT MeshSharedPtr GetMesh ()
 
virtual NEKMESHUTILS_EXPORT void ProcessVertices ()
 Extract element vertices. More...
 
virtual NEKMESHUTILS_EXPORT void ProcessEdges (bool ReprocessEdges=true)
 Extract element edges. More...
 
virtual NEKMESHUTILS_EXPORT void ProcessFaces (bool ReprocessFaces=true)
 Extract element faces. More...
 
virtual NEKMESHUTILS_EXPORT void ProcessElements ()
 Generate element IDs. More...
 
virtual NEKMESHUTILS_EXPORT void ProcessComposites ()
 Generate composites. More...
 
virtual NEKMESHUTILS_EXPORT void ClearElementLinks ()
 

Static Public Member Functions

static std::shared_ptr< Modulecreate (NekMeshUtils::MeshSharedPtr m)
 Creates an instance of this class. More...
 

Static Public Attributes

static NekMeshUtils::ModuleKey className
 

Additional Inherited Members

- Protected Member Functions inherited from Nektar::NekMeshUtils::Module
NEKMESHUTILS_EXPORT void ReorderPrisms (PerMap &perFaces)
 Reorder node IDs so that prisms and tetrahedra are aligned correctly. More...
 
NEKMESHUTILS_EXPORT void PrismLines (int prism, PerMap &perFaces, std::set< int > &prismsDone, std::vector< ElementSharedPtr > &line)
 
- Protected Attributes inherited from Nektar::NekMeshUtils::Module
MeshSharedPtr m_mesh
 Mesh object. More...
 
std::map< std::string, ConfigOptionm_config
 List of configuration values. More...
 

Detailed Description

This processing module calculates the Jacobian of elements using SpatialDomains::GeomFactors and the Element::GetGeom method. For now it simply prints a list of elements which have negative Jacobian.

Definition at line 51 of file ProcessInsertSurface.h.

Constructor & Destructor Documentation

◆ ProcessInsertSurface()

Nektar::Utilities::ProcessInsertSurface::ProcessInsertSurface ( NekMeshUtils::MeshSharedPtr  m)

Definition at line 59 of file ProcessInsertSurface.cpp.

References Nektar::NekMeshUtils::Module::m_config.

59  : ProcessModule(m)
60 {
61  m_config["mesh"] =
62  ConfigOption(false, "", "Mesh to be inserted.");
63  m_config["nonconforming"] =
64  ConfigOption(false,"", "Relax tests for nonconforming boundries");
65 }
Represents a command-line configuration option.
NEKMESHUTILS_EXPORT ProcessModule(MeshSharedPtr p_m)
std::map< std::string, ConfigOption > m_config
List of configuration values.

◆ ~ProcessInsertSurface()

Nektar::Utilities::ProcessInsertSurface::~ProcessInsertSurface ( )
virtual

Definition at line 67 of file ProcessInsertSurface.cpp.

68 {
69 }

Member Function Documentation

◆ create()

static std::shared_ptr<Module> Nektar::Utilities::ProcessInsertSurface::create ( NekMeshUtils::MeshSharedPtr  m)
inlinestatic

Creates an instance of this class.

Definition at line 55 of file ProcessInsertSurface.h.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr().

56  {
58  }
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.

◆ Process()

void Nektar::Utilities::ProcessInsertSurface::Process ( )
virtual

Write mesh to output file.

Implements Nektar::NekMeshUtils::Module.

Definition at line 71 of file ProcessInsertSurface.cpp.

References ASSERTL0, Nektar::LibUtilities::NekFactory< tKey, tBase, tParam >::CreateInstance(), Nektar::FieldUtils::eInputModule, Nektar::FieldUtils::GetModuleFactory(), Nektar::NekMeshUtils::Module::m_config, Nektar::NekMeshUtils::Module::m_mesh, and CG_Iterations::Mesh.

72 {
73  typedef bg::model::point<NekDouble, 3, bg::cs::cartesian> Point;
74  typedef pair<Point, unsigned int> PointI;
75 
76  if (m_mesh->m_verbose)
77  {
78  cout << "ProcessInsertSurface: Inserting mesh... " << endl;
79  }
80 
81  string file = m_config["mesh"].as<string>();
82  bool nonconform = m_config["nonconforming"].beenSet;
83 
84  if (m_mesh->m_verbose)
85  {
86  cout << "inserting surface from " << file << endl;
87  }
88  MeshSharedPtr inMsh = std::shared_ptr<Mesh>(new Mesh());
89  inMsh->m_verbose = m_mesh->m_verbose;
91  ModuleKey(eInputModule, "xml"), inMsh);
92  mod->RegisterConfig("infile", file);
93  mod->Process();
94 
95  //build ann tree of surface verticies from inMsh
96  //match surface vertices in ccm mesh to inMsh and copy information
97 
98  //tolerance of matching vertices
99  NekDouble tol = 1e-5;
100 
101  NodeSet surfaceNodes;
102  for(int i = 0; i < inMsh->m_element[2].size(); i++)
103  {
104  vector<NodeSharedPtr> ns = inMsh->m_element[2][i]->GetVertexList();
105  for(int j = 0; j < ns.size(); j++)
106  {
107  surfaceNodes.insert(ns[j]);
108  }
109  }
110 
111  vector<NodeSharedPtr> inMshnodeList(surfaceNodes.begin(), surfaceNodes.end());
112 
113  vector<PointI> dataPts;
114  for(int i = 0; i < inMshnodeList.size(); i++)
115  {
116  dataPts.push_back(make_pair(Point( inMshnodeList[i]->m_x,
117  inMshnodeList[i]->m_y,
118  inMshnodeList[i]->m_z), i));
119  }
120 
121  //Build tree
122  bgi::rtree<PointI, bgi::rstar<16> > rtree;
123  rtree.insert(dataPts.begin(), dataPts.end());
124 
125  surfaceNodes.clear();
126  for(int i = 0; i < m_mesh->m_element[2].size(); i++)
127  {
128  vector<NodeSharedPtr> ns = m_mesh->m_element[2][i]->GetVertexList();
129  for(int j = 0; j < ns.size(); j++)
130  {
131  surfaceNodes.insert(ns[j]);
132  }
133  }
134 
135  if(!nonconform)
136  {
137  ASSERTL0(surfaceNodes.size() == inMshnodeList.size(),
138  "surface mesh node count mismatch, will not work");
139  }
140 
141  EdgeSet surfEdges;
142  for(int i = 0; i < m_mesh->m_element[2].size(); i++)
143  {
144  FaceSharedPtr f = m_mesh->m_element[2][i]->GetFaceLink();
145  vector<EdgeSharedPtr> es = f->m_edgeList;
146  for(int j = 0; j < es.size(); j++)
147  {
148  surfEdges.insert(es[j]);
149  }
150  }
151 
152  for(auto &it : surfEdges)
153  {
154  Point queryPt1(it->m_n1->m_x, it->m_n1->m_y, it->m_n1->m_z);
155  vector<PointI> result;
156  rtree.query(bgi::nearest(queryPt1, 1), std::back_inserter(result));
157 
158  NekDouble dist1 = bg::distance(result[0].first, queryPt1);
159  if(nonconform)
160  {
161  if(dist1 > tol)
162  {
163  continue;
164  }
165  }
166  else
167  {
168  ASSERTL0(dist1 < tol, "cannot locate point accurately enough");
169  }
170 
171  NodeSharedPtr inN1 = inMshnodeList[result[0].second];
172 
173  Point queryPt2(it->m_n2->m_x, it->m_n2->m_y, it->m_n2->m_z);
174  result.clear();
175  rtree.query(bgi::nearest(queryPt2, 1), std::back_inserter(result));
176 
177  NekDouble dist2 = bg::distance(result[0].first, queryPt2);
178  if(nonconform)
179  {
180  if(dist2 > tol)
181  {
182  continue;
183  }
184  }
185  else
186  {
187  ASSERTL0(dist2 < tol, "cannot locate point accurately enough");
188  }
189  NodeSharedPtr inN2 = inMshnodeList[result[0].second];
190 
191  EdgeSharedPtr tst = std::shared_ptr<Edge>(new Edge(inN1,inN2));
192 
193  auto f = inMsh->m_edgeSet.find(tst);
194 
195  ASSERTL0(f != inMsh->m_edgeSet.end(),"could not find edge in input");
196 
197  it->m_edgeNodes = (*f)->m_edgeNodes;
198  it->m_curveType = (*f)->m_curveType;
199 
200  if((*f)->m_n1->Distance(it->m_n1) > tol)
201  {
202  reverse(it->m_edgeNodes.begin(), it->m_edgeNodes.end());
203  }
204  }
205 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:216
Represents an edge which joins two points.
Definition: Edge.h:58
std::unordered_set< EdgeSharedPtr, EdgeHash > EdgeSet
Definition: Edge.h:159
std::shared_ptr< Module > ModuleSharedPtr
std::shared_ptr< Edge > EdgeSharedPtr
Shared pointer to an edge.
Definition: Edge.h:136
std::shared_ptr< Mesh > MeshSharedPtr
Shared pointer to a mesh.
Definition: Mesh.h:156
std::shared_ptr< Node > NodeSharedPtr
Definition: CADVert.h:49
std::unordered_set< NodeSharedPtr, NodeHash > NodeSet
Definition: Node.h:447
std::shared_ptr< Face > FaceSharedPtr
Definition: Face.h:155
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
A 0-dimensional vertex.
Definition: Point.h:48
double NekDouble
std::map< std::string, ConfigOption > m_config
List of configuration values.
ModuleFactory & GetModuleFactory()

Member Data Documentation

◆ className

ModuleKey Nektar::Utilities::ProcessInsertSurface::className
static
Initial value:
ModuleKey(eProcessModule, "insertsurface"),
"Insert high-order surface mesh into current working mesh.")

Definition at line 59 of file ProcessInsertSurface.h.