27 #ifndef EWOMS_BASE_OUTPUT_MODULE_HH 28 #define EWOMS_BASE_OUTPUT_MODULE_HH 36 #include <opm/common/ErrorMacros.hpp> 37 #include <opm/common/Exceptions.hpp> 39 #include <dune/istl/bvector.hh> 40 #include <dune/common/fvector.hh> 50 namespace Properties {
66 #if __GNUC__ || __clang__ 67 #pragma GCC diagnostic push 68 #pragma GCC diagnostic ignored "-Wpragmas" 69 #pragma GCC diagnostic ignored "-Wformat-nonliteral" 79 template<
class TypeTag>
83 typedef typename GET_PROP_TYPE(TypeTag, Model) Model;
84 typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
85 typedef typename GET_PROP_TYPE(TypeTag, GridView) GridView;
86 typedef typename GET_PROP_TYPE(TypeTag, ElementContext) ElementContext;
87 typedef typename GET_PROP_TYPE(TypeTag, FluidSystem) FluidSystem;
88 typedef typename GET_PROP_TYPE(TypeTag, DiscBaseOutputModule) DiscBaseOutputModule;
93 enum { dim = GridView::dimension };
94 enum { dimWorld = GridView::dimensionworld };
96 typedef BaseOutputWriter::Tensor Tensor;
99 typedef BaseOutputWriter::ScalarBuffer ScalarBuffer;
100 typedef BaseOutputWriter::VectorBuffer VectorBuffer;
101 typedef BaseOutputWriter::TensorBuffer TensorBuffer;
103 typedef std::array<ScalarBuffer, numEq> EqBuffer;
104 typedef std::array<ScalarBuffer, numPhases> PhaseBuffer;
105 typedef std::array<ScalarBuffer, numComponents> ComponentBuffer;
106 typedef std::array<std::array<ScalarBuffer, numComponents>, numPhases> PhaseComponentBuffer;
108 typedef std::array<VectorBuffer, numPhases> PhaseVectorBuffer;
111 : simulator_(simulator)
175 n =
static_cast<size_t>(simulator_.
gridView().size(dim));
177 n =
static_cast<size_t>(simulator_.
gridView().size(0));
179 n = simulator_.
model().numGridDof();
181 OPM_THROW(std::logic_error,
"bufferType must be one of Dof, Vertex or Element");
184 std::fill(buffer.begin(), buffer.end(), 0.0);
195 n =
static_cast<size_t>(simulator_.
gridView().size(dim));
197 n =
static_cast<size_t>(simulator_.
gridView().size(0));
199 n = simulator_.
model().numGridDof();
201 OPM_THROW(std::logic_error,
"bufferType must be one of Dof, Vertex or Element");
204 Tensor nullMatrix(dimWorld, dimWorld, 0.0);
205 std::fill(buffer.begin(), buffer.end(), nullMatrix);
217 n =
static_cast<size_t>(simulator_.
gridView().size(dim));
219 n =
static_cast<size_t>(simulator_.
gridView().size(0));
221 n = simulator_.
model().numGridDof();
223 OPM_THROW(std::logic_error,
"bufferType must be one of Dof, Vertex or Element");
225 for (
unsigned i = 0; i < numEq; ++i) {
227 std::fill(buffer[i].begin(), buffer[i].end(), 0.0);
240 n =
static_cast<size_t>(simulator_.
gridView().size(dim));
242 n =
static_cast<size_t>(simulator_.
gridView().size(0));
244 n = simulator_.
model().numGridDof();
246 OPM_THROW(std::logic_error,
"bufferType must be one of Dof, Vertex or Element");
248 for (
unsigned i = 0; i < numPhases; ++i) {
250 std::fill(buffer[i].begin(), buffer[i].end(), 0.0);
263 n =
static_cast<size_t>(simulator_.
gridView().size(dim));
265 n =
static_cast<size_t>(simulator_.
gridView().size(0));
267 n = simulator_.
model().numGridDof();
269 OPM_THROW(std::logic_error,
"bufferType must be one of Dof, Vertex or Element");
271 for (
unsigned i = 0; i < numComponents; ++i) {
273 std::fill(buffer[i].begin(), buffer[i].end(), 0.0);
286 n =
static_cast<size_t>(simulator_.
gridView().size(dim));
288 n =
static_cast<size_t>(simulator_.
gridView().size(0));
290 n = simulator_.
model().numGridDof();
292 OPM_THROW(std::logic_error,
"bufferType must be one of Dof, Vertex or Element");
294 for (
unsigned i = 0; i < numPhases; ++i) {
295 for (
unsigned j = 0; j < numComponents; ++j) {
296 buffer[i][j].resize(n);
297 std::fill(buffer[i][j].begin(), buffer[i][j].end(), 0.0);
307 ScalarBuffer& buffer,
311 DiscBaseOutputModule::attachScalarDofData_(baseWriter, buffer, name);
313 attachScalarVertexData_(baseWriter, buffer, name);
315 attachScalarElementData_(baseWriter, buffer, name);
317 OPM_THROW(std::logic_error,
"bufferType must be one of Dof, Vertex or Element");
325 VectorBuffer& buffer,
329 DiscBaseOutputModule::attachVectorDofData_(baseWriter, buffer, name);
331 attachVectorVertexData_(baseWriter, buffer, name);
333 attachVectorElementData_(baseWriter, buffer, name);
335 OPM_THROW(std::logic_error,
"bufferType must be one of Dof, Vertex or Element");
343 TensorBuffer& buffer,
347 DiscBaseOutputModule::attachTensorDofData_(baseWriter, buffer, name);
349 attachTensorVertexData_(baseWriter, buffer, name);
351 attachTensorElementData_(baseWriter, buffer, name);
353 OPM_THROW(std::logic_error,
"bufferType must be one of Dof, Vertex or Element");
365 for (
unsigned i = 0; i < numEq; ++i) {
366 std::string eqName = simulator_.
model().primaryVarName(i);
367 snprintf(name, 512, pattern, eqName.c_str());
370 DiscBaseOutputModule::attachScalarDofData_(baseWriter, buffer[i], name);
372 attachScalarVertexData_(baseWriter, buffer[i], name);
374 attachScalarElementData_(baseWriter, buffer[i], name);
376 OPM_THROW(std::logic_error,
"bufferType must be one of Dof, Vertex or Element");
389 for (
unsigned i = 0; i < numEq; ++i) {
390 std::ostringstream oss;
392 snprintf(name, 512, pattern, oss.str().c_str());
395 DiscBaseOutputModule::attachScalarDofData_(baseWriter, buffer[i], name);
397 attachScalarVertexData_(baseWriter, buffer[i], name);
399 attachScalarElementData_(baseWriter, buffer[i], name);
401 OPM_THROW(std::logic_error,
"bufferType must be one of Dof, Vertex or Element");
414 for (
unsigned i = 0; i < numPhases; ++i) {
415 snprintf(name, 512, pattern, FluidSystem::phaseName(i));
418 DiscBaseOutputModule::attachScalarDofData_(baseWriter, buffer[i], name);
420 attachScalarVertexData_(baseWriter, buffer[i], name);
422 attachScalarElementData_(baseWriter, buffer[i], name);
424 OPM_THROW(std::logic_error,
"bufferType must be one of Dof, Vertex or Element");
433 ComponentBuffer& buffer,
437 for (
unsigned i = 0; i < numComponents; ++i) {
438 snprintf(name, 512, pattern, FluidSystem::componentName(i));
441 DiscBaseOutputModule::attachScalarDofData_(baseWriter, buffer[i], name);
443 attachScalarVertexData_(baseWriter, buffer[i], name);
445 attachScalarElementData_(baseWriter, buffer[i], name);
447 OPM_THROW(std::logic_error,
"bufferType must be one of Dof, Vertex or Element");
456 PhaseComponentBuffer& buffer,
460 for (
unsigned i= 0; i < numPhases; ++i) {
461 for (
unsigned j = 0; j < numComponents; ++j) {
462 snprintf(name, 512, pattern,
463 FluidSystem::phaseName(i),
464 FluidSystem::componentName(j));
467 DiscBaseOutputModule::attachScalarDofData_(baseWriter, buffer[i][j], name);
469 attachScalarVertexData_(baseWriter, buffer[i][j], name);
471 attachScalarElementData_(baseWriter, buffer[i][j], name);
473 OPM_THROW(std::logic_error,
474 "bufferType must be one of Dof, Vertex or Element");
480 ScalarBuffer& buffer,
484 void attachScalarVertexData_(BaseOutputWriter& baseWriter,
485 ScalarBuffer& buffer,
487 { baseWriter.attachScalarVertexData(buffer, name); }
489 void attachVectorElementData_(BaseOutputWriter& baseWriter,
490 VectorBuffer& buffer,
492 { baseWriter.attachVectorElementData(buffer, name); }
494 void attachVectorVertexData_(BaseOutputWriter& baseWriter,
495 VectorBuffer& buffer,
497 { baseWriter.attachVectorVertexData(buffer, name); }
499 void attachTensorElementData_(BaseOutputWriter& baseWriter,
500 TensorBuffer& buffer,
502 { baseWriter.attachTensorElementData(buffer, name); }
504 void attachTensorVertexData_(BaseOutputWriter& baseWriter,
505 TensorBuffer& buffer,
507 { baseWriter.attachTensorVertexData(buffer, name); }
509 const Simulator& simulator_;
512 #if __GNUC__ || __clang__ 513 #pragma GCC diagnostic pop virtual void allocBuffers()=0
Allocate memory for the scalar fields we would like to write to disk.
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:383
The base class for all output writers.
Definition: baseoutputwriter.hh:43
Definition: baseauxiliarymodule.hh:37
Model & model()
Return the physical model used in the simulation.
Definition: simulator.hh:189
void commitPhaseBuffer_(BaseOutputWriter &baseWriter, const char *pattern, PhaseBuffer &buffer, BufferType bufferType=DofBuffer)
Add a phase-specific buffer to the result file.
Definition: baseoutputmodule.hh:408
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:323
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:305
#define GET_PROP_VALUE(TypeTag, PropTagName)
Access the value attribute of a property for a type tag.
Definition: propertysystem.hh:469
virtual void processElement(const ElementContext &elemCtx)=0
Modify the internal buffers according to the intensive quanties relevant for an element.
Buffer contains data associated with the degrees of freedom.
Definition: baseoutputmodule.hh:158
void resizeTensorBuffer_(TensorBuffer &buffer, BufferType bufferType=DofBuffer)
Allocate the space for a buffer storing a tensorial quantity.
Definition: baseoutputmodule.hh:190
virtual void attachScalarElementData(ScalarBuffer &buf, std::string name)=0
Add a scalar element centered quantity to the output.
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:341
BufferType
Definition: baseoutputmodule.hh:156
virtual void commitBuffers(BaseOutputWriter &writer)=0
Add all buffers to the VTK output writer.
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:359
Buffer contains data associated with the grid's vertices.
Definition: baseoutputmodule.hh:161
Buffer contains data associated with the grid's elements.
Definition: baseoutputmodule.hh:164
void resizeEqBuffer_(EqBuffer &buffer, BufferType bufferType=DofBuffer)
Allocate the space for a buffer storing a equation specific quantity.
Definition: baseoutputmodule.hh:212
This file provides the infrastructure to retrieve run-time parameters.
void resizeComponentBuffer_(ComponentBuffer &buffer, BufferType bufferType=DofBuffer)
Allocate the space for a buffer storing a component specific quantity.
Definition: baseoutputmodule.hh:258
The base class for writer modules.
Definition: baseoutputmodule.hh:80
void resizePhaseComponentBuffer_(PhaseComponentBuffer &buffer, BufferType bufferType=DofBuffer)
Allocate the space for a buffer storing a phase and component specific buffer.
Definition: baseoutputmodule.hh:281
const GridView & gridView() const
Return the grid view for which the simulation is done.
Definition: simulator.hh:183
void commitComponentBuffer_(BaseOutputWriter &baseWriter, const char *pattern, ComponentBuffer &buffer, BufferType bufferType=DofBuffer)
Add a component-specific buffer to the result file.
Definition: baseoutputmodule.hh:431
The base class for all output writers.
void resizePhaseBuffer_(PhaseBuffer &buffer, BufferType bufferType=DofBuffer)
Allocate the space for a buffer storing a phase-specific quantity.
Definition: baseoutputmodule.hh:235
Provides the magic behind the eWoms property system.
void resizeScalarBuffer_(ScalarBuffer &buffer, BufferType bufferType=DofBuffer)
Allocate the space for a buffer storing a scalar quantity.
Definition: baseoutputmodule.hh:170
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:152
Manages the initializing and running of time dependent problems.
Definition: simulator.hh:75
#define NEW_PROP_TAG(PTagName)
Define a property tag.
Definition: propertysystem.hh:247
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:454