From ad369fcd5ea446e8a25b724bdcccaffea956dd53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carsten=20Gr=C3=A4ser?= <graeser@mi.fu-berlin.de> Date: Fri, 8 Jan 2010 12:39:13 +0000 Subject: [PATCH] Use new virtual interface if DUNE_VIRT* is not enabled [[Imported from SVN: r3131]] --- .../genericmultigridtransfer.hh | 53 +++++++++++++++---- 1 file changed, 43 insertions(+), 10 deletions(-) diff --git a/dune-solvers/transferoperators/genericmultigridtransfer.hh b/dune-solvers/transferoperators/genericmultigridtransfer.hh index a19f1853..83a9450e 100644 --- a/dune-solvers/transferoperators/genericmultigridtransfer.hh +++ b/dune-solvers/transferoperators/genericmultigridtransfer.hh @@ -8,6 +8,7 @@ #include <dune/grid/common/genericreferenceelements.hh> +#include <dune/localfunctions/common/virtualinterface.hh> #include <dune/localfunctions/p1.hh> #include <dune/localfunctions/q1.hh> #include <dune/localfunctions/prismp1.hh> @@ -31,23 +32,50 @@ class GenericMultigridTransfer { template <class DT, class RT, int dim> struct P1ElementFactory { - const Dune::LocalFiniteElementInterface<DT, RT, dim>* get(const Dune::GeometryType& type) { - if (type.isSimplex()) +#ifdef DUNE_VIRTUAL_SHAPEFUNCTIONS + typedef Dune::LocalFiniteElementInterface<DT, RT, dim> type; + + const type* get(const Dune::GeometryType& gt) { + if (gt.isSimplex()) return &simplexBaseSet_; - else if (type.isCube()) + else if (gt.isCube()) return &cubeBaseSet_; - else if (type.isPrism()) + else if (gt.isPrism()) // This cast is necessary because otherwise the code wouldn't compile for dim!=3 return (Dune::LocalFiniteElementInterface<DT, RT, dim>*)&prismBaseSet_; else - DUNE_THROW(Dune::NotImplemented, "transfer operators for " << type); + DUNE_THROW(Dune::NotImplemented, "transfer operators for " << gt); } private: - Dune::P1LocalFiniteElement<DT, RT, dim> simplexBaseSet_; Dune::Q1LocalFiniteElement<DT, RT, dim> cubeBaseSet_; Dune::PrismP1LocalFiniteElement<DT, RT> prismBaseSet_; +#else + + private: + typedef typename Dune::P1LocalFiniteElement<DT, RT, dim>::Traits LocalBasisTraits; + + public: + typedef Dune::C0LocalFiniteElementVirtualInterface<LocalBasisTraits> type; + + const type* get(const Dune::GeometryType& gt) { + if (gt.isSimplex()) + return &simplexBaseSet_; + else if (gt.isCube()) + return &cubeBaseSet_; + else if (gt.isPrism()) + // This cast is necessary because otherwise the code wouldn't compile for dim!=3 + return (type*)&prismBaseSet_; + else + DUNE_THROW(Dune::NotImplemented, "transfer operators for " << gt); + } + + private: + Dune::C0LocalFiniteElementVirtualImp<Dune::P1LocalFiniteElement<DT, RT, dim> > simplexBaseSet_; + Dune::C0LocalFiniteElementVirtualImp<Dune::Q1LocalFiniteElement<DT, RT, dim> > cubeBaseSet_; + Dune::C0LocalFiniteElementVirtualImp<Dune::PrismP1LocalFiniteElement<DT, RT> > prismBaseSet_; +#endif }; @@ -110,6 +138,7 @@ public: // A factory for the shape functions P1ElementFactory<ctype,field_type,dim> p1ElementFactory; + typedef typename P1ElementFactory<ctype,field_type,dim>::type FEType; matrix.setSize(rows,cols); matrix.setBuildMode(TransferOperatorType::random); @@ -131,7 +160,8 @@ public: typedef typename EntityType::HierarchicIterator HierarchicIterator; // Get local finite element - const Dune::LocalFiniteElementInterface<ctype, field_type, dim>* coarseBaseSet = p1ElementFactory.get(cIt->type()); +// const Dune::LocalFiniteElementInterface<ctype, field_type, dim>* coarseBaseSet = p1ElementFactory.get(cIt->type()); + const FEType* coarseBaseSet = p1ElementFactory.get(cIt->type()); const int numCoarseBaseFct = coarseBaseSet->localBasis().size(); @@ -152,7 +182,8 @@ public: const typename EntityType::Geometry& fGeometryInFather = fIt->geometryInFather(); // Get local finite element - const Dune::LocalFiniteElementInterface<ctype, field_type, dim>* fineBaseSet = p1ElementFactory.get(fIt->type());; +// const Dune::LocalFiniteElementInterface<ctype, field_type, dim>* fineBaseSet = p1ElementFactory.get(fIt->type());; + const FEType* fineBaseSet = p1ElementFactory.get(fIt->type());; const int numFineBaseFct = fineBaseSet->localBasis().size(); @@ -193,7 +224,8 @@ public: for (; cIt != cEndIt; ++cIt) { // Get local finite element - const Dune::LocalFiniteElementInterface<ctype, field_type, dim>* coarseBaseSet = p1ElementFactory.get(cIt->type()); +// const Dune::LocalFiniteElementInterface<ctype, field_type, dim>* coarseBaseSet = p1ElementFactory.get(cIt->type()); + const FEType* coarseBaseSet = p1ElementFactory.get(cIt->type()); const int numCoarseBaseFct = coarseBaseSet->localBasis().size(); @@ -217,7 +249,8 @@ public: const typename EntityType::Geometry& fGeometryInFather = fIt->geometryInFather(); // Get local finite element - const Dune::LocalFiniteElementInterface<ctype, field_type, dim>* fineBaseSet = p1ElementFactory.get(fIt->type()); +// const Dune::LocalFiniteElementInterface<ctype, field_type, dim>* fineBaseSet = p1ElementFactory.get(fIt->type()); + const FEType* fineBaseSet = p1ElementFactory.get(fIt->type()); const int numFineBaseFct = fineBaseSet->localBasis().size(); -- GitLab