Loading src/TNL/Meshes/Geometry/getDecomposedMesh.h +2 −2 Original line number Diff line number Diff line Loading @@ -70,7 +70,7 @@ getDecomposedMesh( const Mesh< MeshConfig, Devices::Host > & inMesh ) // Lambda for setting decomposed triangle in meshBuilder GlobalIndexType setCellsCount = 0; auto setDecomposedCellFunc = [&] ( GlobalIndexType v0, GlobalIndexType v1, GlobalIndexType v2 ) { auto & entitySeed = meshBuilder.getCellSeed( setCellsCount++ ); auto entitySeed = meshBuilder.getCellSeed( setCellsCount++ ); entitySeed.setCornerId( 0, v0 ); entitySeed.setCornerId( 1, v1 ); entitySeed.setCornerId( 2, v2 ); Loading Loading @@ -142,7 +142,7 @@ getDecomposedMesh( const Mesh< MeshConfig, Devices::Host > & inMesh ) // Lambda for setting decomposed cells in meshBuilder GlobalIndexType setCellsCount = 0; auto setDecomposedCellFunc = [&] ( GlobalIndexType v0, GlobalIndexType v1, GlobalIndexType v2, GlobalIndexType v3 ) { auto & entitySeed = meshBuilder.getCellSeed( setCellsCount++ ); auto entitySeed = meshBuilder.getCellSeed( setCellsCount++ ); entitySeed.setCornerId( 0, v0 ); entitySeed.setCornerId( 1, v1 ); entitySeed.setCornerId( 2, v2 ); Loading src/TNL/Meshes/Geometry/getPlanarMesh.h +57 −26 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ getPlanarMesh( const Mesh< MeshConfig, Devices::Host > & inMesh ) using LocalIndexType = typename PolygonMesh::LocalIndexType; using PointType = typename PolygonMesh::PointType; using RealType = typename PolygonMesh::RealType; using BoolVector = Containers::Vector< bool, Devices::Host, GlobalIndexType >; using EntityDecomposer = EntityDecomposer< MeshConfig, Topologies::Polygon, EntityDecomposerVersion_ >; constexpr RealType precision{ 1e-6 }; Loading @@ -37,12 +38,17 @@ getPlanarMesh( const Mesh< MeshConfig, Devices::Host > & inMesh ) const GlobalIndexType inPointsCount = inMesh.template getEntitiesCount< 0 >(); const GlobalIndexType inCellsCount = inMesh.template getEntitiesCount< 2 >(); // find the number of points and cells in the outMesh BoolVector planarCache; planarCache.setSize( inCellsCount ); // Count the number of points and cells in the outMesh GlobalIndexType outPointsCount = inPointsCount; GlobalIndexType outCellsCount = 0; for( GlobalIndexType i = 0; i < inCellsCount; i++ ) { const auto cell = inMesh.template getEntity< 2 >( i ); if( isPlanar( inMesh, cell, precision ) ) { // Cell is not decomposed const bool planar = isPlanar( inMesh, cell, precision ); planarCache.setElement( i, planar ); if( planar ) { // Cell is not decomposed outCellsCount++; } else { // Cell is decomposed Loading @@ -68,25 +74,42 @@ getPlanarMesh( const Mesh< MeshConfig, Devices::Host > & inMesh ) return pointIdx; }; // Lambda for setting decomposed cells in meshBuilder // set corner counts for cells for( GlobalIndexType i = 0, o = 0; i < inCellsCount; i++ ) { const auto cell = inMesh.template getEntity< 2 >( i ); const bool planar = planarCache[ i ]; if( planar ) { // Copy planar cells const auto verticesCount = cell.template getSubentitiesCount< 0 >(); meshBuilder.setCellCornersCount( o++, verticesCount ); } else { // Decompose non-planar cells GlobalIndexType entitiesCount; std::tie( std::ignore, entitiesCount ) = EntityDecomposer::getExtraPointsAndEntitiesCount( cell ); for( GlobalIndexType j = 0; j < entitiesCount; j++ ) { meshBuilder.setCellCornersCount( o++, 3 ); } } } meshBuilder.initializeCellSeeds(); // Lambda for setting corner ids of decomposed cells GlobalIndexType setCellsCount = 0; auto setDecomposedCellFunc = [&] ( GlobalIndexType v0, GlobalIndexType v1, GlobalIndexType v2 ) { auto & entitySeed = meshBuilder.getCellSeed( setCellsCount++ ); entitySeed.setCornersCount( 3 ); entitySeed.setCornerId( 0, v0 ); entitySeed.setCornerId( 1, v1 ); entitySeed.setCornerId( 2, v2 ); auto seed = meshBuilder.getCellSeed( setCellsCount++ ); seed.setCornerId( 0, v0 ); seed.setCornerId( 1, v1 ); seed.setCornerId( 2, v2 ); }; // Decompose non-planar cells and copy the rest for( GlobalIndexType i = 0; i < inCellsCount; i++ ) { const auto cell = inMesh.template getEntity< 2 >( i ); if( isPlanar( inMesh, cell, precision ) ) { // Copy planar cells auto & cellSeed = meshBuilder.getCellSeed( setCellsCount++ ); const bool planar = planarCache[ i ]; if( planar ) { // Copy planar cells auto seed = meshBuilder.getCellSeed( setCellsCount++ ); const auto verticesCount = cell.template getSubentitiesCount< 0 >(); cellSeed.setCornersCount( verticesCount ); for( LocalIndexType j = 0; j < verticesCount; j++ ) { cellSeed.setCornerId( j, cell.template getSubentityIndex< 0 >( j ) ); seed.setCornerId( j, cell.template getSubentityIndex< 0 >( j ) ); } } else { // Decompose non-planar cells Loading Loading @@ -124,7 +147,7 @@ getPlanarMesh( const Mesh< MeshConfig, Devices::Host > & inMesh ) FaceMapArray faceMap( inFacesCount ); // Mapping of original face indeces to a group of decomposed face indices // Find the number of points and faces in the outMesh and setup faceMap // Count the number of points and faces in the outMesh and setup faceMap GlobalIndexType outPointsCount = inPointsCount; GlobalIndexType outFacesCount = 0; for( GlobalIndexType i = 0; i < inFacesCount; i++ ) { Loading Loading @@ -155,32 +178,40 @@ getPlanarMesh( const Mesh< MeshConfig, Devices::Host > & inMesh ) meshBuilder.setPoint( setPointsCount, inMesh.getPoint( setPointsCount ) ); } // Set up cell seeds // set cell corner counts for( GlobalIndexType i = 0; i < inCellsCount; i++ ) { const auto cell = inMesh.template getEntity< 3 >( i ); const LocalIndexType cellFacesCount = cell.template getSubentitiesCount< 2 >(); // Find the number of faces in the output cell LocalIndexType cellSeedFacesCount = 0; // Count the number of faces in the cell LocalIndexType cornersCount = 0; for( LocalIndexType j = 0; j < cellFacesCount; j++ ) { const GlobalIndexType faceIdx = cell.template getSubentityIndex< 2 >( j ); const auto & faceMapping = faceMap[ faceIdx ]; cellSeedFacesCount += faceMapping.second - faceMapping.first; cornersCount += faceMapping.second - faceMapping.first; } // Set up the cell seed auto & cellSeed = meshBuilder.getCellSeed( i ); cellSeed.setCornersCount( cellSeedFacesCount ); for( LocalIndexType j = 0, faceSetIdx = 0; j < cellFacesCount; j++ ) { meshBuilder.setCellCornersCount( i, cornersCount ); } meshBuilder.initializeCellSeeds(); // Set cell corner ids for( GlobalIndexType i = 0; i < inCellsCount; i++ ) { const auto cell = inMesh.template getEntity< 3 >( i ); const LocalIndexType cellFacesCount = cell.template getSubentitiesCount< 2 >(); for( LocalIndexType j = 0, o = 0; j < cellFacesCount; j++ ) { const GlobalIndexType faceIdx = cell.template getSubentityIndex< 2 >( j ); const auto & faceMapping = faceMap[ faceIdx ]; auto cellSeed = meshBuilder.getCellSeed( i ); for( GlobalIndexType k = faceMapping.first; k < faceMapping.second; k++ ) { cellSeed.setCornerId( faceSetIdx++, k ); cellSeed.setCornerId( o++, k ); } } } // set corners count for face seeds // set face corners count GlobalIndexType setFacesCount = 0; for( GlobalIndexType i = 0; i < inFacesCount; i++ ) { const auto & faceMapping = faceMap[ i ]; Loading @@ -205,7 +236,7 @@ getPlanarMesh( const Mesh< MeshConfig, Devices::Host > & inMesh ) return pointIdx; }; // Lambda for setting seed of decomposed triangle // Lambda for setting corner ids of decomposed faces setFacesCount = 0; auto setDecomposedFaceFunc = [&] ( GlobalIndexType v0, GlobalIndexType v1, GlobalIndexType v2 ) { const GlobalIndexType faceId = setFacesCount++; Loading src/TNL/Meshes/Mesh.h +1 −1 Original line number Diff line number Diff line Loading @@ -51,7 +51,7 @@ class MeshInitializableBase // The points and cellSeeds arrays will be reset when not needed to save memory. void init( typename MeshTraitsType::PointArrayType& points, typename MeshTraitsType::FaceSeedMatrixType& faceSeeds, typename MeshTraitsType::CellSeedArrayType& cellSeeds ); typename MeshTraitsType::CellSeedMatrixType& cellSeeds ); }; // The mesh cannot be initialized on CUDA GPU, so this specialization is empty. Loading src/TNL/Meshes/Mesh.hpp +1 −1 Original line number Diff line number Diff line Loading @@ -28,7 +28,7 @@ void MeshInitializableBase< MeshConfig, Device, MeshType >:: init( typename MeshTraitsType::PointArrayType& points, typename MeshTraitsType::FaceSeedMatrixType& faceSeeds, typename MeshTraitsType::CellSeedArrayType& cellSeeds ) typename MeshTraitsType::CellSeedMatrixType& cellSeeds ) { MeshType* mesh = static_cast< MeshType* >( this ); Initializer< typename MeshType::Config > initializer; Loading src/TNL/Meshes/MeshBuilder.h +35 −21 Original line number Diff line number Diff line Loading @@ -31,8 +31,8 @@ public: using LocalIndexType = typename MeshTraitsType::LocalIndexType; using PointType = typename MeshTraitsType::PointType; using CellTopology = typename MeshTraitsType::CellTopology; using CellSeedType = typename MeshTraitsType::CellSeedType; using CellSeedMatrixType = typename MeshTraitsType::CellSeedMatrixType; using CellSeedType = typename CellSeedMatrixType::EntitySeedMatrixSeed; using FaceSeedMatrixType = typename MeshTraitsType::FaceSeedMatrixType; using FaceSeedType = typename FaceSeedMatrixType::EntitySeedMatrixSeed; Loading Loading @@ -60,7 +60,20 @@ public: void setCellsCount( const GlobalIndexType& cellsCount ) { this->cellSeeds.setSize( cellsCount ); if( getFacesCount() == 0 ) // faceSeeds aren't used ( cellSeeds store indeces of points ) this->cellSeeds.setDimensions( cellsCount, getPointsCount() ); else // faceSeeds are used ( cellSeeds store indeces of faces ) this->cellSeeds.setDimensions( cellsCount, getFacesCount() ); } void setCellCornersCount( const GlobalIndexType& cellIndex, const LocalIndexType& cornersCount ) { this->cellSeeds.setEntityCornersCount( cellIndex, cornersCount ); } void initializeCellSeeds() { this->cellSeeds.initializeRows(); } GlobalIndexType getPointsCount() const Loading @@ -75,7 +88,7 @@ public: GlobalIndexType getCellsCount() const { return this->cellSeeds.getSize(); return this->cellSeeds.getEntitiesCount(); } void setPoint( GlobalIndexType index, Loading @@ -90,9 +103,9 @@ public: return this->faceSeeds.getSeed( index ); } CellSeedType& getCellSeed( GlobalIndexType index ) CellSeedType getCellSeed( GlobalIndexType index ) { return this->cellSeeds[ index ]; return this->cellSeeds.getSeed( index ); } bool build( MeshType& mesh ) Loading @@ -105,8 +118,6 @@ public: private: using PointArrayType = typename MeshTraitsType::PointArrayType; using CellSeedArrayType = typename MeshTraitsType::CellSeedArrayType; using FaceSeedArrayType = typename MeshTraitsType::FaceSeedArrayType; using BoolVector = Containers::Vector< bool, Devices::Host, GlobalIndexType >; bool validate() const Loading @@ -123,11 +134,12 @@ private: if( faceSeeds.empty() ) { for( GlobalIndexType i = 0; i < getCellsCount(); i++ ) { const auto& cornerIds = this->cellSeeds[ i ].getCornerIds(); for( LocalIndexType j = 0; j < cornerIds.getSize(); j++ ) { assignedPoints[ cornerIds[ j ] ] = true; if( cornerIds[ j ] < 0 || getPointsCount() <= cornerIds[ j ] ) { std::cerr << "Cell seed " << i << " is referencing unavailable point " << cornerIds[ j ] << std::endl; const auto cellSeed = this->cellSeeds.getSeed( i ); for( LocalIndexType j = 0; j < cellSeed.getCornersCount(); j++ ) { const GlobalIndexType cornerId = cellSeed.getCornerId( j ); assignedPoints[ cornerId ] = true; if( cornerId < 0 || getPointsCount() <= cornerId ) { std::cerr << "Cell seed " << i << " is referencing unavailable point " << cornerId << std::endl; return false; } } Loading @@ -143,11 +155,12 @@ private: for( GlobalIndexType i = 0; i < getFacesCount(); i++ ) { const auto faceSeed = this->faceSeeds.getSeed( i ); for( LocalIndexType j = 0; j < faceSeed.getCornersCount(); j++ ) { if( faceSeed.getCornerId( j ) < 0 || getPointsCount() <= faceSeed.getCornerId( j ) ) { std::cerr << "face seed " << i << " is referencing unavailable point " << faceSeed.getCornerId( j ) << std::endl; const GlobalIndexType cornerId = faceSeed.getCornerId( j ); if( cornerId < 0 || getPointsCount() <= cornerId ) { std::cerr << "face seed " << i << " is referencing unavailable point " << cornerId << std::endl; return false; } assignedPoints[ faceSeed.getCornerId( j ) ] = true; assignedPoints[ cornerId ] = true; } } Loading @@ -161,13 +174,14 @@ private: assignedFaces.setValue( false ); for( GlobalIndexType i = 0; i < getCellsCount(); i++ ) { const auto& cornerIds = this->cellSeeds[ i ].getCornerIds(); for( LocalIndexType j = 0; j < cornerIds.getSize(); j++ ) { if( cornerIds[ j ] < 0 || getFacesCount() <= cornerIds[ j ] ) { std::cerr << "cell seed " << i << " is referencing unavailable face " << cornerIds[ j ] << std::endl; const auto cellSeed = this->cellSeeds.getSeed( i ); for( LocalIndexType j = 0; j < cellSeed.getCornersCount(); j++ ) { const GlobalIndexType cornerId = cellSeed.getCornerId( j ); if( cornerId < 0 || getFacesCount() <= cornerId ) { std::cerr << "cell seed " << i << " is referencing unavailable face " << cornerId << std::endl; return false; } assignedFaces[ cornerIds[ j ] ] = true; assignedFaces[ cornerId ] = true; } } Loading @@ -182,7 +196,7 @@ private: PointArrayType points; FaceSeedMatrixType faceSeeds; CellSeedArrayType cellSeeds; CellSeedMatrixType cellSeeds; BoolVector pointsSet; }; Loading Loading
src/TNL/Meshes/Geometry/getDecomposedMesh.h +2 −2 Original line number Diff line number Diff line Loading @@ -70,7 +70,7 @@ getDecomposedMesh( const Mesh< MeshConfig, Devices::Host > & inMesh ) // Lambda for setting decomposed triangle in meshBuilder GlobalIndexType setCellsCount = 0; auto setDecomposedCellFunc = [&] ( GlobalIndexType v0, GlobalIndexType v1, GlobalIndexType v2 ) { auto & entitySeed = meshBuilder.getCellSeed( setCellsCount++ ); auto entitySeed = meshBuilder.getCellSeed( setCellsCount++ ); entitySeed.setCornerId( 0, v0 ); entitySeed.setCornerId( 1, v1 ); entitySeed.setCornerId( 2, v2 ); Loading Loading @@ -142,7 +142,7 @@ getDecomposedMesh( const Mesh< MeshConfig, Devices::Host > & inMesh ) // Lambda for setting decomposed cells in meshBuilder GlobalIndexType setCellsCount = 0; auto setDecomposedCellFunc = [&] ( GlobalIndexType v0, GlobalIndexType v1, GlobalIndexType v2, GlobalIndexType v3 ) { auto & entitySeed = meshBuilder.getCellSeed( setCellsCount++ ); auto entitySeed = meshBuilder.getCellSeed( setCellsCount++ ); entitySeed.setCornerId( 0, v0 ); entitySeed.setCornerId( 1, v1 ); entitySeed.setCornerId( 2, v2 ); Loading
src/TNL/Meshes/Geometry/getPlanarMesh.h +57 −26 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ getPlanarMesh( const Mesh< MeshConfig, Devices::Host > & inMesh ) using LocalIndexType = typename PolygonMesh::LocalIndexType; using PointType = typename PolygonMesh::PointType; using RealType = typename PolygonMesh::RealType; using BoolVector = Containers::Vector< bool, Devices::Host, GlobalIndexType >; using EntityDecomposer = EntityDecomposer< MeshConfig, Topologies::Polygon, EntityDecomposerVersion_ >; constexpr RealType precision{ 1e-6 }; Loading @@ -37,12 +38,17 @@ getPlanarMesh( const Mesh< MeshConfig, Devices::Host > & inMesh ) const GlobalIndexType inPointsCount = inMesh.template getEntitiesCount< 0 >(); const GlobalIndexType inCellsCount = inMesh.template getEntitiesCount< 2 >(); // find the number of points and cells in the outMesh BoolVector planarCache; planarCache.setSize( inCellsCount ); // Count the number of points and cells in the outMesh GlobalIndexType outPointsCount = inPointsCount; GlobalIndexType outCellsCount = 0; for( GlobalIndexType i = 0; i < inCellsCount; i++ ) { const auto cell = inMesh.template getEntity< 2 >( i ); if( isPlanar( inMesh, cell, precision ) ) { // Cell is not decomposed const bool planar = isPlanar( inMesh, cell, precision ); planarCache.setElement( i, planar ); if( planar ) { // Cell is not decomposed outCellsCount++; } else { // Cell is decomposed Loading @@ -68,25 +74,42 @@ getPlanarMesh( const Mesh< MeshConfig, Devices::Host > & inMesh ) return pointIdx; }; // Lambda for setting decomposed cells in meshBuilder // set corner counts for cells for( GlobalIndexType i = 0, o = 0; i < inCellsCount; i++ ) { const auto cell = inMesh.template getEntity< 2 >( i ); const bool planar = planarCache[ i ]; if( planar ) { // Copy planar cells const auto verticesCount = cell.template getSubentitiesCount< 0 >(); meshBuilder.setCellCornersCount( o++, verticesCount ); } else { // Decompose non-planar cells GlobalIndexType entitiesCount; std::tie( std::ignore, entitiesCount ) = EntityDecomposer::getExtraPointsAndEntitiesCount( cell ); for( GlobalIndexType j = 0; j < entitiesCount; j++ ) { meshBuilder.setCellCornersCount( o++, 3 ); } } } meshBuilder.initializeCellSeeds(); // Lambda for setting corner ids of decomposed cells GlobalIndexType setCellsCount = 0; auto setDecomposedCellFunc = [&] ( GlobalIndexType v0, GlobalIndexType v1, GlobalIndexType v2 ) { auto & entitySeed = meshBuilder.getCellSeed( setCellsCount++ ); entitySeed.setCornersCount( 3 ); entitySeed.setCornerId( 0, v0 ); entitySeed.setCornerId( 1, v1 ); entitySeed.setCornerId( 2, v2 ); auto seed = meshBuilder.getCellSeed( setCellsCount++ ); seed.setCornerId( 0, v0 ); seed.setCornerId( 1, v1 ); seed.setCornerId( 2, v2 ); }; // Decompose non-planar cells and copy the rest for( GlobalIndexType i = 0; i < inCellsCount; i++ ) { const auto cell = inMesh.template getEntity< 2 >( i ); if( isPlanar( inMesh, cell, precision ) ) { // Copy planar cells auto & cellSeed = meshBuilder.getCellSeed( setCellsCount++ ); const bool planar = planarCache[ i ]; if( planar ) { // Copy planar cells auto seed = meshBuilder.getCellSeed( setCellsCount++ ); const auto verticesCount = cell.template getSubentitiesCount< 0 >(); cellSeed.setCornersCount( verticesCount ); for( LocalIndexType j = 0; j < verticesCount; j++ ) { cellSeed.setCornerId( j, cell.template getSubentityIndex< 0 >( j ) ); seed.setCornerId( j, cell.template getSubentityIndex< 0 >( j ) ); } } else { // Decompose non-planar cells Loading Loading @@ -124,7 +147,7 @@ getPlanarMesh( const Mesh< MeshConfig, Devices::Host > & inMesh ) FaceMapArray faceMap( inFacesCount ); // Mapping of original face indeces to a group of decomposed face indices // Find the number of points and faces in the outMesh and setup faceMap // Count the number of points and faces in the outMesh and setup faceMap GlobalIndexType outPointsCount = inPointsCount; GlobalIndexType outFacesCount = 0; for( GlobalIndexType i = 0; i < inFacesCount; i++ ) { Loading Loading @@ -155,32 +178,40 @@ getPlanarMesh( const Mesh< MeshConfig, Devices::Host > & inMesh ) meshBuilder.setPoint( setPointsCount, inMesh.getPoint( setPointsCount ) ); } // Set up cell seeds // set cell corner counts for( GlobalIndexType i = 0; i < inCellsCount; i++ ) { const auto cell = inMesh.template getEntity< 3 >( i ); const LocalIndexType cellFacesCount = cell.template getSubentitiesCount< 2 >(); // Find the number of faces in the output cell LocalIndexType cellSeedFacesCount = 0; // Count the number of faces in the cell LocalIndexType cornersCount = 0; for( LocalIndexType j = 0; j < cellFacesCount; j++ ) { const GlobalIndexType faceIdx = cell.template getSubentityIndex< 2 >( j ); const auto & faceMapping = faceMap[ faceIdx ]; cellSeedFacesCount += faceMapping.second - faceMapping.first; cornersCount += faceMapping.second - faceMapping.first; } // Set up the cell seed auto & cellSeed = meshBuilder.getCellSeed( i ); cellSeed.setCornersCount( cellSeedFacesCount ); for( LocalIndexType j = 0, faceSetIdx = 0; j < cellFacesCount; j++ ) { meshBuilder.setCellCornersCount( i, cornersCount ); } meshBuilder.initializeCellSeeds(); // Set cell corner ids for( GlobalIndexType i = 0; i < inCellsCount; i++ ) { const auto cell = inMesh.template getEntity< 3 >( i ); const LocalIndexType cellFacesCount = cell.template getSubentitiesCount< 2 >(); for( LocalIndexType j = 0, o = 0; j < cellFacesCount; j++ ) { const GlobalIndexType faceIdx = cell.template getSubentityIndex< 2 >( j ); const auto & faceMapping = faceMap[ faceIdx ]; auto cellSeed = meshBuilder.getCellSeed( i ); for( GlobalIndexType k = faceMapping.first; k < faceMapping.second; k++ ) { cellSeed.setCornerId( faceSetIdx++, k ); cellSeed.setCornerId( o++, k ); } } } // set corners count for face seeds // set face corners count GlobalIndexType setFacesCount = 0; for( GlobalIndexType i = 0; i < inFacesCount; i++ ) { const auto & faceMapping = faceMap[ i ]; Loading @@ -205,7 +236,7 @@ getPlanarMesh( const Mesh< MeshConfig, Devices::Host > & inMesh ) return pointIdx; }; // Lambda for setting seed of decomposed triangle // Lambda for setting corner ids of decomposed faces setFacesCount = 0; auto setDecomposedFaceFunc = [&] ( GlobalIndexType v0, GlobalIndexType v1, GlobalIndexType v2 ) { const GlobalIndexType faceId = setFacesCount++; Loading
src/TNL/Meshes/Mesh.h +1 −1 Original line number Diff line number Diff line Loading @@ -51,7 +51,7 @@ class MeshInitializableBase // The points and cellSeeds arrays will be reset when not needed to save memory. void init( typename MeshTraitsType::PointArrayType& points, typename MeshTraitsType::FaceSeedMatrixType& faceSeeds, typename MeshTraitsType::CellSeedArrayType& cellSeeds ); typename MeshTraitsType::CellSeedMatrixType& cellSeeds ); }; // The mesh cannot be initialized on CUDA GPU, so this specialization is empty. Loading
src/TNL/Meshes/Mesh.hpp +1 −1 Original line number Diff line number Diff line Loading @@ -28,7 +28,7 @@ void MeshInitializableBase< MeshConfig, Device, MeshType >:: init( typename MeshTraitsType::PointArrayType& points, typename MeshTraitsType::FaceSeedMatrixType& faceSeeds, typename MeshTraitsType::CellSeedArrayType& cellSeeds ) typename MeshTraitsType::CellSeedMatrixType& cellSeeds ) { MeshType* mesh = static_cast< MeshType* >( this ); Initializer< typename MeshType::Config > initializer; Loading
src/TNL/Meshes/MeshBuilder.h +35 −21 Original line number Diff line number Diff line Loading @@ -31,8 +31,8 @@ public: using LocalIndexType = typename MeshTraitsType::LocalIndexType; using PointType = typename MeshTraitsType::PointType; using CellTopology = typename MeshTraitsType::CellTopology; using CellSeedType = typename MeshTraitsType::CellSeedType; using CellSeedMatrixType = typename MeshTraitsType::CellSeedMatrixType; using CellSeedType = typename CellSeedMatrixType::EntitySeedMatrixSeed; using FaceSeedMatrixType = typename MeshTraitsType::FaceSeedMatrixType; using FaceSeedType = typename FaceSeedMatrixType::EntitySeedMatrixSeed; Loading Loading @@ -60,7 +60,20 @@ public: void setCellsCount( const GlobalIndexType& cellsCount ) { this->cellSeeds.setSize( cellsCount ); if( getFacesCount() == 0 ) // faceSeeds aren't used ( cellSeeds store indeces of points ) this->cellSeeds.setDimensions( cellsCount, getPointsCount() ); else // faceSeeds are used ( cellSeeds store indeces of faces ) this->cellSeeds.setDimensions( cellsCount, getFacesCount() ); } void setCellCornersCount( const GlobalIndexType& cellIndex, const LocalIndexType& cornersCount ) { this->cellSeeds.setEntityCornersCount( cellIndex, cornersCount ); } void initializeCellSeeds() { this->cellSeeds.initializeRows(); } GlobalIndexType getPointsCount() const Loading @@ -75,7 +88,7 @@ public: GlobalIndexType getCellsCount() const { return this->cellSeeds.getSize(); return this->cellSeeds.getEntitiesCount(); } void setPoint( GlobalIndexType index, Loading @@ -90,9 +103,9 @@ public: return this->faceSeeds.getSeed( index ); } CellSeedType& getCellSeed( GlobalIndexType index ) CellSeedType getCellSeed( GlobalIndexType index ) { return this->cellSeeds[ index ]; return this->cellSeeds.getSeed( index ); } bool build( MeshType& mesh ) Loading @@ -105,8 +118,6 @@ public: private: using PointArrayType = typename MeshTraitsType::PointArrayType; using CellSeedArrayType = typename MeshTraitsType::CellSeedArrayType; using FaceSeedArrayType = typename MeshTraitsType::FaceSeedArrayType; using BoolVector = Containers::Vector< bool, Devices::Host, GlobalIndexType >; bool validate() const Loading @@ -123,11 +134,12 @@ private: if( faceSeeds.empty() ) { for( GlobalIndexType i = 0; i < getCellsCount(); i++ ) { const auto& cornerIds = this->cellSeeds[ i ].getCornerIds(); for( LocalIndexType j = 0; j < cornerIds.getSize(); j++ ) { assignedPoints[ cornerIds[ j ] ] = true; if( cornerIds[ j ] < 0 || getPointsCount() <= cornerIds[ j ] ) { std::cerr << "Cell seed " << i << " is referencing unavailable point " << cornerIds[ j ] << std::endl; const auto cellSeed = this->cellSeeds.getSeed( i ); for( LocalIndexType j = 0; j < cellSeed.getCornersCount(); j++ ) { const GlobalIndexType cornerId = cellSeed.getCornerId( j ); assignedPoints[ cornerId ] = true; if( cornerId < 0 || getPointsCount() <= cornerId ) { std::cerr << "Cell seed " << i << " is referencing unavailable point " << cornerId << std::endl; return false; } } Loading @@ -143,11 +155,12 @@ private: for( GlobalIndexType i = 0; i < getFacesCount(); i++ ) { const auto faceSeed = this->faceSeeds.getSeed( i ); for( LocalIndexType j = 0; j < faceSeed.getCornersCount(); j++ ) { if( faceSeed.getCornerId( j ) < 0 || getPointsCount() <= faceSeed.getCornerId( j ) ) { std::cerr << "face seed " << i << " is referencing unavailable point " << faceSeed.getCornerId( j ) << std::endl; const GlobalIndexType cornerId = faceSeed.getCornerId( j ); if( cornerId < 0 || getPointsCount() <= cornerId ) { std::cerr << "face seed " << i << " is referencing unavailable point " << cornerId << std::endl; return false; } assignedPoints[ faceSeed.getCornerId( j ) ] = true; assignedPoints[ cornerId ] = true; } } Loading @@ -161,13 +174,14 @@ private: assignedFaces.setValue( false ); for( GlobalIndexType i = 0; i < getCellsCount(); i++ ) { const auto& cornerIds = this->cellSeeds[ i ].getCornerIds(); for( LocalIndexType j = 0; j < cornerIds.getSize(); j++ ) { if( cornerIds[ j ] < 0 || getFacesCount() <= cornerIds[ j ] ) { std::cerr << "cell seed " << i << " is referencing unavailable face " << cornerIds[ j ] << std::endl; const auto cellSeed = this->cellSeeds.getSeed( i ); for( LocalIndexType j = 0; j < cellSeed.getCornersCount(); j++ ) { const GlobalIndexType cornerId = cellSeed.getCornerId( j ); if( cornerId < 0 || getFacesCount() <= cornerId ) { std::cerr << "cell seed " << i << " is referencing unavailable face " << cornerId << std::endl; return false; } assignedFaces[ cornerIds[ j ] ] = true; assignedFaces[ cornerId ] = true; } } Loading @@ -182,7 +196,7 @@ private: PointArrayType points; FaceSeedMatrixType faceSeeds; CellSeedArrayType cellSeeds; CellSeedMatrixType cellSeeds; BoolVector pointsSet; }; Loading