1 #ifndef MASS_BALANCE_HH_
2 #define MASS_BALANCE_HH_
91 Quantity(
const unsigned int index,
const string &name)
128 Balance(
const std::string &file_prefix,
161 void allocate(
unsigned int n_loc_dofs,
unsigned int max_dofs_per_boundary);
172 for (
auto idx : q_idx_vec)
185 for (
auto idx : q_idx_vec)
198 for (
auto idx : q_idx_vec)
211 unsigned int region_idx,
224 unsigned int elem_idx,
237 unsigned int region_idx,
248 unsigned int elem_idx,
260 unsigned int region_idx,
270 for (
auto idx : q_idx_vec)
280 for (
auto idx : q_idx_vec)
290 for (
auto idx : q_idx_vec)
345 const Vec &solution);
353 const Vec &solution);
374 void output_csv(
double time,
char delimiter,
const std::string& comment_string,
unsigned int repeat = 0);
383 std::string
format_csv_val(std::string val,
char delimiter,
bool initial =
false);
386 std::string
format_csv_val(
double val,
char delimiter,
bool initial =
false);
492 #endif // MASS_BALANCE_HH_
UnitSI units_
Units of conserved quantities.
void calculate_cumulative_sources(unsigned int quantity_idx, const Vec &solution, double dt)
std::vector< double > integrated_sources_
unsigned int add_quantity(const string &name)
std::vector< double > sum_fluxes_out_
void calculate_mass(unsigned int quantity_idx, const Vec &solution, vector< double > &output_array)
void allocate(unsigned int n_loc_dofs, unsigned int max_dofs_per_boundary)
double initial_time_
initial time
void calculate_cumulative_fluxes(unsigned int quantity_idx, const Vec &solution, double dt)
void finish_source_assembly(unsigned int quantity_idx)
This method must be called after assembling the matrix and vectors for computing source.
bool initial_
true before calculating the mass at initial time, otherwise false
void add_flux_vec_value(unsigned int quantity_idx, unsigned int elem_idx, double value)
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_
static Input::Type::Record input_type
Main balance input record type.
void add_cumulative_source(unsigned int quantity_idx, double source)
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_
Balance(const std::string &file_prefix, const Mesh *mesh, const Distribution *el_ds, const int *el_4_loc, const Input::Record &in_rec)
Vec ones_
auxiliary vectors for summation of matrix columns
Mat * region_source_rhs_
Matrices for calculation of signed source (n_dofs x n_bulk_regions).
void add_mass_matrix_values(unsigned int quantity_idx, unsigned int region_idx, const std::vector< int > &dof_indices, const std::vector< double > &values)
ofstream output_
Handle for file for output of balance and total fluxes over individual regions and region sets...
bool cumulative() const
Getter for cumulative_.
void output_legacy(double time)
Perform output in old format (for compatibility)
bool allocation_done_
true before allocating necessary internal structures (Petsc matrices etc.)
const RegionDB & regions_
Database of bulk and boundary regions.
std::vector< double > sum_fluxes_
string name_
Name of quantity (for output).
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::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...
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
void calculate_mass(unsigned int quantity_idx, const Vec &solution)
void add_source_rhs_values(unsigned int quantity_idx, unsigned int region_idx, const std::vector< int > &dof_values, const std::vector< double > &values)
std::vector< std::vector< double > > fluxes_
void calculate_source(unsigned int quantity_idx, const Vec &solution)
void add_flux_matrix_values(unsigned int quantity_idx, unsigned int elem_idx, const std::vector< int > &dof_indices, const std::vector< double > &values)
void finish_mass_assembly(unsigned int quantity_idx)
This method must be called after assembling the matrix for computing mass.
void finish_flux_assembly(std::vector< unsigned int > q_idx_vec)
Variant of the finish_flux_assembly() method for a set of quantities.
void calculate_flux(unsigned int quantity_idx, const Vec &solution)
void format_csv_output_header(char delimiter, const std::string &comment_string)
Print output header.
void start_flux_assembly(std::vector< unsigned int > q_idx_vec)
Variant of the start_flux_assembly() method for a set of quantities.
Mat * region_mass_matrix_
Matrices for calculation of mass (n_dofs x n_bulk_regions).
std::vector< std::vector< double > > sources_
std::vector< double > sum_sources_out_
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 > 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.
void output_csv(double time, char delimiter, const std::string &comment_string, unsigned int repeat=0)
Perform output in csv format.
std::vector< unsigned int > add_quantities(const std::vector< string > &names)
Support classes for parallel programing.
std::vector< double > sum_sources_
void start_flux_assembly(unsigned int quantity_idx)
std::vector< double > initial_mass_
static const unsigned int output_column_width
Size of column in output (used if delimiter is space)
Quantity(const unsigned int index, const string &name)
void finish_flux_assembly(unsigned int quantity_idx)
This method must be called after assembling the matrix and vector for computing flux.
std::vector< unsigned int > be_regions_
Number of boundary region for each local boundary edge.
OutputFormat output_format_
Format of output file.
Classes for storing substance data.
void units(const UnitSI &unit)
Setter for units of conserved quantities.
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.
Vec * region_source_vec_
Vectors for calculation of source (n_bulk_regions).
void start_mass_assembly(unsigned int quantity_idx)
std::vector< double > sum_masses_
unsigned int output_line_counter_
hold count of line printed into output_
void output(double time)
Perform output to file for given time instant.
Class for representation SI units of Fields.
void add_source_matrix_values(unsigned int quantity_idx, unsigned int region_idx, const std::vector< int > &dof_indices, const std::vector< double > &values)
void undef(bool val=true)
void start_source_assembly(unsigned int quantity_idx)
static Input::Type::Selection format_selection_input_type
Input selection for file format.
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.
std::vector< double > sum_sources_in_