Loading src/TNL/Meshes/Readers/MeshReader.h +6 −0 Original line number Diff line number Diff line Loading @@ -154,6 +154,12 @@ public: if( meshType != "Meshes::Mesh" ) throw MeshReaderError( "MeshReader", "the file does not contain an unstructured mesh, it is " + meshType ); // skip empty mesh (the cell shape is indeterminate) if( NumberOfPoints == 0 && NumberOfCells == 0 ) { mesh = MeshType {}; return; } // check that the cell shape mathes const VTK::EntityShape meshCellShape = VTK::TopologyToEntityShape< typename MeshType::template EntityTraits< MeshType::getMeshDimension() >::EntityTopology >::shape; if( meshCellShape != cellShape ) Loading src/TNL/Meshes/Readers/PVTUReader.h +15 −2 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ #include <experimental/filesystem> #include <TNL/MPI/Wrappers.h> #include <TNL/MPI/Utils.h> #include <TNL/Meshes/Readers/VTUReader.h> #include <TNL/Meshes/MeshDetails/layers/EntityTags/Traits.h> Loading Loading @@ -204,9 +205,21 @@ public: // reset arrays since they are not needed anymore this->pointTags = this->cellTags = pointGlobalIndices = cellGlobalIndices = {}; // check if we need to split the communicator const Index minCount = MPI::reduce( TNL::min( pointsCount, cellsCount ), MPI_MIN ); if( minCount == 0 ) { // split the communicator, remove the ranks which did not get a subdomain const int color = (pointsCount > 0 && cellsCount > 0) ? 0 : MPI_UNDEFINED; const MPI_Comm subgroup = MPI::Comm_split( group, color, 0 ); // set the communication group mesh.setCommunicationGroup( subgroup ); } else { // set the communication group mesh.setCommunicationGroup( group ); } } virtual VariantVector readPointData( std::string arrayName ) override Loading src/TNL/Meshes/Readers/VTUReader.h +3 −0 Original line number Diff line number Diff line Loading @@ -89,6 +89,9 @@ class VTUReader // check array size if( array.size() != NumberOfCells ) throw MeshReaderError( "VTUReader", "size of the types data array does not match the NumberOfCells attribute" ); // check empty mesh if( array.size() == 0 ) return; cellShape = (VTK::EntityShape) array[0]; meshDimension = getEntityDimension( cellShape ); // TODO: check only entities of the same dimension (edges, faces and cells separately) Loading src/TNL/Meshes/Readers/XMLVTK.h +8 −2 Original line number Diff line number Diff line Loading @@ -166,6 +166,10 @@ protected: VariantVector readAsciiBlock( const char* block ) const { // handle empty array if( ! block ) return std::vector<T> {}; // creating a copy of the block is rather costly, but so is ASCII parsing std::stringstream ss; ss << block; Loading @@ -187,6 +191,10 @@ protected: VariantVector readBinaryBlock( const char* block ) const { // handle empty array if( ! block ) return std::vector<T> {}; // skip whitespace at the beginning while( *block != '\0' && std::isspace( *block ) ) ++block; Loading Loading @@ -250,8 +258,6 @@ protected: { verifyElement( elem, "DataArray" ); const char* block = elem->GetText(); if( ! block ) throw MeshReaderError( "XMLVTK", "the DataArray with Name=\"" + arrayName + "\" does not contain any data" ); const std::string type = getAttributeString( elem, "type" ); const std::string format = getAttributeString( elem, "format" ); if( format == "ascii" ) { Loading src/TNL/Meshes/Writers/VTUWriter.hpp +2 −1 Original line number Diff line number Diff line Loading @@ -479,7 +479,8 @@ VTUWriter< Mesh >::writeDataArray( const Array& array, throw std::logic_error("Unsupported numberOfComponents parameter: " + std::to_string(numberOfComponents)); // write DataArray header str << "<DataArray type=\"" << VTK::getTypeName( array[0] ) << "\""; using ValueType = decltype(array[0]); str << "<DataArray type=\"" << VTK::getTypeName( ValueType{} ) << "\""; str << " Name=\"" << name << "\""; if( numberOfComponents > 0 ) str << " NumberOfComponents=\"" << numberOfComponents << "\""; Loading Loading
src/TNL/Meshes/Readers/MeshReader.h +6 −0 Original line number Diff line number Diff line Loading @@ -154,6 +154,12 @@ public: if( meshType != "Meshes::Mesh" ) throw MeshReaderError( "MeshReader", "the file does not contain an unstructured mesh, it is " + meshType ); // skip empty mesh (the cell shape is indeterminate) if( NumberOfPoints == 0 && NumberOfCells == 0 ) { mesh = MeshType {}; return; } // check that the cell shape mathes const VTK::EntityShape meshCellShape = VTK::TopologyToEntityShape< typename MeshType::template EntityTraits< MeshType::getMeshDimension() >::EntityTopology >::shape; if( meshCellShape != cellShape ) Loading
src/TNL/Meshes/Readers/PVTUReader.h +15 −2 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ #include <experimental/filesystem> #include <TNL/MPI/Wrappers.h> #include <TNL/MPI/Utils.h> #include <TNL/Meshes/Readers/VTUReader.h> #include <TNL/Meshes/MeshDetails/layers/EntityTags/Traits.h> Loading Loading @@ -204,9 +205,21 @@ public: // reset arrays since they are not needed anymore this->pointTags = this->cellTags = pointGlobalIndices = cellGlobalIndices = {}; // check if we need to split the communicator const Index minCount = MPI::reduce( TNL::min( pointsCount, cellsCount ), MPI_MIN ); if( minCount == 0 ) { // split the communicator, remove the ranks which did not get a subdomain const int color = (pointsCount > 0 && cellsCount > 0) ? 0 : MPI_UNDEFINED; const MPI_Comm subgroup = MPI::Comm_split( group, color, 0 ); // set the communication group mesh.setCommunicationGroup( subgroup ); } else { // set the communication group mesh.setCommunicationGroup( group ); } } virtual VariantVector readPointData( std::string arrayName ) override Loading
src/TNL/Meshes/Readers/VTUReader.h +3 −0 Original line number Diff line number Diff line Loading @@ -89,6 +89,9 @@ class VTUReader // check array size if( array.size() != NumberOfCells ) throw MeshReaderError( "VTUReader", "size of the types data array does not match the NumberOfCells attribute" ); // check empty mesh if( array.size() == 0 ) return; cellShape = (VTK::EntityShape) array[0]; meshDimension = getEntityDimension( cellShape ); // TODO: check only entities of the same dimension (edges, faces and cells separately) Loading
src/TNL/Meshes/Readers/XMLVTK.h +8 −2 Original line number Diff line number Diff line Loading @@ -166,6 +166,10 @@ protected: VariantVector readAsciiBlock( const char* block ) const { // handle empty array if( ! block ) return std::vector<T> {}; // creating a copy of the block is rather costly, but so is ASCII parsing std::stringstream ss; ss << block; Loading @@ -187,6 +191,10 @@ protected: VariantVector readBinaryBlock( const char* block ) const { // handle empty array if( ! block ) return std::vector<T> {}; // skip whitespace at the beginning while( *block != '\0' && std::isspace( *block ) ) ++block; Loading Loading @@ -250,8 +258,6 @@ protected: { verifyElement( elem, "DataArray" ); const char* block = elem->GetText(); if( ! block ) throw MeshReaderError( "XMLVTK", "the DataArray with Name=\"" + arrayName + "\" does not contain any data" ); const std::string type = getAttributeString( elem, "type" ); const std::string format = getAttributeString( elem, "format" ); if( format == "ascii" ) { Loading
src/TNL/Meshes/Writers/VTUWriter.hpp +2 −1 Original line number Diff line number Diff line Loading @@ -479,7 +479,8 @@ VTUWriter< Mesh >::writeDataArray( const Array& array, throw std::logic_error("Unsupported numberOfComponents parameter: " + std::to_string(numberOfComponents)); // write DataArray header str << "<DataArray type=\"" << VTK::getTypeName( array[0] ) << "\""; using ValueType = decltype(array[0]); str << "<DataArray type=\"" << VTK::getTypeName( ValueType{} ) << "\""; str << " Name=\"" << name << "\""; if( numberOfComponents > 0 ) str << " NumberOfComponents=\"" << numberOfComponents << "\""; Loading