Skip to content
Snippets Groups Projects
Commit a5f86adb authored by Martin Utz's avatar Martin Utz
Browse files

[swe][frictionlaws] Add an abstract base class

To improve the weird inheritance from Nikuradse to Manning a abstract
base class FrictionLaw as base for all friction laws is introduced, by
making computeUstarH virtual.
parent 33f0c477
No related branches found
No related tags found
1 merge request!1596[shallow water] Add friction laws (Manning and Nikuradse)
install(FILES install(FILES
manning.hh manning.hh
nikuradse.hh nikuradse.hh
frictionlaw.hh
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dumux/material/fluidmatrixinteractions/frictionslaws) DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dumux/material/fluidmatrixinteractions/frictionslaws)
// -*- 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 Fluidmatrixinteractions
* \copydoc Dumux::FrictionLaw
*/
#ifndef DUMUX_FRICTIONLAW_HH
#define DUMUX_FRICTIONLAW_HH
#include <algorithm>
#include <cmath>
namespace Dumux {
/*!
* \ingroup Fluidmatrixinteractions
* \brief Implementation of the abstract base class for friction laws.
*
* The LET mobility model is used to limit the friction for small water depths.
*/
template <typename Scalar>
class FrictionLaw
{
public:
/*!
* \brief Compute the friction ustar_h.
*
* \return ustar_h friction used for the source term in shallow water models.
*/
virtual Scalar computeUstarH(const Scalar waterDepth) =0;
/*!
* \brief Limit the friction for small water depth.
*
* We define a water depth minUpperH. If the water depth is
* smaller, we start to limit the friciton.
* So the friciton term get's not extreme large for small water
* depths.
*
* ------------------------- minUpperh -----------
*
*
*
* ------------------------rough_h ---------------
* /\ /\ roughness /grain\
* -------------------------------bottom ------------------
* /////////////////////////////////////////////////
*
* For the limiting the LET model is used, which is usually applied in the
* porous media flow to limit the permeability due to the saturation. It employs
* the three empirical paramaters L, E and T, which describe the limiting curve.
*
* \param rough_h roughness height of the representive structure (e.g. largest grain size).
* \param waterDepth water depth.
*/
Scalar limitRoughH(Scalar rough_h, const Scalar waterDepth)
{
using std::pow;
using std::min;
using std::max;
const Scalar letL = 0.0; //!< empirical parameter of the LET model
const Scalar letT = 2.0; //!< empirical parameter of the LET model
const Scalar letE = 1.0; //!< empirical parameter of the LET model
Scalar mobility_max = 1.0; //!< maximal mobility
auto minUpperH = rough_h * 2.0;
auto sw = min(waterDepth * (1.0/minUpperH),1.0);
sw = max(0.0,sw);
auto mobility = (mobility_max * pow(sw,letL))/(pow(sw,letL) + letE * pow(1.0-sw,letT));
return rough_h * (1.0 - mobility);
}
};
} // end namespace Dumux
#endif // DUMUX_FRICTIONLAW_HH
...@@ -19,16 +19,14 @@ ...@@ -19,16 +19,14 @@
/*! /*!
* \file * \file
* \ingroup Fluidmatrixinteractions * \ingroup Fluidmatrixinteractions
* \brief Implementation of the friction law after Manning. * \copydoc Dumux::FrictionLawManning
*
* The LET mobility model is used to limit the friction for small water depths.
*/ */
#ifndef DUMUX_FRICTIONLAW_MANNING_HH #ifndef DUMUX_FRICTIONLAW_MANNING_HH
#define DUMUX_FRICTIONLAW_MANNING_HH #define DUMUX_FRICTIONLAW_MANNING_HH
#include <algorithm> #include <algorithm>
#include <cmath> #include <cmath>
#include "nikuradse.hh" #include "frictionlaw.hh"
namespace Dumux { namespace Dumux {
/*! /*!
...@@ -39,29 +37,34 @@ namespace Dumux { ...@@ -39,29 +37,34 @@ namespace Dumux {
*/ */
template <typename Scalar> template <typename Scalar>
class FrictionLawManning : FrictionLawNikuradse<Scalar> class FrictionLawManning : FrictionLaw<Scalar>
{ {
public: public:
FrictionLawManning(const Scalar manningN, const Scalar gravity)
: manningN_(manningN), gravity_(gravity) {}
/*! /*!
* \brief Compute the friction ustar_h. * \brief Compute the friction ustar_h.
* *
* \param waterDepth water depth. * \param waterDepth water depth.
* \param manningN Mannings friction value. *
* \return ustar_h friction used for the source term in shallow water models. * \return ustar_h friction used for the source term in shallow water models.
*/ */
Scalar computeUstarH(const Scalar waterDepth, const Scalar manningN, const Scalar gravity) Scalar computeUstarH(const Scalar waterDepth)
{ {
using std::pow; using std::pow;
Scalar ustar_h = 0.0; Scalar ustar_h = 0.0;
Scalar rough_h = pow(25.68/(1.0/manningN),6.0); Scalar rough_h = pow(25.68/(1.0/manningN_),6.0);
rough_h = this->limitRoughH(rough_h, waterDepth); rough_h = this->limitRoughH(rough_h, waterDepth);
auto cfric = pow((waterDepth + rough_h),1.0/6.0) * 1.0/(manningN); auto cfric = pow((waterDepth + rough_h),1.0/6.0) * 1.0/(manningN_);
ustar_h = gravity / pow(cfric,2.0); ustar_h = gravity_ / pow(cfric,2.0);
return ustar_h; return ustar_h;
} }
private:
Scalar manningN_;
Scalar gravity_;
}; };
} // end namespace Dumux } // end namespace Dumux
......
...@@ -19,15 +19,14 @@ ...@@ -19,15 +19,14 @@
/*! /*!
* \file * \file
* \ingroup Fluidmatrixinteractions * \ingroup Fluidmatrixinteractions
* \brief Implementation of the friction law after Nikuradse. * \copydoc Dumux::FrictionLawNikuradse
*
* The LET mobility model is used to limit the friction for small water depths.
*/ */
#ifndef DUMUX_FRICTIONLAW_NIKURADSE_HH #ifndef DUMUX_FRICTIONLAW_NIKURADSE_HH
#define DUMUX_FRICTIONLAW_NIKURADSE_HH #define DUMUX_FRICTIONLAW_NIKURADSE_HH
#include <algorithm> #include <algorithm>
#include <cmath> #include <cmath>
#include "frictionlaw.hh"
namespace Dumux { namespace Dumux {
/*! /*!
...@@ -38,71 +37,33 @@ namespace Dumux { ...@@ -38,71 +37,33 @@ namespace Dumux {
*/ */
template <typename Scalar> template <typename Scalar>
class FrictionLawNikuradse class FrictionLawNikuradse : FrictionLaw<Scalar>
{ {
public: public:
FrictionLawNikuradse(const Scalar ks)
: ks_(ks) {}
/*! /*!
* \brief Compute the friction ustar_h. * \brief Compute the friction ustar_h.
* *
* \param waterDepth water depth. * \param waterDepth water depth.
* \param ks the Strickler friction value. *
* \return ustar_h friction used for the source term in shallow water models. * \return ustar_h friction used for the source term in shallow water models.
*/ */
Scalar computeUstarH(const Scalar waterDepth,const Scalar ks) Scalar computeUstarH(const Scalar waterDepth)
{ {
using std::pow; using std::pow;
using std::log; using std::log;
Scalar ustar_h = 0.0; Scalar ustar_h = 0.0;
Scalar rough_h = ks; Scalar rough_h = ks_;
rough_h = limitRoughH(rough_h, waterDepth); rough_h = this->limitRoughH(rough_h, waterDepth);
ustar_h = pow(0.41,2.0)/pow(log((12*(waterDepth + rough_h))/ks),2.0); ustar_h = pow(0.41,2.0)/pow(log((12*(waterDepth + rough_h))/ks_),2.0);
return ustar_h; return ustar_h;
} }
private:
/*! Scalar ks_;
* \brief Limit the friction for small water depth.
*
* We define a water depth minUpperH. If the water depth is
* smaller, we start to limit the friciton.
* So the friciton term get's not extreme large for small water
* depths.
*
* ------------------------- minUpperh -----------
*
*
*
* ------------------------rough_h ---------------
* /\ /\ roughness /grain\
* -------------------------------bottom ------------------
* /////////////////////////////////////////////////
*
* For the limiting the LET model is used, which is usually applied in the
* porous media flow to limit the permeability due to the saturation. It employs
* the three empirical paramaters L, E and T, which describe the limiting curve.
*
* \param rough_h roughness height of the representive structure (e.g. largest grain size).
* \param waterDepth water depth.
*/
Scalar limitRoughH(Scalar rough_h, const Scalar waterDepth)
{
using std::pow;
using std::min;
using std::max;
const Scalar letL = 0.0; //!< empirical parameter of the LET model
const Scalar letT = 2.0; //!< empirical parameter of the LET model
const Scalar letE = 1.0; //!< empirical parameter of the LET model
Scalar mobility_max = 1.0; //!< maximal mobility
auto minUpperH = rough_h * 2.0;
auto sw = min(waterDepth * (1.0/minUpperH),1.0);
sw = max(0.0,sw);
auto mobility = (mobility_max * pow(sw,letL))/(pow(sw,letL) + letE * pow(1.0-sw,letT));
return rough_h * (1.0 - mobility);
}
}; };
} // end namespace Dumux } // end namespace Dumux
......
...@@ -33,7 +33,6 @@ ...@@ -33,7 +33,6 @@
#include <dumux/freeflow/shallowwater/boundaryfluxes.hh> #include <dumux/freeflow/shallowwater/boundaryfluxes.hh>
#include <dumux/material/fluidmatrixinteractions/frictionlaws/manning.hh> #include <dumux/material/fluidmatrixinteractions/frictionlaws/manning.hh>
namespace Dumux { namespace Dumux {
template <class TypeTag> template <class TypeTag>
...@@ -228,14 +227,13 @@ public: ...@@ -228,14 +227,13 @@ public:
const auto& globalPos = scv.center(); const auto& globalPos = scv.center();
const auto& volVars = elemVolVars[scv]; const auto& volVars = elemVolVars[scv];
const auto& elementIndex = scv.elementIndex();
const auto gravity = this->spatialParams().gravity(globalPos); const auto gravity = this->spatialParams().gravity(globalPos);
const auto manningN = this->spatialParams().frictionValue(globalPos); const auto manningN = this->spatialParams().frictionValue(globalPos);
auto h = volVars.waterDepth(); auto h = volVars.waterDepth();
auto u = volVars.velocity(0); auto u = volVars.velocity(0);
auto v = volVars.velocity(1); auto v = volVars.velocity(1);
auto ustarH = FrictionLawManning<Scalar>().computeUstarH(h,manningN,gravity); auto ustarH = FrictionLawManning<Scalar>(manningN,gravity).computeUstarH(h);
auto uv = sqrt(pow(u,2.0) + pow(v,2.0)); auto uv = sqrt(pow(u,2.0) + pow(v,2.0));
source[0] = 0.0; source[0] = 0.0;
......
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