Skip to content
Snippets Groups Projects
Commit a516513b authored by Tomáš Oberhuber's avatar Tomáš Oberhuber
Browse files

Implementing the mesh integrity checker.

parent 20b81c7a
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
......
......@@ -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;
}
};
......
......@@ -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 ) )
{
......
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