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

#include <VolumeMesh.h>

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

Public Member Functions

 VolumeMesh (MeshSharedPtr m)
 
virtual ~VolumeMesh ()
 
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
 

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

Definition at line 46 of file VolumeMesh.h.

Constructor & Destructor Documentation

Nektar::NekMeshUtils::VolumeMesh::VolumeMesh ( MeshSharedPtr  m)

Definition at line 56 of file VolumeMesh.cpp.

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

56  : ProcessModule(m)
57 {
58  m_config["blsurfs"] =
59  ConfigOption(false, "0", "Generate prisms on these surfs");
60  m_config["blthick"] = ConfigOption(false, "0", "Prism layer thickness");
61  m_config["bllayers"] = ConfigOption(false, "0", "Prism layers");
62  m_config["blprog"] = ConfigOption(false, "0", "Prism progression");
63 }
NEKMESHUTILS_EXPORT ProcessModule(MeshSharedPtr p_m)
std::map< std::string, ConfigOption > m_config
List of configuration values.
Nektar::NekMeshUtils::VolumeMesh::~VolumeMesh ( )
virtual

Definition at line 65 of file VolumeMesh.cpp.

66 {
67 }

Member Function Documentation

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

Creates an instance of this class.

Definition at line 50 of file VolumeMesh.h.

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

51  {
53  }
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
void Nektar::NekMeshUtils::VolumeMesh::Process ( )
virtual

Implements Nektar::NekMeshUtils::Module.

Definition at line 69 of file VolumeMesh.cpp.

References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), Nektar::NekMeshUtils::Module::ClearElementLinks(), Nektar::LibUtilities::NekFactory< tKey, tBase, >::CreateInstance(), Nektar::LibUtilities::eQuadrilateral, Nektar::StdRegions::find(), Nektar::ParseUtils::GenerateSeqVector(), Nektar::NekMeshUtils::GetElementFactory(), Nektar::iterator, Nektar::NekMeshUtils::Module::m_config, Nektar::NekMeshUtils::Module::m_mesh, Nektar::NekMeshUtils::Module::ProcessComposites(), Nektar::NekMeshUtils::Module::ProcessEdges(), Nektar::NekMeshUtils::Module::ProcessElements(), Nektar::NekMeshUtils::Module::ProcessFaces(), and Nektar::NekMeshUtils::Module::ProcessVertices().

