Skip to content
Snippets Groups Projects
Commit bd4e8872 authored by Dennis Gläser's avatar Dennis Gläser
Browse files

[io][vtkoutput] let velocityOutput decide number of phase velocities

This commit will enable the geomechanics framework to not have to
state the number of phases in geomechanical model traits. Also, when
velocity output for the geomechanical models is implemented, we will
have to distinguish in the vtk output module anyway, as then we would
have to call numSolidPhases(). Outsourcing it directly to the velocity
output seems like an elegant solution.
parent e21f9c98
No related branches found
No related tags found
1 merge request!973Feature/box elastic
...@@ -82,6 +82,10 @@ public: ...@@ -82,6 +82,10 @@ public:
static std::string phaseName(int phaseIdx) static std::string phaseName(int phaseIdx)
{ return GET_PROP_TYPE(TypeTag, FluidSystem)::phaseName(phaseIdx); } { return GET_PROP_TYPE(TypeTag, FluidSystem)::phaseName(phaseIdx); }
// returns the number of phase velocities computed by this class
static constexpr int numPhaseVelocities()
{ return GET_PROP_TYPE(TypeTag, ModelTraits)::numPhases(); }
//! Return the problem boundary types //! Return the problem boundary types
auto problemBoundaryTypes(const Element& element, const SubControlVolumeFace& scvf) const auto problemBoundaryTypes(const Element& element, const SubControlVolumeFace& scvf) const
{ return problem_.boundaryTypes(element, scvf); } { return problem_.boundaryTypes(element, scvf); }
......
...@@ -68,8 +68,7 @@ class VtkOutputModule ...@@ -68,8 +68,7 @@ class VtkOutputModule
using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector); using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector);
using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry);
using VelocityOutput = typename GET_PROP_TYPE(TypeTag, VelocityOutput); using VelocityOutput = typename GET_PROP_TYPE(TypeTag, VelocityOutput);
using ModelTraits = typename GET_PROP_TYPE(TypeTag, ModelTraits); static constexpr int numPhaseVelocities = VelocityOutput::numPhaseVelocities();
static constexpr int numPhases = ModelTraits::numPhases();
using VV = typename GridVariables::VolumeVariables; using VV = typename GridVariables::VolumeVariables;
using Scalar = typename GridVariables::Scalar; using Scalar = typename GridVariables::Scalar;
...@@ -263,7 +262,7 @@ private: ...@@ -263,7 +262,7 @@ private:
// instatiate the velocity output // instatiate the velocity output
VelocityOutput velocityOutput(problem_, gridGeom_, gridVariables_, sol_); VelocityOutput velocityOutput(problem_, gridGeom_, gridVariables_, sol_);
std::array<std::vector<VelocityVector>, numPhases> velocity; std::array<std::vector<VelocityVector>, numPhaseVelocities> velocity;
// process rank // process rank
static bool addProcessRank = getParamFromGroup<bool>(paramGroup_, "Vtk.AddProcessRank"); static bool addProcessRank = getParamFromGroup<bool>(paramGroup_, "Vtk.AddProcessRank");
...@@ -291,7 +290,7 @@ private: ...@@ -291,7 +290,7 @@ private:
if (velocityOutput.enableOutput()) if (velocityOutput.enableOutput())
{ {
for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) for (int phaseIdx = 0; phaseIdx < numPhaseVelocities; ++phaseIdx)
{ {
if(isBox && dim == 1) if(isBox && dim == 1)
velocity[phaseIdx].resize(numCells); velocity[phaseIdx].resize(numCells);
...@@ -343,7 +342,7 @@ private: ...@@ -343,7 +342,7 @@ private:
// velocity output // velocity output
if (velocityOutput.enableOutput()) if (velocityOutput.enableOutput())
for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) for (int phaseIdx = 0; phaseIdx < numPhaseVelocities; ++phaseIdx)
velocityOutput.calculateVelocity(velocity[phaseIdx], elemVolVars, fvGeometry, element, phaseIdx); velocityOutput.calculateVelocity(velocity[phaseIdx], elemVolVars, fvGeometry, element, phaseIdx);
//! the rank //! the rank
...@@ -378,7 +377,7 @@ private: ...@@ -378,7 +377,7 @@ private:
{ {
if (isBox && dim > 1) if (isBox && dim > 1)
{ {
for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) for (int phaseIdx = 0; phaseIdx < numPhaseVelocities; ++phaseIdx)
sequenceWriter_.addVertexData( Field(gridGeom_.gridView(), gridGeom_.vertexMapper(), velocity[phaseIdx], sequenceWriter_.addVertexData( Field(gridGeom_.gridView(), gridGeom_.vertexMapper(), velocity[phaseIdx],
"velocity_" + velocityOutput.phaseName(phaseIdx+phaseIdxOffset) + " (m/s)", "velocity_" + velocityOutput.phaseName(phaseIdx+phaseIdxOffset) + " (m/s)",
/*numComp*/dimWorld, /*codim*/dim).get() ); /*numComp*/dimWorld, /*codim*/dim).get() );
...@@ -386,7 +385,7 @@ private: ...@@ -386,7 +385,7 @@ private:
// cell-centered models // cell-centered models
else else
{ {
for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) for (int phaseIdx = 0; phaseIdx < numPhaseVelocities; ++phaseIdx)
sequenceWriter_.addCellData( Field(gridGeom_.gridView(), gridGeom_.elementMapper(), velocity[phaseIdx], sequenceWriter_.addCellData( Field(gridGeom_.gridView(), gridGeom_.elementMapper(), velocity[phaseIdx],
"velocity_" + velocityOutput.phaseName(phaseIdx+phaseIdxOffset) + " (m/s)", "velocity_" + velocityOutput.phaseName(phaseIdx+phaseIdxOffset) + " (m/s)",
/*numComp*/dimWorld, /*codim*/0).get() ); /*numComp*/dimWorld, /*codim*/0).get() );
...@@ -432,7 +431,7 @@ private: ...@@ -432,7 +431,7 @@ private:
// instatiate the velocity output // instatiate the velocity output
VelocityOutput velocityOutput(problem_, gridGeom_, gridVariables_, sol_); VelocityOutput velocityOutput(problem_, gridGeom_, gridVariables_, sol_);
std::array<std::vector<VelocityVector>, numPhases> velocity; std::array<std::vector<VelocityVector>, numPhaseVelocities> velocity;
// process rank // process rank
static bool addProcessRank = getParamFromGroup<bool>(paramGroup_, "Vtk.AddProcessRank"); static bool addProcessRank = getParamFromGroup<bool>(paramGroup_, "Vtk.AddProcessRank");
...@@ -462,7 +461,7 @@ private: ...@@ -462,7 +461,7 @@ private:
if (velocityOutput.enableOutput()) if (velocityOutput.enableOutput())
{ {
for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) for (int phaseIdx = 0; phaseIdx < numPhaseVelocities; ++phaseIdx)
{ {
if(isBox && dim == 1) if(isBox && dim == 1)
velocity[phaseIdx].resize(numCells); velocity[phaseIdx].resize(numCells);
...@@ -520,7 +519,7 @@ private: ...@@ -520,7 +519,7 @@ private:
// velocity output // velocity output
if (velocityOutput.enableOutput()) if (velocityOutput.enableOutput())
for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) for (int phaseIdx = 0; phaseIdx < numPhaseVelocities; ++phaseIdx)
velocityOutput.calculateVelocity(velocity[phaseIdx], elemVolVars, fvGeometry, element, phaseIdx); velocityOutput.calculateVelocity(velocity[phaseIdx], elemVolVars, fvGeometry, element, phaseIdx);
//! the rank //! the rank
...@@ -546,14 +545,14 @@ private: ...@@ -546,14 +545,14 @@ private:
{ {
// node-wise velocities // node-wise velocities
if (dim > 1) if (dim > 1)
for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) for (int phaseIdx = 0; phaseIdx < numPhaseVelocities; ++phaseIdx)
sequenceWriter_.addVertexData( Field(gridGeom_.gridView(), gridGeom_.vertexMapper(), velocity[phaseIdx], sequenceWriter_.addVertexData( Field(gridGeom_.gridView(), gridGeom_.vertexMapper(), velocity[phaseIdx],
"velocity_" + velocityOutput.phaseName(phaseIdx+phaseIdxOffset) + " (m/s)", "velocity_" + velocityOutput.phaseName(phaseIdx+phaseIdxOffset) + " (m/s)",
/*numComp*/dimWorld, /*codim*/dim).get() ); /*numComp*/dimWorld, /*codim*/dim).get() );
// cell-wise velocities // cell-wise velocities
else else
for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) for (int phaseIdx = 0; phaseIdx < numPhaseVelocities; ++phaseIdx)
sequenceWriter_.addCellData( Field(gridGeom_.gridView(), gridGeom_.elementMapper(), velocity[phaseIdx], sequenceWriter_.addCellData( Field(gridGeom_.gridView(), gridGeom_.elementMapper(), velocity[phaseIdx],
"velocity_" + velocityOutput.phaseName(phaseIdx+phaseIdxOffset) + " (m/s)", "velocity_" + velocityOutput.phaseName(phaseIdx+phaseIdxOffset) + " (m/s)",
/*numComp*/dimWorld, /*codim*/0).get() ); /*numComp*/dimWorld, /*codim*/0).get() );
......
...@@ -111,6 +111,10 @@ public: ...@@ -111,6 +111,10 @@ public:
static std::string phaseName(int phaseIdx) static std::string phaseName(int phaseIdx)
{ return FluidSystem::phaseName(phaseIdx); } { return FluidSystem::phaseName(phaseIdx); }
// returns the number of phase velocities computed by this class
static constexpr int numPhaseVelocities()
{ return GET_PROP_TYPE(TypeTag, ModelTraits)::numPhases(); }
// The following SFINAE enable_if usage allows compilation, even if only a // The following SFINAE enable_if usage allows compilation, even if only a
// //
// boundaryTypes(const Element&, const scv&) // boundaryTypes(const Element&, const scv&)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment