From 851f5ecb016f2464e7852aa16f5d90dce641f011 Mon Sep 17 00:00:00 2001 From: Kilian Weishaupt <kilian.weishaupt@iws.uni-stuttgart.de> Date: Mon, 5 Dec 2016 09:45:13 +0100 Subject: [PATCH] [staggeredGrid] Add cellCenter and face specific init and dirichlet functions --- .../staggered/globalvolumevariables.hh | 2 +- dumux/freeflow/staggered/problem.hh | 18 ++++++ dumux/implicit/staggered/localresidual.hh | 4 ++ dumux/implicit/staggered/model.hh | 4 +- dumux/implicit/staggered/problem.hh | 63 +++++++------------ .../staggered/staggeredtestproblem.hh | 10 ++- 6 files changed, 58 insertions(+), 43 deletions(-) diff --git a/dumux/discretization/staggered/globalvolumevariables.hh b/dumux/discretization/staggered/globalvolumevariables.hh index e996447513..cbc1b32ea2 100644 --- a/dumux/discretization/staggered/globalvolumevariables.hh +++ b/dumux/discretization/staggered/globalvolumevariables.hh @@ -94,7 +94,7 @@ public: { const auto insideScvIdx = scvf.insideScvIdx(); const auto& insideScv = fvGeometry.scv(insideScvIdx); - const auto dirichletPriVars = problem.dirichlet(element, scvf); + const auto dirichletPriVars = problem.ccDirichlet(element, scvf); volumeVariables_[scvf.outsideScvIdx()].update(dirichletPriVars, problem, element, insideScv); } diff --git a/dumux/freeflow/staggered/problem.hh b/dumux/freeflow/staggered/problem.hh index 5ea3896999..6ee5c27bfe 100644 --- a/dumux/freeflow/staggered/problem.hh +++ b/dumux/freeflow/staggered/problem.hh @@ -52,6 +52,8 @@ class NavierStokesProblem : public StaggeredProblem<TypeTag> typedef typename GET_PROP_TYPE(TypeTag, FVElementGeometry) FVElementGeometry; + using FacePrimaryVariables = typename GET_PROP_TYPE(TypeTag, FacePrimaryVariables); + enum { dim = Grid::dimension, dimWorld = Grid::dimensionworld @@ -116,6 +118,22 @@ public: const int boundaryFaceIdx) const { DUNE_THROW(Dune::NotImplemented, "permeability()"); } + + /*! + * \brief Evaluate the boundary conditions for a dirichlet + * control volume. + * + * \param globalPos The position of the center of the finite volume + * for which the dirichlet condition ought to be + * set in global coordinates + * + * For this method, the \a values parameter stores primary variables. + */ + FacePrimaryVariables faceDirichletAtPos(const GlobalPosition &globalPos, const int direction) const + { + return asImp_().dirichletVelocityAtPos(globalPos)[direction]; + } + // \} private: diff --git a/dumux/implicit/staggered/localresidual.hh b/dumux/implicit/staggered/localresidual.hh index 38e371d392..d2116e158a 100644 --- a/dumux/implicit/staggered/localresidual.hh +++ b/dumux/implicit/staggered/localresidual.hh @@ -267,7 +267,11 @@ protected: { if (scvf.boundary()) { +// auto test = this->problem().faceDirichletAtPos(scvf.center(), scvf.directionIndex()); +// std::cout << " face: " << scvf.center() << ", normal: " << scvf.unitOuterNormal() << ", value: " << test << std::endl; + // auto bcTypes = this->problem().boundaryTypes(element, scvf); + // this->residual_[0] += evalBoundaryFluxes_(element, fvGeometry, elemVolVars, scvf, bcTypes, elemFluxVarsCache[scvf]); } } diff --git a/dumux/implicit/staggered/model.hh b/dumux/implicit/staggered/model.hh index 5bf97ce7f6..603fbc4912 100644 --- a/dumux/implicit/staggered/model.hh +++ b/dumux/implicit/staggered/model.hh @@ -256,7 +256,7 @@ public: { // let the problem do the dirty work of nailing down // the initial solution. - auto initPriVars = this->problem_().initial(scv); + auto initPriVars = this->problem_().initialCCValuesAtPos(scv.dofPosition()); auto dofIdxGlobal = scv.dofIndex(); this->uCur_[cellCenterIdx][dofIdxGlobal] += initPriVars; @@ -265,7 +265,7 @@ public: // loop over faces for(auto&& scvf : scvfs(fvGeometry)) { - auto initPriVars = this->problem_().initialFaceValues(scvf); + auto initPriVars = this->problem_().initialFaceValueAtPos(scvf.center()); this->uCur_[faceIdx][scvf.dofIndexSelf()] = initPriVars; } } diff --git a/dumux/implicit/staggered/problem.hh b/dumux/implicit/staggered/problem.hh index 9ab98e2291..ea9c1afec2 100644 --- a/dumux/implicit/staggered/problem.hh +++ b/dumux/implicit/staggered/problem.hh @@ -103,7 +103,7 @@ public: * * The method returns the boundary types information. */ - CellCenterPrimaryVariables dirichlet(const Element &element, const SubControlVolumeFace &scvf) const + CellCenterPrimaryVariables ccDirichlet(const Element &element, const SubControlVolumeFace &scvf) const { // forward it to the method which only takes the global coordinate if (isBox) @@ -114,7 +114,7 @@ public: return asImp_().dirichletAtPos(scvf.center()); } - CellCenterPrimaryVariables dirichlet(const Element &element, const SubControlVolume &scv) const + CellCenterPrimaryVariables ccDirichlet(const Element &element, const SubControlVolume &scv) const { // forward it to the method which only takes the global coordinate if (!isBox) @@ -135,7 +135,27 @@ public: * * For this method, the \a values parameter stores primary variables. */ - CellCenterPrimaryVariables dirichletAtPos(const GlobalPosition &globalPos) const + CellCenterPrimaryVariables ccDirichletAtPos(const GlobalPosition &globalPos) const + { + // Throw an exception (there is no reasonable default value + // for Dirichlet conditions) + DUNE_THROW(Dune::InvalidStateException, + "The problem specifies that some boundary " + "segments are dirichlet, but does not provide " + "a dirichlet() method."); + } + + /*! + * \brief Evaluate the boundary conditions for a dirichlet + * control volume. + * + * \param globalPos The position of the center of the finite volume + * for which the dirichlet condition ought to be + * set in global coordinates + * + * For this method, the \a values parameter stores primary variables. + */ + FacePrimaryVariables faceDirichletAtPos(const GlobalPosition &globalPos, const int direction) const { // Throw an exception (there is no reasonable default value // for Dirichlet conditions) @@ -249,25 +269,6 @@ public: } - - /*! - * \brief Evaluate the initial value for a control volume. - * - * \param values The initial values for the primary variables - * \param element The finite element - * \param fvGeometry The finite-volume geometry - * \param scvIdx The local subcontrolvolume index - * - * For this method, the \a values parameter stores primary - * variables. - */ - CellCenterPrimaryVariables initial(const SubControlVolume &scv) const - { - // forward to generic interface - return asImp_().initialAtPos(scv.dofPosition()); - } - - /*! * \brief Evaluate the initial value for a control volume. * @@ -278,7 +279,7 @@ public: * * For this method, the \a values parameter stores primary variables. */ - CellCenterPrimaryVariables initialAtPos(const GlobalPosition &globalPos) const + CellCenterPrimaryVariables initialCCValuesAtPos(const GlobalPosition &globalPos) const { // Throw an exception (there is no reasonable default value // for initial values) @@ -287,22 +288,6 @@ public: "a initialAtPos() method."); } - /*! - * \brief Evaluate the initial value for a facet. - * - * \param values The initial values for the primary variables - * \param element The finite element - * \param fvGeometry The finite-volume geometry - * \param scvIdx The local subcontrolvolume index - * - * For this method, the \a values parameter stores primary - * variables. - */ - FacePrimaryVariables initialFaceValues(const SubControlVolumeFace &scvf) const - { - // forward to generic interface - return asImp_().initialFaceValueAtPos(scvf.center()); - } /*! * \brief Evaluate the initial value for a facet. diff --git a/test/freeflow/staggered/staggeredtestproblem.hh b/test/freeflow/staggered/staggeredtestproblem.hh index 8eaf56a13c..b42496d501 100644 --- a/test/freeflow/staggered/staggeredtestproblem.hh +++ b/test/freeflow/staggered/staggeredtestproblem.hh @@ -246,7 +246,7 @@ public: * For this method, the \a priVars parameter stores primary * variables. */ - CellCenterPrimaryVariables initial(const SubControlVolume& scv) const + CellCenterPrimaryVariables initialCCValuesAtPos(const GlobalPosition &globalPos) const { CellCenterPrimaryVariables priVars(0); priVars[pressureIdx] = 1.0e+5; @@ -273,6 +273,14 @@ public: } + GlobalPosition dirichletVelocityAtPos(const GlobalPosition &pos) const + { + GlobalPosition velocity; + velocity[0] = 1.0; + velocity[1] = 0.0; + return velocity; + } + // \} private: -- GitLab