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

Final version for today

[[Imported from SVN: r2724]]
parent 8a0e9f44
Branches
Tags
No related merge requests found
......@@ -10,6 +10,7 @@
#include <dune/fem/common/discretefunctionspace.hh>
#include <dune/fem/common/basefunctions.hh>
#include <dune/fem/common/dofmapperinterface.hh>
#include <dune/fem/space/subspace.hh>
#include <dune/common/misc.hh>
namespace Dune {
......@@ -141,6 +142,8 @@ namespace Dune {
typedef typename ContainedSpaceTraits::GridType GridType;
typedef typename ContainedSpaceTraits::IteratorType IteratorType;
typedef DofConversionUtility<policy> DofConversionType;
enum { DimRange = FunctionSpaceType::DimRange,
DimDomain = FunctionSpaceType::DimDomain };
public:
......@@ -181,6 +184,8 @@ namespace Dune {
typedef typename Traits::BaseFunctionSetType BaseFunctionSetType;
typedef typename Traits::MapperType MapperType;
typedef typename Traits::DofConversionType DofConversionType;
CompileTimeChecker<(Traits::ContainedDimRange == 1)> use_CombinedSpace_only_with_scalar_spaces;
public:
//- Public methods
......@@ -233,13 +238,28 @@ namespace Dune {
//! access to mapper
const MapperType& mapper() const { return mapper_; }
//- Additional methods
//! number of components
int numComponents() const { return N; }
//! policy of this space
DofStoragePolicy policy() const { return policy; }
private:
//- Private typedefs
typedef typename Traits::ContainedMapperType ContainedMapperType;
//- Friend
friend class SubSpace<ThisType>;
private:
//- Private methods
CombinedSpace(const ThisType& other);
const ContainedMapperType& containedMapper() const {
return mapper_.containedMapper();
}
private:
//- Member data
ContainedDiscreteFunctionSpaceType& spc_;
......@@ -343,6 +363,10 @@ namespace Dune {
CombinedMapper<DiscreteFunctionSpaceImp, N, policy>
>
{
public:
//- Friends
friend class CombinedSpace<DiscreteFunctionSpaceImp, N, policy>;
public:
//- Typedefs and enums
enum { numComponents = N };
......@@ -359,7 +383,7 @@ namespace Dune {
spc_(spc),
mapper_(mapper),
utilLocal_(N),
utilGlobal_(chooseSize(N, spc.size(), Int2Type<policy>()))
utilGlobal_(policy == PointBased ? N : spc.size())
{}
//! Total number of degrees of freedom
......@@ -410,6 +434,10 @@ namespace Dune {
//- Private methods
CombinedMapper(const ThisType& other);
const ContainedMapperType& containedMapper() const {
return mapper_;
}
static int chooseSize(int pointBased, int variableBased,
Int2Type<PointBased>) {
return pointBased;
......
......@@ -13,40 +13,65 @@ namespace Dune {
mapper_(spc, spc.mapper(), component),
component_(component)
{
assert(false);
// * more to come here
// initialise your basefunction set with all Geometry types found in mesh
IteratorType endit = spc.end();
for (IteratorType it = spc.begin(); it != endit; ++it) {
GeometryType geo = it->geometry().type();
const int dimension =
static_cast<int>(IteratorType::Entity::mydimension);
GeometryIdentifier::IdentifierType id =
GeometryIdentifier::fromGeo(dimension, geo);
assert(id >= 0 && id < GeometryIdentifier::numTypes);
if (baseSetVec_[id] == 0) {
baseSetVec_[id] =
new BaseFunctionSetType(spc.getBaseFunctionSet(*it), component);
}
} // end for
}
//- class SubBaseFunctionSet
template <class CombinedSpaceImp>
template <int diffOrd>
void SubMapper<CombinedSpaceImp>::
void SubBaseFunctionSet<CombinedSpaceImp>::
evaluate (int baseFunct,
const FieldVector<deriType, diffOrd> &diffVariable,
const DomainType & x, RangeType & phi ) const;
const FieldVector<deriType, diffOrd>& diffVariable,
const DomainType& x, RangeType& phi ) const
{
// Assumption: dimRange == 1
bSet_.evaluate(baseFunct, diffVariable, x, tmp_);
phi[0] = tmp_[component_];
}
//! evaluate base function at quadrature point
template <class CombinedSpaceImp>
template <int diffOrd, class QuadratureType >
void SubMapper<CombinedSpaceImp>::
void SubBaseFunctionSet<CombinedSpaceImp>::
evaluate (int baseFunct,
const FieldVector<deriType, diffOrd> &diffVariable,
QuadratureType & quad,
int quadPoint, RangeType & phi ) const;
int quadPoint, RangeType & phi ) const
{
// Assumption: dimRange == 1
bSet_.evaluate(baseFunct, diffVariable, quad, quadPoint, tmp_);
phi[0] = tmp_[component_];
}
//- class SubMapper
template <class CombinedSpaceImp>
int SubMapper<CombinedSpaceImp>::size() const
{
assert(false);
// *more to come
return mapper_.size();
}
template <class CombinedSpaceImp>
template <class EntityType>
SubMapper<CombinedSpaceImp>::mapToGlobal(EntityType& en, int localNum) const
{
assert(false);
// *more to come
const int containedGlobal = mapper_.mapToGlobal(en, localNum);
utilGlobal_.newSize(mapper_.size()); // ok, since pointbased specialisation does nothing for newSize
return utilGlobal_.combinedDof(containedGlobal, component_);
}
......
......@@ -12,6 +12,14 @@
namespace Dune {
//- Forward declarations
template <class CombinedSpaceImp>
class SubSpace;
template <class CombinedSpaceImp>
class SubBaseFunctionSet;
template <class CombinedSpaceImp>
class SubMapper;
template <class CombinedSpaceImp>
struct SubSpaceTraits {
private:
......@@ -25,9 +33,10 @@ namespace Dune {
typedef typename CombinedTraits::BaseFunctionSetType CombinedBaseFunctionSetType;
typedef typename CombinedTraits::MapperType CombinedMapperType;
enum { CombinedDimRange = CombinedTraits::DimRange; }
enum { CombinedDimRange = CombinedTraits::DimRange };
public:
// Assumption: only scalar contained function spaces
enum { DimDomain = CombinedTraits::DimDomain,
DimRange = 1 };
......@@ -45,6 +54,7 @@ namespace Dune {
typedef typename CombinedTraits::GridType GridType;
typedef typename CombinedTraits::IteratorType IteratorType;
typedef typename CombinedTraits::DofConversionType DofConversionType;
public:
//- Friends
......@@ -136,7 +146,7 @@ namespace Dune {
};
// Idea: wrap contained base function set, since this is exactly what you
// need here (except for when you go for ranges...)
// need here (except for when you go for ranges of subfunctions...)
template <class CombinedSpaceImp>
class SubBaseFunctionSet :
public BaseFunctionSetDefault<SubSpaceTraits<CombinedSpaceImp> >
......@@ -159,8 +169,11 @@ namespace Dune {
typedef int deriType;
public:
//- Public methods
SubBaseFunctionSet(const CombinedBaseFunctionSetType& bSet) :
bSet_(bSet)
SubBaseFunctionSet(const CombinedBaseFunctionSetType& bSet,
int component) :
bSet_(bSet),
component_(component),
tmp_(0.0)
{}
int getNumberOfBaseFunctions() const {
......@@ -184,7 +197,9 @@ namespace Dune {
private:
//- Data members
const CombinedBaseFunctionSetType& bSet_;
int component_;
const int component_;
mutable CombinedRangeType tmp_;
};
template <class CombinedSpaceImp>
......@@ -199,16 +214,21 @@ namespace Dune {
typedef SubSpaceTraits<CombinedSpaceType> Traits;
typedef typename Traits::CombinedMapperType CombinedMapperType;
typedef typename Traits::DofConversionType DofConversionType;
public:
//- Public methods
SubMapper(const CombinedSpaceType& spc,
const CombinedMapperType& mapper,
const ContainedMapperType& mapper,
int component) :
spc_(spc),
mapper_(mapper),
component_(component)
component_(component),
utilGlobal_(policy == PointBased() ?
spc.numComponents() :
spc.size()/spc.numComponents())
{}
//! Total number of degrees of freedom
int size() const;
......@@ -267,9 +287,11 @@ namespace Dune {
private:
//- Data members
CombinedSpaceType& spc_;
CombinedMapperType& mapper_;
int component_;
const CombinedSpaceType& spc_;
const ContainedMapperType& mapper_;
const int component_;
DofConversionType utilGlobal_;
};
} // end namespace Dune
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment