Commit c4feaf0a authored by Dennis Gläser's avatar Dennis Gläser
Browse files

Merge branch 'feature/freeflow-new-staggered-stokes' into 'master'

[freeflow] Add mass/energy model and donea/channel/sincos test with new staggered

See merge request !2823
parents 6fb0dae6 f9933f1b
......@@ -133,7 +133,7 @@ public:
boundaryVolVarIndices_.push_back(scvFace.outsideScvIdx());
};
if (bcTypes.hasOnlyDirichlet())
if (bcTypes.hasDirichlet())
{
addBoundaryVolVars(scvf);
continue;
......@@ -141,7 +141,7 @@ public:
// treat domain corners
if (const auto& orthogonalScvf = fvGeometry.lateralOrthogonalScvf(scvf); orthogonalScvf.boundary())
if (problem.boundaryTypes(element, orthogonalScvf).hasOnlyDirichlet())
if (problem.boundaryTypes(element, orthogonalScvf).hasDirichlet())
addBoundaryVolVars(scvf);
}
......@@ -364,7 +364,7 @@ private:
volVarIndices_.push_back(scvFace.outsideScvIdx());
};
if (bcTypes.hasOnlyDirichlet())
if (bcTypes.hasDirichlet())
{
addBoundaryVolVars(scvf);
continue;
......@@ -372,7 +372,7 @@ private:
// treat domain corners
if (const auto& orthogonalScvf = fvGeometry.lateralOrthogonalScvf(scvf); orthogonalScvf.boundary())
if (problem.boundaryTypes(element, orthogonalScvf).hasOnlyDirichlet())
if (problem.boundaryTypes(element, orthogonalScvf).hasDirichlet())
addBoundaryVolVars(scvf);
}
......
add_subdirectory(energy)
add_subdirectory(mass)
add_subdirectory(momentum)
add_subdirectory(staggered)
......
file(GLOB DUMUX_FREEFLOW_NAVIERSTOKES_ENERGY_HEADERS *.hh *.inc)
install(FILES ${DUMUX_FREEFLOW_NAVIERSTOKES_ENERGY_HEADERS}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dumux/freeflow/navierstokes/energy)
// -*- 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 FreeflowNIModel
* \copydoc Dumux::FreeflowNonIsothermalIndices
*/
#ifndef DUMUX_FREEFLOW_NAVIER_STOKES_ENERGY_INDICES_HH
#define DUMUX_FREEFLOW_NAVIER_STOKES_ENERGY_INDICES_HH
namespace Dumux {
/*!
* \ingroup FreeflowNIModel
* \brief Indices for the non-isothermal Navier-Stokes model.
*
* \tparam IsothermalIndices The isothermal indices class
* \tparam numEq the number of equations of the non-isothermal model
*/
template <class IsothermalIndices, int numEq>
class NavierStokesEnergyIndices : public IsothermalIndices
{
public:
static constexpr int energyEqIdx = numEq - 1;
static constexpr int temperatureIdx = numEq - 1;
};
} // 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 FreeflowNIModel
* \copydoc Dumux::FreeflowNonIsothermalIOFields
*/
#ifndef DUMUX_FREEFLOW_NAVIERSTOKES_ENERGY_IO_FIELDS_HH
#define DUMUX_FREEFLOW_NAVIERSTOKES_ENERGY_IO_FIELDS_HH
#include <dumux/io/name.hh>
namespace Dumux {
/*!
* \ingroup FreeflowNIModel
* \brief Adds I/O fields specific to non-isothermal free-flow models
*/
template<class IsothermalIOFields>
struct NavierStokesEnergyIOFields
{
//! Add the non-isothermal specific output fields.
template <class OutputModule>
static void initOutputModule(OutputModule& out)
{
IsothermalIOFields::initOutputModule(out);
out.addVolumeVariable([](const auto& v){ return v.temperature(); }, IOName::temperature());
out.addVolumeVariable([](const auto& v){ return v.fluidThermalConductivity(); }, "lambda");
}
//! return the names of the primary variables
template<class ModelTraits, class FluidSystem = void>
static std::string primaryVariableName(int pvIdx, int state = 0)
{
if (pvIdx < ModelTraits::numEq() - 1)
return IsothermalIOFields::template primaryVariableName<ModelTraits, FluidSystem>(pvIdx, state);
else
return IOName::temperature();
}
};
} // 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 FreeflowNIModel
*
* \brief A single-phase, non-isothermal free-flow model
*
* In addition to the momentum and mass/mole balance equations, this model also solves the <B> energy balance equation </B>:
* \f[
* \frac{\partial (\varrho v)}{\partial t}
* + \nabla \cdot \left( \varrho h {\boldsymbol{v}}
* - \lambda_\text{eff} \textbf{grad}\, T \right) - q_T = 0
* \f]
*
*
* For laminar Navier-Stokes flow the effective thermal conductivity is the fluid
* thermal conductivity: \f$ \lambda_\text{eff} = \lambda \f$.
*
* For turbulent Reynolds-averaged Navier-Stokes flow the eddy thermal conductivity is added:
* \f$ \lambda_\text{eff} = \lambda + \lambda_\text{t} \f$.
* The eddy thermal conductivity \f$ \lambda_\text{t} \f$ is related to the eddy viscosity \f$ \nu_\text{t} \f$
* by the turbulent Prandtl number:
* \f[ \lambda_\text{t} = \frac{\nu_\text{t} \varrho c_\text{p}}{\mathrm{Pr}_\text{t}} \f]
*/
#ifndef DUMUX_FREEFLOW_NAVIER_STOKES_ENERGY_MODEL_HH
#define DUMUX_FREEFLOW_NAVIER_STOKES_ENERGY_MODEL_HH
#include "indices.hh"
#include "iofields.hh"
namespace Dumux {
/*!
* \ingroup FreeflowNIModel
* \brief Specifies a number properties of non-isothermal free-flow
* flow models based on the specifics of a given isothermal model.
* \tparam IsothermalT Model traits of the isothermal model
*/
template<class IsothermalT>
struct NavierStokesEnergyModelTraits : public IsothermalT
{
//! Export the isothermal model traits
using IsothermalTraits = IsothermalT;
//! We solve for one more equation, i.e. the energy balance
static constexpr int numEq() { return IsothermalTraits::numEq()+1; }
//! We additionally solve for the equation balance
static constexpr bool enableEnergyBalance() { return true; }
//! the indices
using Indices = NavierStokesEnergyIndices<typename IsothermalTraits::Indices, numEq()>;
};
} // 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 NIModel
* \brief Base class for the model specific class which provides
* access to all volume averaged quantities.
*/
#ifndef DUMUX_FREEFLOW_NAVIER_STOKES_ENERGY_VOLUME_VARIABLES_HH
#define DUMUX_FREEFLOW_NAVIER_STOKES_ENERGY_VOLUME_VARIABLES_HH
#include <type_traits>
#include <dune/common/std/type_traits.hh>
namespace Dumux {
namespace Detail {
struct EmptyFreeFlowHeatCondType {};
template<bool enableEnergyBalance, class Traits>
struct FreeFlowHeatCondType
{
using type = EmptyFreeFlowHeatCondType;
};
template<class Traits>
struct FreeFlowHeatCondType<true, Traits>
{
using type = typename Traits::HeatConductionType;
};
} // end namespace Detail
/*!
* \ingroup NIModel
* \brief The isothermal base class
*/
template<class Traits, class Impl>
class NavierStokesEnergyVolumeVariables
{
using Scalar = typename Traits::PrimaryVariables::value_type;
static constexpr bool enableEnergyBalance = Traits::ModelTraits::enableEnergyBalance();
public:
using FluidState = typename Traits::FluidState;
using FluidSystem = typename Traits::FluidSystem;
using HeatConductionType = typename Detail::FreeFlowHeatCondType<enableEnergyBalance, Traits>::type;
/*!
* \brief Returns the temperature at a given sub-control volume
*
* \param elemSol A vector containing all primary variables connected to the element
* \param problem The object specifying the problem which ought to
* be simulated
* \param element An element which contains part of the control volume
* \param scv The sub-control volume
*/
template<class ElementSolution, class Problem, class Element, class SubControlVolume>
Scalar getTemperature(const ElementSolution& elemSol,
const Problem& problem,
const Element& element,
const SubControlVolume& scv) const
{
if constexpr (enableEnergyBalance)
return elemSol[scv.localDofIndex()][Traits::ModelTraits::Indices::temperatureIdx];
else
return problem.temperatureAtPos(scv.dofPosition());
}
//! The effective thermal conductivity is zero for isothermal models
void updateEffectiveThermalConductivity()
{
if constexpr (enableEnergyBalance)
lambdaEff_ = Traits::EffectiveThermalConductivityModel::effectiveThermalConductivity(asImp_());
}
/*!
* \brief Returns the total internal energy of a phase in the
* sub-control volume.
*
* \param phaseIdx The phase index
*/
Scalar internalEnergy(const int phaseIdx = 0) const
{
if constexpr (enableEnergyBalance)
return asImp_().fluidState().internalEnergy(0);
else
return 0.0;
}
/*!
* \brief Returns the total enthalpy of a phase in the sub-control
* volume.
*
* \param phaseIdx The phase index
*/
Scalar enthalpy(const int phaseIdx = 0) const
{
if constexpr (enableEnergyBalance)
return asImp_().fluidState().enthalpy(0);
else
return 0.0;
}
/*!
* \brief Returns the temperature of a fluid phase assuming thermal nonequilibrium
* the sub-control volume.
* \param phaseIdx The local index of the phases
*/
Scalar temperatureFluid(const int phaseIdx = 0) const
{ return asImp_().fluidState().temperature(0); }
/*!
* \brief Returns the thermal conductivity \f$\mathrm{[W/(m*K)]}\f$
* of a fluid phase in the sub-control volume.
*/
Scalar fluidThermalConductivity(const int phaseIdx = 0) const
{ return FluidSystem::thermalConductivity(asImp_().fluidState(), 0); }
/*!
* \brief Returns the effective thermal conductivity \f$\mathrm{[W/(m*K)]}\f$ in
* the sub-control volume. Specific to equilibirum models (case fullThermalEquilibrium).
*/
Scalar effectiveThermalConductivity(const int phaseIdx = 0) const
{ return lambdaEff_; }
//! The phase enthalpy is zero for isothermal models
//! This is needed for completing the fluid state
template<class ParameterCache>
static Scalar enthalpy(const FluidState& fluidState,
const ParameterCache& paramCache)
{
if constexpr (enableEnergyBalance)
return FluidSystem::enthalpy(fluidState, paramCache, 0);
else
return 0.0;
}
protected:
Scalar lambdaEff_;
const Impl &asImp_() const { return *static_cast<const Impl*>(this); }
Impl &asImp_() { return *static_cast<Impl*>(this); }
};
} // end namespace Dumux
#endif
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