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 193 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().

194 {
195  map<int, Array<OneD, NekDouble> > edgeNormals;
196 
197  int eid = 0;
198 
199  for (vector<unsigned>::iterator it = m_blCurves.begin();
200  it != m_blCurves.end(); ++it)
201  {
203  m_mesh->m_cad->GetCurve(*it)->GetOrienationWRT(faceid);
204 
205  vector<EdgeSharedPtr> es = m_curvemeshes[*it]->GetMeshEdges();
206 
207  // on each !!!EDGE!!! calculate a normal
208  // always to the left unless edgeo is 1
209  // normal must be done in the parametric space (and then projected back)
210  // because of face orientation
211  for (int j = 0; j < es.size(); j++)
212  {
213  es[j]->m_id = eid++;
214  Array<OneD, NekDouble> p1, p2;
215  p1 = es[j]->m_n1->GetCADSurfInfo(faceid);
216  p2 = es[j]->m_n2->GetCADSurfInfo(faceid);
217  if (edgeo == CADOrientation::eBackwards)
218  {
219  swap(p1, p2);
220  }
221  Array<OneD, NekDouble> n(2);
222  n[0] = p1[1] - p2[1];
223  n[1] = p2[0] - p1[0];
224  NekDouble mag = sqrt(n[0] * n[0] + n[1] * n[1]);
225  n[0] /= mag;
226  n[1] /= mag;
227 
228  Array<OneD, NekDouble> np = es[j]->m_n1->GetCADSurfInfo(faceid);
229  np[0] += n[0];
230  np[1] += n[1];
231 
232  Array<OneD, NekDouble> loc = es[j]->m_n1->GetLoc();
233  Array<OneD, NekDouble> locp = m_mesh->m_cad->GetSurf(faceid)->P(np);
234 
235  n[0] = locp[0] - loc[0];
236  n[1] = locp[1] - loc[1];
237  mag = sqrt(n[0] * n[0] + n[1] * n[1]);
238  n[0] /= mag;
239  n[1] /= mag;
240 
241  edgeNormals[es[j]->m_id] = n;
242  }
243  }
244 
245  map<NodeSharedPtr, NodeSharedPtr> nodeNormals;
246  map<NodeSharedPtr, vector<EdgeSharedPtr> >::iterator it;
247  for (it = m_nodesToEdge.begin(); it != m_nodesToEdge.end(); it++)
248  {
249  Array<OneD, NekDouble> n(3);
250  ASSERTL0(it->second.size() == 2,
251  "wierdness, most likely bl_surfs are incorrect");
252  Array<OneD, NekDouble> n1 = edgeNormals[it->second[0]->m_id];
253  Array<OneD, NekDouble> n2 = edgeNormals[it->second[1]->m_id];
254 
255  n[0] = (n1[0] + n2[0]) / 2.0;
256  n[1] = (n1[1] + n2[1]) / 2.0;
257  NekDouble mag = sqrt(n[0] * n[0] + n[1] * n[1]);
258  n[0] /= mag;
259  n[1] /= mag;
260 
261  NekDouble t = m_thickness.Evaluate(m_thickness_ID, it->first->m_x,
262  it->first->m_y, 0.0, 0.0);
263 
264  n[0] = n[0] * t + it->first->m_x;
265  n[1] = n[1] * t + it->first->m_y;
266  n[2] = 0.0;
267 
268  NodeSharedPtr nn = boost::shared_ptr<Node>(
269  new Node(m_mesh->m_numNodes++, n[0], n[1], 0.0));
270  CADSurfSharedPtr s = m_mesh->m_cad->GetSurf(faceid);
271  Array<OneD, NekDouble> uv = s->locuv(n);
272  nn->SetCADSurf(faceid, s, uv);
273  nodeNormals[it->first] = nn;
274  }
275 
276  for (vector<unsigned>::iterator it = m_blCurves.begin();
277  it != m_blCurves.end(); ++it)
278  {
280  m_mesh->m_cad->GetCurve(*it)->GetOrienationWRT(faceid);
281 
282  vector<NodeSharedPtr> ns = m_curvemeshes[*it]->GetMeshPoints();
283  vector<NodeSharedPtr> newNs;
284  for (int i = 0; i < ns.size(); i++)
285  {
286  newNs.push_back(nodeNormals[ns[i]]);
287  }
288  m_curvemeshes[*it] =
290 
291  if (edgeo == CADOrientation::eBackwards)
292  {
293  reverse(ns.begin(), ns.end());
294  }
295  for (int i = 0; i < ns.size() - 1; ++i)
296  {
297  vector<NodeSharedPtr> qns;
298 
299  qns.push_back(ns[i]);
300  qns.push_back(ns[i + 1]);
301  qns.push_back(nodeNormals[ns[i + 1]]);
302  qns.push_back(nodeNormals[ns[i]]);
303 
304  ElmtConfig conf(LibUtilities::eQuadrilateral, 1, false, false);
305 
306  vector<int> tags;
307  tags.push_back(101);
308 
310  LibUtilities::eQuadrilateral, conf, qns, tags);
311 
312  E->m_parentCAD = m_mesh->m_cad->GetSurf(faceid);
313 
314  for (int j = 0; j < E->GetEdgeCount(); ++j)
315  {
316  pair<EdgeSet::iterator, bool> testIns;
317  EdgeSharedPtr ed = E->GetEdge(j);
318  // look for edge in m_mesh edgeset from curves
319  EdgeSet::iterator s = m_mesh->m_edgeSet.find(ed);
320  if (!(s == m_mesh->m_edgeSet.end()))
321  {
322  ed = *s;
323  E->SetEdge(j, *s);
324  }
325  }
326  m_mesh->m_element[2].push_back(E);
327  }
328  }
329 }
#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:135
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 172 of file 2DGenerator.cpp.

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

