From dc8967d0ae411852e7d7b8bd988e872669ce00e6 Mon Sep 17 00:00:00 2001 From: Ned Coltman <edward.coltman@iws.uni-stuttgart.de> Date: Thu, 30 Mar 2023 18:47:44 +0200 Subject: [PATCH] [exercises][ff-pm] Cleanup styleguide issues in problem files --- .../interface/freeflowsubproblem.hh | 51 +++++++-------- .../interface/params.input | 4 +- .../interface/porousmediumsubproblem.hh | 29 ++++----- .../models/freeflowsubproblem.hh | 64 +++++++++---------- .../models/porousmediumsubproblem.hh | 23 +++---- .../turbulence/freeflowsubproblem.hh | 54 +++++++--------- .../turbulence/porousmediumsubproblem.hh | 23 +++---- .../turbulence/freeflowsubproblem.hh | 36 +++++------ .../turbulence/porousmediumsubproblem.hh | 18 +++--- 9 files changed, 136 insertions(+), 166 deletions(-) diff --git a/exercises/exercise-coupling-ff-pm/interface/freeflowsubproblem.hh b/exercises/exercise-coupling-ff-pm/interface/freeflowsubproblem.hh index a7984532..3de81a16 100644 --- a/exercises/exercise-coupling-ff-pm/interface/freeflowsubproblem.hh +++ b/exercises/exercise-coupling-ff-pm/interface/freeflowsubproblem.hh @@ -60,22 +60,15 @@ class FreeFlowSubProblem : public NavierStokesStaggeredProblem<TypeTag> using CouplingManager = GetPropType<TypeTag, Properties::CouplingManager>; public: - FreeFlowSubProblem(std::shared_ptr<const FVGridGeometry> fvGridGeometry, std::shared_ptr<CouplingManager> couplingManager) - : ParentType(fvGridGeometry, "Stokes"), eps_(1e-6), couplingManager_(couplingManager) + FreeFlowSubProblem(std::shared_ptr<const FVGridGeometry> fvGridGeometry, + std::shared_ptr<CouplingManager> couplingManager) + : ParentType(fvGridGeometry, "Stokes"), + eps_(1e-6), + couplingManager_(couplingManager) { deltaP_ = getParamFromGroup<Scalar>(this->paramGroup(), "Problem.PressureDifference"); } - - /*! - * \brief Return the sources within the domain. - * - * \param globalPos The global position - */ - NumEqVector sourceAtPos(const GlobalPosition &globalPos) const - { return NumEqVector(0.0); } - - /*! * \brief Specifies which kind of boundary condition should be * used for which equation on a given boundary segment. @@ -163,17 +156,15 @@ public: return values; } + /*! + * \brief Return the sources within the domain. + * + * \param globalPos The global position + */ + NumEqVector sourceAtPos(const GlobalPosition &globalPos) const + { return NumEqVector(0.0); } - //! Set the coupling manager - void setCouplingManager(std::shared_ptr<CouplingManager> cm) - { couplingManager_ = cm; } - - //! Get the coupling manager - const CouplingManager& couplingManager() const - { return *couplingManager_; } - - - /*! + /*! * \brief Evaluate the initial value for a control volume. * * \param globalPos The global position @@ -192,17 +183,13 @@ public: * \brief Returns the intrinsic permeability of required as input parameter for the Beavers-Joseph-Saffman boundary condition */ Scalar permeability(const Element& element, const SubControlVolumeFace& scvf) const - { - return couplingManager().couplingData().darcyPermeability(element, scvf); - } + { return couplingManager().couplingData().darcyPermeability(element, scvf); } /*! * \brief Returns the alpha value required as input parameter for the Beavers-Joseph-Saffman boundary condition */ Scalar alphaBJ(const SubControlVolumeFace& scvf) const - { - return couplingManager().problem(CouplingManager::darcyIdx).spatialParams().beaversJosephCoeffAtPos(scvf.center()); - } + { return couplingManager().problem(CouplingManager::darcyIdx).spatialParams().beaversJosephCoeffAtPos(scvf.center()); } /*! * \brief calculate the analytical velocity in x direction based on Beavers & Joseph (1967) @@ -241,6 +228,14 @@ public: return analyticalVelocityX_; } + //! Set the coupling manager + void setCouplingManager(std::shared_ptr<CouplingManager> cm) + { couplingManager_ = cm; } + + //! Get the coupling manager + const CouplingManager& couplingManager() const + { return *couplingManager_; } + // \} private: diff --git a/exercises/exercise-coupling-ff-pm/interface/params.input b/exercises/exercise-coupling-ff-pm/interface/params.input index 22730c83..669bae28 100644 --- a/exercises/exercise-coupling-ff-pm/interface/params.input +++ b/exercises/exercise-coupling-ff-pm/interface/params.input @@ -1,5 +1,5 @@ - # for dune-subgrid - [Grid] +# for dune-subgrid +[Grid] Positions0 = 0 1 Positions1 = 0 0.2 0.3 0.65 Cells0 = 100 diff --git a/exercises/exercise-coupling-ff-pm/interface/porousmediumsubproblem.hh b/exercises/exercise-coupling-ff-pm/interface/porousmediumsubproblem.hh index 836e041c..dca93c17 100644 --- a/exercises/exercise-coupling-ff-pm/interface/porousmediumsubproblem.hh +++ b/exercises/exercise-coupling-ff-pm/interface/porousmediumsubproblem.hh @@ -60,18 +60,19 @@ class PorousMediumSubProblem : public PorousMediumFlowProblem<TypeTag> public: PorousMediumSubProblem(std::shared_ptr<const FVGridGeometry> fvGridGeometry, - std::shared_ptr<CouplingManager> couplingManager) - : ParentType(fvGridGeometry, "Darcy"), eps_(1e-7), couplingManager_(couplingManager) + std::shared_ptr<CouplingManager> couplingManager) + : ParentType(fvGridGeometry, "Darcy"), + eps_(1e-7), + couplingManager_(couplingManager) {} - /*! - * \brief Specifies which kind of boundary condition should be - * used for which equation on a given boundary control volume. - * - * \param element The element - * \param scvf The boundary sub control volume face - */ + * \brief Specifies which kind of boundary condition should be + * used for which equation on a given boundary control volume. + * + * \param element The element + * \param scvf The boundary sub control volume face + */ BoundaryTypes boundaryTypes(const Element &element, const SubControlVolumeFace &scvf) const { BoundaryTypes values; @@ -90,7 +91,7 @@ public: return values; } - /*! + /*! * \brief Evaluate the boundary conditions for a Dirichlet control volume. * * \param element The element for which the Dirichlet boundary condition is set @@ -150,8 +151,6 @@ public: const SubControlVolume &scv) const { return NumEqVector(0.0); } - // \} - /*! * \brief Evaluate the initial value for a control volume. * @@ -161,11 +160,7 @@ public: * variables. */ PrimaryVariables initial(const Element &element) const - { - return PrimaryVariables(0.0); - } - - // \} + { return PrimaryVariables(0.0); } //! Set the coupling manager void setCouplingManager(std::shared_ptr<CouplingManager> cm) diff --git a/exercises/exercise-coupling-ff-pm/models/freeflowsubproblem.hh b/exercises/exercise-coupling-ff-pm/models/freeflowsubproblem.hh index 57d749f2..b53c16a0 100644 --- a/exercises/exercise-coupling-ff-pm/models/freeflowsubproblem.hh +++ b/exercises/exercise-coupling-ff-pm/models/freeflowsubproblem.hh @@ -69,24 +69,17 @@ class FreeFlowSubProblem : public NavierStokesStaggeredProblem<TypeTag> static constexpr bool useMoles = GetPropType<TypeTag, Properties::ModelTraits>::useMoles(); public: - FreeFlowSubProblem(std::shared_ptr<const FVGridGeometry> fvGridGeometry, std::shared_ptr<CouplingManager> couplingManager) - : ParentType(fvGridGeometry, "Stokes"), eps_(1e-6), couplingManager_(couplingManager) + FreeFlowSubProblem(std::shared_ptr<const FVGridGeometry> fvGridGeometry, + std::shared_ptr<CouplingManager> couplingManager) + : ParentType(fvGridGeometry, "Stokes"), + eps_(1e-6), + couplingManager_(couplingManager) { velocity_ = getParamFromGroup<Scalar>(this->paramGroup(), "Problem.Velocity"); pressure_ = getParamFromGroup<Scalar>(this->paramGroup(), "Problem.Pressure"); moleFraction_ = getParamFromGroup<Scalar>(this->paramGroup(), "Problem.MoleFraction"); } - - /*! - * \brief Return the sources within the domain. - * - * \param globalPos The global position - */ - NumEqVector sourceAtPos(const GlobalPosition &globalPos) const - { return NumEqVector(0.0); } - - /*! * \brief Specifies which kind of boundary condition should be * used for which equation on a given boundary segment. @@ -173,21 +166,7 @@ public: return values; } - /*! - * \brief Set the coupling manager - */ - void setCouplingManager(std::shared_ptr<CouplingManager> cm) - { couplingManager_ = cm; } - - /*! - * \brief Get the coupling manager - */ - const CouplingManager& couplingManager() const - { return *couplingManager_; } - - - /*! * \brief Evaluate the initial value for a control volume. * * \param globalPos The global position @@ -216,26 +195,40 @@ public: return values; } - void setTimeLoop(TimeLoopPtr timeLoop) - { timeLoop_ = timeLoop; } + /*! + * \brief Return the sources within the domain. + * + * \param globalPos The global position + */ + NumEqVector sourceAtPos(const GlobalPosition &globalPos) const + { return NumEqVector(0.0); } /*! * \brief Returns the intrinsic permeability of required as input parameter for the Beavers-Joseph-Saffman boundary condition */ Scalar permeability(const Element& element, const SubControlVolumeFace& scvf) const - { - return couplingManager().couplingData().darcyPermeability(element, scvf); - } + { return couplingManager().couplingData().darcyPermeability(element, scvf); } /*! * \brief Returns the alpha value required as input parameter for the Beavers-Joseph-Saffman boundary condition */ Scalar alphaBJ(const SubControlVolumeFace& scvf) const - { - return couplingManager().problem(CouplingManager::darcyIdx).spatialParams().beaversJosephCoeffAtPos(scvf.center()); - } + { return couplingManager().problem(CouplingManager::darcyIdx).spatialParams().beaversJosephCoeffAtPos(scvf.center()); } - // \} + /*! + * \brief Set the coupling manager + */ + void setCouplingManager(std::shared_ptr<CouplingManager> cm) + { couplingManager_ = cm; } + + /*! + * \brief Get the coupling manager + */ + const CouplingManager& couplingManager() const + { return *couplingManager_; } + + void setTimeLoop(TimeLoopPtr timeLoop) + { timeLoop_ = timeLoop; } private: bool onLeftBoundary_(const GlobalPosition &globalPos) const @@ -271,6 +264,7 @@ private: const Scalar enthalpy = FluidSystem::enthalpy(fluidState, paramCache, 0); fluidState.setEnthalpy(0, enthalpy); } + // the height of the free-flow domain const Scalar height_() const { return this->gridGeometry().bBoxMax()[1] - this->gridGeometry().bBoxMin()[1]; } diff --git a/exercises/exercise-coupling-ff-pm/models/porousmediumsubproblem.hh b/exercises/exercise-coupling-ff-pm/models/porousmediumsubproblem.hh index 01d64fdd..911b0246 100644 --- a/exercises/exercise-coupling-ff-pm/models/porousmediumsubproblem.hh +++ b/exercises/exercise-coupling-ff-pm/models/porousmediumsubproblem.hh @@ -76,8 +76,10 @@ class PorousMediumSubProblem : public PorousMediumFlowProblem<TypeTag> public: PorousMediumSubProblem(std::shared_ptr<const FVGridGeometry> fvGridGeometry, - std::shared_ptr<CouplingManager> couplingManager) - : ParentType(fvGridGeometry, "Darcy"), eps_(1e-7), couplingManager_(couplingManager) + std::shared_ptr<CouplingManager> couplingManager) + : ParentType(fvGridGeometry, "Darcy"), + eps_(1e-7), + couplingManager_(couplingManager) { moleFraction_ = getParamFromGroup<Scalar>(this->paramGroup(), "Problem.MoleFraction"); @@ -93,7 +95,6 @@ public: << std::endl; } - /*! * \brief Initialize the problem. */ @@ -217,14 +218,13 @@ public: } } - /*! - * \brief Specifies which kind of boundary condition should be - * used for which equation on a given boundary control volume. - * - * \param element The element - * \param scvf The boundary sub control volume face - */ + * \brief Specifies which kind of boundary condition should be + * used for which equation on a given boundary control volume. + * + * \param element The element + * \param scvf The boundary sub control volume face + */ BoundaryTypes boundaryTypes(const Element& element, const SubControlVolumeFace& scvf) const { BoundaryTypes values; @@ -277,7 +277,6 @@ public: const SubControlVolume& scv) const { return NumEqVector(0.0); } - /*! * \brief Evaluate the initial value for a control volume. * @@ -300,8 +299,6 @@ public: return values; } - // \} - //! Set the coupling manager void setCouplingManager(std::shared_ptr<CouplingManager> cm) { couplingManager_ = cm; } diff --git a/exercises/exercise-coupling-ff-pm/turbulence/freeflowsubproblem.hh b/exercises/exercise-coupling-ff-pm/turbulence/freeflowsubproblem.hh index 4887b096..30761bbc 100644 --- a/exercises/exercise-coupling-ff-pm/turbulence/freeflowsubproblem.hh +++ b/exercises/exercise-coupling-ff-pm/turbulence/freeflowsubproblem.hh @@ -75,8 +75,11 @@ class FreeFlowSubProblem : public NavierStokesStaggeredProblem<TypeTag> static constexpr bool useMoles = GetPropType<TypeTag, Properties::ModelTraits>::useMoles(); public: - FreeFlowSubProblem(std::shared_ptr<const FVGridGeometry> fvGridGeometry, std::shared_ptr<CouplingManager> couplingManager) - : ParentType(fvGridGeometry, "Stokes"), eps_(1e-6), couplingManager_(couplingManager) + FreeFlowSubProblem(std::shared_ptr<const FVGridGeometry> fvGridGeometry, + std::shared_ptr<CouplingManager> couplingManager) + : ParentType(fvGridGeometry, "Stokes"), + eps_(1e-6), + couplingManager_(couplingManager) { refVelocity_ = getParamFromGroup<Scalar>(this->paramGroup(), "Problem.RefVelocity"); refPressure_ = getParamFromGroup<Scalar>(this->paramGroup(), "Problem.RefPressure"); @@ -87,16 +90,6 @@ public: getParamFromGroup<std::string>(this->paramGroup(), "Problem.InterfaceDiffusionCoefficientAvg")); } - - /*! - * \brief Return the sources within the domain. - * - * \param globalPos The global position - */ - NumEqVector sourceAtPos(const GlobalPosition &globalPos) const - { return NumEqVector(0.0); } - - /*! * \brief Specifies which kind of boundary condition should be * used for which equation on a given boundary segment. @@ -201,21 +194,15 @@ public: return values; } - /*! - * \brief Set the coupling manager + * \brief Return the sources within the domain. + * + * \param globalPos The global position */ - void setCouplingManager(std::shared_ptr<CouplingManager> cm) - { couplingManager_ = cm; } + NumEqVector sourceAtPos(const GlobalPosition &globalPos) const + { return NumEqVector(0.0); } /*! - * \brief Get the coupling manager - */ - const CouplingManager& couplingManager() const - { return *couplingManager_; } - - - /*! * \brief Evaluate the initial value for a control volume. * * \param globalPos The global position @@ -257,7 +244,6 @@ public: const Scalar refTemperature() const { return refTemperature_; } - void setTimeLoop(TimeLoopPtr timeLoop) { timeLoop_ = timeLoop; } @@ -265,19 +251,25 @@ public: * \brief Returns the intrinsic permeability of required as input parameter for the Beavers-Joseph-Saffman boundary condition */ Scalar permeability(const Element& element, const SubControlVolumeFace& scvf) const - { - return couplingManager().problem(CouplingManager::darcyIdx).spatialParams().permeabilityAtPos(scvf.center()); - } + { return couplingManager().problem(CouplingManager::darcyIdx).spatialParams().permeabilityAtPos(scvf.center()); } /*! * \brief Returns the alpha value required as input parameter for the Beavers-Joseph-Saffman boundary condition */ Scalar alphaBJ(const SubControlVolumeFace& scvf) const - { - return couplingManager().problem(CouplingManager::darcyIdx).spatialParams().beaversJosephCoeffAtPos(scvf.center()); - } + { return couplingManager().problem(CouplingManager::darcyIdx).spatialParams().beaversJosephCoeffAtPos(scvf.center()); } + + /*! + * \brief Set the coupling manager + */ + void setCouplingManager(std::shared_ptr<CouplingManager> cm) + { couplingManager_ = cm; } - // \} + /*! + * \brief Get the coupling manager + */ + const CouplingManager& couplingManager() const + { return *couplingManager_; } private: bool onLeftBoundary_(const GlobalPosition &globalPos) const diff --git a/exercises/exercise-coupling-ff-pm/turbulence/porousmediumsubproblem.hh b/exercises/exercise-coupling-ff-pm/turbulence/porousmediumsubproblem.hh index 5d989c36..99c26cd7 100644 --- a/exercises/exercise-coupling-ff-pm/turbulence/porousmediumsubproblem.hh +++ b/exercises/exercise-coupling-ff-pm/turbulence/porousmediumsubproblem.hh @@ -77,8 +77,10 @@ class PorousMediumSubProblem : public PorousMediumFlowProblem<TypeTag> public: PorousMediumSubProblem(std::shared_ptr<const FVGridGeometry> fvGridGeometry, - std::shared_ptr<CouplingManager> couplingManager) - : ParentType(fvGridGeometry, "Darcy"), eps_(1e-7), couplingManager_(couplingManager) + std::shared_ptr<CouplingManager> couplingManager) + : ParentType(fvGridGeometry, "Darcy"), + eps_(1e-7), + couplingManager_(couplingManager) { pressure_ = getParamFromGroup<Scalar>(this->paramGroup(), "Problem.Pressure"); initialSw_ = getParamFromGroup<Scalar>(this->paramGroup(), "Problem.Saturation"); @@ -89,7 +91,6 @@ public: getParamFromGroup<std::string>(this->paramGroup(), "Problem.InterfaceDiffusionCoefficientAvg")); } - template<class SolutionVector, class GridVariables> void postTimeStep(const SolutionVector& curSol, const GridVariables& gridVariables, @@ -123,12 +124,12 @@ public: } /*! - * \brief Specifies which kind of boundary condition should be - * used for which equation on a given boundary control volume. - * - * \param element The element - * \param scvf The boundary sub control volume face - */ + * \brief Specifies which kind of boundary condition should be + * used for which equation on a given boundary control volume. + * + * \param element The element + * \param scvf The boundary sub control volume face + */ BoundaryTypes boundaryTypes(const Element &element, const SubControlVolumeFace &scvf) const { BoundaryTypes values; @@ -207,8 +208,6 @@ public: const SubControlVolume &scv) const { return NumEqVector(0.0); } - // \} - /*! * \brief Evaluate the initial value for a control volume. * @@ -227,8 +226,6 @@ public: return values; } - // \} - /*! * \brief Set the coupling manager */ diff --git a/exercises/solution/exercise-coupling-ff-pm/turbulence/freeflowsubproblem.hh b/exercises/solution/exercise-coupling-ff-pm/turbulence/freeflowsubproblem.hh index cfba4038..6257675c 100644 --- a/exercises/solution/exercise-coupling-ff-pm/turbulence/freeflowsubproblem.hh +++ b/exercises/solution/exercise-coupling-ff-pm/turbulence/freeflowsubproblem.hh @@ -85,8 +85,11 @@ class FreeFlowSubProblem : public NavierStokesStaggeredProblem<TypeTag> static constexpr bool useMoles = GetPropType<TypeTag, Properties::ModelTraits>::useMoles(); public: - FreeFlowSubProblem(std::shared_ptr<const FVGridGeometry> fvGridGeometry, std::shared_ptr<CouplingManager> couplingManager) - : ParentType(fvGridGeometry, "Stokes"), eps_(1e-6), couplingManager_(couplingManager) + FreeFlowSubProblem(std::shared_ptr<const FVGridGeometry> fvGridGeometry, + std::shared_ptr<CouplingManager> couplingManager) + : ParentType(fvGridGeometry, "Freeflow"), + eps_(1e-6), + couplingManager_(couplingManager) { refVelocity_ = getParamFromGroup<Scalar>(this->paramGroup(), "Problem.RefVelocity"); refPressure_ = getParamFromGroup<Scalar>(this->paramGroup(), "Problem.RefPressure"); @@ -97,8 +100,7 @@ public: getParamFromGroup<std::string>(this->paramGroup(), "Problem.InterfaceDiffusionCoefficientAvg")); } - - /*! + /*! * \brief Return the sources within the domain. * * \param globalPos The global position @@ -221,21 +223,7 @@ public: return values; } - /*! - * \brief Set the coupling manager - */ - void setCouplingManager(std::shared_ptr<CouplingManager> cm) - { couplingManager_ = cm; } - - /*! - * \brief Get the coupling manager - */ - const CouplingManager& couplingManager() const - { return *couplingManager_; } - - - /*! * \brief Evaluate the initial value for a control volume. * * \param globalPos The global position @@ -300,7 +288,17 @@ public: return couplingManager().problem(CouplingManager::darcyIdx).spatialParams().beaversJosephCoeffAtPos(scvf.center()); } - // \} + /*! + * \brief Set the coupling manager + */ + void setCouplingManager(std::shared_ptr<CouplingManager> cm) + { couplingManager_ = cm; } + + /*! + * \brief Get the coupling manager + */ + const CouplingManager& couplingManager() const + { return *couplingManager_; } private: bool onLeftBoundary_(const GlobalPosition &globalPos) const diff --git a/exercises/solution/exercise-coupling-ff-pm/turbulence/porousmediumsubproblem.hh b/exercises/solution/exercise-coupling-ff-pm/turbulence/porousmediumsubproblem.hh index 456f9b14..5aa968b3 100644 --- a/exercises/solution/exercise-coupling-ff-pm/turbulence/porousmediumsubproblem.hh +++ b/exercises/solution/exercise-coupling-ff-pm/turbulence/porousmediumsubproblem.hh @@ -77,8 +77,10 @@ class PorousMediumSubProblem : public PorousMediumFlowProblem<TypeTag> public: PorousMediumSubProblem(std::shared_ptr<const FVGridGeometry> fvGridGeometry, - std::shared_ptr<CouplingManager> couplingManager) - : ParentType(fvGridGeometry, "Darcy"), eps_(1e-7), couplingManager_(couplingManager) + std::shared_ptr<CouplingManager> couplingManager) + : ParentType(fvGridGeometry, "PorousMedium"), + eps_(1e-7), + couplingManager_(couplingManager) { pressure_ = getParamFromGroup<Scalar>(this->paramGroup(), "Problem.Pressure"); initialSw_ = getParamFromGroup<Scalar>(this->paramGroup(), "Problem.Saturation"); @@ -123,12 +125,12 @@ public: } /*! - * \brief Specifies which kind of boundary condition should be - * used for which equation on a given boundary control volume. - * - * \param element The element - * \param scvf The boundary sub control volume face - */ + * \brief Specifies which kind of boundary condition should be + * used for which equation on a given boundary control volume. + * + * \param element The element + * \param scvf The boundary sub control volume face + */ BoundaryTypes boundaryTypes(const Element &element, const SubControlVolumeFace &scvf) const { BoundaryTypes values; -- GitLab