From 46a5085401d7e934424dfa6e11365623793ed30f Mon Sep 17 00:00:00 2001 From: leonidas <leon.keim@googlemail.com> Date: Wed, 17 Jul 2024 11:48:54 +0200 Subject: [PATCH] [properties][slides] Proposal to change the introduction --- slides/properties.md | 86 +++++++++++++++++++++++--------------------- 1 file changed, 45 insertions(+), 41 deletions(-) diff --git a/slides/properties.md b/slides/properties.md index 81b522be..fc7d6e45 100644 --- a/slides/properties.md +++ b/slides/properties.md @@ -1,20 +1,19 @@ --- title: The DuMuX property system -subtitle: Flexible compile-time parameters +subtitle: Flexible compile-time customization --- -# Parameters vs. properties +# System Design +## Goals -## Parameters vs. properties - -- <span style="color:#3498DB">Parameters</span> are set at __run-time__ - <p>A default value may be used if the user does not provide one at run-time</p> -- <span style="color:#3498DB">Properties</span> are known and set at __compile-time__ - <p> - Can be used e.g. as template parameters (__types__ or values with `constexpr` specifier); - No run-time penalty, enable compiler to optimize - </p> +- Easy to change parts of the simulation + - Add a energy equation +- Reuse specializations efficiently + - Test various discretization schemes for same application +- Group properties of the simulations + - Improves readability +# A C++ solution ## Template parameters - C++ supports _generic programming_ via __templates__ @@ -85,13 +84,44 @@ DGGO2 dggo2(gfs, cd, gfs, cf, lop, mbe); A usual way to group template parameters ```cpp -struct MyGridOperatorTraits +template<class PV, class FSY, class FST, class SSY, class SST, class PT, class MT, class SR> +struct TwoPVolumeVariablesTraits { - using FromGFS = ...; - // ... + using PrimaryVariables = PV; + using FluidSystem = FSY; + using FluidState = FST; + using SolidSystem = SSY; + using SolidState = SST; + using PermeabilityType = PT; + using ModelTraits = MT; + using SaturationReconstruction = SR; +}; +``` +## Traits classes + +Making it usable using a single template parameter +```c++ +template<class TypeTag> +struct VolumeVariables<TypeTag, TTag::TwoP> +{ +private: + using PV = GetPropType<TypeTag, Properties::PrimaryVariables>; + using FSY = GetPropType<TypeTag, Properties::FluidSystem>; + using FST = GetPropType<TypeTag, Properties::FluidState>; + using SSY = GetPropType<TypeTag, Properties::SolidSystem>; + using SST = GetPropType<TypeTag, Properties::SolidState>; + using MT = GetPropType<TypeTag, Properties::ModelTraits>; + using PT = typename GetPropType<TypeTag, Properties::SpatialParams>::PermeabilityType; + using DM = typename GetPropType<TypeTag, Properties::GridGeometry>::DiscretizationMethod; + static constexpr bool enableIS = getPropValue<TypeTag, Properties::EnableBoxInterfaceSolver>(); + // class used for scv-wise reconstruction of nonwetting phase saturations + using SR = TwoPScvSaturationReconstruction<DM, enableIS>; + + using Traits = TwoPVolumeVariablesTraits<PV, FSY, FST, SSY, SST, PT, MT, SR>; +public: + using type = TwoPVolumeVariables<Traits>; }; -using GOF0 = Dune::PDELab::GridOperator<MyGridOperatorTraits>; ``` ## Inheriting from traits classes @@ -131,32 +161,6 @@ template<typename T, int size> struct ValueType<Dune::FieldVector<T, size>> { using type = T; }; ``` - -## Type traits - -A usage example - - -```cpp -// expecting Container to export value_type -template<typename Container> -void someFunction(const Container& c) { - using V = typename Container::value_type; - // do something with V - // ... -} -``` - -```cpp -// using type traits -template<typename Container> -void someFunction(const Container& c) { - using V = typename ValueType<Container>::type; - // do something with V - // ... -} -``` - # The DuMuX Property System ## Property System Design -- GitLab