39 #include "../InputModules/InputGmsh.h"
52 "Writes Gmsh msh file.");
62 for (it = igelmap.begin(); it != igelmap.end(); ++it)
64 elmMap[it->second] = it->first;
86 cout <<
"OutputGmsh: Writing file..." << endl;
95 <<
"$EndMeshFormat" << endl;
97 int id =
m_mesh->m_vertexSet.size();
98 vector<ElementSharedPtr> toComplete;
104 for (
int i = 0; i <
m_mesh->m_element[
m_mesh->m_expDim].size(); ++i)
107 if (e->GetMaxOrder() > maxOrder)
109 maxOrder = e->GetMaxOrder();
114 for (
int d = 1; d <= 3; ++d)
116 for (
int i = 0; i <
m_mesh->m_element[d].size(); ++i)
119 if ((e->GetConf().m_order <= 1 && maxOrder > 1) ||
120 (e->GetConf().m_order == maxOrder &&
121 e->GetConf().m_faceNodes ==
false))
123 toComplete.push_back(e);
133 for (
int i = 0; i < toComplete.size(); ++i)
135 toComplete[i]->Complete(maxOrder);
139 for (
int d = 1; d <= 3; ++d)
141 for (
int i = 0; i <
m_mesh->m_element[d].size(); ++i)
145 boost::unordered_set<int> edgesDone;
146 boost::unordered_set<int> facesDone;
149 if (e->GetConf().m_order > 1)
151 vector<NodeSharedPtr> tmp;
152 vector<EdgeSharedPtr> edgeList = e->GetEdgeList();
153 vector<FaceSharedPtr> faceList = e->GetFaceList();
154 vector<NodeSharedPtr> volList = e->GetVolumeNodes();
156 for (
int j = 0; j < edgeList.size(); ++j)
159 edgesDone.find(edgeList[j]->m_id);
160 if (it == edgesDone.end() || d != 3)
162 tmp.insert(tmp.end(),
163 edgeList[j]->m_edgeNodes.begin(),
164 edgeList[j]->m_edgeNodes.end());
165 edgesDone.insert(edgeList[j]->m_id);
169 for (
int j = 0; j < faceList.size(); ++j)
172 facesDone.find(faceList[j]->m_id);
173 if (it == facesDone.end() || d != 3)
175 tmp.insert(tmp.end(),
176 faceList[j]->m_faceNodes.begin(),
177 faceList[j]->m_faceNodes.end());
178 facesDone.insert(faceList[j]->m_id);
182 tmp.insert(tmp.end(), volList.begin(), volList.end());
189 for (
int j = 0; j < tmp.size(); ++j)
191 pair<NodeSet::iterator, bool> testIns =
192 m_mesh->m_vertexSet.insert(tmp[j]);
196 (*(testIns.first))->m_id =
id++;
200 tmp[j]->m_id = (*(testIns.first))->m_id;
209 std::set<NodeSharedPtr> tmp(
m_mesh->m_vertexSet.begin(),
210 m_mesh->m_vertexSet.end());
215 for (it = tmp.begin(); it != tmp.end(); ++it)
217 m_mshFile << (*it)->m_id <<
" " << scientific << setprecision(10)
218 << (*it)->m_x <<
" " << (*it)->m_y <<
" " << (*it)->m_z
231 for (
int d = 1; d <= 3; ++d)
233 for (
int i = 0; i <
m_mesh->m_element[d].size(); ++i, ++id)
242 vector<int> tags = e->GetTagList();
244 if (tags.size() == 1)
246 tags.push_back(tags[0]);
252 for (
int j = 0; j < tags.size(); ++j)
259 vector<NodeSharedPtr> nodeList = e->GetVertexList();
260 vector<EdgeSharedPtr> edgeList = e->GetEdgeList();
261 vector<FaceSharedPtr> faceList = e->GetFaceList();
262 vector<NodeSharedPtr> volList = e->GetVolumeNodes();
266 for (
int j = 0; j < nodeList.size(); ++j)
268 tags.push_back(nodeList[j]->m_id);
271 if (e->GetConf().m_order > 1)
273 for (
int j = 0; j < edgeList.size(); ++j)
275 nodeList = edgeList[j]->m_edgeNodes;
276 for (
int k = 0; k < nodeList.size(); ++k)
278 tags.push_back(nodeList[k]->m_id);
283 for (
int j = 0; j < faceList.size(); ++j)
285 nodeList = faceList[j]->m_faceNodes;
286 for (
int k = 0; k < nodeList.size(); ++k)
289 tags.push_back(nodeList[k]->m_id);
293 for (
int j = 0; j < volList.size(); ++j)
296 tags.push_back(volList[j]->m_id);
303 int order = e->GetConf().m_order;
306 cerr <<
"Temporary error: Gmsh tets only supported "
307 <<
"up to 4th order - will fix soon!" << endl;
312 pos = 4 + 4 * (order - 1);
313 for (
int j = 0; j < order - 1; ++j)
315 swap(tags[j + pos], tags[j + pos + order - 1]);
319 reverse(tags.begin() + 4 + 3 * (order - 1),
320 tags.begin() + 4 + 4 * (order - 1));
321 reverse(tags.begin() + 4 + 4 * (order - 1),
322 tags.begin() + 4 + 5 * (order - 1));
323 reverse(tags.begin() + 4 + 5 * (order - 1),
324 tags.begin() + 4 + 6 * (order - 1));
327 pos = 4 + 6 * (order - 1) + 2 * (order - 2) * (order - 1) / 2;
328 for (
int j = 0; j < (order - 2) * (order - 1) / 2; ++j)
331 tags[j + pos + (order - 2) * (order - 1) / 2]);
345 vector<int> tmp((order - 2) * (order - 1) / 2);
347 pos = 4 + 6 * (order - 1);
348 for (
int j = 0; j < order - 2; ++j)
350 for (
int k = 0; k < order - 2 - j; ++k, ++a)
353 tags[pos + j + k * (2 * (order - 2) + 1 - k) / 2];
356 for (
int j = 0; j < (order - 1) * (order - 2) / 2; ++j)
358 tags[pos + j] = tmp[j];
362 pos = 4 + 6 * (order - 1) + 2 * (order - 2) * (order - 1) / 2;
364 for (
int j = 0; j < order - 2; ++j)
366 for (
int k = 0; k < order - 2 - j; ++k, ++a)
369 tags[pos + j + k * (2 * (order - 2) + 1 - k) / 2];
372 for (
int j = 0; j < (order - 1) * (order - 2) / 2; ++j)
374 tags[pos + j] = tmp[j];
378 pos = 4 + 6 * (order - 1) + 3 * (order - 2) * (order - 1) / 2;
380 for (
int j = 0; j < order - 2; ++j)
382 for (
int k = order - 3 - j; k >= 0; --k, ++a)
385 tags[pos + j + k * (2 * (order - 2) + 1 - k) / 2];
389 for (
int j = 0; j < (order - 1) * (order - 2) / 2; ++j)
391 tags[pos + j] = tmp[j];
397 int order = e->GetConf().m_order;
400 cerr <<
"Temporary error: Gmsh prisms only "
401 <<
"supported up to 2nd order!" << endl;
406 vector<int> temp(18);
425 for (
int k = 0; k < 18; ++k)
432 for (
int j = 0; j < tags.size(); ++j)
pair< ModuleType, string > ModuleKey
Abstract base class for output modules.
MeshSharedPtr m_mesh
Mesh object.
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 void Process()
Write mesh to output file.
boost::shared_ptr< Element > ElementSharedPtr
std::ofstream m_mshFile
Output stream.
void OpenStream()
Open a file for output.
boost::shared_ptr< Geometry > GeometrySharedPtr
boost::unordered_map< ElmtConfig, unsigned int, ElmtConfigHash > elmMap
ModuleFactory & GetModuleFactory()
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.