Skip to content
Snippets Groups Projects
Commit f5a45e44 authored by Oliver Sander's avatar Oliver Sander Committed by sander
Browse files

Add a wrapper that makes a dune-functions function space basis look like a dune-fufem one

This short class wraps a dune-functions-style function space basis and
implements the interface of dune-fufem bases.  That way you can now technically
use dune-functions bases to assemble all your problems.

Caveats:
- constraints are not supported

[[Imported from SVN: r13072]]
parent 33f93510
No related branches found
No related tags found
No related merge requests found
...@@ -2,6 +2,7 @@ install(FILES ...@@ -2,6 +2,7 @@ install(FILES
conformingbasis.hh conformingbasis.hh
dgpqkbasis.hh dgpqkbasis.hh
dofconstraints.hh dofconstraints.hh
dunefunctionsbasis.hh
extensionbasis.hh extensionbasis.hh
functionspacebasis.hh functionspacebasis.hh
p0basis.hh p0basis.hh
......
...@@ -3,6 +3,7 @@ SUBDIRS = ...@@ -3,6 +3,7 @@ SUBDIRS =
functionspacebasesdir = $(includedir)/dune/fufem/functionspacebases functionspacebasesdir = $(includedir)/dune/fufem/functionspacebases
functionspacebases_HEADERS = conformingbasis.hh \ functionspacebases_HEADERS = conformingbasis.hh \
dofconstraints.hh \ dofconstraints.hh \
dunefunctionsbasis.hh \
extensionbasis.hh \ extensionbasis.hh \
functionspacebasis.hh \ functionspacebasis.hh \
p0basis.hh \ p0basis.hh \
......
#ifndef DUNE_FUFEM_FUNCTIONSPACEBASES_DUNEFUNCTIONSBASIS_HH
#define DUNE_FUFEM_FUNCTIONSPACEBASES_DUNEFUNCTIONSBASIS_HH
/**
@file
@brief A wrapper around the function space bases from the dune-functions module
@author Oliver Sander
*/
#include <dune/fufem/functionspacebases/functionspacebasis.hh>
/** \brief Wrap a basis from dune-functions and make it look like a dune-fufem basis
*
* \tparam A function space basis from dune-functions
*
* This class exists for transition purposes only. In the long run, we want to use the function
* space bases from dune-functions directly in dune-fufem. However, get some experience with
* them, we start with this wrapper.
*
* Using this wrapper may be a bit slower than using either the dune-fufem or the dune-functions
* bases directly, because 'bind' needs to be called at each access to 'getLocalFiniteElement'
* and 'index'. I don't know whether the difference is significant.
*/
template <class DFBasis>
class DuneFunctionsBasis
: public FunctionSpaceBasis<typename DFBasis::GridView,
double,
typename DFBasis::LocalView::Tree::FiniteElement >
{
protected:
typedef FunctionSpaceBasis<typename DFBasis::GridView,double,typename DFBasis::LocalView::Tree::FiniteElement> Base;
typedef typename Base::Element Element;
public:
/** \brief GridView on which this basis is defined */
typedef typename DFBasis::GridView GridView;
/** \brief Number type used for basis function values */
typedef typename Base::ReturnType ReturnType;
/** \brief The LocalFiniteElement (in the dune-localfunctions sense of the word)
* that implements the local basis on each element
*/
typedef typename DFBasis::LocalView::Tree::FiniteElement LocalFiniteElement;
/** \brief Constructor from a dune-functions basis */
DuneFunctionsBasis(const DFBasis& dfBasis)
: Base(dfBasis.gridView()),
dfBasis_(dfBasis),
localView_(dfBasis.localView())
{}
/** \brief Return the total number of basis vectors in this basis
*/
size_t size() const
{
return dfBasis_.subIndexCount();
}
/** \brief Get a local finite element (i.e., a set of shape functions) for the given element
*/
const LocalFiniteElement& getLocalFiniteElement(const Element& element) const
{
localView_.bind(element);
return localView_.tree().finiteElement();
}
/** \brief Get the global index of the i-th local degree of freedom on element 'element'
*/
int index(const Element& element, const int i) const
{
localView_.bind(element);
return localView_.tree().globalIndex(i)[0];
}
protected:
// The dune-functions basis we are wrapping
const DFBasis& dfBasis_;
// Must be mutable, because it gets bound to individual elements during the const methods
// 'getLocalFiniteElement' and 'index'.
mutable typename DFBasis::LocalView localView_;
};
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment