Commit a7b3c125 authored by Timo Koch's avatar Timo Koch

Merge branch 'fix/wallDistance_check' into 'master'

Fix/wall distance check

Closes #941

See merge request !2289
parents 333e3714 3c3d56fd
......@@ -16,6 +16,11 @@ Differences Between DuMu<sup>x</sup> 3.3 and DuMu<sup>x</sup> 3.2
- For the "sequential" models, the property `BoundaryTypes` has been simply renamed to `SequentialBoundaryTypes`
- __Quadmath__: Dumux::Quad has been removed without deprecation. Use Dune::Float128 instead.
- Within the RANS group, two additional runtime parameters have been included 'IsFlatWallBounded' and 'WriteFlatWallBoundedFields'.
For both the K-Epsilon and Zero-eq RANS models the 'IsFlatWallBounded' runtime parameter should be set as True,
as wall topology is not supported for these models with our geometric contraints. If not set as true, the geometry
will be checked before the model is run. If either the runtime parameter or the geometry check indicate non-flat walls,
the model will terminate. To add FlatWallBounded specific output to the vtk output, WriteFlatWallBoundedFields can be set as True.
### Deprecated properties/classes/functions/files, to be removed after 3.3:
......
......@@ -333,9 +333,6 @@ private:
// parameters in the mpfa group
defaultParams["MPFA.Q"] = "0.0";
// parameters in the RANS group
defaultParams["RANS.IsFlatWallBounded"] = "false";
// merge the global default tree but do not overwrite if the parameter already exists
mergeTree_(params, defaultParams, false);
}
......
......@@ -40,7 +40,8 @@ struct RANSIOFields
{
NavierStokesIOFields::initOutputModule(out);
static const bool isFlatWallBounded = getParamFromGroup<bool>(out.paramGroup(), "RANS.IsFlatWallBounded");
static const bool isFlatWallBounded = getParamFromGroup<bool>(out.paramGroup(), "RANS.IsFlatWallBounded", false);
static const bool writeFlatWallBoundedFields = getParamFromGroup<bool>(out.paramGroup(), "RANS.WriteFlatWallBoundedFields", isFlatWallBounded);
static constexpr auto dim = decltype(std::declval<typename OutputModule::VolumeVariables>().ccVelocityVector())::dimension;
......@@ -54,7 +55,7 @@ struct RANSIOFields
out.addVolumeVariable([](const auto& v){ return v.viscosity() / v.density(); }, "nu");
out.addVolumeVariable([](const auto& v){ return v.kinematicEddyViscosity(); }, "nu_t");
out.addVolumeVariable([](const auto& v){ return v.wallDistance(); }, "l_w");
if (isFlatWallBounded)
if (writeFlatWallBoundedFields)
{
out.addVolumeVariable([](const auto& v){ return v.yPlus(); }, "y^+");
out.addVolumeVariable([](const auto& v){ return v.uPlus(); }, "u^+");
......
......@@ -24,6 +24,8 @@
#ifndef DUMUX_RANS_PROBLEM_HH
#define DUMUX_RANS_PROBLEM_HH
#include <algorithm>
#include <dune/common/fmatrix.hh>
#include <dumux/common/properties.hh>
#include <dumux/common/staggeredfvproblem.hh>
......@@ -126,6 +128,13 @@ public:
wallNormalAxis_.resize(this->gridGeometry().elementMapper().size(), fixedWallNormalAxis_);
kinematicViscosity_.resize(this->gridGeometry().elementMapper().size(), 0.0);
if ( !(hasParamInGroup(this->paramGroup(), "RANS.IsFlatWallBounded")))
{
std::cout << "The parameter \"Rans.IsFlatWallBounded\" is not specified. \n"
<< " -- Based on the grid and the isOnWallAtPos function specified by the user,"
<< " this parameter is set to be "<< std::boolalpha << isFlatWallBounded() << "\n";
}
std::vector<WallElementInformation> wallElements;
const auto gridView = this->gridGeometry().gridView();
......@@ -307,8 +316,8 @@ public:
bool isFlatWallBounded() const
{
static const bool isFlatWallBounded = getParamFromGroup<bool>(this->paramGroup(), "RANS.IsFlatWallBounded");
return isFlatWallBounded;
static const bool hasAlignedWalls = hasAlignedWalls_();
return hasAlignedWalls;
}
/*!
......@@ -409,6 +418,35 @@ public:
bool calledUpdateStaticWallProperties = false;
private:
bool hasAlignedWalls_() const
{
if ( hasParamInGroup(this->paramGroup(), "RANS.IsFlatWallBounded"))
{
static const bool isFlatWallBounded = getParamFromGroup<bool>(this->paramGroup(), "RANS.IsFlatWallBounded");
return isFlatWallBounded;
}
std::vector<int> wallFaceAxis;
wallFaceAxis.reserve(this->gridGeometry().numBoundaryScvf());
const auto gridView = this->gridGeometry().gridView();
auto fvGeometry = localView(this->gridGeometry());
for (const auto& element : elements(gridView))
{
fvGeometry.bindElement(element);
for (const auto& scvf : scvfs(fvGeometry))
{
// only search for walls at a global boundary
if (!scvf.boundary() && asImp_().isOnWall(scvf))
wallFaceAxis.push_back(scvf.directionIndex());
}
}
// Returns if all wall directions are the same
return std::all_of(wallFaceAxis.begin(), wallFaceAxis.end(), [firstDir=wallFaceAxis[0]](auto dir){ return (dir == firstDir);} ) ;
}
void calculateCCVelocities_(const SolutionVector& curSol)
{
// calculate cell-center-averaged velocities
......
......@@ -68,7 +68,9 @@ dumux_add_test(NAME test_ff_rans_lauferpipe_komega_nochannel
--files ${CMAKE_SOURCE_DIR}/test/references/test_ff_rans_lauferpipe_komega_nochannel-reference.vtu
${CMAKE_CURRENT_BINARY_DIR}/test_ff_rans_lauferpipe_komega_nochannel-00047.vtu
--command "${CMAKE_CURRENT_BINARY_DIR}/test_ff_rans_lauferpipe_komega params.input
-Problem.Name test_ff_rans_lauferpipe_komega_nochannel")
-Problem.Name test_ff_rans_lauferpipe_komega_nochannel
-RANS.IsFlatWallBounded False
-RANS.WriteFlatWallBoundedFields False")
dumux_add_test(NAME test_ff_rans_lauferpipe_oneeq
SOURCES main.cc
......
......@@ -23,6 +23,7 @@ EddyViscosityModel = "baldwinLomax"
TurbulentPrandtlNumber = 0.85
WallNormalAxis = 1
IsFlatWallBounded = True
WriteFlatWallBoundedFields = True
[Assembly]
NumericDifferenceMethod = 0
......
......@@ -23,6 +23,7 @@ YPlusThreshold = 10. # should be small (10-30) for coarse grids
TurbulentPrandtlNumber = 0.85
WallNormalAxis = 1
IsFlatWallBounded = True
WriteFlatWallBoundedFields = True
[Assembly]
NumericDifferenceMethod = 0
......
......@@ -23,6 +23,7 @@ YPlusThreshold = 10. # should be small (10-30) for coarse grids
[RANS]
WallNormalAxis = 1
WriteFlatWallBoundedFields = True
[Assembly]
NumericDifferenceMethod = 0
......
......@@ -21,6 +21,7 @@ SandGrainRoughness = 0.0 # [m] # not implemented for EddyViscosityModel = 3
EddyViscosityModel = "baldwinLomax"
UseStoredEddyViscosity = false
IsFlatWallBounded = True
WriteFlatWallBoundedFields = True
[KEpsilon]
YPlusThreshold = 60. # should be large (30-60) for fine grids
......
......@@ -23,6 +23,7 @@ EddyViscosityModel = "prandtl"
TurbulentSchmidtNumber = 0.7
WallNormalAxis = 1
IsFlatWallBounded = True
WriteFlatWallBoundedFields = True
[Assembly]
NumericDifferenceMethod = 0
......
......@@ -21,6 +21,7 @@ TurbulentSchmidtNumber = 0.7
TurbulentPrandtlNumber = 0.85
WallNormalAxis = 1
IsFlatWallBounded = True
WriteFlatWallBoundedFields = True
[Assembly]
NumericDifferenceMethod = 0
......
......@@ -19,6 +19,7 @@ TurbulentSchmidtNumber = 0.7
TurbulentPrandtlNumber = 0.85
WallNormalAxis = 1
IsFlatWallBounded = True
WriteFlatWallBoundedFields = True
[KEpsilon]
YPlusThreshold = 10. # should be small (10-30) for coarse grids
......
......@@ -22,6 +22,7 @@ TurbulentSchmidtNumber = 0.7
TurbulentPrandtlNumber = 0.85
WallNormalAxis = 1
IsFlatWallBounded = True
WriteFlatWallBoundedFields = True
[KEpsilon]
YPlusThreshold = 10. # should be small (10-30) for coarse grids
......
......@@ -129,6 +129,8 @@ private:
using BoundaryTypes = Dumux::NavierStokesBoundaryTypes<GetPropType<TypeTag, Properties::ModelTraits>::numEq()>;
using Scalar = GetPropType<TTag, Properties::Scalar>;
using Traits = GetPropType<TTag, Properties::ModelTraits>;
Scalar eps_ = 1e-6;
public:
using ParentType::ParentType;
......@@ -159,8 +161,8 @@ private:
{ return ParentType::updateDynamicWallProperties(u); }
template<class Scvf>
bool isOnWall(const Scvf&) const
{ return true; }
bool isOnWall(const Scvf& scvf) const
{ return (scvf.center()[0] < eps_); }
};
public:
......
Markdown is supported
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