Commit 985dae8c authored by Martin Utz's avatar Martin Utz
Browse files

[swe][frictionlaws] Use unique pointer without vector

parent 1959a01e
......@@ -42,6 +42,8 @@ public:
/*!
* \brief Compute the shear stress.
*
* \param volVar Volume Variables.
*
* Compute the shear stress due to friction. The shear stress is not a tensor as know
* from contiuums mechanics, but a force projected on an area. Therefore it is a
* vector with two entries.
......@@ -49,7 +51,7 @@ public:
* \return shear stress [N/m^2]. First entry is the x-component, the second the y-component.
*/
virtual Dune::FieldVector<Scalar, 2> shearStress(const VolumeVariables& VolVar) const = 0;
virtual Dune::FieldVector<Scalar, 2> shearStress(const VolumeVariables& volVar) const = 0;
/*!
* \brief Limit the friction for small water depth.
......
......@@ -65,8 +65,10 @@ struct SpatialParams<TypeTag, TTag::RoughChannel>
private:
using FVGridGeometry = GetPropType<TypeTag, Properties::FVGridGeometry>;
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView;
using VolumeVariables = typename ElementVolumeVariables::VolumeVariables;
public:
using type = RoughChannelSpatialParams<FVGridGeometry, Scalar, TypeTag>;
using type = RoughChannelSpatialParams<FVGridGeometry, Scalar, VolumeVariables>;
};
template<class TypeTag>
......@@ -219,11 +221,9 @@ public:
const SubControlVolume &scv) const
{
const auto& volVars = elemVolVars[scv];
NumEqVector source (0.0);
Dune::FieldVector<Scalar, 2> bottomShearStress = this->spatialParams().frictionLaw(element)->shearStress(volVars);
source += bottomFrictionSource(bottomShearStress);
source += bottomFrictionSource(element, fvGeometry, elemVolVars, scv);
return source;
}
......@@ -231,19 +231,28 @@ public:
/*!
* \brief Compute the source term due to bottom friction
*
* \param bottomShearStress Shear stress due to bottom friction.
* \param element The finite element
* \param fvGeometry The finite-volume geometry
* \param elemVolVars All volume variables for the element
* \param scv The sub control volume
*
* \return source
*/
NumEqVector bottomFrictionSource(const Dune::FieldVector<Scalar, 2> bottomShearStress) const
NumEqVector bottomFrictionSource(const Element& element,
const FVElementGeometry& fvGeometry,
const ElementVolumeVariables& elemVolVars,
const SubControlVolume &scv) const
{
NumEqVector bottomFrictionSource(0.0);
NumEqVector bottomFrictionSource(0.0);
const auto& volVars = elemVolVars[scv];
Dune::FieldVector<Scalar, 2> bottomShearStress = this->spatialParams().frictionLaw(element).shearStress(volVars);
bottomFrictionSource[0] = 0.0;
bottomFrictionSource[1] =bottomShearStress[0];
bottomFrictionSource[2] =bottomShearStress[1];
bottomFrictionSource[0] = 0.0;
bottomFrictionSource[1] =bottomShearStress[0];
bottomFrictionSource[2] =bottomShearStress[1];
return bottomFrictionSource;
return bottomFrictionSource;
}
// \}
......
......@@ -37,20 +37,18 @@ namespace Dumux {
* \brief The spatial parameters class for the rough channel test.
*
*/
template<class FVGridGeometry, class Scalar, class TypeTag>
template<class FVGridGeometry, class Scalar, class VolumeVariables>
class RoughChannelSpatialParams
: public FVSpatialParams<FVGridGeometry, Scalar,
RoughChannelSpatialParams<FVGridGeometry, Scalar, TypeTag>>
RoughChannelSpatialParams<FVGridGeometry, Scalar, VolumeVariables>>
{
using ThisType = RoughChannelSpatialParams<FVGridGeometry, Scalar, TypeTag>;
using ThisType = RoughChannelSpatialParams<FVGridGeometry, Scalar, VolumeVariables>;
using ParentType = FVSpatialParams<FVGridGeometry, Scalar, ThisType>;
using GridView = typename FVGridGeometry::GridView;
using FVElementGeometry = typename FVGridGeometry::LocalView;
using SubControlVolume = typename FVElementGeometry::SubControlVolume;
using Element = typename GridView::template Codim<0>::Entity;
using GlobalPosition = typename Element::Geometry::GlobalCoordinate;
using ElementVolumeVariables = typename GetPropType<TypeTag, Properties::GridVolumeVariables>::LocalView;
using VolumeVariables = typename ElementVolumeVariables::VolumeVariables;
public:
RoughChannelSpatialParams(std::shared_ptr<const FVGridGeometry> fvGridGeometry)
......@@ -60,27 +58,21 @@ public:
bedSlope_ = getParam<Scalar>("Problem.BedSlope");
frictionValue_ = getParam<Scalar>("Problem.FrictionValue");
frictionLawType_ = getParam<std::string>("Problem.FrictionLaw");
initFrictionLaw(fvGridGeometry);
initFrictionLaw();
}
/*!
* \brief Initialize FrictionLaws
*/
void initFrictionLaw(std::shared_ptr<const FVGridGeometry> fvGridGeometry)
void initFrictionLaw()
{
if (frictionLawType_ == "Manning")
{
for (const auto& element : elements(fvGridGeometry->gridView()))
{
frictionLaw_.push_back(std::make_shared<FrictionLawManning<Scalar, VolumeVariables>>(gravity_, frictionValue_));
}
frictionLaw_ = std::make_unique<FrictionLawManning<Scalar, VolumeVariables>>(gravity_, frictionValue_);
}
if (frictionLawType_ == "Nikuradse")
{
for (const auto& element : elements(fvGridGeometry->gridView()))
{
frictionLaw_.push_back(std::make_shared<FrictionLawNikuradse<Scalar, VolumeVariables>>(frictionValue_));
}
frictionLaw_ = std::make_unique<FrictionLawNikuradse<Scalar, VolumeVariables>>(frictionValue_);
}
else
{
......@@ -141,10 +133,10 @@ public:
*
* \return frictionLaw
*/
std::shared_ptr<FrictionLaw<Scalar, VolumeVariables>> frictionLaw(const Element element) const
const FrictionLaw<Scalar, VolumeVariables>& frictionLaw(const Element element) const
{
const auto eIdx = this->fvGridGeometry().elementMapper().index(element);
return frictionLaw_[eIdx];
return *frictionLaw_;
}
/*! \brief Define the bed surface
......@@ -166,7 +158,7 @@ private:
Scalar bedSlope_;
Scalar frictionValue_;
std::string frictionLawType_;
std::vector<std::shared_ptr<FrictionLaw<Scalar, VolumeVariables>>> frictionLaw_;
std::unique_ptr<FrictionLaw<Scalar, VolumeVariables>> frictionLaw_;
};
} // end namespace Dumux
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment