Skip to content
Snippets Groups Projects
Commit 4b9c4af3 authored by Robert Klöfkorn's avatar Robert Klöfkorn
Browse files

Changed read and write default method of discrete functions.

[[Imported from SVN: r246]]
parent 2cb85c28
No related branches found
No related tags found
No related merge requests found
......@@ -251,10 +251,9 @@ namespace Dune
template<class DiscreteFunctionSpaceType, class DofIteratorImp,
template <class,class> class LocalFunctionIteratorImp, class DiscreteFunctionImp >
template <FileFormatType ftype>
inline bool DiscreteFunctionDefault<DiscreteFunctionSpaceType ,
DofIteratorImp , LocalFunctionIteratorImp,DiscreteFunctionImp >::
write(const char *filename, int timestep)
write(const FileFormatType ftype, const char *filename, int timestep)
{
{
enum { n = DiscreteFunctionSpaceType::DimDomain };
......@@ -279,38 +278,34 @@ namespace Dune
template<class DiscreteFunctionSpaceType, class DofIteratorImp,
template <class,class> class LocalFunctionIteratorImp, class DiscreteFunctionImp >
template <FileFormatType ftype>
inline bool DiscreteFunctionDefault<DiscreteFunctionSpaceType ,
DofIteratorImp , LocalFunctionIteratorImp,DiscreteFunctionImp >::
read(const char *filename, int timestep)
{
enum { tn = DiscreteFunctionSpaceType::DimDomain };
enum { tm = DiscreteFunctionSpaceType::DimRange };
std::fstream file( filename , std::ios::in );
int n,m;
std::basic_string <char> r,d;
std::basic_string <char> tr (typeIdentifier<RangeFieldType>());
std::basic_string <char> td (typeIdentifier<DomainFieldType>());
file >> d;
file >> r;
file >> n >> m;
int id,type;
file >> id >> type;
FileFormatType ftype = static_cast<FileFormatType> (type);
if((d != td) || (r != tr) || (n != tn) || (m != tm) )
{
enum { tn = DiscreteFunctionSpaceType::DimDomain };
enum { tm = DiscreteFunctionSpaceType::DimRange };
std::fstream file( filename , std::ios::in );
int n,m;
std::basic_string <char> r,d;
std::basic_string <char> tr (typeIdentifier<RangeFieldType>());
std::basic_string <char> td (typeIdentifier<DomainFieldType>());
file >> d;
file >> r;
file >> n >> m;
int id,type;
file >> id >> type;
FileFormatType ft = static_cast<FileFormatType> (type);
if((d != td) || (r != tr) || (n != tn) || (m != tm) || (ft != ftype) )
{
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 << ftype << " Wrong FileFormat! \n";
std::cerr << "Can not initialize DiscreteFunction with wrong FunctionSpace! \n";
abort();
}
file.close();
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();
}
file.close();
if(ftype == xdr)
return asImp().read_xdr(filename,timestep);
......@@ -318,6 +313,10 @@ namespace Dune
return asImp().read_ascii(filename,timestep);
if(ftype == pgm)
return asImp().read_pgm(filename,timestep);
std::cerr << ftype << " FileFormatType not supported at the moment! \n";
abort();
return false;
};
......
......@@ -217,11 +217,9 @@ namespace Dune {
//! write disc func information file and write dofs to file+timestep
//! this method use the write method of the implementation of the
//! discrete function
template <FileFormatType ftype>
bool write(const char *filename, int timestep);
bool write(const FileFormatType ftype, const char *filename, int timestep);
//! same as write only read
template <FileFormatType ftype>
bool read(const char *filename, int timestep);
private:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment