18 #include <boost/foreach.hpp> 46 "Linear isotherm runs the concentration exchange between liquid and solid.")
48 "Langmuir isotherm runs the concentration exchange between liquid and solid.")
50 "Freundlich isotherm runs the concentration exchange between liquid and solid.")
57 return Record(
"SorptionAux",
"AUXILIARY RECORD. Should not be directly part of the input tree.")
59 "Names of the substances that take part in the sorption model.")
61 "Density of the solvent.")
63 "Number of equidistant substeps, molar mass and isotherm intersections")
65 "Specifies solubility limits of all the sorbing species.")
67 "Specifies the highest aqueous concentration in the isotherm function interpolation table. " 68 "Use any negative value for an automatic choice according to current maximal concentration (default and recommended). " 69 "Use '0' to always evaluate isotherm function directly (can be very slow). " 70 "Use a positive value to set the interpolation table limit manually " 71 "(if aqueous concentration is higher, then the isotherm function is evaluated directly).")
73 "Containes region specific data necessary to construct isotherms.")
82 ADD_FIELD(rock_density,
"Rock matrix density.",
"0.0");
83 rock_density.units(
UnitSI().kg().m(-3) );
85 ADD_FIELD(sorption_type,
"Considered sorption is described by selected isotherm. If porosity on an element is equal or even higher than 1.0 (meaning no sorbing surface), then type 'none' will be selected automatically.");
86 sorption_type.input_selection(get_sorption_type_selection());
89 ADD_FIELD(distribution_coefficient,
"Multiplication parameters (k, omega) in either Langmuir c_s = omega * (alpha*c_a)/(1- alpha*c_a) or in linear c_s = k * c_a isothermal description.",
"1.0");
90 distribution_coefficient.units(
UnitSI().m(3).kg(-1) );
92 ADD_FIELD(isotherm_other,
"Second parameters (alpha, ...) defining isotherm c_s = omega * (alpha*c_a)/(1- alpha*c_a).",
"1.0");
95 ADD_FIELD(init_conc_solid,
"Initial solid concentration of substances." 96 " Vector, one value for every substance.",
"0");
97 init_conc_solid.units(
UnitSI().mol().kg(-1) );
99 input_data_set_ += *
this;
109 output_fields += *
this;
183 for(
unsigned int i_reg = 0; i_reg < nr_of_regions; i_reg++)
187 for(
unsigned int i_subst = 0; i_subst <
n_substances_; i_subst++)
216 .set_time_governor(*
time_);
223 .set_time_governor(*
time_);
232 unsigned int k, global_idx, i_subst = 0;
236 for(; spec_iter != substances_array.
end(); ++spec_iter, i_subst++)
251 THROW(ReactionTerm::ExcUnknownSubstance()
252 << ReactionTerm::EI_Substance(*spec_iter)
289 THROW(SorptionBase::ExcSubstanceCountMatch()
290 << SorptionBase::EI_ArrayName(
"solubility")
305 if( interp_table_limits )
309 THROW(SorptionBase::ExcSubstanceCountMatch()
310 << SorptionBase::EI_ArrayName(
"table_limits")
332 substances_sorption.push_back(
substances_[i].name());
365 std::stringstream ss;
444 xprintf(
UsrErr,
"Scaling parameter in sorption is not positive. Check the input for rock density and molar mass of %d. substance.",i_subst);
454 for(
unsigned int i_subst = 0; i_subst <
n_substances_; i_subst++)
462 unsigned int reg_idx, i_subst, subst_id;
466 for(reg_idx = 0; reg_idx < nr_of_regions; reg_idx++)
467 for(
unsigned int i_subst = 0; i_subst <
n_substances_; i_subst++)
473 unsigned int reg_idx, i_subst, subst_id;
495 int reg_idx = reg_iter.bulk_idx();
508 for(
unsigned int i_subst = 0; i_subst <
n_substances_; i_subst++){
512 isotherms[reg_idx][i_subst].clear_table();
518 bool call_make_table = call_reinit;
520 double subst_table_limit =
isotherms[reg_idx][i_subst].table_limit();
525 if(subst_table_limit <
max_conc[reg_idx][i_subst])
527 call_make_table =
true;
528 subst_table_limit = 2*
max_conc[reg_idx][i_subst];
556 unsigned int i_subst, subst_id;
558 bool is_common_ele_data_valid =
false;
572 if(! is_common_ele_data_valid){
574 is_common_ele_data_valid =
true;
594 return concentrations;
607 for (sbi = 0; sbi < n_subst; sbi++) {
void output_type(OutputTime::DiscreteSpace rt)
unsigned int size() const
get global size
std::shared_ptr< ReactionTerm > reaction_solid
void allocate_output_mpi(void)
Allocates petsc vectors, prepares them for output and creates vector scatter.
MultiField< 3, FieldValue< 3 >::Scalar > conc_solid
Calculated sorbed concentrations, for output only.
RegionSet get_region_set(const std::string &set_name) const
std::vector< VectorSeqDouble > conc_solid_out
sorbed concentration array output (gathered - sequential)
void compute(double &c_aqua, double &c_sorbed)
std::vector< std::vector< Isotherm > > isotherms
virtual ~SorptionBase(void)
void initialize_substance_ids()
Reads names of substances from input and creates indexing to global vector of substance.
double ** concentration_matrix_
unsigned int bulk_size() const
const std::vector< std::string > & names()
EqData(const string &output_field_name)
Collect all fields.
void output(TimeStep step)
SubstanceList substances_
Names belonging to substances.
void zero_time_step() override
EquationOutput output_fields
Fields indended for output, i.e. all input fields plus those representing solution.
static const Input::Type::Selection & get_sorption_type_selection()
void chkerr(unsigned int ierr)
Replacement of new/delete operator in the spirit of xmalloc.
const RegionDB & region_db() const
const TimeStep & step(int index=-1) const
std::vector< double > table_limit_
static Input::Type::Abstract & it_abstract_reaction()
#define ADD_FIELD(name,...)
void reinit(enum SorptionType sorption_type, bool limited_solubility_on, double aqua_density, double scale_aqua, double scale_sorbed, double c_aqua_limit, double mult_coef, double second_coef)
unsigned int size() const
virtual ElementAccessor< 3 > element_accessor(unsigned int idx) const
Create and return ElementAccessor to element of given idx.
std::shared_ptr< OutputTime > output_stream_
Pointer to a transport output stream.
ReactionTerm(Mesh &init_mesh, Input::Record in_rec)
Constructor.
Class ReactionTerm is an abstract class representing reaction term in transport.
std::vector< unsigned int > substance_global_idx_
Mapping from local indexing of substances to global.
void initialize_fields()
Initializes field sets.
void isotherm_reinit(unsigned int i_subst, const ElementAccessor< 3 > &elm)
Reinitializes the isotherm.
Class Dual_por_exchange implements the model of dual porosity.
arma::vec::fixed< spacedim > centre() const
Computes the barycenter.
MultiField< 3, FieldValue< 3 >::Scalar > isotherm_other
Langmuir sorption coeficients alpha (in fraction c_s = omega * (alpha*c_a)/(1- alpha*c_a)).
double no_sorbing_surface_cond
Distribution * distribution_
Pointer to reference to distribution of elements between processors.
static constexpr Mask equation_result
Match result fields. These are never given by input or copy of input.
void output_data(void) override
Output method.
static constexpr Mask input_copy
Vec * vconc_solid
PETSC sorbed concentration vector (parallel).
std::vector< std::shared_ptr< FieldFE< 3, FieldValue< 3 >::Scalar > > > output_field_ptr
Fields correspond with conc_solid_out.
MultiField< 3, FieldValue< 3 >::Scalar > init_conc_solid
Initial sorbed concentrations.
void initialize_from_input()
Initializes private members of sorption from the input record.
std::vector< double > solubility_vec_
unsigned int n_interpolation_steps_
#define START_TIMER(tag)
Starts a timer with specified tag.
#define OLD_ASSERT_LESS(a, b)
void update_max_conc()
Computes maximal aqueous concentration at the current step.
virtual void compute_common_ele_data(const ElementAccessor< 3 > &elem)=0
MultiField< 3, FieldValue< 3 >::Enum > sorption_type
Discrete need Selection for initialization.
void output_vector_gather(void) override
Gathers all the parallel vectors to enable them to be output.
void update_solution(void) override
Updates the solution.
SorptionType
Type of adsorption isotherm.
double ** compute_reaction(double **concentrations, int loc_el) override
Support classes for parallel programing.
void set_input_list(Input::Array input_list, const TimeGovernor &tg)
virtual unsigned int n_elements(bool boundary=false) const
Returns count of boundary or bulk elements.
Class SorptionBase is abstract class representing model of sorption in transport. ...
void interpolate(double &c_aqua, double &c_sorbed)
void initialize(std::shared_ptr< OutputTime > stream, Mesh *mesh, Input::Record in_rec, const TimeGovernor &tg)
Input::Record input_record_
void set_components(const std::vector< string > &names)
void set_initial_condition()
Reads and sets initial condition for concentration in solid.
LongIdx * row_4_el_
Indices of rows belonging to elements.
bool set_time(const TimeStep &time, LimitSide limit_side)
bool is_constant(Region reg) const
unsigned int bulk_idx() const
Returns index of the region in the bulk set.
#define WarningOut()
Macro defining 'warning' record of log.
#define END_TIMER(tag)
Ends a timer with specified tag.
void clear_max_conc()
Sets max conc to zeros on all regins.
bool is_precomputed(void)
void set_mesh(const Mesh &mesh)
void set_components(const std::vector< string > &names)
static const Input::Type::Record & get_input_type()
VecScatter vconc_out_scatter
Output vector scatter.
bool is_field_output_time(const FieldCommon &field, TimeStep step) const
void isotherm_reinit_all(const ElementAccessor< 3 > &elm)
Calls isotherm_reinit for all isotherms.
Base of exceptions used in Flow123d.
MultiField< 3, FieldValue< 3 >::Scalar > distribution_coefficient
Multiplication coefficients (k, omega) for all types of isotherms.
LongIdx * el_4_loc_
Indices of elements belonging to local dofs.
unsigned int n_substances_
Class for representation SI units of Fields.
EqData * data_
Pointer to equation data. The object is constructed in descendants.
static UnitSI & dimensionless()
Returns dimensionless unit.
static bool print_message_table(ostream &stream, std::string equation_name)
std::vector< std::vector< double > > max_conc
Other possible transformation of coordinates:
#define THROW(whole_exception_expr)
Wrapper for throw. Saves the throwing point.
Input::Type::Record make_field_descriptor_type(const std::string &equation_name) const
struct SorptionBase::CommonElementData common_ele_data
FieldSet input_data_set_
Input data set - fields in this set are read from the input file.
std::shared_ptr< ReactionTerm > reaction_liquid
unsigned int lsize(int proc) const
get local size
void initialize() override
Prepares the object to usage.