Loading src/TNL/Meshes/BuildConfigTags.h +3 −2 Original line number Diff line number Diff line Loading @@ -2,7 +2,7 @@ BuildConfigTags.h - description ------------------- begin : Nov 22, 2016 copyright : (C) 2016 by Tomas Oberhuber copyright : (C) 2016 by Tomas Oberhuber et al. email : tomas.oberhuber@fjfi.cvut.cz ***************************************************************************/ Loading Loading @@ -121,10 +121,11 @@ struct MeshConfigTemplateTag // Mesh< typename MeshConfigTemplateTag< ConfigTag >:: // template MeshConfig< CellTopology, WorldDimension, Real, GlobalIndex, LocalIndex, Id > > > // template< typename ConfigTag, typename CellTopology, int WorldDimension, typename Real, typename GlobalIndex, typename LocalIndex, typename Id > template< typename ConfigTag, typename Device, typename CellTopology, int WorldDimension, typename Real, typename GlobalIndex, typename LocalIndex, typename Id > struct MeshTag { enum { enabled = MeshDeviceTag< ConfigTag, Device >::enabled && MeshCellTopologyTag< ConfigTag, CellTopology >::enabled && MeshWorldDimensionTag< ConfigTag, CellTopology, WorldDimension >::enabled && MeshRealTag< ConfigTag, Real >::enabled && Loading src/TNL/Meshes/Readers/CMakeLists.txt +2 −2 Original line number Diff line number Diff line SET( headers Netgen.h TNL.h SET( headers NetgenReader.h TNLReader.h VTKEntityType.h ) Loading src/TNL/Meshes/Readers/Netgen.h→src/TNL/Meshes/Readers/NetgenReader.h +125 −65 Original line number Diff line number Diff line /*************************************************************************** MeshReaderNetgen.h - description NetgenReader.h - description ------------------- begin : Feb 19, 2014 copyright : (C) 2014 by Tomas Oberhuber et al. Loading @@ -21,19 +21,20 @@ #include <sstream> #include <TNL/Meshes/MeshBuilder.h> #include <TNL/Meshes/Readers/VTKEntityType.h> namespace TNL { namespace Meshes { namespace Readers { class MeshReaderNetgen class NetgenReader { public: MeshReaderNetgen() : dimensions( 0 ){} bool detectMesh( const String& fileName ) { this->reset(); this->fileName = fileName; std::fstream inputFile( fileName.getString() ); if( ! inputFile ) { Loading Loading @@ -69,12 +70,12 @@ class MeshReaderNetgen getline( inputFile, line ); iss.clear(); iss.str( line ); this->dimensions = -1; meshDimension = worldDimension = -1; while( iss ) { double aux; iss >> aux; this->dimensions++; meshDimension = ++worldDimension; } /**** Loading Loading @@ -113,21 +114,39 @@ class MeshReaderNetgen getline( inputFile, line ); iss.clear(); iss.str( line ); this->verticesInCell = -2; int verticesInCell = -2; while( iss ) { int aux; iss >> aux; this->verticesInCell++; verticesInCell++; } //cout << "There are " << verticesInCell << " vertices in cell ..." << std::endl; if( meshDimension == 1 && verticesInCell == 2 ) cellVTKType = VTKEntityType::Line; else if( meshDimension == 2 ) { if( verticesInCell == 3 ) cellVTKType = VTKEntityType::Triangle; else if( verticesInCell == 4 ) cellVTKType = VTKEntityType::Quad; } //cout << "There are " << this->verticesInCell << " vertices in cell ..." << std::endl; else if( meshDimension == 3 ) { if( verticesInCell == 4 ) cellVTKType = VTKEntityType::Tetra; else if( verticesInCell == 8 ) cellVTKType = VTKEntityType::Hexahedron; } if( cellVTKType == VTKEntityType::Vertex ) { std::cerr << "Unknown cell topology: mesh dimension is " << meshDimension << ", number of vertices in cells is " << verticesInCell << "." << std::endl; return false; } return true; } template< typename MeshType > static bool readMesh( const String& fileName, MeshType& mesh, bool verbose ) static bool readMesh( const String& fileName, MeshType& mesh ) { typedef typename MeshType::PointType PointType; typedef MeshBuilder< MeshType > MeshBuilder; Loading Loading @@ -176,12 +195,8 @@ class MeshReaderNetgen iss >> p[ d ]; //cout << "Setting point number " << i << " of " << pointsCount << std::endl; meshBuilder.setPoint( i, p ); if( verbose ) std::cout << pointsCount << " vertices expected ... " << i+1 << "/" << pointsCount << " \r" << std::flush; //const PointType& point = mesh.getVertex( i ).getPoint(); } if( verbose ) std::cout << std::endl; /**** * Skip white spaces Loading @@ -191,7 +206,7 @@ class MeshReaderNetgen /**** * Read number of cells */ typedef typename MeshType::MeshTraitsType::template EntityTraits< dimensions >::GlobalIndexType CellIndexType; typedef typename MeshType::Config::GlobalIndexType CellIndexType; if( ! inputFile ) { std::cerr << "I cannot read the mesh cells." << std::endl; Loading Loading @@ -222,30 +237,75 @@ class MeshReaderNetgen iss >> vertexIdx; meshBuilder.getCellSeed( i ).setCornerId( cellVertex, vertexIdx - 1 ); } if( verbose ) std::cout << numberOfCells << " cells expected ... " << i+1 << "/" << numberOfCells << " \r" << std::flush; } if( verbose ) std::cout << std::endl; meshBuilder.build( mesh ); return true; } int getDimension() const String getMeshType() const { return this->dimensions; return "Meshes::Mesh"; } int getVerticesInCell() const int getMeshDimension() const { return this->verticesInCell; return this->meshDimension; } protected: int getWorldDimension() const { return worldDimension; } int dimensions, verticesInCell; VTKEntityType getCellVTKType() const { return cellVTKType; } String getRealType() const { // not stored in the Netgen file return "float"; } String getGlobalIndexType() const { // not stored in the Netgen file return "int"; } String getLocalIndexType() const { // not stored in the Netgen file return "short int"; } String getIdType() const { // not stored in the Netgen file return "int"; } protected: String fileName; int meshDimension, worldDimension; VTKEntityType cellVTKType = VTKEntityType::Vertex; void reset() { fileName = ""; meshDimension = worldDimension = 0; cellVTKType = VTKEntityType::Vertex; } }; } // namespace Readers } // namespace Meshes } // namespace TNL src/TNL/Meshes/Readers/TNL.h→src/TNL/Meshes/Readers/TNLReader.h +9 −8 Original line number Diff line number Diff line Loading @@ -19,13 +19,14 @@ namespace TNL { namespace Meshes { namespace Readers { class TNL class TNLReader { public: bool readFile( const String& fileName ) detectMesh( const String& fileName ) { this->reset(); this->fileName = fileName; String meshType; if( ! getObjectType( fileName, meshType ) ) Loading Loading @@ -65,8 +66,8 @@ public: } template< typename MeshType > bool initializeMesh( MeshType& mesh ) static bool readMesh( const String& fileName, MeshType& mesh ) { return mesh.load( fileName ); } Loading Loading @@ -110,13 +111,13 @@ public: String getLocalIndexType() const { return globalIndexType; return localIndexType; } String getIdType() const { return globalIndexType; return idType; } protected: Loading @@ -134,9 +135,9 @@ protected: { fileName = ""; meshType = ""; meshDimension = 0; realType = localIndexType = globalIndexType = idType = ""; meshDimension = worldDimension = 0; cellVTKType = VTKEntityType::Vertex; realType = localIndexType = globalIndexType = idType = ""; } }; Loading src/TNL/Meshes/Readers/VTKEntityType.h +1 −1 Original line number Diff line number Diff line Loading @@ -2,7 +2,7 @@ MeshTypeResolver_impl.h - description ------------------- begin : Nov 22, 2016 copyright : (C) 2016 by Tomas Oberhuber copyright : (C) 2016 by Tomas Oberhuber et al. email : tomas.oberhuber@fjfi.cvut.cz ***************************************************************************/ Loading Loading
src/TNL/Meshes/BuildConfigTags.h +3 −2 Original line number Diff line number Diff line Loading @@ -2,7 +2,7 @@ BuildConfigTags.h - description ------------------- begin : Nov 22, 2016 copyright : (C) 2016 by Tomas Oberhuber copyright : (C) 2016 by Tomas Oberhuber et al. email : tomas.oberhuber@fjfi.cvut.cz ***************************************************************************/ Loading Loading @@ -121,10 +121,11 @@ struct MeshConfigTemplateTag // Mesh< typename MeshConfigTemplateTag< ConfigTag >:: // template MeshConfig< CellTopology, WorldDimension, Real, GlobalIndex, LocalIndex, Id > > > // template< typename ConfigTag, typename CellTopology, int WorldDimension, typename Real, typename GlobalIndex, typename LocalIndex, typename Id > template< typename ConfigTag, typename Device, typename CellTopology, int WorldDimension, typename Real, typename GlobalIndex, typename LocalIndex, typename Id > struct MeshTag { enum { enabled = MeshDeviceTag< ConfigTag, Device >::enabled && MeshCellTopologyTag< ConfigTag, CellTopology >::enabled && MeshWorldDimensionTag< ConfigTag, CellTopology, WorldDimension >::enabled && MeshRealTag< ConfigTag, Real >::enabled && Loading
src/TNL/Meshes/Readers/CMakeLists.txt +2 −2 Original line number Diff line number Diff line SET( headers Netgen.h TNL.h SET( headers NetgenReader.h TNLReader.h VTKEntityType.h ) Loading
src/TNL/Meshes/Readers/Netgen.h→src/TNL/Meshes/Readers/NetgenReader.h +125 −65 Original line number Diff line number Diff line /*************************************************************************** MeshReaderNetgen.h - description NetgenReader.h - description ------------------- begin : Feb 19, 2014 copyright : (C) 2014 by Tomas Oberhuber et al. Loading @@ -21,19 +21,20 @@ #include <sstream> #include <TNL/Meshes/MeshBuilder.h> #include <TNL/Meshes/Readers/VTKEntityType.h> namespace TNL { namespace Meshes { namespace Readers { class MeshReaderNetgen class NetgenReader { public: MeshReaderNetgen() : dimensions( 0 ){} bool detectMesh( const String& fileName ) { this->reset(); this->fileName = fileName; std::fstream inputFile( fileName.getString() ); if( ! inputFile ) { Loading Loading @@ -69,12 +70,12 @@ class MeshReaderNetgen getline( inputFile, line ); iss.clear(); iss.str( line ); this->dimensions = -1; meshDimension = worldDimension = -1; while( iss ) { double aux; iss >> aux; this->dimensions++; meshDimension = ++worldDimension; } /**** Loading Loading @@ -113,21 +114,39 @@ class MeshReaderNetgen getline( inputFile, line ); iss.clear(); iss.str( line ); this->verticesInCell = -2; int verticesInCell = -2; while( iss ) { int aux; iss >> aux; this->verticesInCell++; verticesInCell++; } //cout << "There are " << verticesInCell << " vertices in cell ..." << std::endl; if( meshDimension == 1 && verticesInCell == 2 ) cellVTKType = VTKEntityType::Line; else if( meshDimension == 2 ) { if( verticesInCell == 3 ) cellVTKType = VTKEntityType::Triangle; else if( verticesInCell == 4 ) cellVTKType = VTKEntityType::Quad; } //cout << "There are " << this->verticesInCell << " vertices in cell ..." << std::endl; else if( meshDimension == 3 ) { if( verticesInCell == 4 ) cellVTKType = VTKEntityType::Tetra; else if( verticesInCell == 8 ) cellVTKType = VTKEntityType::Hexahedron; } if( cellVTKType == VTKEntityType::Vertex ) { std::cerr << "Unknown cell topology: mesh dimension is " << meshDimension << ", number of vertices in cells is " << verticesInCell << "." << std::endl; return false; } return true; } template< typename MeshType > static bool readMesh( const String& fileName, MeshType& mesh, bool verbose ) static bool readMesh( const String& fileName, MeshType& mesh ) { typedef typename MeshType::PointType PointType; typedef MeshBuilder< MeshType > MeshBuilder; Loading Loading @@ -176,12 +195,8 @@ class MeshReaderNetgen iss >> p[ d ]; //cout << "Setting point number " << i << " of " << pointsCount << std::endl; meshBuilder.setPoint( i, p ); if( verbose ) std::cout << pointsCount << " vertices expected ... " << i+1 << "/" << pointsCount << " \r" << std::flush; //const PointType& point = mesh.getVertex( i ).getPoint(); } if( verbose ) std::cout << std::endl; /**** * Skip white spaces Loading @@ -191,7 +206,7 @@ class MeshReaderNetgen /**** * Read number of cells */ typedef typename MeshType::MeshTraitsType::template EntityTraits< dimensions >::GlobalIndexType CellIndexType; typedef typename MeshType::Config::GlobalIndexType CellIndexType; if( ! inputFile ) { std::cerr << "I cannot read the mesh cells." << std::endl; Loading Loading @@ -222,30 +237,75 @@ class MeshReaderNetgen iss >> vertexIdx; meshBuilder.getCellSeed( i ).setCornerId( cellVertex, vertexIdx - 1 ); } if( verbose ) std::cout << numberOfCells << " cells expected ... " << i+1 << "/" << numberOfCells << " \r" << std::flush; } if( verbose ) std::cout << std::endl; meshBuilder.build( mesh ); return true; } int getDimension() const String getMeshType() const { return this->dimensions; return "Meshes::Mesh"; } int getVerticesInCell() const int getMeshDimension() const { return this->verticesInCell; return this->meshDimension; } protected: int getWorldDimension() const { return worldDimension; } int dimensions, verticesInCell; VTKEntityType getCellVTKType() const { return cellVTKType; } String getRealType() const { // not stored in the Netgen file return "float"; } String getGlobalIndexType() const { // not stored in the Netgen file return "int"; } String getLocalIndexType() const { // not stored in the Netgen file return "short int"; } String getIdType() const { // not stored in the Netgen file return "int"; } protected: String fileName; int meshDimension, worldDimension; VTKEntityType cellVTKType = VTKEntityType::Vertex; void reset() { fileName = ""; meshDimension = worldDimension = 0; cellVTKType = VTKEntityType::Vertex; } }; } // namespace Readers } // namespace Meshes } // namespace TNL
src/TNL/Meshes/Readers/TNL.h→src/TNL/Meshes/Readers/TNLReader.h +9 −8 Original line number Diff line number Diff line Loading @@ -19,13 +19,14 @@ namespace TNL { namespace Meshes { namespace Readers { class TNL class TNLReader { public: bool readFile( const String& fileName ) detectMesh( const String& fileName ) { this->reset(); this->fileName = fileName; String meshType; if( ! getObjectType( fileName, meshType ) ) Loading Loading @@ -65,8 +66,8 @@ public: } template< typename MeshType > bool initializeMesh( MeshType& mesh ) static bool readMesh( const String& fileName, MeshType& mesh ) { return mesh.load( fileName ); } Loading Loading @@ -110,13 +111,13 @@ public: String getLocalIndexType() const { return globalIndexType; return localIndexType; } String getIdType() const { return globalIndexType; return idType; } protected: Loading @@ -134,9 +135,9 @@ protected: { fileName = ""; meshType = ""; meshDimension = 0; realType = localIndexType = globalIndexType = idType = ""; meshDimension = worldDimension = 0; cellVTKType = VTKEntityType::Vertex; realType = localIndexType = globalIndexType = idType = ""; } }; Loading
src/TNL/Meshes/Readers/VTKEntityType.h +1 −1 Original line number Diff line number Diff line Loading @@ -2,7 +2,7 @@ MeshTypeResolver_impl.h - description ------------------- begin : Nov 22, 2016 copyright : (C) 2016 by Tomas Oberhuber copyright : (C) 2016 by Tomas Oberhuber et al. email : tomas.oberhuber@fjfi.cvut.cz ***************************************************************************/ Loading