Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
Nektar::NekMeshUtils::Generator2D Class Reference

class containing all surface meshing routines methods and classes More...

#include <2DGenerator.h>

Inheritance diagram for Nektar::NekMeshUtils::Generator2D:
Inheritance graph
[legend]
Collaboration diagram for Nektar::NekMeshUtils::Generator2D:
Collaboration graph
[legend]

Public Member Functions

 Generator2D (MeshSharedPtr m)
 
virtual ~Generator2D ()
 
virtual void Process ()
 
- 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)
 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 boost::shared_ptr< Modulecreate (MeshSharedPtr m)
 Creates an instance of this class. More...
 

Static Public Attributes

static ModuleKey className
 

Private Member Functions

void MakeBLPrep ()
 
void MakeBL (int faceid)
 
void Report ()
 

Private Attributes

std::map< int, FaceMeshSharedPtrm_facemeshes
 map of individual surface meshes from parametric surfaces More...
 
std::map< int, CurveMeshSharedPtrm_curvemeshes
 map of individual curve meshes of the curves in the domain More...
 
std::vector< unsigned int > m_blCurves
 
LibUtilities::AnalyticExpressionEvaluator m_thickness
 
int m_thickness_ID
 
std::map< NodeSharedPtr,
std::vector< EdgeSharedPtr > > 
m_nodesToEdge
 

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,
ConfigOption
m_config
 List of configuration values. More...
 

Detailed Description

class containing all surface meshing routines methods and classes

Definition at line 53 of file 2DGenerator.h.

Constructor & Destructor Documentation

Nektar::NekMeshUtils::Generator2D::Generator2D ( MeshSharedPtr  m)

Definition at line 52 of file 2DGenerator.cpp.

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

52  : ProcessModule(m)
53 {
54  m_config["blcurves"] =
55  ConfigOption(false, "", "Generate parallelograms on these curves");
56  m_config["blthick"] =
57  ConfigOption(false, "0.0", "Parallelogram layer thickness");
58 }
NEKMESHUTILS_EXPORT ProcessModule(MeshSharedPtr p_m)
std::map< std::string, ConfigOption > m_config
List of configuration values.
Nektar::NekMeshUtils::Generator2D::~Generator2D ( )
virtual

Definition at line 60 of file 2DGenerator.cpp.

61 {
62 }

Member Function Documentation

static boost::shared_ptr<Module> Nektar::NekMeshUtils::Generator2D::create ( MeshSharedPtr  m)
inlinestatic

Creates an instance of this class.

Definition at line 57 of file 2DGenerator.h.

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

58  {
60  }
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
void Nektar::NekMeshUtils::Generator2D::MakeBL ( int  faceid)
private

Definition at line 197 of file 2DGenerator.cpp.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), ASSERTL0, Nektar::LibUtilities::NekFactory< tKey, tBase, >::CreateInstance(), Nektar::NekMeshUtils::CADOrientation::eBackwards, Nektar::LibUtilities::eQuadrilateral, Nektar::LibUtilities::AnalyticExpressionEvaluator::Evaluate(), Nektar::NekMeshUtils::GetElementFactory(), Nektar::iterator, m_blCurves, m_curvemeshes, Nektar::NekMeshUtils::Module::m_mesh, m_nodesToEdge, m_thickness, m_thickness_ID, and class_topology::Node.

Referenced by Process().

