From 6221b196d399e138b7c80ec4853884821af2a3bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Klinkovsk=C3=BD?= <klinkjak@fjfi.cvut.cz> Date: Thu, 11 Apr 2019 13:51:05 +0200 Subject: [PATCH] Fixed methods save/load in Mesh --- .../DistributedMeshes/DistributedGridIO.h | 14 ++---- src/TNL/Meshes/DummyMesh.h | 10 ++-- src/TNL/Meshes/MeshDetails/MeshEntity_impl.h | 18 +++---- .../MeshLayers/BoundaryTags/Layer.h | 37 +++----------- .../MeshLayers/BoundaryTags/LayerFamily.h | 23 +++------ .../MeshDetails/MeshLayers/StorageLayer.h | 49 +++++-------------- .../MeshLayers/SubentityStorageLayer.h | 41 +++------------- .../MeshLayers/SuperentityStorageLayer.h | 41 +++------------- src/TNL/Meshes/MeshEntity.h | 8 +-- 9 files changed, 62 insertions(+), 179 deletions(-) diff --git a/src/TNL/Meshes/DistributedMeshes/DistributedGridIO.h b/src/TNL/Meshes/DistributedMeshes/DistributedGridIO.h index 49d7467e1f..38a7c04f0b 100644 --- a/src/TNL/Meshes/DistributedMeshes/DistributedGridIO.h +++ b/src/TNL/Meshes/DistributedMeshes/DistributedGridIO.h @@ -40,21 +40,17 @@ class DistributedGridIO< MeshFunctionType, Dummy > bool save(const String& fileName, MeshFunctionType &meshFunction) { return true; - }; + } bool load(const String& fileName, MeshFunctionType &meshFunction) { return true; - }; + } }; - - - - -} -} -} +} // namespace DistributedMeshes +} // namespace Meshes +} // namespace TNL //not clean logic of includes... #include <TNL/Meshes/DistributedMeshes/DistributedGridIO_MeshFunction.h> diff --git a/src/TNL/Meshes/DummyMesh.h b/src/TNL/Meshes/DummyMesh.h index 4bff7ce177..96cd7e3a42 100644 --- a/src/TNL/Meshes/DummyMesh.h +++ b/src/TNL/Meshes/DummyMesh.h @@ -11,6 +11,7 @@ #pragma once #include <TNL/String.h> +#include <TNL/File.h> #include <TNL/Devices/Host.h> namespace TNL { @@ -42,14 +43,13 @@ public: const GridFunction& f2, const typename GridFunction::RealType& p ) const { return 0.0; } - bool save( File& file ) const { return true; } + void save( File& file ) const {} - //! Method for restoring the object from a file - bool load( File& file ) { return true; } + void load( File& file ) {} - bool save( const String& fileName ) const { return true; } + void save( const String& fileName ) const {} - bool load( const String& fileName ) { return true; } + void load( const String& fileName ) {} bool writeMesh( const String& fileName, const String& format ) const { return true; } diff --git a/src/TNL/Meshes/MeshDetails/MeshEntity_impl.h b/src/TNL/Meshes/MeshDetails/MeshEntity_impl.h index 8a21168de1..8bdd40570a 100644 --- a/src/TNL/Meshes/MeshDetails/MeshEntity_impl.h +++ b/src/TNL/Meshes/MeshDetails/MeshEntity_impl.h @@ -100,23 +100,21 @@ getTypeVirtual() const template< typename MeshConfig, typename Device, typename EntityTopology > -bool +void MeshEntity< MeshConfig, Device, EntityTopology >:: save( File& file ) const { // no I/O for subentities and superentities - not loaded anyway - return true; } template< typename MeshConfig, typename Device, typename EntityTopology > -bool +void MeshEntity< MeshConfig, Device, EntityTopology >:: load( File& file ) { // no I/O for subentities and superentities - Mesh::load has to rebind pointers - return true; } template< typename MeshConfig, @@ -258,25 +256,21 @@ getTypeVirtual() const } template< typename MeshConfig, typename Device > -bool +void MeshEntity< MeshConfig, Device, Topologies::Vertex >:: save( File& file ) const { // no I/O for superentities - not loaded anyway - if( ! point.save( file ) ) - return false; - return true; + point.save( file ); } template< typename MeshConfig, typename Device > -bool +void MeshEntity< MeshConfig, Device, Topologies::Vertex >:: load( File& file ) { // no I/O for superentities - Mesh::load has to rebind pointers - if( ! point.load( file ) ) - return false; - return true; + point.load( file ); } template< typename MeshConfig, typename Device > diff --git a/src/TNL/Meshes/MeshDetails/MeshLayers/BoundaryTags/Layer.h b/src/TNL/Meshes/MeshDetails/MeshLayers/BoundaryTags/Layer.h index 99a0e61266..ebbee9fdd6 100644 --- a/src/TNL/Meshes/MeshDetails/MeshLayers/BoundaryTags/Layer.h +++ b/src/TNL/Meshes/MeshDetails/MeshLayers/BoundaryTags/Layer.h @@ -168,33 +168,15 @@ public: return interiorIndices[ i ]; } - bool save( File& file ) const + void save( File& file ) const { - try - { - boundaryTags.save( file ); - } - catch(...) - { - std::cerr << "Failed to save the boundary tags of the entities with dimension " << DimensionTag::value << "." << std::endl; - return false; - } - return true; + boundaryTags.save( file ); } - bool load( File& file ) + void load( File& file ) { - try - { - boundaryTags.load( file ); - } - catch(...) - { - std::cerr << "Failed to load the boundary tags of the entities with dimension " << DimensionTag::value << "." << std::endl; - return false; - } + boundaryTags.load( file ); updateBoundaryIndices( DimensionTag() ); - return true; } void print( std::ostream& str ) const @@ -257,16 +239,9 @@ protected: void getInteriorEntitiesCount( DimensionTag ) const {} void getInteriorEntityIndex( DimensionTag, const GlobalIndexType& i ) const {} - bool save( File& file ) const - { - return true; - } + void save( File& file ) const {} + void load( File& file ) {} - bool load( File& file ) - { - return true; - } - void print( std::ostream& str ) const {} bool operator==( const Layer& layer ) const diff --git a/src/TNL/Meshes/MeshDetails/MeshLayers/BoundaryTags/LayerFamily.h b/src/TNL/Meshes/MeshDetails/MeshLayers/BoundaryTags/LayerFamily.h index 44f6cdc445..d78ba1c523 100644 --- a/src/TNL/Meshes/MeshDetails/MeshLayers/BoundaryTags/LayerFamily.h +++ b/src/TNL/Meshes/MeshDetails/MeshLayers/BoundaryTags/LayerFamily.h @@ -77,16 +77,16 @@ protected: } - bool save( File& file ) const + void save( File& file ) const { - return LayerType::save( file ) && - BaseType::save( file ); + LayerType::save( file ); + BaseType::save( file ); } - bool load( File& file ) + void load( File& file ) { - return LayerType::load( file ) && - BaseType::load( file ); + LayerType::load( file ); + BaseType::load( file ); } void print( std::ostream& str ) const @@ -124,16 +124,9 @@ protected: template< typename Device_ > LayerInheritor& operator=( const LayerInheritor< MeshConfig, Device_, DimensionTag< MeshConfig::meshDimension + 1 > >& other ) { return *this; } - bool save( File& file ) const - { - return true; - } + void save( File& file ) const {} + void load( File& file ) {} - bool load( File& file ) - { - return true; - } - void print( std::ostream& str ) const {} bool operator==( const LayerInheritor& layer ) const diff --git a/src/TNL/Meshes/MeshDetails/MeshLayers/StorageLayer.h b/src/TNL/Meshes/MeshDetails/MeshLayers/StorageLayer.h index a9d25d8438..618934ce5b 100644 --- a/src/TNL/Meshes/MeshDetails/MeshLayers/StorageLayer.h +++ b/src/TNL/Meshes/MeshDetails/MeshLayers/StorageLayer.h @@ -139,38 +139,20 @@ public: return *this; } - bool save( File& file ) const + void save( File& file ) const { - try - { - SubentityStorageBaseType::save( file ); - SuperentityStorageBaseType::save( file ); - this->entities.save( file ); - BaseType::save( file ); - } - catch(...) - { - std::cerr << "Saving of the mesh entities with dimension " << DimensionTag::value << " failed." << std::endl; - return false; - } - return true; + SubentityStorageBaseType::save( file ); + SuperentityStorageBaseType::save( file ); + this->entities.save( file ); + BaseType::save( file ); } - bool load( File& file ) + void load( File& file ) { - try - { - SubentityStorageBaseType::load( file ); - SuperentityStorageBaseType::load( file ); - this->entities.load( file ); - BaseType::load( file ); - } - catch(...) - { - std::cerr << "Loading of the mesh entities with dimension " << DimensionTag::value << " failed." << std::endl; - return false; - } - return true; + SubentityStorageBaseType::load( file ); + SuperentityStorageBaseType::load( file ); + this->entities.load( file ); + BaseType::load( file ); } void print( std::ostream& str ) const @@ -276,15 +258,8 @@ protected: void getEntitiesCount() const {} void getEntity() const {} - bool save( File& file ) const - { - return true; - } - - bool load( File& file ) - { - return true; - } + void save( File& file ) const {} + void load( File& file ) {} void print( std::ostream& str ) const {} diff --git a/src/TNL/Meshes/MeshDetails/MeshLayers/SubentityStorageLayer.h b/src/TNL/Meshes/MeshDetails/MeshLayers/SubentityStorageLayer.h index cd4d9edf00..a598289e5d 100644 --- a/src/TNL/Meshes/MeshDetails/MeshLayers/SubentityStorageLayer.h +++ b/src/TNL/Meshes/MeshDetails/MeshLayers/SubentityStorageLayer.h @@ -105,34 +105,16 @@ protected: } - bool save( File& file ) const + void save( File& file ) const { - try - { - BaseType::save( file ); - this->storageNetwork.save( file ); - } - catch(...) - { - std::cerr << "Saving of the entity subentities layer with " << SubdimensionTag::value << " dimension failed." << std::endl; - return false; - } - return true; + BaseType::save( file ); + this->storageNetwork.save( file ); } - bool load( File& file ) + void load( File& file ) { - try - { - BaseType::load( file ); - this->storageNetwork.load( file ); - } - catch(...) - { - std::cerr << "Loading of the entity subentities layer with " << SubdimensionTag::value << " dimension failed." << std::endl; - return false; - } - return true; + BaseType::load( file ); + this->storageNetwork.load( file ); } void print( std::ostream& str ) const @@ -219,16 +201,9 @@ protected: return true; } - bool save( File& file ) const - { - return true; - } + void save( File& file ) const {} + void load( File& file ) {} - bool load( File& file ) - { - return true; - } - void getSubentityStorageNetwork( SubdimensionTag ) {} }; diff --git a/src/TNL/Meshes/MeshDetails/MeshLayers/SuperentityStorageLayer.h b/src/TNL/Meshes/MeshDetails/MeshLayers/SuperentityStorageLayer.h index 7e49a3155c..9cc1c5535b 100644 --- a/src/TNL/Meshes/MeshDetails/MeshLayers/SuperentityStorageLayer.h +++ b/src/TNL/Meshes/MeshDetails/MeshLayers/SuperentityStorageLayer.h @@ -107,34 +107,16 @@ protected: } - bool save( File& file ) const + void save( File& file ) const { - try - { - BaseType::save( file ); - this->storageNetwork.save( file ); - } - catch(...) - { - std::cerr << "Saving of the entity superentities layer with " << SuperdimensionTag::value << " dimension failed." << std::endl; - return false; - } - return true; + BaseType::save( file ); + this->storageNetwork.save( file ); } - bool load( File& file ) + void load( File& file ) { - try - { - BaseType::load( file ); - this->storageNetwork.load( file ); - } - catch(...) - { - std::cerr << "Loading of the entity superentities layer with " << SuperdimensionTag::value << " dimension failed." << std::endl; - return false; - } - return true; + BaseType::load( file ); + this->storageNetwork.load( file ); } void print( std::ostream& str ) const @@ -212,16 +194,9 @@ protected: return true; } - bool save( File& file ) const - { - return true; - } + void save( File& file ) const {} + void load( File& file ) {} - bool load( File& file ) - { - return true; - } - void getSuperentityStorageNetwork( SuperdimensionTag ) {} }; diff --git a/src/TNL/Meshes/MeshEntity.h b/src/TNL/Meshes/MeshEntity.h index 7c97686808..6e0970ade3 100644 --- a/src/TNL/Meshes/MeshEntity.h +++ b/src/TNL/Meshes/MeshEntity.h @@ -76,9 +76,9 @@ class MeshEntity String getTypeVirtual() const; - bool save( File& file ) const; + void save( File& file ) const; - bool load( File& file ); + void load( File& file ); void print( std::ostream& str ) const; @@ -170,9 +170,9 @@ class MeshEntity< MeshConfig, Device, Topologies::Vertex > String getTypeVirtual() const; - bool save( File& file ) const; + void save( File& file ) const; - bool load( File& file ); + void load( File& file ); void print( std::ostream& str ) const; -- GitLab