Commit 37832831 authored by Kilian Weishaupt's avatar Kilian Weishaupt Committed by Timo Koch
Browse files

[ff][staggered] Add new 1p mass model

parent a75c3e18
add_subdirectory(mass)
add_subdirectory(momentum)
add_subdirectory(staggered)
......
file(GLOB DUMUX_FREEFLOW_NAVIERSTOKES_MASS_1P_HEADERS *.hh *.inc)
install(FILES ${DUMUX_FREEFLOW_NAVIERSTOKES_MASS_1P_HEADERS}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dumux/freeflow/navierstokes/mass/1p)
// -*- 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 *
* the Free Software Foundation, either version 3 of the License, or *
* (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
* \ingroup NavierStokesModel
* \brief Helper struct defining the advective fluxes of the single-phase flow
* Navier-Stokes mass model
*/
#ifndef DUMUX_FREEFLOW_NAVIERSTOKES_MASS_1P_ADVECTIVE_FLUX_HH
#define DUMUX_FREEFLOW_NAVIERSTOKES_MASS_1P_ADVECTIVE_FLUX_HH
namespace Dumux {
#ifndef DOXYGEN
// forward declare
struct NavierStokesMassOnePModelTraits;
template<class IsothermalTraits>
struct NavierStokesEnergyModelTraits;
template<class ModelTraits, class T = ModelTraits>
struct AdvectiveFlux;
#endif
/*!
* \ingroup NavierStokesModel
* \brief Helper struct defining the advective fluxes of the single-phase flow
* Navier-Stokes mass model
*/
template<class T>
struct AdvectiveFlux<NavierStokesMassOnePModelTraits, T>
{
template<class NumEqVector, class UpwindFunction>
static void addAdvectiveFlux(NumEqVector& flux,
const UpwindFunction& upwind)
{
using ModelTraits = T;
// get equation index
const auto eqIdx = ModelTraits::Indices::conti0EqIdx;
flux[eqIdx] += upwind([](const auto& volVars) { return volVars.density(); });
}
};
// use the same mass flux for the non-isothermal model (heat fluxes are added separately)
template<>
struct AdvectiveFlux<NavierStokesEnergyModelTraits<NavierStokesMassOnePModelTraits>>
: public AdvectiveFlux<NavierStokesMassOnePModelTraits>
{};
} // end namespace Dumux
#endif
// -*- 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 *
* the Free Software Foundation, either version 3 of the License, or *
* (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
* \ingroup NavierStokesModel
* \copydoc Dumux::NavierStokesMassOnePFluxVariables
*/
#ifndef DUMUX_FREEFLOW_NAVIERSTOKES_MASS_1P_FLUXVARIABLES_HH
#define DUMUX_FREEFLOW_NAVIERSTOKES_MASS_1P_FLUXVARIABLES_HH
#include <dumux/flux/upwindscheme.hh>
#include <dumux/freeflow/navierstokes/scalarfluxvariables.hh>
#include "advectiveflux.hh"
namespace Dumux {
/*!
* \ingroup NavierStokesModel
* \brief The flux variables class for the single-phase flow Navier-Stokes model.
*/
template<class Problem,
class ModelTraits,
class FluxTs,
class ElementVolumeVariables,
class ElementFluxVariablesCache,
class UpwindScheme = UpwindScheme<typename ProblemTraits<Problem>::GridGeometry>>
class NavierStokesMassOnePFluxVariables
: public NavierStokesScalarConservationModelFluxVariables<Problem,
ModelTraits,
FluxTs,
ElementVolumeVariables,
ElementFluxVariablesCache,
UpwindScheme>
{
using ParentType = NavierStokesScalarConservationModelFluxVariables<Problem,
ModelTraits,
FluxTs,
ElementVolumeVariables,
ElementFluxVariablesCache,
UpwindScheme>;
using VolumeVariables = typename ElementVolumeVariables::VolumeVariables;
using NumEqVector = typename VolumeVariables::PrimaryVariables;
public:
/*!
* \brief Returns the advective mass flux in kg/s.
*/
NumEqVector advectiveFlux(int phaseIdx = 0) const
{
NumEqVector result(0.0);
// g++ requires to capture 'this' by value
const auto upwinding = [this](const auto& term) { return this->getAdvectiveFlux(term); };
AdvectiveFlux<ModelTraits>::addAdvectiveFlux(result, upwinding);
return result;
}
/*!
* \brief Returns all fluxes for the single-phase flow Navier-Stokes model: the
* advective mass flux in kg/s and the energy flux in J/s (for nonisothermal models).
*/
NumEqVector flux(int phaseIdx = 0) const
{
NumEqVector flux = advectiveFlux(phaseIdx);
ParentType::addHeatFlux(flux);
return flux;
}
};
} // end namespace Dumux
#endif
// -*- 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 *
* the Free Software Foundation, either version 3 of the License, or *
* (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
* \ingroup NavierStokesModel
* \copydoc Dumux::NavierStokesIndices
*/
#ifndef DUMUX_FREEFLOW_NAVIERSTOKES_MASS_1P_INDICES_HH
#define DUMUX_FREEFLOW_NAVIERSTOKES_MASS_1P_INDICES_HH
namespace Dumux {
/*!
* \ingroup NavierStokesModel
* \brief The common indices for the isothermal Navier-Stokes mass conservation model.
*/
struct NavierStokesMassOnePIndices
{
static constexpr int conti0EqIdx = 0; //!< Index of the first (total for pure-fluid systems) mass balance equation
static constexpr int pressureIdx = conti0EqIdx; //!< Index of the pressure
};
} // end namespace Dumux
#endif
// -*- 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 *
* the Free Software Foundation, either version 3 of the License, or *
* (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
* \ingroup NavierStokesModel
* \copydoc Dumux::NavierStokesResidualImpl
*/
#ifndef DUMUX_FREEFLOW_NAVIERSTOKES_MASS_1P_LOCAL_RESIDUAL_HH
#define DUMUX_FREEFLOW_NAVIERSTOKES_MASS_1P_LOCAL_RESIDUAL_HH
#include <dumux/common/numeqvector.hh>
#include <dumux/common/properties.hh>
namespace Dumux {
/*!
* \ingroup NavierStokesModel
* \brief Element-wise calculation of the Navier-Stokes residual for single-phase flow.
*/
template<class TypeTag>
class NavierStokesMassOnePLocalResidual : public GetPropType<TypeTag, Properties::BaseLocalResidual>
{
using ParentType = GetPropType<TypeTag, Properties::BaseLocalResidual>;
using GridVariables = GetPropType<TypeTag, Properties::GridVariables>;
using GridVolumeVariables = typename GridVariables::GridVolumeVariables;
using ElementVolumeVariables = typename GridVolumeVariables::LocalView;
using VolumeVariables = typename GridVolumeVariables::VolumeVariables;
using GridFluxVariablesCache = typename GridVariables::GridFluxVariablesCache;
using ElementFluxVariablesCache = typename GridFluxVariablesCache::LocalView;
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
using Problem = GetPropType<TypeTag, Properties::Problem>;
using GridGeometry = GetPropType<TypeTag, Properties::GridGeometry>;
using FVElementGeometry = typename GridGeometry::LocalView;
using SubControlVolume = typename FVElementGeometry::SubControlVolume;
using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace;
using GridView = typename GridGeometry::GridView;
using Element = typename GridView::template Codim<0>::Entity;
using FluxVariables = GetPropType<TypeTag, Properties::FluxVariables>;
using NumEqVector = Dumux::NumEqVector<GetPropType<TypeTag, Properties::PrimaryVariables>>;
using ModelTraits = GetPropType<TypeTag, Properties::ModelTraits>;
public:
//! Use the parent type's constructor
using ParentType::ParentType;
/*!
* \brief Calculate the storage term of the equation
*/
NumEqVector computeStorage(const Problem& problem,
const SubControlVolume& scv,
const VolumeVariables& volVars) const
{
NumEqVector storage(0.0);
storage[ModelTraits::Indices::conti0EqIdx] = volVars.density();
// consider energy storage for non-isothermal models
if constexpr (ModelTraits::enableEnergyBalance())
storage[ModelTraits::Indices::energyEqIdx] = volVars.density() * volVars.internalEnergy();
return storage;
}
/*!
* \brief Evaluatex the mass flux over a face of a sub control volume.
*
* \param problem The problem
* \param element The element
* \param fvGeometry The finite volume geometry context
* \param elemVolVars The volume variables for all flux stencil elements
* \param scvf The sub control volume face to compute the flux on
* \param elemFluxVarsCache The cache related to flux computation
*/
NumEqVector computeFlux(const Problem& problem,
const Element& element,
const FVElementGeometry& fvGeometry,
const ElementVolumeVariables& elemVolVars,
const SubControlVolumeFace& scvf,
const ElementFluxVariablesCache& elemFluxVarsCache) const
{
FluxVariables fluxVars;
fluxVars.init(problem, element, fvGeometry, elemVolVars, scvf, elemFluxVarsCache);
return fluxVars.flux(0);
}
};
} // end namespace Dumux
#endif
// -*- 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 *
* the Free Software Foundation, either version 3 of the License, or *
* (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
* \ingroup NavierStokesModel
*
* \brief A single-phase, isothermal Navier-Stokes model
*
* This model implements a single-phase, isothermal Navier-Stokes model, solving the <B> momentum balance equation </B>
* \f[
\frac{\partial (\varrho \textbf{v})}{\partial t} + \nabla \cdot (\varrho \textbf{v} \textbf{v}^{\text{T}}) = \nabla \cdot (\mu (\nabla \textbf{v} + \nabla \textbf{v}^{\text{T}}))
- \nabla p + \varrho \textbf{g} - \textbf{f}
* \f]
* By setting the runtime parameter <code>Problem.EnableInertiaTerms</code> to <code>false</code> the Stokes
* equation can be solved. In this case the term
* \f[
* \nabla \cdot (\varrho \textbf{v} \textbf{v}^{\text{T}})
* \f]
* is neglected.
*
* The <B> mass balance equation </B>
* \f[
\frac{\partial \varrho}{\partial t} + \nabla \cdot (\varrho \textbf{v}) - q = 0
* \f]
*
* closes the system.
*
*
* So far, only the staggered grid spatial discretization (for structured grids) is available.
*/
#ifndef DUMUX_FREEFLOW_NAVIERSTOKES_1P_MODEL_HH
#define DUMUX_FREEFLOW_NAVIERSTOKES_1P_MODEL_HH
#include <dumux/common/properties.hh>
#include <dumux/common/properties/model.hh>
#include <dumux/material/fluidstates/immiscible.hh>
#include <dumux/freeflow/navierstokes/iofields.hh>
#include <dumux/freeflow/turbulencemodel.hh>
#include <dumux/freeflow/navierstokes/energy/model.hh>
#include <dumux/freeflow/navierstokes/scalarfluxvariablescachefiller.hh>
#include <dumux/flux/fourierslaw.hh>
#include "localresidual.hh"
#include "volumevariables.hh"
#include "fluxvariables.hh"
#include "indices.hh"
namespace Dumux {
/*!
* \ingroup NavierStokesModel
* \brief Traits for the single-phase flow Navier-Stokes mass model
*/
struct NavierStokesMassOnePModelTraits
{
//! There are as many momentum balance equations as dimensions
//! and one mass balance equation.
static constexpr int numEq() { return 1; }
//! The number of phases is 1
static constexpr int numFluidPhases() { return 1; }
//! The number of components is 1
static constexpr int numFluidComponents() { return 1; }
//! Enable advection
static constexpr bool enableAdvection() { return true; }
//! The one-phase model has no molecular diffusion
static constexpr bool enableMolecularDiffusion() { return false; }
//! The model is isothermal
static constexpr bool enableEnergyBalance() { return false; }
//! The model does not include a turbulence model
static constexpr bool usesTurbulenceModel() { return false; }
//! return the type of turbulence model used
static constexpr auto turbulenceModel()
{ return TurbulenceModel::none; }
//! the indices
using Indices = NavierStokesMassOnePIndices;
};
/*!
* \ingroup NavierStokesModel
* \brief Traits class for the volume variables of the Navier-Stokes model.
*
* \tparam PV The type used for primary variables
* \tparam FSY The fluid system type
* \tparam FST The fluid state type
* \tparam MT The model traits
*/
template<class PV,
class FSY,
class FST,
class MT>
struct NavierStokesMassOnePVolumeVariablesTraits
{
using PrimaryVariables = PV;
using FluidSystem = FSY;
using FluidState = FST;
using ModelTraits = MT;
};
// \{
///////////////////////////////////////////////////////////////////////////
// properties for the single-phase Navier-Stokes model
///////////////////////////////////////////////////////////////////////////
namespace Properties {
//////////////////////////////////////////////////////////////////
// Type tags
//////////////////////////////////////////////////////////////////
// Create new type tags
namespace TTag {
//! The type tag for the single-phase, isothermal Navier-Stokes model
struct NavierStokesMassOneP{ using InheritsFrom = std::tuple<ModelProperties>; };
struct NavierStokesMassOnePNI{ using InheritsFrom = std::tuple<NavierStokesMassOneP>; };
} // end namespace TTag
template<class TypeTag>
struct ModelTraits<TypeTag, TTag::NavierStokesMassOneP>
{ using type = NavierStokesMassOnePModelTraits; };
/*!
* \brief The fluid state which is used by the volume variables to
* store the thermodynamic state. This should be chosen
* appropriately for the model ((non-)isothermal, equilibrium, ...).
* This can be done in the problem.
*/
template<class TypeTag>
struct FluidState<TypeTag, TTag::NavierStokesMassOneP>
{
private:
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
public:
using type = Dumux::ImmiscibleFluidState<Scalar, FluidSystem>;
};
//! The local residual
template<class TypeTag>
struct LocalResidual<TypeTag, TTag::NavierStokesMassOneP>
{ using type = NavierStokesMassOnePLocalResidual<TypeTag>; };
//! Set the volume variables property
template<class TypeTag>
struct VolumeVariables<TypeTag, TTag::NavierStokesMassOneP>
{
private:
using PV = GetPropType<TypeTag, Properties::PrimaryVariables>;
using FSY = GetPropType<TypeTag, Properties::FluidSystem>;
using FST = GetPropType<TypeTag, Properties::FluidState>;
using MT = GetPropType<TypeTag, Properties::ModelTraits>;
static_assert(FSY::numPhases == MT::numFluidPhases(), "Number of phases mismatch between model and fluid system");
static_assert(FST::numPhases == MT::numFluidPhases(), "Number of phases mismatch between model and fluid state");
static_assert(!FSY::isMiscible(), "The Navier-Stokes model only works with immiscible fluid systems.");
using Traits = NavierStokesMassOnePVolumeVariablesTraits<PV, FSY, FST, MT>;
public:
using type = NavierStokesMassOnePVolumeVariables<Traits>;
};
//! The flux variables
template<class TypeTag>
struct FluxVariables<TypeTag, TTag::NavierStokesMassOneP>
{
private:
using Problem = GetPropType<TypeTag, Properties::Problem>;
using ModelTraits = GetPropType<TypeTag, Properties::ModelTraits>;
struct DiffusiveFluxTypes {}; // no diffusion
using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView;
using ElementFluxVariablesCache = typename GetPropType<TypeTag, Properties::GridFluxVariablesCache>::LocalView;
public:
using type = NavierStokesMassOnePFluxVariables<
Problem, ModelTraits, DiffusiveFluxTypes, ElementVolumeVariables, ElementFluxVariablesCache
>;
};
template<class TypeTag>
struct FluxVariablesCache<TypeTag, TTag::NavierStokesMassOneP>
{ using type = FluxVariablesCaching::EmptyCache<GetPropType<TypeTag, Properties::Scalar>>; };
template<class TypeTag>
struct FluxVariablesCacheFiller<TypeTag, TTag::NavierStokesMassOneP>
{ using type = FluxVariablesCaching::EmptyCacheFiller; };
// ! The specific I/O fields
template<class TypeTag>
struct IOFields<TypeTag, TTag::NavierStokesMassOneP> { using type = NavierStokesIOFields; };
template<class TypeTag>
struct CouplingManager<TypeTag, TTag::NavierStokesMassOneP>
{
public:
using type = struct EmptyCouplingManager {};
};
///////////////////////////////////////////////////////////////////////////
// Properties for the non-isothermal single phase model
///////////////////////////////////////////////////////////////////////////
//! Add temperature to the output
template<class TypeTag>
struct IOFields<TypeTag, TTag::NavierStokesMassOnePNI>
{ using type = NavierStokesEnergyIOFields<NavierStokesIOFields>; };
//! The model traits of the non-isothermal model
template<class TypeTag>
struct ModelTraits<TypeTag, TTag::NavierStokesMassOnePNI>
{ using type = NavierStokesEnergyModelTraits<NavierStokesMassOnePModelTraits>; };
//! Set the volume variables property
template<class TypeTag>
struct VolumeVariables<TypeTag, TTag::NavierStokesMassOnePNI>
{
private:
using PV = GetPropType<TypeTag, Properties::PrimaryVariables>;
using FSY = GetPropType<TypeTag, Properties::FluidSystem>;
using FST = GetPropType<TypeTag, Properties::FluidState>;
using MT = GetPropType<TypeTag, Properties::ModelTraits>;
static_assert(FSY::numPhases == MT::numFluidPhases(), "Number of phases mismatch between model and fluid system");
static_assert(FST::numPhases == MT::numFluidPhases(), "Number of phases mismatch between model and fluid state");
static_assert(!FSY::isMiscible(), "The Navier-Stokes model only works with immiscible fluid systems.");
using BaseTraits = NavierStokesMassOnePVolumeVariablesTraits<PV, FSY, FST, MT>;
using ETCM = GetPropType<TypeTag, Properties::ThermalConductivityModel>;
using HCT = GetPropType<TypeTag, Properties::HeatConductionType>;
struct NITraits : public BaseTraits
{
using EffectiveThermalConductivityModel = ETCM;
using HeatConductionType = HCT;
};
public:
using type = NavierStokesMassOnePVolumeVariables<NITraits>;
};
//! Use the average for effective conductivities
template<class TypeTag>
struct ThermalConductivityModel<TypeTag, TTag::NavierStokesMassOnePNI>
{
struct type
{
template<class VolVars>
static auto effectiveThermalConductivity(const VolVars& volVars)
{
return volVars.fluidThermalConductivity();
}
};
};
template<class TypeTag>
struct HeatConductionType<TypeTag, TTag::NavierStokesMassOnePNI>
{ using type = FouriersLaw<TypeTag>; };