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