1 #include <boost/foreach.hpp>
27 "Linear isotherm runs the concentration exchange between liquid and solid.")
29 "Langmuir isotherm runs the concentration exchange between liquid and solid.")
31 "Freundlich isotherm runs the concentration exchange between liquid and solid.");
36 =
Record(
"Sorption",
"AUXILIARY RECORD. Should not be directly part of the input tree.")
38 "Names of the substances that take part in the sorption model.")
40 "Density of the solvent.")
42 "Number of equidistant substeps, molar mass and isotherm intersections")
44 "Specifies solubility limits of all the sorbing species.")
46 "Specifies highest aqueous concentration in interpolation table.")
48 "Containes region specific data necessary to construct isotherms.")
55 ADD_FIELD(rock_density,
"Rock matrix density.",
"0.0");
56 rock_density.units(
UnitSI().kg().m(-3) );
58 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.");
59 sorption_type.input_selection(&sorption_type_selection);
62 ADD_FIELD(isotherm_mult,
"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");
63 isotherm_mult.units(
UnitSI().mol().kg(-1) );
65 ADD_FIELD(isotherm_other,
"Second parameters (alpha, ...) defining isotherm c_s = omega * (alpha*c_a)/(1- alpha*c_a).",
"1.0");
68 ADD_FIELD(init_conc_solid,
"Initial solid concentration of substances."
69 " Vector, one value for every substance.",
"0");
70 init_conc_solid.units(
UnitSI().mol().kg(-1) );
72 input_data_set_ += *
this;
81 output_fields += *
this;
82 output_fields += conc_solid.name(output_field_name).units(
UnitSI().kg().m(-3) );
90 case SorptionRecord::mobile:
91 rec =
IT::Record(
"SorptionMobile",
"Sorption model in the mobile zone, following the dual porosity model.")
94 .
declare_key(
"output_fields",
IT::Array(make_output_selection(
"conc_solid",
"SorptionMobile_Output")),
95 IT::Default(
"conc_solid"),
"List of fields to write to output stream.");
97 case SorptionRecord::immobile:
98 rec =
IT::Record(
"SorptionImmobile",
"Sorption model in the immobile zone, following the dual porosity model.")
101 .
declare_key(
"output_fields",
IT::Array(make_output_selection(
"conc_immobile_solid",
"SorptionImmobile_Output")),
102 IT::Default(
"conc_immobile_solid"),
"List of fields to write to output stream.");
106 rec =
IT::Record(
"Sorption",
"Sorption model in the reaction term of transport.")
109 .
declare_key(
"output_fields",
IT::Array(make_output_selection(
"conc_solid",
"Sorption_Output")),
110 IT::Default(
"conc_solid"),
"List of fields to write to output stream.");
157 THROW( ReactionTerm::ExcWrongDescendantModel()
158 << ReactionTerm::EI_Model((*reactions_it).type().type_name())
159 << (*reactions_it).ei_address());
162 THROW( ReactionTerm::ExcWrongDescendantModel()
163 << ReactionTerm::EI_Model((*reactions_it).type().type_name())
164 << (*reactions_it).ei_address());
167 {
THROW( ReactionTerm::ExcWrongDescendantModel()
168 << ReactionTerm::EI_Model((*reactions_it).type().type_name())
169 << EI_Message(
"This model is not currently supported!")
170 << (*reactions_it).ei_address());
174 << EI_Message(
"Descending model type selection failed (SHOULD NEVER HAPPEN).")
175 << (*reactions_it).ei_address());
192 THROW( ReactionTerm::ExcWrongDescendantModel()
193 << ReactionTerm::EI_Model((*reactions_it).type().type_name())
194 << (*reactions_it).ei_address());
197 THROW( ReactionTerm::ExcWrongDescendantModel()
198 << ReactionTerm::EI_Model((*reactions_it).type().type_name())
199 << (*reactions_it).ei_address());
202 {
THROW( ReactionTerm::ExcWrongDescendantModel()
203 << ReactionTerm::EI_Model((*reactions_it).type().type_name())
204 << EI_Message(
"This model is not currently supported!")
205 << (*reactions_it).ei_address());
209 << EI_Message(
"Descending model type selection failed (SHOULD NEVER HAPPEN).")
210 << (*reactions_it).ei_address());
221 ASSERT(
time_ !=
nullptr,
"Time governor has not been set yet.\n");
231 for(
unsigned int i_reg = 0; i_reg < nr_of_regions; i_reg++)
234 for(
unsigned int i_subst = 0; i_subst <
n_substances_; i_subst++)
277 unsigned int k, global_idx, i_subst = 0;
281 for(; spec_iter != substances_array.
end(); ++spec_iter, i_subst++)
296 THROW(ReactionTerm::ExcUnknownSubstance()
297 << ReactionTerm::EI_Substance(*spec_iter)
334 THROW(SorptionBase::ExcSubstanceCountMatch()
335 << SorptionBase::EI_ArrayName(
"solubility")
350 if( interp_table_limits )
354 THROW(SorptionBase::ExcSubstanceCountMatch()
355 << SorptionBase::EI_ArrayName(
"table_limits")
371 ASSERT(
n_substances_ > 0,
"Number of substances is wrong, they might have not been set yet.\n");
400 ASSERT(
time_ !=
nullptr,
"Time governor has not been set yet.\n");
470 for(
unsigned int i_subst = 0; i_subst <
n_substances_; i_subst++)
487 int reg_idx = elem->region().bulk_idx();
488 unsigned int i_subst, subst_id;
495 if (isotherms_vec[0].is_precomputed())
523 return concentrations;
536 for (sbi = 0; sbi < n_subst; sbi++) {
void output_type(OutputTime::DiscreteSpace rt)
unsigned int size() const
get global size
void set_input_list(Input::Array input_list)
virtual void zero_time_step()
void allocate_output_mpi(void)
Allocates petsc vectors, prepares them for output and creates vector scatter.
void set_limit_side(LimitSide side)
MultiField< 3, FieldValue< 3 >::Scalar > conc_solid
Calculated sorbed concentrations, for output only.
OutputTime * output_stream_
Pointer to a transport output stream.
std::vector< VectorSeqDouble > conc_solid_out
sorbed concentration array output (gathered - sequential)
ReactionTerm * reaction_liquid
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()
virtual void initialize()
Initialize fields.
void add_admissible_field_names(const Input::Array &in_array)
Registers names of output fields that can be written using this stream.
EqData(const string &output_field_name)
Collect all fields.
double ** compute_reaction(double **concentrations, int loc_el)
SubstanceList substances_
Names belonging to substances.
void zero_time_step() override
void set_time(const TimeStep &time)
static Input::Type::Record input_type
RegionSet get_region_set(const string &set_name) const
int * row_4_el_
Indices of rows belonging to elements.
const RegionDB & region_db() const
static Input::Type::Record input_type
Input record for class FirstOrderReaction.
ElementAccessor< 3 > element_accessor(unsigned int idx, bool boundary=false)
static Input::Type::Selection sorption_type_selection
Field< 3, FieldValue< 3 >::Vector > init_conc_solid
Initial sorbed concentrations.
const TimeStep & step(int index=-1) const
std::vector< double > table_limit_
#define ADD_FIELD(name,...)
unsigned int size() const
std::vector< unsigned int > substance_global_idx_
Mapping from local indexing of substances to global.
void initialize_fields()
Initializes field sets.
static Input::Type::AbstractRecord input_type
static Input::Type::Record input_type
unsigned int n_elements() const
Distribution * distribution_
Pointer to reference to distribution of elements between processors.
void output_data(void) override
Output method.
static constexpr Mask input_copy
A field that is input of its equation and can not read from input, thus must be set by copy...
Vec * vconc_solid
PETSC sorbed concentration vector (parallel).
FieldSet output_fields
Fields indended for output, i.e. all input fields plus those representing solution.
void initialize_from_input()
Initializes private members of sorption from the input record.
std::vector< double > solubility_vec_
Class implements the radioactive decay chain.
unsigned int n_interpolation_steps_
#define ASSERT_LESS(a, b)
#define START_TIMER(tag)
Starts a timer with specified tag.
virtual void isotherm_reinit(std::vector< Isotherm > &isotherms, const ElementAccessor< 3 > &elm)=0
Reinitializes the isotherm.
virtual Value::return_type const & value(const Point &p, const ElementAccessor< spacedim > &elm) const
ReactionTerm * reaction_solid
static Input::Type::Record input_type
static Input::Type::Record record_factory(SorptionRecord::Type)
Creates the input record for different cases of sorption model (simple or in dual porosity)...
void output_vector_gather(void) override
Gathers all the parallel vectors to enable them to be output.
Input::Array output_array
void update_solution(void) override
Updates the solution.
void * xmalloc(size_t size)
Memory allocation with checking.
virtual void set_time_governor(TimeGovernor &time)
Support classes for parallel programing.
virtual void update_solution()
void output(OutputTime *stream)
Input::Record input_record_
void set_components(const std::vector< string > &names)
int * el_4_loc_
Indices of elements belonging to local dofs.
void set_initial_condition()
Reads and sets initial condition for concentration in solid.
bool is_constant(Region reg) const
unsigned int bulk_idx() const
Returns index of the region in the bulk set.
#define END_TIMER(tag)
Ends a timer with specified tag.
static Input::Type::Record input_type
Input record for class RadioactiveDecay.
arma::vec::fixed< spacedim > centre() const
void set_mesh(const Mesh &mesh)
void set_components(const std::vector< string > &names)
VecScatter vconc_out_scatter
Output vector scatter.
Base of exceptions used in Flow123d.
Class implements the linear reactions.
unsigned int n_substances_
Class for representation SI units of Fields.
#define MPI_Barrier(comm)
EqData * data_
Pointer to equation data. The object is constructed in descendants.
static UnitSI & dimensionless()
Returns dimensionless unit.
#define THROW(whole_exception_expr)
Wrapper for throw. Saves the throwing point.
ReactionTerm & concentration_matrix(double **concentration, Distribution *conc_distr, int *el_4_loc, int *row_4_el)
ReactionTerm & substances(SubstanceList &substances)
Sets the names of substances considered in transport.
ElementVector element
Vector of elements of the mesh.
FieldSet input_data_set_
Input data set - fields in this set are read from the input file.
unsigned int lsize(int proc) const
get local size
void initialize() override
Prepares the object to usage.