diff --git a/src/mesh/tnlMeshInitializer.h b/src/mesh/tnlMeshInitializer.h index 9ae0812abde2ae1d5ef301567bee277320fe341b..0fc913f4e1627e9e10ef0aee4ca2c0058b211c42 100644 --- a/src/mesh/tnlMeshInitializer.h +++ b/src/mesh/tnlMeshInitializer.h @@ -108,17 +108,27 @@ class tnlMeshInitializerLayer< ConfigTag, bool checkCells() { typedef typename tnlMeshEntity< ConfigTag, EntityTag >::template SubentitiesTraits< 0 >::LocalIndexType LocalIndexType; + const GlobalIndexType numberOfVertices( this->getMesh().getNumberOfVertices() ); for( GlobalIndexType cell = 0; cell < this->getMesh().getNumberOfCells(); cell++ ) for( LocalIndexType i = 0; i < this->getMesh().getCell( cell ).getNumberOfVertices(); i++ ) + { if( this->getMesh().getCell( cell ).getVerticesIndices()[ i ] == - 1 ) { cerr << "The cell number " << cell << " does not have properly set vertex index number " << i << "." << endl; return false; } + if( this->getMesh().getCell( cell ).getVerticesIndices()[ i ] >= numberOfVertices ) + { + cerr << "The cell number " << cell << " does not have properly set vertex index number " << i + << ". The index is higher than the number of all vertices ( " << numberOfVertices + << " )." << endl; + return false; + } + } return true; } diff --git a/src/mesh/tnlMeshIntegrityChecker.h b/src/mesh/tnlMeshIntegrityChecker.h index 5b215ee5e1bdf29c68e1a104b96d543ab159306d..4be1c207b5eee02f9da89da0d207785196e2bdee 100644 --- a/src/mesh/tnlMeshIntegrityChecker.h +++ b/src/mesh/tnlMeshIntegrityChecker.h @@ -23,7 +23,29 @@ template< typename MeshType > class tnlMeshIntegrityChecker { + public: + typedef typename MeshType::Config ConfigTag; + typedef typename ConfigTag::CellTag CellTag; + typedef tnlDimensionsTraits< CellTag::dimensions > CellDimensionsTraits; + typedef tnlMeshEntitiesTraits< ConfigTag, + CellDimensionsTraits > CellTraits; + typedef typename CellTraits::SharedContainerType CellsSharedContainerType; + typedef tnlDimensionsTraits< 0 > VertexDimensionsTraits; + typedef tnlMeshEntitiesTraits< ConfigTag, + VertexDimensionsTraits > VertexTraits; + typedef typename VertexTraits::SharedContainerType VertexSharedConatinerType; + + static bool checkMesh( const MeshType& mesh ) + { + for( CellsGlobalIndexType cell = 0; + cell < mesh.getNumberOfCells(); + cell++ ) + { + cout << "Checking cell number " << cell << endl; + } + return true; + } }; diff --git a/tools/src/tnl-mesh-convert.h b/tools/src/tnl-mesh-convert.h index 9b4d5556eb08d6c379a5c73d589b66a3f7cd37cb..82e507a3699c9f0c63bdd7024c55953bbb5cfc02 100644 --- a/tools/src/tnl-mesh-convert.h +++ b/tools/src/tnl-mesh-convert.h @@ -25,6 +25,7 @@ #include <mesh/topologies/tnlMeshTetrahedronTag.h> #include <mesh/tnlMesh.h> #include <mesh/tnlMeshInitializer.h> +#include <mesh/tnlMeshIntegrityChecker.h> #include <core/mfilename.h> template< int Dimensions > @@ -38,8 +39,9 @@ bool readMeshWithDimensions( const tnlParameterContainer& parameters ) struct MeshConfig : public tnlMeshConfigBase< 2 > { typedef tnlMeshTriangleTag CellTag; - }; - tnlMesh< MeshConfig > mesh; + }; + typedef tnlMesh< MeshConfig > MeshType; + MeshType mesh; if( fileExt == "ng" && ! tnlMeshReaderNetgen::readMesh<>( inputFileName, mesh, true ) ) return false; @@ -47,6 +49,8 @@ bool readMeshWithDimensions( const tnlParameterContainer& parameters ) meshInitializer.setVerbose( true ); if( ! meshInitializer.initMesh( mesh ) ) return false; + if( ! tnlMeshIntegrityChecker< MeshType >::checkMesh( mesh ) ) + return false; tnlString outputFile; if( parameters.GetParameter< tnlString >( "output-file", outputFile ) ) { @@ -64,7 +68,8 @@ bool readMeshWithDimensions( const tnlParameterContainer& parameters ) { typedef tnlMeshTetrahedronTag CellTag; }; - tnlMesh< MeshConfig > mesh; + typedef tnlMesh< MeshConfig > MeshType; + MeshType mesh; if( fileExt == "ng" && ! tnlMeshReaderNetgen::readMesh<>( inputFileName, mesh, true ) ) return false; @@ -72,6 +77,8 @@ bool readMeshWithDimensions( const tnlParameterContainer& parameters ) meshInitializer.setVerbose( true ); if( ! meshInitializer.initMesh( mesh ) ) return false; + if( ! tnlMeshIntegrityChecker< MeshType >::checkMesh( mesh ) ) + return false; tnlString outputFile; if( parameters.GetParameter< tnlString >( "output-file", outputFile ) ) {