25 #include <unordered_map> 130 Quantity(
const unsigned int index,
const string &name)
160 static void set_yaml_output();
167 Balance(
const std::string &file_prefix,
const Mesh *mesh);
187 void units(
const UnitSI &unit);
198 unsigned int add_quantity(
const string &name);
212 void allocate(
const std::shared_ptr<DOFHandlerMultiDim>& dh,
213 unsigned int max_dofs_per_boundary);
220 void allocate(
unsigned int n_loc_dofs,
221 unsigned int max_dofs_per_boundary);
230 void start_mass_assembly(
unsigned int quantity_idx);
235 for (
auto idx : q_idx_vec)
236 start_mass_assembly(idx);
243 void start_flux_assembly(
unsigned int quantity_idx);
248 for (
auto idx : q_idx_vec)
249 start_flux_assembly(idx);
256 void start_source_assembly(
unsigned int quantity_idx);
261 for (
auto idx : q_idx_vec)
262 start_source_assembly(idx);
278 void add_mass_values(
unsigned int quantity_idx,
295 void add_flux_values(
unsigned int quantity_idx,
313 void add_source_values(
unsigned int quantity_idx,
314 unsigned int region_idx,
321 void finish_mass_assembly(
unsigned int quantity_idx);
326 for (
auto idx : q_idx_vec)
327 finish_mass_assembly(idx);
331 void finish_flux_assembly(
unsigned int quantity_idx);
336 for (
auto idx : q_idx_vec)
337 finish_flux_assembly(idx);
341 void finish_source_assembly(
unsigned int quantity_idx);
346 for (
auto idx : q_idx_vec)
347 finish_source_assembly(idx);
357 void calculate_cumulative(
unsigned int quantity_idx,
358 const Vec &solution);
366 void calculate_mass(
unsigned int quantity_idx,
375 void calculate_instant(
unsigned int quantity_idx,
376 const Vec &solution);
384 void add_cumulative_source(
unsigned int quantity_idx,
double source);
391 static const unsigned int output_column_width = 20;
399 void lazy_initialize();
402 void output_legacy(
double time);
405 void output_csv(
double time,
char delimiter,
const std::string& comment_string,
unsigned int repeat = 0);
408 void output_yaml(
double time);
411 std::string csv_zero_vals(
unsigned int cnt,
char delimiter);
414 void format_csv_output_header(
char delimiter,
const std::string& comment_string);
417 std::string format_csv_val(std::string val,
char delimiter,
bool initial =
false);
420 std::string format_csv_val(
double val,
char delimiter,
bool initial =
false);
566 #endif // BALANCE_HH_ UnitSI units_
Units of conserved quantities.
unsigned int n_loc_dofs_par_
Allocation parameters. Set by the allocate method used in the lazy_initialize.
std::vector< double > integrated_sources_
std::vector< double > sum_fluxes_out_
LongIdx get_boundary_edge_uid(SideIter side)
TimeMark::Type output_mark_type_
TimeMark type for output of particular equation.
TimeMark::Type balance_output_type_
TimeMark type for balance output of particular equation.
unsigned int side_idx() const
Returns local index of the side on the element.
bool initial_
true before calculating the mass at initial time, otherwise false
void start_mass_assembly(std::vector< unsigned int > q_idx_vec)
Variant of the start_mass_assembly() method for a set of quantities.
std::vector< std::vector< double > > sources_in_
void finish_mass_assembly(std::vector< unsigned int > q_idx_vec)
Variant of the finish_mass_assembly() method for a set of quantities.
std::vector< std::vector< double > > fluxes_in_
std::vector< double > sum_fluxes_in_
std::vector< std::vector< double > > fluxes_out_
const TimeGovernor * time_
Mat * region_source_rhs_
Matrices for calculation of signed source (n_dofs x n_bulk_regions).
Input::Record input_record_
Record for current balance.
Cell accessor allow iterate over DOF handler cells.
bool cumulative() const
Getter for cumulative_.
bool allocation_done_
true before allocating necessary internal structures (Petsc matrices etc.)
Basic time management functionality for unsteady (and steady) solvers (class Equation).
std::vector< double > sum_fluxes_
string name_
Name of quantity (for output).
bool balance_on_
If the balance is on. Balance is off in the case of no balance output time marks. ...
std::vector< double > increment_sources_
const unsigned int index_
Internal index within list of quantities.
Vec * be_flux_vec_
Vectors for calculation of flux (n_boundary_edges).
std::vector< double > integrated_fluxes_
std::vector< Quantity > quantities_
Names of conserved quantities.
std::vector< std::vector< double > > sources_out_
Mat * be_flux_matrix_
Matrices for calculation of flux (n_boundary_edges x n_dofs).
double last_time_
time of last calculated balance
std::vector< std::vector< double > > fluxes_
std::ofstream output_
Handle for file for output in given OutputFormat of balance and total fluxes over individual regions ...
void finish_flux_assembly(std::vector< unsigned int > q_idx_vec)
Variant of the finish_flux_assembly() method for a set of quantities.
void start_flux_assembly(std::vector< unsigned int > q_idx_vec)
Variant of the start_flux_assembly() method for a set of quantities.
Provides the numbering of the finite element degrees of freedom on the computational mesh...
Mat * region_mass_matrix_
Matrices for calculation of mass (n_dofs x n_bulk_regions).
std::vector< double > sum_sources_out_
unsigned int max_dofs_per_boundary_
bool cumulative_
if true then cumulative balance is computed
unsigned int n_loc_dofs_seq_
Mat * region_source_matrix_
Matrices for calculation of source (n_dofs x n_bulk_regions).
std::vector< double > increment_fluxes_
void finish_source_assembly(std::vector< unsigned int > q_idx_vec)
Variant of the finish_source_assembly() method for a set of quantities.
static bool do_yaml_output_
Dedicated class for storing path to input and output files.
int LongIdx
Define type that represents indices of large arrays (elements, nodes, dofs etc.)
std::vector< double > sum_sources_
std::vector< double > initial_mass_
Quantity(const unsigned int index, const string &name)
std::ofstream output_yaml_
std::vector< unsigned int > be_regions_
Maps local boundary edge to its region boundary index.
OutputFormat output_format_
Format of output file.
std::unordered_map< LongIdx, unsigned int > be_id_map_
int be_offset_
Offset for local part of vector of boundary edges.
std::vector< std::vector< double > > masses_
void start_source_assembly(std::vector< unsigned int > q_idx_vec)
Variant of the start_source_assembly() method for a set of quantities.
unsigned int elem_idx() const
Returns index of element in Mesh::element_vec_.
std::vector< double > sum_masses_
Vec * region_mass_vec_
Vectors for calculation of mass (n_bulk_regions).
unsigned int output_line_counter_
hold count of line printed into output_
bool add_output_times_
Add output time marks to balance output time marks.
Class for representation SI units of Fields.
arma::Col< Idx > LocDofVec
Side accessor allows to iterate over sides of DOF handler cell.
FilePath balance_output_file_
File path for output_ stream.
std::string file_prefix_
Save prefix passed in in constructor.
bool output_yaml_header_
marks whether YAML output has printed header
std::vector< double > sum_sources_in_