Skip to content
Snippets Groups Projects
Commit 93d96cc9 authored by Adrian Burri's avatar Adrian Burri
Browse files

Final merging from space-refactoring branch

[[Imported from SVN: r2667]]
parent 882514eb
No related branches found
No related tags found
No related merge requests found
# $Id$
SUBDIRS = common dgspace discfuncarray feop lagrangebase norms \
operator transfer space discretefunction
......
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifndef DUNE_DISCRETEFUNCTION_HH
#define DUNE_DISCRETEFUNCTION_HH
#include <string>
#include <dune/grid/common/grid.hh>
#include <dune/common/function.hh>
#include <dune/common/functionspace.hh>
......@@ -11,6 +14,7 @@
namespace Dune {
/** @defgroup DiscreteFunction DiscreteFunction
@ingroup FunctionCommon
The DiscreteFunction is responsible for the dof storage. This can be
......@@ -82,7 +86,12 @@ namespace Dune {
DiscreteFunctionInterface (const DiscreteFunctionSpaceType& f)
: FunctionType ( f ) {}
//! Continuous data?
//! Name of the discrete function
std::string name() const {
return asImp().name();
}
//! Continuous data
bool continuous() const {
return asImp().continuous();
}
......@@ -189,7 +198,6 @@ namespace Dune {
//! Type of the local function
typedef typename DiscreteFunctionTraits::LocalFunctionType LocalFunctionType;
//! Type of the dof iterator
typedef typename DiscreteFunctionTraits::DofIteratorType DofIteratorType;
......
......@@ -139,10 +139,16 @@ namespace Dune {
return asImp().getBaseFunctionSet( en );
}
//! return the corresponding Grid
const GridType& grid () { return asImp().grid(); }
//! Is space continuous?
bool continuous() const { return asImp().continuous(); }
//! return number of degrees of freedom for specified grid
//! Return the corresponding Grid (const version)
const GridType& grid() const { return asImp().grid() }
//! Return the corresponding Grid (const version)
GridType& grid() { return asImp().grid() }
//! Return number of degrees of freedom for specified grid
//! which can also be the leaflevel and furthermore
//! this depends also on the base function set
int size () const { return asImp().size(); }
......
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifndef __DUNE_DFADAPT_HH__
#define __DUNE_DFADAPT_HH__
#ifndef DUNE_DFADAPT_HH
#define DUNE_DFADAPT_HH
#include "dune/common/array.hh"
#include "common/discretefunction.hh"
......@@ -15,6 +15,7 @@
namespace Dune {
template <class DiscreteFunctionSpaceImp> class LocalFunctionAdapt;
template <class DofType, class DofArrayType> class DofIteratorAdapt;
template <class DiscreteFunctionSpaceImp> class DFAdapt;
......@@ -80,6 +81,8 @@ namespace Dune {
/** \brief For ISTL-compatibility */
typedef FieldVector<DofType,1> block_type;
public:
//! Constructor make Discrete Function
DFAdapt(DiscreteFunctionSpaceType& f);
......@@ -100,6 +103,9 @@ namespace Dune {
//! return object of type LocalFunctionType
LocalFunctionAdapt<DiscreteFunctionSpaceType> newLocalFunction ( );
template <class EntityType>
LocalFunctionAdapt<DiscreteFunctionSpaceType> localFunction(EntityType& en);
//! update LocalFunction to given Entity en
template <class EntityType>
void localFunction ( const EntityType &en,
......
......@@ -87,6 +87,14 @@ namespace Dune
//*************************************************************************
// Interface Methods
//*************************************************************************
template<class DiscreteFunctionSpaceType > template <class EntityType>
inline LocalFunctionAdapt<DiscreteFunctionSpaceType>
DFAdapt< DiscreteFunctionSpaceType >::localFunction(EntityType& en) {
return LocalFunctionAdapt<DiscreteFunctionSpaceType> (this->functionSpace_,
dofVec_,
en);
}
template<class DiscreteFunctionSpaceType > template <class EntityType>
inline void
DFAdapt< DiscreteFunctionSpaceType >::
......@@ -385,6 +393,7 @@ namespace Dune
: fSpace_ ( f ), dofVec_ ( dofVec )
, uniform_(true), init_(false) {}
template<class DiscreteFunctionSpaceType >
inline LocalFunctionAdapt < DiscreteFunctionSpaceType >::~LocalFunctionAdapt()
{}
......
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
namespace Dune {
template <class DiscreteFunctionSpaceImp>
AdaptiveFunctionImplementation<DiscreteFunctionSpaceImp>::
AdaptiveFunctionImplementation(std::string name,
DiscreteFunctionSpaceType& spc) :
spc_(spc),
memObj_(spc.signIn(*this))
dofVec_(memObj_.getArray()),
name_(name)
{}
template <class DiscreteFunctionSpaceImp>
AdaptiveFunctionImplementation<DiscreteFunctionSpaceImp>::
~AdaptiveFunctionImplementation() {
bool removed = spc_.signOut(*this);
assert(removed);
}
template <class DiscreteFunctionSpaceImp>
AdaptiveFunctionImplementation<DiscreteFunctionSpaceImp>::DofIterator
AdaptiveFunctionImplementation<DiscreteFunctionSpaceImp>::dbegin() {
return dofVec_.dbegin();
}
template <class DiscreteFunctionSpaceImp>
AdaptiveFunctionImplementation<DiscreteFunctionSpaceImp>::DofIterator
AdaptiveFunctionImplementation<DiscreteFunctionSpaceImp>::dend() {
return dofVec_.dend();
}
template <class DiscreteFunctionSpaceImp>
AdaptiveFunctionImplementation<DiscreteFunctionSpaceImp>::ConstDofIteratorType
AdaptiveFunctionImplementation<DiscreteFunctionSpaceImp>::dbegin() const {
return dofVec_.dbegin();
}
template <class DiscreteFunctionSpaceImp>
AdaptiveFunctionImplementation<DiscreteFunctionSpaceImp>::ConstDofIteratorType
AdaptiveFunctionImplementation<DiscreteFunctionSpaceImp>::dend() const {
return dofVec_.dend();
}
template <class DiscreteFunctionSpaceImp>
AdaptiveFunctionImplementation<DiscreteFunctionSpaceImp>::LocalFunctionType
AdaptiveFunctionImplementation<DiscreteFunctionSpaceImp>::
newLocalFunction() {
return LocalFunctionType(spc_, dofVec_);
}
template <class DiscreteFunctionSpaceImp>
template <class EntityType>
void AdaptiveFunctionImplementation<DiscreteFunctionSpaceImp>::
localFunction(const EntityType& en, LocalFunctionType& lf) {
lf.init(en);
}
//- Read/write methods
template<class DiscreteFunctionSpaceImp>
bool AdaptiveFunctionImplementation<DiscreteFunctionSpaceImp>::
write_xdr(std::string fn)
{
FILE *file;
XDR xdrs;
file = fopen(fn.c_str(), "wb");
if (!file)
{
printf( "\aERROR in AdaptiveDiscreteFunction::write_xdr(..): could not open <%s>!\n", fn.c_str());
fflush(stderr);
return false;
}
xdrstdio_create(&xdrs, file, XDR_ENCODE);
dofVec_.processXdr(&xdrs);
xdr_destroy(&xdrs);
fclose(file);
return true;
}
template <class DiscreteFunctionSpaceImp>
inline bool AdaptiveFunctionImplementation<DiscreteFunctionSpaceImp>::
read_xdr(std::string fn)
{
FILE *file;
XDR xdrs;
std::cout << "Reading <" << fn << "> \n";
file = fopen(fn.c_str() , "rb");
if(!file)
{
printf( "\aERROR in AdaptiveDiscreteFunction::read_xdr(..): could not open <%s>!\n", fn.c_str());
fflush(stderr);
return(false);
}
// read xdr
xdrstdio_create(&xdrs, file, XDR_DECODE);
dofVec_.processXdr(&xdrs);
xdr_destroy(&xdrs);
fclose(file);
return true;
}
template <class DiscreteFunctionSpaceImp>
inline bool AdaptiveFunctionImplementation<DiscreteFunctionSpaceImp>::
write_ascii(std::string fn)
{
std::fstream outfile( fn.c_str() , std::ios::out );
if (!outfile)
{
printf( "\aERROR in AdaptiveDiscreteFunction::write_ascii(..): could not open <%s>!\n", fn.c_str());
fflush(stderr);
return false;
}
{
int length = this->functionSpace_.size();
outfile << length << "\n";
DofIteratorType enddof = dend ( );
for(DofIteratorType itdof = dbegin ( ); itdof != enddof; ++itdof)
{
outfile << (*itdof) << " ";
}
outfile << "\n";
}
outfile.close();
return true;
}
template<class DiscreteFunctionSpaceImp >
inline bool AdaptiveFunctionImplementation<DiscreteFunctionSpaceImp>::
read_ascii(std::string fn)
{
FILE *infile=0;
infile = fopen( fn.c_str(), "r" );
assert(infile != 0);
{
int length;
fscanf(infile,"%d \n",&length);
assert(length == this->functionSpace_.size( ));
DofIteratorType enddof = dend ( );
for(DofIteratorType itdof = dbegin ( ); itdof != enddof; ++itdof)
{
fscanf(infile,"%le \n",& (*itdof));
}
}
fclose(infile);
return true;
}
} // end namespace Dune
// NOTE: The current revision of this file was left untouched when the DUNE source files were reindented!
// NOTE: It contained invalid syntax that could not be processed by uncrustify.
#ifndef DUNE_ADAPTIVEFUNCTIONIMP_HH
#define DUNE_ADAPTIVEFUNCTIONIMP_HH
//- System includes
#include <string>
//- Dune includes
namespace Dune {
template <class DiscreteFunctionSpaceImp>
class AdaptiveFunctionImplementation {
private:
typedef AdaptiveDiscreteFunctionTraits<DiscreteFunctionSpaceImp> Traits;
typedef typename Traits::DofIteratorType DofIteratorType;
typedef typename Traits::ConstDofIteratorType ConstDofIteratorType;
typedef typename Traits::LocalFunctionType LocalFunctionType
typedef typename DiscreteFunctionSpaceImp::Traits SpaceTraits;
typedef typename SpaceTraits::RangeFieldType RangeFieldType;
typedef DofArray<RangeFieldType> DofStorageType;
public:
AdaptiveFunctionImplementation(
DofIteratorType dbegin();
DofIteratorType dend();
ConstDofIteratorType dbegin() const;
ConstDofIteratorType dend() const;
LocalFunctionType newLocalFunction();
template <class EntityType>
void localFunction(const EntityType& en, LocalFunctionType& lf);
//! write data of discrete function to file filename|timestep
//! with xdr methods
bool write_xdr(const std::string& filename);
//! write data of discrete function to file filename|timestep
//! with xdr methods
bool read_xdr(const std::string& filename);
//! write function data to file filename|timestep in ascii Format
bool write_ascii(const std::string& filename);
//! read function data from file filename|timestep in ascii Format
bool read_ascii(const std::string& filename);
protected:
AdaptiveFunctionImplementation(std::string name);
~AdaptiveFunctionImplementation();
DiscreteFunctionSpaceType& spc_;
MemObjectType& memObj_;
DofStorageType& dofVec_;
std::string name_;
}; // end class AdaptiveFunctionImplementation
} // end namespace Dune
#include "adaptiveimp.cc"
#endif
......@@ -34,7 +34,6 @@ namespace Dune {
dm_.addIndexSet( gridPart.grid() , gridPart.indexSet() );
//std::cout << "Constructor of LagrangeDiscreteFunctionSpace! \n";
// search the macro grid for diffrent element types
typedef typename GridType::template Codim<0>::LevelIterator LevelIteratorType;
IteratorType endit = gridPart.template end<0>();
......@@ -44,11 +43,7 @@ namespace Dune {
GeometryIdentifier::IdentifierType id =
GeometryIdentifier::fromGeo(dimension, geo);
if(baseFuncSet_[id] == 0 )
{
assert( id < (int) baseFuncSet_.size() );
assert( id >= 0);
baseFuncSet_[id] = setBaseFuncSetPointer(*it, gridPart.indexSet());
}
}
// for empty functions space which can happen for BSGrid
......@@ -87,11 +82,14 @@ namespace Dune {
LagrangeDiscreteFunctionSpace<FunctionSpaceImp, GridPartImp, polOrd, DofManagerImp>::
getBaseFunctionSet (EntityType &en) const
{
GeometryType geo = en.geometry().type();
int dimension = static_cast<int>(EntityType::mydimension);
assert(GeometryIdentifier::fromGeo(dimension, geo) < (int) baseFuncSet_.size());
assert(GeometryIdentifier::fromGeo(dimension, geo) >= 0);
return *baseFuncSet_[GeometryIdentifier::fromGeo(dimension, geo)];
}
template <
......@@ -119,7 +117,6 @@ namespace Dune {
return (polOrd != 0);
}
template <
class FunctionSpaceImp, class GridPartImp, int polOrd, class DofManagerImp
>
......@@ -149,6 +146,7 @@ namespace Dune {
{
// only for gcc to pass type DofType
assert(mapper_ != 0);
return dm_.addDofSet( df.getStorageType() , grid_.grid() , *mapper_, df.name() );
}
......
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