25#ifndef DUMUX_PNM_VTK_OUTPUT_MODULE_HH
26#define DUMUX_PNM_VTK_OUTPUT_MODULE_HH
37template<
class Gr
idVariables,
class FluxVariables,
class SolutionVector>
41 using Scalar =
typename GridVariables::Scalar;
42 using FluxVarsCache =
typename GridVariables::GridFluxVariablesCache::FluxVariablesCache;
44 struct ThroatFluxDataInfo { std::function<Scalar(
const FluxVariables&,
const FluxVarsCache&)> get; std::string
name; };
50 const SolutionVector&
sol,
51 const std::string&
name,
53 Dune::VTK::DataMode dm = Dune::VTK::conforming,
57 if constexpr (GridVariables::VolumeVariables::numFluidPhases() >= 1)
68 void addFluxVariable(std::function<Scalar(
const FluxVariables&,
const FluxVarsCache&)>&& f,
const std::string&
name)
70 throatFluxDataInfo_.push_back(ThroatFluxDataInfo{f,
name});
71 const auto numElems =
problem().gridGeometry().gridView().size(0);
72 throatFluxData_.push_back(std::vector<Scalar>(numElems));
77 void write(
double time, Dune::VTK::OutputType type = Dune::VTK::ascii)
79 const auto gridView =
problem().gridGeometry().gridView();
80 const auto numElems = gridView.size(0);
83 for (
auto& data : throatFluxData_)
84 data.resize(numElems);
90 for (
const auto& element : elements(gridView, Dune::Partitions::interior))
92 const auto eIdx =
problem().gridGeometry().elementMapper().index(element);
95 fvElementGeometry.bindElement(element);
96 elemVolVars.bind(element, fvElementGeometry, this->
sol());
97 elemFluxVarsCache.bind(element, fvElementGeometry, elemVolVars);
100 std::size_t dataIdx = 0;
101 for (
auto&& scvf : scvfs(fvElementGeometry))
103 if (!scvf.boundary())
105 FluxVariables fluxVars;
106 fluxVars.init(
problem(), element, fvElementGeometry, elemVolVars, scvf, elemFluxVarsCache);
109 for(
auto& data : throatFluxData_)
110 data[eIdx] = throatFluxDataInfo_[dataIdx++].get(fluxVars, elemFluxVarsCache[scvf]);
119 auto clearAndShrink = [] (
auto& data)
122 data.shrink_to_fit();
125 for (
auto& data : throatFluxData_)
126 clearAndShrink(data);
133 std::vector<ThroatFluxDataInfo> throatFluxDataInfo_;
134 std::list<std::vector<Scalar>> throatFluxData_;
GridCache::LocalView localView(const GridCache &gridCache)
Free function to get the local view of a grid cache object.
Definition: localview.hh:38
Definition: discretization/porenetwork/fvelementgeometry.hh:34
Velocity output for implicit (porous media) models.
Definition: io/velocityoutput.hh:41
A VTK output module to simplify writing dumux simulation data to VTK format.
Definition: io/vtkoutputmodule.hh:61
const std::string & paramGroup() const
the parameter group for getting parameter from the parameter tree
Definition: io/vtkoutputmodule.hh:91
void write(double time, Dune::VTK::OutputType type=Dune::VTK::ascii)
Definition: io/vtkoutputmodule.hh:177
const std::string & name() const
Definition: io/vtkoutputmodule.hh:199
bool verbose() const
Definition: io/vtkoutputmodule.hh:198
void addField(const Vector &v, const std::string &name, Vtk::FieldType fieldType=Vtk::FieldType::automatic)
Add a scalar or vector valued vtk field.
Definition: io/vtkoutputmodule.hh:104
A VTK output module to simplify writing dumux simulation data to VTK format.
Definition: io/vtkoutputmodule.hh:312
const auto & problem() const
Definition: io/vtkoutputmodule.hh:395
const GridVariables & gridVariables() const
Definition: io/vtkoutputmodule.hh:396
void addVelocityOutput(std::shared_ptr< VelocityOutputType > velocityOutput)
Add a velocity output policy.
Definition: io/vtkoutputmodule.hh:370
const SolutionVector & sol() const
Definition: io/vtkoutputmodule.hh:398
const GridGeometry & gridGeometry() const
Definition: io/vtkoutputmodule.hh:397
Adds vtk output fields specific to pore-network models.
Definition: pnmvtkoutputmodule.hh:39
void write(double time, Dune::VTK::OutputType type=Dune::VTK::ascii)
Gather and process all required data and write them to a vtk file.
Definition: pnmvtkoutputmodule.hh:77
VtkOutputModule(const GridVariables &gridVariables, const SolutionVector &sol, const std::string &name, const std::string ¶mGroup="", Dune::VTK::DataMode dm=Dune::VTK::conforming, bool verbose=true)
The constructor.
Definition: pnmvtkoutputmodule.hh:49
void addFluxVariable(std::function< Scalar(const FluxVariables &, const FluxVarsCache &)> &&f, const std::string &name)
Definition: pnmvtkoutputmodule.hh:68
const auto & problem() const
Return a reference to the problem.
Definition: pnmvtkoutputmodule.hh:130
A VTK output module to simplify writing dumux simulation data to VTK format.