Referenced by Process().

173 {
174  if (m_mesh->m_verbose)
175  {
176  cout << endl << "\tBoundary layer meshing:" << endl << endl;
177  }
178 
179  // identify the nodes which will become the boundary layer.
180 
181  for (vector<unsigned>::iterator it = m_blCurves.begin();
182  it != m_blCurves.end(); ++it)
183  {
184  vector<EdgeSharedPtr> localedges = m_curvemeshes[*it]->GetMeshEdges();
185  for (int i = 0; i < localedges.size(); i++)
186  {
187  m_nodesToEdge[localedges[i]->m_n1].push_back(localedges[i]);
188  m_nodesToEdge[localedges[i]->m_n2].push_back(localedges[i]);
189  }
190  }
191 }
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(), 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  if (m_mesh->m_verbose)
67  {
68  cout << endl << "2D meshing" << endl;
69  cout << endl << "\tCurve meshing:" << endl << endl;
70  }
71 
72  m_mesh->m_numNodes = m_mesh->m_cad->GetNumVerts();
73 
75  m_thickness.DefineFunction("x y z", m_config["blthick"].as<string>());
76 
77  ParseUtils::GenerateSeqVector(m_config["blcurves"].as<string>().c_str(),
78  m_blCurves);
79 
80  // linear mesh all curves
81  for (int i = 1; i <= m_mesh->m_cad->GetNumCurve(); i++)
82  {
83  if (m_mesh->m_verbose)
84  {
85  LibUtilities::PrintProgressbar(i, m_mesh->m_cad->GetNumCurve(),
86  "Curve progress");
87  }
88 
90  find(m_blCurves.begin(), m_blCurves.end(), i);
91 
92  if (f == m_blCurves.end())
93  {
94  m_curvemeshes[i] =
96  }
97  else
98  {
100  i, m_mesh, m_config["blthick"].as<string>());
101  }
102 
103  m_curvemeshes[i]->Mesh();
104  }
105 
106  ////////////////////////////////////////
107 
108  if (m_config["blcurves"].beenSet)
109  {
110  // we need to do the boundary layer generation in a face by face basis
111  MakeBLPrep();
112 
113  for (int i = 1; i <= m_mesh->m_cad->GetNumSurf(); i++)
114  {
115  MakeBL(i);
116  }
117  }
118 
119  if (m_mesh->m_verbose)
120  {
121  cout << endl << "\tFace meshing:" << endl << endl;
122  }
123 
124  // linear mesh all surfaces
125  for (int i = 1; i <= m_mesh->m_cad->GetNumSurf(); i++)
126  {
127  if (m_mesh->m_verbose)
128  {
129  LibUtilities::PrintProgressbar(i, m_mesh->m_cad->GetNumSurf(),
130  "Face progress");
131  }
132 
133  m_facemeshes[i] =
135  m_curvemeshes, 99+i);
136  m_facemeshes[i]->Mesh();
137  }
138 
139  ////////////////////////////////////
140 
142  for (it = m_mesh->m_edgeSet.begin(); it != m_mesh->m_edgeSet.end(); it++)
143  {
144  vector<NodeSharedPtr> ns;
145  ns.push_back((*it)->m_n1);
146  ns.push_back((*it)->m_n2);
147 
148  // for each iterator create a LibUtilities::eSegement
149  // push segment into m_mesh->m_element[1]
150  // tag for the elements shoudl be the CAD number of the curves
151 
152  ElmtConfig conf(LibUtilities::eSegment, 1, false, false);
153 
154  vector<int> tags;
155  tags.push_back((*it)->m_parentCAD->GetId());
156 
158  LibUtilities::eSegment, conf, ns, tags);
159 
160  m_mesh->m_element[1].push_back(E2);
161  }
162 
163  ProcessVertices();
164  ProcessEdges();
165  ProcessFaces();
166  ProcessElements();
168 
169  Report();
170 }
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 331 of file 2DGenerator.cpp.

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

Referenced by Process().

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

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().