From e21f9c98eb35f6c96f05f52d3b46b2416078aa6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dennis=20Gl=C3=A4ser?= <dennis.glaeser@iws.uni-stuttgart.de> Date: Tue, 8 May 2018 11:14:01 +0200 Subject: [PATCH] [io] make vtk output module independent of fluid system Geomechanical models will not be able to reuse the vtk output module otherwise. --- .../discretization/staggered/freeflow/velocityoutput.hh | 4 ++++ dumux/io/vtkoutputmodule.hh | 9 ++++----- dumux/porousmediumflow/velocityoutput.hh | 5 +++++ 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/dumux/discretization/staggered/freeflow/velocityoutput.hh b/dumux/discretization/staggered/freeflow/velocityoutput.hh index 05ed28c28b..1d8683a4f6 100644 --- a/dumux/discretization/staggered/freeflow/velocityoutput.hh +++ b/dumux/discretization/staggered/freeflow/velocityoutput.hh @@ -78,6 +78,10 @@ public: bool enableOutput() { return velocityOutput_; } + // returns the name of the phase for a given index + static std::string phaseName(int phaseIdx) + { return GET_PROP_TYPE(TypeTag, FluidSystem)::phaseName(phaseIdx); } + //! Return the problem boundary types auto problemBoundaryTypes(const Element& element, const SubControlVolumeFace& scvf) const { return problem_.boundaryTypes(element, scvf); } diff --git a/dumux/io/vtkoutputmodule.hh b/dumux/io/vtkoutputmodule.hh index 708d5406bd..63522f9d89 100644 --- a/dumux/io/vtkoutputmodule.hh +++ b/dumux/io/vtkoutputmodule.hh @@ -72,7 +72,6 @@ class VtkOutputModule static constexpr int numPhases = ModelTraits::numPhases(); using VV = typename GridVariables::VolumeVariables; - using FluidSystem = typename VV::FluidSystem; using Scalar = typename GridVariables::Scalar; using GridView = typename FVGridGeometry::GridView; @@ -381,7 +380,7 @@ private: { for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) sequenceWriter_.addVertexData( Field(gridGeom_.gridView(), gridGeom_.vertexMapper(), velocity[phaseIdx], - "velocity_" + std::string(FluidSystem::phaseName(phaseIdx+phaseIdxOffset)) + " (m/s)", + "velocity_" + velocityOutput.phaseName(phaseIdx+phaseIdxOffset) + " (m/s)", /*numComp*/dimWorld, /*codim*/dim).get() ); } // cell-centered models @@ -389,7 +388,7 @@ private: { for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) sequenceWriter_.addCellData( Field(gridGeom_.gridView(), gridGeom_.elementMapper(), velocity[phaseIdx], - "velocity_" + std::string(FluidSystem::phaseName(phaseIdx+phaseIdxOffset)) + " (m/s)", + "velocity_" + velocityOutput.phaseName(phaseIdx+phaseIdxOffset) + " (m/s)", /*numComp*/dimWorld, /*codim*/0).get() ); } } @@ -549,14 +548,14 @@ private: if (dim > 1) for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) sequenceWriter_.addVertexData( Field(gridGeom_.gridView(), gridGeom_.vertexMapper(), velocity[phaseIdx], - "velocity_" + std::string(FluidSystem::phaseName(phaseIdx+phaseIdxOffset)) + " (m/s)", + "velocity_" + velocityOutput.phaseName(phaseIdx+phaseIdxOffset) + " (m/s)", /*numComp*/dimWorld, /*codim*/dim).get() ); // cell-wise velocities else for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) sequenceWriter_.addCellData( Field(gridGeom_.gridView(), gridGeom_.elementMapper(), velocity[phaseIdx], - "velocity_" + std::string(FluidSystem::phaseName(phaseIdx+phaseIdxOffset)) + " (m/s)", + "velocity_" + velocityOutput.phaseName(phaseIdx+phaseIdxOffset) + " (m/s)", /*numComp*/dimWorld, /*codim*/0).get() ); } diff --git a/dumux/porousmediumflow/velocityoutput.hh b/dumux/porousmediumflow/velocityoutput.hh index 65101339f5..b7877c5e2a 100644 --- a/dumux/porousmediumflow/velocityoutput.hh +++ b/dumux/porousmediumflow/velocityoutput.hh @@ -48,6 +48,7 @@ class PorousMediumFlowVelocityOutput using SubControlVolumeFace = typename FVElementGeometry::SubControlVolumeFace; using ElementVolumeVariables = typename GET_PROP_TYPE(TypeTag, GridVolumeVariables)::LocalView; using VolumeVariables = typename GET_PROP_TYPE(TypeTag, VolumeVariables); + using FluidSystem = typename GET_PROP_TYPE(TypeTag, FluidSystem); using FluxVariables = typename GET_PROP_TYPE(TypeTag, FluxVariables); using BoundaryTypes = typename GET_PROP_TYPE(TypeTag, BoundaryTypes); using GridView = typename GET_PROP_TYPE(TypeTag, GridView); @@ -106,6 +107,10 @@ public: bool enableOutput() { return velocityOutput_; } + // returns the name of the phase for a given index + static std::string phaseName(int phaseIdx) + { return FluidSystem::phaseName(phaseIdx); } + // The following SFINAE enable_if usage allows compilation, even if only a // // boundaryTypes(const Element&, const scv&) -- GitLab