Commit 1f64c687 authored by Robert K's avatar Robert K

[feature][DynamicLagrangeDiscreteFunctionSpace] Allow polynomial order

to be chosen dynamically. The only LagrangeDiscreteFunctionSpace behaves
as before.
parent d9bde6bd
Pipeline #17747 failed with stage
in 23 minutes and 50 seconds
......@@ -17,12 +17,14 @@ namespace Dune
// DefaultLocalRestrictProlong
// ---------------------------
template< class FunctionSpaceType, class GridPartType, int order, template< class > class StorageType >
class DefaultLocalRestrictProlong< LagrangeDiscreteFunctionSpace< FunctionSpaceType, GridPartType, order, StorageType > >
: public LagrangeLocalRestrictProlong< typename GridPartType::GridType, order >
template< class FunctionSpaceType, class GridPartType, int maxPolOrder, template< class > class StorageType >
class DefaultLocalRestrictProlong< LagrangeDiscreteFunctionSpace< FunctionSpaceType, GridPartType, maxPolOrder, StorageType > >
: public LagrangeLocalRestrictProlong< typename GridPartType::GridType,
// extract maxPolynomialOrder from space because maxPolOrder could be -1
LagrangeDiscreteFunctionSpace< FunctionSpaceType, GridPartType, maxPolOrder, StorageType >::maxPolynomialOrder >
{
public:
DefaultLocalRestrictProlong ( const LagrangeDiscreteFunctionSpace< FunctionSpaceType, GridPartType, order, StorageType > & )
DefaultLocalRestrictProlong ( const LagrangeDiscreteFunctionSpace< FunctionSpaceType, GridPartType, maxPolOrder, StorageType > & )
{ }
};
......
......@@ -13,6 +13,8 @@ namespace Dune
namespace Capabilities
{
// LagrangeDiscreteFunctionSpace
//------------------------------
template< class FunctionSpace, class GridPart, int polOrder, template< class > class Storage >
struct hasFixedPolynomialOrder< LagrangeDiscreteFunctionSpace< FunctionSpace, GridPart, polOrder, Storage > >
......@@ -63,6 +65,54 @@ namespace Dune
static const bool v = true;
};
// DynamicLagrangeDiscreteFunctionSpace
//-------------------------------------
template< class FunctionSpace, class GridPart, template< class > class Storage >
struct hasFixedPolynomialOrder< DynamicLagrangeDiscreteFunctionSpace< FunctionSpace, GridPart, Storage > >
{
static const bool v = true;
};
// hasStaticPolynomialOrder we use default
template< class FunctionSpace, class GridPart, template< class > class Storage >
struct isContinuous< DynamicLagrangeDiscreteFunctionSpace< FunctionSpace, GridPart, Storage > >
{
static const bool v = Dune::Fem::GridPartCapabilities::isConforming< GridPart >::v;
};
template< class FunctionSpace, class GridPart, template< class > class Storage >
struct isLocalized< DynamicLagrangeDiscreteFunctionSpace< FunctionSpace, GridPart, Storage > >
{
static const bool v = true;
};
template< class FunctionSpace, class GridPart, template< class > class Storage >
struct isAdaptive< DynamicLagrangeDiscreteFunctionSpace< FunctionSpace, GridPart, Storage > >
{
static const bool v = true;
};
template< class FunctionSpace, class GridPart, template< class > class Storage >
struct threadSafe< DynamicLagrangeDiscreteFunctionSpace< FunctionSpace, GridPart, Storage > >
{
static const bool v = false;
};
template< class FunctionSpace, class GridPart, template< class > class Storage >
struct viewThreadSafe< DynamicLagrangeDiscreteFunctionSpace< FunctionSpace, GridPart, Storage > >
{
static const bool v = true;
};
} // namespace Capabilities
} // namespace Fem
......
......@@ -13,6 +13,9 @@ namespace Dune
template< class FunctionSpace, class GridPart, int order, template< class > class Storage >
class LagrangeDiscreteFunctionSpace;
template< class FunctionSpace, class GridPart, template< class > class Storage >
using DynamicLagrangeDiscreteFunctionSpace = LagrangeDiscreteFunctionSpace< FunctionSpace, GridPart, -1, Storage >;
} // namespace Fem
} // namespace Dune
......
......@@ -16,16 +16,16 @@ namespace Dune
// LagrangeLocalInterpolation
// --------------------------
template< class GridPart, int order, class BasisFunctionSet >
template< class GridPart, int maxOrder, class BasisFunctionSet >
class LagrangeLocalInterpolation
{
typedef LagrangeLocalInterpolation< GridPart, order, BasisFunctionSet > ThisType;
typedef LagrangeLocalInterpolation< GridPart, maxOrder, BasisFunctionSet > ThisType;
public:
/** \brief basis function set type */
typedef BasisFunctionSet BasisFunctionSetType;
/** \brief point set type */
typedef LagrangePointSet< GridPart, order > LagrangePointSetType;
typedef LagrangePointSet< GridPart, maxOrder > LagrangePointSetType;
private:
typedef typename BasisFunctionSetType::FunctionSpaceType FunctionSpaceType;
......
......@@ -404,14 +404,14 @@ namespace Dune
template< class Field, int dim, unsigned int polOrder >
template< class Field, int dim, unsigned int maxPolOrder >
struct LagrangePointSetTraits
{
//! field type of coordinates
typedef Field FieldType;
//! polynomial order of corresponding base functions
static const unsigned int polynomialOrder = polOrder;
static const unsigned int maxPolynomialOrder = maxPolOrder;
//! dimension of points
static const int dimension = dim;
......@@ -423,26 +423,26 @@ namespace Dune
template< typename ct, int quaddim >
struct PointListTraits
{
typedef LagrangePointListImplementation< ct, 0, 0, polynomialOrder >
typedef LagrangePointListImplementation< ct, 0, 0, maxPolynomialOrder >
PointQuadratureType;
typedef LagrangePointListImplementation< ct, 0, 1, polynomialOrder >
typedef LagrangePointListImplementation< ct, 0, 1, maxPolynomialOrder >
LineQuadratureType;
typedef LagrangePointListImplementation< ct, 0, dimension, polynomialOrder >
typedef LagrangePointListImplementation< ct, 0, dimension, maxPolynomialOrder >
SimplexQuadratureType;
typedef LagrangePointListImplementation< ct, (1 << dimension)-1, dimension, polynomialOrder >
typedef LagrangePointListImplementation< ct, (1 << dimension)-1, dimension, maxPolynomialOrder >
CubeQuadratureType;
typedef LagrangePointListImplementation< ct, (1 << (dimension-1)), dimension, polynomialOrder >
typedef LagrangePointListImplementation< ct, (1 << (dimension-1)), dimension, maxPolynomialOrder >
PrismQuadratureType;
typedef LagrangePointListImplementation< ct, (1 << (dimension-1))-1, dimension, polynomialOrder >
typedef LagrangePointListImplementation< ct, (1 << (dimension-1))-1, dimension, maxPolynomialOrder >
PyramidQuadratureType;
//! type of integration point list implemementation
typedef LagrangePointListInterface< ct, quaddim, polynomialOrder > IntegrationPointListType;
typedef LagrangePointListInterface< ct, quaddim, maxPolynomialOrder > IntegrationPointListType;
typedef int QuadratureKeyType ;
};
......@@ -456,7 +456,7 @@ namespace Dune
template< class GridPart, unsigned int polOrder >
template< class GridPart, unsigned int maxPolOrder >
class LagrangePointSet;
......@@ -695,7 +695,7 @@ namespace Dune
static const int dimension = BaseType::dimension;
enum { polynomialOrder = Traits::polynomialOrder };
enum { maxPolynomialOrder = Traits::maxPolynomialOrder };
typedef typename BaseType::CoordinateType CoordinateType;
typedef typename Traits::CoordinateType PointType;
......@@ -704,7 +704,7 @@ namespace Dune
struct Codim
{
//! type of iterator over DoF numbers in a subentity
typedef SubEntityLagrangePointIterator< GridPartType, codim, polynomialOrder >
typedef SubEntityLagrangePointIterator< GridPartType, codim, maxPolynomialOrder >
SubEntityIteratorType;
};
......@@ -714,8 +714,8 @@ namespace Dune
public:
//! constructor
LagrangePointSet ( const GeometryType &geometry, const int order )
: BaseType( geometry, order ), lagrangePointList_( this->quadImp().ipList() )
LagrangePointSet ( const GeometryType &geometry, const int polynomialOrder )
: BaseType( geometry, polynomialOrder ), lagrangePointList_( this->quadImp().ipList() )
{}
//! copy constructor
......
......@@ -61,7 +61,7 @@ namespace Dune
const auto &refSon = Dune::ReferenceElements< ctype, dimension >::general( lfSon.entity().type() );
const LagrangePointSetType &pointSet = lagrangePointSet( lfFather.entity() );
const LagrangePointSetType &pointSet = lagrangePointSet( lfFather.entity(), lfFather.order() );
const EntityDofIterator send = pointSet.template endSubEntity< 0 >( 0 );
for( EntityDofIterator sit = pointSet.template beginSubEntity< 0 >( 0 ); sit != send; ++sit )
......@@ -86,7 +86,7 @@ namespace Dune
{
static const int dimRange = LFFather::dimRange;
const LagrangePointSetType &pointSet = lagrangePointSet( lfSon.entity() );
const LagrangePointSetType &pointSet = lagrangePointSet( lfSon.entity(), lfSon.order() );
const EntityDofIterator send = pointSet.template endSubEntity< 0 >( 0 );
for( EntityDofIterator sit = pointSet.template beginSubEntity< 0 >( 0 ); sit != send; ++sit )
......@@ -106,17 +106,17 @@ namespace Dune
protected:
template< class Entity >
const LagrangePointSetType &lagrangePointSet ( const Entity &entity ) const
const LagrangePointSetType &lagrangePointSet ( const Entity &entity, const int order ) const
{
return lagrangePointSet( entity.type() );
return lagrangePointSet( entity.type(), order );
}
const LagrangePointSetType &lagrangePointSet ( const GeometryType &type ) const
const LagrangePointSetType &lagrangePointSet ( const GeometryType &type, const int order ) const
{
typedef typename LagrangePointSetMapType::iterator Iterator;
Iterator it = lagrangePointSet_.find( type );
if( it == lagrangePointSet_.end() )
it = lagrangePointSet_.insert( it, std::make_pair( type, new LagrangePointSetType( type, ord ) ) );
it = lagrangePointSet_.insert( it, std::make_pair( type, new LagrangePointSetType( type, order ) ) );
assert( it->second != 0 );
return *(it->second);
}
......
......@@ -160,21 +160,22 @@ namespace Dune
* \tparam FunctionSpace function space
* \tparam polOrder polynomial order
*/
template< class FunctionSpace, int polOrder >
template< class FunctionSpace, int maxPolOrder >
class LagrangeShapeFunctionSet
: public SimpleShapeFunctionSet<
typename LagrangeShapeFunctionFactory< FunctionSpace, polOrder >::ShapeFunctionType
typename LagrangeShapeFunctionFactory< FunctionSpace, maxPolOrder >::ShapeFunctionType
>
{
static_assert( (FunctionSpace::dimRange == 1), "FunctionSpace must be scalar." );
typedef LagrangeShapeFunctionFactory< FunctionSpace, polOrder > ShapeFunctionFactoryType;
typedef LagrangeShapeFunctionFactory< FunctionSpace, maxPolOrder > ShapeFunctionFactoryType;
typedef SimpleShapeFunctionSet< typename ShapeFunctionFactoryType::ShapeFunctionType > BaseType;
public:
LagrangeShapeFunctionSet ( const Dune::GeometryType &type )
: BaseType( ShapeFunctionFactoryType( type ) )
{}
LagrangeShapeFunctionSet ( const Dune::GeometryType &type, const int order = maxPolOrder )
: BaseType( ShapeFunctionFactoryType( type, order ) )
{
}
};
......@@ -288,12 +289,12 @@ namespace Dune
// Implementation of LagrangeShapeFunctionFactory
// ----------------------------------------------
template< class FunctionSpace, int polOrder >
const int LagrangeShapeFunctionFactory< FunctionSpace, polOrder >::dimension;
template< class FunctionSpace, int maxPolOrder >
const int LagrangeShapeFunctionFactory< FunctionSpace, maxPolOrder >::dimension;
template< class FunctionSpace, int polOrder >
inline int LagrangeShapeFunctionFactory< FunctionSpace, polOrder >
template< class FunctionSpace, int maxPolOrder >
inline int LagrangeShapeFunctionFactory< FunctionSpace, maxPolOrder >
::order () const
{
return order_;
......
This diff is collapsed.
......@@ -29,7 +29,8 @@ namespace Dune
: gridPart_( gridPart ),
pointSet_( pointSet ),
polOrd_( polOrd )
{}
{
}
bool operator== ( const ThisType &other ) const
{
......
......@@ -248,8 +248,7 @@ void algorithm ( GridPartType &gridPart,
int turn,
const bool locallyAdaptive )
{
const unsigned int polOrder
= DiscreteFunctionSpaceType :: polynomialOrder + 1;
const unsigned int polOrder = solution.space().order() + 1;
ExactSolutionType fexact;
GridExactSolutionType f( "exact solution", fexact, gridPart, polOrder );
......
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