From ee8eeb58147da2e8814245f278813cff6c73e960 Mon Sep 17 00:00:00 2001
From: Robert Kloefkorn <robertk@ucar.edu>
Date: Sat, 7 Dec 2013 14:16:22 +0100
Subject: [PATCH] allow to select advection, diffusion, or both.

---
 dune/fem-dg/test/advdiff/Makefile.am       |   8 +-
 dune/fem-dg/test/advdiff/parameter         |  11 +-
 dune/fem-dg/test/advdiff/problemcreator.hh |  10 +-
 dune/fem-dg/test/advdiff/steppertraits.hh  | 112 +++++++++++++++++++++
 4 files changed, 130 insertions(+), 11 deletions(-)
 create mode 100644 dune/fem-dg/test/advdiff/steppertraits.hh

diff --git a/dune/fem-dg/test/advdiff/Makefile.am b/dune/fem-dg/test/advdiff/Makefile.am
index 7e95ba12..a9ceae34 100644
--- a/dune/fem-dg/test/advdiff/Makefile.am
+++ b/dune/fem-dg/test/advdiff/Makefile.am
@@ -1,7 +1,7 @@
 # install these headers 
 advdiffdir=$(includedir)/test/advdiff
-advdiff_HEADERS = models.hh  problemcreator.hh \
-problem.hh  problemQuasiHeatEqn.hh
+advdiff_HEADERS = models.hh  deformationalflow.hh problemcreator.hh \
+problem.hh  problemQuasiHeatEqn.hh steppertraits.hh
 
 LDADD = $(ALL_PKG_LDFLAGS) $(ALL_PKG_LIBS) $(LOCAL_LIBS) $(DUNEMPILDFLAGS) $(DUNEMPILIBS)
 
@@ -22,6 +22,9 @@ GRIDDIM  = 2
 DIMRANGE = 1
 FLUX = 1    # LLF 1, HLL 2
 
+ADVECTION=0
+DIFFUSION=1
+
 #USE_OMP=-fopenmp
 
 # INFO SPACE OPERATOR:
@@ -37,6 +40,7 @@ check_PROGRAMS = advdiff advdiffonep advdiff12 # quasiadvdiff quasiadvdiff12 pla
 
 AM_CPPFLAGS = $(USE_OMP) -I../../problems/advdiff  $(ALL_PKG_CPPFLAGS) -DGRIDDIM=$(GRIDDIM) \
 							-D$(GRIDTYPE) $(DUNEMPICPPFLAGS) -DFEMTIMER \
+              -DADVECTION=$(ADVECTION)  -DDIFFUSION=$(DIFFUSION) \
 							-DDIMRANGE=$(DIMRANGE) -DFLUX=$(FLUX) -DPRIMALDG -DUSE_ASSERT_THROW
 AM_LDFLAGS = $(ALL_PKG_LDFLAGS) $(LAPACK_LDFLAGS) $(USE_OMP)
 
diff --git a/dune/fem-dg/test/advdiff/parameter b/dune/fem-dg/test/advdiff/parameter
index ce6d324d..c83c54de 100644
--- a/dune/fem-dg/test/advdiff/parameter
+++ b/dune/fem-dg/test/advdiff/parameter
@@ -39,14 +39,9 @@ femhowto.zvelocity: 0.    # the only advection part for the linear heat eqn
 # DOMAIN
 #-------
 
-fem.io.macroGridFile_1d: ../macrogrids/unitcube1.dgf
-fem.io.macroGridFile_2d: ../macrogrids/unitcube2_per.dgf
-#fem.io.macroGridFile_2d: ../macrogrids/unitcube2_unstr.dgf
-#fem.io.macroGridFile_2d: ../macrogrids/test2.dgf
-#fem.io.macroGridFile_2d: ../macrogrids/unitgrid2d_unstr_2.dgf
-#fem.io.macroGridFile_2d: ../macrogrids/stability.dgf
-#fem.io.macroGridFile_2d: ../macrogrids/cdgpaper_test.dgf
-fem.io.macroGridFile_3d: ../macrogrids/unitcube3.dgf
+fem.io.macroGridFile_1d: ../grids/unitcube1.dgf
+fem.io.macroGridFile_2d: ../grids/unitcube2.dgf
+fem.io.macroGridFile_3d: ../grids/unitcube3.dgf
 
 
 # SOLVER