198 {
199  map<int, Array<OneD, NekDouble> > edgeNormals;
200 
201  int eid = 0;
202 
203  for (vector<unsigned>::iterator it = m_blCurves.begin();
204  it != m_blCurves.end(); ++it)
205  {
207  m_mesh->m_cad->GetCurve(*it)->GetOrienationWRT(faceid);
208 
209  vector<EdgeSharedPtr> es = m_curvemeshes[*it]->GetMeshEdges();
210 
211  // on each !!!EDGE!!! calculate a normal
212  // always to the left unless edgeo is 1
213  // normal must be done in the parametric space (and then projected back)
214  // because of face orientation
215  for (int j = 0; j < es.size(); j++)
216  {
217  es[j]->m_id = eid++;
218  Array<OneD, NekDouble> p1, p2;
219  p1 = es[j]->m_n1->GetCADSurfInfo(faceid);
220  p2 = es[j]->m_n2->GetCADSurfInfo(faceid);
221  if (edgeo == CADOrientation::eBackwards)
222  {
223  swap(p1, p2);
224  }
225  Array<OneD, NekDouble> n(2);
226  n[0] = p1[1] - p2[1];
227  n[1] = p2[0] - p1[0];
228  NekDouble mag = sqrt(n[0] * n[0] + n[1] * n[1]);
229  n[0] /= mag;
230  n[1] /= mag;
231 
232  Array<OneD, NekDouble> np = es[j]->m_n1->GetCADSurfInfo(faceid);
233  np[0] += n[0];
234  np[1] += n[1];
235 
236  Array<OneD, NekDouble> loc = es[j]->m_n1->GetLoc();
237  Array<OneD, NekDouble> locp = m_mesh->m_cad->GetSurf(faceid)->P(np);
238 
239  n[0] = locp[0] - loc[0];
240  n[1] = locp[1] - loc[1];
241  mag = sqrt(n[0] * n[0] + n[1] * n[1]);
242  n[0] /= mag;
243  n[1] /= mag;
244 
245  edgeNormals[es[j]->m_id] = n;
246  }
247  }
248 
249  map<NodeSharedPtr, NodeSharedPtr> nodeNormals;
250  map<NodeSharedPtr, vector<EdgeSharedPtr> >::iterator it;
251  for (it = m_nodesToEdge.begin(); it != m_nodesToEdge.end(); it++)
252  {
253  Array<OneD, NekDouble> n(3);
254  ASSERTL0(it->second.size() == 2,
255  "wierdness, most likely bl_surfs are incorrect");
256  Array<OneD, NekDouble> n1 = edgeNormals[it->second[0]->m_id];
257  Array<OneD, NekDouble> n2 = edgeNormals[it->second[1]->m_id];
258 
259  n[0] = (n1[0] + n2[0]) / 2.0;
260  n[1] = (n1[1] + n2[1]) / 2.0;
261  NekDouble mag = sqrt(n[0] * n[0] + n[1] * n[1]);
262  n[0] /= mag;
263  n[1] /= mag;
264 
265  NekDouble t = m_thickness.Evaluate(m_thickness_ID, it->first->m_x,
266  it->first->m_y, 0.0, 0.0);
267 
268  n[0] = n[0] * t + it->first->m_x;
269  n[1] = n[1] * t + it->first->m_y;
270  n[2] = 0.0;
271 
272  NodeSharedPtr nn = boost::shared_ptr<Node>(
273  new Node(m_mesh->m_numNodes++, n[0], n[1], 0.0));
274  CADSurfSharedPtr s = m_mesh->m_cad->GetSurf(faceid);
275  Array<OneD, NekDouble> uv = s->locuv(n);
276  nn->SetCADSurf(faceid, s, uv);
277  nodeNormals[it->first] = nn;
278  }
279 
280  for (vector<unsigned>::iterator it = m_blCurves.begin();
281  it != m_blCurves.end(); ++it)
282  {
284  m_mesh->m_cad->GetCurve(*it)->GetOrienationWRT(faceid);
285 
286  vector<NodeSharedPtr> ns = m_curvemeshes[*it]->GetMeshPoints();
287  vector<NodeSharedPtr> newNs;
288  for (int i = 0; i < ns.size(); i++)
289  {
290  newNs.push_back(nodeNormals[ns[i]]);
291  }
292  m_curvemeshes[*it] =
294 
295  if (edgeo == CADOrientation::eBackwards)
296  {
297  reverse(ns.begin(), ns.end());
298  }
299  for (int i = 0; i < ns.size() - 1; ++i)
300  {
301  vector<NodeSharedPtr> qns;
302 
303  qns.push_back(ns[i]);
304  qns.push_back(ns[i + 1]);
305  qns.push_back(nodeNormals[ns[i + 1]]);
306  qns.push_back(nodeNormals[ns[i]]);
307 
308  ElmtConfig conf(LibUtilities::eQuadrilateral, 1, false, false);
309 
310  vector<int> tags;
311  tags.push_back(101);
312 
314  LibUtilities::eQuadrilateral, conf, qns, tags);
315 
316  E->m_parentCAD = m_mesh->m_cad->GetSurf(faceid);
317 
318  for (int j = 0; j < E->GetEdgeCount(); ++j)
319  {
320  pair<EdgeSet::iterator, bool> testIns;
321  EdgeSharedPtr ed = E->GetEdge(j);
322  // look for edge in m_mesh edgeset from curves
323  EdgeSet::iterator s = m_mesh->m_edgeSet.find(ed);
324  if (!(s == m_mesh->m_edgeSet.end()))
325  {
326  ed = *s;
327  E->SetEdge(j, *s);
328  }
329  }
330  m_mesh->m_element[2].push_back(E);
331  }
332  }
333 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:198
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
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
std::vector< unsigned int > m_blCurves
Definition: 2DGenerator.h:80
NekDouble Evaluate(const int AnalyticExpression_id)
Evaluation method for expressions depending on parameters only.
ElementFactory & GetElementFactory()
Definition: Element.cpp:47
LibUtilities::AnalyticExpressionEvaluator m_thickness
Definition: 2DGenerator.h:81
boost::shared_ptr< Node > NodeSharedPtr
Definition: Node.h:50
double NekDouble
boost::shared_ptr< Edge > EdgeSharedPtr
Shared pointer to an edge.
Definition: Edge.h:136
boost::shared_ptr< CADSurf > CADSurfSharedPtr
Definition: CADSurf.h:172
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
boost::shared_ptr< Element > ElementSharedPtr
Definition: Edge.h:49
std::map< NodeSharedPtr, std::vector< EdgeSharedPtr > > m_nodesToEdge
Definition: 2DGenerator.h:83
std::map< int, CurveMeshSharedPtr > m_curvemeshes
map of individual curve meshes of the curves in the domain
Definition: 2DGenerator.h:78
void Nektar::NekMeshUtils::Generator2D::MakeBLPrep ( )
private

