25 #include <unordered_map>
130 Quantity(
const unsigned int index,
const string &name)
167 Balance(
const std::string &file_prefix,
const Mesh *mesh);
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);
235 for (
auto idx : q_idx_vec)
248 for (
auto idx : q_idx_vec)
261 for (
auto idx : q_idx_vec)
314 unsigned int region_idx,
326 for (
auto idx : q_idx_vec)
336 for (
auto idx : q_idx_vec)
346 for (
auto idx : q_idx_vec)
358 const Vec &solution);
376 const Vec &solution);
405 void output_csv(
double time,
char delimiter,
const std::string& comment_string,
unsigned int repeat = 0);
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);
Quantity(const unsigned int index, const string &name)
string name_
Name of quantity (for output).
const unsigned int index_
Internal index within list of quantities.
std::vector< double > sum_fluxes_in_
OutputFormat output_format_
Format of output file.
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.
void start_source_assembly(std::vector< unsigned int > q_idx_vec)
Variant of the start_source_assembly() method for a set of quantities.
void allocate(const std::shared_ptr< DOFHandlerMultiDim > &dh, unsigned int max_dofs_per_boundary)
void calculate_instant(unsigned int quantity_idx, const Vec &solution)
bool balance_on_
If the balance is on. Balance is off in the case of no balance output time marks.
void start_mass_assembly(std::vector< unsigned int > q_idx_vec)
Variant of the start_mass_assembly() method for a set of quantities.
unsigned int n_loc_dofs_seq_
double last_time_
time of last calculated balance
void add_source_values(unsigned int quantity_idx, unsigned int region_idx, const LocDofVec &loc_dof_indices, const std::vector< double > &mult_mat_values, const std::vector< double > &add_mat_values)
TimeMark::Type balance_output_type_
TimeMark type for balance output of particular equation.
bool is_current()
Returns true if the current time step is marked for the balance output.
void output_yaml(double time)
Perform output in yaml format.
unsigned int n_loc_dofs_par_
Allocation parameters. Set by the allocate method used in the lazy_initialize.
Mat * be_flux_matrix_
Matrices for calculation of flux (n_boundary_edges x n_dofs).
std::vector< double > integrated_sources_
std::vector< unsigned int > be_regions_
Maps local boundary edge to its region boundary index.
unsigned int max_dofs_per_boundary_
Mat * region_source_rhs_
Matrices for calculation of signed source (n_dofs x n_bulk_regions).
void calculate_cumulative(unsigned int quantity_idx, const Vec &solution)
bool cumulative() const
Getter for cumulative_.
void start_source_assembly(unsigned int quantity_idx)
std::string file_prefix_
Save prefix passed in in constructor.
static const Input::Type::Record & get_input_type()
Main balance input record type.
std::vector< double > integrated_fluxes_
std::unordered_map< LongIdx, unsigned int > be_id_map_
void finish_source_assembly(std::vector< unsigned int > q_idx_vec)
Variant of the finish_source_assembly() method for a set of quantities.
void start_mass_assembly(unsigned int quantity_idx)
std::ofstream output_
Handle for file for output in given OutputFormat of balance and total fluxes over individual regions ...
std::vector< double > sum_fluxes_
static const Input::Type::Selection & get_format_selection_input_type()
Input selection for file format.
std::vector< double > sum_sources_
std::vector< std::vector< double > > masses_
void output()
Perform output to file for given time instant.
void units(const UnitSI &unit)
Setter for units of conserved quantities.
static bool do_yaml_output_
void calculate_mass(unsigned int quantity_idx, const Vec &solution, vector< double > &output_array)
TimeMark::Type output_mark_type_
TimeMark type for output of particular equation.
std::vector< std::vector< double > > fluxes_in_
void format_csv_output_header(char delimiter, const std::string &comment_string)
Print output header.
void finish_flux_assembly(std::vector< unsigned int > q_idx_vec)
Variant of the finish_flux_assembly() method for a set of quantities.
Balance(const std::string &file_prefix, const Mesh *mesh)
bool initial_
true before calculating the mass at initial time, otherwise false
std::vector< std::vector< double > > fluxes_out_
Vec * region_mass_vec_
Vectors for calculation of mass (n_bulk_regions).
void init_from_input(const Input::Record &in_rec, TimeGovernor &tg)
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,...
Input::Record input_record_
Record for current balance.
std::vector< std::vector< double > > fluxes_
void finish_source_assembly(unsigned int quantity_idx)
This method must be called after assembling the matrix and vectors for computing source.
const TimeGovernor * time_
Vec * be_flux_vec_
Vectors for calculation of flux (n_boundary_edges).
std::vector< std::vector< double > > sources_out_
std::ofstream output_yaml_
FilePath balance_output_file_
File path for output_ stream.
bool allocation_done_
true before allocating necessary internal structures (Petsc matrices etc.)
std::vector< std::vector< double > > sources_in_
void add_cumulative_source(unsigned int quantity_idx, double source)
void output_csv(double time, char delimiter, const std::string &comment_string, unsigned int repeat=0)
Perform output in csv format.
unsigned int output_line_counter_
hold count of line printed into output_
Mat * region_mass_matrix_
Matrices for calculation of mass (n_dofs x n_bulk_regions).
std::vector< Quantity > quantities_
Names of conserved quantities.
void output_legacy(double time)
Perform output in old format (for compatibility)
void finish_mass_assembly(unsigned int quantity_idx)
This method must be called after assembling the matrix for computing mass.
bool output_yaml_header_
marks whether YAML output has printed header
bool add_output_times_
Add output time marks to balance output time marks.
UnitSI units_
Units of conserved quantities.
std::vector< double > increment_sources_
bool cumulative_
if true then cumulative balance is computed
Mat * region_source_matrix_
Matrices for calculation of source (n_dofs x n_bulk_regions).
std::vector< double > sum_fluxes_out_
static void set_yaml_output()
Set global variable to output balance files into YAML format (in addition to the table format).
void start_flux_assembly(unsigned int quantity_idx)
void add_flux_values(unsigned int quantity_idx, const DHCellSide &side, const LocDofVec &loc_dof_indices, const std::vector< double > &mat_values, double vec_value)
void start_flux_assembly(std::vector< unsigned int > q_idx_vec)
Variant of the start_flux_assembly() method for a set of quantities.
void finish_mass_assembly(std::vector< unsigned int > q_idx_vec)
Variant of the finish_mass_assembly() method for a set of quantities.
void finish_flux_assembly(unsigned int quantity_idx)
This method must be called after assembling the matrix and vector for computing flux.
std::vector< double > sum_masses_
int be_offset_
Offset for local part of vector of boundary edges.
std::vector< double > initial_mass_
std::vector< double > sum_sources_in_
void add_mass_values(unsigned int quantity_idx, const DHCellAccessor &dh_cell, const LocDofVec &loc_dof_indices, const std::vector< double > &mat_values, double vec_value)
std::vector< double > increment_fluxes_
std::vector< unsigned int > add_quantities(const std::vector< string > &names)
std::vector< double > sum_sources_out_
static const unsigned int output_column_width
Size of column in output (used if delimiter is space)
unsigned int add_quantity(const string &name)
LongIdx get_boundary_edge_uid(SideIter side)
Cell accessor allow iterate over DOF handler cells.
Side accessor allows to iterate over sides of DOF handler cell.
Provides the numbering of the finite element degrees of freedom on the computational mesh.
Dedicated class for storing path to input and output files.
unsigned int elem_idx() const
Returns index of element in Mesh::element_vec_.
unsigned int side_idx() const
Returns local index of the side on the element.
Basic time management functionality for unsteady (and steady) solvers (class Equation).
Class for representation SI units of Fields.
arma::Col< IntIdx > LocDofVec
int LongIdx
Define type that represents indices of large arrays (elements, nodes, dofs etc.)