diff --git a/dumux/discretization/CMakeLists.txt b/dumux/discretization/CMakeLists.txt index ca79030943ef8d22577ed78a63b4ce739420eb94..bf508c6ca40c06bde1bc2a3a89a6cb7c1db32cbe 100644 --- a/dumux/discretization/CMakeLists.txt +++ b/dumux/discretization/CMakeLists.txt @@ -1,5 +1,6 @@ add_subdirectory(box) add_subdirectory(cellcentered) +add_subdirectory(facecentered) add_subdirectory(fem) add_subdirectory(porenetwork) add_subdirectory(projection) diff --git a/dumux/discretization/facecentered/CMakeLists.txt b/dumux/discretization/facecentered/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..bc798bad22f550b2ac000ae101d7c21738c58369 --- /dev/null +++ b/dumux/discretization/facecentered/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(staggered) diff --git a/dumux/discretization/facecentered/staggered/CMakeLists.txt b/dumux/discretization/facecentered/staggered/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..f7c6fdc39f5e53a0716b034457ade167630e6762 --- /dev/null +++ b/dumux/discretization/facecentered/staggered/CMakeLists.txt @@ -0,0 +1,3 @@ +file(GLOB DUMUX_DISCRETIZATION_FACECENTERED_STAGGERED_HEADERS *.hh *.inc) +install(FILES ${DUMUX_DISCRETIZATION_FACECENTERED_STAGGERED_HEADERS} + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dumux/discretization/facecentered/staggered) diff --git a/dumux/discretization/facecentered/staggered/elementsolution.hh b/dumux/discretization/facecentered/staggered/elementsolution.hh index 63af3dd1c4fe648602c5a727223c233cb98c5de3..535e632f4390467d6e9b1873642ff0e69f9bfdb8 100644 --- a/dumux/discretization/facecentered/staggered/elementsolution.hh +++ b/dumux/discretization/facecentered/staggered/elementsolution.hh @@ -128,14 +128,14 @@ private: */ template<class Element, class SolutionVector, class GridGeometry> auto elementSolution(const Element& element, const SolutionVector& sol, const GridGeometry& gg) --> std::enable_if_t<GridGeometry::discMethod == DiscretizationMethod::fcstaggered, - FaceCenteredStaggeredElementSolution<typename GridGeometry::LocalView, - std::decay_t<decltype(std::declval<SolutionVector>()[0])>> - > -{ - using PrimaryVariables = std::decay_t<decltype(std::declval<SolutionVector>()[0])>; - return { element, sol, gg }; -} +-> std::enable_if_t< + GridGeometry::discMethod == DiscretizationMethod::fcstaggered, + FaceCenteredStaggeredElementSolution< + typename GridGeometry::LocalView, + std::decay_t<decltype(std::declval<SolutionVector>()[0])> + > +> +{ return { element, sol, gg }; } /*! * \ingroup FaceCenteredStaggeredDiscretization @@ -143,12 +143,14 @@ auto elementSolution(const Element& element, const SolutionVector& sol, const Gr */ template<class Element, class ElementVolumeVariables, class FVElementGeometry> auto elementSolution(const Element& element, const ElementVolumeVariables& elemVolVars, const FVElementGeometry& gg) --> std::enable_if_t<FVElementGeometry::GridGeometry::discMethod == DiscretizationMethod::fcstaggered, - FaceCenteredStaggeredElementSolution<FVElementGeometry, typename ElementVolumeVariables::VolumeVariables::PrimaryVariables>> -{ - using PrimaryVariables = typename ElementVolumeVariables::VolumeVariables::PrimaryVariables; - return { element, elemVolVars, gg }; -} +-> std::enable_if_t< + FVElementGeometry::GridGeometry::discMethod == DiscretizationMethod::fcstaggered, + FaceCenteredStaggeredElementSolution< + FVElementGeometry, + typename ElementVolumeVariables::VolumeVariables::PrimaryVariables + > +> +{ return { element, elemVolVars, gg }; } /*! * \ingroup FaceCenteredStaggeredDiscretization @@ -157,11 +159,14 @@ auto elementSolution(const Element& element, const ElementVolumeVariables& elemV */ template<class FVElementGeometry, class PrimaryVariables> auto elementSolution(PrimaryVariables&& priVars) --> std::enable_if_t<FVElementGeometry::GridGeometry::discMethod == DiscretizationMethod::fcstaggered, - FaceCenteredStaggeredElementSolution<FVElementGeometry, std::decay_t<PrimaryVariables>>> -{ - return { std::forward<PrimaryVariables>(priVars) }; -} +-> std::enable_if_t< + FVElementGeometry::GridGeometry::discMethod == DiscretizationMethod::fcstaggered, + FaceCenteredStaggeredElementSolution< + FVElementGeometry, + std::decay_t<PrimaryVariables> + > +> +{ return { std::forward<PrimaryVariables>(priVars) }; } } // end namespace Dumux diff --git a/dumux/discretization/facecentered/staggered/elementvolumevariables.hh b/dumux/discretization/facecentered/staggered/elementvolumevariables.hh index 63687a8aaa87df73ef441ac451ce6ec1ff043491..4e066c93e92bea9a8c99cc642669174dc792cc59 100644 --- a/dumux/discretization/facecentered/staggered/elementvolumevariables.hh +++ b/dumux/discretization/facecentered/staggered/elementvolumevariables.hh @@ -45,6 +45,11 @@ class FaceCenteredStaggeredElementVolumeVariables; template<class GVV> class FaceCenteredStaggeredElementVolumeVariables<GVV, /*cachingEnabled*/true> { + using ThisType = FaceCenteredStaggeredElementVolumeVariables<GVV, /*cachingEnabled*/true>; + using GridGeometry = std::decay_t<decltype(std::declval<GVV>().problem().gridGeometry())>; + using FVElementGeometry = typename GridGeometry::LocalView; + using SubControlVolume = typename GridGeometry::SubControlVolume; + public: //! export type of the grid volume variables using GridVolumeVariables = GVV; @@ -58,7 +63,6 @@ public: {} //! operator for the access with an scvf - template<class SubControlVolume, typename std::enable_if_t<!std::is_integral<SubControlVolume>::value, int> = 0> const VolumeVariables& operator [](const SubControlVolume& scv) const { if (scv.index() < numScv_) @@ -82,10 +86,10 @@ public: * This overload is called when an instance of this class is a temporary in the usage context * This allows a usage like this: `const auto view = localView(...).bind(element);` */ - template<class FVElementGeometry, class SolutionVector> - FaceCenteredStaggeredFVElementGeometry bind(const typename FVElementGeometry::Element& element, - const FVElementGeometry& fvGeometry, - const SolutionVector& sol) && + template<class SolutionVector> + ThisType bind(const typename FVElementGeometry::Element& element, + const FVElementGeometry& fvGeometry, + const SolutionVector& sol) && { this->bind(element, fvGeometry, sol); return std::move(*this); @@ -93,7 +97,7 @@ public: //! For compatibility reasons with the case of not storing the face vars. //! function to be called before assembling an element, preparing the vol vars within the stencil - template<class FVElementGeometry, class SolutionVector> + template<class SolutionVector> void bind(const typename FVElementGeometry::Element& element, const FVElementGeometry& fvGeometry, const SolutionVector& sol) & @@ -150,17 +154,17 @@ public: * This overload is called when an instance of this class is a temporary in the usage context * This allows a usage like this: `const auto view = localView(...).bind(element);` */ - template<class FVElementGeometry, class SolutionVector> - FaceCenteredStaggeredFVElementGeometry bindElement(const typename FVElementGeometry::Element& element, - const FVElementGeometry& fvGeometry, - const SolutionVector& sol) && + template<class SolutionVector> + ThisType bindElement(const typename FVElementGeometry::Element& element, + const FVElementGeometry& fvGeometry, + const SolutionVector& sol) && { this->bindElement(element, fvGeometry, sol); return std::move(*this); } //! Binding of an element, prepares only the face variables of the element //! specialization for Staggered models - template<class FVElementGeometry, class SolutionVector> + template<class SolutionVector> void bindElement(const typename FVElementGeometry::Element& element, const FVElementGeometry& fvGeometry, const SolutionVector& sol) & @@ -212,7 +216,11 @@ private: template<class GVV> class FaceCenteredStaggeredElementVolumeVariables<GVV, /*cachingEnabled*/false> { + using ThisType = FaceCenteredStaggeredElementVolumeVariables<GVV, /*cachingEnabled*/false>; using GridGeometry = std::decay_t<decltype(std::declval<GVV>().problem().gridGeometry())>; + using FVElementGeometry = typename GridGeometry::LocalView; + using SubControlVolume = typename GridGeometry::SubControlVolume; + static constexpr auto dim = GridGeometry::GridView::dimension; static constexpr auto numInsideVolVars = dim * 2; static constexpr auto numOutsideVolVars = numInsideVolVars * 2 * (dim - 1); @@ -224,10 +232,10 @@ public: //! export type of the volume variables using VolumeVariables = typename GridVolumeVariables::VolumeVariables; - FaceCenteredStaggeredElementVolumeVariables(const GridVolumeVariables& globalFacesVars) : gridVolumeVariablesPtr_(&globalFacesVars) {} + FaceCenteredStaggeredElementVolumeVariables(const GridVolumeVariables& globalFacesVars) + : gridVolumeVariablesPtr_(&globalFacesVars) {} //! const operator for the access with an scvf - template<class SubControlVolume, typename std::enable_if_t<!std::is_integral<SubControlVolume>::value, int> = 0> const VolumeVariables& operator [](const SubControlVolume& scv) const { return volumeVariables_[getLocalIdx_(scv.index())]; } @@ -236,7 +244,6 @@ public: { return volumeVariables_[getLocalIdx_(scvIdx)]; } //! operator for the access with an scvf - template<class SubControlVolume, typename std::enable_if_t<!std::is_integral<SubControlVolume>::value, int> = 0> VolumeVariables& operator [](const SubControlVolume& scv) { return volumeVariables_[getLocalIdx_(scv.index())]; } @@ -249,16 +256,16 @@ public: * This overload is called when an instance of this class is a temporary in the usage context * This allows a usage like this: `const auto view = localView(...).bind(element);` */ - template<class FVElementGeometry, class SolutionVector> - FaceCenteredStaggeredFVElementGeometry bind(const typename FVElementGeometry::Element& element, - const FVElementGeometry& fvGeometry, - const SolutionVector& sol) && + template<class SolutionVector> + ThisType bind(const typename FVElementGeometry::Element& element, + const FVElementGeometry& fvGeometry, + const SolutionVector& sol) && { this->bind_(element, fvGeometry, sol); return std::move(*this); } - template<class FVElementGeometry, class SolutionVector> + template<class SolutionVector> void bind(const typename FVElementGeometry::Element& element, const FVElementGeometry& fvGeometry, const SolutionVector& sol) & @@ -271,15 +278,16 @@ public: * This overload is called when an instance of this class is a temporary in the usage context * This allows a usage like this: `const auto view = localView(...).bind(element);` */ - template<class FVElementGeometry, class SolutionVector> - FaceCenteredStaggeredFVElementGeometry bindElement(const typename FVElementGeometry::Element& element, - const FVElementGeometry& fvGeometry, - const SolutionVector& sol) && + template<class SolutionVector> + ThisType bindElement(const typename FVElementGeometry::Element& element, + const FVElementGeometry& fvGeometry, + const SolutionVector& sol) && { this->bindElement_(element, fvGeometry, sol); return std::move(*this); } + template<class SolutionVector> void bindElement(const typename FVElementGeometry::Element& element, const FVElementGeometry& fvGeometry, const SolutionVector& sol) & @@ -296,7 +304,7 @@ public: private: //! For compatibility reasons with the case of not storing the vol vars. //! function to be called before assembling an element, preparing the vol vars within the stencil - template<class FVElementGeometry, class SolutionVector> + template<class SolutionVector> void bind_(const typename FVElementGeometry::Element& element, const FVElementGeometry& fvGeometry, const SolutionVector& sol) @@ -373,7 +381,7 @@ private: //! Binding of an element, prepares only the face variables of the element //! specialization for Staggered models - template<class FVElementGeometry, class SolutionVector> + template<class SolutionVector> void bindElement_(const typename FVElementGeometry::Element& element, const FVElementGeometry& fvGeometry, const SolutionVector& sol) diff --git a/dumux/discretization/fcstaggered.hh b/dumux/discretization/fcstaggered.hh index d125131b1c868f614425455e7a11bf69a4278b1b..c950aec44e7cbf3339ff77cd1377b632e786b866 100644 --- a/dumux/discretization/fcstaggered.hh +++ b/dumux/discretization/fcstaggered.hh @@ -132,9 +132,4 @@ public: } // end namespace Detail -// TODO: bundle SolutionVector, JacobianMatrix -// in LinearAlgebra traits - -} // namespace Dumux::Detail - #endif