Definition at line 176 of file 2DGenerator.cpp.

References Nektar::iterator, m_blCurves, m_curvemeshes, Nektar::NekMeshUtils::Module::m_mesh, and m_nodesToEdge.

Referenced by Process().

177 {
178  if (m_mesh->m_verbose)
179  {
180  cout << endl << "\tBoundary layer meshing:" << endl << endl;
181  }
182 
183  // identify the nodes which will become the boundary layer.
184 
185  for (vector<unsigned>::iterator it = m_blCurves.begin();
186  it != m_blCurves.end(); ++it)
187  {
188  vector<EdgeSharedPtr> localedges = m_curvemeshes[*it]->GetMeshEdges();
189  for (int i = 0; i < localedges.size(); i++)
190  {
191  m_nodesToEdge[localedges[i]->m_n1].push_back(localedges[i]);
192  m_nodesToEdge[localedges[i]->m_n2].push_back(localedges[i]);
193  }
194  }
195 }
std::vector< unsigned int > m_blCurves
Definition: 2DGenerator.h:80
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
std::map< NodeSharedPtr, std::vector< EdgeSharedPtr > > m_nodesToEdge
Definition: 2DGenerator.h:83
std::map< int, CurveMeshSharedPtr > m_curvemeshes
map of individual curve meshes of the curves in the domain
Definition: 2DGenerator.h:78
void Nektar::NekMeshUtils::Generator2D::Process ( )
virtual

Implements Nektar::NekMeshUtils::Module.

Definition at line 64 of file 2DGenerator.cpp.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), ASSERTL0, Nektar::LibUtilities::NekFactory< tKey, tBase, >::CreateInstance(), Nektar::LibUtilities::AnalyticExpressionEvaluator::DefineFunction(), Nektar::LibUtilities::eSegment, Nektar::StdRegions::find(), Nektar::ParseUtils::GenerateSeqVector(), Nektar::NekMeshUtils::GetElementFactory(), Nektar::iterator, m_blCurves, Nektar::NekMeshUtils::Module::m_config, m_curvemeshes, m_facemeshes, Nektar::NekMeshUtils::Module::m_mesh, m_thickness, m_thickness_ID, MakeBL(), MakeBLPrep(), Nektar::LibUtilities::PrintProgressbar(), Nektar::NekMeshUtils::Module::ProcessComposites(), Nektar::NekMeshUtils::Module::ProcessEdges(), Nektar::NekMeshUtils::Module::ProcessElements(), Nektar::NekMeshUtils::Module::ProcessFaces(), Nektar::NekMeshUtils::Module::ProcessVertices(), and Report().

