diff --git a/dumux/freeflow/rans/CMakeLists.txt b/dumux/freeflow/rans/CMakeLists.txt index 6aab4a5d747a00c78bd902688afb6011eea342fc..386564fc5127b952f9b4373247020bff79cc398e 100644 --- a/dumux/freeflow/rans/CMakeLists.txt +++ b/dumux/freeflow/rans/CMakeLists.txt @@ -3,4 +3,5 @@ install(FILES model.hh problem.hh volumevariables.hh +vtkoutputfields.hh DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dumux/freeflow/rans) diff --git a/dumux/freeflow/rans/model.hh b/dumux/freeflow/rans/model.hh index 4eec38257727321ec807250716521f8e6118dc95..597193c192c47c872accc80b61634b2dbfd68ec7 100644 --- a/dumux/freeflow/rans/model.hh +++ b/dumux/freeflow/rans/model.hh @@ -44,6 +44,7 @@ #include <dumux/freeflow/nonisothermal/model.hh> #include "volumevariables.hh" +#include "vtkoutputfields.hh" #include <dumux/material/fluidstates/immiscible.hh> #include <dumux/discretization/methods.hh> @@ -74,6 +75,9 @@ SET_BOOL_PROP(RANS, EnableInertiaTerms, true); //!< Explicitly force the conside //! The volume variables SET_TYPE_PROP(RANS, VolumeVariables, RANSVolumeVariables<TypeTag>); + +//! The specific vtk output fields +SET_TYPE_PROP(RANS, VtkOutputFields, RANSVtkOutputFields<TypeTag>); // \} } diff --git a/dumux/freeflow/rans/volumevariables.hh b/dumux/freeflow/rans/volumevariables.hh index 78f3b9fd95216cfdf7cbdb29b1f4fdeb3963d41f..2f90b5859f9f7e4a9f91093557ae12b31dfe266f 100644 --- a/dumux/freeflow/rans/volumevariables.hh +++ b/dumux/freeflow/rans/volumevariables.hh @@ -82,12 +82,8 @@ public: const Element &element, const SubControlVolume& scv) { - ParentType::completeFluidState(elemSol, problem, element, scv, fluidState_); - dynamicEddyViscosity_ = scv.dofPosition()[1] * scv.dofPosition()[1]; - std::cout << dynamicEddyViscosity_ << " " - << asImp_().viscosity(defaultPhaseIdx) << " " - << effectiveViscosity(defaultPhaseIdx) << " " - << std::endl; + ParentType::update(elemSol, problem, element, scv); + dynamicEddyViscosity_ = std::max(0.0, scv.dofPosition()[1] * (0.2469 - scv.dofPosition()[1])); // TODO preliminary }; /*! @@ -159,7 +155,7 @@ public: const Element &element, const SubControlVolume &scv) { - completeFluidState(elemSol, problem, element, scv, this->fluidState_); + update(elemSol, problem, element, scv); } /*! diff --git a/dumux/freeflow/rans/vtkoutputfields.hh b/dumux/freeflow/rans/vtkoutputfields.hh new file mode 100644 index 0000000000000000000000000000000000000000..63de8b2fdb3f636a8125d24637e8edd6750ad97c --- /dev/null +++ b/dumux/freeflow/rans/vtkoutputfields.hh @@ -0,0 +1,99 @@ +// -*- 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 RANSModel + * \copydoc Dumux::RANSVtkOutputFields + */ +#ifndef DUMUX_RANS_VTK_OUTPUT_FIELDS_HH +#define DUMUX_RANS_VTK_OUTPUT_FIELDS_HH + +#include <dune/common/fvector.hh> +#include <dumux/common/properties.hh> +#include <dumux/common/parameters.hh> +#include <dumux/discretization/methods.hh> + +namespace Dumux +{ + +/*! + * \ingroup RANSModel + * \brief Adds vtk output fields for the Reynolds-Averaged Navier-Stokes model + */ +template<class TypeTag> +class RANSVtkOutputFields +{ + using Indices = typename GET_PROP_TYPE(TypeTag, Indices); + using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar); + using GridView = typename GET_PROP_TYPE(TypeTag, GridView); + using VolumeVariables = typename GET_PROP_TYPE(TypeTag, VolumeVariables); + using SubControlVolumeFace = typename GET_PROP_TYPE(TypeTag, SubControlVolumeFace); + using FaceVariables = typename GET_PROP_TYPE(TypeTag, FaceVariables); + + using GlobalPosition = Dune::FieldVector<Scalar, GridView::dimensionworld>; + + // Helper type used for tag dispatching (to add discretization-specific fields). + template<DiscretizationMethods method> + using MethodType = std::integral_constant<DiscretizationMethods, method>; + +public: + //! Initialize the Navier-Stokes specific vtk output fields. + template <class VtkOutputModule> + static void init(VtkOutputModule& vtk) + { + vtk.addVolumeVariable([](const VolumeVariables& v){ return v.pressure(); }, "p [Pa]"); + vtk.addVolumeVariable([](const VolumeVariables& v){ return v.pressure() - 1e5; }, "p_rel [Pa]"); + vtk.addVolumeVariable([](const VolumeVariables& v){ return v.density(); }, "rho [kg/m^3]"); + vtk.addVolumeVariable([](const VolumeVariables& v){ return v.viscosity() / v.density(); }, "nu [m^2/s]"); + vtk.addVolumeVariable([](const VolumeVariables& v){ return v.dynamicEddyViscosity() / v.density(); }, "nu_t [m^2/s]"); + + // add discretization-specific fields + const auto discType = MethodType<GET_PROP_VALUE(TypeTag, DiscretizationMethod)>(); + additionalOutput_(vtk, discType); + } + +private: + + //! Adds discretization-specific fields (nothing by default). + template <class VtkOutputModule, class AnyMethod> + static void additionalOutput_(VtkOutputModule& vtk, AnyMethod) + { } + + //! Adds discretization-specific fields (velocity vectors on the faces for the staggered discretization). + template <class VtkOutputModule> + static void additionalOutput_(VtkOutputModule& vtk, MethodType<DiscretizationMethods::Staggered>) + { + const bool writeFaceVars = getParamFromGroup<bool>(GET_PROP_VALUE(TypeTag, ModelParameterGroup), "Vtk.WriteFaceData", false); + if(writeFaceVars) + { + auto faceVelocityVector = [](const SubControlVolumeFace& scvf, const FaceVariables& f) + { + GlobalPosition velocity(0.0); + velocity[scvf.directionIndex()] = f.velocitySelf(); + return velocity; + }; + + vtk.addFaceVariable(faceVelocityVector, "faceVelocity"); + } + } +}; + +} // end namespace Dumux + +#endif diff --git a/test/freeflow/rans/pipelauferproblem.hh b/test/freeflow/rans/pipelauferproblem.hh index 933dc780bfec350cb9b2e4ab3417aabd59d0de36..80bae39c7355b4e968e4035665cedc6ca9b41006 100644 --- a/test/freeflow/rans/pipelauferproblem.hh +++ b/test/freeflow/rans/pipelauferproblem.hh @@ -199,8 +199,11 @@ public: PrimaryVariables initialAtPos(const GlobalPosition &globalPos) const { PrimaryVariables values; - values[pressureIdx] = 1.1e+5; - values[velocityXIdx] = 0.0; + values[pressureIdx] = 1.0e+5; + if(isInlet(globalPos)) + { + values[velocityXIdx] = inletVelocity_; + } values[velocityYIdx] = 0.0; return values;