Commit 1715aa52 authored by Kilian Weishaupt's avatar Kilian Weishaupt
Browse files

[io][pmflow] Remove phaseIdxOffset

* use SFINAE and check if fluidSystemPhaseIdx is present
parent 2dae6828
......@@ -53,14 +53,13 @@ namespace Dumux {
* \brief A VTK output module to simplify writing dumux simulation data to VTK format
*
* \tparam TypeTag The TypeTag of the problem implementation
* \tparam phaseIdxOffset Used for single-phase problems to retrieve the right phase name
*
* Handles the output of scalar and vector fields to VTK formatted file for multiple
* variables and timesteps. Certain predefined fields can be registered on
* initialization and/or be turned on/off using the designated properties. Additionally
* non-standardized scalar and vector fields can be added to the writer manually.
*/
template<typename TypeTag, int phaseIdxOffset = 0>
template<typename TypeTag>
class VtkOutputModule
{
using Problem = typename GET_PROP_TYPE(TypeTag, Problem);
......@@ -372,7 +371,7 @@ private:
{
for (int phaseIdx = 0; phaseIdx < numPhaseVelocities; ++phaseIdx)
sequenceWriter_.addVertexData( Field(gridGeom_.gridView(), gridGeom_.vertexMapper(), velocity[phaseIdx],
"velocity_" + velocityOutput.phaseName(phaseIdx+phaseIdxOffset) + " (m/s)",
"velocity_" + velocityOutput.phaseName(phaseIdx) + " (m/s)",
/*numComp*/dimWorld, /*codim*/dim).get() );
}
// cell-centered models
......@@ -380,7 +379,7 @@ private:
{
for (int phaseIdx = 0; phaseIdx < numPhaseVelocities; ++phaseIdx)
sequenceWriter_.addCellData( Field(gridGeom_.gridView(), gridGeom_.elementMapper(), velocity[phaseIdx],
"velocity_" + velocityOutput.phaseName(phaseIdx+phaseIdxOffset) + " (m/s)",
"velocity_" + velocityOutput.phaseName(phaseIdx) + " (m/s)",
/*numComp*/dimWorld, /*codim*/0).get() );
}
}
......@@ -540,14 +539,14 @@ private:
if (dim > 1)
for (int phaseIdx = 0; phaseIdx < numPhaseVelocities; ++phaseIdx)
sequenceWriter_.addVertexData( Field(gridGeom_.gridView(), gridGeom_.vertexMapper(), velocity[phaseIdx],
"velocity_" + velocityOutput.phaseName(phaseIdx+phaseIdxOffset) + " (m/s)",
"velocity_" + velocityOutput.phaseName(phaseIdx) + " (m/s)",
/*numComp*/dimWorld, /*codim*/dim).get() );
// cell-wise velocities
else
for (int phaseIdx = 0; phaseIdx < numPhaseVelocities; ++phaseIdx)
sequenceWriter_.addCellData( Field(gridGeom_.gridView(), gridGeom_.elementMapper(), velocity[phaseIdx],
"velocity_" + velocityOutput.phaseName(phaseIdx+phaseIdxOffset) + " (m/s)",
"velocity_" + velocityOutput.phaseName(phaseIdx) + " (m/s)",
/*numComp*/dimWorld, /*codim*/0).get() );
}
......
......@@ -51,10 +51,10 @@ namespace Dumux {
* initialization and/or be turned on/off using the designated properties. Additionally
* non-standardized scalar and vector fields can be added to the writer manually.
*/
template<class TypeTag, class FractureGrid, int phaseIdxOffset = 0>
class BoxDfmVtkOutputModule : public VtkOutputModule<TypeTag, phaseIdxOffset>
template<class TypeTag, class FractureGrid>
class BoxDfmVtkOutputModule : public VtkOutputModule<TypeTag>
{
using ParentType = VtkOutputModule<TypeTag, phaseIdxOffset>;
using ParentType = VtkOutputModule<TypeTag>;
using Problem = typename GET_PROP_TYPE(TypeTag, Problem);
using GridVariables = typename GET_PROP_TYPE(TypeTag, GridVariables);
......@@ -270,7 +270,7 @@ private:
{
for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
this->sequenceWriter().addVertexData( Field(gridView, this->fvGridGeometry().vertexMapper(), velocity[phaseIdx],
"velocity_" + std::string(FluidSystem::phaseName(phaseIdx+phaseIdxOffset)) + " (m/s)",
"velocity_" + velocityOutput.phaseName(phaseIdx) + " (m/s)",
/*numComp*/dimWorld, /*codim*/dim).get() );
}
......@@ -455,7 +455,7 @@ private:
{
for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
this->sequenceWriter().addVertexData( Field(gridView, this->fvGridGeometry().vertexMapper(), velocity[phaseIdx],
"velocity_" + std::string(FluidSystem::phaseName(phaseIdx+phaseIdxOffset)) + " (m/s)",
"velocity_" + velocityOutput.phaseName(phaseIdx) + " (m/s)",
/*numComp*/dimWorld, /*codim*/dim).get() );
}
......
......@@ -30,11 +30,25 @@
#include <dumux/common/properties.hh>
#include <dumux/common/parameters.hh>
#include <dumux/common/typetraits/isvalid.hh>
#include <dumux/discretization/methods.hh>
#include <dumux/discretization/elementsolution.hh>
namespace Dumux {
namespace Detail {
//! helper struct detecting if an Indices class contains a fluidSystemPhaseIdx
struct hasFluidSystemPhaseIdx
{
template<class Indices>
auto operator()(Indices&&)
-> decltype(Indices::fluidSystemPhaseIdx)
{}
};
} // end namespace Detail
/*!
* \brief Velocity output for implicit (porous media) models
*/
......@@ -52,6 +66,7 @@ class PorousMediumFlowVelocityOutput
using FluxVariables = typename GET_PROP_TYPE(TypeTag, FluxVariables);
using BoundaryTypes = typename GET_PROP_TYPE(TypeTag, BoundaryTypes);
using GridView = typename GET_PROP_TYPE(TypeTag, GridView);
using Indices = typename GET_PROP_TYPE(TypeTag, ModelTraits)::Indices;
using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry);
using GridVariables = typename GET_PROP_TYPE(TypeTag, GridVariables);
......@@ -106,7 +121,12 @@ public:
//! returns whether or not velocity output is enabled
bool enableOutput() { return velocityOutput_; }
//! returns the name of the phase for a given index for models that use a fluidsystem phase index (e.g. 1pnc)
template<bool hasFluidSystemPhaseIdx = decltype(isValid(Detail::hasFluidSystemPhaseIdx())(Indices{}))::value, std::enable_if_t<hasFluidSystemPhaseIdx, int> = 0>
static std::string phaseName(int phaseIdx) { return FluidSystem::phaseName(Indices::fluidSystemPhaseIdx); }
//! returns the name of the phase for a given index
template<bool hasFluidSystemPhaseIdx = decltype(isValid(Detail::hasFluidSystemPhaseIdx())(Indices{}))::value, std::enable_if_t<!hasFluidSystemPhaseIdx, int> = 0>
static std::string phaseName(int phaseIdx) { return FluidSystem::phaseName(phaseIdx); }
//! returns the number of phase velocities computed by this class
......
......@@ -110,7 +110,7 @@ int main(int argc, char** argv) try
auto maxDt = getParam<Scalar>("TimeLoop.MaxTimeStepSize");
// intialize the vtk output module
VtkOutputModule<TypeTag, GET_PROP_VALUE(TypeTag, PhaseIdx)> vtkWriter(*problem, *fvGridGeometry, *gridVariables, x, problem->name());
VtkOutputModule<TypeTag> vtkWriter(*problem, *fvGridGeometry, *gridVariables, x, problem->name());
using VtkOutputFields = typename GET_PROP_TYPE(TypeTag, VtkOutputFields);
VtkOutputFields::init(vtkWriter); //!< Add model specific output fields
vtkWriter.write(0.0);
......
......@@ -110,7 +110,7 @@ int main(int argc, char** argv) try
auto maxDt = getParam<Scalar>("TimeLoop.MaxTimeStepSize");
// intialize the vtk output module
VtkOutputModule<TypeTag, GET_PROP_VALUE(TypeTag, PhaseIdx)> vtkWriter(*problem, *fvGridGeometry, *gridVariables, x, problem->name());
VtkOutputModule<TypeTag> vtkWriter(*problem, *fvGridGeometry, *gridVariables, x, problem->name());
using VtkOutputFields = typename GET_PROP_TYPE(TypeTag, VtkOutputFields);
VtkOutputFields::init(vtkWriter); //!< Add model specific output fields
vtkWriter.addField(problem->getExactTemperature(), "temperatureExact");
......
......@@ -110,7 +110,7 @@ int main(int argc, char** argv) try
auto maxDt = getParam<Scalar>("TimeLoop.MaxTimeStepSize");
// intialize the vtk output module
VtkOutputModule<TypeTag, GET_PROP_VALUE(TypeTag, PhaseIdx)> vtkWriter(*problem, *fvGridGeometry, *gridVariables, x, problem->name());
VtkOutputModule<TypeTag> vtkWriter(*problem, *fvGridGeometry, *gridVariables, x, problem->name());
using VtkOutputFields = typename GET_PROP_TYPE(TypeTag, VtkOutputFields);
VtkOutputFields::init(vtkWriter); //!< Add model specific output fields
vtkWriter.addField(problem->getExactTemperature(), "temperatureExact");
......
......@@ -136,7 +136,7 @@ int main(int argc, char** argv) try
auto maxDt = getParam<Scalar>("TimeLoop.MaxTimeStepSize");
// intialize the vtk output module
VtkOutputModule<TypeTag, GET_PROP_VALUE(TypeTag, PhaseIdx)> vtkWriter(*problem, *fvGridGeometry, *gridVariables, x, problem->name());
VtkOutputModule<TypeTag> vtkWriter(*problem, *fvGridGeometry, *gridVariables, x, problem->name());
using VtkOutputFields = typename GET_PROP_TYPE(TypeTag, VtkOutputFields);
VtkOutputFields::init(vtkWriter);
......
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