From cb2e8714d3076ade0d79edd3450e78561278dae0 Mon Sep 17 00:00:00 2001 From: IvBu <ivan.buntic@iws.uni-stuttgart.de> Date: Fri, 28 Feb 2025 14:56:16 +0100 Subject: [PATCH 1/2] Use DiscretizationDefaultLocalOperator. --- exercises/exercise-properties/mylocalresidual.hh | 10 ++++++---- exercises/solution/exercise-model/model.hh | 8 +++++--- .../solution/exercise-properties/mylocalresidual.hh | 10 ++++++---- slides/model.md | 6 +++--- 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/exercises/exercise-properties/mylocalresidual.hh b/exercises/exercise-properties/mylocalresidual.hh index 2ff017f1..c723184d 100644 --- a/exercises/exercise-properties/mylocalresidual.hh +++ b/exercises/exercise-properties/mylocalresidual.hh @@ -15,6 +15,7 @@ #include <dumux/common/properties.hh> #include <dumux/common/numeqvector.hh> +#include <dumux/discretization/defaultlocaloperator.hh> namespace Dumux { @@ -24,9 +25,10 @@ namespace Dumux * using the n-phase immiscible fully implicit models. */ template<class TypeTag> -class MyLocalResidual : public GetPropType<TypeTag, Properties::BaseLocalResidual> +class MyLocalResidual : public DiscretizationDefaultLocalOperator<TypeTag> { - using ParentType = GetPropType<TypeTag, Properties::BaseLocalResidual>; + using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>; + using ParentType = DiscretizationDefaultLocalOperator<TypeTag>; using Scalar = GetPropType<TypeTag, Properties::Scalar>; using Problem = GetPropType<TypeTag, Properties::Problem>; using NumEqVector = Dumux::NumEqVector<GetPropType<TypeTag, Properties::PrimaryVariables>>; @@ -34,10 +36,10 @@ class MyLocalResidual : public GetPropType<TypeTag, Properties::BaseLocalResidua using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView; using FluxVariables = GetPropType<TypeTag, Properties::FluxVariables>; using ElementFluxVariablesCache = typename GetPropType<TypeTag, Properties::GridFluxVariablesCache>::LocalView; - using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView; + using FVElementGeometry = typename GridGeometry::LocalView; using SubControlVolume = typename FVElementGeometry::SubControlVolume; using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace; - using GridView = typename GetPropType<TypeTag, Properties::GridGeometry>::GridView; + using GridView = typename GridGeometry::GridView; using Element = typename GridView::template Codim<0>::Entity; using EnergyLocalResidual = GetPropType<TypeTag, Properties::EnergyLocalResidual>; diff --git a/exercises/solution/exercise-model/model.hh b/exercises/solution/exercise-model/model.hh index de08d526..529740f5 100644 --- a/exercises/solution/exercise-model/model.hh +++ b/exercises/solution/exercise-model/model.hh @@ -17,6 +17,7 @@ #include <dumux/common/numeqvector.hh> #include <dumux/common/volumevariables.hh> #include <dumux/discretization/method.hh> +#include <dumux/discretization/defaultlocaloperator.hh> // The property tag is simply an empty struct with the name `NonlinearDiffusionModel` namespace Dumux::Properties::TTag { @@ -75,9 +76,11 @@ private: */ template<class TypeTag> class NonlinearDiffusionModelLocalResidual -: public GetPropType<TypeTag, Properties::BaseLocalResidual> +: public DiscretizationDefaultLocalOperator<TypeTag> { - using ParentType = GetPropType<TypeTag, Properties::BaseLocalResidual>; + using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>; + using ParentType = DiscretizationDefaultLocalOperator<TypeTag>; + using Scalar = GetPropType<TypeTag, Properties::Scalar>; using Problem = GetPropType<TypeTag, Properties::Problem>; using NumEqVector = Dumux::NumEqVector<GetPropType<TypeTag, Properties::PrimaryVariables>>; @@ -87,7 +90,6 @@ class NonlinearDiffusionModelLocalResidual using ElementVolumeVariables = typename GridVariables::GridVolumeVariables::LocalView; using ElementFluxVariablesCache = typename GridVariables::GridFluxVariablesCache::LocalView; - using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>; using FVElementGeometry = typename GridGeometry::LocalView; using SubControlVolume = typename GridGeometry::SubControlVolume; using SubControlVolumeFace = typename GridGeometry::SubControlVolumeFace; diff --git a/exercises/solution/exercise-properties/mylocalresidual.hh b/exercises/solution/exercise-properties/mylocalresidual.hh index fc7d3847..e35ad5a5 100644 --- a/exercises/solution/exercise-properties/mylocalresidual.hh +++ b/exercises/solution/exercise-properties/mylocalresidual.hh @@ -15,6 +15,7 @@ #include <dumux/common/properties.hh> #include <dumux/common/numeqvector.hh> +#include <dumux/discretization/defaultlocaloperator.hh> namespace Dumux { @@ -24,9 +25,10 @@ namespace Dumux * using the n-phase immiscible fully implicit models. */ template<class TypeTag> -class MyLocalResidual : public GetPropType<TypeTag, Properties::BaseLocalResidual> +class MyLocalResidual : public DiscretizationDefaultLocalOperator<TypeTag> { - using ParentType = GetPropType<TypeTag, Properties::BaseLocalResidual>; + using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>; + using ParentType = DiscretizationDefaultLocalOperator<TypeTag>; using Scalar = GetPropType<TypeTag, Properties::Scalar>; using Problem = GetPropType<TypeTag, Properties::Problem>; using NumEqVector = Dumux::NumEqVector<GetPropType<TypeTag, Properties::PrimaryVariables>>; @@ -34,10 +36,10 @@ class MyLocalResidual : public GetPropType<TypeTag, Properties::BaseLocalResidua using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView; using FluxVariables = GetPropType<TypeTag, Properties::FluxVariables>; using ElementFluxVariablesCache = typename GetPropType<TypeTag, Properties::GridFluxVariablesCache>::LocalView; - using FVElementGeometry = typename GetPropType<TypeTag, Properties::GridGeometry>::LocalView; + using FVElementGeometry = typename GridGeometry::LocalView; using SubControlVolume = typename FVElementGeometry::SubControlVolume; using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace; - using GridView = typename GetPropType<TypeTag, Properties::GridGeometry>::GridView; + using GridView = typename GridGeometry::GridView; using Element = typename GridView::template Codim<0>::Entity; using EnergyLocalResidual = GetPropType<TypeTag, Properties::EnergyLocalResidual>; diff --git a/slides/model.md b/slides/model.md index 52ea56d3..92c1cdcf 100644 --- a/slides/model.md +++ b/slides/model.md @@ -94,14 +94,14 @@ The local residual of the diffusion model: ```cpp template<class TypeTag> class DiffusionModelLocalResidual -: public GetPropType<TypeTag, Properties::BaseLocalResidual> +: public DiscretizationDefaultLocalOperator<TypeTag> { ... } ``` <span style="font-size: 0.4em; position: relative; top: -38px; color: gray;">File: `dumux/examples/diffusion/model.hh`</span> -Inherits from the `BaseLocalResidual`, which is chosen depending on the discretization scheme, here *Box scheme*. +Inherits from the `DiscretizationDefaultLocalOperator`, which is chosen depending on the discretization scheme, here *Box scheme*. ## Storage term ```cpp @@ -268,4 +268,4 @@ Implementation of a **nonlinear diffusion model** for denoising of an MRI image - Use model in test case - Customize volume variables -* Go to [Model excercise](https://git.iws.uni-stuttgart.de/dumux-repositories/dumux-course/tree/master/exercises/exercise-model#exercise-model-dumux-course) \ No newline at end of file +* Go to [Model excercise](https://git.iws.uni-stuttgart.de/dumux-repositories/dumux-course/tree/master/exercises/exercise-model#exercise-model-dumux-course) -- GitLab From 00875fa60be51b3f19ecd6bf9c0e7688f41c4e4b Mon Sep 17 00:00:00 2001 From: IvBu <ivan.buntic@iws.uni-stuttgart.de> Date: Fri, 7 Mar 2025 16:58:55 +0100 Subject: [PATCH 2/2] Update patches. --- .patches/exercise-model/exercise-model.patch | 22 +++++++++------- .../exercise-properties.patch | 26 +++++++++---------- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/.patches/exercise-model/exercise-model.patch b/.patches/exercise-model/exercise-model.patch index a84dc582..d29bc612 100644 --- a/.patches/exercise-model/exercise-model.patch +++ b/.patches/exercise-model/exercise-model.patch @@ -1,6 +1,6 @@ diff -ruN exercises/exercise-model/CMakeLists.txt exercises/solution/exercise-model/CMakeLists.txt ---- exercises/exercise-model/CMakeLists.txt 2025-03-07 10:42:02.615882961 +0100 -+++ exercises/solution/exercise-model/CMakeLists.txt 2025-03-07 10:42:02.621882923 +0100 +--- exercises/exercise-model/CMakeLists.txt 2025-03-07 16:57:19.034997903 +0100 ++++ exercises/solution/exercise-model/CMakeLists.txt 2025-03-07 16:57:19.038998197 +0100 @@ -3,5 +3,5 @@ dune_symlink_to_source_files(FILES images params.input) @@ -9,8 +9,8 @@ diff -ruN exercises/exercise-model/CMakeLists.txt exercises/solution/exercise-mo +dumux_add_test(NAME exercise_nonlineardiffusion_sol SOURCES main.cc) diff -ruN exercises/exercise-model/main.cc exercises/solution/exercise-model/main.cc ---- exercises/exercise-model/main.cc 2025-03-07 11:30:34.876192021 +0100 -+++ exercises/solution/exercise-model/main.cc 2025-03-07 11:30:34.878192008 +0100 +--- exercises/exercise-model/main.cc 2025-03-07 16:57:19.034997903 +0100 ++++ exercises/solution/exercise-model/main.cc 2025-03-07 16:57:19.038998197 +0100 @@ -30,6 +30,7 @@ #include <dumux/assembly/fvassembler.hh> @@ -148,8 +148,8 @@ diff -ruN exercises/exercise-model/main.cc exercises/solution/exercise-model/mai }// end main diff -ruN exercises/exercise-model/model.hh exercises/solution/exercise-model/model.hh --- exercises/exercise-model/model.hh 1970-01-01 01:00:00.000000000 +0100 -+++ exercises/solution/exercise-model/model.hh 2025-03-07 10:42:02.622882916 +0100 -@@ -0,0 +1,210 @@ ++++ exercises/solution/exercise-model/model.hh 2025-03-07 16:57:19.047998860 +0100 +@@ -0,0 +1,212 @@ +// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- +// vi: set et ts=4 sw=4 sts=4: +// @@ -169,6 +169,7 @@ diff -ruN exercises/exercise-model/model.hh exercises/solution/exercise-model/mo +#include <dumux/common/numeqvector.hh> +#include <dumux/common/volumevariables.hh> +#include <dumux/discretization/method.hh> ++#include <dumux/discretization/defaultlocaloperator.hh> + +// The property tag is simply an empty struct with the name `NonlinearDiffusionModel` +namespace Dumux::Properties::TTag { @@ -227,9 +228,11 @@ diff -ruN exercises/exercise-model/model.hh exercises/solution/exercise-model/mo + */ +template<class TypeTag> +class NonlinearDiffusionModelLocalResidual -+: public GetPropType<TypeTag, Properties::BaseLocalResidual> ++: public DiscretizationDefaultLocalOperator<TypeTag> +{ -+ using ParentType = GetPropType<TypeTag, Properties::BaseLocalResidual>; ++ using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>; ++ using ParentType = DiscretizationDefaultLocalOperator<TypeTag>; ++ + using Scalar = GetPropType<TypeTag, Properties::Scalar>; + using Problem = GetPropType<TypeTag, Properties::Problem>; + using NumEqVector = Dumux::NumEqVector<GetPropType<TypeTag, Properties::PrimaryVariables>>; @@ -239,7 +242,6 @@ diff -ruN exercises/exercise-model/model.hh exercises/solution/exercise-model/mo + using ElementVolumeVariables = typename GridVariables::GridVolumeVariables::LocalView; + using ElementFluxVariablesCache = typename GridVariables::GridFluxVariablesCache::LocalView; + -+ using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>; + using FVElementGeometry = typename GridGeometry::LocalView; + using SubControlVolume = typename GridGeometry::SubControlVolume; + using SubControlVolumeFace = typename GridGeometry::SubControlVolumeFace; @@ -361,7 +363,7 @@ diff -ruN exercises/exercise-model/model.hh exercises/solution/exercise-model/mo + +#endif diff -ruN exercises/exercise-model/README.md exercises/solution/exercise-model/README.md ---- exercises/exercise-model/README.md 2025-03-07 11:30:34.876192021 +0100 +--- exercises/exercise-model/README.md 2025-03-07 16:57:19.034997903 +0100 +++ exercises/solution/exercise-model/README.md 1970-01-01 01:00:00.000000000 +0100 @@ -1,195 +0,0 @@ -# Exercise Model (DuMuX course) diff --git a/.patches/exercise-properties/exercise-properties.patch b/.patches/exercise-properties/exercise-properties.patch index 05a072c2..8f2fe126 100644 --- a/.patches/exercise-properties/exercise-properties.patch +++ b/.patches/exercise-properties/exercise-properties.patch @@ -1,6 +1,6 @@ diff -ruN exercises/exercise-properties/CMakeLists.txt exercises/solution/exercise-properties/CMakeLists.txt ---- exercises/exercise-properties/CMakeLists.txt 2025-03-07 10:42:02.615882961 +0100 -+++ exercises/solution/exercise-properties/CMakeLists.txt 2025-03-07 10:42:02.622882916 +0100 +--- exercises/exercise-properties/CMakeLists.txt 2025-03-07 16:57:19.034997903 +0100 ++++ exercises/solution/exercise-properties/CMakeLists.txt 2025-03-07 16:57:19.038998197 +0100 @@ -1,8 +1,8 @@ # SPDX-FileCopyrightText: Copyright © DuMux-Course contributors, see AUTHORS.md in root folder # SPDX-License-Identifier: GPL-3.0-or-later @@ -13,9 +13,9 @@ diff -ruN exercises/exercise-properties/CMakeLists.txt exercises/solution/exerci # add a symlink for each input file diff -ruN exercises/exercise-properties/mylocalresidual.hh exercises/solution/exercise-properties/mylocalresidual.hh ---- exercises/exercise-properties/mylocalresidual.hh 2025-03-07 11:30:34.876192021 +0100 -+++ exercises/solution/exercise-properties/mylocalresidual.hh 2025-03-07 10:42:02.622882916 +0100 -@@ -59,8 +59,6 @@ +--- exercises/exercise-properties/mylocalresidual.hh 2025-03-07 16:57:19.047998860 +0100 ++++ exercises/solution/exercise-properties/mylocalresidual.hh 2025-03-07 16:57:19.047998860 +0100 +@@ -61,8 +61,6 @@ * \note The volVars can be different to allow computing * the implicit euler time derivative here */ @@ -24,7 +24,7 @@ diff -ruN exercises/exercise-properties/mylocalresidual.hh exercises/solution/ex NumEqVector computeStorage(const Problem& problem, const SubControlVolume& scv, const VolumeVariables& volVars) const -@@ -71,7 +69,6 @@ +@@ -73,7 +71,6 @@ { auto eqIdx = conti0EqIdx + phaseIdx; storage[eqIdx] = volVars.porosity() @@ -32,7 +32,7 @@ diff -ruN exercises/exercise-properties/mylocalresidual.hh exercises/solution/ex * volVars.saturation(phaseIdx); //! The energy storage in the fluid phase with index phaseIdx -@@ -95,8 +92,6 @@ +@@ -97,8 +94,6 @@ * \param scvf The sub control volume face to compute the flux on * \param elemFluxVarsCache The cache related to flux computation */ @@ -41,7 +41,7 @@ diff -ruN exercises/exercise-properties/mylocalresidual.hh exercises/solution/ex NumEqVector computeFlux(const Problem& problem, const Element& element, const FVElementGeometry& fvGeometry, -@@ -112,7 +107,7 @@ +@@ -114,7 +109,7 @@ { // the physical quantities for which we perform upwinding auto upwindTerm = [phaseIdx](const auto& volVars) @@ -51,8 +51,8 @@ diff -ruN exercises/exercise-properties/mylocalresidual.hh exercises/solution/ex auto eqIdx = conti0EqIdx + phaseIdx; flux[eqIdx] = fluxVars.advectiveFlux(phaseIdx, upwindTerm); diff -ruN exercises/exercise-properties/problem.hh exercises/solution/exercise-properties/problem.hh ---- exercises/exercise-properties/problem.hh 2025-03-07 11:30:34.876192021 +0100 -+++ exercises/solution/exercise-properties/problem.hh 2025-03-07 10:42:02.622882916 +0100 +--- exercises/exercise-properties/problem.hh 2025-03-07 16:57:19.035997976 +0100 ++++ exercises/solution/exercise-properties/problem.hh 2025-03-07 16:57:19.039998271 +0100 @@ -11,6 +11,7 @@ #ifndef DUMUX_INCOMPRESSIBLE_TWOP_TEST_PROBLEM_HH #define DUMUX_INCOMPRESSIBLE_TWOP_TEST_PROBLEM_HH @@ -77,8 +77,8 @@ diff -ruN exercises/exercise-properties/problem.hh exercises/solution/exercise-p return values; } diff -ruN exercises/exercise-properties/properties.hh exercises/solution/exercise-properties/properties.hh ---- exercises/exercise-properties/properties.hh 2025-03-07 11:30:34.876192021 +0100 -+++ exercises/solution/exercise-properties/properties.hh 2025-03-07 10:42:02.622882916 +0100 +--- exercises/exercise-properties/properties.hh 2025-03-07 16:57:19.035997976 +0100 ++++ exercises/solution/exercise-properties/properties.hh 2025-03-07 16:57:19.039998271 +0100 @@ -27,9 +27,7 @@ #include "spatialparams.hh" @@ -103,7 +103,7 @@ diff -ruN exercises/exercise-properties/properties.hh exercises/solution/exercis // Set the fluid system template<class TypeTag> diff -ruN exercises/exercise-properties/README.md exercises/solution/exercise-properties/README.md ---- exercises/exercise-properties/README.md 2025-02-26 11:38:46.811817734 +0100 +--- exercises/exercise-properties/README.md 2025-02-28 14:22:14.796953365 +0100 +++ exercises/solution/exercise-properties/README.md 1970-01-01 01:00:00.000000000 +0100 @@ -1,75 +0,0 @@ -# Exercise Properties (DuMuX course) -- GitLab