diff --git a/src/Python/pytnl/tnl/Object.cpp b/src/Python/pytnl/tnl/Object.cpp index 56b0f54e523df5201a3a14261d3ab712f1ea11da..8c7569f2b3d80b75b954b6642afdb132dbc0b48a 100644 --- a/src/Python/pytnl/tnl/Object.cpp +++ b/src/Python/pytnl/tnl/Object.cpp @@ -12,7 +12,6 @@ void export_Object( py::module & m ) // TODO: make it abstract class in Python .def("save", (void (TNL::Object::*)(const TNL::String &) const) &TNL::Object::save) .def("load", (void (TNL::Object::*)(const TNL::String &)) &TNL::Object::load) - .def("boundLoad", (void (TNL::Object::*)(const TNL::String &)) &TNL::Object::boundLoad) // FIXME: why does it not work? // .def("save", py::overload_cast<TNL::File>(&TNL::Object::save, py::const_)) // .def("load", py::overload_cast<TNL::File>(&TNL::Object::load)) diff --git a/src/TNL/Containers/Array.h b/src/TNL/Containers/Array.h index caeb88dd03e5ca93566baa05aaaf5f68cfff6f34..0c0e6c0cc82b2f9b6bdfe51716a3fd69463f27c6 100644 --- a/src/TNL/Containers/Array.h +++ b/src/TNL/Containers/Array.h @@ -537,24 +537,10 @@ class Array : public Object */ void load( File& file ); - /** - * \brief This method loads data without reallocation. - * - * This is useful for loading data into shared arrays. - * If the array was not initialize yet, common load is - * performed. Otherwise, the array size must fit with - * the size of array being loaded. - * - * This method is deprecated - use ArrayView instead. - */ - void boundLoad( File& file ); - using Object::save; using Object::load; - using Object::boundLoad; - /** \brief Basic destructor. */ ~Array(); diff --git a/src/TNL/Containers/Array.hpp b/src/TNL/Containers/Array.hpp index d0cbf39651fce64c2d6013c931d43633b53eced3..cde3b782ebceabbac4aca3d5d3168c55a408940c 100644 --- a/src/TNL/Containers/Array.hpp +++ b/src/TNL/Containers/Array.hpp @@ -677,27 +677,6 @@ load( File& file ) Algorithms::ArrayIO< Value, Device, Index >::load( file, this->data, this->size ); } -template< typename Value, - typename Device, - typename Index > -void -Array< Value, Device, Index >:: -boundLoad( File& file ) -{ - Object::load( file ); - Index _size; - file.load( &_size ); - if( _size < 0 ) - throw Exceptions::FileDeserializationError( file.getFileName(), "invalid array size: " + std::to_string(_size) ); - if( this->getSize() != 0 ) - { - if( this->getSize() != _size ) - throw Exceptions::FileDeserializationError( file.getFileName(), "invalid array size: " + std::to_string(_size) + " (expected " + std::to_string( this->getSize() ) + ")." ); - } - else setSize( _size ); - Algorithms::ArrayIO< Value, Device, Index >::load( file, this->data, this->size ); -} - template< typename Value, typename Device, typename Index > diff --git a/src/TNL/Containers/DistributedArray.h b/src/TNL/Containers/DistributedArray.h index edae7ccd03e94aa67df8f12eb11b24650d18f6bc..db160a1efbdfc2e90d4e54554713031fbf36d717 100644 --- a/src/TNL/Containers/DistributedArray.h +++ b/src/TNL/Containers/DistributedArray.h @@ -138,7 +138,7 @@ public: // Returns true iff non-zero size is set operator bool() const; - // TODO: serialization (save, load, boundLoad) + // TODO: serialization (save, load) protected: LocalRangeType localRange; @@ -150,7 +150,6 @@ private: // TODO: disabled until they are implemented using Object::save; using Object::load; - using Object::boundLoad; }; } // namespace Containers diff --git a/src/TNL/Functions/MeshFunction.h b/src/TNL/Functions/MeshFunction.h index 9e6f6f571919beae6d1ecbeb151220c4dfb6691e..c9eb66ac53e60a23f895fa62a0098b68bde943f8 100644 --- a/src/TNL/Functions/MeshFunction.h +++ b/src/TNL/Functions/MeshFunction.h @@ -152,6 +152,8 @@ class MeshFunction : void boundLoad( File& file ); + void boundLoad( const String& fileName ); + bool write( const String& fileName, const String& format = "vtk", const double& scale = 1.0 ) const; @@ -160,8 +162,6 @@ class MeshFunction : using Object::load; - using Object::boundLoad; - DistributedMeshSynchronizerType& getSynchronizer() { return this->synchronizer; diff --git a/src/TNL/Functions/MeshFunction_impl.h b/src/TNL/Functions/MeshFunction_impl.h index 40844062bca996675fa3dca7d8a89227d88c7744..d0efb9f38798a72392888d9e1c213ae51ff08a2d 100644 --- a/src/TNL/Functions/MeshFunction_impl.h +++ b/src/TNL/Functions/MeshFunction_impl.h @@ -497,7 +497,19 @@ MeshFunction< Mesh, MeshEntityDimension, Real >:: boundLoad( File& file ) { Object::load( file ); - this->data.boundLoad( file ); + this->data.getView().load( file ); +} + +template< typename Mesh, + int MeshEntityDimension, + typename Real > +void +MeshFunction< Mesh, MeshEntityDimension, Real >:: +boundLoad( const String& fileName ) +{ + File file; + file.open( fileName, std::ios_base::in ); + this->boundLoad( file ); } template< typename Mesh, diff --git a/src/TNL/Functions/VectorField.h b/src/TNL/Functions/VectorField.h index 87d86d62b6b3029637ee2cbeb45d7f4bccc8998e..4db601c9f4ccd9c003c46f41a112501953a73a76 100644 --- a/src/TNL/Functions/VectorField.h +++ b/src/TNL/Functions/VectorField.h @@ -282,14 +282,21 @@ class VectorField< Size, MeshFunction< Mesh, MeshEntityDimension, Real > > for( int i = 0; i < Size; i++ ) vectorField[ i ]->load( file ); } - + void boundLoad( File& file ) { Object::load( file ); for( int i = 0; i < Size; i++ ) vectorField[ i ]->boundLoad( file ); } - + + void boundLoad( const String& fileName ) + { + File file; + file.open( fileName, std::ios_base::in ); + this->boundLoad( file ); + } + bool write( const String& fileName, const String& format = "vtk", const double& scale = 1.0 ) const @@ -316,8 +323,6 @@ class VectorField< Size, MeshFunction< Mesh, MeshEntityDimension, Real > > using Object::load; - using Object::boundLoad; - protected: Containers::StaticArray< Size, FunctionPointer > vectorField; diff --git a/src/TNL/Matrices/DistributedMatrix.h b/src/TNL/Matrices/DistributedMatrix.h index dd76804cf7fa815a00c565ff3c61ca5f496ccaf6..c200663dc3473a03d21ab7d0b61944de3756a12b 100644 --- a/src/TNL/Matrices/DistributedMatrix.h +++ b/src/TNL/Matrices/DistributedMatrix.h @@ -177,7 +177,6 @@ private: // TODO: disabled until they are implemented using Object::save; using Object::load; - using Object::boundLoad; }; } // namespace Matrices diff --git a/src/TNL/Object.h b/src/TNL/Object.h index 4dd6d658e39968981098be5534f3f3ebb2fade02..8e7e567a9c572963dfe74742b7b0ec3fc62da97a 100644 --- a/src/TNL/Object.h +++ b/src/TNL/Object.h @@ -104,15 +104,6 @@ class Object */ virtual void load( File& file ); - /** - * \brief Method for restoring the object from a file. - * - * Throws \ref Exceptions::FileDeserializationError if the object cannot be loaded. - * - * \param file Name of file object. - */ - virtual void boundLoad( File& file ); - /** * \brief Method for saving the object to a file as a binary data. * @@ -131,15 +122,6 @@ class Object */ void load( const String& fileName ); - /** - * \brief Method for restoring the object from a file. - * - * Throws \ref Exceptions::FileDeserializationError if the object cannot be loaded. - * - * \param fileName String defining the name of a file. - */ - void boundLoad( const String& fileName ); - /** * \brief Destructor. * diff --git a/src/TNL/Object.hpp b/src/TNL/Object.hpp index f2bad7cf3a55b4a00ca059f0f8ead786a629f63b..697e738fdbcf2cc21b86135c0b41e7cc99c0e648 100644 --- a/src/TNL/Object.hpp +++ b/src/TNL/Object.hpp @@ -53,11 +53,6 @@ inline void Object::load( File& file ) throw Exceptions::FileDeserializationError( file.getFileName(), "object type does not match (expected " + this->getSerializationTypeVirtual() + ", found " + objectType + ")." ); } -inline void Object::boundLoad( File& file ) -{ - this->load( file ); -} - inline void Object::save( const String& fileName ) const { File file; @@ -72,13 +67,6 @@ inline void Object::load( const String& fileName ) this->load( file ); } -inline void Object::boundLoad( const String& fileName ) -{ - File file; - file.open( fileName, std::ios_base::in ); - this->boundLoad( file ); -} - inline String getObjectType( File& file ) { char mn[ 10 ]; diff --git a/src/UnitTests/Containers/ArrayTest.h b/src/UnitTests/Containers/ArrayTest.h index 2d4283221dd28254e48d0d8f748c168c013cb194..527f6e9e13b35ddc25907d4bb1e662e9f5ec7282 100644 --- a/src/UnitTests/Containers/ArrayTest.h +++ b/src/UnitTests/Containers/ArrayTest.h @@ -489,7 +489,7 @@ TYPED_TEST( ArrayTest, SaveAndLoad ) EXPECT_EQ( std::remove( "test-file.tnl" ), 0 ); } -TYPED_TEST( ArrayTest, boundLoad ) +TYPED_TEST( ArrayTest, LoadViaView ) { using ArrayType = typename TestFixture::ArrayType; @@ -511,11 +511,7 @@ TYPED_TEST( ArrayTest, boundLoad ) ArrayType z( 50 ); ASSERT_NO_THROW( file.open( "test-file.tnl", std::ios_base::in ) ); - EXPECT_ANY_THROW( z.boundLoad( file ) ); - - v.reset(); - ASSERT_NO_THROW( file.open( "test-file.tnl", std::ios_base::in ) ); - EXPECT_NO_THROW( v.boundLoad( file ) ); + EXPECT_ANY_THROW( z.getView().load( file ) ); EXPECT_EQ( std::remove( "test-file.tnl" ), 0 ); }