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>
49namespace Opm::Properties {
51template <
class TypeTag,
class MyTypeTag>
65template<
class TypeTag>
79 enum { dim = GridView::dimension };
80 enum { dimWorld = GridView::dimensionworld };
81 using Vector = BaseOutputWriter::Vector;
82 using Tensor = BaseOutputWriter::Tensor;
85 using ScalarBuffer = BaseOutputWriter::ScalarBuffer;
86 using VectorBuffer = BaseOutputWriter::VectorBuffer;
87 using TensorBuffer = BaseOutputWriter::TensorBuffer;
89 using EqBuffer = std::array<ScalarBuffer, numEq>;
90 using PhaseBuffer = std::array<ScalarBuffer, numPhases>;
91 using ComponentBuffer = std::array<ScalarBuffer, numComponents>;
92 using PhaseComponentBuffer = std::array<std::array<ScalarBuffer, numComponents>, numPhases>;
94 using PhaseVectorBuffer = std::array<VectorBuffer, numPhases>;
97 : simulator_(simulator)
159 buffer.resize(this->getBufferSize(bufferType));
160 std::fill(buffer.begin(), buffer.end(), 0.0);
169 buffer.resize(this->getBufferSize(bufferType));
170 Tensor nullMatrix(dimWorld, dimWorld, 0.0);
171 std::fill(buffer.begin(), buffer.end(), nullMatrix);
174 void resizeVectorBuffer_(VectorBuffer& buffer,
177 buffer.resize(this->getBufferSize(bufferType));
178 Vector zerovector(dimWorld,0.0);
180 std::fill(buffer.begin(), buffer.end(), zerovector);
190 const std::size_t n = this->getBufferSize(bufferType);
191 for (
unsigned i = 0; i < numEq; ++i) {
193 std::fill(buffer[i].begin(), buffer[i].end(), 0.0);
204 const std::size_t n = this->getBufferSize(bufferType);
205 for (
unsigned i = 0; i < numPhases; ++i) {
207 std::fill(buffer[i].begin(), buffer[i].end(), 0.0);
218 const std::size_t n = this->getBufferSize(bufferType);
219 for (
unsigned i = 0; i < numComponents; ++i) {
221 std::fill(buffer[i].begin(), buffer[i].end(), 0.0);
232 const std::size_t n = this->getBufferSize(bufferType);
233 for (
unsigned i = 0; i < numPhases; ++i) {
234 for (
unsigned j = 0; j < numComponents; ++j) {
235 buffer[i][j].resize(n);
236 std::fill(buffer[i][j].begin(), buffer[i][j].end(), 0.0);
246 ScalarBuffer& buffer,
249 switch (bufferType) {
251 DiscBaseOutputModule::attachScalarDofData_(baseWriter, buffer, name);
254 attachScalarVertexData_(baseWriter, buffer, name);
257 attachScalarElementData_(baseWriter, buffer, name);
259 default:
throw std::logic_error(
"bufferType must be one of Dof, Vertex or Element");
268 VectorBuffer& buffer,
271 switch (bufferType) {
273 DiscBaseOutputModule::attachVectorDofData_(baseWriter, buffer, name);
276 attachVectorVertexData_(baseWriter, buffer, name);
279 attachVectorElementData_(baseWriter, buffer, name);
281 default:
throw std::logic_error(
"bufferType must be one of Dof, Vertex or Element");
290 TensorBuffer& buffer,
293 switch (bufferType) {
295 DiscBaseOutputModule::attachTensorDofData_(baseWriter, buffer, name);
298 attachTensorVertexData_(baseWriter, buffer, name);
301 attachTensorElementData_(baseWriter, buffer, name);
303 default:
throw std::logic_error(
"bufferType must be one of Dof, Vertex or Element");
316 for (
unsigned i = 0; i < numEq; ++i) {
317 std::string eqName = simulator_.model().primaryVarName(i);
318 snprintf(name, 512, pattern, eqName.c_str());
333 for (
unsigned i = 0; i < numEq; ++i) {
334 std::ostringstream oss;
336 snprintf(name, 512, pattern, oss.str().c_str());
338 this->commitScalarBuffer(baseWriter, name, buffer[i], bufferType);
351 for (
unsigned i = 0; i < numPhases; ++i) {
352 snprintf(name, 512, pattern, FluidSystem::phaseName(i).data());
363 ComponentBuffer& buffer,
367 for (
unsigned i = 0; i < numComponents; ++i) {
368 snprintf(name, 512, pattern, FluidSystem::componentName(i).data());
379 PhaseComponentBuffer& buffer,
383 for (
unsigned i= 0; i < numPhases; ++i) {
384 for (
unsigned j = 0; j < numComponents; ++j) {
385 snprintf(name, 512, pattern,
386 FluidSystem::phaseName(i).data(),
387 FluidSystem::componentName(j).data());
395 ScalarBuffer& buffer,
399 void attachScalarVertexData_(BaseOutputWriter& baseWriter,
400 ScalarBuffer& buffer,
402 { baseWriter.attachScalarVertexData(buffer, name); }
404 void attachVectorElementData_(BaseOutputWriter& baseWriter,
405 VectorBuffer& buffer,
407 { baseWriter.attachVectorElementData(buffer, name); }
409 void attachVectorVertexData_(BaseOutputWriter& baseWriter,
410 VectorBuffer& buffer,
412 { baseWriter.attachVectorVertexData(buffer, name); }
414 void attachTensorElementData_(BaseOutputWriter& baseWriter,
415 TensorBuffer& buffer,
417 { baseWriter.attachTensorElementData(buffer, name); }
419 void attachTensorVertexData_(BaseOutputWriter& baseWriter,
420 TensorBuffer& buffer,
422 { baseWriter.attachTensorVertexData(buffer, name); }
424 std::size_t getBufferSize(
BufferType bufferType)
const
426 switch (bufferType) {
427 case VertexBuffer:
return simulator_.gridView().size(dim);
429 case DofBuffer:
return simulator_.model().numGridDof();
430 default:
throw std::logic_error(
"bufferType must be one of Dof, Vertex or Element");
434 const Simulator& simulator_;
The base class for all output writers.
Defines a type tags and some fundamental properties all models.
The base class for writer modules.
Definition baseoutputmodule.hh:67
void commitPhaseBuffer_(BaseOutputWriter &baseWriter, const char *pattern, PhaseBuffer &buffer, BufferType bufferType=DofBuffer)
Add a phase-specific buffer to the result file.
Definition baseoutputmodule.hh:345
void resizePhaseBuffer_(PhaseBuffer &buffer, BufferType bufferType=DofBuffer)
Allocate the space for a buffer storing a phase-specific quantity.
Definition baseoutputmodule.hh:201
void commitComponentBuffer_(BaseOutputWriter &baseWriter, const char *pattern, ComponentBuffer &buffer, BufferType bufferType=DofBuffer)
Add a component-specific buffer to the result file.
Definition baseoutputmodule.hh:361
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:138
void commitTensorBuffer_(BaseOutputWriter &baseWriter, const char *name, TensorBuffer &buffer, BufferType bufferType=DofBuffer)
Add a buffer containing tensorial quantities to the result file.
Definition baseoutputmodule.hh:288
void resizeComponentBuffer_(ComponentBuffer &buffer, BufferType bufferType=DofBuffer)
Allocate the space for a buffer storing a component specific quantity.
Definition baseoutputmodule.hh:215
void commitEqBuffer_(BaseOutputWriter &baseWriter, const char *pattern, EqBuffer &buffer, BufferType bufferType=DofBuffer)
Add a buffer with as many variables as PDEs to the result file.
Definition baseoutputmodule.hh:327
void resizePhaseComponentBuffer_(PhaseComponentBuffer &buffer, BufferType bufferType=DofBuffer)
Allocate the space for a buffer storing a phase and component specific buffer.
Definition baseoutputmodule.hh:229
BufferType
Definition baseoutputmodule.hh:142
@ DofBuffer
Buffer contains data associated with the degrees of freedom.
Definition baseoutputmodule.hh:144
@ VertexBuffer
Buffer contains data associated with the grid's vertices.
Definition baseoutputmodule.hh:147
@ ElementBuffer
Buffer contains data associated with the grid's elements.
Definition baseoutputmodule.hh:150
void commitPriVarsBuffer_(BaseOutputWriter &baseWriter, const char *pattern, EqBuffer &buffer, BufferType bufferType=DofBuffer)
Add a buffer with as many variables as PDEs to the result file.
Definition baseoutputmodule.hh:310
void resizeEqBuffer_(EqBuffer &buffer, BufferType bufferType=DofBuffer)
Allocate the space for a buffer storing a equation specific quantity.
Definition baseoutputmodule.hh:187
void commitPhaseComponentBuffer_(BaseOutputWriter &baseWriter, const char *pattern, PhaseComponentBuffer &buffer, BufferType bufferType=DofBuffer)
Add a phase and component specific quantities to the output.
Definition baseoutputmodule.hh:377
virtual void processElement(const ElementContext &elemCtx)=0
Modify the internal buffers according to the intensive quanties relevant for an element.
void resizeTensorBuffer_(TensorBuffer &buffer, BufferType bufferType=DofBuffer)
Allocate the space for a buffer storing a tensorial quantity.
Definition baseoutputmodule.hh:166
virtual void commitBuffers(BaseOutputWriter &writer)=0
Add all buffers to the VTK output writer.
void commitVectorBuffer_(BaseOutputWriter &baseWriter, const char *name, VectorBuffer &buffer, BufferType bufferType=DofBuffer)
Add a buffer containing vectorial quantities to the result file.
Definition baseoutputmodule.hh:266
virtual void allocBuffers()=0
Allocate memory for the scalar fields we would like to write to disk.
void commitScalarBuffer_(BaseOutputWriter &baseWriter, const char *name, ScalarBuffer &buffer, BufferType bufferType=DofBuffer)
Add a buffer containing scalar quantities to the result file.
Definition baseoutputmodule.hh:244
void resizeScalarBuffer_(ScalarBuffer &buffer, BufferType bufferType=DofBuffer)
Allocate the space for a buffer storing a scalar quantity.
Definition baseoutputmodule.hh:156
The base class for all output writers.
Definition baseoutputwriter.hh:44
virtual void attachScalarElementData(ScalarBuffer &buf, std::string 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 blackoilboundaryratevector.hh:37
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:235
constexpr auto getPropValue()
get the value data member of a property
Definition propertysystem.hh:242
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 baseoutputmodule.hh:52