Skip to content
Snippets Groups Projects
Commit 7734ee3c authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Added function getMeshReader

It is useful especially when one wants to load mesh functions via the
readPointData or readCellData methods when the mesh was already loaded.
parent afcc762a
No related branches found
No related tags found
1 merge request!82MPI refactoring
/***************************************************************************
getMeshReader.h - description
-------------------
begin : Nov 7, 2020
copyright : (C) 2020 by Tomas Oberhuber et al.
email : tomas.oberhuber@fjfi.cvut.cz
***************************************************************************/
/* See Copyright Notice in tnl/Copyright */
// Implemented by: Jakub Klinkovský
#pragma once
#include <experimental/filesystem>
#include <TNL/Meshes/Readers/NetgenReader.h>
#include <TNL/Meshes/Readers/VTKReader.h>
#include <TNL/Meshes/Readers/VTUReader.h>
#include <TNL/Meshes/Readers/PVTUReader.h>
namespace TNL {
namespace Meshes {
namespace Readers {
std::shared_ptr< Readers::MeshReader >
getMeshReader( const std::string& fileName,
const std::string& fileFormat )
{
namespace fs = std::experimental::filesystem;
std::string format = fileFormat;
if( format == "auto" ) {
format = fs::path(fileName).extension();
if( format.length() > 0 )
// remove dot from the extension
format = format.substr(1);
}
if( format == "ng" )
return std::make_shared< Readers::NetgenReader >( fileName );
else if( format == "vtk" )
return std::make_shared< Readers::VTKReader >( fileName );
else if( format == "vtu" )
return std::make_shared< Readers::VTUReader >( fileName );
else if( format == "pvtu" )
return std::make_shared< Readers::PVTUReader >( fileName );
if( fileFormat == "auto" )
std::cerr << "File '" << fileName << "' has unsupported format (based on the file extension): " << format << ".";
else
std::cerr << "Unsupported fileFormat parameter: " << fileFormat << ".";
std::cerr << " Supported formats are 'vtk', 'vtu', 'pvtu' and 'ng'." << std::endl;
return nullptr;
}
} // namespace Readers
} // namespace Meshes
} // namespace TNL
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment