From c6e7719f9125d2dab63d1028d05049b2d3a67d62 Mon Sep 17 00:00:00 2001
From: Timo Koch <timok@simula.no>
Date: Thu, 27 Feb 2025 11:31:28 +0100
Subject: [PATCH] [discretization] Specialize LocalOperator for all
 discreizations

---
 dumux/discretization/box.hh                     | 13 +++++++++++++
 dumux/discretization/ccmpfa.hh                  | 16 ++++++++++++++++
 dumux/discretization/cctpfa.hh                  | 15 +++++++++++++++
 dumux/discretization/fcdiamond.hh               | 15 +++++++++++++++
 dumux/discretization/fcstaggered.hh             |  8 ++++++++
 dumux/discretization/pq1bubble.hh               | 13 +++++++++++++
 dumux/discretization/staggered.hh               | 15 +++++++++++++++
 dumux/multidomain/facet/box/properties.hh       | 15 +++++++++++++++
 .../facet/cellcentered/mpfa/properties.hh       | 16 +++++++++++++++-
 .../facet/cellcentered/tpfa/properties.hh       | 17 +++++++++++++++++
 10 files changed, 142 insertions(+), 1 deletion(-)

diff --git a/dumux/discretization/box.hh b/dumux/discretization/box.hh
index 9bf9a02a08..2b4908a971 100644
--- a/dumux/discretization/box.hh
+++ b/dumux/discretization/box.hh
@@ -27,6 +27,7 @@
 #include <dumux/discretization/method.hh>
 #include <dumux/discretization/fvproperties.hh>
 #include <dumux/discretization/localdoftraits.hh>
+#include <dumux/discretization/defaultlocaloperator.hh>
 
 #include <dumux/discretization/cvfe/elementboundarytypes.hh>
 #include <dumux/discretization/cvfe/gridfluxvariablescache.hh>
@@ -138,6 +139,18 @@ struct LocalDofTraits<GridView, DiscretizationMethods::Box>
     static constexpr int numCubeElementDofs = (1<<dim);
 };
 
+template<class TypeTag>
+concept BoxModel = std::is_same_v<
+    typename GetPropType<TypeTag, Properties::GridGeometry>::DiscretizationMethod,
+    DiscretizationMethods::Box
+>;
+
+template<BoxModel TypeTag>
+struct DiscretizationDefaultLocalOperator<TypeTag>
+{
+    using type = CVFELocalResidual<TypeTag>;
+};
+
 } // end namespace Dumux:Detail
 
 #endif
diff --git a/dumux/discretization/ccmpfa.hh b/dumux/discretization/ccmpfa.hh
index 04eedc99af..96ad23fe76 100644
--- a/dumux/discretization/ccmpfa.hh
+++ b/dumux/discretization/ccmpfa.hh
@@ -13,6 +13,8 @@
 #ifndef DUMUX_DISCRETIZATION_CC_MPFA_HH
 #define DUMUX_DISCRETIZATION_CC_MPFA_HH
 
+#include <type_traits>
+
 #include <dune/common/reservedvector.hh>
 
 #include <dumux/common/properties.hh>
@@ -21,7 +23,9 @@
 
 #include <dumux/assembly/cclocalresidual.hh>
 
+#include <dumux/discretization/method.hh>
 #include <dumux/discretization/fvproperties.hh>
+#include <dumux/discretization/defaultlocaloperator.hh>
 
 #include <dumux/discretization/cellcentered/elementsolution.hh>
 #include <dumux/discretization/cellcentered/elementboundarytypes.hh>
@@ -171,6 +175,18 @@ public:
     using BoundaryTypes = std::decay_t<decltype(std::declval<Problem>().boundaryTypes(std::declval<Element>(), std::declval<SubControlVolumeFace>()))>;
 };
 
+template<class TypeTag>
+concept CCMpfaModel = std::is_same_v<
+    typename GetPropType<TypeTag, Properties::GridGeometry>::DiscretizationMethod,
+    DiscretizationMethods::CCMpfa
+>;
+
+template<CCMpfaModel TypeTag>
+struct DiscretizationDefaultLocalOperator<TypeTag>
+{
+    using type = CCLocalResidual<TypeTag>;
+};
+
 } // end namespace Detail
 
 } // namespace Dumux
