Commit 1dd07d34 authored by Kilian Weishaupt's avatar Kilian Weishaupt
Browse files

[freeflow][non-isothermal] Revise non-isthermal model

* rename folder staggeredni -> nonisothermal
* use Dune ifelse for energy-transport/storage in fluxVars/localRes
* remove now obsolete headers
* now independent of discretization
parent 70e47a50
......@@ -68,7 +68,6 @@ public:
static constexpr int value = GET_PROP_VALUE(TypeTag, NumEq) - dim;
};
//! The default sub-controlvolume face
SET_PROP(StaggeredFreeFlowModel, SubControlVolumeFace)
{
......
add_subdirectory("navierstokes")
add_subdirectory("staggerednc")
add_subdirectory("staggeredni")
add_subdirectory("nonisothermal")
......@@ -27,7 +27,7 @@
#include <dumux/common/properties.hh>
#include <dumux/freeflow/properties.hh>
#include <dumux/freeflow/staggeredni/properties.hh>
#include <dumux/freeflow/nonisothermal/model.hh>
#include "localresidual.hh"
#include "volumevariables.hh"
......@@ -70,8 +70,6 @@
NEW_PROP_TAG(EnableComponentTransport); //!< Returns whether to consider component transport or not
NEW_PROP_TAG(EnableEnergyTransport); //!< Returns whether to consider energy transport or not
NEW_PROP_TAG(NormalizePressure); //!< Returns whether to normalize the pressure term in the momentum balance or not
NEW_PROP_TAG(EnergyLocalResidual); //!< The energy local residual
NEW_PROP_TAG(EnergyFluxVariables); //!< The energy flux variables
///////////////////////////////////////////////////////////////////////////
// default property values for the isothermal single phase model
......@@ -80,6 +78,16 @@
SET_INT_PROP(NavierStokes, NumComponents, 1); //! The number of components in the 1p model is 1
SET_INT_PROP(NavierStokes, PhaseIdx, 0); //! The default phase index
//! The number of equations
SET_PROP(NavierStokes, NumEq)
{
private:
using GridView = typename GET_PROP_TYPE(TypeTag, GridView);
static constexpr auto dim = GridView::dimension;
public:
static constexpr int value = dim + 1;
};
/*!
* \brief The fluid state which is used by the volume variables to
* store the thermodynamic state. This should be chosen
......@@ -115,10 +123,6 @@
//! The indices required by the isothermal single-phase model
SET_TYPE_PROP(NavierStokes, Indices, NavierStokesCommonIndices<TypeTag>);
SET_TYPE_PROP(NavierStokes, EnergyLocalResidual, FreeFlowEnergyLocalResidual<TypeTag>);
SET_TYPE_PROP(NavierStokes, EnergyFluxVariables, FreeFlowEnergyFluxVariables<TypeTag>);
SET_BOOL_PROP(NavierStokes, EnableEnergyBalance, false);
SET_TYPE_PROP(NavierStokes, VtkOutputFields, NavierStokesVtkOutputFields<TypeTag>);
......@@ -141,8 +145,14 @@
SET_TYPE_PROP(NavierStokesNI, IsothermalVtkOutputFields, NavierStokesVtkOutputFields<TypeTag>);
//set isothermal NumEq
SET_INT_PROP(NavierStokesNI, IsothermalNumEqCellCenter, 1); //!< set the number of equations to 1
SET_INT_PROP(NavierStokesNI, IsothermalNumEqFace, 1); //!< set the number of equations to 1
SET_PROP(NavierStokesNI, IsothermalNumEq)
{
private:
using GridView = typename GET_PROP_TYPE(TypeTag, GridView);
static constexpr auto dim = GridView::dimension;
public:
static constexpr int value = dim + 1;
};
// \}
}
......
......@@ -23,6 +23,7 @@
#ifndef DUMUX_STAGGERED_NAVIERSTOKES_LOCAL_RESIDUAL_HH
#define DUMUX_STAGGERED_NAVIERSTOKES_LOCAL_RESIDUAL_HH
#include <dune/common/hybridutilities.hh>
#include <dumux/common/properties.hh>
namespace Dumux
......@@ -32,7 +33,6 @@ namespace Properties
{
// forward declaration
NEW_PROP_TAG(EnableInertiaTerms);
NEW_PROP_TAG(EnergyFluxVariables);
NEW_PROP_TAG(NormalizePressure);
NEW_PROP_TAG(ElementFaceVariables);
}
......@@ -74,8 +74,6 @@ class NavierStokesResidualImpl<TypeTag, DiscretizationMethods::Staggered> : publ
using FacePrimaryVariables = typename GET_PROP_TYPE(TypeTag, FacePrimaryVariables);
using Indices = typename GET_PROP_TYPE(TypeTag, Indices);
using FluxVariables = typename GET_PROP_TYPE(TypeTag, FluxVariables);
using EnergyLocalResidual = typename GET_PROP_TYPE(TypeTag, EnergyLocalResidual);
using EnergyFluxVariables = typename GET_PROP_TYPE(TypeTag, EnergyFluxVariables);
using ElementFaceVariables = typename GET_PROP_TYPE(TypeTag, ElementFaceVariables);
......@@ -85,7 +83,6 @@ class NavierStokesResidualImpl<TypeTag, DiscretizationMethods::Staggered> : publ
using CellCenterResidual = typename GET_PROP_TYPE(TypeTag, CellCenterPrimaryVariables);
using FaceResidual = typename GET_PROP_TYPE(TypeTag, FacePrimaryVariables);
using FaceResidualVector = typename GET_PROP_TYPE(TypeTag, FaceSolutionVector);
enum {
// grid and world dimension
......@@ -121,7 +118,27 @@ public:
CellCenterPrimaryVariables flux = fluxVars.computeFluxForCellCenter(problem, element, fvGeometry, elemVolVars,
elemFaceVars, scvf, elemFluxVarsCache[scvf]);
EnergyFluxVariables::energyFlux(flux, problem, element, fvGeometry, elemVolVars, elemFaceVars, scvf, elemFluxVarsCache[scvf]);
// add energy fluxes for non-isothermal models
Dune::Hybrid::ifElse(std::integral_constant<bool, GET_PROP_VALUE(TypeTag, EnableEnergyBalance) >(),
[&](auto IF)
{
// if we are on an inflow/outflow boundary, use the volVars of the element itself
// TODO: catch neumann and outflow in localResidual's evalBoundary_()
bool isOutflow = false;
if(scvf.boundary())
{
const auto bcTypes = problem.boundaryTypesAtPos(scvf.center());
if(bcTypes.isOutflow(Indices::energyBalanceIdx))
isOutflow = true;
}
auto upwindTerm = [](const auto& volVars) { return volVars.density() * volVars.enthalpy(); };
using HeatConductionType = typename GET_PROP_TYPE(TypeTag, HeatConductionType);
flux[Indices::energyBalanceIdx] = FluxVariables::advectiveFluxForCellCenter(elemVolVars, elemFaceVars, scvf, upwindTerm, isOutflow);
flux[Indices::energyBalanceIdx] += HeatConductionType::diffusiveFluxForCellCenter(problem, element, fvGeometry, elemVolVars, scvf);
});
return flux;
}
......@@ -133,8 +150,7 @@ public:
const ElementFaceVariables& elemFaceVars,
const SubControlVolume &scv) const
{
return CellCenterPrimaryVariables(0.0);
// TODO sources
return problem.sourceAtPos(scv.center())[cellCenterIdx];
}
......@@ -153,8 +169,15 @@ public:
const VolumeVariables& volVars) const
{
CellCenterPrimaryVariables storage;
storage[0] = volVars.density();
EnergyLocalResidual::fluidPhaseStorage(storage, scv, volVars);
storage[Indices::massBalanceIdx] = volVars.density();
// add energy storage for non-isothermal models
Dune::Hybrid::ifElse(std::integral_constant<bool, GET_PROP_VALUE(TypeTag, EnableEnergyBalance) >(),
[&](auto IF)
{
storage[Indices::energyBalanceIdx] = volVars.density() * volVars.internalEnergy();
});
return storage;
}
......
#install headers
install(FILES
indices.hh
model.hh
vtkoutputfields.hh
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dumux/freeflow/nonisothermal)
......@@ -18,10 +18,10 @@
*****************************************************************************/
/*!
* \file
* \brief Defines the indices for the staggered Navier-Stokes NI model.
* \brief Defines the indices for the Navier-Stokes NI model.
*/
#ifndef DUMUX_STAGGERED_NAVIERSTOKES_NI_INDICES_HH
#define DUMUX_STAGGERED_NAVIERSTOKES_NI_INDICES_HH
#ifndef DUMUX_NAVIERSTOKES_NI_INDICES_HH
#define DUMUX_NAVIERSTOKES_NI_INDICES_HH
#include <dumux/common/properties.hh>
......@@ -31,7 +31,7 @@ namespace Dumux
/*!
* \ingroup NavierStokesNIModel
* \ingroup ImplicitIndices
* \brief Indices for the staggered Navier-Stokes NI model model.
* \brief Indices for the Navier-Stokes NI model model.
*
* \tparam PVOffset The first index in a primary variable vector.
*/
......@@ -39,11 +39,13 @@ template <class TypeTag, int PVOffset = 0>
class NavierStokesNonIsothermalIndices : public GET_PROP_TYPE(TypeTag, IsothermalIndices)
{
public:
static const int numEqCC = GET_PROP_VALUE(TypeTag, NumEqCellCenter);
using GridView = typename GET_PROP_TYPE(TypeTag, GridView);
static constexpr auto dim = GridView::dimension;
static constexpr auto numEq = GET_PROP_VALUE(TypeTag, NumEq);
static constexpr int energyBalanceIdx = PVOffset + numEqCC -1;
static constexpr auto energyBalanceIdx = PVOffset + GET_PROP_VALUE(TypeTag, NumEq) - dim - 1;
static constexpr int temperatureIdx = energyBalanceIdx;
};
} // end namespace
#endif
#endif // DUMUX_NAVIERSTOKES_NI_INDICES_HH
......@@ -17,28 +17,25 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*****************************************************************************/
/*!
* \ingroup Properties
* \ingroup ImplicitProperties
* \ingroup OnePModel
* \file
*
* \brief Defines the properties required for the one-phase fully implicit model.
* \brief Base class for all models which use the one-phase,
* fully implicit model.
* Adaption of the fully implicit scheme to the one-phase flow model.
*/
#ifndef DUMUX_NAVIER_STOKES_NI_PROPERTIES_HH
#define DUMUX_NAVIER_STOKES_NI_PROPERTIES_HH
#ifndef DUMUX_STAGGERED_NI_MODEL_HH
#define DUMUX_STAGGERED_NI_MODEL_HH
#include <dumux/common/properties.hh>
#include "fluxvariables.hh"
#include "indices.hh"
#include "localresidual.hh"
#include "vtkoutputfields.hh"
#include <dumux/discretization/fourierslaw.hh>
namespace Dumux
{
// \{
namespace Properties {
//! The type tags for the non-isothermal Navier Stokes problems
......@@ -51,22 +48,13 @@ NEW_PROP_TAG(IsothermalNumEqFace);
// default property values for the non-isothermal single phase model
///////////////////////////////////////////////////////////////////////////
SET_PROP(NavierStokesNonIsothermal, NumEqCellCenter)
{
private:
static constexpr auto isothermalNumEqCellCenter = GET_PROP_VALUE(TypeTag, IsothermalNumEqCellCenter);
public:
static constexpr auto value = isothermalNumEqCellCenter + 1;
};
SET_PROP(NavierStokesNonIsothermal, NumEq)
{
private:
using GridView = typename GET_PROP_TYPE(TypeTag, GridView);
static constexpr auto dim = GridView::dimension;
static constexpr auto numComponents = GET_PROP_VALUE(TypeTag, NumComponents);
static constexpr auto isothermalNumEq = GET_PROP_VALUE(TypeTag, IsothermalNumEq);
public:
static constexpr int value = dim + numComponents + 1;
static constexpr int value = isothermalNumEq + 1;
};
SET_TYPE_PROP(NavierStokesNonIsothermal, Indices, NavierStokesNonIsothermalIndices<TypeTag>);
......@@ -79,6 +67,6 @@ SET_TYPE_PROP(NavierStokesNonIsothermal, HeatConductionType, FouriersLaw<TypeTag
} // end namespace Properties
} // end namespace Dumux
}
#endif
......@@ -36,16 +36,6 @@ namespace Properties
//! Type tag for free-flow models
NEW_TYPE_TAG(FreeFlow, INHERITS_FROM(ModelProperties));
SET_PROP(FreeFlow, NumEq)
{
private:
using GridView = typename GET_PROP_TYPE(TypeTag, GridView);
static constexpr auto dim = GridView::dimension;
static constexpr auto numComponents = GET_PROP_VALUE(TypeTag, NumComponents);
public:
static constexpr int value = dim + numComponents;
};
} // namespace Properties
} // namespace Dumux
......
#install headers
install(FILES
indices.hh
localresidual.hh
model.hh
properties.hh
propertydefaults.hh
volumevariables.hh
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dumux/porousmediumflow/1p/implicit)
\ No newline at end of file
// -*- 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 2 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
* \brief Base class for the flux variables
*/
#ifndef DUMUX_FREELOW_IMPLICIT_NI_FLUXVARIABLES_HH
#define DUMUX_FREELOW_IMPLICIT_NI_FLUXVARIABLES_HH
#include <dumux/common/properties.hh>
namespace Dumux
{
namespace Properties
{
NEW_PROP_TAG(ElementFaceVariables);
}
/*!
* \ingroup ImplicitModel
* \brief The flux variables class
* specializations are provided for combinations of physical processes
* \note Not all specializations are currently implemented
*/
// forward declaration
template<class TypeTag, bool enableEnergyBalance>
class FreeFlowEnergyFluxVariablesImplementation;
template<class TypeTag>
using FreeFlowEnergyFluxVariables = FreeFlowEnergyFluxVariablesImplementation<TypeTag, GET_PROP_VALUE(TypeTag, EnableEnergyBalance)>;
// specialization for isothermal flow
template<class TypeTag>
class FreeFlowEnergyFluxVariablesImplementation<TypeTag, false>
{
using GridView = typename GET_PROP_TYPE(TypeTag, GridView);
using Problem = typename GET_PROP_TYPE(TypeTag, Problem);
using Element = typename GridView::template Codim<0>::Entity;
using FVElementGeometry = typename GET_PROP_TYPE(TypeTag, FVElementGeometry);
using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar);
using ElementVolumeVariables = typename GET_PROP_TYPE(TypeTag, ElementVolumeVariables);
using ElementFaceVariables = typename GET_PROP_TYPE(TypeTag, ElementFaceVariables);
using SubControlVolumeFace = typename GET_PROP_TYPE(TypeTag, SubControlVolumeFace);
using FluxVariablesCache = typename GET_PROP_TYPE(TypeTag, FluxVariablesCache);
using CellCenterPrimaryVariables = typename GET_PROP_TYPE(TypeTag, CellCenterPrimaryVariables);
public:
static void energyFlux(CellCenterPrimaryVariables& flux,
const Problem& problem,
const Element &element,
const FVElementGeometry& fvGeometry,
const ElementVolumeVariables& elemVolVars,
const ElementFaceVariables& elemFaceVars,
const SubControlVolumeFace &scvf,
const FluxVariablesCache& fluxVarsCache)
{ }
};
// specialization for non-isothermal flow
template<class TypeTag>
class FreeFlowEnergyFluxVariablesImplementation<TypeTag, true>
{
using GridView = typename GET_PROP_TYPE(TypeTag, GridView);
using Problem = typename GET_PROP_TYPE(TypeTag, Problem);
using Element = typename GridView::template Codim<0>::Entity;
using FVElementGeometry = typename GET_PROP_TYPE(TypeTag, FVElementGeometry);
using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar);
using Indices = typename GET_PROP_TYPE(TypeTag, Indices);
using ElementVolumeVariables = typename GET_PROP_TYPE(TypeTag, ElementVolumeVariables);
using ElementFaceVariables = typename GET_PROP_TYPE(TypeTag, ElementFaceVariables);
using SubControlVolumeFace = typename GET_PROP_TYPE(TypeTag, SubControlVolumeFace);
using FluxVariablesCache = typename GET_PROP_TYPE(TypeTag, FluxVariablesCache);
using FluxVariables = typename GET_PROP_TYPE(TypeTag, FluxVariables);
using CellCenterPrimaryVariables = typename GET_PROP_TYPE(TypeTag, CellCenterPrimaryVariables);
using HeatConductionType = typename GET_PROP_TYPE(TypeTag, HeatConductionType);
enum { energyBalanceIdx = Indices::energyBalanceIdx };
public:
static void energyFlux(CellCenterPrimaryVariables& flux,
const Problem& problem,
const Element &element,
const FVElementGeometry& fvGeometry,
const ElementVolumeVariables& elemVolVars,
const ElementFaceVariables& elemFaceVars,
const SubControlVolumeFace &scvf,
const FluxVariablesCache& fluxVarsCache)
{
// if we are on an inflow/outflow boundary, use the volVars of the element itself
// TODO: catch neumann and outflow in localResidual's evalBoundary_()
bool isOutflow = false;
if(scvf.boundary())
{
const auto bcTypes = problem.boundaryTypesAtPos(scvf.center());
if(bcTypes.isOutflow(energyBalanceIdx))
isOutflow = true;
}
auto upwindTerm = [](const auto& volVars) { return volVars.density() * volVars.enthalpy(); };
flux[energyBalanceIdx] = FluxVariables::advectiveFluxForCellCenter(elemVolVars, elemFaceVars, scvf, upwindTerm, isOutflow);
flux[energyBalanceIdx] += HeatConductionType::diffusiveFluxForCellCenter(problem, element, fvGeometry, elemVolVars, scvf);
}
};
} // end namespace
#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 2 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
*
* \brief Element-wise calculation of the local residual for non-isothermal
* fully implicit models.
*/
#ifndef DUMUX_FREE_FLOW_ENERGY_LOCAL_RESIDUAL_HH
#define DUMUX_FREE_FLOW_ENERGY_LOCAL_RESIDUAL_HH
#include <dumux/common/properties.hh>
namespace Dumux
{
// property forward declarations
namespace Properties
{
NEW_PROP_TAG(Indices);
}
// forward declaration
template<class TypeTag, bool enableEneryBalance>
class FreeFlowEnergyLocalResidualImplementation;
/*!
* \ingroup NIModel
* \ingroup ImplicitLocalResidual
* \brief Element-wise calculation of the energy residual for non-isothermal problems.
*/
template<class TypeTag>
using FreeFlowEnergyLocalResidual = FreeFlowEnergyLocalResidualImplementation<TypeTag, GET_PROP_VALUE(TypeTag, EnableEnergyBalance)>;
template<class TypeTag>
class FreeFlowEnergyLocalResidualImplementation<TypeTag, false>
{
using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar);
using CellCenterPrimaryVariables = typename GET_PROP_TYPE(TypeTag, CellCenterPrimaryVariables);
using VolumeVariables = typename GET_PROP_TYPE(TypeTag, VolumeVariables);
using SubControlVolume = typename GET_PROP_TYPE(TypeTag, SubControlVolume);
using FluxVariables = typename GET_PROP_TYPE(TypeTag, FluxVariables);
public:
//! The energy storage in the fluid phase with index phaseIdx
static void fluidPhaseStorage(CellCenterPrimaryVariables& storage,
const SubControlVolume& scv,
const VolumeVariables& volVars)
{}
};
template<class TypeTag>
class FreeFlowEnergyLocalResidualImplementation<TypeTag, true>
{
using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar);
using CellCenterPrimaryVariables = typename GET_PROP_TYPE(TypeTag, CellCenterPrimaryVariables);
using VolumeVariables = typename GET_PROP_TYPE(TypeTag, VolumeVariables);
using SubControlVolume = typename GET_PROP_TYPE(TypeTag, SubControlVolume);
using FluxVariables = typename GET_PROP_TYPE(TypeTag, FluxVariables);
using Indices = typename GET_PROP_TYPE(TypeTag, Indices);
enum { energyBalanceIdx = Indices::energyBalanceIdx };
public:
//! The energy storage in the fluid phase
static void fluidPhaseStorage(CellCenterPrimaryVariables& storage,
const SubControlVolume& scv,
const VolumeVariables& volVars)
{
storage[energyBalanceIdx] += volVars.density()
* volVars.internalEnergy();
}
};
} // 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 2 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
*
* \brief Base class for all models which use the one-phase,
* fully implicit model.
* Adaption of the fully implicit scheme to the one-phase flow model.
*/
#ifndef DUMUX_STAGGERED_NI_MODEL_HH
#define DUMUX_STAGGERED_NI_MODEL_HH
#include "properties.hh"
namespace Dumux
{
/*!
* \ingroup NavierStokesModel
* \brief A single-phase, non-isothermal flow model using the fully implicit scheme.
*
* All equations are discretized using a staggered grid as spatial
* and the implicit Euler method as time discretization.
* The model supports compressible as well as incompressible fluids.
*/
template<class TypeTag >
class NavierStokesNonIsothermalModel : public GET_PROP_TYPE(TypeTag, IsothermalModel)
{
using ParentType = typename GET_PROP_TYPE(TypeTag, IsothermalModel);
using Problem = typename GET_PROP_TYPE(TypeTag, Problem);
using Indices = typename GET_PROP_TYPE(TypeTag, Indices);
public:
void init(Problem& problem)
{
ParentType::init(problem);
// add temperature to output
auto& vtkOutputModule = problem.vtkOutputModule();
vtkOutputModule.addPrimaryVariable("temperature", Indices::temperatureIdx);
}
};
}
#include "propertydefaults.hh"
#endif