From ddd369c7eeb5d587b3004635fcb815b64f6cffcb Mon Sep 17 00:00:00 2001 From: Tomas Oberhuber <tomas.oberhuber@fjfi.cvut.cz> Date: Tue, 18 Aug 2015 23:00:26 +0200 Subject: [PATCH] Adding mesh builder. --- src/mesh/config/tnlMeshConfigBase.h | 3 +- src/mesh/tnlMeshBuilder.h | 120 ++++++++++++++++++ src/mesh/tnlMeshEntityInitializer.h | 76 +++++++---- src/mesh/tnlMeshEntitySeed.h | 63 +++++++++ src/mesh/tnlMeshInitializer.h | 21 +-- src/mesh/tnlMeshReaderNetgen.h | 21 +-- src/mesh/tnlMeshSuperentityInitializerLayer.h | 19 ++- src/mesh/traits/tnlMeshTraits.h | 25 ++-- 8 files changed, 289 insertions(+), 59 deletions(-) create mode 100644 src/mesh/tnlMeshBuilder.h create mode 100644 src/mesh/tnlMeshEntitySeed.h diff --git a/src/mesh/config/tnlMeshConfigBase.h b/src/mesh/config/tnlMeshConfigBase.h index 5f03b1de77..bff5bfb720 100644 --- a/src/mesh/config/tnlMeshConfigBase.h +++ b/src/mesh/config/tnlMeshConfigBase.h @@ -86,7 +86,8 @@ struct tnlMeshConfigBase template< typename MeshEntity > static constexpr bool superentityStorage( MeshEntity, int SuperentityDimensions ) { - return false; + return true; + //return false; } static_assert( WorldDimensions >= Cell::dimensions, "The number of the cell dimensions cannot be larger than the world dimension." ); diff --git a/src/mesh/tnlMeshBuilder.h b/src/mesh/tnlMeshBuilder.h new file mode 100644 index 0000000000..f021b0de3e --- /dev/null +++ b/src/mesh/tnlMeshBuilder.h @@ -0,0 +1,120 @@ +/*************************************************************************** + tnlMeshBuilder.h - description + ------------------- + begin : Aug 18, 2015 + copyright : (C) 2015 by Tomas Oberhuber et al. + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef TNLMESHBUILDER_H +#define TNLMESHBUILDER_H + +#include <mesh/traits/tnlMeshTraits.h> + +template< typename Mesh > +class tnlMeshBuilder +{ + //static constexpr const char *CLASS_NAME = "MeshBuilder"; + + public: + typedef Mesh MeshType; + typedef MeshType::MeshTraits MeshTraits; + typedef typename MeshTraits::GlobalIndexType GlobalIndexType; + typedef typename MeshTraits::LocalIndexType LocalIndexType; + typedef typename MeshTraits::PointType PointType; + typedef typename MeshTraits::CellType CellType; + typedef typename MeshTraits::CellSeedType CellSeedType; + + bool setPointsCount( const GlobalIndexType& points ) + { + tnlAssert( 0 <= pointsCount, cerr << "pointsCount = " << points ); + this->points.setSize( points ); + this->pointsSet.setSize( points ); + pointsSet.setValue( false ); + return true; + } + + bool setCellsCount( const GlobalIndexType& cellsCount ) + { + tnlAssert( 0 <= cellsCount, cerr << "cellsCount = " << cellsCount ); + this->cellCount.setSize( cellsCount ); + return true; + } + + GlobalIndexType getPointsCount() const { return this->points.getSize(); } + + GlobalIndexType getCellsCount() const { return this->cellSeeds.getSize(); } + + void setPoint( GlobalIndexType index, + const PointType& point ) + { + tnlAssert( 0 <= index && index < getPointsCount(), cerr << "Index = " << index ); + + this->points[ index ] = point; + this->pointsSet[ index ] = true; + } + + CellSeedType& getCellSeed( GlobalIndexType index ) + { + tnlAssert( 0 <= index && index < getCellsCount(), cerr << "Index = " << index ); + + return this->cellSeeds[ index ]; + } + + bool build( MeshType& mesh ) const + { + if( ! this->validate() ) + return false; + if( ! mesh.init( this->points, this->cellSeeds ) ) + return false; + return true; + } + + private: + typedef typename MeshTraits::PointArrayType PointArrayType; + typedef typename MeshTraits::CellSeedArrayType CellSeedArrayType; + + void validate() const + { + if( !allPointsSet() ) + { + cerr << "Mesh builder error: Not all points were set." << endl; + return false; + } + + for( GlobalIndexType i = 0; i < getCellsCount(); i++ ) + { + auto cornerIds = this->cellSeeds[ i ].getCornerIds(); + for( LocalIndexType j = 0; j < cornerIds.getSize(); j++ ) + if( cornerIds[ j ] < 0 || getPointsCount() <= cornerIds[ j ] ) + { + cerr << "Cell seed " << i << " is referencing unavailable point " << cornerIds[ j ] << endl; + return false; + } + } + } + + bool allPointsSet() const + { + for( GlobalIndexType i = 0; i < this->points.getSize(); i++ ) + if (! this->pointsSet[ i ] ) + return false; + return true; + } + + PointArrayType points; + CellSeedArrayType cellSeeds; + tnlArray< bool, GlobalIndexType > pointsSet; +}; + +#endif /* TNLMESHBUILDER_H */ + diff --git a/src/mesh/tnlMeshEntityInitializer.h b/src/mesh/tnlMeshEntityInitializer.h index eb47aea620..131b263e73 100644 --- a/src/mesh/tnlMeshEntityInitializer.h +++ b/src/mesh/tnlMeshEntityInitializer.h @@ -80,20 +80,12 @@ class tnlMeshEntityInitializer tnlMeshEntityInitializer() : entity(0), entityIndex( -1 ) {} - void init( EntityType& entity, GlobalIndexType entityIndex ) - { - this->entity = &entity; - this->entityIndex = entityIndex; - } - - void initEntity( InitializerType &meshInitializer ) + void initEntity( EntityType& entity, GlobalIndexType entityIndex, InitializerType &meshInitializer ) { tnlAssert( this->entity, ); this->entity->setId( entityIndex ); - - initSuperentities(); - initSubentities( meshInitializer ); + initSubentities( entity, entityIndex, meshInitializer ); //cout << " Entity initiation done ... " << endl; } @@ -148,17 +140,17 @@ class tnlMeshEntityInitializer EntityType *entity; GlobalIndexType entityIndex; - void initSubentities( InitializerType& meshInitializer ) + void initSubentities( EntityType& entity, GlobalIndexType entityIndex, InitializerType& meshInitializer ) { //cout << " Initiating subentities of entity ... " << endl; SubentityBaseType::initSubentities( *this, meshInitializer ); } - void initSuperentities() + /*void initSuperentities() { //cout << " Initiating superentities..." << endl; //SuperentityBaseType::initSuperentities( *this) ; - } + }*/ template< typename SubentityDimensionTag > class SubentitiesCreator @@ -246,16 +238,16 @@ class tnlMeshEntityInitializer< ConfigTag, tnlMeshVertexTag >/* static tnlString getType() {}; - void init( EntityType& entity, GlobalIndexType entityIndex ) + /*void init( EntityType& entity, GlobalIndexType entityIndex ) { this->entity = &entity; this->entityIndex = entityIndex; - } + }*/ - void initEntity(InitializerType &meshInitializer) + void initEntity( EntityType& entity, GlobalIndexType entityIndex, InitializerType &meshInitializer ) { this->entity->setId( this->entityIndex ); - initSuperentities(); + //initSuperentities(); //cout << "Vertex initiation done ... " << endl; } @@ -280,11 +272,11 @@ class tnlMeshEntityInitializer< ConfigTag, tnlMeshVertexTag >/* EntityType *entity; GlobalIndexType entityIndex; - void initSuperentities() + /*void initSuperentities() { //cout << " Initiating superentities of vertex ..." << endl; //SuperentityBaseType::initSuperentities(*this); - } + }*/ }; /**** @@ -315,9 +307,10 @@ class tnlMeshEntityInitializerLayer< ConfigTag, typedef tnlMeshInitializer< ConfigTag > InitializerType; typedef tnlMeshEntityInitializer< ConfigTag, EntityTag > EntityInitializerType; typedef tnlDimensionsTag< EntityTag::dimensions > EntityDimensionsTag; + typedef typename tnlMeshConfigTraits< ConfigTag >::template EntityTraits< DimensionsTag >::Type EntityType; protected: - void initSubentities( EntityInitializerType& entityInitializer, + void initSubentities( EntityType& entity, GlobalIndexType entityIndex, EntityInitializerType& entityInitializer, InitializerType& meshInitializer ) { SubentityContainerType subentities; @@ -332,6 +325,7 @@ class tnlMeshEntityInitializerLayer< ConfigTag, GlobalIndexType subentityIndex = meshInitializer.findEntityIndex( subentities[ i ] ); GlobalIndexType superentityIndex = entityInitializer.getEntityIndex(); subentityContainer[ i ] = subentityIndex; + meshInitializer.template getSuperentityInitializer< DimensionsTag >().addSuperentity( EntityDimensionsTag(), subentityIndex, entityIndex); //cout << " Setting " << i << "-th subentity to " << subentityContainer[ i ] << endl; //meshInitializer.getEntityInitializer( DimensionsTag(), subentityIndex ).addSuperentity( EntityDimensionsTag(), superentityIndex ); } @@ -362,12 +356,14 @@ class tnlMeshEntityInitializerLayer< ConfigTag, typedef typename tnlMeshSubentitiesTraits< ConfigTag, EntityTag, DimensionsTag >::SharedContainerType SharedContainerType; + typedef typename SharedContainerType::ElementType GlobalIndexType; typedef tnlMeshInitializer< ConfigTag > InitializerType; typedef tnlMeshEntityInitializer< ConfigTag, EntityTag > EntityInitializerType; + typedef typename tnlMeshConfigTraits< ConfigTag >::template tnlMeshEntityTraits< DimensionsTag >::Type EntityType; protected: - void initSubentities( EntityInitializerType& entityInitializer, + void initSubentities( EntityType& entity, GlobalIndexType entityIndex, EntityInitializerType& entityInitializer, InitializerType& meshInitializer ) { SubentityContainerType subentities; @@ -378,7 +374,7 @@ class tnlMeshEntityInitializerLayer< ConfigTag, i < subentityContainer.getSize(); i++ ) { - subentityContainer[ i ] = meshInitializer.findEntityIndex( subentities[ i ] ); + subentityContainer[ i ] = meshInitializer.findEntityIndex( subentities[ i ] ); //cout << " Setting " << i << "-th subentity to " << subentityContainer[ i ] << endl; } @@ -413,9 +409,10 @@ class tnlMeshEntityInitializerLayer< ConfigTag, typedef tnlMeshInitializer< ConfigTag > InitializerType; typedef tnlMeshEntityInitializer< ConfigTag, EntityTag > EntityInitializerType; typedef tnlDimensionsTag< EntityTag::dimensions > EntityDimensionsTag; + typedef typename tnlMeshConfigTraits< ConfigTag >::template tnlMeshEntityTraits< DimensionsTag >::Type EntityType; protected: - void initSubentities( EntityInitializerType& entityInitializer, + void initSubentities( EntityType& entity, GlobalIndexType entityIndex, EntityInitializerType& entityInitializer, InitializerType& meshInitializer ) { SubentityContainerType subentities; @@ -429,7 +426,8 @@ class tnlMeshEntityInitializerLayer< ConfigTag, GlobalIndexType subentityIndex = meshInitializer.findEntityIndex( subentities[ i ] ); GlobalIndexType superentityIndex = entityInitializer.getEntityIndex(); //cout << " NOT setting " << i << "-th subentity to " << subentityIndex << endl; - meshInitializer.getEntityInitializer( DimensionsTag(), subentityIndex ).addSuperentity( EntityDimensionsTag(), superentityIndex ); + //meshInitializer.template getSuperentityInitializer< DimensionsTag >().addSuperentity( EntityDimensionsTag(), subentityIndex, entityIndex); + //meshInitializer.getEntityInitializer( DimensionsTag(), subentityIndex ).addSuperentity( EntityDimensionsTag(), superentityIndex ); } BaseType::initSubentities( entityInitializer, meshInitializer ); } @@ -467,9 +465,10 @@ class tnlMeshEntityInitializerLayer< ConfigTag, typedef tnlMeshInitializer< ConfigTag > InitializerType; typedef tnlMeshEntityInitializer< ConfigTag, EntityTag > EntityInitializerType; typedef tnlDimensionsTag< EntityTag::dimensions > EntityDimensionsTag; + typedef typename tnlMeshConfigTraits< ConfigTag >::template EntityTraits< DimensionsTag >::Type EntityType; protected: - void initSubentities( EntityInitializerType &entityInitializer, + void initSubentities( EntityType& entity, GlobalIndexType entityIndex, EntityInitializerType &entityInitializer, InitializerType &meshInitializer ) { //cout << " Initiating subentities with " << DimensionsTag::value << " dimensions..." << endl; @@ -498,10 +497,17 @@ class tnlMeshEntityInitializerLayer< ConfigTag, typedef tnlMeshInitializer< ConfigTag > InitializerType; typedef tnlMeshEntityInitializer< ConfigTag, EntityTag > EntityInitializerType; + typedef tnlDimensionsTag< 0 > DimensionsTag; + typedef tnlMeshSubentitiesTraits< ConfigTag, + EntityTag, + DimensionsTag > SubentitiesTraits; + typedef typename SubentitiesTraits::SharedContainerType SharedContainerType; + typedef typename SharedContainerType::ElementType GlobalIndexType; + typedef typename tnlMeshConfigTraits< ConfigTag >::template tnlMeshEntityTraits< DimensionsTag >::Type EntityType; protected: - void initSubentities( EntityInitializerType&, InitializerType& ) {} + void initSubentities( EntityType& entity, GlobalIndexType entityIndex, EntityInitializerType&, InitializerType& ) {} }; template< typename ConfigTag, @@ -514,9 +520,16 @@ class tnlMeshEntityInitializerLayer< ConfigTag, { typedef tnlMeshInitializer< ConfigTag > InitializerType; typedef tnlMeshEntityInitializer< ConfigTag, EntityTag > EntityInitializerType; + typedef tnlDimensionsTag< 0 > DimensionsTag; + typedef tnlMeshSubentitiesTraits< ConfigTag, + EntityTag, + DimensionsTag > SubentitiesTraits; + typedef typename SubentitiesTraits::SharedContainerType SharedContainerType; + typedef typename SharedContainerType::ElementType GlobalIndexType; + typedef typename tnlMeshConfigTraits< ConfigTag >::template tnlMeshEntityTraits< DimensionsTag >::Type EntityType; protected: - void initSubentities( EntityInitializerType&, InitializerType& ) {} + void initSubentities( EntityType& entity, GlobalIndexType entityIndex, EntityInitializerType&, InitializerType& ) {} }; template< typename ConfigTag, @@ -529,9 +542,16 @@ class tnlMeshEntityInitializerLayer< ConfigTag, { typedef tnlMeshInitializer< ConfigTag > InitializerType; typedef tnlMeshEntityInitializer< ConfigTag, EntityTag > EntityInitializerType; + typedef tnlDimensionsTag< 0 > DimensionsTag; + typedef tnlMeshSubentitiesTraits< ConfigTag, + EntityTag, + DimensionsTag > SubentitiesTraits; + typedef typename SubentitiesTraits::SharedContainerType SharedContainerType; + typedef typename SharedContainerType::ElementType GlobalIndexType; + typedef typename tnlMeshConfigTraits< ConfigTag >::template tnlMeshEntityTraits< DimensionsTag >::Type EntityType; protected: - void initSubentities( EntityInitializerType&, + void initSubentities( EntityType& entity, GlobalIndexType entityIndex, EntityInitializerType&, InitializerType& ) {} }; diff --git a/src/mesh/tnlMeshEntitySeed.h b/src/mesh/tnlMeshEntitySeed.h new file mode 100644 index 0000000000..5fee4dfda2 --- /dev/null +++ b/src/mesh/tnlMeshEntitySeed.h @@ -0,0 +1,63 @@ +/*************************************************************************** + tnlMeshEntitySeed.h - description + ------------------- + begin : Aug 18, 2015 + copyright : (C) 2015 by Tomas Oberhuber et al. + email : tomas.oberhuber@fjfi.cvut.cz + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef TNLMESHENTITYSEED_H +#define TNLMESHENTITYSEED_H + +template< typename MeshConfig, + typename EntityTopology > +class tnlMeshEntitySeed +{ + typedef typename tnlMeshConfigTraits< MeshConfig >::template SubentityTraits< EntityTopology, tnlDimensionsTag< 0 > > SubvertexTraits; + + public: + typedef typename tnlMeshConfigTraits< MeshConfig >::GlobalIndexType GlobalIndexType; + typedef typename tnlMeshConfigTraits< MeshConfig >::LocalIndexType LocalIndexType; + //typedef typename tnlMeshConfigTraits< MeshConfig >::IdArrayAccessorType IdArrayAccessorType; + typedef typename SubvertexTraits::IdArrayType IdArrayType; + + static constexpr LocalIndexType getCornersCount() + { + return SubvertexTraits::Count; + } + + void setCornerId( LocalIndexType cornerIndex, GlobalIndexType pointIndex ) + { + tnlAssert( 0 <= cornerIndex && cornerIndex < getCornersCount(), cerr << "cornerIndex = " << cornerIndex ); + tnlAssert( 0 <= pointIndex, cerr << "pointIndex = " << pointIndex ); + + this->cornerIds[ cornerIndex ] = pointIndex; + } + + IdArrayType& getCornerIds() + { + return this->cornerIds; + } + + + const IdArrayType& getCornerIds() const + { + return this->cornerIds; + } + + private: + + IdArrayType cornerIds; +}; + +#endif /* TNLMESHENTITYSEED_H */ + diff --git a/src/mesh/tnlMeshInitializer.h b/src/mesh/tnlMeshInitializer.h index 2a1c8a2d80..aaa6e076da 100644 --- a/src/mesh/tnlMeshInitializer.h +++ b/src/mesh/tnlMeshInitializer.h @@ -169,7 +169,7 @@ class tnlMeshInitializerLayer< ConfigTag, cout << " Creating the cell number " << cell << " \r " << flush; CellInitializerType& cellInitializer = cellInitializerContainer[ cell ]; - cellInitializer.init( this->getMesh().getCell( cell ), cell ); + //cellInitializer.init( this->getMesh().getCell( cell ), cell ); BaseType::createEntitiesFromCells( cellInitializer ); } if( verbose ) @@ -185,7 +185,7 @@ class tnlMeshInitializerLayer< ConfigTag, i++ ) { //cout << " Initiating entity " << i << " with " << DimensionsTag::value << " dimensions..." << endl; - cellInitializerContainer[ i ].initEntity( meshInitializer ); + //cellInitializerContainer[ i ].initEntity( meshInitializer ); } cellInitializerContainer.reset(); //cout << "Initiating superentities ...." << endl; @@ -195,7 +195,7 @@ class tnlMeshInitializerLayer< ConfigTag, private: typedef tnlMeshSuperentityInitializerLayer< ConfigTag, - typename tnlMeshConfigTraits< ConfigTag >::CellType, + EntityTag, typename tnlMeshTraits< ConfigTag >::DimensionsTag > SuperentityInitializer; CellInitializerContainerType cellInitializerContainer; @@ -294,12 +294,13 @@ class tnlMeshInitializerLayer< ConfigTag, //cout << "Initiating entity " << i << " with " << DimensionsTag::value << " dimensions..." << endl; EntityInitializerType& entityInitializer = entityInitializerContainer[ i ]; //cout << "Initiating with entity " << this->getMesh().template getEntity< DimensionsTag::value >( i ) << endl; - entityInitializer.init( this->getMesh().template getEntity< DimensionsTag::value >( i ), i ); - entityInitializer.initEntity( meshInitializer ); + //entityInitializer.init( this->getMesh().template getEntity< DimensionsTag::value >( i ), i ); + //entityInitializer.initEntity( meshInitializer ); } entityInitializerContainer.reset(); - cout << "Initiating superentities..." << endl; + cout << "Initiating superentities for entities with " << DimensionsTag::value << " dimensions ..." << endl; + cout << "Storage is " << tnlMeshSuperentitiesTraits< ConfigTag, EntityTag, typename tnlMeshTraits< ConfigTag >::DimensionsTag >::SuperentityStorageTag::enabled << endl; superentityInitializer.initSuperentities( meshInitializer ); BaseType::initEntities( meshInitializer ); } @@ -391,16 +392,18 @@ class tnlMeshInitializerLayer< ConfigTag, { //cout << "Initiating entity " << i << " with " << DimensionsTag::value << " dimensions..." << endl; VertexInitializerType& vertexInitializer = vertexInitializerContainer[ i ]; - vertexInitializer.init( vertexContainer[ i ], i ); - vertexInitializer.initEntity( meshInitializer ); + //vertexInitializer.init( vertexContainer[ i ], i ); + //vertexInitializer.initEntity( meshInitializer ); } + cout << "Initiating superentities for entities with " << DimensionsTag::value << " dimensions ..." << endl; + cout << "Storage is " << tnlMeshSuperentitiesTraits< ConfigTag, EntityTag, typename tnlMeshTraits< ConfigTag >::DimensionsTag >::SuperentityStorageTag::enabled << endl; superentityInitializer.initSuperentities( meshInitializer ); vertexInitializerContainer.reset(); } private: typedef tnlMeshSuperentityInitializerLayer< ConfigTag, - typename tnlMeshConfigTraits< ConfigTag >::CellType, + EntityTag, typename tnlMeshTraits< ConfigTag >::DimensionsTag > SuperentityInitializer; SuperentityInitializer superentityInitializer; diff --git a/src/mesh/tnlMeshReaderNetgen.h b/src/mesh/tnlMeshReaderNetgen.h index a9e813ae06..0dfdc54a6a 100644 --- a/src/mesh/tnlMeshReaderNetgen.h +++ b/src/mesh/tnlMeshReaderNetgen.h @@ -22,6 +22,8 @@ #include <istream> #include <sstream> +#include <mesh/tnlMeshBuilder.h> + using namespace std; class tnlMeshReaderNetgen @@ -138,6 +140,7 @@ class tnlMeshReaderNetgen return false; } + tnlMeshBuilder< MeshType > meshBuilder; string line; istringstream iss; @@ -154,15 +157,15 @@ class tnlMeshReaderNetgen getline( inputFile, line ); iss.str( line ); typedef typename MeshType::template EntitiesTraits< 0 >::GlobalIndexType VertexIndexType; - VertexIndexType numberOfVertices; - iss >> numberOfVertices; - if( ! mesh.setNumberOfVertices( numberOfVertices ) ) + VertexIndexType pointsCount; + iss >> pointsCount; + if( ! meshBuilder.setPointCount( pointsCount ) ) { - cerr << "I am not able to allocate enough memory for " << numberOfVertices << " vertices." << endl; + cerr << "I am not able to allocate enough memory for " << pointsCount << " vertices." << endl; return false; } - for( VertexIndexType i = 0; i < numberOfVertices; i++ ) + for( VertexIndexType i = 0; i < pointsCount; i++ ) { getline( inputFile, line ); iss.clear(); @@ -170,10 +173,10 @@ class tnlMeshReaderNetgen PointType p; for( int d = 0; d < dimensions; d++ ) iss >> p[ d ]; - mesh.setVertex( i, p ); + meshBuilder.setPoint( i, p ); if( verbose ) - cout << numberOfVertices << " vertices expected ... " << i+1 << "/" << numberOfVertices << " \r" << flush; - const PointType& point = mesh.getVertex( i ).getPoint(); + cout << pointsCount << " vertices expected ... " << i+1 << "/" << pointsCount << " \r" << flush; + //const PointType& point = mesh.getVertex( i ).getPoint(); } if( verbose ) cout << endl; @@ -197,7 +200,7 @@ class tnlMeshReaderNetgen iss.str( line ); CellIndexType numberOfCells=atoi( line.data() ); //iss >> numberOfCells; // TODO: I do not know why this does not work - if( ! mesh.template setNumberOfEntities< dimensions >( numberOfCells ) ) + if( ! meshBuilder.setCellsCount( numberOfCells ) ) { cerr << "I am not able to allocate enough memory for " << numberOfCells << " cells." << endl; return false; diff --git a/src/mesh/tnlMeshSuperentityInitializerLayer.h b/src/mesh/tnlMeshSuperentityInitializerLayer.h index 902be58b79..9425287a30 100644 --- a/src/mesh/tnlMeshSuperentityInitializerLayer.h +++ b/src/mesh/tnlMeshSuperentityInitializerLayer.h @@ -62,8 +62,10 @@ class tnlMeshSuperentityInitializerLayer< ConfigTag, indexPairs.push_back( IndexPair{ entityIndex, superentityIndex } ); } + using BaseType::initSuperentities; void initSuperentities( MeshInitializer& meshInitializer ) { + cerr << "####" << endl; std::sort( indexPairs.begin(), indexPairs.end(), []( IndexPair pair0, IndexPair pair1 ){ return ( pair0.entityIndex < pair1.entityIndex ); } ); @@ -72,10 +74,12 @@ class tnlMeshSuperentityInitializerLayer< ConfigTag, superentityIdsArray.setSize( static_cast< GlobalIndexType >( indexPairs.size() ) ); GlobalIndexType currentBegin = 0; GlobalIndexType lastEntityIndex = 0; + cout << "There are " << superentityIdsArray.getSize() << " superentities..." << endl; for( GlobalIndexType i = 0; i < superentityIdsArray.getSize(); i++) { superentityIdsArray[ i ] = indexPairs[i].superentityIndex; - + + cout << "Adding superentity " << indexPairs[i].superentityIndex << " to entity " << lastEntityIndex << endl; if( indexPairs[ i ].entityIndex != lastEntityIndex ) { meshInitializer.template superentityIdsArray< DimensionsTag >( meshInitializer.template meshEntitiesArray< EntityDimensions >()[ lastEntityIndex ] ).bind( superentityIdsArray, currentBegin, i - currentBegin ); @@ -112,6 +116,15 @@ class tnlMeshSuperentityInitializerLayer< ConfigTag, EntityTag, typename DimensionsTag::Decrement > { + typedef tnlMeshSuperentityInitializerLayer< ConfigTag, + EntityTag, + typename DimensionsTag::Decrement > BaseType; + typedef tnlMeshInitializer< ConfigTag > MeshInitializerType; + + public: + void addSuperentity() {} // This method is due to 'using BaseType::...;' in the derived classes. + using BaseType::initSuperentities; + void initSuperentities( MeshInitializerType& ) {cerr << "***" << endl;} }; template< typename ConfigTag, @@ -125,7 +138,7 @@ class tnlMeshSuperentityInitializerLayer< ConfigTag, public: void addSuperentity() {} // This method is due to 'using BaseType::...;' in the derived classes. - void initSuperentities( MeshInitializerType& ) {} + void initSuperentities( MeshInitializerType& ) {cerr << "***" << endl;} }; template< typename ConfigTag, @@ -139,7 +152,7 @@ class tnlMeshSuperentityInitializerLayer< ConfigTag, public: void addSuperentity() {} // This method is due to 'using BaseType::...;' in the derived classes. - void initSuperentities( MeshInitializerType& ) {} + void initSuperentities( MeshInitializerType& ) { cerr << "***" << endl;} }; diff --git a/src/mesh/traits/tnlMeshTraits.h b/src/mesh/traits/tnlMeshTraits.h index 595e3f82a2..d870f3c71f 100644 --- a/src/mesh/traits/tnlMeshTraits.h +++ b/src/mesh/traits/tnlMeshTraits.h @@ -25,18 +25,25 @@ template< typename ConfigTag, typename EntityTag > class tnlMeshEntity; -template< typename ConfigTag > +template< typename MeshConfig, + typename Device = tnlHost > class tnlMeshTraits { public: - - enum { meshDimensions = ConfigTag::CellType::dimensions }; - - enum { worldDimensions = ConfigTag::worldDimensions }; - - typedef tnlDimensionsTag< meshDimensions > DimensionsTag; - typedef tnlStaticVector< worldDimensions, typename ConfigTag::RealType > PointType; - typedef tnlMeshEntity< ConfigTag, typename ConfigTag::CellType > CellType; + + static const int meshDimensions = MeshConfig::CellType::dimensions; + static const int worldDimensions = MeshConfig::worldDimensions; + + typedef Device DeviceType; + typedef typename MeshConfig::GlobalIndexTyp GlobalIndexType; + typedef typename MeshConfig::LocalIndexType LocalIndexType; + + typedef tnlStaticVector< worldDimensions, typename MeshConfig::RealType > PointType; + typedef tnlMeshEntity< MeshConfig, typename MeshConfig::CellType > CellType; + typedef typename CellType::SeedType CellSeedType; + + typedef tnlArray< PointType, tnlHost, GlobalIndexType > PointArrayType; + typedef tnlArray< CellSeedType, tnlHost, GlobalIndexType > CellSeedArrayType; }; -- GitLab