diff --git a/dumux/discretization/cctpfa.hh b/dumux/discretization/cctpfa.hh
index 4e2864fe01..89686af5ce 100644
--- a/dumux/discretization/cctpfa.hh
+++ b/dumux/discretization/cctpfa.hh
@@ -14,6 +14,8 @@
 #ifndef DUMUX_DISCRETIZATION_CC_TPFA_HH
 #define DUMUX_DISCRETIZATION_CC_TPFA_HH
 
+#include <type_traits>
+
 #include <dumux/common/properties.hh>
 #include <dumux/common/boundaryflag.hh>
 #include <dumux/common/typetraits/problem.hh>
@@ -22,6 +24,7 @@
 
 #include <dumux/discretization/method.hh>
 #include <dumux/discretization/fvproperties.hh>
+#include <dumux/discretization/defaultlocaloperator.hh>
 
 #include <dumux/discretization/cellcentered/subcontrolvolume.hh>
 #include <dumux/discretization/cellcentered/elementboundarytypes.hh>
@@ -107,6 +110,18 @@ public:
     using BoundaryTypes = std::decay_t<decltype(std::declval<Problem>().boundaryTypes(std::declval<Element>(), std::declval<SubControlVolumeFace>()))>;
 };
 
+template<class TypeTag>
+concept CCTpfaModel = std::is_same_v<
+    typename GetPropType<TypeTag, Properties::GridGeometry>::DiscretizationMethod,
+    DiscretizationMethods::CCTpfa
+>;
+
+template<CCTpfaModel TypeTag>
+struct DiscretizationDefaultLocalOperator<TypeTag>
+{
+    using type = CCLocalResidual<TypeTag>;
+};
+
 } // end namespace Detail
 
 } // namespace Dumux
diff --git a/dumux/discretization/fcdiamond.hh b/dumux/discretization/fcdiamond.hh
index d8292f2e55..ac57965594 100644
--- a/dumux/discretization/fcdiamond.hh
+++ b/dumux/discretization/fcdiamond.hh
@@ -14,6 +14,8 @@
 #ifndef DUMUX_DISCRETIZATION_FACECENTERED_DIAMOND_HH
 #define DUMUX_DISCRETIZATION_FACECENTERED_DIAMOND_HH
 
+#include <type_traits>
+
 #include <dumux/common/properties.hh>
 #include <dumux/common/typetraits/problem.hh>
 
@@ -21,6 +23,7 @@
 #include <dumux/discretization/method.hh>
 #include <dumux/discretization/fvproperties.hh>
 #include <dumux/discretization/localdoftraits.hh>
+#include <dumux/discretization/defaultlocaloperator.hh>
 #include <dumux/flux/fluxvariablescaching.hh>
 
 #include <dumux/discretization/facecentered/diamond/fvgridgeometry.hh>
@@ -142,6 +145,18 @@ struct LocalDofTraits<GridView, DiscretizationMethods::FCDiamond>
     static constexpr int numCubeElementDofs = 2*dim;
 };
 
+template<class TypeTag>
+concept FaceCenteredDiamondModel = std::is_same_v<
+    typename GetPropType<TypeTag, Properties::GridGeometry>::DiscretizationMethod,
+    DiscretizationMethods::FCDiamond
+>;
+
+template<FaceCenteredDiamondModel TypeTag>
+struct DiscretizationDefaultLocalOperator<TypeTag>
+{
+    using type = CVFELocalResidual<TypeTag>;
+};
+
 } // end namespace Dumux::Detail
 
 #endif
diff --git a/dumux/discretization/fcstaggered.hh b/dumux/discretization/fcstaggered.hh
index 7c9c6fdff4..f61757b4e7 100644
--- a/dumux/discretization/fcstaggered.hh
+++ b/dumux/discretization/fcstaggered.hh
@@ -15,6 +15,8 @@
 #ifndef DUMUX_DISCRETIZATION_FACECENTERED_STAGGERED_HH
 #define DUMUX_DISCRETIZATION_FACECENTERED_STAGGERED_HH
 
