From b83a172e329cbb597838682a8d05befd66782256 Mon Sep 17 00:00:00 2001 From: Robert Kloefkorn <robertk@ucar.edu> Date: Sat, 7 Dec 2013 15:11:16 +0100 Subject: [PATCH] model determins whether advection or diffusion is enabled. --- dune/fem-dg/test/advdiff/Makefile.am | 4 -- dune/fem-dg/test/advdiff/models.hh | 4 ++ dune/fem-dg/test/advdiff/problemcreator.hh | 3 +- dune/fem-dg/test/advdiff/steppertraits.hh | 52 ++++++++++++++-------- 4 files changed, 40 insertions(+), 23 deletions(-) diff --git a/dune/fem-dg/test/advdiff/Makefile.am b/dune/fem-dg/test/advdiff/Makefile.am index 37f02506..92bb98e8 100644 --- a/dune/fem-dg/test/advdiff/Makefile.am +++ b/dune/fem-dg/test/advdiff/Makefile.am @@ -22,9 +22,6 @@ GRIDDIM = 2 DIMRANGE = 1 FLUX = 1 # LLF 1, HLL 2 -ADVECTION=0 -DIFFUSION=1 - #USE_OMP=-fopenmp # INFO SPACE OPERATOR: @@ -40,7 +37,6 @@ check_PROGRAMS = advdiff advdiffonep advdiff12 # quasiadvdiff quasiadvdiff12 pla AM_CPPFLAGS = $(USE_OMP) -I../../problems/advdiff $(ALL_PKG_CPPFLAGS) -DGRIDDIM=$(GRIDDIM) \ -D$(GRIDTYPE) $(DUNEMPICPPFLAGS) \ - -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/models.hh b/dune/fem-dg/test/advdiff/models.hh index d429fa9f..4339388e 100644 --- a/dune/fem-dg/test/advdiff/models.hh +++ b/dune/fem-dg/test/advdiff/models.hh @@ -88,6 +88,10 @@ template <class GridPartType,class ProblemImp> class HeatEqnModel : public DefaultModel < HeatEqnModelTraits< GridPartType > > { public: + // for heat equations advection is disabled + static const bool hasAdvection = false ; + static const bool hasDiffusion = true ; + typedef ProblemImp ProblemType ; static const int ConstantVelocity = ProblemType :: ConstantVelocity; diff --git a/dune/fem-dg/test/advdiff/problemcreator.hh b/dune/fem-dg/test/advdiff/problemcreator.hh index 03aaaba4..3defe42b 100644 --- a/dune/fem-dg/test/advdiff/problemcreator.hh +++ b/dune/fem-dg/test/advdiff/problemcreator.hh @@ -25,7 +25,7 @@ struct ProblemGenerator Dune::Fem::FunctionSpace< double, double, GridType::dimension, DIMRANGE>, false > ProblemType; - //typedef HeatProblemType ProblemType; + // define problem type here if interface should be avoided template< class GridPart > struct Traits @@ -33,6 +33,7 @@ struct ProblemGenerator typedef ProblemType InitialDataType; typedef HeatEqnModel< GridPart, InitialDataType > ModelType; typedef LLFFlux< ModelType > FluxType; + //typedef UpwindFlux< ModelType > FluxType; // choice of diffusion flux (see diffusionflux.hh for methods) static const Dune :: DGDiffusionFluxIdentifier PrimalDiffusionFluxId diff --git a/dune/fem-dg/test/advdiff/steppertraits.hh b/dune/fem-dg/test/advdiff/steppertraits.hh index 00f0260e..ed88b3bd 100644 --- a/dune/fem-dg/test/advdiff/steppertraits.hh +++ b/dune/fem-dg/test/advdiff/steppertraits.hh @@ -63,27 +63,43 @@ private: typedef Dune :: DGDiffusionOperator< ModelType, FluxType, DiffusionFluxId, polynomialOrder > DgDiffusionType; + + // default is that both are enabled + template < bool advection, bool diffusion > + struct OperatorChooser + { + typedef DgType FullOperatorType; + typedef DgDiffusionType ImplicitOperatorType; + typedef DgAdvectionType ExplicitOperatorType; + }; + + // advection operator only, i.e. linear advection equation + template < bool advection > + struct OperatorChooser< advection, false > + { + typedef DgAdvectionType FullOperatorType; + typedef FullOperatorType ImplicitOperatorType; + typedef FullOperatorType ExplicitOperatorType; + }; + + // diffusion operator only, i.e. for the heat equation + template < bool diffusion > + struct OperatorChooser< false, diffusion > + { + typedef DgDiffusionType FullOperatorType; + typedef FullOperatorType ImplicitOperatorType; + typedef FullOperatorType ExplicitOperatorType; + }; public: + static const bool advection = ModelType :: hasAdvection ; + static const bool diffusion = ModelType :: hasDiffusion ; -#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 + typedef OperatorChooser< advection, diffusion > OperatorChooserType ; + + typedef typename OperatorChooserType :: FullOperatorType FullOperatorType; + typedef typename OperatorChooserType :: ImplicitOperatorType ImplicitOperatorType; + typedef typename OperatorChooserType :: ExplicitOperatorType ExplicitOperatorType; // The discrete function for the unknown solution is defined in the DgOperator typedef typename DgType :: DestinationType DiscreteFunctionType; -- GitLab