65 {
66  // Check that cad is 2D
67  Array<OneD, NekDouble> bndBox = m_mesh->m_cad->GetBoundingBox();
68  ASSERTL0(fabs(bndBox[5] - bndBox[4]) < 1.0e-7, "CAD isn't 2D");
69 
70  if (m_mesh->m_verbose)
71  {
72  cout << endl << "2D meshing" << endl;
73  cout << endl << "\tCurve meshing:" << endl << endl;
74  }
75 
76  m_mesh->m_numNodes = m_mesh->m_cad->GetNumVerts();
77 
79  m_thickness.DefineFunction("x y z", m_config["blthick"].as<string>());
80 
81  ParseUtils::GenerateSeqVector(m_config["blcurves"].as<string>().c_str(),
82  m_blCurves);
83 
84  // linear mesh all curves
85  for (int i = 1; i <= m_mesh->m_cad->GetNumCurve(); i++)
86  {
87  if (m_mesh->m_verbose)
88  {
89  LibUtilities::PrintProgressbar(i, m_mesh->m_cad->GetNumCurve(),
90  "Curve progress");
91  }
92 
94  find(m_blCurves.begin(), m_blCurves.end(), i);
95 
96  if (f == m_blCurves.end())
97  {
98  m_curvemeshes[i] =
100  }
101  else
102  {
104  i, m_mesh, m_config["blthick"].as<string>());
105  }
106 
107  m_curvemeshes[i]->Mesh();
108  }
109 
110  ////////////////////////////////////////
111 
112  if (m_config["blcurves"].beenSet)
113  {
114  // we need to do the boundary layer generation in a face by face basis
115  MakeBLPrep();
116 
117  for (int i = 1; i <= m_mesh->m_cad->GetNumSurf(); i++)
118  {
119  MakeBL(i);
120  }
121  }
122 
123  if (m_mesh->m_verbose)
124  {
125  cout << endl << "\tFace meshing:" << endl << endl;
126  }
127 
128  // linear mesh all surfaces
129  for (int i = 1; i <= m_mesh->m_cad->GetNumSurf(); i++)
130  {
131  if (m_mesh->m_verbose)
132  {
133  LibUtilities::PrintProgressbar(i, m_mesh->m_cad->GetNumSurf(),
134  "Face progress");
135  }
136 
137  m_facemeshes[i] =
139  m_curvemeshes, 99+i);
140  m_facemeshes[i]->Mesh();
141  }
142 
143  ////////////////////////////////////
144 
146  for (it = m_mesh->m_edgeSet.begin(); it != m_mesh->m_edgeSet.end(); it++)
147  {
148  vector<NodeSharedPtr> ns;
149  ns.push_back((*it)->m_n1);
150  ns.push_back((*it)->m_n2);
151 
152  // for each iterator create a LibUtilities::eSegement
153  // push segment into m_mesh->m_element[1]
154  // tag for the elements shoudl be the CAD number of the curves
155 
156  ElmtConfig conf(LibUtilities::eSegment, 1, false, false);
157 
158  vector<int> tags;
159  tags.push_back((*it)->m_parentCAD->GetId());
160 
162  LibUtilities::eSegment, conf, ns, tags);
163 
164  m_mesh->m_element[1].push_back(E2);
165  }
166 
167  ProcessVertices();
168  ProcessEdges();
169  ProcessFaces();
170  ProcessElements();
172 
173  Report();
174 }
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:198
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
int PrintProgressbar(const int position, const int goal, const string message, int lastprogress=-1)
Prints a progressbar.
Definition: Progressbar.hpp:69
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
std::vector< unsigned int > m_blCurves
Definition: 2DGenerator.h:80
std::map< int, FaceMeshSharedPtr > m_facemeshes
map of individual surface meshes from parametric surfaces
Definition: 2DGenerator.h:76
ElementFactory & GetElementFactory()
Definition: Element.cpp:47
static bool GenerateSeqVector(const char *const str, std::vector< unsigned int > &vec)
Definition: ParseUtils.hpp:79
LibUtilities::AnalyticExpressionEvaluator m_thickness
Definition: 2DGenerator.h:81
virtual NEKMESHUTILS_EXPORT void ProcessFaces(bool ReprocessFaces=true)
Extract element faces.
virtual NEKMESHUTILS_EXPORT void ProcessElements()
Generate element IDs.
std::map< std::string, ConfigOption > m_config
List of configuration values.
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
int DefineFunction(const std::string &vlist, const std::string &function)
This function allows one to define a function to evaluate. The first argument (vlist) is a list of va...
virtual NEKMESHUTILS_EXPORT void ProcessVertices()
Extract element vertices.
virtual NEKMESHUTILS_EXPORT void ProcessEdges(bool ReprocessEdges=true)
Extract element edges.
InputIterator find(InputIterator first, InputIterator last, InputIterator startingpoint, const EqualityComparable &value)
Definition: StdRegions.hpp:316
boost::shared_ptr< Element > ElementSharedPtr
Definition: Edge.h:49
std::map< int, CurveMeshSharedPtr > m_curvemeshes
map of individual curve meshes of the curves in the domain
Definition: 2DGenerator.h:78
virtual NEKMESHUTILS_EXPORT void ProcessComposites()
Generate composites.
void Nektar::NekMeshUtils::Generator2D::Report ( )
private