+#include <type_traits>
+
 #include <dumux/common/properties.hh>
 #include <dumux/common/typetraits/problem.hh>
 
@@ -123,6 +125,12 @@ public:
     using BoundaryTypes = std::decay_t<decltype(std::declval<Problem>().boundaryTypes(std::declval<Element>(), std::declval<SubControlVolumeFace>()))>;
 };
 
+template<class TypeTag>
+concept FaceCenteredStaggeredModel = std::is_same_v<
+    typename GetPropType<TypeTag, Properties::GridGeometry>::DiscretizationMethod,
+    DiscretizationMethods::FCStaggered
+>;
+
 } // end namespace Detail
 
 #endif
diff --git a/dumux/discretization/pq1bubble.hh b/dumux/discretization/pq1bubble.hh
index 5cca5d8923..fd2614284d 100644
--- a/dumux/discretization/pq1bubble.hh
+++ b/dumux/discretization/pq1bubble.hh
@@ -27,6 +27,7 @@
 #include <dumux/discretization/method.hh>
 #include <dumux/discretization/fvproperties.hh>
 #include <dumux/discretization/localdoftraits.hh>
+#include <dumux/discretization/defaultlocaloperator.hh>
 
 #include <dumux/discretization/cvfe/elementboundarytypes.hh>
 #include <dumux/discretization/cvfe/gridfluxvariablescache.hh>
@@ -138,6 +139,18 @@ struct LocalDofTraits<GridView, DiscretizationMethods::PQ1Bubble>
     static constexpr int numCubeElementDofs = (1<<dim) + 1;
 };
 
+template<class TypeTag>
+concept PQ1BubbleModel = std::is_same_v<
+    typename GetPropType<TypeTag, Properties::GridGeometry>::DiscretizationMethod,
+    DiscretizationMethods::PQ1Bubble
+>;
+
+template<PQ1BubbleModel TypeTag>
+struct DiscretizationDefaultLocalOperator<TypeTag>
+{
+    using type = CVFELocalResidual<TypeTag>;
+};
+
 } // end namespace Dumux::Detail
 
 #endif
diff --git a/dumux/discretization/staggered.hh b/dumux/discretization/staggered.hh
index 98bf9b7f9c..c1947674e2 100644
--- a/dumux/discretization/staggered.hh
+++ b/dumux/discretization/staggered.hh
@@ -15,11 +15,14 @@
 #ifndef DUMUX_DISCRETIZATION_STAGGERD_HH
 #define DUMUX_DISCRETIZATION_STAGGERD_HH
 
+#include <type_traits>
+
 #include <dumux/common/properties.hh>
 #include <dumux/common/typetraits/problem.hh>
 
 #include <dumux/discretization/method.hh>
 #include <dumux/discretization/fvproperties.hh>
+#include <dumux/discretization/defaultlocaloperator.hh>
 #include <dumux/flux/fluxvariablescaching.hh>
 
 #include <dumux/discretization/cellcentered/elementboundarytypes.hh>
@@ -205,6 +208,18 @@ public:
     using BoundaryTypes = std::decay_t<decltype(std::declval<Problem>().boundaryTypes(std::declval<Element>(), std::declval<SubControlVolumeFace>()))>;
 };
 
+template<class TypeTag>
+concept StaggeredModel = std::is_same_v<
+    typename GetPropType<TypeTag, Properties::GridGeometry>::DiscretizationMethod,
+    DiscretizationMethods::Staggered
+>;
+
+template<StaggeredModel TypeTag>
+struct DiscretizationDefaultLocalOperator<TypeTag>
+{
+    using type = StaggeredLocalResidual<TypeTag>;
+};
+
 } // end namespace Detail
 
 } // namespace Dumux
diff --git a/dumux/multidomain/facet/box/properties.hh b/dumux/multidomain/facet/box/properties.hh
index 3309821863..11121a0a32 100644
--- a/dumux/multidomain/facet/box/properties.hh
+++ b/dumux/multidomain/facet/box/properties.hh
@@ -19,6 +19,7 @@
 
 #include <dumux/common/properties.hh>
 #include <dumux/discretization/box.hh>
