Commit 771786ce authored by Luca Bertagna's avatar Luca Bertagna
Browse files

For LinearTriangle meshes with extension '.msh' we are now able to read both...

For LinearTriangle meshes with extension '.msh' we are now able to read both FreeFem and Gmsh formats. The proper reader is chosen based on the first character of the mesh: Gmsh format starts with '$MeshFormat', while FreeFem format starts with the number of nodes.
parent 7bfd4ce7
......@@ -55,6 +55,7 @@
#include <lifev/core/filter/ImporterMesh3D.hpp>
#include <lifev/core/mesh/RegionMesh3DStructured.hpp>
#include <lifev/core/filter/ParserINRIAMesh.hpp>
#include <lifev/core/filter/ParserGmsh.hpp>
#include <lifev/core/mesh/ConvertBareMesh.hpp>
namespace LifeV
......@@ -196,8 +197,26 @@ void readMesh ( RegionMesh<LinearTriangle, MC>& mesh, const MeshData& data )
if ( data.meshType() == ".msh" )
{
std::ifstream ifile;
ifile.open ( ( data.meshDir() + data.meshFile()).c_str() );
ASSERT (ifile.is_open(), "Error! Unable to read mesh file.\n");
// Checking whether it is Gmsh or FreeFem mesh format
if (ifile.get()=='$')
{
// Gmsh files start with '$MeshFormat'
ifile.close();
BareMesh<LinearTriangle> bareMesh;
MeshIO::ReadGmshFile (data.meshDir() + data.meshFile(),bareMesh,0,data.verbose());
convertBareMesh ( bareMesh, mesh, data.verbose() );
}
else
{
// If not Gmsh format, it must be FreeFem
ifile.close();
readFreeFemFile ( mesh, data.meshDir() + data.meshFile(), 1, data.verbose() );
}
}
else
{
ERROR_MSG ( "Sorry, this mesh file can not be loaded" );
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment