27#ifndef EWOMS_BASE_OUTPUT_MODULE_HH
28#define EWOMS_BASE_OUTPUT_MODULE_HH
30#include <dune/common/fvector.hh>
32#include <dune/istl/bvector.hh>
50namespace Opm::Properties {
52template <
class TypeTag,
class MyTypeTag>
66template<
class TypeTag>
80 enum { dim = GridView::dimension };
81 enum { dimWorld = GridView::dimensionworld };
82 using Vector = BaseOutputWriter::Vector;
83 using Tensor = BaseOutputWriter::Tensor;
86 using ScalarBuffer = BaseOutputWriter::ScalarBuffer;
87 using VectorBuffer = BaseOutputWriter::VectorBuffer;
88 using TensorBuffer = BaseOutputWriter::TensorBuffer;
90 using EqBuffer = std::array<ScalarBuffer, numEq>;
91 using PhaseBuffer = std::array<ScalarBuffer, numPhases>;
92 using ComponentBuffer = std::array<ScalarBuffer, numComponents>;
93 using PhaseComponentBuffer = std::array<std::array<ScalarBuffer, numComponents>, numPhases>;
95 using PhaseVectorBuffer = std::array<VectorBuffer, numPhases>;
97 BaseOutputModule(
const Simulator& simulator)
98 : simulator_(simulator)
101 virtual ~BaseOutputModule()
159 buffer.resize(this->getBufferSize(bufferType));
160 std::fill(buffer.begin(), buffer.end(), 0.0);
168 buffer.resize(this->getBufferSize(bufferType));
169 const Tensor nullMatrix(dimWorld, dimWorld, 0.0);
170 std::fill(buffer.begin(), buffer.end(), nullMatrix);
173 void resizeVectorBuffer_(VectorBuffer& buffer,
BufferType bufferType)
175 buffer.resize(this->getBufferSize(bufferType));
176 Vector zerovector(dimWorld,0.0);
178 std::fill(buffer.begin(), buffer.end(), zerovector);
187 const std::size_t n = this->getBufferSize(bufferType);
188 for (
unsigned i = 0; i < numEq; ++i) {
190 std::fill(buffer[i].begin(), buffer[i].end(), 0.0);
200 const std::size_t n = this->getBufferSize(bufferType);
201 for (
unsigned i = 0; i < numPhases; ++i) {
203 std::fill(buffer[i].begin(), buffer[i].end(), 0.0);
213 const std::size_t n = this->getBufferSize(bufferType);
214 for (
unsigned i = 0; i < numComponents; ++i) {
216 std::fill(buffer[i].begin(), buffer[i].end(), 0.0);
226 const std::size_t n = this->getBufferSize(bufferType);
227 for (
unsigned i = 0; i < numPhases; ++i) {
228 for (
unsigned j = 0; j < numComponents; ++j) {
229 buffer[i][j].resize(n);
230 std::fill(buffer[i][j].begin(), buffer[i][j].end(), 0.0);
240 ScalarBuffer& buffer,
243 switch (bufferType) {
245 DiscBaseOutputModule::attachScalarDofData_(baseWriter, buffer, name);
248 attachScalarVertexData_(baseWriter, buffer, name);
251 attachScalarElementData_(baseWriter, buffer, name);
253 default:
throw std::logic_error(
"bufferType must be one of Dof, Vertex or Element");
262 VectorBuffer& buffer,
265 switch (bufferType) {
267 DiscBaseOutputModule::attachVectorDofData_(baseWriter, buffer, name);
270 attachVectorVertexData_(baseWriter, buffer, name);
273 attachVectorElementData_(baseWriter, buffer, name);
275 default:
throw std::logic_error(
"bufferType must be one of Dof, Vertex or Element");
284 TensorBuffer& buffer,
287 switch (bufferType) {
289 DiscBaseOutputModule::attachTensorDofData_(baseWriter, buffer, name);
292 attachTensorVertexData_(baseWriter, buffer, name);
295 attachTensorElementData_(baseWriter, buffer, name);
297 default:
throw std::logic_error(
"bufferType must be one of Dof, Vertex or Element");
310 for (
unsigned i = 0; i < numEq; ++i) {
311 const std::string eqName = simulator_.model().primaryVarName(i);
312 snprintf(name, 512, pattern, eqName.c_str());
327 for (
unsigned i = 0; i < numEq; ++i) {
328 snprintf(name, 512, pattern, std::to_string(i).c_str());
343 for (
unsigned i = 0; i < numPhases; ++i) {
344 snprintf(name, 512, pattern, FluidSystem::phaseName(i).data());
355 ComponentBuffer& buffer,
359 for (
unsigned i = 0; i < numComponents; ++i) {
360 snprintf(name, 512, pattern, FluidSystem::componentName(i).data());
371 PhaseComponentBuffer& buffer,
375 for (
unsigned i = 0; i < numPhases; ++i) {
376 for (
unsigned j = 0; j < numComponents; ++j) {
377 snprintf(name, 512, pattern,
378 FluidSystem::phaseName(i).data(),
379 FluidSystem::componentName(j).data());
387 ScalarBuffer& buffer,
391 void attachScalarVertexData_(BaseOutputWriter& baseWriter,
392 ScalarBuffer& buffer,
394 { baseWriter.attachScalarVertexData(buffer, name); }
396 void attachVectorElementData_(BaseOutputWriter& baseWriter,
397 VectorBuffer& buffer,
399 { baseWriter.attachVectorElementData(buffer, name); }
401 void attachVectorVertexData_(BaseOutputWriter& baseWriter,
402 VectorBuffer& buffer,
404 { baseWriter.attachVectorVertexData(buffer, name); }
406 void attachTensorElementData_(BaseOutputWriter& baseWriter,
407 TensorBuffer& buffer,
409 { baseWriter.attachTensorElementData(buffer, name); }
411 void attachTensorVertexData_(BaseOutputWriter& baseWriter,
412 TensorBuffer& buffer,
414 { baseWriter.attachTensorVertexData(buffer, name); }
416 std::size_t getBufferSize(
BufferType bufferType)
const
418 switch (bufferType) {
422 default:
throw std::logic_error(
"bufferType must be one of Dof, Vertex or Element");
426 const Simulator& simulator_;
The base class for all output writers.
Defines a type tags and some fundamental properties all models.
void commitEqBuffer_(BaseOutputWriter &baseWriter, const char *pattern, EqBuffer &buffer, BufferType bufferType)
Add a buffer with as many variables as PDEs to the result file.
Definition baseoutputmodule.hh:321
void commitPhaseComponentBuffer_(BaseOutputWriter &baseWriter, const char *pattern, PhaseComponentBuffer &buffer, BufferType bufferType)
Add a phase and component specific quantities to the output.
Definition baseoutputmodule.hh:369
void resizeScalarBuffer_(ScalarBuffer &buffer, BufferType bufferType)
Allocate the space for a buffer storing a scalar quantity.
Definition baseoutputmodule.hh:157
void commitComponentBuffer_(BaseOutputWriter &baseWriter, const char *pattern, ComponentBuffer &buffer, BufferType bufferType)
Add a component-specific buffer to the result file.
Definition baseoutputmodule.hh:353
virtual bool needExtensiveQuantities() const
Returns true iff the module needs to access the extensive quantities of a context to do its job.
Definition baseoutputmodule.hh:139
void resizeEqBuffer_(EqBuffer &buffer, BufferType bufferType)
Allocate the space for a buffer storing a equation specific quantity.
Definition baseoutputmodule.hh:185
void commitVectorBuffer_(BaseOutputWriter &baseWriter, const char *name, VectorBuffer &buffer, BufferType bufferType)
Add a buffer containing vectorial quantities to the result file.
Definition baseoutputmodule.hh:260
void commitPriVarsBuffer_(BaseOutputWriter &baseWriter, const char *pattern, EqBuffer &buffer, BufferType bufferType)
Add a buffer with as many variables as PDEs to the result file.
Definition baseoutputmodule.hh:304
BufferType
Definition baseoutputmodule.hh:143
@ Element
Buffer contains data associated with the grid's elements.
Definition baseoutputmodule.hh:151
@ Dof
Buffer contains data associated with the degrees of freedom.
Definition baseoutputmodule.hh:145
@ Vertex
Buffer contains data associated with the grid's vertices.
Definition baseoutputmodule.hh:148
void commitTensorBuffer_(BaseOutputWriter &baseWriter, const char *name, TensorBuffer &buffer, BufferType bufferType)
Add a buffer containing tensorial quantities to the result file.
Definition baseoutputmodule.hh:282
virtual void processElement(const ElementContext &elemCtx)=0
Modify the internal buffers according to the intensive quanties relevant for an element.
void resizePhaseComponentBuffer_(PhaseComponentBuffer &buffer, BufferType bufferType)
Allocate the space for a buffer storing a phase and component specific buffer.
Definition baseoutputmodule.hh:224
void resizeTensorBuffer_(TensorBuffer &buffer, BufferType bufferType)
Allocate the space for a buffer storing a tensorial quantity.
Definition baseoutputmodule.hh:166
void commitPhaseBuffer_(BaseOutputWriter &baseWriter, const char *pattern, PhaseBuffer &buffer, BufferType bufferType)
Add a phase-specific buffer to the result file.
Definition baseoutputmodule.hh:337
virtual void commitBuffers(BaseOutputWriter &writer)=0
Add all buffers to the VTK output writer.
void commitScalarBuffer_(BaseOutputWriter &baseWriter, const char *name, ScalarBuffer &buffer, BufferType bufferType)
Add a buffer containing scalar quantities to the result file.
Definition baseoutputmodule.hh:238
virtual void allocBuffers()=0
Allocate memory for the scalar fields we would like to write to disk.
void resizeComponentBuffer_(ComponentBuffer &buffer, BufferType bufferType)
Allocate the space for a buffer storing a component specific quantity.
Definition baseoutputmodule.hh:211
void resizePhaseBuffer_(PhaseBuffer &buffer, BufferType bufferType)
Allocate the space for a buffer storing a phase-specific quantity.
Definition baseoutputmodule.hh:198
The base class for all output writers.
Definition baseoutputwriter.hh:46
virtual void attachScalarElementData(ScalarBuffer &buf, std::string_view name)=0
Add a scalar element centered quantity to the output.
Declare the properties used by the infrastructure code of the finite volume discretizations.
Defines the common properties required by the porous medium multi-phase models.
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilbioeffectsmodules.hh:43
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property (equivalent to old macro GET_PROP_TYPE(....
Definition propertysystem.hh:233
constexpr auto getPropValue()
get the value data member of a property
Definition propertysystem.hh:240
This file provides the infrastructure to retrieve run-time parameters.
The Opm property system, traits with inheritance.
The fluid systems including the information about the phases.
Definition multiphasebaseproperties.hh:79