+#include <dumux/discretization/defaultlocaloperator.hh>
 
 #include <dumux/multidomain/facet/box/darcyslaw.hh>
 #include <dumux/multidomain/facet/box/fickslaw.hh>
@@ -87,6 +88,20 @@ public:
 };
 
 } // namespace Properties
+
+namespace Detail {
+
+template<class T>
+concept BoxFacetCouplingModel = BoxModel<T> && Dumux::Properties::inheritsFrom<Properties::TTag::BoxFacetCouplingModel, T>();
+
+template<BoxFacetCouplingModel TypeTag>
+struct DiscretizationDefaultLocalOperator<TypeTag>
+{
+    using type = BoxFacetCouplingLocalResidual<TypeTag>;
+};
+
+} // namespace Detail
+
 } // namespace Dumux
 
 #endif
diff --git a/dumux/multidomain/facet/cellcentered/mpfa/properties.hh b/dumux/multidomain/facet/cellcentered/mpfa/properties.hh
index ebc96b34fd..ac08864d42 100644
--- a/dumux/multidomain/facet/cellcentered/mpfa/properties.hh
+++ b/dumux/multidomain/facet/cellcentered/mpfa/properties.hh
@@ -19,7 +19,7 @@
 
 #include <dumux/common/properties.hh>
 #include <dumux/discretization/ccmpfa.hh>
-
+#include <dumux/discretization/defaultlocaloperator.hh>
 #include <dumux/multidomain/facet/cellcentered/upwindscheme.hh>
 #include <dumux/multidomain/facet/cellcentered/localresidual.hh>
 #include <dumux/multidomain/facet/cellcentered/mpfa/interactionvolume.hh>
@@ -78,6 +78,20 @@ struct FluxVariables<TypeTag, TTag::CCMpfaFacetCouplingModel>
 };
 
 } // namespace Properties
+
+namespace Detail {
+
+template<class T>
+concept CCMpfaFacetCouplingModel = CCMpfaModel<T> && Dumux::Properties::inheritsFrom<Properties::TTag::CCMpfaFacetCouplingModel, T>();
+
+template<CCMpfaFacetCouplingModel TypeTag>
+struct DiscretizationDefaultLocalOperator<TypeTag>
+{
+    using type = CCFacetCouplingLocalResidual<TypeTag>;
+};
+
+} // end namespace Detail
+
 } // namespace Dumux
 
 #endif
diff --git a/dumux/multidomain/facet/cellcentered/tpfa/properties.hh b/dumux/multidomain/facet/cellcentered/tpfa/properties.hh
index 87167307db..402a317254 100644
--- a/dumux/multidomain/facet/cellcentered/tpfa/properties.hh
+++ b/dumux/multidomain/facet/cellcentered/tpfa/properties.hh
@@ -17,8 +17,11 @@
 #ifndef DUMUX_FACETCOUPLING_CC_TPFA_PROPERTIES_HH
 #define DUMUX_FACETCOUPLING_CC_TPFA_PROPERTIES_HH
 
+#include <type_traits>
+
 #include <dumux/common/properties.hh>
 #include <dumux/discretization/cctpfa.hh>
+#include <dumux/discretization/defaultlocaloperator.hh>
 #include <dumux/multidomain/facet/cellcentered/upwindscheme.hh>
 #include <dumux/multidomain/facet/cellcentered/localresidual.hh>
 #include <dumux/multidomain/facet/cellcentered/tpfa/darcyslaw.hh>
@@ -73,6 +76,20 @@ struct FluxVariables<TypeTag, TTag::CCTpfaFacetCouplingModel>
 };
 
 } // namespace Properties
+
+namespace Detail {
+
+template<class T>
+concept CCTpfaFacetCouplingModel = CCTpfaModel<T> && Dumux::Properties::inheritsFrom<Properties::TTag::CCTpfaFacetCouplingModel, T>();
+
+template<CCTpfaFacetCouplingModel TypeTag>
+struct DiscretizationDefaultLocalOperator<TypeTag>
+{
+    using type = CCFacetCouplingLocalResidual<TypeTag>;
+};
+
+} // end namespace Detail
+
 } // namespace Dumux
 
 #endif
-- 
GitLab