Skip to content
Snippets Groups Projects
Commit ddffc20d authored by Uli Sack's avatar Uli Sack Committed by usack@PCPOOL.MI.FU-BERLIN.DE
Browse files

introduced quadrature order as member; can be set in constructor; adapted to new Base Class

[[Imported from SVN: r2589]]
parent d326be4c
Branches
No related tags found
No related merge requests found
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
#include "dune/ag-common/assemblers/localassembler.hh" #include "dune/ag-common/assemblers/localassembler.hh"
//! \TODO Please doc me ! //! \TODO Please doc me !
template <class GridType, class FunctionType> template <class GridType, class TrialLocalFE, class AnsatzLocalFE, class FunctionType >
class GeneralizedLaplaceAssembler : public LocalAssembler < GridType, Dune::FieldMatrix<double,1,1> > class GeneralizedLaplaceAssembler : public LinearLocalAssembler < GridType, TrialLocalFE, AnsatzLocalFE, Dune::FieldMatrix<double,1,1> >
{ {
private: private:
static const int dim = GridType::dimension; static const int dim = GridType::dimension;
...@@ -22,28 +22,27 @@ class GeneralizedLaplaceAssembler : public LocalAssembler < GridType, Dune::Fiel ...@@ -22,28 +22,27 @@ class GeneralizedLaplaceAssembler : public LocalAssembler < GridType, Dune::Fiel
public: public:
typedef typename Dune::FieldMatrix<double,1,1> T; typedef typename Dune::FieldMatrix<double,1,1> T;
typedef typename LocalAssembler < GridType ,T >::ElementPointer ElementPointer; typedef typename LinearLocalAssembler < GridType, TrialLocalFE, AnsatzLocalFE ,T >::ElementPointer ElementPointer;
typedef typename LocalAssembler < GridType ,T >::BoolMatrix BoolMatrix; typedef typename LinearLocalAssembler < GridType, TrialLocalFE, AnsatzLocalFE ,T >::BoolMatrix BoolMatrix;
typedef typename LocalAssembler < GridType ,T >::LocalMatrix LocalMatrix; typedef typename LinearLocalAssembler < GridType, TrialLocalFE, AnsatzLocalFE ,T >::LocalMatrix LocalMatrix;
GeneralizedLaplaceAssembler(FunctionType& coeffFunction): GeneralizedLaplaceAssembler(FunctionType& coeffFunction, int quadOrder=3):
coeffFunction(coeffFunction) coeffFunction_(coeffFunction),
quadOrder_(quadOrder)
{ {
if (not(FunctionType::DimRange==1 or FunctionType::DimRange==dim*dim)) if (not(FunctionType::DimRange==1 or FunctionType::DimRange==dim*dim))
DUNE_THROW(Dune::Exception,"Coefficient function for generalized Laplace has wrong dimension of range.\n Should be 1 or " << dim*dim << ", is " << FunctionType::DimRange << "."); DUNE_THROW(Dune::Exception,"Coefficient function for generalized Laplace has wrong dimension of range.\n Should be 1 or " << dim*dim << ", is " << FunctionType::DimRange << ".");
isGridFunction = (dynamic_cast<Dune::GridFunction<GridType, typename FunctionType::RangeFieldType, FunctionType::DimRange>*>(&coeffFunction)!=0); isGridFunction = (dynamic_cast<const Dune::GridFunction<GridType, typename FunctionType::RangeFieldType, FunctionType::DimRange>*>(&coeffFunction_)!=0);
} }
template <class TrialLocalFE, class AnsatzLocalFE> void indices(const ElementPointer& element, BoolMatrix& isNonZero, const TrialLocalFE& tFE, const AnsatzLocalFE& aFE) const
void indices(const ElementPointer& element, BoolMatrix& isNonZero, const TrialLocalFE& tFE, const AnsatzLocalFE& aFE)
{ {
isNonZero = true; isNonZero = true;
return; return;
} }
template <class TrialLocalFE, class AnsatzLocalFE> void assemble(const ElementPointer& element, LocalMatrix& localMatrix, const TrialLocalFE& tFE, const AnsatzLocalFE& aFE) const
void assemble(const ElementPointer& element, LocalMatrix& localMatrix, const TrialLocalFE& tFE, const AnsatzLocalFE& aFE)
{ {
typedef typename Dune::template FieldVector<double,dim> FVdim; typedef typename Dune::template FieldVector<double,dim> FVdim;
typedef typename Dune::template FieldMatrix<double,dim,dim> FMdimdim; typedef typename Dune::template FieldMatrix<double,dim,dim> FMdimdim;
...@@ -55,9 +54,8 @@ class GeneralizedLaplaceAssembler : public LocalAssembler < GridType, Dune::Fiel ...@@ -55,9 +54,8 @@ class GeneralizedLaplaceAssembler : public LocalAssembler < GridType, Dune::Fiel
localMatrix = 0.0; localMatrix = 0.0;
// get quadrature rule // get quadrature rule
const int order = 3; // const Dune::template QuadratureRule<double, dim>& quad = Dune::template QuadratureRules<double, dim>::rule(element->type(), quadOrder_);
// const Dune::template QuadratureRule<double, dim>& quad = Dune::template QuadratureRules<double, dim>::rule(element->type(), order); const Dune::template QuadratureRule<double, dim>& quad = QuadratureRuleCache<double, dim>::rule(element->type(), quadOrder_, IsRefinedLocalFiniteElement<TrialLocalFE>::value );
const Dune::template QuadratureRule<double, dim>& quad = QuadratureRuleCache<double, dim>::rule(element->type(), order, IsRefinedLocalFiniteElement<TrialLocalFE>::value );
// store gradients of shape functions and base functions // store gradients of shape functions and base functions
std::vector<JacobianType> referenceGradients(tFE.localBasis().size()); std::vector<JacobianType> referenceGradients(tFE.localBasis().size());
...@@ -89,7 +87,7 @@ class GeneralizedLaplaceAssembler : public LocalAssembler < GridType, Dune::Fiel ...@@ -89,7 +87,7 @@ class GeneralizedLaplaceAssembler : public LocalAssembler < GridType, Dune::Fiel
} }
// get coefficient(matrix) at quadrature point // get coefficient(matrix) at quadrature point
isGridFunction ? coeffFunction.evalalllocal(*element, quadPos, coeffs) : coeffFunction.evalall((*element).geometry().global(quadPos),coeffs); isGridFunction ? coeffFunction_.evalalllocal(*element, quadPos, coeffs) : coeffFunction_.evalall((*element).geometry().global(quadPos),coeffs);
// compute matrix entries // compute matrix entries
double z = quad[pt].weight() * integrationElement; double z = quad[pt].weight() * integrationElement;
...@@ -119,8 +117,9 @@ class GeneralizedLaplaceAssembler : public LocalAssembler < GridType, Dune::Fiel ...@@ -119,8 +117,9 @@ class GeneralizedLaplaceAssembler : public LocalAssembler < GridType, Dune::Fiel
} }
private: private:
const FunctionType& coeffFunction; const FunctionType& coeffFunction_;
const int quadOrder_;
bool isGridFunction; bool isGridFunction;
// Dune::GridFunction<GridType, typename FunctionType::RangeFieldType, FunctionType::DimRange>* isGridFunction; // Dune::GridFunction<GridType, typename FunctionType::RangeFieldType, FunctionType::DimRange>* isGridFunction;
}; };
......
...@@ -29,8 +29,8 @@ class L2FunctionalAssembler : ...@@ -29,8 +29,8 @@ class L2FunctionalAssembler :
//! create assembler for grid //! create assembler for grid
L2FunctionalAssembler(const Function& f, int order=2) : L2FunctionalAssembler(const Function& f, int order=2) :
f(f), f_(f),
order(order) order_(order)
{} {}
template <class TrialLocalFE> template <class TrialLocalFE>
...@@ -44,8 +44,8 @@ class L2FunctionalAssembler : ...@@ -44,8 +44,8 @@ class L2FunctionalAssembler :
localVector = 0.0; localVector = 0.0;
// get quadrature rule // get quadrature rule
// const Dune::template QuadratureRule<double, dim>& quad = Dune::template QuadratureRules<double, dim>::rule(element->type(), order); // const Dune::template QuadratureRule<double, dim>& quad = Dune::template QuadratureRules<double, dim>::rule(element->type(), order_);
const Dune::template QuadratureRule<double, dim>& quad = QuadratureRuleCache<double, dim>::rule(element->type(), order, IsRefinedLocalFiniteElement<TrialLocalFE>::value ); const Dune::template QuadratureRule<double, dim>& quad = QuadratureRuleCache<double, dim>::rule(element->type(), order_, IsRefinedLocalFiniteElement<TrialLocalFE>::value );
// store values of shape functions // store values of shape functions
std::vector<RangeType> values(tFE.localBasis().size()); std::vector<RangeType> values(tFE.localBasis().size());
...@@ -64,10 +64,10 @@ class L2FunctionalAssembler : ...@@ -64,10 +64,10 @@ class L2FunctionalAssembler :
// compute values of function // compute values of function
FV f_pos; FV f_pos;
if (dynamic_cast<const Dune::GridFunction<GridType,double,T::size>*>(&f)) if (dynamic_cast<const Dune::GridFunction<GridType,double,T::size>*>(&f_))
dynamic_cast<const Dune::GridFunction<GridType,double,T::size>*>(&f)->evalalllocal(*element, quadPos, f_pos); dynamic_cast<const Dune::GridFunction<GridType,double,T::size>*>(&f_)->evalalllocal(*element, quadPos, f_pos);
else else
f.evalall(element->geometry().global(quadPos), f_pos); f_.evalall(element->geometry().global(quadPos), f_pos);
// and vector entries // and vector entries
for(int i=0; i<values.size(); ++i) for(int i=0; i<values.size(); ++i)
...@@ -79,8 +79,8 @@ class L2FunctionalAssembler : ...@@ -79,8 +79,8 @@ class L2FunctionalAssembler :
} }
private: private:
const Function& f; const Function& f_;
const int order; const int order_;
}; };
#endif #endif
......
...@@ -19,14 +19,15 @@ class LaplaceAssembler : public LinearLocalAssembler <GridType, TrialLocalFE, An ...@@ -19,14 +19,15 @@ class LaplaceAssembler : public LinearLocalAssembler <GridType, TrialLocalFE, An
{ {
private: private:
static const int dim = GridType::dimension; static const int dim = GridType::dimension;
const int quadOrder_;
public: public:
typedef typename LocalAssembler < GridType, TrialLocalFE, AnsatzLocalFE, T >::ElementPointer ElementPointer; typedef typename LinearLocalAssembler < GridType, TrialLocalFE, AnsatzLocalFE, T >::ElementPointer ElementPointer;
typedef typename LocalAssembler < GridType, TrialLocalFE, AnsatzLocalFE, T >::BoolMatrix BoolMatrix; typedef typename LinearLocalAssembler < GridType, TrialLocalFE, AnsatzLocalFE, T >::BoolMatrix BoolMatrix;
typedef typename LocalAssembler < GridType, TrialLocalFE, AnsatzLocalFE, T >::LocalMatrix LocalMatrix; typedef typename LinearLocalAssembler < GridType, TrialLocalFE, AnsatzLocalFE, T >::LocalMatrix LocalMatrix;
LaplaceAssembler() LaplaceAssembler(int quadOrder=2):
quadOrder_(quadOrder)
{} {}
void indices(const ElementPointer& element, BoolMatrix& isNonZero, const TrialLocalFE& tFE, const AnsatzLocalFE& aFE) const void indices(const ElementPointer& element, BoolMatrix& isNonZero, const TrialLocalFE& tFE, const AnsatzLocalFE& aFE) const
...@@ -50,9 +51,8 @@ class LaplaceAssembler : public LinearLocalAssembler <GridType, TrialLocalFE, An ...@@ -50,9 +51,8 @@ class LaplaceAssembler : public LinearLocalAssembler <GridType, TrialLocalFE, An
localMatrix = 0.0; localMatrix = 0.0;
// get quadrature rule // get quadrature rule
const int order = 2; // const Dune::template QuadratureRule<double, dim>& quad = Dune::template QuadratureRules<double, dim>::rule(element->type(), quadOrder_);
// const Dune::template QuadratureRule<double, dim>& quad = Dune::template QuadratureRules<double, dim>::rule(element->type(), order); const Dune::template QuadratureRule<double, dim>& quad = QuadratureRuleCache<double, dim>::rule(element->type(), quadOrder_, IsRefinedLocalFiniteElement<TrialLocalFE>::value );
const Dune::template QuadratureRule<double, dim>& quad = QuadratureRuleCache<double, dim>::rule(element->type(), order, IsRefinedLocalFiniteElement<TrialLocalFE>::value );
// store gradients of shape functions and base functions // store gradients of shape functions and base functions
std::vector<JacobianType> referenceGradients(tFE.localBasis().size()); std::vector<JacobianType> referenceGradients(tFE.localBasis().size());
......
...@@ -15,18 +15,19 @@ ...@@ -15,18 +15,19 @@
//! \TODO Please doc me ! //! \TODO Please doc me !
template <class GridType, class TrialLocalFE, class AnsatzLocalFE, class T=Dune::FieldMatrix<double,1,1> > template <class GridType, class TrialLocalFE, class AnsatzLocalFE, class T=Dune::FieldMatrix<double,1,1> >
class LumpedMassAssembler : public LinearLocalAssembler <GridType, TrialLocalFE, AnsatzLocalFE, T > class LumpedMassAssembler : public LinearLocalAssembler < GridType, TrialLocalFE, AnsatzLocalFE, T >
{ {
private: private:
static const int dim = GridType::dimension; static const int dim = GridType::dimension;
const int quadOrder_;
public: public:
typedef typename LocalAssembler < GridType, TrialLocalFE, AnsatzLocalFE, T >::ElementPointer ElementPointer; typedef typename LinearLocalAssembler < GridType, TrialLocalFE, AnsatzLocalFE ,T >::ElementPointer ElementPointer;
typedef typename LocalAssembler < GridType, TrialLocalFE, AnsatzLocalFE, T >::BoolMatrix BoolMatrix; typedef typename LinearLocalAssembler < GridType, TrialLocalFE, AnsatzLocalFE ,T >::BoolMatrix BoolMatrix;
typedef typename LocalAssembler < GridType, TrialLocalFE, AnsatzLocalFE, T >::LocalMatrix LocalMatrix; typedef typename LinearLocalAssembler < GridType, TrialLocalFE, AnsatzLocalFE ,T >::LocalMatrix LocalMatrix;
LumpedMassAssembler() LumpedMassAssembler(int quadOrder=1):
quadOrder_(quadOrder)
{} {}
void indices(const ElementPointer& element, BoolMatrix& isNonZero, const TrialLocalFE& tFE, const AnsatzLocalFE& aFE) const void indices(const ElementPointer& element, BoolMatrix& isNonZero, const TrialLocalFE& tFE, const AnsatzLocalFE& aFE) const
...@@ -54,9 +55,8 @@ class LumpedMassAssembler : public LinearLocalAssembler <GridType, TrialLocalFE, ...@@ -54,9 +55,8 @@ class LumpedMassAssembler : public LinearLocalAssembler <GridType, TrialLocalFE,
localMatrix = 0.0; localMatrix = 0.0;
// get quadrature rule // get quadrature rule
const int order = 1; // const Dune::template QuadratureRule<double, dim>& quad = Dune::template QuadratureRules<double, dim>::rule(element->type(), quadOrder_);
// const Dune::template QuadratureRule<double, dim>& quad = Dune::template QuadratureRules<double, dim>::rule(element->type(), order); const Dune::template QuadratureRule<double, dim>& quad = QuadratureRuleCache<double, dim>::rule(element->type(), quadOrder_, IsRefinedLocalFiniteElement<TrialLocalFE>::value );
const Dune::template QuadratureRule<double, dim>& quad = QuadratureRuleCache<double, dim>::rule(element->type(), order, IsRefinedLocalFiniteElement<TrialLocalFE>::value );
// store values of shape functions // store values of shape functions
std::vector<RangeType> values(tFE.localBasis().size()); std::vector<RangeType> values(tFE.localBasis().size());
......
...@@ -13,20 +13,21 @@ ...@@ -13,20 +13,21 @@
#include "dune/ag-common/assemblers/localassembler.hh" #include "dune/ag-common/assemblers/localassembler.hh"
//! \TODO Please doc me ! //** \brief Local mass assembler **//
template <class GridType, class TrialLocalFE, class AnsatzLocalFE, class T=Dune::FieldMatrix<double,1,1> > template <class GridType, class TrialLocalFE, class AnsatzLocalFE, class T=Dune::FieldMatrix<double,1,1> >
class MassAssembler : public LinearLocalAssembler <GridType, TrialLocalFE, AnsatzLocalFE, T > class MassAssembler : public LinearLocalAssembler < GridType, TrialLocalFE, AnsatzLocalFE, T >
{ {
private: private:
static const int dim = GridType::dimension; static const int dim = GridType::dimension;
const int quadOrder_;
public: public:
typedef typename LocalAssembler < GridType, TrialLocalFE, AnsatzLocalFE, T >::ElementPointer ElementPointer; typedef typename LinearLocalAssembler < GridType, TrialLocalFE, AnsatzLocalFE ,T >::ElementPointer ElementPointer;
typedef typename LocalAssembler < GridType, TrialLocalFE, AnsatzLocalFE, T >::BoolMatrix BoolMatrix; typedef typename LinearLocalAssembler < GridType, TrialLocalFE, AnsatzLocalFE ,T >::BoolMatrix BoolMatrix;
typedef typename LocalAssembler < GridType, TrialLocalFE, AnsatzLocalFE, T >::LocalMatrix LocalMatrix; typedef typename LinearLocalAssembler < GridType, TrialLocalFE, AnsatzLocalFE ,T >::LocalMatrix LocalMatrix;
MassAssembler() MassAssembler(int quadOrder=2):
quadOrder_(quadOrder)
{} {}
void indices(const ElementPointer& element, BoolMatrix& isNonZero, const TrialLocalFE& tFE, const AnsatzLocalFE& aFE) const void indices(const ElementPointer& element, BoolMatrix& isNonZero, const TrialLocalFE& tFE, const AnsatzLocalFE& aFE) const
...@@ -40,15 +41,18 @@ class MassAssembler : public LinearLocalAssembler <GridType, TrialLocalFE, Ansat ...@@ -40,15 +41,18 @@ class MassAssembler : public LinearLocalAssembler <GridType, TrialLocalFE, Ansat
typedef typename Dune::template FieldMatrix<double,dim,dim> FMdimdim; typedef typename Dune::template FieldMatrix<double,dim,dim> FMdimdim;
typedef typename TrialLocalFE::Traits::LocalBasisType::Traits::RangeType RangeType; typedef typename TrialLocalFE::Traits::LocalBasisType::Traits::RangeType RangeType;
// Make sure we got suitable shape functions
assert(tFE.type() == element->type());
assert(aFE.type() == element->type());
int rows = localMatrix.N(); int rows = localMatrix.N();
int cols = localMatrix.M(); int cols = localMatrix.M();
localMatrix = 0.0; localMatrix = 0.0;
// get quadrature rule // get quadrature rule
const int order = 2; // const Dune::template QuadratureRule<double, dim>& quad = Dune::template QuadratureRules<double, dim>::rule(element->type(), quadOrder_);
// const Dune::template QuadratureRule<double, dim>& quad = Dune::template QuadratureRules<double, dim>::rule(element->type(), order); const Dune::template QuadratureRule<double, dim>& quad = QuadratureRuleCache<double, dim>::rule(element->type(), quadOrder_, IsRefinedLocalFiniteElement<TrialLocalFE>::value );
const Dune::template QuadratureRule<double, dim>& quad = QuadratureRuleCache<double, dim>::rule(element->type(), order, IsRefinedLocalFiniteElement<TrialLocalFE>::value );
// store values of shap functions // store values of shap functions
std::vector<RangeType> values(tFE.localBasis().size()); std::vector<RangeType> values(tFE.localBasis().size());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment