problem_darcy.hh 10.2 KB
Newer Older
1 2 3 4 5 6 7
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*****************************************************************************
 *   See the file COPYING for full copying permissions.                      *
 *                                                                           *
 *   This program is free software: you can redistribute it and/or modify    *
 *   it under the terms of the GNU General Public License as published by    *
8
 *   the Free Software Foundation, either version 3 of the License, or       *
9 10 11 12 13 14 15 16 17 18 19 20
 *   (at your option) any later version.                                     *
 *                                                                           *
 *   This program is distributed in the hope that it will be useful,         *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of          *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the            *
 *   GNU General Public License for more details.                            *
 *                                                                           *
 *   You should have received a copy of the GNU General Public License       *
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.   *
 *****************************************************************************/
/*!
 * \file
21 22 23
 * \ingroup BoundaryTests
 * \brief A simple Darcy test problem (cell-centered finite volume method) for
 *        the comparison of different diffusion laws.
24
 */
25

26 27 28 29 30
#ifndef DUMUX_DARCY_SUBPROBLEM_DIFFUSION_COMPARISON_HH
#define DUMUX_DARCY_SUBPROBLEM_DIFFUSION_COMPARISON_HH

#include <dune/grid/yaspgrid.hh>

31
#include <dumux/discretization/cctpfa.hh>
32 33 34 35 36 37 38 39 40 41 42
#include <dumux/flux/maxwellstefanslaw.hh>

#include <dumux/porousmediumflow/1pnc/model.hh>
#include <dumux/porousmediumflow/problem.hh>

#include "./../spatialparams.hh"

#include <dumux/material/fluidsystems/1padapter.hh>
#include <dumux/material/fluidsystems/h2oair.hh>
#include <dumux/material/fluidmatrixinteractions/diffusivityconstanttortuosity.hh>

Timo Koch's avatar
Timo Koch committed
43 44 45 46 47 48 49
// for StokesDarcyCouplingOptions
#include <dumux/multidomain/boundary/stokesdarcy/couplingdata.hh>

#ifndef DIFFUSIONTYPE
#define DIFFUSIONTYPE FicksLaw<TypeTag>
#endif

50
namespace Dumux {
51 52 53
template <class TypeTag>
class DarcySubProblem;

54
namespace Properties {
55 56
// Create new type tags
namespace TTag {
57
struct DarcyOnePTwoC { using InheritsFrom = std::tuple<OnePNC, CCTpfaModel>; };
58 59 60 61
} // end namespace TTag

// Set the problem property
template<class TypeTag>
62
struct Problem<TypeTag, TTag::DarcyOnePTwoC> { using type = Dumux::DarcySubProblem<TypeTag>; };
63 64 65

// The fluid system
template<class TypeTag>
66
struct FluidSystem<TypeTag, TTag::DarcyOnePTwoC>
67 68 69 70 71 72 73 74
{
  using H2OAir = FluidSystems::H2OAir<GetPropType<TypeTag, Properties::Scalar>>;
  static constexpr auto phaseIdx = H2OAir::liquidPhaseIdx; // simulate the water phase
  using type = FluidSystems::OnePAdapter<H2OAir, phaseIdx>;
};

// Use moles
template<class TypeTag>
75
struct UseMoles<TypeTag, TTag::DarcyOnePTwoC> { static constexpr bool value = true; };
76 77 78

// Do not replace one equation with a total mass balance
template<class TypeTag>
79
struct ReplaceCompEqIdx<TypeTag, TTag::DarcyOnePTwoC> { static constexpr int value = 3; };
80 81

//! Use a model with constant tortuosity for the effective diffusivity
82 83 84
template<class TypeTag>
struct EffectiveDiffusivityModel<TypeTag, TTag::DarcyOnePTwoC>
{ using type = DiffusivityConstantTortuosity<GetPropType<TypeTag, Properties::Scalar>>; };
85 86 87

// Set the grid type
template<class TypeTag>
88
struct Grid<TypeTag, TTag::DarcyOnePTwoC> { using type = Dune::YaspGrid<2>; };
89 90 91

// Set the diffusion type
template<class TypeTag>
92
struct MolecularDiffusionType<TypeTag, TTag::DarcyOnePTwoC> { using type = DIFFUSIONTYPE; };
93 94 95

// Set the spatial paramaters type
template<class TypeTag>
96
struct SpatialParams<TypeTag, TTag::DarcyOnePTwoC>
97 98 99 100 101
{
    using FVGridGeometry = GetPropType<TypeTag, Properties::FVGridGeometry>;
    using Scalar = GetPropType<TypeTag, Properties::Scalar>;
    using type = OnePSpatialParams<FVGridGeometry, Scalar>;
};
102
} // end namespace Properties
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151

template <class TypeTag>
class DarcySubProblem : public PorousMediumFlowProblem<TypeTag>
{
    using ParentType = PorousMediumFlowProblem<TypeTag>;
    using GridView = GetPropType<TypeTag, Properties::GridView>;
    using Scalar = GetPropType<TypeTag, Properties::Scalar>;
    using PrimaryVariables = GetPropType<TypeTag, Properties::PrimaryVariables>;
    using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
    using NumEqVector = GetPropType<TypeTag, Properties::NumEqVector>;
    using BoundaryTypes = GetPropType<TypeTag, Properties::BoundaryTypes>;
    using FVElementGeometry = typename GetPropType<TypeTag, Properties::FVGridGeometry>::LocalView;
    using SubControlVolume = typename FVElementGeometry::SubControlVolume;
    using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
    using FVGridGeometry = GetPropType<TypeTag, Properties::FVGridGeometry>;
    using DiffusionCoefficientAveragingType = typename StokesDarcyCouplingOptions::DiffusionCoefficientAveragingType;

