41 #include "../InputModules/InputGmsh.h"
54 "Writes Gmsh msh file.");
63 for (it = igelmap.begin(); it != igelmap.end(); ++it)
65 elmMap[it->second] = it->first;
89 cout <<
"OutputGmsh: Writing file..." << endl;
92 boost::unordered_map<int, vector<int> > orderingMap;
93 boost::unordered_map<int, vector<int> >
::iterator oIt;
101 <<
"$EndMeshFormat" << endl;
103 int id =
m_mesh->m_vertexSet.size();
104 vector<ElementSharedPtr> toComplete;
106 int order =
m_config[
"order"].as<
int>();
112 cout <<
"Making mesh of order " << order << endl;
119 for (
int i = 0; i <
m_mesh->m_element[
m_mesh->m_expDim].size(); ++i)
122 if (e->GetMaxOrder() > order)
124 order = e->GetMaxOrder();
132 cout <<
"Mesh order of " << order <<
" detected" << endl;
141 for (eIt =
m_mesh->m_edgeSet.begin(); eIt !=
m_mesh->m_edgeSet.end(); ++eIt)
143 m_mesh->m_vertexSet.insert((*eIt)->m_edgeNodes.begin(),
144 (*eIt)->m_edgeNodes.end());
147 for (fIt =
m_mesh->m_faceSet.begin(); fIt !=
m_mesh->m_faceSet.end(); ++fIt)
149 m_mesh->m_vertexSet.insert((*fIt)->m_faceNodes.begin(),
150 (*fIt)->m_faceNodes.end());
154 for (
int d = 1; d <= 3; ++d)
156 for (
int i = 0; i <
m_mesh->m_element[d].size(); ++i)
159 vector<NodeSharedPtr> volList = e->GetVolumeNodes();
160 m_mesh->m_vertexSet.insert(volList.begin(), volList.end());
166 std::set<NodeSharedPtr> tmp(
m_mesh->m_vertexSet.begin(),
167 m_mesh->m_vertexSet.end());
172 for (it = tmp.begin(); it != tmp.end(); ++it)
174 m_mshFile << (*it)->m_id+1 <<
" " << scientific << setprecision(10)
175 << (*it)->m_x <<
" " << (*it)->m_y <<
" " << (*it)->m_z
188 for (
int d = 1; d <= 3; ++d)
190 for (
int i = 0; i <
m_mesh->m_element[d].size(); ++i, ++id)
195 int elmtType =
elmMap[e->GetConf()];
196 m_mshFile <<
id <<
" " << elmtType <<
" ";
200 vector<int> tags = e->GetTagList();
202 if (tags.size() == 1)
204 tags.push_back(tags[0]);
210 for (
int j = 0; j < tags.size(); ++j)
217 vector<NodeSharedPtr> nodeList = e->GetVertexList();
218 vector<EdgeSharedPtr> edgeList = e->GetEdgeList();
219 vector<FaceSharedPtr> faceList = e->GetFaceList();
220 vector<NodeSharedPtr> volList = e->GetVolumeNodes();
224 for (
int j = 0; j < nodeList.size(); ++j)
226 tags.push_back(nodeList[j]->m_id);
230 for (
int j = 0; j < edgeList.size(); ++j)
232 nodeList = edgeList[j]->m_edgeNodes;
236 for (
int k = 0; k < nodeList.size(); ++k)
238 tags.push_back(nodeList[k]->m_id);
243 for (
int k = nodeList.size() - 1; k >= 0; --k)
245 tags.push_back(nodeList[k]->m_id);
251 for (
int j = 0; j < faceList.size(); ++j)
253 nodeList = faceList[j]->m_faceNodes;
254 int nFaceVerts = faceList[j]->m_vertexList.size();
255 vector<int> faceIds(nFaceVerts), volFaceIds(nFaceVerts);
257 for (
int k = 0; k < nFaceVerts; ++k)
259 faceIds [k] = faceList[j]->m_vertexList[k]->m_id;
261 e->GetVertexList()[e->GetFaceVertex(j, k)]->m_id;
267 hoTri.
Align(volFaceIds);
268 for (
int k = 0; k < hoTri.
surfVerts.size(); ++k)
270 tags.push_back(hoTri.
surfVerts[k]->m_id);
276 hoQuad.
Align(volFaceIds);
278 for (
int k = 0; k < hoQuad.
surfVerts.size(); ++k)
280 tags.push_back(hoQuad.
surfVerts[k]->m_id);
286 for (
int j = 0; j < volList.size(); ++j)
288 tags.push_back(volList[j]->m_id);
293 oIt = orderingMap.find(elmtType);
296 if (oIt == orderingMap.end())
299 vector<int> inv(tags.size());
301 ASSERTL1(tags.size() == reordering.size(),
302 "Reordering map size not equal to element tags 1.");
304 for (
int j = 0; j < tags.size(); ++j)
306 inv[reordering[j]] = j;
309 oIt = orderingMap.insert(make_pair(elmtType, inv)).first;
312 ASSERTL1(tags.size() == oIt->second.size(),
313 "Reordering map size not equal to element tags 2.");
316 for (
int j = 0; j < tags.size(); ++j)
318 m_mshFile << tags[oIt->second[j]] + 1 <<
" ";
io::filtering_ostream m_mshFile
Output stream.
void Align(std::vector< int > vertId)
Align this surface to a given vertex ID.
boost::unordered_map< NekMeshUtils::ElmtConfig, unsigned int, ElmtConfigHash > elmMap
NEKMESHUTILS_EXPORT void OpenStream()
Open a file for output.
std::vector< T > surfVerts
The quadrilateral surface vertices – templated so that this can either be nodes or IDs...
Abstract base class for output modules.
std::vector< T > surfVerts
The triangle surface vertices – templated so that this can either be nodes or IDs.
pair< ModuleType, string > ModuleKey
MeshSharedPtr m_mesh
Mesh object.
1D Evenly-spaced points using Lagrange polynomial
Represents a command-line configuration option.
std::map< std::string, ConfigOption > m_config
List of configuration values.
void Align(std::vector< int > vertId)
Align this surface to a given vertex ID.
A lightweight struct for dealing with high-order triangle alignment.
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
boost::shared_ptr< Mesh > MeshSharedPtr
Shared pointer to a mesh.
A lightweight struct for dealing with high-order quadrilateral alignment.
virtual void Process()
Write mesh to output file.
boost::shared_ptr< Element > ElementSharedPtr
std::pair< ModuleType, std::string > ModuleKey
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
ModuleFactory & GetModuleFactory()
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.