From 9e7afdf0be9997487d61a19d1a57dc60b7e70f91 Mon Sep 17 00:00:00 2001 From: Thomas Fetzer <thomas.fetzer@iws.uni-stuttgart.de> Date: Tue, 22 May 2018 10:50:01 +0200 Subject: [PATCH] [zeroeq] Implement model names instead of model numbers --- dumux/freeflow/rans/zeroeq/CMakeLists.txt | 1 - dumux/freeflow/rans/zeroeq/model.hh | 5 +- dumux/freeflow/rans/zeroeq/models.hh | 49 ------------------- dumux/freeflow/rans/zeroeq/problem.hh | 11 +++-- dumux/freeflow/rans/zeroeq/volumevariables.hh | 19 ++++--- test/freeflow/rans/test_pipe_laufer.input | 2 +- .../rans/test_pipe_laufer_reference.input | 2 +- test/freeflow/rans/test_pipe_zeroeqni.input | 2 +- test/freeflow/ransnc/test_flatplate2c.input | 2 +- test/freeflow/ransnc/test_flatplate2cni.input | 1 + 10 files changed, 26 insertions(+), 68 deletions(-) delete mode 100644 dumux/freeflow/rans/zeroeq/models.hh diff --git a/dumux/freeflow/rans/zeroeq/CMakeLists.txt b/dumux/freeflow/rans/zeroeq/CMakeLists.txt index 379e2f5d0a..24c5d3e332 100644 --- a/dumux/freeflow/rans/zeroeq/CMakeLists.txt +++ b/dumux/freeflow/rans/zeroeq/CMakeLists.txt @@ -1,7 +1,6 @@ #install headers install(FILES model.hh -models.hh problem.hh volumevariables.hh DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dumux/freeflow/rans/zeroeq) diff --git a/dumux/freeflow/rans/zeroeq/model.hh b/dumux/freeflow/rans/zeroeq/model.hh index 07b55e954a..b0d647ba4d 100644 --- a/dumux/freeflow/rans/zeroeq/model.hh +++ b/dumux/freeflow/rans/zeroeq/model.hh @@ -27,7 +27,10 @@ * These models calculate the eddy viscosity without solving additional PDEs, * only based on the wall distance and the velocity gradient. * - * \copydoc Dumux::EddyViscosityModels + * The following models are available: + * -# Prandtl's mixing length, e.g. \cite Oertel2012a + * -# Van-Driest modification, \cite vanDriest1956a and \cite Hanna1981a + * -# Baldwin-Lomax, \cite Baldwin1978a */ #ifndef DUMUX_ZEROEQ_MODEL_HH diff --git a/dumux/freeflow/rans/zeroeq/models.hh b/dumux/freeflow/rans/zeroeq/models.hh deleted file mode 100644 index 15fa56e090..0000000000 --- a/dumux/freeflow/rans/zeroeq/models.hh +++ /dev/null @@ -1,49 +0,0 @@ -// -*- 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::EddyViscosityModels - */ -#ifndef DUMUX_ZEROEQ_MODELS_HH -#define DUMUX_ZEROEQ_MODELS_HH - -namespace Dumux { - -/*! - * \ingroup ZeroEqModel - * \brief The available 0-eq. eddy viscosity models. - * - * The following models are available: - * -# Prandtl's mixing length, e.g. \cite Oertel2012a - * -# Van-Driest modification, \cite vanDriest1956a and \cite Hanna1981a - * -# Baldwin-Lomax, \cite Baldwin1978a - */ -class EddyViscosityModels -{ -public: - static constexpr int none = 0; - static constexpr int prandtl = 1; - static constexpr int modifiedVanDriest = 2; - static constexpr int baldwinLomax = 3; -}; - -} // end namespace Dumux - -#endif diff --git a/dumux/freeflow/rans/zeroeq/problem.hh b/dumux/freeflow/rans/zeroeq/problem.hh index 5382d415af..4db036eb33 100644 --- a/dumux/freeflow/rans/zeroeq/problem.hh +++ b/dumux/freeflow/rans/zeroeq/problem.hh @@ -24,6 +24,8 @@ #ifndef DUMUX_ZEROEQ_PROBLEM_HH #define DUMUX_ZEROEQ_PROBLEM_HH +#include <string> + #include <dumux/common/properties.hh> #include <dumux/common/staggeredfvproblem.hh> #include <dumux/discretization/localview.hh> @@ -32,7 +34,6 @@ #include <dumux/freeflow/rans/problem.hh> #include "model.hh" -#include "models.hh" namespace Dumux { @@ -77,7 +78,7 @@ public: ZeroEqProblem(std::shared_ptr<const FVGridGeometry> fvGridGeometry, const std::string& paramGroup = "") : ParentType(fvGridGeometry, paramGroup) { - eddyViscosityModel_ = getParamFromGroup<int>(paramGroup, "RANS.EddyViscosityModel", 1); + eddyViscosityModel_ = getParamFromGroup<std::string>(paramGroup, "RANS.EddyViscosityModel", "vanDriest"); } /*! @@ -127,7 +128,7 @@ public: volVars.update(elemSol, asImp_(), element, scv); Scalar ksPlus = this->sandGrainRoughness_[elementID] * volVars.uStar() / volVars.kinematicViscosity(); - if (ksPlus > 0 && eddyViscosityModel_ == EddyViscosityModels::baldwinLomax) + if (ksPlus > 0 && eddyViscosityModel_.compare("baldwinLomax") == 0) { DUNE_THROW(Dune::NotImplemented, "Roughness is not implemented for the Baldwin-Lomax model."); } @@ -151,7 +152,7 @@ public: } // update routine for specfic models - if (eddyViscosityModel_ == EddyViscosityModels::baldwinLomax) + if (eddyViscosityModel_.compare("baldwinLomax") == 0) updateBaldwinLomaxProperties(); } @@ -265,7 +266,7 @@ public: } public: - int eddyViscosityModel_; + std::string eddyViscosityModel_; std::vector<Scalar> kinematicEddyViscosity_; std::vector<Scalar> additionalRoughnessLength_; diff --git a/dumux/freeflow/rans/zeroeq/volumevariables.hh b/dumux/freeflow/rans/zeroeq/volumevariables.hh index aabe2bcbce..4f61a3d95f 100644 --- a/dumux/freeflow/rans/zeroeq/volumevariables.hh +++ b/dumux/freeflow/rans/zeroeq/volumevariables.hh @@ -25,9 +25,10 @@ #ifndef DUMUX_ZEROEQ_VOLUME_VARIABLES_HH #define DUMUX_ZEROEQ_VOLUME_VARIABLES_HH +#include <string> + #include <dune/common/exceptions.hh> #include <dumux/freeflow/rans/volumevariables.hh> -#include "models.hh" namespace Dumux { @@ -94,7 +95,7 @@ public: RANSParentType::updateRANSProperties(elemSol, problem, element, scv); additionalRoughnessLength_ = problem.additionalRoughnessLength_[RANSParentType::elementID()]; yPlusRough_ = wallDistanceRough() * RANSParentType::uStar() / RANSParentType::kinematicViscosity(); - dynamicEddyViscosity_ = calculateEddyViscosity(elemSol, problem, element, scv); + dynamicEddyViscosity_ = calculateEddyViscosity(elemSol, problem, element, scv, problem.eddyViscosityModel_); calculateEddyDiffusivity(problem); } @@ -129,12 +130,14 @@ public: * \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 + * \param modelName The name of the used model */ template<class ElementSolution, class Problem, class Element, class SubControlVolume> Scalar calculateEddyViscosity(const ElementSolution &elemSol, const Problem &problem, const Element &element, - const SubControlVolume& scv) + const SubControlVolume& scv, + const std::string modelName) { using std::abs; using std::exp; @@ -144,30 +147,30 @@ public: unsigned int wallNormalAxis = problem.wallNormalAxis_[RANSParentType::elementID()]; Scalar velGrad = abs(RANSParentType::velocityGradients()[flowNormalAxis][wallNormalAxis]); - if (problem.eddyViscosityModel_ == EddyViscosityModels::none) + if (modelName.compare("none") == 0) { // kinematicEddyViscosity = 0.0 } - else if (problem.eddyViscosityModel_ == EddyViscosityModels::prandtl) + else if (modelName.compare("prandtl") == 0) { Scalar mixingLength = problem.karmanConstant() * wallDistanceRough(); kinematicEddyViscosity = mixingLength * mixingLength * velGrad; } - else if (problem.eddyViscosityModel_ == EddyViscosityModels::modifiedVanDriest) + else if (modelName.compare("vanDriest") == 0) { Scalar mixingLength = problem.karmanConstant() * wallDistanceRough() * (1.0 - exp(-yPlusRough() / 26.0)) / sqrt(1.0 - exp(-0.26 * yPlusRough())); kinematicEddyViscosity = mixingLength * mixingLength * velGrad; } - else if (problem.eddyViscosityModel_ == EddyViscosityModels::baldwinLomax) + else if (modelName.compare("baldwinLomax") == 0) { kinematicEddyViscosity = problem.kinematicEddyViscosity_[RANSParentType::elementID()]; } else { DUNE_THROW(Dune::NotImplemented, - "This eddy viscosity model is not implemented: " << problem.eddyViscosityModel_); + "The eddy viscosity model \"" << modelName << "\" is not implemented."); } return kinematicEddyViscosity * NavierStokesParentType::density(); diff --git a/test/freeflow/rans/test_pipe_laufer.input b/test/freeflow/rans/test_pipe_laufer.input index f11416bc5e..20eba371cd 100644 --- a/test/freeflow/rans/test_pipe_laufer.input +++ b/test/freeflow/rans/test_pipe_laufer.input @@ -21,7 +21,7 @@ EnableGravity = false SandGrainRoughness = 0.0 # [m] # not implemented for EddyViscosityModel = 3 [RANS] -EddyViscosityModel = 3 +EddyViscosityModel = "baldwinLomax" UseStoredEddyViscosity = false [Assembly] diff --git a/test/freeflow/rans/test_pipe_laufer_reference.input b/test/freeflow/rans/test_pipe_laufer_reference.input index 262dceb9fe..daedf5780a 100644 --- a/test/freeflow/rans/test_pipe_laufer_reference.input +++ b/test/freeflow/rans/test_pipe_laufer_reference.input @@ -16,7 +16,7 @@ InletVelocity = 2.5 # [m/s] EnableGravity = false [RANS] -EddyViscosityModel = 3 +EddyViscosityModel = "baldwinLomax" [Assembly] NumericDifferenceMethod = 0 diff --git a/test/freeflow/rans/test_pipe_zeroeqni.input b/test/freeflow/rans/test_pipe_zeroeqni.input index 77273d9aed..924d125906 100644 --- a/test/freeflow/rans/test_pipe_zeroeqni.input +++ b/test/freeflow/rans/test_pipe_zeroeqni.input @@ -18,7 +18,7 @@ WallTemperature = 303.15 # [K] EnableGravity = false [RANS] -EddyViscosityModel = 3 +EddyViscosityModel = "baldwinLomax" [Assembly] NumericDifferenceMethod = 0 diff --git a/test/freeflow/ransnc/test_flatplate2c.input b/test/freeflow/ransnc/test_flatplate2c.input index 0098301d06..0651ae51e6 100644 --- a/test/freeflow/ransnc/test_flatplate2c.input +++ b/test/freeflow/ransnc/test_flatplate2c.input @@ -16,7 +16,7 @@ InletVelocity = 0.1 # [m/s] EnableGravity = false [RANS] -EddyViscosityModel = 3 +EddyViscosityModel = "baldwinLomax" TurbulentSchmidtNumber = 0.7 [Assembly] diff --git a/test/freeflow/ransnc/test_flatplate2cni.input b/test/freeflow/ransnc/test_flatplate2cni.input index d3640ff2e2..b23acfd7ee 100644 --- a/test/freeflow/ransnc/test_flatplate2cni.input +++ b/test/freeflow/ransnc/test_flatplate2cni.input @@ -16,6 +16,7 @@ InletVelocity = 0.1 # [m/s] EnableGravity = false [RANS] +EddyViscosityModel = "prandtl" TurbulentSchmidtNumber = 0.7 TurbulentPrandtlNumber = 0.85 -- GitLab