    // copy some indices for convenience
    using Indices = typename GetPropType<TypeTag, Properties::ModelTraits>::Indices;
    enum {
        // grid and world dimension
        dim = GridView::dimension,
        dimworld = GridView::dimensionworld,

        // primary variable indices
        conti0EqIdx = Indices::conti0EqIdx,
        pressureIdx = Indices::pressureIdx,
    };

    using Element = typename GridView::template Codim<0>::Entity;
    using GlobalPosition = Dune::FieldVector<Scalar, dimworld>;

    using CouplingManager = GetPropType<TypeTag, Properties::CouplingManager>;

public:
    DarcySubProblem(std::shared_ptr<const FVGridGeometry> fvGridGeometry,
                   std::shared_ptr<CouplingManager> couplingManager)
    : ParentType(fvGridGeometry, "Darcy"), eps_(1e-7), couplingManager_(couplingManager)
    {
        pressure_ = getParamFromGroup<Scalar>(this->paramGroup(), "Problem.Pressure");
        initialMoleFraction_ = getParamFromGroup<Scalar>(this->paramGroup(), "Problem.InitialMoleFraction");
    }

    /*!
     * \name Simulation steering
     */
    // \{

    /*!
152
     * \brief Returns true if a restart file should be written to disk.
153 154 155 156 157 158 159 160 161 162 163 164 165
     */
    bool shouldWriteRestartFile() const
    { return false; }

    /*!
     * \name Problem parameters
     */
    // \{

    bool shouldWriteOutput() const // define output
    { return true; }

    /*!
166
     * \brief Returns the temperature within the domain in [K].
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
     *
     */
    Scalar temperature() const
    { return 273.15 + 10; } // 10°C
    // \}

    /*!
     * \name Boundary conditions
     */
    // \{

    /*!
      * \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;
        values.setAllNeumann();

        if (couplingManager().isCoupledEntity(CouplingManager::darcyIdx, scvf))
            values.setAllCouplingNeumann();

        return values;
    }

    /*!
197
     * \brief Evaluates the boundary conditions for a Neumann control volume.
198 199
     *
     * \param element The element for which the Neumann boundary condition is set
200
     * \param fvGeometry The fvGeometry
201 202 203 204 205 206 207 208 209 210 211 212 213 214
     * \param elemVolVars The element volume variables
     * \param scvf The boundary sub control volume face
     *
     * For this method, the \a values variable stores primary variables.
     */
    template<class ElementVolumeVariables>
    NumEqVector neumann(const Element& element,
                        const FVElementGeometry& fvGeometry,
                        const ElementVolumeVariables& elemVolVars,
                        const SubControlVolumeFace& scvf) const
    {
        NumEqVector values(0.0);

        if (couplingManager().isCoupledEntity(CouplingManager::darcyIdx, scvf))
215
            values = couplingManager().couplingData().massCouplingCondition(element, fvGeometry, elemVolVars, scvf, DiffusionCoefficientAveragingType::harmonic);
216 217 218 219 220 221 222 223 224 225 226

        return values;
    }

    // \}

    /*!
     * \name Volume terms
     */
    // \{
    /*!
227 228
     * \brief Evaluates the source term for all phases within a given
     *        sub control volume.
229 230
     *
     * \param element The element for which the source term is set
231
     * \param fvGeometry The fvGeometry
232
     * \param elemVolVars The element volume variables
233
     * \param scv The sub control volume
234 235 236 237 238 239 240 241 242 243 244
     */
    template<class ElementVolumeVariables>
    NumEqVector source(const Element &element,
                       const FVElementGeometry& fvGeometry,
                       const ElementVolumeVariables& elemVolVars,
                       const SubControlVolume &scv) const
    { return NumEqVector(0.0); }

    // \}

    /*!
245
     * \brief Evaluates the initial value for a control volume.
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285
     *
     * \param element The element
     *
     * For this method, the \a priVars parameter stores primary
     * variables.
     */
    PrimaryVariables initial(const Element &element) const
    {
        PrimaryVariables values(0.0);
        values[pressureIdx] = pressure_;
        values[conti0EqIdx + 1] = initialMoleFraction_;

        return values;
    }

    // \}

    //! Get the coupling manager
    const CouplingManager& couplingManager() const
    { return *couplingManager_; }

private:
    bool onLeftBoundary_(const GlobalPosition &globalPos) const
    { return globalPos[0] < this->fvGridGeometry().bBoxMin()[0] + eps_; }

    bool onRightBoundary_(const GlobalPosition &globalPos) const
    { return globalPos[0] > this->fvGridGeometry().bBoxMax()[0] - eps_; }

    bool onLowerBoundary_(const GlobalPosition &globalPos) const
    { return globalPos[1] < this->fvGridGeometry().bBoxMin()[1] + eps_; }

    bool onUpperBoundary_(const GlobalPosition &globalPos) const
    { return globalPos[1] > this->fvGridGeometry().bBoxMax()[1] - eps_; }

    Scalar eps_;
    Scalar pressure_;
    Scalar initialMoleFraction_;

    std::shared_ptr<CouplingManager> couplingManager_;
};
286
} // end namespace Dumux
287 288

#endif //DUMUX_DARCY_SUBPROBLEM_HH