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

write/read Methods removed from GridDefault.

DefaultConstIterators removed.

[[Imported from SVN: r1389]]
parent f1a766e4
Branches
Tags
No related merge requests found
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifndef __DUNE_CONSTGRIDITERATORS_HH__
#define __DUNE_CONSTGRIDITERATORS_HH__
#include <string>
#include <dune/common/matvec.hh>
#include <dune/common/exceptions.hh>
namespace Dune {
/** @defgroup GridCommon Grid Interface
These Iterators define wrapper for const versions
of all interface grid iterators.
@{
*/
//************************************************************************
// C O N S T L E V E L I T E R A T O R
//************************************************************************
/** \brief Enables iteration over all entities of a given codimension and level of a grid.
*/
template <class LevelIteratorImp>
class ConstLevelIteratorWrapper
{
typedef ConstLevelIteratorWrapper<LevelIteratorImp> ConstLevelIteratorType;
public:
struct Traits
{
/** \todo Please doc me! */
typedef typename LevelIteratorImp:: Traits :: CoordType CoordType;
/** \todo Please doc me! */
typedef const typename LevelIteratorImp :: Traits :: Entity Entity;
//! Please doc me!
typedef const typename LevelIteratorImp :: Traits :: LevelIterator LevelIterator;
//! Please doc me!
typedef const typename LevelIteratorImp :: Traits :: InteriorLevelIterator InteriorLevelIterator;
//! Please doc me!
typedef const typename LevelIteratorImp :: Traits :: InteriorBorderLevelIterator InteriorBorderLevelIterator;
//! Please doc me!
typedef const typename LevelIteratorImp :: Traits :: OverlapLevelIterator OverlapLevelIterator;
//! Please doc me!
typedef const typename LevelIteratorImp :: Traits :: OverlapFrontLevelIterator OverlapFrontLevelIterator;
//! Please doc me!
typedef const typename LevelIteratorImp :: Traits :: GhostLevelIterator GhostLevelIterator;
};
//! know your own codimension
enum { codimension = LevelIteratorImp :: codimension };
//! know your own dimension
enum { dimension = LevelIteratorImp :: dimension };
//! know your own dimension of world
enum { dimensionworld = LevelIteratorImp :: dimensionworld };
//! copy the normal LevelIterator, this is ok because the normal
//! interface method lbegin uses copy aswell
ConstLevelIteratorWrapper ( LevelIteratorImp & lit);
//! prefix increment
ConstLevelIteratorType & operator ++ ();
//! equality
bool operator== (const ConstLevelIteratorType & i) const;
//! inequality
bool operator!= (const ConstLevelIteratorType & i) const;
//! dereferencing
typename Traits :: Entity & operator*() const;
//! arrow
typename Traits :: Entity * operator->() const;
//! ask for level of entity
int level () const;
protected:
LevelIteratorImp it_;
};
template <class LevelIteratorImp>
inline ConstLevelIteratorWrapper<LevelIteratorImp> ::
ConstLevelIteratorWrapper( LevelIteratorImp & lit ) : it_ ( lit ) {}
template <class LevelIteratorImp>
inline ConstLevelIteratorWrapper<LevelIteratorImp> &
ConstLevelIteratorWrapper<LevelIteratorImp> :: operator++()
{
++it_;
return (*this);
}
template <class LevelIteratorImp>
inline bool ConstLevelIteratorWrapper<LevelIteratorImp> ::
operator == ( const ConstLevelIteratorWrapper<LevelIteratorImp> & i) const
{
return it_ == i.it_;
}
template <class LevelIteratorImp>
inline bool ConstLevelIteratorWrapper<LevelIteratorImp> ::
operator != ( const ConstLevelIteratorWrapper<LevelIteratorImp> & i) const
{
return it_ != i.it_;
}
template <class LevelIteratorImp>
inline typename ConstLevelIteratorWrapper<LevelIteratorImp> :: Traits :: Entity &
ConstLevelIteratorWrapper<LevelIteratorImp> :: operator * () const
{
return *it_;
}
template <class LevelIteratorImp>
inline typename ConstLevelIteratorWrapper<LevelIteratorImp> :: Traits :: Entity *
ConstLevelIteratorWrapper<LevelIteratorImp> :: operator -> () const
{
return it_.operator -> ();
}
template <class LevelIteratorImp>
inline int ConstLevelIteratorWrapper<LevelIteratorImp> ::
level () const
{
return it_.level();
}
/** @} */
}
#endif
......@@ -1191,98 +1191,6 @@ namespace Dune {
};
*/
template< int dim, int dimworld, class ct, template<int,int> class GridImp,
template<int,int,int,PartitionIteratorType> class LevelIteratorImp, template<int,int,int> class EntityImp>
inline bool GridDefault<dim,dimworld,ct,GridImp,LevelIteratorImp,EntityImp>::
write ( const FileFormatType ftype, const char * filename , double time, int timestep, int precision)
{
const char *path = 0;
std::fstream file (filename,std::ios::out);
file << "Grid: " << transformToGridName(asImp().type()) << std::endl;
file << "Format: " << ftype << std::endl;
file << "Precision: " << precision << std::endl;
const char * fn = genFilename(path,filename,timestep,precision);
file.close();
switch (ftype)
{
case xdr : return asImp().template writeGrid<xdr>(fn,time);
case ascii : return asImp().template writeGrid<ascii>(fn,time);
default :
{
std::cerr << ftype << " FileFormatType not supported at the moment! " << __FILE__ << __LINE__ << "\n";
assert(false);
abort();
return false;
}
}
return false;
} // end grid2File
template< int dim, int dimworld, class ct, template<int,int> class GridImp,
template<int,int,int,PartitionIteratorType> class LevelIteratorImp, template<int,int,int> class EntityImp>
inline bool GridDefault<dim,dimworld,ct,GridImp,LevelIteratorImp,EntityImp>::
read ( const char * filename , double & time, int timestep)
{
const char * fn;
int helpType;
char gridname [1024];
readParameter(filename,"Grid",gridname);
std::string gname (gridname);
if(transformToGridName(asImp().type()) != gname)
{
std::cerr << "\nERROR: " << transformToGridName(asImp().type()) << " tries to read " << gname << " file. \n";
abort();
}
readParameter(filename,"Format",helpType);
FileFormatType ftype = (FileFormatType) helpType;
int precision = 6;
readParameter(filename,"Precision",precision);
const char *path = 0;
fn = genFilename(path,filename,timestep,precision);
printf("Read file: filename = `%s' \n",fn);
switch (ftype)
{
case xdr : return asImp().template readGrid<xdr> (fn,time);
case ascii : return asImp().template readGrid<ascii>(fn,time);
default :
{
std::cerr << ftype << " FileFormatType not supported at the moment! \n";
assert(false);
abort();
return false;
}
}
return false;
} // end file2Grid
template< int dim, int dimworld, class ct, template<int,int> class GridImp,
template<int,int,int,PartitionIteratorType> class LevelIteratorImp, template<int,int,int> class EntityImp>
template <FileFormatType ftype>
inline bool GridDefault<dim,dimworld,ct,GridImp,LevelIteratorImp,EntityImp>::
writeGrid ( const char * filename , double time )
{
std::cerr << "WARNING: writeGrid not implemented! \n";
return false;
}
template< int dim, int dimworld, class ct, template<int,int> class GridImp,
template<int,int,int,PartitionIteratorType> class LevelIteratorImp, template<int,int,int> class EntityImp>
template <FileFormatType ftype>
inline bool GridDefault<dim,dimworld,ct,GridImp,LevelIteratorImp,EntityImp>::
readGrid ( const char * filename , double & time )
{
std::cerr << "WARNING: readGrid not implemented! \n";
return false;
}
//************************************************************************
// G R I D Default :: LeafIterator
//************************************************************************
......
......@@ -1437,25 +1437,6 @@ namespace Dune {
//! clean up some markers
void postAdapt() {}
/** Write Grid with GridType file filename and time
*
* This method uses the Grid Interface Method writeGrid
* to actually write the grid, within this method the real file name is
* generated out of filename and timestep
*/
bool write (const FileFormatType ftype, const char * fnprefix , double time=0.0, int timestep=0, int precision = 6);
//! get Grid from file with time and timestep , return true if ok
bool read ( const char * fnprefix , double & time , int timestep);
//! write Grid to file filename and store time
template <FileFormatType ftype>
bool writeGrid ( const char * filename , double time );
//! read Grid from file filename and also read time of grid
template <FileFormatType ftype>
bool readGrid ( const char * filename , double &time );
protected:
//! Barton-Nackman trick
GridImp<dim,dimworld>& asImp () {return static_cast<GridImp<dim,dimworld>&>(*this);}
......@@ -1591,6 +1572,5 @@ namespace Dune {
}
#include "grid.cc"
#include "constgriditerators.hh"
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment