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 ...@@ -93,101 +93,120 @@ namespace Dune
const std::vector< BasisFunctionSetType >& childBasisSets_; const std::vector< BasisFunctionSetType >& childBasisSets_;
const std::vector< std::vector<double> >& childDofs_; const std::vector< std::vector<double> >& childDofs_;
}; };
} // namespce Impl
// a detailed description is given in MR308 // a detailed description is given in MR308
// https://gitlab.dune-project.org/dune-fem/dune-fem/merge_requests/308 // https://gitlab.dune-project.org/dune-fem/dune-fem/merge_requests/308
template< class LFEMap, class FunctionSpace, template< class > class Storage > template< class LFESpace >
struct DefaultLocalRestrictProlong< LocalFiniteElementSpace< LFEMap, FunctionSpace, Storage > > struct DefaultLocalRestrictProlongLFE
{
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 )
{ {
} typedef LFESpace DiscreteFunctionSpaceType;
typedef DefaultLocalRestrictProlongLFE< DiscreteFunctionSpaceType > ThisType;
//! restrict data to father typedef typename DiscreteFunctionSpaceType::DomainFieldType DomainFieldType;
template< class LFFather, class LFSon, class LocalGeometry > typedef typename DiscreteFunctionSpaceType::BasisFunctionSetType BasisFunctionSetType;
void restrictLocal ( LFFather &lfFather, const LFSon &lfSon, typedef typename DiscreteFunctionSpaceType::EntityType EntityType;
const LocalGeometry &geometryInFather, bool initialize ) const typedef typename EntityType::LocalGeometry LocalGeometryType;
{ typedef typename EntityType::EntitySeed EntitySeedType;
const int numDofs = lfFather.numDofs();
assert( lfFather.numDofs() == lfSon.numDofs() ); 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()); //! restrict data to father
childDofs_.push_back(std::vector<double>(lfSon.size())); template< class LFFather, class LFSon, class LocalGeometry >
for (unsigned int i=0;i<lfSon.size();++i) void restrictLocal ( LFFather &lfFather, const LFSon &lfSon,
childDofs_.back()[i] = lfSon[i]; 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> childSeeds_.push_back(lfSon.entity().seed());
void restrictFinalize( LFFather &lfFather ) const childDofs_.push_back(std::vector<double>(lfSon.size()));
{ for (unsigned int i=0;i<lfSon.size();++i)
const int numDofs = lfFather.numDofs(); childDofs_.back()[i] = lfSon[i];
std::vector< EntityType > childEntities(childSeeds_.size()); }
std::vector< BasisFunctionSetType > childBasisSets(childSeeds_.size());
for (unsigned int i=0; i<childSeeds_.size();++i) template <class LFFather>
void restrictFinalize( LFFather &lfFather ) const
{ {
childEntities[i] = space_.gridPart().entity( childSeeds_[i] ); const int numDofs = lfFather.numDofs();
childBasisSets[i] = space_.basisFunctionSet( childEntities[i] ); 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_ ), //! prolong data to children
lfFather.localDofVector() ); template< class LFFather, class LFSon, class LocalGeometry >
} void prolongLocal ( const LFFather &lfFather, LFSon &lfSon,
const LocalGeometry &geometryInFather, bool initialize ) const
//! prolong data to children {
template< class LFFather, class LFSon, class LocalGeometry > const int numDofs = lfFather.numDofs();
void prolongLocal ( const LFFather &lfFather, LFSon &lfSon, assert( lfFather.numDofs() == lfSon.numDofs() );
const LocalGeometry &geometryInFather, bool initialize ) const DynamicVector<double> sonDofs( numDofs );
{ space_.interpolation(lfSon.entity())
const int numDofs = lfFather.numDofs(); ( Impl::FatherWrapper<LocalGeometry,LFFather>(geometryInFather,lfFather),
assert( lfFather.numDofs() == lfSon.numDofs() ); sonDofs );
DynamicVector<double> sonDofs( numDofs ); for (int i=0;i<numDofs;++i)
space_.interpolation(lfSon.entity()) lfSon[i] = sonDofs[i];
( Impl::FatherWrapper<LocalGeometry,LFFather>(geometryInFather,lfFather), }
sonDofs );
for (int i=0;i<numDofs;++i) //! do discrete functions need a communication after restriction / prolongation?
lfSon[i] = sonDofs[i]; bool needCommunication () const { return true; }
}
protected:
//! do discrete functions need a communication after restriction / prolongation? template< class Entity >
bool needCommunication () const { return true; } static DomainFieldType calcWeight ( const Entity &father, const Entity &son )
{
protected: return son.geometry().volume() / father.geometry().volume();
template< class Entity > }
static DomainFieldType calcWeight ( const Entity &father, const Entity &son ) const DiscreteFunctionSpaceType &space_;
{ mutable std::vector< EntitySeedType > childSeeds_;
return son.geometry().volume() / father.geometry().volume(); mutable std::vector< std::vector<double> > childDofs_;
} };
const DiscreteFunctionSpaceType &space_; } // namespce Impl
mutable std::vector< EntitySeedType > childSeeds_;
mutable std::vector< std::vector<double> > childDofs_; 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 Fem
} // namespace Dune } // 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