Skip to content
Snippets Groups Projects
Commit d834ddee authored by Thomas Fetzer's avatar Thomas Fetzer
Browse files

[rans][zeroeq] Implement a generic zeroeq model framework

parent de87b3d6
No related branches found
No related tags found
2 merge requests!856Feature/zeroeq,!851Feature/rans
...@@ -259,6 +259,9 @@ private: ...@@ -259,6 +259,9 @@ private:
// parameters in the mpfa group // parameters in the mpfa group
params["Mpfa.Q"] = "0.0"; params["Mpfa.Q"] = "0.0";
// parameters in the freeflow group
params["FreeFlow.EddyViscosityModel"] = "1";
} }
}; };
......
add_subdirectory("zeroeq")
#install headers #install headers
install(FILES install(FILES
model.hh model.hh
......
...@@ -83,9 +83,16 @@ public: ...@@ -83,9 +83,16 @@ public:
const SubControlVolume& scv) const SubControlVolume& scv)
{ {
ParentType::update(elemSol, problem, element, scv); ParentType::update(elemSol, problem, element, scv);
dynamicEddyViscosity_ = std::max(0.0, scv.dofPosition()[1] * (0.2469 - scv.dofPosition()[1])); // TODO preliminary setDynamicEddyViscosity(0.0);
}; };
/*!
* \brief Set the values of the dynamic eddy viscosity \f$\mathrm{[Pa s]}\f$ within the
* control volume.
*/
void setDynamicEddyViscosity(Scalar value)
{ dynamicEddyViscosity_ = value; }
/*! /*!
* \brief Return the dynamic eddy viscosity \f$\mathrm{[Pa s]}\f$ of the flow within the * \brief Return the dynamic eddy viscosity \f$\mathrm{[Pa s]}\f$ of the flow within the
* control volume. * control volume.
...@@ -110,7 +117,6 @@ private: ...@@ -110,7 +117,6 @@ private:
{ return *static_cast<const Implementation *>(this); } { return *static_cast<const Implementation *>(this); }
protected: protected:
FluidState fluidState_;
Scalar dynamicEddyViscosity_; Scalar dynamicEddyViscosity_;
}; };
...@@ -155,28 +161,42 @@ public: ...@@ -155,28 +161,42 @@ public:
const Element &element, const Element &element,
const SubControlVolume &scv) const SubControlVolume &scv)
{ {
update(elemSol, problem, element, scv); ParentTypeIsothermal::update(elemSol, problem, element, scv);
ParentTypeNonIsothermal::update(elemSol, problem, element, scv);
calculateEddyViscosity(elemSol, problem, element, scv);
} }
/*! /*!
* \brief Update the fluid state * \brief Calculate the eddy thermal conductivity
*
* \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
*/ */
static void completeFluidState(const ElementSolutionVector& elemSol, void calculateEddyViscosity(const ElementSolutionVector &elemSol,
const Problem& problem, const Problem &problem,
const Element& element, const Element &element,
const SubControlVolume& scv, const SubControlVolume &scv)
FluidState& fluidState)
{ {
ParentTypeIsothermal::completeFluidState(elemSol, problem, element, scv, fluidState); // TODO convert mit Prandtl number etc.
ParentTypeNonIsothermal::completeFluidState(elemSol, problem, element, scv, fluidState); eddyThermalConductivity_(ParentTypeIsothermal::dynamicEddyViscosity_());
} }
/*!
* \brief Sets the eddy thermal conductivity \f$\mathrm{[W/(m*K)]}\f$
* of the flow phase in the sub-control volume.
*/
void setEddyThermalConductivity(Scalar value)
{ eddyThermalConductivity_ = value; }
/*! /*!
* \brief Returns the eddy thermal conductivity \f$\mathrm{[W/(m*K)]}\f$ * \brief Returns the eddy thermal conductivity \f$\mathrm{[W/(m*K)]}\f$
* of the flow phase in the sub-control volume. * of the flow phase in the sub-control volume.
*/ */
Scalar eddyThermalConductivity() const Scalar eddyThermalConductivity() const
{ return ParentTypeIsothermal::dynamicEddyViscosity_(); } { return eddyThermalConductivity_; }
/*! /*!
* \brief Returns the effective thermal conductivity \f$\mathrm{[W/(m*K)]}\f$ * \brief Returns the effective thermal conductivity \f$\mathrm{[W/(m*K)]}\f$
...@@ -187,6 +207,9 @@ public: ...@@ -187,6 +207,9 @@ public:
return FluidSystem::thermalConductivity(this->fluidState_, defaultPhaseIdx) return FluidSystem::thermalConductivity(this->fluidState_, defaultPhaseIdx)
+ eddyThermalConductivity(); + eddyThermalConductivity();
} }
protected:
Scalar eddyThermalConductivity_;
}; };
} }
......
#install headers
install(FILES
indices.hh
model.hh
volumevariables.hh
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dumux/freeflow/rans/zeroeq)
// -*- 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
* \ingroup ZeroEqModel
* \copydoc Dumux::ZeroEqIndices
*/
#ifndef DUMUX_ZEROEQ_INDICES_HH
#define DUMUX_ZEROEQ_INDICES_HH
#include <dumux/freeflow/navierstokes/indices.hh>
namespace Dumux
{
// \{
/*!
* \ingroup ZeroEqModel
* \brief The common indices for the isothermal ZeroEq model.
*
* \tparam PVOffset The first index in a primary variable vector.
*/
template <class TypeTag, int PVOffset = 0>
struct ZeroEqIndices
: NavierStokesIndices<TypeTag, PVOffset>
{
static constexpr int noEddyViscosityModel = 0;
static constexpr int prandtl = 1;
};
// \}
} // 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
* \ingroup ZeroEqModel
*
* \brief A single-phase, isothermal Reynolds-Averaged Navier-Stokes 0-Eq. model
*
* These models calculate the eddy viscosity without solving additional PDEs,
* only based on the wall distance and the velocity gradient.
* The following models are available:
* \todo list implemented 0-Eq. models
*/
#ifndef DUMUX_ZEROEQ_MODEL_HH
#define DUMUX_ZEROEQ_MODEL_HH
#include <dumux/common/properties.hh>
#include <dumux/freeflow/properties.hh>
#include <dumux/freeflow/rans/model.hh>
#include "indices.hh"
#include "volumevariables.hh"
// #include "vtkoutputfields.hh"
namespace Dumux
{
// \{
///////////////////////////////////////////////////////////////////////////
// properties for the single-phase Reynolds-Averaged Navier-Stokes 0-Eq. model
///////////////////////////////////////////////////////////////////////////
namespace Properties {
//////////////////////////////////////////////////////////////////
// Type tags
//////////////////////////////////////////////////////////////////
//! The type tag for the single-phase, isothermal Reynolds-Averaged Navier-Stokes 0-Eq. model
NEW_TYPE_TAG(ZeroEq, INHERITS_FROM(RANS));
//! The type tag for the corresponding non-isothermal model
NEW_TYPE_TAG(ZeroEqNI, INHERITS_FROM(ZeroEq, RANSNI));
///////////////////////////////////////////////////////////////////////////
// default property values for the isothermal single phase model
///////////////////////////////////////////////////////////////////////////
//! use the global group as default for the model's parameter group
// SET_STRING_PROP(ModelProperties, ModelParameterGroup, "ZeroEq");
//! The indices
SET_TYPE_PROP(ZeroEq, Indices, ZeroEqIndices<TypeTag>);
//! The volume variables
SET_TYPE_PROP(ZeroEq, VolumeVariables, ZeroEqVolumeVariables<TypeTag>);
// \}
}
} // end namespace
#endif // DUMUX_ZEROEQ_MODEL_HH
// -*- 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
* \ingroup ZeroEqModel
*
* \copydoc Dumux::ZEROEQVolumeVariables
*/
#ifndef DUMUX_ZEROEQ_VOLUME_VARIABLES_HH
#define DUMUX_ZEROEQ_VOLUME_VARIABLES_HH
#include <dumux/common/properties.hh>
#include <dumux/material/fluidstates/immiscible.hh>
namespace Dumux
{
// forward declaration
template <class TypeTag, bool enableEnergyBalance>
class ZeroEqVolumeVariablesImplementation;
/*!
* \ingroup Reynolds-Averaged NavierStokesModel
* \brief Volume variables for the single-phase Reynolds-Averaged Navier-Stokes model.
* The class is specialized for isothermal and non-isothermal models.
*/
template <class TypeTag>
using ZeroEqVolumeVariables = ZeroEqVolumeVariablesImplementation<TypeTag, GET_PROP_VALUE(TypeTag, EnableEnergyBalance)>;
/*!
* \ingroup Reynolds-Averaged NavierStokesModel
* \brief Volume variables for the isothermal single-phase Reynolds-Averaged Navier-Stokes model.
*/
template <class TypeTag>
class ZeroEqVolumeVariablesImplementation<TypeTag, false>
: public RANSVolumeVariablesImplementation<TypeTag, false>
{
using ParentType = NavierStokesVolumeVariablesImplementation<TypeTag, false>;
using Implementation = typename GET_PROP_TYPE(TypeTag, VolumeVariables);
using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar);
using Problem = typename GET_PROP_TYPE(TypeTag, Problem);
using SubControlVolume = typename GET_PROP_TYPE(TypeTag, SubControlVolume);
using ElementSolutionVector = typename GET_PROP_TYPE(TypeTag, ElementSolutionVector);
using Indices = typename GET_PROP_TYPE(TypeTag, Indices);
using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem);
using GridView = typename GET_PROP_TYPE(TypeTag, GridView);
using Element = typename GridView::template Codim<0>::Entity;
static const int defaultPhaseIdx = GET_PROP_VALUE(TypeTag, PhaseIdx);
public:
ZeroEqVolumeVariablesImplementation()
{
eddyViscosityModel_ = getParamFromGroup<int>(GET_PROP_VALUE(TypeTag, ModelParameterGroup),
"FreeFlow.EddyViscosityModel");
}
/*!
* \brief Update all quantities for a given 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
*/
void update(const ElementSolutionVector &elemSol,
const Problem &problem,
const Element &element,
const SubControlVolume& scv)
{
ParentType::update(elemSol, problem, element, scv);
calculateEddyViscosity(elemSol, problem, element, scv);
};
/*!
* \brief Calculate the eddy viscosity
*
* \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
*/
void calculateEddyViscosity(const ElementSolutionVector &elemSol,
const Problem &problem,
const Element &element,
const SubControlVolume& scv)
{
Scalar kinematicEddyViscosity = 0.0;
if (eddyViscosityModel_ == Indices::prandtl)
{
kinematicEddyViscosity = std::max(0.0, scv.dofPosition()[1] * (0.2469 - scv.dofPosition()[1])); // TODO preliminary
}
asImp_().setDynamicEddyViscosity(kinematicEddyViscosity * asImp_().density(defaultPhaseIdx));
}
private:
//! Returns the implementation of the problem (i.e. static polymorphism)
Implementation &asImp_()
{ return *static_cast<Implementation *>(this); }
//! \copydoc asImp_()
const Implementation &asImp_() const
{ return *static_cast<const Implementation *>(this); }
protected:
int eddyViscosityModel_;
};
/*!
* \ingroup ZeroEqModel
* \brief Volume variables for the non-isothermal single-phase Reynolds-Averaged Navier-Stokes model.
*/
template <class TypeTag>
class ZeroEqVolumeVariablesImplementation<TypeTag, true>
: public RANSVolumeVariablesImplementation<TypeTag, true>
{ };
}
#endif
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#include <dumux/material/fluidsystems/gasphase.hh> #include <dumux/material/fluidsystems/gasphase.hh>
#include <dumux/material/components/air.hh> #include <dumux/material/components/air.hh>
#include <dumux/freeflow/rans/model.hh> #include <dumux/freeflow/rans/zeroeq/model.hh>
#include <dumux/freeflow/rans/problem.hh> #include <dumux/freeflow/rans/problem.hh>
#include <dumux/discretization/staggered/freeflow/properties.hh> #include <dumux/discretization/staggered/freeflow/properties.hh>
...@@ -41,7 +41,7 @@ class PipeLauferProblem; ...@@ -41,7 +41,7 @@ class PipeLauferProblem;
namespace Properties namespace Properties
{ {
NEW_TYPE_TAG(PipeLauferProblem, INHERITS_FROM(StaggeredFreeFlowModel, RANS)); NEW_TYPE_TAG(PipeLauferProblem, INHERITS_FROM(StaggeredFreeFlowModel, ZeroEq));
// the fluid system // the fluid system
SET_PROP(PipeLauferProblem, FluidSystem) SET_PROP(PipeLauferProblem, FluidSystem)
......
...@@ -17,6 +17,9 @@ Name = test_pipe_laufer # name passed to the output routines ...@@ -17,6 +17,9 @@ Name = test_pipe_laufer # name passed to the output routines
InletVelocity = 2.5 # [m/s] InletVelocity = 2.5 # [m/s]
EnableGravity = false EnableGravity = false
[FreeFlow]
EddyViscosityModel = 1
[Newton] [Newton]
MaxSteps = 10 MaxSteps = 10
MaxRelativeShift = 1e-5 MaxRelativeShift = 1e-5
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment