Flow123d  release_1.8.2-1603-g0109a2b
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 "mesh/mesh.h"
23 #include <string>
24 #include <vector>
25 
26 #include "io/output_time.hh"
28 #include "input/accessors.hh"
29 
30 #include "fem/mapping_p1.hh"
31 #include "fem/fe_p.hh"
32 
33 #include "fields/vec_seq_double.hh"
34 
35 
36 class DarcyFlowMH_Steady;
37 class OutputTime;
38 class DOFHandlerMultiDim;
39 
40 
41 /**
42  * Actually this class only collect former code from postprocess.*
43  * This code depends on values stored in mesh and has to be changed to use fields or other data provided by
44  * interface to darcy_flow. We have to relay on the interface in order to allow different implementation of darcy_flow.
45  *
46  * Principal functionalities of current postprocess are:
47  * - move computed values into mesh - this can be removed after we get new output classes,
48  * other dependent code can use directly field interface
49  * - compute interpolation to nodes - this can be external and operate directly on fields
50  * - compute water balances over materials and boundary parts - is feasible through field interface
51  *
52  * Further functionality of this class should be:
53  * - prepare data for general output classes
54  *
55  */
57 public:
58 
59  class OutputFields : public FieldSet {
60  public:
61 
62  OutputFields();
63 
70 
74 
75  // List fields, we have initialized for output
76  // In case of error fields, we have to add them to the main field set
77  // but perform output only if user set compute_errors flag.
79 
81  };
82 
85 
86  static const Input::Type::Record & get_input_type();
87 
88 
89  /** \brief Calculate values for output. **/
90  void output();
91 
93 
94 
95 private:
96  void make_side_flux();
97  void make_element_scalar();
98 
99  /** Computes fluxes at the barycenters of elements.
100  * TODO:
101  * We use FEValues to get fluxes at the barycenters of elements,
102  * but we still use MHDofHandler. Once we are able to make output routines
103  * parallel, we can use simply FieldFE for velocity here.
104  */
105  void make_element_vector();
106 
107  void make_sides_scalar();
108  /**
109  * \brief Calculate nodes scalar,
110  * store it in double* node_scalars instead of node->scalar
111  * */
112  void make_node_scalar_param();
113  void make_node_scalar();
114  void make_corner_scalar(vector<double> &node_scalar);
115  void make_neighbour_flux();
117 
118  /**
119  * Temporary hack.
120  * Calculate approximation of L2 norm for:
121  * 1) difference between regularized pressure and analytical solution (using FunctionPython)
122  * 2) difference between RT velocities and analytical solution
123  * 3) difference of divergence
124  *
125  * TODO:
126  * 1) implement field objects
127  * 2) implement DG_P2 finite elements
128  * 3) implement pressure postprocessing (result is DG_P2 field)
129  * 4) implement calculation of L2 norm for two field (compute the norm and values on individual elements as P0 field)
130  */
131  void compute_l2_difference();
132 
133  /**
134  * Calculate and output water balance over material subdomains and boudary fluxes.
135  * Works only for steady flow.
136  *
137  * TODO:
138  * - fix it also for unsteady flow
139  * - create separate class for this caculations and output
140  * - create class for output of tables with support to output into various file formats
141  * like GNUplot of excel/open calc
142  **/
143  void water_balance();
144  double calc_water_balance();
145 
148 
149  /// Accessor to the input record for the DarcyFlow output.
151 
152 
153  /** Pressure head (in [m]) interpolated into nodes. Provides P1 approximation. Indexed by element-node numbering.*/
155  /** Pressure head (in [m]) in barycenters of elements (or equivalently mean pressure over every element). Indexed by element indexes in the mesh.*/
157  /** Piezo-metric head (in [m]) in barycenter of elements (or equivalently mean pressure over every element). Indexed by element indexes in the mesh.*/
159 
160  /** Average flux in barycenter of every element. Indexed as elements in the mesh. */
161  // TODO: Definitely we need more general (templated) implementation of Output that accept arbitrary containers. So
162  // that we can pass there directly vector< arma:: vec3 >
164 
165  // integrals of squared differences on individual elements - error indicators, can be written out into VTK files
167 
176 
178 
179  std::shared_ptr<OutputTime> output_stream;
180 
181  /// Temporary solution for writing balance into separate file.
183  /// Raw data output file.
185 };
186 
187 
188 #endif /* DARCY_FLOW_MH_OUTPUT_HH_ */
189 
Field< 3, FieldValue< 3 >::VectorFixed > field_ele_flux
Class MappingP1 implements the affine transformation of the unit cell onto the actual cell...
Field< 3, FieldValue< 3 >::Scalar > velocity_diff
VectorSeqDouble ele_pressure
Container for various descendants of FieldCommonBase.
Definition: field_set.hh:61
DarcyFlowMH_Steady * darcy_flow
std::vector< double > l2_diff_velocity
Field< 3, FieldValue< 3 >::Scalar > field_node_pressure
MappingP1< 1, 3 > map1
Class template representing a field with values dependent on: point, element, and region...
Definition: field.hh:62
DarcyFlowMHOutput(DarcyFlowMH_Steady *flow, Input::Record in_rec)
DOFHandlerMultiDim * dh
Definition: mesh.h:99
void make_corner_scalar(vector< double > &node_scalar)
double calc_water_balance()
Field< 3, FieldValue< 3 >::Integer > subdomain
std::vector< double > l2_diff_divergence
std::shared_ptr< OutputTime > output_stream
static const Input::Type::Selection & get_output_selection()
static const Input::Type::Record & get_input_type()
void make_sides_scalar()
Field< 3, FieldValue< 3 >::Scalar > field_ele_pressure
FE_P_disc< 1, 2, 3 > fe2
VectorSeqDouble ele_piezo_head
void make_neighbour_flux()
MappingP1< 2, 3 > map2
Definitions of basic Lagrangean finite elements with polynomial shape functions.
FILE * raw_output_file
Raw data output file.
Accessor to the data with type Type::Record.
Definition: accessors.hh:277
Provides the numbering of the finite element degrees of freedom on the computational mesh...
Definition: dofhandler.hh:248
FILE * balance_output_file
Temporary solution for writing balance into separate file.
Input::Record in_rec_
Accessor to the input record for the DarcyFlow output.
VectorSeqDouble ele_flux
The class for outputting data during time.
Definition: output_time.hh:42
MappingP1< 3, 3 > map3
Field< 3, FieldValue< 3 >::Scalar > field_ele_piezo_head
Field< 3, FieldValue< 3 >::Integer > region_id
Field< 3, FieldValue< 3 >::Scalar > pressure_diff
const OutputFields & get_output_fields()
void output(std::shared_ptr< OutputTime > stream)
Definition: field_set.cc:169
Mixed-hybrid model of linear Darcy flow, possibly unsteady.
Field< 3, FieldValue< 3 >::Scalar > div_diff
FE_P_disc< 1, 3, 3 > fe3
vector< double > corner_pressure
Record type proxy class.
Definition: type_record.hh:171
FE_P_disc< 1, 1, 3 > fe1
void make_node_scalar_param()
Calculate nodes scalar, store it in double* node_scalars instead of node->scalar. ...
Template for classes storing finite set of named values.
std::vector< double > l2_diff_pressure