70 {
71  if (m_mesh->m_verbose)
72  cout << endl << "Volume meshing" << endl;
73 
74  bool makeBL;
75  vector<unsigned int> blSurfs;
76 
77  if (m_config["blsurfs"].beenSet)
78  {
79  makeBL = true;
80  ParseUtils::GenerateSeqVector(m_config["blsurfs"].as<string>().c_str(),
81  blSurfs);
82  }
83  else
84  {
85  makeBL = false;
86  }
87 
88  NekDouble prefix = 100;
89  if (m_mesh->m_cad->GetNumSurf() > 100)
90  {
91  prefix *= 10;
92  }
93 
94  TetMeshSharedPtr tet;
95  if (makeBL)
96  {
98  m_mesh, blSurfs, m_config["blthick"].as<NekDouble>(),
99  m_config["bllayers"].as<int>(), m_config["blprog"].as<NekDouble>(),
100  prefix + 1);
101 
102  blmesh->Mesh();
103 
104  // remesh the correct surfaces
105  vector<unsigned int> symsurfs = blmesh->GetSymSurfs();
106  vector<ElementSharedPtr> els = m_mesh->m_element[2];
107  m_mesh->m_element[2].clear();
108  for (int i = 0; i < els.size(); i++)
109  {
111  symsurfs.begin(), symsurfs.end(), els[i]->m_parentCAD->GetId());
112 
113  if (f == symsurfs.end())
114  {
115  m_mesh->m_element[2].push_back(els[i]);
116  }
117  else
118  {
119  // remove element from links
120  vector<EdgeSharedPtr> es = els[i]->GetEdgeList();
121  for (int j = 0; j < es.size(); j++)
122  {
123  vector<pair<ElementSharedPtr, int> > lk = es[j]->m_elLink;
124  es[j]->m_elLink.clear();
125  for (int k = 0; k < lk.size(); k++)
126  {
127  if (lk[k].first == els[i])
128  {
129  continue;
130  }
131  es[j]->m_elLink.push_back(lk[k]);
132  }
133  }
134  }
135  }
136 
137  for (int i = 0; i < symsurfs.size(); i++)
138  {
139  set<int> cIds;
140  vector<CADSystem::EdgeLoopSharedPtr> e =
141  m_mesh->m_cad->GetSurf(symsurfs[i])->GetEdges();
142  for (int k = 0; k < e.size(); k++)
143  {
144  for (int j = 0; j < e[k]->edges.size(); j++)
145  {
146  cIds.insert(e[k]->edges[j]->GetId());
147  }
148  }
149 
150  // find the curve nodes which are on this symsurf
151  map<int, vector<NodeSharedPtr> > curveNodeMap;
153  for (it = m_mesh->m_vertexSet.begin();
154  it != m_mesh->m_vertexSet.end(); it++)
155  {
156  vector<pair<int, CADCurveSharedPtr> > cc =
157  (*it)->GetCADCurves();
158  for (int j = 0; j < cc.size(); j++)
159  {
160  set<int>::iterator f = cIds.find(cc[j].first);
161  if (f != cIds.end())
162  {
163  curveNodeMap[cc[j].first].push_back((*it));
164  }
165  }
166  }
167 
168  // need to bubble sort the vectors
169  map<int, vector<NodeSharedPtr> >::iterator cit;
170  for (cit = curveNodeMap.begin(); cit != curveNodeMap.end(); cit++)
171  {
172  vector<NekDouble> ts;
173  for (int i = 0; i < cit->second.size(); i++)
174  {
175  ts.push_back(cit->second[i]->GetCADCurveInfo(cit->first));
176  }
177  bool repeat = true;
178  while (repeat)
179  {
180  repeat = false;
181  for (int i = 0; i < ts.size() - 1; i++)
182  {
183  if (ts[i] > ts[i + 1])
184  {
185  swap(ts[i], ts[i + 1]);
186  swap(cit->second[i], cit->second[i + 1]);
187  repeat = true;
188  break;
189  }
190  }
191  }
192  }
193 
194  // create quads
195  map<NodeSharedPtr, NodeSharedPtr> nmap = blmesh->GetSymNodes();
196  for (cit = curveNodeMap.begin(); cit != curveNodeMap.end(); cit++)
197  {
198  for (int j = 0; j < cit->second.size() - 1; j++)
199  {
201  nmap.find(cit->second[j]);
203  nmap.find(cit->second[j + 1]);
204 
205  if (f1 == nmap.end() || f2 == nmap.end())
206  {
207  continue;
208  }
209 
210  NodeSharedPtr n1 = f1->second;
211  NodeSharedPtr n2 = f2->second;
212 
213  vector<NodeSharedPtr> ns;
214  ns.push_back(cit->second[j]);
215  ns.push_back(n1);
216  ns.push_back(n2);
217  ns.push_back(cit->second[j + 1]);
218 
219  ElmtConfig conf(LibUtilities::eQuadrilateral, 1, false,
220  false);
221 
222  vector<int> tags;
223  tags.push_back(prefix * 2 + symsurfs[i]);
225  LibUtilities::eQuadrilateral, conf, ns, tags);
226  E->m_parentCAD = m_mesh->m_cad->GetSurf(symsurfs[i]);
227  m_mesh->m_element[2].push_back(E);
228 
229  // need to dummy process the new elements
230  for (int k = 0; k < E->GetEdgeCount(); ++k)
231  {
232  pair<EdgeSet::iterator, bool> testIns;
233  EdgeSharedPtr ed = E->GetEdge(k);
234  testIns = m_mesh->m_edgeSet.insert(ed);
235 
236  if (testIns.second)
237  {
238  EdgeSharedPtr ed2 = *testIns.first;
239  ed2->m_elLink.push_back(
240  pair<ElementSharedPtr, int>(E, k));
241  }
242  else
243  {
244  EdgeSharedPtr e2 = *(testIns.first);
245  E->SetEdge(k, e2);
246  e2->m_elLink.push_back(
247  pair<ElementSharedPtr, int>(E, k));
248  }
249  }
250  }
251  }
252 
253  // swap nodes
254  for (cit = curveNodeMap.begin(); cit != curveNodeMap.end(); cit++)
255  {
256  for (int j = 0; j < cit->second.size(); j++)
257  {
259  nmap.find(cit->second[j]);
260  if (f1 == nmap.end())
261  {
262  continue;
263  }
264  cit->second[j] = f1->second;
265  }
266  }
267  map<int, CurveMeshSharedPtr> cm;
268  for (cit = curveNodeMap.begin(); cit != curveNodeMap.end(); cit++)
269  {
271  cit->first, m_mesh, cit->second);
272  }
273 
275  symsurfs[i], m_mesh, cm, symsurfs[i]);
276  f->Mesh();
277  }
278 
279  vector<unsigned int> blsurfs = blmesh->GetBLSurfs();
280 
281  // build the surface for tetgen to use.
282  vector<ElementSharedPtr> tetsurface = blmesh->GetPseudoSurface();
283  for (int i = 0; i < m_mesh->m_element[2].size(); i++)
284  {
285  if (m_mesh->m_element[2][i]->GetConf().m_e ==
287  {
288  continue;
289  }
290 
292  find(blsurfs.begin(), blsurfs.end(),
293  m_mesh->m_element[2][i]->m_parentCAD->GetId());
294 
295  if (f == blsurfs.end())
296  {
297  tetsurface.push_back(m_mesh->m_element[2][i]);
298  }
299  }
300 
301  tet = MemoryManager<TetMesh>::AllocateSharedPtr(m_mesh, prefix, tetsurface);
302  }
303  else
304  {
306  }
307 
308  tet->Mesh();
309 
311  ProcessVertices();
312  ProcessEdges();
313  ProcessFaces();
314  ProcessElements();
316 
317  if (m_mesh->m_verbose)
318  {
319  cout << endl;
320  }
321 }
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.
ElementFactory & GetElementFactory()
Definition: Element.cpp:47
static bool GenerateSeqVector(const char *const str, std::vector< unsigned int > &vec)
Definition: ParseUtils.hpp:79
boost::shared_ptr< BLMesh > BLMeshSharedPtr
Definition: BLMesh.h:141
virtual NEKMESHUTILS_EXPORT void ProcessFaces(bool ReprocessFaces=true)
Extract element faces.
boost::shared_ptr< FaceMesh > FaceMeshSharedPtr
Definition: FaceMesh.h:161
virtual NEKMESHUTILS_EXPORT void ProcessElements()
Generate element IDs.
boost::shared_ptr< Node > NodeSharedPtr
Definition: Node.h:50
boost::shared_ptr< TetMesh > TetMeshSharedPtr
Definition: TetMesh.h:89
double NekDouble
std::map< std::string, ConfigOption > m_config
List of configuration values.
virtual NEKMESHUTILS_EXPORT void ClearElementLinks()
boost::shared_ptr< Edge > EdgeSharedPtr
Shared pointer to an edge.
Definition: Edge.h:136
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
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
virtual NEKMESHUTILS_EXPORT void ProcessComposites()
Generate composites.

Member Data Documentation

ModuleKey Nektar::NekMeshUtils::VolumeMesh::className
static
Initial value:
"Generates a volume mesh")

Definition at line 54 of file VolumeMesh.h.