Commit 6723242c authored by Tomáš Oberhuber's avatar Tomáš Oberhuber
Browse files

Implementing save and load methods in arrays nad vectors.

Adding tnl-view tool.
parent 041bb8e1
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -93,7 +93,9 @@ class tnlSharedArray : public tnlObject
   void touch( IndexType2 touches = 1 ) const;

   //! Method for saving the object to a file as a binary data.
   virtual bool save( tnlFile& file ) const;
   bool save( tnlFile& file ) const;

   bool save( const tnlString& fileName ) const;

   protected:

+4 −0
Original line number Diff line number Diff line
@@ -46,6 +46,10 @@ class tnlSharedVector : public tnlSharedArray< Real, Device, Index >
   template< typename Vector >
   bool operator != ( const Vector& array ) const;

   bool save( tnlFile& file ) const;

   bool save( const tnlString& fileName ) const;

   Real max() const;

   Real min() const;
+1 −0
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ SET( headers )

set( tnl_implementation_SOURCES 
     ${tnl_implementation_core_SOURCES}
     ${tnl_implementation_mesh_SOURCES}
     ${tnl_implementation_solvers_SOURCES} 
     PARENT_SCOPE )

+11 −1
Original line number Diff line number Diff line
@@ -278,7 +278,7 @@ template< typename Element,
bool tnlSharedArray< Element, Device, Index > :: save( tnlFile& file ) const
{
   tnlAssert( this -> size != 0,
              cerr << "You try to save empty vector. Its name is " << this -> getName() );
              cerr << "You try to save empty array. Its name is " << this -> getName() );
   if( ! tnlObject :: save( file ) )
      return false;
   if( ! file. write( &this -> size, 1 ) )
@@ -292,6 +292,16 @@ bool tnlSharedArray< Element, Device, Index > :: save( tnlFile& file ) const
   return true;
};


template< typename Element,
          typename Device,
          typename Index >
bool tnlSharedArray< Element, Device, Index > :: save( const tnlString& fileName ) const
{
   return tnlObject :: save( fileName );
};


//}; // namespace implementation

#endif /* TNLSHAREDARRAY_H_IMPLEMENTATION */
+28 −0
Original line number Diff line number Diff line
@@ -70,6 +70,34 @@ bool tnlSharedVector< Real, Device, Index > :: operator != ( const Vector& vecto
   return tnlSharedArray< Real, Device, Index > :: operator == ( vector );
}

template< typename Element,
          typename Device,
          typename Index >
bool tnlSharedVector< Element, Device, Index > :: save( tnlFile& file ) const
{
   tnlAssert( this -> size != 0,
              cerr << "You try to save empty vector. Its name is " << this -> getName() );
   if( ! tnlObject :: save( file ) )
      return false;
   if( ! file. write( &this -> size, 1 ) )
      return false;
   if( ! file. write< Element, Device, Index >( this -> data, this -> size ) )
   {
      cerr << "I was not able to SAVE tnlSharedVector " << this -> getName()
           << " with size " << this -> getSize() << endl;
      return false;
   }
   return true;
};

template< typename Element,
          typename Device,
          typename Index >
bool tnlSharedVector< Element, Device, Index > :: save( const tnlString& fileName ) const
{
   return tnlObject :: save( fileName );
};

template< typename Real,
          typename Device,
          typename Index >
Loading