Flow123d  master-94c4283
darcy_flow_mh_output.hh
Go to the documentation of this file.
1 /*!
2  *
3  * Copyright (C) 2015 Technical University of Liberec. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU General Public License version 3 as published by the
7  * Free Software Foundation. (http://www.gnu.org/licenses/gpl-3.0.en.html)
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12  *
13  *
14  * @file darcy_flow_mh_output.hh
15  * @brief Output class for darcy_flow_mh model.
16  * @author Jan Brezina
17  */
18 
19 #ifndef DARCY_FLOW_MH_OUTPUT_HH_
20 #define DARCY_FLOW_MH_OUTPUT_HH_
21 
22 #include <stdio.h> // for sprintf
23 #include <string.h> // for memcpy
24 
25 #include <cmath> // for pow
26 #include <iosfwd> // for ofstream
27 #include <memory> // for shared_ptr
28 #include <vector> // for vector
29 #include <armadillo>
30 #include "fields/equation_output.hh" // for EquationOutput
31 #include "fields/field.hh" // for Field
32 #include "fields/field_set.hh" // for FieldSet
33 #include "fields/field_values.hh" // for FieldValue<>::Scalar, FieldV...
34 #include "fields/field_python.hh"
35 #include "la/vector_mpi.hh" // for VectorMPI
36 #include "input/type_base.hh" // for Array
37 #include "input/type_generic.hh" // for Instance
38 #include "petscvec.h" // for Vec, _p_Vec
39 #include "system/exceptions.hh" // for ExcAssertMsg::~ExcAssertMsg
40 
41 class DOFHandlerMultiDim;
42 class DarcyLMH;
43 class Mesh;
44 class OutputTime;
45 namespace Input {
46  class Record;
47  namespace Type {
48  class Record;
49  }
50 }
51 
52 template<unsigned int spacedim> class FEValues;
53 template <int spacedim, class Value> class FieldFE;
54 template<unsigned int dim> class L2DifferenceAssembly;
55 template<unsigned int dim> class OutputInternalFlowAssembly;
56 template< template<IntDim...> class DimAssembly> class GenericAssembly;
57 
58 /**
59  * Actually this class only collect former code from postprocess.*
60  * This code depends on values stored in mesh and has to be changed to use fields or other data provided by
61  * interface to darcy_flow. We have to relay on the interface in order to allow different implementation of darcy_flow.
62  *
63  * Principal functionalities of current postprocess are:
64  * - move computed values into mesh - this can be removed after we get new output classes,
65  * other dependent code can use directly field interface
66  * - compute interpolation to nodes - this can be external and operate directly on fields
67  * - compute water balances over materials and boundary parts - is feasible through field interface
68  *
69  * Further functionality of this class should be:
70  * - prepare data for general output classes
71  *
72  */
74 public:
75 
76  /// Standard quantities for output in DarcyFlowMH.
77  class OutputFields : public EquationOutput {
78  public:
79 
80  OutputFields();
81 
84  };
85 
86  /// Specific quantities for output in DarcyFlowMH - error estimates etc.
88  public:
90 
94  };
95 
96  /// Output specific field stuff
97  class DiffEqData {
98  public:
100 
103 
104  // Temporary objects holding pointers to appropriate FieldFE
105  // TODO remove after final fix of equations
106  std::shared_ptr<FieldFE<3, FieldValue<3>::Scalar>> pressure_diff_ptr;
107  std::shared_ptr<FieldFE<3, FieldValue<3>::Scalar>> vel_diff_ptr;
108  std::shared_ptr<FieldFE<3, FieldValue<3>::Scalar>> div_diff_ptr;
109 
110  std::shared_ptr<SubDOFHandlerMultiDim> dh_;
111 
113  std::shared_ptr<DarcyLMH::EqData> flow_data_;
114  };
115 
117  public:
119 
120  ofstream raw_output_file; ///< Raw data output file.
121  std::vector< std::string > raw_output_strings_; ///< Output lines of cells.
122  TimeGovernor *time_; ///< Time is shared with flow equation.
123 
124  std::shared_ptr<DarcyLMH::EqData> flow_data_;
125  };
126 
128  virtual ~DarcyFlowMHOutput();
129 
130  static const Input::Type::Instance & get_input_type(FieldSet& eq_data, const std::string &equation_name);
132 
133  /** \brief Calculate values for output. **/
134  void output();
135 
136  //const OutputFields &get_output_fields() { return output_fields; }
137 
138 
139 
140 protected:
142 
143  virtual void prepare_output(Input::Record in_rec);
146 
147  template <class FieldType>
148  void set_ref_solution(const Input::Record &rec, Field<3, FieldType> &output_field, std::vector<std::string> reg);
149 
150 
153 
154  /// Specific experimental error computing.
156 
157 
158  /** Pressure head (in [m]) interpolated into nodes. Provides P1 approximation. Indexed by element-node numbering.*/
160  /** Pressure head (in [m]) in barycenters of elements (or equivalently mean pressure over every element). Indexed by element indexes in the mesh.*/
162  /** Piezo-metric head (in [m]) in barycenter of elements (or equivalently mean pressure over every element). Indexed by element indexes in the mesh.*/
164 
165  // integrals of squared differences on individual elements - error indicators, can be written out into VTK files
167 
168  std::shared_ptr<DOFHandlerMultiDim> dh_;
169  std::shared_ptr<DiscreteSpace> ds;
170 
173 
174  std::shared_ptr<OutputTime> output_stream;
175 
176  /// Output specific field stuff
178  std::shared_ptr<DarcyLMH::EqFields> flow_eq_fields_;
179  std::shared_ptr<DiffEqData> diff_eq_data_;
180  std::shared_ptr<RawOutputEqData> raw_eq_data_;
181 
182  //MixedPtr<FE_P_disc> fe_p0;
183 
184  /// general assembly objects, hold assembly objects of appropriate dimension
187 
188 };
189 
190 
191 #endif /* DARCY_FLOW_MH_OUTPUT_HH_ */
192 
DarcyFlowMHOutput::set_specific_output_python_fields
void set_specific_output_python_fields()
Definition: darcy_flow_mh_output.cc:259
DarcyFlowMHOutput::OutputSpecificFields::OutputSpecificFields
OutputSpecificFields()
Definition: darcy_flow_mh_output.cc:109
DarcyFlowMHOutput::l2_diff_pressure
std::vector< double > l2_diff_pressure
Definition: darcy_flow_mh_output.hh:166
DarcyFlowMHOutput::prepare_specific_output
void prepare_specific_output(Input::Record in_rec)
Definition: darcy_flow_mh_output.cc:206
DarcyFlowMHOutput::DiffEqData::flow_data_
std::shared_ptr< DarcyLMH::EqData > flow_data_
Definition: darcy_flow_mh_output.hh:113
DarcyFlowMHOutput::DiffEqData::dh_
std::shared_ptr< SubDOFHandlerMultiDim > dh_
Definition: darcy_flow_mh_output.hh:110
L2DifferenceAssembly
Definition: assembly_flow_output.hh:54
DarcyFlowMHOutput::l2_diff_velocity
std::vector< double > l2_diff_velocity
Definition: darcy_flow_mh_output.hh:166
DarcyFlowMHOutput::output
void output()
Calculate values for output.
Definition: darcy_flow_mh_output.cc:320
DarcyFlowMHOutput::DiffEqData::pressure_error
double pressure_error[3]
Definition: darcy_flow_mh_output.hh:101
vector_mpi.hh
DarcyFlowMHOutput::DiffEqData::vel_diff_ptr
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::Scalar > > vel_diff_ptr
Definition: darcy_flow_mh_output.hh:107
DarcyFlowMHOutput::output_internal_assembly_
GenericAssembly< OutputInternalFlowAssembly > * output_internal_assembly_
Definition: darcy_flow_mh_output.hh:186
field_python.hh
Input
Abstract linear system class.
Definition: balance.hh:40
DarcyFlowMHOutput::DiffEqData::velocity_mask
std::vector< int > velocity_mask
Definition: darcy_flow_mh_output.hh:112
DarcyFlowMHOutput::is_output_specific_fields
bool is_output_specific_fields
Output specific field stuff.
Definition: darcy_flow_mh_output.hh:177
DarcyFlowMHOutput::output_specific_fields
OutputSpecificFields output_specific_fields
Definition: darcy_flow_mh_output.hh:172
DarcyFlowMHOutput::DarcyFlowMHOutput
DarcyFlowMHOutput(DarcyLMH *flow, Input::Record in_rec)
Definition: darcy_flow_mh_output.cc:123
string.h
DarcyFlowMHOutput::prepare_output
virtual void prepare_output(Input::Record in_rec)
Definition: darcy_flow_mh_output.cc:181
DarcyFlowMHOutput::ElementSetRef
const typedef vector< unsigned int > & ElementSetRef
Definition: darcy_flow_mh_output.hh:141
field_set.hh
std::vector< int >
DarcyFlowMHOutput::mesh_
Mesh * mesh_
Definition: darcy_flow_mh_output.hh:152
DarcyFlowMHOutput::raw_eq_data_
std::shared_ptr< RawOutputEqData > raw_eq_data_
Definition: darcy_flow_mh_output.hh:180
DarcyFlowMHOutput::corner_pressure
VectorMPI corner_pressure
Definition: darcy_flow_mh_output.hh:159
type_base.hh
DarcyFlowMHOutput::output_stream
std::shared_ptr< OutputTime > output_stream
Definition: darcy_flow_mh_output.hh:174
flow
Definition: output_msh.hh:24
exceptions.hh
DarcyFlowMHOutput::OutputSpecificFields::pressure_diff
Field< 3, FieldValue< 3 >::Scalar > pressure_diff
Definition: darcy_flow_mh_output.hh:92
DarcyFlowMHOutput::OutputFields
Standard quantities for output in DarcyFlowMH.
Definition: darcy_flow_mh_output.hh:77
DarcyFlowMHOutput::dh_
std::shared_ptr< DOFHandlerMultiDim > dh_
Definition: darcy_flow_mh_output.hh:168
DarcyFlowMHOutput::OutputFields::region_id
Field< 3, FieldValue< 3 >::Scalar > region_id
Definition: darcy_flow_mh_output.hh:83
FEValues
Calculates finite element data on the actual cell.
Definition: fe_values.hh:66
DarcyFlowMHOutput::get_input_type
static const Input::Type::Instance & get_input_type(FieldSet &eq_data, const std::string &equation_name)
Definition: darcy_flow_mh_output.cc:58
equation_output.hh
DarcyFlowMHOutput::DiffEqData::mask_vel_error
double mask_vel_error
Definition: darcy_flow_mh_output.hh:102
DarcyFlowMHOutput::ds
std::shared_ptr< DiscreteSpace > ds
Definition: darcy_flow_mh_output.hh:169
DarcyFlowMHOutput::l2_diff_divergence
std::vector< double > l2_diff_divergence
Definition: darcy_flow_mh_output.hh:166
DarcyFlowMHOutput::diff_eq_data_
std::shared_ptr< DiffEqData > diff_eq_data_
Definition: darcy_flow_mh_output.hh:179
DarcyFlowMHOutput::output_fields
OutputFields output_fields
Definition: darcy_flow_mh_output.hh:171
Input::Record
Accessor to the data with type Type::Record.
Definition: accessors.hh:291
DarcyFlowMHOutput::OutputSpecificFields
Specific quantities for output in DarcyFlowMH - error estimates etc.
Definition: darcy_flow_mh_output.hh:87
type_generic.hh
DOFHandlerMultiDim
Provides the numbering of the finite element degrees of freedom on the computational mesh.
Definition: dofhandler.hh:151
EquationOutput
Definition: equation_output.hh:46
DarcyFlowMHOutput::OutputSpecificFields::velocity_diff
Field< 3, FieldValue< 3 >::Scalar > velocity_diff
Definition: darcy_flow_mh_output.hh:91
TimeGovernor
Basic time management functionality for unsteady (and steady) solvers (class Equation).
Definition: time_governor.hh:310
DarcyFlowMHOutput::OutputSpecificFields::div_diff
Field< 3, FieldValue< 3 >::Scalar > div_diff
Definition: darcy_flow_mh_output.hh:93
DarcyFlowMHOutput::OutputFields::OutputFields
OutputFields()
Definition: darcy_flow_mh_output.cc:82
field_values.hh
OutputTime
The class for outputting data during time.
Definition: output_time.hh:51
DarcyFlowMHOutput::RawOutputEqData::time_
TimeGovernor * time_
Time is shared with flow equation.
Definition: darcy_flow_mh_output.hh:122
DarcyFlowMHOutput::ele_pressure
VectorMPI ele_pressure
Definition: darcy_flow_mh_output.hh:161
DarcyFlowMHOutput::RawOutputEqData::flow_data_
std::shared_ptr< DarcyLMH::EqData > flow_data_
Definition: darcy_flow_mh_output.hh:124
Input::Type::Instance
Helper class that stores data of generic types.
Definition: type_generic.hh:89
OutputInternalFlowAssembly
Definition: assembly_flow_output.hh:259
DarcyFlowMHOutput::get_input_type_specific
static const Input::Type::Instance & get_input_type_specific()
Definition: darcy_flow_mh_output.cc:65
DarcyFlowMHOutput::DiffEqData::pressure_diff_ptr
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::Scalar > > pressure_diff_ptr
Definition: darcy_flow_mh_output.hh:106
FieldSet
Container for various descendants of FieldCommonBase.
Definition: field_set.hh:159
DarcyFlowMHOutput::DiffEqData::div_diff_ptr
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::Scalar > > div_diff_ptr
Definition: darcy_flow_mh_output.hh:108
DarcyFlowMHOutput::DiffEqData::DiffEqData
DiffEqData()
Definition: darcy_flow_mh_output.hh:99
FieldFE
Definition: field.hh:60
Mesh
Definition: mesh.h:362
DarcyFlowMHOutput::ele_piezo_head
VectorMPI ele_piezo_head
Definition: darcy_flow_mh_output.hh:163
DarcyFlowMHOutput::DiffEqData::div_error
double div_error[3]
Definition: darcy_flow_mh_output.hh:101
DarcyFlowMHOutput::l2_difference_assembly_
GenericAssembly< L2DifferenceAssembly > * l2_difference_assembly_
general assembly objects, hold assembly objects of appropriate dimension
Definition: darcy_flow_mh_output.hh:185
DarcyFlowMHOutput::set_ref_solution
void set_ref_solution(const Input::Record &rec, Field< 3, FieldType > &output_field, std::vector< std::string > reg)
Definition: darcy_flow_mh_output.cc:290
DarcyFlowMHOutput::compute_errors_
bool compute_errors_
Specific experimental error computing.
Definition: darcy_flow_mh_output.hh:155
DarcyLMH
Mixed-hybrid model of linear Darcy flow, possibly unsteady.
Definition: darcy_flow_lmh.hh:132
DarcyFlowMHOutput::DiffEqData::velocity_error
double velocity_error[3]
Definition: darcy_flow_mh_output.hh:101
DarcyFlowMHOutput::RawOutputEqData::raw_output_strings_
std::vector< std::string > raw_output_strings_
Output lines of cells.
Definition: darcy_flow_mh_output.hh:121
DarcyFlowMHOutput::DiffEqData
Output specific field stuff.
Definition: darcy_flow_mh_output.hh:97
DarcyFlowMHOutput::OutputFields::subdomain
Field< 3, FieldValue< 3 >::Scalar > subdomain
Definition: darcy_flow_mh_output.hh:82
DarcyFlowMHOutput::~DarcyFlowMHOutput
virtual ~DarcyFlowMHOutput()
Definition: darcy_flow_mh_output.cc:305
VectorMPI
Definition: vector_mpi.hh:43
Field
Class template representing a field with values dependent on: point, element, and region.
Definition: field.hh:92
DarcyFlowMHOutput::RawOutputEqData
Definition: darcy_flow_mh_output.hh:116
DarcyFlowMHOutput::RawOutputEqData::raw_output_file
ofstream raw_output_file
Raw data output file.
Definition: darcy_flow_mh_output.hh:120
DarcyFlowMHOutput::flow_eq_fields_
std::shared_ptr< DarcyLMH::EqFields > flow_eq_fields_
Definition: darcy_flow_mh_output.hh:178
DarcyFlowMHOutput::RawOutputEqData::RawOutputEqData
RawOutputEqData()
Definition: darcy_flow_mh_output.hh:118
DarcyFlowMHOutput
Definition: darcy_flow_mh_output.hh:73
GenericAssembly
Generic class of assemblation.
Definition: generic_assembly.hh:165
DarcyFlowMHOutput::darcy_flow
DarcyLMH * darcy_flow
Definition: darcy_flow_mh_output.hh:151
field.hh
IntDim
unsigned int IntDim
A dimension index type.
Definition: mixed.hh:19