Skip to content
Snippets Groups Projects
Commit 4b417ccf authored by Max Kahnt's avatar Max Kahnt
Browse files

Make NonconformingBasis a base instead of member of ConformingBasis.

Backward compatibility should be assured by a the remaining
deprecated constructor and proper forwarding of the new variadic
constructor to a potential copy constructor.
parent 558093de
No related branches found
No related tags found
No related merge requests found
......@@ -16,20 +16,18 @@
*/
template <class NonconformingBasis>
class ConformingBasis :
public FunctionSpaceBasis<
typename NonconformingBasis::GridView,
typename NonconformingBasis::ReturnType,
typename NonconformingBasis::LocalFiniteElement>
public NonconformingBasis
{
// TODO static_assert that template param NoncormingBasis is a FunctionSpaceBasis template?
using Base = NonconformingBasis;
protected:
typedef typename NonconformingBasis::GridView GV;
typedef typename NonconformingBasis::ReturnType RT;
typedef typename NonconformingBasis::LocalFiniteElement LFE;
typedef FunctionSpaceBasis<GV, RT, LFE> Base;
typedef typename Base::Element Element;
public:
typedef typename Base::GridView GridView;
typedef typename Base::ReturnType ReturnType;
......@@ -37,21 +35,26 @@ class ConformingBasis :
typedef typename Base::BitVector BitVector;
typedef typename Base::LinearCombination LinearCombination;
DUNE_DEPRECATED_MSG("Please put the DOFConstraints first.") // TODO check if there might be reasons why this should be kept
ConformingBasis(const NonconformingBasis& ncBasis, const DOFConstraints& dofConstraints) :
ConformingBasis(dofConstraints, ncBasis)
{}
/**
* \brief Setup conforming global basis
*
* This constructor will take some time since the interpolation values
* for the conforming basis need to be build.
*
* \param ncBasis Global basis of underlying nonconforming function space
* \param args construction arguments of underlying nonconforming function space
*/
ConformingBasis(const NonconformingBasis& ncBasis) :
Base(ncBasis.getGridView()),
ncBasis_(ncBasis)
template<typename... Args>
ConformingBasis(Args... args) :
Base(args...)
{
dofConstraints_ = new DOFConstraints;
dofConstraintsAllocated_ = true;
dofConstraints_->setupFromBasis<NonconformingBasis>(ncBasis_);
dofConstraints_->setupFromBasis<NonconformingBasis>(*this);
}
/**
......@@ -60,12 +63,12 @@ class ConformingBasis :
* Using this constructor you can provide a custom DOFConstrains object.
* This needs to be set up before using the basis and after grid modification manually.
*
* \param ncBasis Global basis of underlying nonconforming function space
* \param dofConstraints Set of interpolation values for the conforming subspace basis
* \param args construction arguments of underlying nonconforming function space
*/
ConformingBasis(const NonconformingBasis& ncBasis, const DOFConstraints& dofConstraints) :
Base(ncBasis.getGridView()),
ncBasis_(ncBasis),
template<typename... Args>
ConformingBasis(const DOFConstraints& dofConstraints, Args... args) :
Base(args...),
dofConstraints_(const_cast<DOFConstraints*>(&dofConstraints)),
dofConstraintsAllocated_(false)
{}
......@@ -74,8 +77,7 @@ class ConformingBasis :
* \brief Deep copy
*/
ConformingBasis(const ConformingBasis& from) :
Base(from.getGridView()),
ncBasis_(from.ncBasis_)
Base(from)
{
dofConstraintsAllocated_ = from.dofConstraintsAllocated_;
if (dofConstraintsAllocated_)
......@@ -91,27 +93,15 @@ class ConformingBasis :
}
using Base::update;
using Base::size;
using Base::getLocalFiniteElement;
using Base::index;
void update(const GridView& gridview)
{
Base::update(gridview);
if (dofConstraintsAllocated_)
dofConstraints_->setupFromBasis<NonconformingBasis>(ncBasis_);
}
size_t size() const
{
return ncBasis_.size();
}
const LocalFiniteElement& getLocalFiniteElement(const Element& e) const
{
return ncBasis_.getLocalFiniteElement(e);
}
int index(const Element& e, const int i) const
{
return ncBasis_.index(e, i);
dofConstraints_->setupFromBasis<NonconformingBasis>(*this);
}
bool isConstrained(const int index) const
......@@ -129,8 +119,10 @@ class ConformingBasis :
return dofConstraints_->isConstrained();
}
NonconformingBasis& ncBasis() { return *this; }
const NonconformingBasis& ncBasis() const { return *this; }
protected:
const NonconformingBasis& ncBasis_;
DOFConstraints* dofConstraints_;
bool dofConstraintsAllocated_;
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment