Flow123d  release_2.2.1-10-gb9fad4d
balance.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 balance.hh
15  * @brief
16  */
17 
18 #ifndef BALANCE_HH_
19 #define BALANCE_HH_
20 
21 
22 #include <fstream>
23 #include "la/distribution.hh"
24 #include "transport/substance.hh"
25 #include "petscmat.h"
26 #include "fields/unit_si.hh"
27 #include "tools/time_marks.hh"
28 
29 class RegionDB;
30 class TimeGovernor;
31 class TimeStep;
32 
33 
34 
35 
36 
37 /**
38  * Design of balance class - serves as storage and writer.
39  * Equations themselves call methods of Balance that add/modify mass, source and flux
40  * of various quantities and generate output.
41  *
42  * One instance of Balance can handle several conservative quantities of the same type
43  * (e.g. mass of several substances or their phases).
44  *
45  * The mass, flux and source are calculated as follows:
46  *
47  * m(q,r) = ( M'(q) * solution + mv(q) )[r]
48  * f(q,r) = -( R' * ( F(q) * solution + fv(q) ) )[r]
49  * s(q,r) = ( S'(q) * solution + sv(q) )[r]
50  *
51  * where M' stands for matrix transpose,
52  *
53  * m(q,r)...mass of q-th substance in region r
54  * f(q,r)...incoming flux of q-th substance in region r
55  * s(q,r)...source of q-th substance in region r
56  *
57  * and
58  *
59  * M(q)...region_mass_matrix_ n_dofs x n_bulk_regions
60  * F(q)...be_flux_matrix_ n_boundary_edges x n_dofs
61  * S(q)...region_source_matrix_ n_dofs x n_bulk_regions
62  * SV(q)..region_source_rhs_ n_dofs x n_bulk_regions
63  * mv(q)..region_mass_vec_ n_bulk_regions
64  * fv(q)..be_flux_vec_ n_boundary_edges
65  * sv(q)..region_source_vec_ n_bulk_regions
66  * R......region_be_matrix_ n_boundary_edges x n_boundary_regions
67  *
68  * Remark: Matrix F and the vector fv are such that F*solution+fv produces _outcoming_ fluxes per boundary edge.
69  * However we write to output _incoming_ flux due to users' convention and consistently with input interface.
70  *
71  * Note that it holds:
72  *
73  * sv(q) = column sum of SV(q)
74  *
75  * Except for that, we also provide information on positive/negative flux and source:
76  *
77  * fp(q,r) = ( R' * EFP(q) )[r], EFP(q)[e] = max{ 0, ( F(q) * solution + fv(q) )[e] }
78  * fn(q,r) = ( R' * EFN(q) )[r], EFN(q)[e] = min{ 0, ( F(q) * solution + fv(q) )[e] }
79  * sp(q,r) = sum_{i in DOFS } max{ 0, ( S(q)[i,r] * solution[i] + SV(q)[i,r] ) }
80  * sn(q,r) = sum_{i in DOFS } min{ 0, ( S(q)[i,r] * solution[i] + SV(q)[i,r] ) }
81  *
82  * where
83  *
84  * fp(q,r)...positive (inward) flux of q-th quantity in region r
85  * fn(q,r)...negative (outward) flux of q-th quantity in region r
86  * sp(q,r)...positive source (spring) of q-th quantity in region r
87  * sn(q,r)...negative source (sink) of q-th quantity in region r
88  *
89  * Remark: The matrix R is needed only for calculation of signed fluxes.
90  * The reason is that to determine sign, we decompose flux to sum of local contributions
91  * per each boundary element and check its sign. It is not possible to decompose flux
92  * using shape functions, since their normal derivatives may have any sign.
93  *
94  *
95  *
96  * Output values (if not relevant, zero is supplied):
97  *
98  * #time bulk_region quantity 0 0 0 mass source source_in source_out 0 0 0
99  * #time boundary_region quantity flux flux_in flux_out 0 0 0 0 0 0 0
100  * #time ALL quantity flux flux_in flux_out mass source source_in source_out integrated_flux integrated_source error
101  *
102  * error = current_mass - (initial_mass + integrated_source - integrated_flux)
103  *
104  */
105 class Balance {
106 public:
107 
108  /**
109  * Class for storing internal data about conservative quantities handled by the Balance object.
110  * In the future we may store additional data or support definition of derived quantities
111  * (e.g. linear combinations of quantities).
112  */
113  class Quantity {
114  public:
115 
116  Quantity(const unsigned int index, const string &name)
117  : name_(name),
118  index_(index)
119  {}
120 
121  /// Name of quantity (for output).
122  string name_;
123 
124  /// Internal index within list of quantities.
125  const unsigned int index_;
126 
127  };
128 
129  /**
130  * Possible formats of output file.
131  */
133  {
134  legacy,//!< legacy
135  txt, //!< csv
136  gnuplot//!< gnuplot
137  };
138 
139  /// Main balance input record type.
140  static const Input::Type::Record & get_input_type();
141 
142  /// Input selection for file format.
144 
145  /// Set global variable to output balance files into YAML format (in addition to the table format).
146  static void set_yaml_output();
147 
148  /**
149  * Constructor.
150  * @param file_prefix Prefix of output file name.
151  * @param mesh Mesh.
152  */
153  Balance(const std::string &file_prefix, const Mesh *mesh);
154 
155  /**
156  * Destructor.
157  */
158  ~Balance();
159 
160 
161  /**
162  * Initialize the balance object according to the input.
163  * The balance output time marks are set according to the already existing output time marks of the same equation.
164  * So, this method must be called after Output::
165  *
166  * @param in_rec Input record of balance.
167  * @param tg TimeGovernor of the equation. We need just equation mark type.
168  *
169  */
170  void init_from_input(const Input::Record &in_rec, TimeGovernor &tg);
171 
172  /// Setter for units of conserved quantities.
173  void units(const UnitSI &unit);
174 
175  /// Getter for cumulative_.
176  inline bool cumulative() const { return cumulative_; }
177 
178 
179  /**
180  * Define a single conservative quantity.
181  * @param name Name of the quantity.
182  * @return Quantity's internal index.
183  */
184  unsigned int add_quantity(const string &name);
185 
186  /**
187  * Define a set of conservative quantities.
188  * @param names List of quantities' names.
189  * @return List of quantities' indices.
190  */
192 
193  /**
194  * Allocates matrices and vectors for balance.
195  * @param n_loc_dofs Number of solution dofs on the local process.
196  * @param max_dofs_per_boundary Number of dofs contributing to one boundary edge.
197  */
198  void allocate(unsigned int n_loc_dofs,
199  unsigned int max_dofs_per_boundary);
200 
201 
202  /// Returns true if the current time step is marked for the balance output.
203  bool is_current();
204 
205  /**
206  * This method must be called before assembling the matrix for computing mass.
207  * It actually erases the matrix.
208  */
209  void start_mass_assembly(unsigned int quantity_idx);
210 
211  /// Variant of the start_mass_assembly() method for a set of quantities.
213  {
214  for (auto idx : q_idx_vec)
215  start_mass_assembly(idx);
216  }
217 
218  /**
219  * This method must be called before assembling the matrix and vector for fluxes.
220  * It actually erases the matrix and vector.
221  */
222  void start_flux_assembly(unsigned int quantity_idx);
223 
224  /// Variant of the start_flux_assembly() method for a set of quantities.
226  {
227  for (auto idx : q_idx_vec)
228  start_flux_assembly(idx);
229  }
230 
231  /**
232  * This method must be called before assembling the matrix and vectors for sources.
233  * It actually erases the matrix and vectors.
234  */
235  void start_source_assembly(unsigned int quantity_idx);
236 
237  /// Variant of the start_source_assembly() method for a set of quantities.
239  {
240  for (auto idx : q_idx_vec)
242  }
243 
244  /**
245  * Adds elements into matrix for computing mass.
246  * @param quantity_idx Index of quantity.
247  * @param region_idx Index of bulk region.
248  * @param dof_indices Dof indices to be added.
249  * @param values Values to be added.
250  */
251  void add_mass_matrix_values(unsigned int quantity_idx,
252  unsigned int region_idx,
253  const std::vector<int> &dof_indices,
254  const std::vector<double> &values);
255 
256  /**
257  * Adds elements into matrix for computing (outgoing) flux.
258  * @param quantity_idx Index of quantity.
259  * @param boundary_idx Local index of boundary edge.
260  * @param dof_indices Dof indices to be added.
261  * @param values Values to be added.
262  *
263  * The order of local boundary edges is given by traversing
264  * the local elements and their sides.
265  *
266  * TODO: Think of less error-prone way of finding the local
267  * boundary index for a given Boundary object. It can be
268  * possibly done when we will have a boundary mesh.
269  */
270  void add_flux_matrix_values(unsigned int quantity_idx,
271  unsigned int boundary_idx,
272  const std::vector<int> &dof_indices,
273  const std::vector<double> &values);
274 
275  /**
276  * Adds element into vector for computing mass.
277  * @param quantity_idx Index of quantity.
278  * @param region_idx Index of bulk region.
279  * @param value Value to be added.
280  */
281  void add_mass_vec_value(unsigned int quantity_idx,
282  unsigned int region_idx,
283  double value);
284 
285  /**
286  * Adds elements into matrix and vector for computing source.
287  * @param quantity_idx Index of quantity.
288  * @param region_idx Index of bulk region.
289  * @param dof_indices Local dof indices to be added.
290  * @param mat_values Values to be added into matrix.
291  * @param vec_values Values to be added into vector.
292  */
293  void add_source_values(unsigned int quantity_idx,
294  unsigned int region_idx,
295  const std::vector<int> &loc_dof_indices,
296  const std::vector<double> &mat_values,
297  const std::vector<double> &vec_values);
298 
299  /**
300  * Adds element into vector for computing (outgoing) flux.
301  * @param quantity_idx Index of quantity.
302  * @param boundary_idx Local index of boundary edge.
303  * @param value Value to be added.
304  *
305  * For determining the local boundary index see @ref add_flux_matrix_values.
306  */
307  void add_flux_vec_value(unsigned int quantity_idx,
308  unsigned int boundary_idx,
309  double value);
310 
311  /// This method must be called after assembling the matrix for computing mass.
312  void finish_mass_assembly(unsigned int quantity_idx);
313 
314  /// Variant of the finish_mass_assembly() method for a set of quantities.
316  {
317  for (auto idx : q_idx_vec)
319  }
320 
321  /// This method must be called after assembling the matrix and vector for computing flux.
322  void finish_flux_assembly(unsigned int quantity_idx);
323 
324  /// Variant of the finish_flux_assembly() method for a set of quantities.
326  {
327  for (auto idx : q_idx_vec)
329  }
330 
331  /// This method must be called after assembling the matrix and vectors for computing source.
332  void finish_source_assembly(unsigned int quantity_idx);
333 
334  /// Variant of the finish_source_assembly() method for a set of quantities.
336  {
337  for (auto idx : q_idx_vec)
339  }
340 
341  /**
342  * Updates cumulative quantities for balance.
343  * This method can be called in substeps even if no output is generated.
344  * It calculates the sum of source and sum of (incoming) flux over time interval.
345  * @param quantity_idx Index of quantity.
346  * @param solution Solution vector.
347  */
348  void calculate_cumulative(unsigned int quantity_idx,
349  const Vec &solution);
350 
351  /**
352  * Calculates actual mass and save it to given vector.
353  * @param quantity_idx Index of quantity.
354  * @param solution Solution vector.
355  * @param output_array Vector of output masses per region.
356  */
357  void calculate_mass(unsigned int quantity_idx,
358  const Vec &solution,
359  vector<double> &output_array);
360 
361  /**
362  * Calculates actual mass, incoming flux and source.
363  * @param quantity_idx Index of quantity.
364  * @param solution Solution vector.
365  */
366  void calculate_instant(unsigned int quantity_idx,
367  const Vec &solution);
368 
369  /**
370  * Adds provided values to the cumulative sources.
371  * @param quantity_idx Index of quantity.
372  * @param sources Sources per region.
373  * @param dt Actual time step.
374  */
375  void add_cumulative_source(unsigned int quantity_idx, double source);
376 
377  /// Perform output to file for given time instant.
378  void output();
379 
380 private:
381  /// Size of column in output (used if delimiter is space)
382  static const unsigned int output_column_width = 20;
383  /**
384  * Postponed allocation and initialization to allow calling setters in arbitrary order.
385  * In particular we need to perform adding of output times after the output time marks are set.
386  * On the other hand we need to read the input before we make the allocation.
387  *
388  * The initialization is done during the first call of any start_*_assembly method.
389  */
390  void lazy_initialize();
391 
392  /// Perform output in old format (for compatibility)
393  void output_legacy(double time);
394 
395  /// Perform output in csv format
396  void output_csv(double time, char delimiter, const std::string& comment_string, unsigned int repeat = 0);
397 
398  /// Perform output in yaml format
399  void output_yaml(double time);
400 
401  /// Return part of output represented by zero values. Count of zero values is given by cnt parameter.
402  std::string csv_zero_vals(unsigned int cnt, char delimiter);
403 
404  /// Print output header
405  void format_csv_output_header(char delimiter, const std::string& comment_string);
406 
407  /// Format string value of csv output. Wrap string into quotes and if delimiter is space, align text to column.
408  std::string format_csv_val(std::string val, char delimiter, bool initial = false);
409 
410  /// Format double value of csv output. If delimiter is space, align text to column.
411  std::string format_csv_val(double val, char delimiter, bool initial = false);
412 
413 
414  //**********************************************
415 
416  static bool do_yaml_output_;
417 
418  /// Allocation parameters. Set by the allocate method used in the lazy_initialize.
419  unsigned int n_loc_dofs_;
421 
422 
423  /// Save prefix passed in in constructor.
424  std::string file_prefix_;
425 
426  /// File path for output_ stream.
428 
429  /// Handle for file for output in given OutputFormat of balance and total fluxes over individual regions and region sets.
430  ofstream output_;
431 
432  // The same as the previous case, but for output in YAML format.
433  ofstream output_yaml_;
434 
435  /// Format of output file.
437 
438  /// Names of conserved quantities.
440 
441  const Mesh *mesh_;
442 
443  /// Units of conserved quantities.
445 
446 
447  /// Matrices for calculation of mass (n_dofs x n_bulk_regions).
449 
450  /// Matrices for calculation of flux (n_boundary_edges x n_dofs).
452 
453  /// Matrices for calculation of source (n_dofs x n_bulk_regions).
455 
456  /// Matrices for calculation of signed source (n_dofs x n_bulk_regions).
458 
459  /// Vectors for calculation of flux (n_boundary_edges).
461 
462  /// Vectors for calculation of mass (n_bulk_regions).
464 
465  /**
466  * Auxiliary matrix for transfer of quantities between boundary edges and regions
467  * (n_boundary_edges x n_boundary_regions).
468  */
470 
471  /// Number of boundary region for each local boundary edge.
473 
474  /// Offset for local part of vector of boundary edges.
476 
477 
478  // Vectors storing mass and balances of fluxes and volumes.
479  // substance, phase, region
486 
487  // Sums of the above vectors over phases and regions
496 
497  // time integrated quantities
502 
503  /// time of last calculated balance
504  double last_time_;
505 
506  /// TimeMark type for balance output of particular equation.
508 
509  /// TimeMark type for output of particular equation.
511 
512  /// true before calculating the mass at initial time, otherwise false
513  bool initial_;
514 
515  /// if true then cumulative balance is computed
517 
518  /// true before allocating necessary internal structures (Petsc matrices etc.)
520 
521  /// If the balance is on. Balance is off in the case of no balance output time marks.
523 
524  /// Add output time marks to balance output time marks.
526 
527 
528  /// MPI rank.
529  int rank_;
530 
531  /// hold count of line printed into output_
532  unsigned int output_line_counter_;
533 
534  /// marks whether YAML output has printed header
536 
537  /// Record for current balance
539 
541 
542 
543 };
544 
545 
546 
547 
548 
549 #endif // BALANCE_HH_
UnitSI units_
Units of conserved quantities.
Definition: balance.hh:444
void lazy_initialize()
Definition: balance.cc:184
static const Input::Type::Record & get_input_type()
Main balance input record type.
Definition: balance.cc:44
std::vector< double > integrated_sources_
Definition: balance.hh:498
unsigned int add_quantity(const string &name)
Definition: balance.cc:156
std::vector< double > sum_fluxes_out_
Definition: balance.hh:490
void calculate_mass(unsigned int quantity_idx, const Vec &solution, vector< double > &output_array)
Definition: balance.cc:611
TimeMark::Type output_mark_type_
TimeMark type for output of particular equation.
Definition: balance.hh:510
TimeMark::Type balance_output_type_
TimeMark type for balance output of particular equation.
Definition: balance.hh:507
void allocate(unsigned int n_loc_dofs, unsigned int max_dofs_per_boundary)
Definition: balance.cc:176
void finish_source_assembly(unsigned int quantity_idx)
This method must be called after assembling the matrix and vectors for computing source.
Definition: balance.cc:424
void add_mass_vec_value(unsigned int quantity_idx, unsigned int region_idx, double value)
Definition: balance.cc:504
gnuplot
Definition: balance.hh:136
bool initial_
true before calculating the mass at initial time, otherwise false
Definition: balance.hh:513
void start_mass_assembly(std::vector< unsigned int > q_idx_vec)
Variant of the start_mass_assembly() method for a set of quantities.
Definition: balance.hh:212
std::vector< std::vector< double > > sources_in_
Definition: balance.hh:484
void add_cumulative_source(unsigned int quantity_idx, double source)
Definition: balance.cc:529
void finish_mass_assembly(std::vector< unsigned int > q_idx_vec)
Variant of the finish_mass_assembly() method for a set of quantities.
Definition: balance.hh:315
std::vector< std::vector< double > > fluxes_in_
Definition: balance.hh:481
std::vector< double > sum_fluxes_in_
Definition: balance.hh:489
std::vector< std::vector< double > > fluxes_out_
Definition: balance.hh:482
const TimeGovernor * time_
Definition: balance.hh:540
Mat * region_source_rhs_
Matrices for calculation of signed source (n_dofs x n_bulk_regions).
Definition: balance.hh:457
Definition: mesh.h:97
void add_mass_matrix_values(unsigned int quantity_idx, unsigned int region_idx, const std::vector< int > &dof_indices, const std::vector< double > &values)
Definition: balance.cc:438
Input::Record input_record_
Record for current balance.
Definition: balance.hh:538
ofstream output_
Handle for file for output in given OutputFormat of balance and total fluxes over individual regions ...
Definition: balance.hh:430
bool cumulative() const
Getter for cumulative_.
Definition: balance.hh:176
void output_legacy(double time)
Perform output in old format (for compatibility)
Definition: balance.cc:865
Mat region_be_matrix_
Definition: balance.hh:469
bool allocation_done_
true before allocating necessary internal structures (Petsc matrices etc.)
Definition: balance.hh:519
void calculate_cumulative(unsigned int quantity_idx, const Vec &solution)
Definition: balance.cc:539
Basic time management functionality for unsteady (and steady) solvers (class Equation).
void calculate_instant(unsigned int quantity_idx, const Vec &solution)
Definition: balance.cc:636
void add_flux_vec_value(unsigned int quantity_idx, unsigned int boundary_idx, double value)
Definition: balance.cc:515
std::vector< double > sum_fluxes_
Definition: balance.hh:488
string name_
Name of quantity (for output).
Definition: balance.hh:122
bool balance_on_
If the balance is on. Balance is off in the case of no balance output time marks. ...
Definition: balance.hh:522
static constexpr bool value
Definition: json.hpp:87
std::vector< double > increment_sources_
Definition: balance.hh:501
const unsigned int index_
Internal index within list of quantities.
Definition: balance.hh:125
Vec * be_flux_vec_
Vectors for calculation of flux (n_boundary_edges).
Definition: balance.hh:460
static void set_yaml_output()
Set global variable to output balance files into YAML format (in addition to the table format)...
Definition: balance.cc:57
static const Input::Type::Selection & get_format_selection_input_type()
Input selection for file format.
Definition: balance.cc:36
std::vector< double > integrated_fluxes_
Definition: balance.hh:499
std::vector< Quantity > quantities_
Names of conserved quantities.
Definition: balance.hh:439
std::string csv_zero_vals(unsigned int cnt, char delimiter)
Return part of output represented by zero values. Count of zero values is given by cnt parameter...
Definition: balance.cc:1010
std::vector< std::vector< double > > sources_out_
Definition: balance.hh:485
Mat * be_flux_matrix_
Matrices for calculation of flux (n_boundary_edges x n_dofs).
Definition: balance.hh:451
double last_time_
time of last calculated balance
Definition: balance.hh:504
std::vector< std::vector< double > > fluxes_
Definition: balance.hh:480
void finish_mass_assembly(unsigned int quantity_idx)
This method must be called after assembling the matrix for computing mass.
Definition: balance.cc:402
void finish_flux_assembly(std::vector< unsigned int > q_idx_vec)
Variant of the finish_flux_assembly() method for a set of quantities.
Definition: balance.hh:325
void format_csv_output_header(char delimiter, const std::string &comment_string)
Print output header.
Definition: balance.cc:1099
int rank_
MPI rank.
Definition: balance.hh:529
Accessor to the data with type Type::Record.
Definition: accessors.hh:292
void init_from_input(const Input::Record &in_rec, TimeGovernor &tg)
Definition: balance.cc:123
void start_flux_assembly(std::vector< unsigned int > q_idx_vec)
Variant of the start_flux_assembly() method for a set of quantities.
Definition: balance.hh:225
Mat * region_mass_matrix_
Matrices for calculation of mass (n_dofs x n_bulk_regions).
Definition: balance.hh:448
std::vector< double > sum_sources_out_
Definition: balance.hh:494
unsigned int max_dofs_per_boundary_
Definition: balance.hh:420
bool cumulative_
if true then cumulative balance is computed
Definition: balance.hh:516
Mat * region_source_matrix_
Matrices for calculation of source (n_dofs x n_bulk_regions).
Definition: balance.hh:454
std::vector< double > increment_fluxes_
Definition: balance.hh:500
void finish_source_assembly(std::vector< unsigned int > q_idx_vec)
Variant of the finish_source_assembly() method for a set of quantities.
Definition: balance.hh:335
bool is_current()
Returns true if the current time step is marked for the balance output.
Definition: balance.cc:364
Balance(const std::string &file_prefix, const Mesh *mesh)
Definition: balance.cc:80
void output_csv(double time, char delimiter, const std::string &comment_string, unsigned int repeat=0)
Perform output in csv format.
Definition: balance.cc:1018
void add_flux_matrix_values(unsigned int quantity_idx, unsigned int boundary_idx, const std::vector< int > &dof_indices, const std::vector< double > &values)
Definition: balance.cc:458
~Balance()
Definition: balance.cc:97
static bool do_yaml_output_
Definition: balance.hh:416
std::vector< unsigned int > add_quantities(const std::vector< string > &names)
Definition: balance.cc:167
Dedicated class for storing path to input and output files.
Definition: file_path.hh:54
const Mesh * mesh_
Definition: balance.hh:441
Support classes for parallel programing.
void output_yaml(double time)
Perform output in yaml format.
Definition: balance.cc:1156
void output()
Perform output to file for given time instant.
Definition: balance.cc:722
std::vector< double > sum_sources_
Definition: balance.hh:492
void start_flux_assembly(unsigned int quantity_idx)
Definition: balance.cc:384
void add_source_values(unsigned int quantity_idx, unsigned int region_idx, const std::vector< int > &loc_dof_indices, const std::vector< double > &mat_values, const std::vector< double > &vec_values)
Definition: balance.cc:476
std::vector< double > initial_mass_
Definition: balance.hh:495
static const unsigned int output_column_width
Size of column in output (used if delimiter is space)
Definition: balance.hh:382
Quantity(const unsigned int index, const string &name)
Definition: balance.hh:116
void finish_flux_assembly(unsigned int quantity_idx)
This method must be called after assembling the matrix and vector for computing flux.
Definition: balance.cc:413
std::vector< unsigned int > be_regions_
Number of boundary region for each local boundary edge.
Definition: balance.hh:472
ofstream output_yaml_
Definition: balance.hh:433
OutputFormat output_format_
Format of output file.
Definition: balance.hh:436
Classes for storing substance data.
void units(const UnitSI &unit)
Setter for units of conserved quantities.
Definition: balance.cc:148
int be_offset_
Offset for local part of vector of boundary edges.
Definition: balance.hh:475
std::vector< std::vector< double > > masses_
Definition: balance.hh:483
void start_source_assembly(std::vector< unsigned int > q_idx_vec)
Variant of the start_source_assembly() method for a set of quantities.
Definition: balance.hh:238
void start_mass_assembly(unsigned int quantity_idx)
Definition: balance.cc:375
Record type proxy class.
Definition: type_record.hh:182
std::vector< double > sum_masses_
Definition: balance.hh:491
Vec * region_mass_vec_
Vectors for calculation of mass (n_bulk_regions).
Definition: balance.hh:463
unsigned int output_line_counter_
hold count of line printed into output_
Definition: balance.hh:532
bool add_output_times_
Add output time marks to balance output time marks.
Definition: balance.hh:525
Class for representation SI units of Fields.
Definition: unit_si.hh:40
unsigned int n_loc_dofs_
Allocation parameters. Set by the allocate method used in the lazy_initialize.
Definition: balance.hh:419
OutputFormat
Definition: balance.hh:132
Representation of one time step..
void start_source_assembly(unsigned int quantity_idx)
Definition: balance.cc:393
Template for classes storing finite set of named values.
FilePath balance_output_file_
File path for output_ stream.
Definition: balance.hh:427
std::string file_prefix_
Save prefix passed in in constructor.
Definition: balance.hh:424
bool output_yaml_header_
marks whether YAML output has printed header
Definition: balance.hh:535
std::string format_csv_val(std::string val, char delimiter, bool initial=false)
Format string value of csv output. Wrap string into quotes and if delimiter is space, align text to column.
Definition: balance.cc:1126
std::vector< double > sum_sources_in_
Definition: balance.hh:493