Flow123d  release_2.2.0-22-g936454a
output_time.impl.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 output.h
15  * @brief Header: The functions for all outputs.
16  * @todo
17  * - remove Output, keep OutputTime only (done)
18  * - remove parameter mesh from static method OutputTime::output_stream (done)
19  * - move initialization of streams from hc_expolicit_sequantial to
20  * Aplication::Aplication() constructor (done)
21  * - OutputTime::register_XXX_data - should accept iterator to output record of particular equation, ask for presence of the key
22  * that has same name as the name of the quantity to output, extract the string with stream name from this key, find the stream
23  * and perform output.
24  *
25  * on input:
26  *
27  * { // darcy flow
28  * output = {
29  * pressure_nodes="nodal_data",
30  * pressure_elements="el_data"
31  * }
32  * }
33  *
34  * output_streams=[
35  * {name="nodal_data", ... },
36  * {name="el_data", ... }
37  * ]
38  *
39  * in code:
40  *
41  * Input::Record out_rec = in_rec.val<Input::Record>("output");
42  * OutputTime::register_node_data(mesh_, "pressure_nodes", "L", out_rec, node_pressure);
43  * OutputTime::register_elem_data(mesh_, "pressure_elements", "L", out_rec, ele_pressure);
44  * ...
45  *
46  * - use exceptions instead of returning result, see declaration of exceptions through DECLARE_EXCEPTION macro
47  * - move write_data from equations into coupling, write all streams
48  *
49  * =======================
50  * - Is it still necessary to split output into registration and write the data?
51  * Could we perform it at once? ... No, it doesn't make any sense.
52  * - Support for output of corner data into GMSH format (ElementNodeData section)
53  *
54  */
55 
56 #ifndef OUTPUT_H
57 #define OUTPUT_H
58 
59 #include <vector>
60 #include <string>
61 
62 #include "system/system.hh"
63 
64 #include "system/exceptions.hh"
65 #include "io/output_time.hh"
66 #include "io/output_mesh.hh"
67 #include "io/element_data_cache.hh"
68 #include "io/output_element.hh"
69 
70 
71 
72 
73 /**************************************************************************************************************
74  * OutputTime implementation
75  */
76 
77 template <typename T>
78 ElementDataCache<T> & OutputTime::prepare_compute_data(std::string field_name, DiscreteSpace space_type, unsigned int n_rows,
79  unsigned int n_cols)
80 {
81  if(space_type == CORNER_DATA)
83 
84  // get possibly existing data for the same field, check both name and type
86  size[NODE_DATA] = output_mesh_->n_nodes();
87  size[ELEM_DATA] = output_mesh_->n_elements();
88  size[CORNER_DATA] = output_mesh_discont_->n_nodes();
89 
90  auto &od_vec=this->output_data_vec_[space_type];
91  auto it=std::find_if(od_vec.begin(), od_vec.end(),
92  [&field_name](OutputDataPtr ptr) { return (ptr->field_input_name() == field_name); });
93  if ( it == od_vec.end() ) {
94  od_vec.push_back( std::make_shared< ElementDataCache<T> >(field_name, n_rows, n_cols, size[space_type]) );
95  it=--od_vec.end();
96  }
97  return dynamic_cast<ElementDataCache<T> &>(*(*it));
98 }
99 
100 #endif
ElementDataCache< T > & prepare_compute_data(std::string field_name, DiscreteSpace space_type, unsigned int n_rows, unsigned int n_cols)
Classes for auxiliary output mesh.
std::shared_ptr< OutputMesh > output_mesh_
Output mesh.
Definition: output_time.hh:267
std::shared_ptr< OutputMeshDiscontinuous > output_mesh_discont_
Discontinuous (non-conforming) mesh. Used for CORNER_DATA.
Definition: output_time.hh:269
std::shared_ptr< ElementDataCacheBase > OutputDataPtr
Definition: output_time.hh:111
static const unsigned int N_DISCRETE_SPACES
Definition: output_time.hh:95
void compute_discontinuous_output_mesh()
Definition: output_time.cc:154
Class OutputElement and its iterator OutputElementIterator on the output mesh.
OutputDataFieldVec output_data_vec_[N_DISCRETE_SPACES]
Definition: output_time.hh:218