diff --git a/dune/fem-dg/test/advdiff/problemcreator.hh b/dune/fem-dg/test/advdiff/problemcreator.hh
index d6095fa3..03aaaba4 100644
--- a/dune/fem-dg/test/advdiff/problemcreator.hh
+++ b/dune/fem-dg/test/advdiff/problemcreator.hh
@@ -10,6 +10,8 @@
 
 // local includes
 #include <dune/fem-dg/operator/fluxes/diffusionflux.hh>
+#include <dune/fem-dg/stepper/base.hh>
+
 #include "problem.hh"
 #include "problemQuasiHeatEqn.hh"
 #include "deformationalflow.hh"
@@ -94,6 +96,12 @@ struct ProblemGenerator
   }
 };
 
-//#include <dune/fem-dg/stepper/advectionstepper.hh>
+#include "steppertraits.hh"
+
+#if ADVECTION && DIFFUSION 
+#include <dune/fem-dg/stepper/advectiondiffusionstepper.hh>
+#else 
+#include <dune/fem-dg/stepper/advectionstepper.hh>
+#endif
 
 #endif // FEMHOWTO_HEATSTEPPER_HH
diff --git a/dune/fem-dg/test/advdiff/steppertraits.hh b/dune/fem-dg/test/advdiff/steppertraits.hh
new file mode 100644
index 00000000..00f0260e
--- /dev/null
+++ b/dune/fem-dg/test/advdiff/steppertraits.hh
@@ -0,0 +1,112 @@
+#ifndef DUNE_STEPPERTRAITS_HH
+#define DUNE_STEPPERTRAITS_HH
+
+#include <dune/fem/gridpart/adaptiveleafgridpart.hh>
+#include <dune/fem/gridpart/idgridpart.hh>
+#include <dune/fem/solver/odesolver.hh>
+#include <dune/fem/solver/pardginverseoperators.hh>
+
+#include <dune/fem-dg/operator/dg/dgoperatorchoice.hh>
+
+template <class GridImp,
+          class ProblemTraits, 
+          int polOrd>
+struct StepperTraits 
+{
+  enum { polynomialOrder = polOrd };
+
+  // type of Grid
+  typedef GridImp                                   GridType;
+
+  // Choose a suitable GridView
+  typedef Dune :: Fem :: DGAdaptiveLeafGridPart< GridType >       HostGridPartType;
+  typedef HostGridPartType  GridPartType ;
+  //typedef Dune :: Fem :: IdGridPart< HostGridPartType >       GridPartType;
+
+  // problem dependent types 
+  typedef typename ProblemTraits :: template Traits< GridPartType > :: InitialDataType   InitialDataType;
+  typedef typename ProblemTraits :: template Traits< GridPartType > :: ModelType         ModelType;
+  typedef typename ProblemTraits :: template Traits< GridPartType > :: FluxType          FluxType;
+  static const Dune::DGDiffusionFluxIdentifier DiffusionFluxId 
+    = ProblemTraits :: template Traits< GridPartType > ::PrimalDiffusionFluxId ;
+
+private:
+  // The DG Operator (using 2 Passes)
+  // The first operator is sum of the other two
+  // The other two are needed for semi-implicit time discretization
+#ifdef LIMITER
+  #if (not defined EULER) and (defined FLUXDG)
+  #warning "DGAdvectionDiffusionOperator: using LIMITER."
+    typedef Dune :: DGLimitedAdvectionDiffusionOperator< 
+                        ModelType, FluxType, DiffusionFluxId, polynomialOrder >  DgType;
+  #else
+  #warning "DGAdvectionDiffusionOperator: LIMITER can NOT be used. Not supported -> LIMITER, no EULER, no FLUXDG."
+    typedef Dune :: DGAdvectionDiffusionOperator< 
+                        ModelType, FluxType, DiffusionFluxId, polynomialOrder >  DgType;
+  #endif
+  #ifndef HIGHER_ORDER_FV 
+  #warning "DGAdvectionOperator: using LIMITER."
+    typedef Dune :: DGLimitedAdvectionOperator< ModelType, FluxType,
+                                                DiffusionFluxId, polynomialOrder >      DgAdvectionType;
+  #else 
+  #warning "DGAdvectionOperator: using HIGHER ORDER FV."
+    typedef Dune :: DGLimitedAdvectionOperator< ModelType, FluxType,
+                                                DiffusionFluxId, -1 >      DgAdvectionType;
+  #endif
+#else // no LIMITER 
+#warning "No limiter is applied to the numerical solution !!"
+  typedef Dune :: DGAdvectionDiffusionOperator< ModelType, FluxType,
+                                                DiffusionFluxId,  polynomialOrder >   DgType;
+  typedef Dune :: DGAdvectionOperator< ModelType, FluxType,
+                                       DiffusionFluxId, polynomialOrder >      DgAdvectionType;
+#endif                                       
+  typedef Dune :: DGDiffusionOperator< ModelType, FluxType,
+                                       DiffusionFluxId, polynomialOrder >      DgDiffusionType;
+
+public:
+
+
+#if ADVECTION && DIFFUSION
+#warning "Using Advection-Diffusion Operator"
+  typedef DgType          FullOperatorType;
+  typedef DgDiffusionType ImplicitOperatorType;
+  typedef DgAdvectionType ExplicitOperatorType;
+#elif ADVECTION 
+#warning "Using Advection Operator"
+  typedef DgAdvectionType  FullOperatorType;
+  typedef FullOperatorType ImplicitOperatorType;
+  typedef FullOperatorType ExplicitOperatorType;
+#elif DIFFUSION 
+#warning "Using Diffusion Operator"
+  typedef DgDiffusionType  FullOperatorType;
+  typedef FullOperatorType ImplicitOperatorType;
+  typedef FullOperatorType ExplicitOperatorType;
+#else 
+#error "Either ADVECTION or DIFFUSSION has to be set" 
+#endif
+
+  // The discrete function for the unknown solution is defined in the DgOperator
+  typedef typename DgType :: DestinationType                         DiscreteFunctionType;
+
+  // The indicator function in case of limiting 
+  typedef typename DgAdvectionType :: IndicatorType                  IndicatorType;
+
+  // ... as well as the Space type
+  typedef typename DgType :: SpaceType                               DiscreteSpaceType;
+
+  // The ODE Solvers                                                         /*@LST1S@*/
+  typedef DuneODE :: OdeSolverInterface< DiscreteFunctionType > OdeSolverType ;
+
+  // type of restriction/prolongation projection for adaptive simulations 
+  typedef Dune :: Fem :: RestrictProlongDefault< DiscreteFunctionType > RestrictionProlongationType;
+
+  // type of IOTuple 
+  typedef Dune::tuple< DiscreteFunctionType*, DiscreteFunctionType*, IndicatorType* >  IOTupleType;
+
+  // type of linear solver for implicit ode
+  typedef Dune::Fem::ParDGGeneralizedMinResInverseOperator< DiscreteFunctionType >  LinearInverseOperatorType;
+  typedef Dune::Fem::ParDGGeneralizedMinResInverseOperator< DiscreteFunctionType >  LinearInverseImplicitOperatorType;
+
+};
+
+#endif
-- 
GitLab