From 00f9124b24d9129791c409e9064fcfdde4fe68ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Kl=C3=B6fkorn?= <robertk@dune-project.org> Date: Mon, 24 Jan 2005 12:50:02 +0000 Subject: [PATCH] write/read moved to GrapeDataIO. [[Imported from SVN: r1392]] --- fem/common/discretefunction.cc | 89 ---------------------------------- fem/common/discretefunction.hh | 40 --------------- 2 files changed, 129 deletions(-) diff --git a/fem/common/discretefunction.cc b/fem/common/discretefunction.cc index 2f5605008..15e372402 100644 --- a/fem/common/discretefunction.cc +++ b/fem/common/discretefunction.cc @@ -193,95 +193,6 @@ namespace Dune return *this; } - template<class DiscreteFunctionSpaceType, class DofIteratorImp, - template <class,class> class LocalFunctionIteratorImp, class DiscreteFunctionImp > - inline bool DiscreteFunctionDefault<DiscreteFunctionSpaceType , - DofIteratorImp , LocalFunctionIteratorImp,DiscreteFunctionImp >:: - write(const FileFormatType ftype, const char *filename, int timestep, int - precision ) - { - { - enum { n = DiscreteFunctionSpaceType::DimDomain }; - enum { m = DiscreteFunctionSpaceType::DimRange }; - std::fstream file( filename , std::ios::out ); - StringType d = typeIdentifier<DomainFieldType>(); - StringType r = typeIdentifier<RangeFieldType>(); - - file << "DomainField: " << d << std::endl; - file << "RangeField: " << r << std::endl; - file << "Dim_Domain: " << n << std::endl; - file << "Dim_Range: " << m << std::endl; - file << "Space: " << this->functionSpace_.type() << std::endl; - file << "Format: " << ftype << std::endl; - file << "Precision: " << precision << std::endl; - file << "Polynom_order: " << this->functionSpace_.polynomOrder() << std::endl; - file.close(); - } - - const char * path = 0; - const char * fn = genFilename(path,filename,timestep,precision); - - if(ftype == xdr) - return asImp().write_xdr(fn); - if(ftype == ascii) - return asImp().write_ascii(fn); - if(ftype == pgm) - return asImp().write_pgm(fn); - - return false; - } - - template<class DiscreteFunctionSpaceType, class DofIteratorImp, - template <class,class> class LocalFunctionIteratorImp, class DiscreteFunctionImp > - inline bool DiscreteFunctionDefault<DiscreteFunctionSpaceType , - DofIteratorImp , LocalFunctionIteratorImp,DiscreteFunctionImp >:: - read(const char *filename, int timestep) - { - enum { tn = DiscreteFunctionSpaceType::DimDomain }; - enum { tm = DiscreteFunctionSpaceType::DimRange }; - - int n,m; - std::basic_string <char> r,d; - std::basic_string <char> tr (typeIdentifier<RangeFieldType>()); - std::basic_string <char> td (typeIdentifier<DomainFieldType>()); - - readParameter(filename,"DomainField",d,false); - readParameter(filename,"RangeField",r,false); - readParameter(filename,"Dim_Domain",n,false); - readParameter(filename,"Dim_Range",m,false); - int space; - readParameter(filename,"Space",space,false); - int filetype; - readParameter(filename,"Format",filetype,false); - FileFormatType ftype = static_cast<FileFormatType> (filetype); - int precision; - readParameter(filename,"Precision",precision,false); - - if((d != td) || (r != tr) || (n != tn) || (m != tm) ) - { - std::cerr << d << " | " << td << " DomainField in read!\n"; - std::cerr << r << " | " << tr << " RangeField in read!\n"; - std::cerr << n << " | " << tn << " in read!\n"; - std::cerr << m << " | " << tm << " in read!\n"; - std::cerr << "Can not initialize DiscreteFunction with wrong FunctionSpace! \n"; - abort(); - } - - const char * path = 0; - const char * fn = genFilename(path,filename,timestep,precision); - - if(ftype == xdr) - return asImp().read_xdr(fn); - if(ftype == ascii) - return asImp().read_ascii(fn); - if(ftype == pgm) - return asImp().read_pgm(fn); - - std::cerr << ftype << " FileFormatType not supported at the moment! in file " << __FILE__ << " line " << __LINE__ << "\n"; - abort(); - - return false; - }; } // end namespace Dune diff --git a/fem/common/discretefunction.hh b/fem/common/discretefunction.hh index 47058e700..bc23874e8 100644 --- a/fem/common/discretefunction.hh +++ b/fem/common/discretefunction.hh @@ -22,38 +22,6 @@ namespace Dune { @{ */ - typedef std::basic_string <char> StringType; - - /** \brief ??? - * \todo Please doc me! */ - template <typename T> - StringType typeIdentifier () - { - StringType tmp = "unknown"; - return tmp; - }; - - template <> - StringType typeIdentifier<float> () - { - StringType tmp = "float"; - return tmp; - }; - - template <> - StringType typeIdentifier<int> () - { - StringType tmp = "int"; - return tmp; - }; - - template <> - StringType typeIdentifier<double> () - { - StringType tmp = "double"; - return tmp; - }; - //************************************************************************ // @@ -231,14 +199,6 @@ namespace Dune { Vector<RangeFieldType> & add(const Vector<RangeFieldType> &g , RangeFieldType scalar ); - //! write disc func information file and write dofs to file+timestep - //! this method use the write method of the implementation of the - //! discrete function - bool write(const FileFormatType ftype, const char *filename, int timestep, int precision = 6); - - //! same as write only read - bool read(const char *filename, int timestep); - private: // Barton-Nackman trick DiscreteFunctionImp &asImp() -- GitLab