38 #include <boost/thread.hpp>
54 "Reads mesh configuration and will generate the mesh file.");
69 vector<string> filename;
70 filename.push_back(nm);
74 ASSERTL0(pSession->DefinesElement(
"NEKTAR/MESHING"),
"no meshing tag");
75 ASSERTL0(pSession->DefinesElement(
"NEKTAR/MESHING/INFORMATION"),
76 "no information tag");
77 ASSERTL0(pSession->DefinesElement(
"NEKTAR/MESHING/PARAMETERS"),
80 TiXmlElement *mcf = pSession->GetElement(
"NEKTAR/MESHING");
82 TiXmlElement *info = mcf->FirstChildElement(
"INFORMATION");
83 TiXmlElement *I = info->FirstChildElement(
"I");
84 map<string, string> information;
88 I->QueryStringAttribute(
"PROPERTY", &tmp1);
89 I->QueryStringAttribute(
"VALUE", &tmp2);
90 information[tmp1] = tmp2;
91 I = I->NextSiblingElement(
"I");
94 TiXmlElement *param = mcf->FirstChildElement(
"PARAMETERS");
95 TiXmlElement *
P = param->FirstChildElement(
"P");
96 map<string, string> parameters;
100 P->QueryStringAttribute(
"PARAM", &tmp1);
101 P->QueryStringAttribute(
"VALUE", &tmp2);
102 parameters[tmp1] = tmp2;
103 P = P->NextSiblingElement(
"P");
106 set<string> boolparameters;
108 if (pSession->DefinesElement(
"NEKTAR/MESHING/BOOLPARAMETERS"))
110 TiXmlElement *bparam = mcf->FirstChildElement(
"BOOLPARAMETERS");
111 TiXmlElement *BP = bparam->FirstChildElement(
"P");
116 BP->QueryStringAttribute(
"VALUE", &tmp);
117 boolparameters.insert(tmp);
118 BP = BP->NextSiblingElement(
"P");
122 set<string> refinement;
123 if (pSession->DefinesElement(
"NEKTAR/MESHING/REFINEMENT"))
125 TiXmlElement *refine = mcf->FirstChildElement(
"REFINEMENT");
126 TiXmlElement *
L = refine->FirstChildElement(
"LINE");
131 TiXmlElement *T = L->FirstChildElement(
"X1");
132 ss << T->GetText() <<
",";
133 T = L->FirstChildElement(
"Y1");
134 ss << T->GetText() <<
",";
135 T = L->FirstChildElement(
"Z1");
136 ss << T->GetText() <<
",";
137 T = L->FirstChildElement(
"X2");
138 ss << T->GetText() <<
",";
139 T = L->FirstChildElement(
"Y2");
140 ss << T->GetText() <<
",";
141 T = L->FirstChildElement(
"Z2");
142 ss << T->GetText() <<
",";
143 T = L->FirstChildElement(
"R");
144 ss << T->GetText() <<
",";
145 T = L->FirstChildElement(
"D");
148 refinement.insert(ss.str());
150 L = L->NextSiblingElement(
"LINE");
156 it = information.find(
"CADFile");
157 ASSERTL0(it != information.end(),
"no cadfile defined");
160 it = information.find(
"MeshType");
161 ASSERTL0(it != information.end(),
"no meshtype defined");
162 m_makeBL = it->second ==
"3DBndLayer";
163 m_2D = it->second ==
"2D";
165 if (it->second ==
"2DBndLayer")
172 ASSERTL0(it->second ==
"3D",
"unsure on MeshType")
175 it = parameters.find(
"MinDelta");
176 ASSERTL0(it != parameters.end(),
"no mindelta defined");
179 it = parameters.find(
"MaxDelta");
180 ASSERTL0(it != parameters.end(),
"no maxdelta defined");
183 it = parameters.find(
"EPS");
184 ASSERTL0(it != parameters.end(),
"no eps defined");
187 it = parameters.find(
"Order");
188 ASSERTL0(it != parameters.end(),
"no order defined");
193 it = parameters.find(
"BndLayerSurfaces");
194 ASSERTL0(it != parameters.end(),
"no BndLayersurfs defined");
197 it = parameters.find(
"BndLayerThickness");
198 ASSERTL0(it != parameters.end(),
"no BndLayerthick defined");
201 it = parameters.find(
"BndLayerLayers");
206 it = parameters.find(
"BndLayerProgression");
207 m_blprog = it != parameters.end() ? it->second :
"2.0";
212 if (
m_2D && m_cadfile.find(
'.') == std::string::npos)
217 it = parameters.find(
"Xmin");
218 ASSERTL0(it != parameters.end(),
"no xmin defined");
219 ss << it->second <<
",";
220 it = parameters.find(
"Ymin");
221 ASSERTL0(it != parameters.end(),
"no ymin defined");
222 ss << it->second <<
",";
223 it = parameters.find(
"Xmax");
224 ASSERTL0(it != parameters.end(),
"no xmax defined");
225 ss << it->second <<
",";
226 it = parameters.find(
"Ymax");
227 ASSERTL0(it != parameters.end(),
"no zmax defined");
228 ss << it->second <<
",";
229 it = parameters.find(
"AOA");
230 ASSERTL0(it != parameters.end(),
"no aoa defined");
237 sit = boolparameters.find(
"SurfaceOptimiser");
239 sit = boolparameters.find(
"WriteOctree");
240 m_woct = sit != boolparameters.end();
241 sit = boolparameters.find(
"VariationalOptimiser");
248 for (sit = refinement.begin(); sit != refinement.end(); sit++)
271 module->RegisterConfig(
"filename",
m_cadfile);
275 module->RegisterConfig(
"2D",
"");
282 module->SetDefaults();
290 module->RegisterConfig(
"eps",
m_eps);
297 module->RegisterConfig(
"writeoctree",
"");
300 module->SetDefaults();
312 module->RegisterConfig(
"blcurves",
m_blsurfs);
313 module->RegisterConfig(
"blthick",
m_blthick);
318 module->SetDefaults();
321 catch (runtime_error &e)
323 cout <<
"2D linear mesh generator failed with message:" << endl;
324 cout << e.what() << endl;
325 cout <<
"No mesh file has been created" << endl;
337 module->SetDefaults();
340 catch (runtime_error &e)
342 cout <<
"Surface meshing has failed with message:" << endl;
343 cout << e.what() << endl;
344 cout <<
"Any surfaces which were succsessfully meshed will be "
345 "dumped as a manifold mesh"
368 module->RegisterConfig(
"blsurfs",
m_blsurfs);
369 module->RegisterConfig(
"blthick",
m_blthick);
370 module->RegisterConfig(
"bllayers",
m_bllayers);
371 module->RegisterConfig(
"blprog",
m_blprog);
376 module->SetDefaults();
379 catch (runtime_error &e)
381 cout <<
"Volume meshing has failed with message:" << endl;
382 cout << e.what() << endl;
383 cout <<
"The linear surface mesh be dumped as a manifold mesh"
386 m_mesh->m_element[3].clear();
402 module->RegisterConfig(
"opti",
"");
407 module->SetDefaults();
410 catch (runtime_error &e)
412 cout <<
"High-order surface meshing has failed with message:" << endl;
413 cout << e.what() << endl;
414 cout <<
"The mesh will be written as normal but the incomplete surface "
415 "will remain faceted"
423 unsigned int np = boost::thread::physical_concurrency();
426 cout <<
"Detecting 4 cores, will attempt to run in parrallel"
431 module->RegisterConfig(
"hyperelastic",
"");
432 module->RegisterConfig(
"maxiter",
"10");
433 module->RegisterConfig(
"numthreads",
434 boost::lexical_cast<string>(np));
438 module->SetDefaults();
441 catch (runtime_error &e)
443 cout <<
"Variational optimisation has failed with message:" << endl;
444 cout << e.what() << endl;
445 cout <<
"The mesh will be written as is, it may be invalid" << endl;
456 module->RegisterConfig(
"surf",
m_blsurfs);
457 module->RegisterConfig(
458 "nq", boost::lexical_cast<string>(
m_mesh->m_nummode));
459 module->RegisterConfig(
"r",
m_blprog);
463 module->SetDefaults();
466 catch (runtime_error &e)
468 cout <<
"Boundary layer splitting has failed with message:" << endl;
469 cout << e.what() << endl;
470 cout <<
"The mesh will be written as is, it may be invalid" << endl;
#define ASSERTL0(condition, msg)
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.
pair< ModuleType, string > ModuleKey
MeshSharedPtr m_mesh
Mesh object.
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
static SessionReaderSharedPtr CreateInstance(int argc, char *argv[])
Creates an instance of the SessionReader class.
virtual NEKMESHUTILS_EXPORT void ProcessFaces(bool ReprocessFaces=true)
Extract element faces.
boost::shared_ptr< Module > ModuleSharedPtr
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
boost::shared_ptr< Mesh > MeshSharedPtr
Shared pointer to a mesh.
virtual NEKMESHUTILS_EXPORT void ProcessVertices()
Extract element vertices.
virtual NEKMESHUTILS_EXPORT void ProcessEdges(bool ReprocessEdges=true)
Extract element edges.
std::pair< ModuleType, std::string > ModuleKey
virtual NEKMESHUTILS_EXPORT void ProcessComposites()
Generate composites.
ModuleFactory & GetModuleFactory()
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.