Definition at line 335 of file 2DGenerator.cpp.

References Nektar::NekMeshUtils::Module::m_mesh.

Referenced by Process().

336 {
337  if (m_mesh->m_verbose)
338  {
339  int ns = m_mesh->m_vertexSet.size();
340  int es = m_mesh->m_edgeSet.size();
341  int ts = m_mesh->m_element[2].size();
342  int ep = ns - es + ts;
343  cout << endl << "\tSurface mesh statistics" << endl;
344  cout << "\t\tNodes: " << ns << endl;
345  cout << "\t\tEdges: " << es << endl;
346  cout << "\t\tTriangles " << ts << endl;
347  cout << "\t\tEuler-PoincarĂ© characteristic: " << ep << endl;
348  }
349 }

Member Data Documentation

ModuleKey Nektar::NekMeshUtils::Generator2D::className
static
Initial value:

Definition at line 61 of file 2DGenerator.h.

std::vector<unsigned int> Nektar::NekMeshUtils::Generator2D::m_blCurves
private

Definition at line 80 of file 2DGenerator.h.

Referenced by MakeBL(), MakeBLPrep(), and Process().

std::map<int, CurveMeshSharedPtr> Nektar::NekMeshUtils::Generator2D::m_curvemeshes
private

map of individual curve meshes of the curves in the domain

Definition at line 78 of file 2DGenerator.h.

Referenced by MakeBL(), MakeBLPrep(), and Process().

std::map<int, FaceMeshSharedPtr> Nektar::NekMeshUtils::Generator2D::m_facemeshes
private

map of individual surface meshes from parametric surfaces

Definition at line 76 of file 2DGenerator.h.

Referenced by Process().

std::map<NodeSharedPtr, std::vector<EdgeSharedPtr> > Nektar::NekMeshUtils::Generator2D::m_nodesToEdge
private

Definition at line 83 of file 2DGenerator.h.

Referenced by MakeBL(), and MakeBLPrep().

LibUtilities::AnalyticExpressionEvaluator Nektar::NekMeshUtils::Generator2D::m_thickness
private

Definition at line 81 of file 2DGenerator.h.

Referenced by MakeBL(), and Process().

int Nektar::NekMeshUtils::Generator2D::m_thickness_ID
private

Definition at line 82 of file 2DGenerator.h.

Referenced by MakeBL(), and Process().