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

Bugfixes - passes all tests now

[[Imported from SVN: r2792]]
parent ff2b26d8
No related branches found
No related tags found
No related merge requests found
......@@ -38,7 +38,7 @@ namespace Dune {
AdaptiveLocalFunction<DiscreteFunctionSpaceImp >::
operator[] (int num)
{
assert(num >= 0 && num < numberOfDofs());
assert(num >= 0 && num < numDofs());
return (* (values_[num]));
}
......@@ -48,7 +48,7 @@ namespace Dune {
AdaptiveLocalFunction<DiscreteFunctionSpaceImp >::
operator[] (int num) const
{
assert(num >= 0 && num < numberOfDofs());
assert(num >= 0 && num < numDofs());
return (* (values_[num]));
}
......@@ -59,15 +59,23 @@ namespace Dune {
return values_.size();
}
template <class DiscreteFunctionSpaceImp>
int AdaptiveLocalFunction<DiscreteFunctionSpaceImp >::
numDofs() const
{
return values_.size();
}
template <class DiscreteFunctionSpaceImp>
template <class EntityType>
void AdaptiveLocalFunction<DiscreteFunctionSpaceImp >::
evaluateLocal(EntityType& en, const DomainType& x, RangeType& ret) const
{
assert(en.geometry().checkInside(x));
ret *= 0.0;
const BaseFunctionSetType& bSet = spc_.getBaseFunctionSet(en);
for (int i = 0; i < bSet.getNumberOfBaseFunctions(); ++i) {
for (int i = 0; i < bSet.numBaseFunctions(); ++i) {
bSet.eval(i, x, tmp_);
for (int l = 0; l < dimRange; ++l) {
ret[l] += (*values_[i]) * tmp_[l];
......@@ -98,7 +106,7 @@ namespace Dune {
ret *= 0.0;
const BaseFunctionSetType& bSet = spc_.getBaseFunctionSet(en);
for (int i = 0; i < bSet.getNumberOfBaseFunctions(); ++i) {
for (int i = 0; i < bSet.numBaseFunctions(); ++i) {
tmpGrad_ *= 0.0;
bSet.jacobian(i, x, tmpGrad_);
......@@ -126,7 +134,7 @@ namespace Dune {
init(EntityType& en)
{
int numOfDof =
spc_.getBaseFunctionSet(en).getNumberOfBaseFunctions();
spc_.getBaseFunctionSet(en).numBaseFunctions();
values_.resize(numOfDof);
for (int i = 0; i < numOfDof; ++i) {
......@@ -163,7 +171,6 @@ namespace Dune {
}
//- AdaptiveLocalFunction (Specialisation for CombinedSpace)
template <class ContainedFunctionSpaceImp, int N, DofStoragePolicy p>
AdaptiveLocalFunction<
CombinedSpace<ContainedFunctionSpaceImp, N, p> >::
......@@ -173,9 +180,9 @@ namespace Dune {
dofVec_(dofVec),
values_(),
cTmp_(0.0),
cTmpGrad_(0.0),
tmp_(0.0),
tmpGrad_(0.0)
cTmpGradRef_(0.0),
cTmpGradReal_(0.0),
tmp_(0.0)
{}
template <class ContainedFunctionSpaceImp, int N, DofStoragePolicy p>
......@@ -186,9 +193,9 @@ namespace Dune {
dofVec_(other.dofVec_),
values_(),
cTmp_(0.0),
cTmpGrad_(0.0),
tmp_(0.0),
tmpGrad_(0.0)
cTmpGradRef_(0.0),
cTmpGradReal_(0.0),
tmp_(0.0)
{}
template <class ContainedFunctionSpaceImp, int N, DofStoragePolicy p>
......@@ -203,6 +210,7 @@ namespace Dune {
CombinedSpace<ContainedFunctionSpaceImp, N, p> >::
operator[] (int num)
{
assert(num >= 0 && num < numDofs());
return *values_[num/N][num%N];
}
......@@ -213,6 +221,7 @@ namespace Dune {
CombinedSpace<ContainedFunctionSpaceImp, N, p> >::
operator[] (int num) const
{
assert(num >= 0 && num < numDofs());
return *values_[num/N][num%N];
}
......@@ -224,6 +233,14 @@ namespace Dune {
return values_.size()*N;
}
template <class ContainedFunctionSpaceImp, int N, DofStoragePolicy p>
int AdaptiveLocalFunction<
CombinedSpace<ContainedFunctionSpaceImp, N, p> >::
numDofs() const
{
return values_.size()*N;
}
template <class ContainedFunctionSpaceImp, int N, DofStoragePolicy p>
template <class EntityType>
void AdaptiveLocalFunction<
......@@ -232,6 +249,8 @@ namespace Dune {
const DomainType& x,
RangeType& result) const
{
assert(en.geometry().checkInside(x));
const BaseFunctionSetType& bSet = spc_.getBaseFunctionSet(en);
result *= 0.0;
......@@ -266,19 +285,23 @@ namespace Dune {
JacobianRangeType& result) const
{
enum { dim = EntityType::dimension };
typedef FieldMatrix<DofType, RangeType::size, RangeType::size> JacobianInverseType;
result *= 0.0;
const BaseFunctionSetType& bSet = spc_.getBaseFunctionSet(en);
const JacobianInverseType& jInv = en.geometry().jacobianInverse(x);
for (int i = 0; i < bSet.numContainedFunctions(); ++i) {
cTmpGrad_ *= 0.0;
bSet.jacobianContained(i, x, cTmpGrad_);
//cTmpGradRef_ *= 0.0;
cTmpGradReal_ *= 0.0;
bSet.jacobianContained(i, x, cTmpGradRef_);
jInv.umtv(cTmpGradRef_[0], cTmpGradReal_[0]);
for (int j = 0; j < N; ++j) {
// Assumption: ContainedDimRange == 1
tmpGrad_[j] = (*values_[i][j])*cTmpGrad_[0];
//cTmpGrad_[0] *= *values_[i][j];
result[j].axpy(*values_[i][j], cTmpGradReal_[0]);
}
en.geometry().jacobianInverse(x).umtv(tmpGrad_, result);
}
}
......
......@@ -61,8 +61,7 @@ namespace Dune {
class AdaptiveDiscreteFunction :
public DiscreteFunctionDefault<
AdaptiveDiscreteFunctionTraits<DiscreteFunctionSpaceImp > >,
private AdaptiveFunctionImplementation<
DiscreteFunctionSpaceImp >
private AdaptiveFunctionImplementation<DiscreteFunctionSpaceImp >
{
public:
//- friends
......@@ -224,7 +223,10 @@ namespace Dune {
//- Methods
//! Number of dofs on this element
int numberOfDofs() const;
int numberOfDofs() const DUNE_DEPRECATED;
//! Number of dofs on this element
int numDofs() const;
//! Evaluation of the discrete function
template <class EntityType>
......@@ -425,7 +427,9 @@ namespace Dune {
const DofType& operator[] (int num) const;
//- Methods
int numberOfDofs() const;
int numberOfDofs() const DUNE_DEPRECATED;
int numDofs() const;
template <class EntityType>
void evaluateLocal(EntityType& en,
......@@ -466,10 +470,11 @@ namespace Dune {
mutable std::vector<FieldVector<DofType*, N> > values_;
mutable RangeType tmp_;
mutable ContainedRangeType cTmp_;
mutable ContainedJacobianRangeType cTmpGrad_;
mutable JacobianRangeType tmpGrad_;
mutable ContainedJacobianRangeType cTmpGradRef_;
mutable ContainedJacobianRangeType cTmpGradReal_;
mutable RangeType tmp_;
}; // end class AdaptiveLocalFunction (specialised for CombinedSpace)
} // end namespace Dune
......
......@@ -22,7 +22,7 @@ namespace Dune {
spc_(spc),
name_(name),
dm_(DofManagerFactory<DofManagerType>::getDofManager(spc.grid())),
memObj_(std::pair<MemObjectInterface*, DofStorageType*>(0, 0)),
memPair_(std::pair<MemObjectInterface*, DofStorageType*>(0, 0)),
dofVec_(dofVec)
{}
......
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