diff --git a/exercises/exercise-coupling-ff-pm/interface/freeflowsubproblem.hh b/exercises/exercise-coupling-ff-pm/interface/freeflowsubproblem.hh index a7984532a58d3c52b3ed907e7e275ce32980d687..3de81a16998e2bb3381371c021c11eed3c527282 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 22730c83706e84a4c14db95473405ca48c0be3bd..669bae289bd084ac05efbccdbbbd4eb53cf5e7ed 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 836e041cbb39f40d35fd89b4deeaf6effb3170a3..dca93c17cc517a173a82f01a19e3ff47039aa043 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 57d749f2b05a1be9e324c66b18c7cf4b9181ead3..b53c16a0ba2448d5914a090218e1689802a31b37 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 01d64fdd8ca7064b080958e04a126dee25c0c5db..911b02462a838ee68faa2f06283d9a1461097683 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 4887b0962d62c58ef2b32dddc4245dceca01ad7b..30761bbcbed154f26f7892b1e1a586aa81aa7442 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 5d989c367192c6fe81776a07768e540357fe08c3..99c26cd7f22b466e06c5d09736820c0a1b4d82ba 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 cfba40383d607ea9797221682cbe1fd7b2e1fe56..6257675c2cb1fca1b848d0e07a747b82347fa6a3 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 456f9b14fac589d5b233dfb87c073f5ad3a054d5..5aa968b3756eb43a0f90ecf84c2a4c99c5d8dcdb 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;