Commit 2ead81d4 authored by Andreas Dedner's avatar Andreas Dedner

add specialization for DGLFE space - used same base implementation as non DG version

parent f7a0f4fb
Pipeline #18034 failed with stage
in 62 minutes and 6 seconds
......@@ -93,101 +93,120 @@ namespace Dune
const std::vector< BasisFunctionSetType >& childBasisSets_;
const std::vector< std::vector<double> >& childDofs_;
};
} // namespce Impl
// a detailed description is given in MR308
// https://gitlab.dune-project.org/dune-fem/dune-fem/merge_requests/308
template< class LFEMap, class FunctionSpace, template< class > class Storage >
struct DefaultLocalRestrictProlong< LocalFiniteElementSpace< LFEMap, FunctionSpace, Storage > >
{
typedef LocalFiniteElementSpace< LFEMap, FunctionSpace, Storage > DiscreteFunctionSpaceType;
typedef DefaultLocalRestrictProlong< DiscreteFunctionSpaceType > ThisType;
typedef typename DiscreteFunctionSpaceType::DomainFieldType DomainFieldType;
typedef typename DiscreteFunctionSpaceType::BasisFunctionSetType BasisFunctionSetType;
typedef typename DiscreteFunctionSpaceType::EntityType EntityType;
typedef typename EntityType::LocalGeometry LocalGeometryType;
typedef typename EntityType::EntitySeed EntitySeedType;
DefaultLocalRestrictProlong (const DiscreteFunctionSpaceType &space)
: space_( space ), childSeeds_(0), childDofs_(0)
{}
/** \brief explicit set volume ratio of son and father
*
* \param[in] weight volume of son / volume of father
*
* \note If this ratio is set, it is assume to be constant.
*/
void setFatherChildWeight ( const DomainFieldType &weight )
// a detailed description is given in MR308
// https://gitlab.dune-project.org/dune-fem/dune-fem/merge_requests/308
template< class LFESpace >
struct DefaultLocalRestrictProlongLFE
{
}
typedef LFESpace DiscreteFunctionSpaceType;
typedef DefaultLocalRestrictProlongLFE< DiscreteFunctionSpaceType > ThisType;
//! restrict data to father
template< class LFFather, class LFSon, class LocalGeometry >
void restrictLocal ( LFFather &lfFather, const LFSon &lfSon,
const LocalGeometry &geometryInFather, bool initialize ) const
{
const int numDofs = lfFather.numDofs();
assert( lfFather.numDofs() == lfSon.numDofs() );
typedef typename DiscreteFunctionSpaceType::DomainFieldType DomainFieldType;
typedef typename DiscreteFunctionSpaceType::BasisFunctionSetType BasisFunctionSetType;
typedef typename DiscreteFunctionSpaceType::EntityType EntityType;
typedef typename EntityType::LocalGeometry LocalGeometryType;
typedef typename EntityType::EntitySeed EntitySeedType;
DefaultLocalRestrictProlongLFE (const DiscreteFunctionSpaceType &space)
: space_( space ), childSeeds_(0), childDofs_(0)
{}
if (initialize)
/** \brief explicit set volume ratio of son and father
*
* \param[in] weight volume of son / volume of father
*
* \note If this ratio is set, it is assume to be constant.
*/
void setFatherChildWeight ( const DomainFieldType &weight )
{
childSeeds_.resize(0);
childDofs_.resize(0);
}
childSeeds_.push_back(lfSon.entity().seed());
childDofs_.push_back(std::vector<double>(lfSon.size()));
for (unsigned int i=0;i<lfSon.size();++i)
childDofs_.back()[i] = lfSon[i];
}
//! restrict data to father
template< class LFFather, class LFSon, class LocalGeometry >
void restrictLocal ( LFFather &lfFather, const LFSon &lfSon,
const LocalGeometry &geometryInFather, bool initialize ) const
{
const int numDofs = lfFather.numDofs();
assert( lfFather.numDofs() == lfSon.numDofs() );
if (initialize)
{
childSeeds_.resize(0);
childDofs_.resize(0);
}
template <class LFFather>
void restrictFinalize( LFFather &lfFather ) const
{
const int numDofs = lfFather.numDofs();
std::vector< EntityType > childEntities(childSeeds_.size());
std::vector< BasisFunctionSetType > childBasisSets(childSeeds_.size());
for (unsigned int i=0; i<childSeeds_.size();++i)
childSeeds_.push_back(lfSon.entity().seed());
childDofs_.push_back(std::vector<double>(lfSon.size()));
for (unsigned int i=0;i<lfSon.size();++i)
childDofs_.back()[i] = lfSon[i];
}
template <class LFFather>
void restrictFinalize( LFFather &lfFather ) const
{
childEntities[i] = space_.gridPart().entity( childSeeds_[i] );
childBasisSets[i] = space_.basisFunctionSet( childEntities[i] );
const int numDofs = lfFather.numDofs();
std::vector< EntityType > childEntities(childSeeds_.size());
std::vector< BasisFunctionSetType > childBasisSets(childSeeds_.size());
for (unsigned int i=0; i<childSeeds_.size();++i)
{
childEntities[i] = space_.gridPart().entity( childSeeds_[i] );
childBasisSets[i] = space_.basisFunctionSet( childEntities[i] );
}
space_.interpolation(lfFather.entity())
( Impl::SonsWrapper<BasisFunctionSetType, LFFather>( childEntities, childBasisSets, childDofs_ ),
lfFather.localDofVector() );
}
space_.interpolation(lfFather.entity())
( Impl::SonsWrapper<BasisFunctionSetType, LFFather>( childEntities, childBasisSets, childDofs_ ),
lfFather.localDofVector() );
}
//! prolong data to children
template< class LFFather, class LFSon, class LocalGeometry >
void prolongLocal ( const LFFather &lfFather, LFSon &lfSon,
const LocalGeometry &geometryInFather, bool initialize ) const
{
const int numDofs = lfFather.numDofs();
assert( lfFather.numDofs() == lfSon.numDofs() );
DynamicVector<double> sonDofs( numDofs );
space_.interpolation(lfSon.entity())
( Impl::FatherWrapper<LocalGeometry,LFFather>(geometryInFather,lfFather),
sonDofs );
for (int i=0;i<numDofs;++i)
lfSon[i] = sonDofs[i];
}
//! do discrete functions need a communication after restriction / prolongation?
bool needCommunication () const { return true; }
protected:
template< class Entity >
static DomainFieldType calcWeight ( const Entity &father, const Entity &son )
{
return son.geometry().volume() / father.geometry().volume();
}
const DiscreteFunctionSpaceType &space_;
mutable std::vector< EntitySeedType > childSeeds_;
mutable std::vector< std::vector<double> > childDofs_;
//! prolong data to children
template< class LFFather, class LFSon, class LocalGeometry >
void prolongLocal ( const LFFather &lfFather, LFSon &lfSon,
const LocalGeometry &geometryInFather, bool initialize ) const
{
const int numDofs = lfFather.numDofs();
assert( lfFather.numDofs() == lfSon.numDofs() );
DynamicVector<double> sonDofs( numDofs );
space_.interpolation(lfSon.entity())
( Impl::FatherWrapper<LocalGeometry,LFFather>(geometryInFather,lfFather),
sonDofs );
for (int i=0;i<numDofs;++i)
lfSon[i] = sonDofs[i];
}
//! do discrete functions need a communication after restriction / prolongation?
bool needCommunication () const { return true; }
protected:
template< class Entity >
static DomainFieldType calcWeight ( const Entity &father, const Entity &son )
{
return son.geometry().volume() / father.geometry().volume();
}
const DiscreteFunctionSpaceType &space_;
mutable std::vector< EntitySeedType > childSeeds_;
mutable std::vector< std::vector<double> > childDofs_;
};
} // namespce Impl
template< class LFEMap, class FunctionSpace, template< class > class Storage >
struct DefaultLocalRestrictProlong< LocalFiniteElementSpace< LFEMap, FunctionSpace, Storage > >
: public Impl::DefaultLocalRestrictProlongLFE
< LocalFiniteElementSpace< LFEMap, FunctionSpace, Storage > >
{
typedef Impl::DefaultLocalRestrictProlongLFE
< LocalFiniteElementSpace< LFEMap, FunctionSpace, Storage > > BaseType;
using BaseType::BaseType;
};
template< class LFEMap, class FunctionSpace, template< class > class Storage >
struct DefaultLocalRestrictProlong< DiscontinuousLocalFiniteElementSpace< LFEMap, FunctionSpace, Storage > >
: public Impl::DefaultLocalRestrictProlongLFE
< DiscontinuousLocalFiniteElementSpace< LFEMap, FunctionSpace, Storage > >
{
typedef Impl::DefaultLocalRestrictProlongLFE
< DiscontinuousLocalFiniteElementSpace< LFEMap, FunctionSpace, Storage > > BaseType;
using BaseType::BaseType;
};
} // namespace Fem
} // namespace Dune
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment