56 Input::register_class< ConvectionTransport, Mesh &, const Input::Record >(
"Convection_FV") +
61 return IT::Record(
"Convection_FV",
"Explicit in time finite volume method for solute transport.")
64 EqData().make_field_descriptor_type(
"Convection_FV")),
71 .make_output_field_selection(
72 "ConvectionTransport_output_fields",
73 "Selection of output fields for Convection Solute Transport model.")
76 "List of fields to write to output file.")
84 "ConvectionTransport_output_fields",
85 "Selection of output fields for Convection Solute Transport model.")
201 VecDestroy(&(
vconc[sbi]));
202 VecDestroy(&(
vpconc[sbi]));
245 conc[sbi][index] = value(sbi);
255 unsigned int i, sbi, n_subst;
259 tm_diag =
new double*[n_subst];
261 for (sbi = 0; sbi < n_subst; sbi++) {
267 conc =
new double*[n_subst];
270 for (sbi = 0; sbi < n_subst; sbi++) {
287 int sbi, n_subst, rank, np;
294 vconc =
new Vec[n_subst];
295 vpconc =
new Vec[n_subst];
302 for (sbi = 0; sbi < n_subst; sbi++) {
309 VecZeroEntries(
vconc[sbi]);
310 VecZeroEntries(
vpconc[sbi]);
323 VecZeroEntries(
out_conc[sbi].get_data_petsc());
346 unsigned int sbi, loc_el, loc_b = 0;
354 for (loc_el = 0; loc_el <
el_ds->
lsize(); loc_el++) {
356 if (elm->boundary_idx_ != NULL) {
360 Boundary *b = elm->side(si)->cond();
364 double aij = -(flux / elm->measure() );
368 VecSetValue(
bcvcorr[sbi], new_i, value[sbi] * aij, ADD_VALUES);
382 VecSetValue(
bcvcorr[sbi], new_i, 0, ADD_VALUES);
418 unsigned int loc_el, sbi;
419 double csection, source, diag;
437 for (loc_el = 0; loc_el <
el_ds->
lsize(); loc_el++)
452 source = csection * (src_density(sbi) + src_sigma(sbi) * src_conc(sbi));
456 diag = src_sigma(sbi) * csection;
460 max_cfl = std::max(max_cfl, fabs(diag));
465 {- src_sigma(sbi) * ele->
measure() * csection});
515 bool cfl_changed =
false;
523 DBGMSG(
"CFL changed - flow.\n");
530 DBGMSG(
"CFL changed - mass matrix.\n");
540 DBGMSG(
"CFL changed - source.\n");
548 VecCreateMPI(PETSC_COMM_WORLD,
el_ds->
lsize(),PETSC_DETERMINE, &cfl);
588 DBGMSG(
"BC - rescale dt.\n");
599 DBGMSG(
"SRC - rescale dt.\n");
612 DBGMSG(
"TM - rescale dt.\n");
633 for (
unsigned int sbi = 0; sbi <
n_substances(); sbi++) {
705 for (
unsigned int loc_el = 0; loc_el <
el_ds->
lsize(); loc_el++) {
741 int s, j, np, rank, new_j, new_i;
749 double flux, flux2, edg_flux;
753 for (
unsigned int loc_el = 0; loc_el <
el_ds->
lsize(); loc_el++) {
760 if (elm->side(si)->cond() == NULL) {
761 edg = elm->side(si)->edge();
763 for(
int s=0; s < edg->
n_sides; s++) {
765 if ( flux2 > 0) edg_flux+= flux2;
770 if (edg->
side(s) != elm->side(si)) {
775 if ( flux2 > 0.0 && flux <0.0)
776 aij = -(flux * flux2 / ( edg_flux * elm->measure() ) );
778 MatSetValue(
tm, new_i, new_j, aij, INSERT_VALUES);
782 aii -= (flux / elm->measure() );
793 if (flux > 0.0) aij = flux / elm->measure();
795 MatSetValue(
tm, new_i, new_j, aij, INSERT_VALUES);
800 aii -= (-flux) / elm->measure();
801 aij = (-flux) / el2->measure();
803 MatSetValue(
tm, new_j, new_i, aij, INSERT_VALUES);
806 MatSetValue(
tm, new_i, new_i, aii, INSERT_VALUES);
812 MatAssemblyBegin(
tm, MAT_FINAL_ASSEMBLY);
813 MatAssemblyEnd(
tm, MAT_FINAL_ASSEMBLY);
850 el_distribution_out = this->
el_ds;
void output_type(OutputTime::DiscreteSpace rt)
static const IT::Selection & get_output_selection()
unsigned int size() const
get global size
void set_input_list(Input::Array input_list)
void calculate_instant_balance() override
void set_balance_object(boost::shared_ptr< Balance > balance) override
#define ADD_FIELD(name,...)
std::vector< VectorSeqDouble > out_conc
bool is_mass_diag_changed
Flag indicates that porosity or cross_section changed during last time.
double time_changed() const
void update_solution() override
double end_time() const
End time.
double transport_matrix_time
const std::vector< std::string > & names()
#define FOR_EDGE_SIDES(i, j)
#define FOR_ELEMENTS(_mesh_, __i)
void alloc_transport_vectors()
unsigned int n_substances() override
Returns number of transported substances.
void set_time(const TimeStep &time, LimitSide limit_side)
double fix_dt_until_mark()
Fixing time step until fixed time mark.
MultiField< 3, FieldValue< 3 >::Scalar > conc_mobile
Calculated concentrations in the mobile zone.
void create_mass_matrix()
void next_time()
Proceed to the next time according to current estimated time step.
void initialize() override
std::shared_ptr< OutputTime > output_stream_
TimeMark::Type target_mark_type
TimeMark type for time marks denoting end of every time interval where transport matrix remains const...
TimeMark::Type type_output()
void set_initial_condition()
double transport_bc_time
Time of the last update of the boundary condition terms.
MultiField< 3, FieldValue< 3 >::Scalar > sources_density
Concentration sources - density of substance source, only positive part is used.
void set_boundary_conditions()
RegionSet get_region_set(const string &set_name) const
#define ELEMENT_FULL_ITER(_mesh_, i)
Fields computed from the mesh data.
#define FOR_ELEMENT_SIDES(i, j)
MultiField< 3, FieldValue< 3 >::Scalar > sources_conc
BCMultiField< 3, FieldValue< 3 >::Scalar > bc_conc
bool is_current(const TimeMark::Type &mask) const
int * get_el_4_loc() const
const RegionDB & region_db() const
ElementAccessor< 3 > element_accessor(unsigned int idx, bool boundary=false)
double ** conc
Concentrations for phase, substance, element.
const TimeStep & step(int index=-1) const
virtual ~ConvectionTransport()
static Input::Type::Abstract & get_input_type()
Common specification of the input record for secondary equations.
MultiField< 3, FieldValue< 3 >::Scalar > init_conc
Initial concentrations.
FieldCommon & units(const UnitSI &units)
Set basic units of the field.
void zero_time_step() override
static TimeMarks & marks()
void output_vector_gather()
Basic time management class.
const Input::Record input_rec
Record with input specification.
const MH_DofHandler * mh_dh
static const Input::Type::Record & get_input_type()
void add(const TimeMark &mark)
unsigned int n_elements() const
bool is_local(unsigned int idx) const
identify local index
static constexpr Mask equation_result
Match result fields. These are never given by input or copy of input.
TimeMark::Type equation_fixed_mark_type() const
MultiField< 3, FieldValue< 3 >::Scalar > sources_sigma
Concentration sources - Robin type, in_flux = sources_sigma * (sources_conc - mobile_conc) ...
static constexpr Mask equation_external_output
Match an output field, that can be also copy of other field.
unsigned int begin(int proc) const
get starting local index
static auto region_id(Mesh &mesh) -> IndexField
ConvectionTransport(Mesh &init_mesh, const Input::Record in_rec)
static const int registrar
Registrar of class to factory.
bool is_changed_dt() const
#define START_TIMER(tag)
Starts a timer with specified tag.
SubstanceList substances_
Transported substances.
virtual Value::return_type const & value(const Point &p, const ElementAccessor< spacedim > &elm) const
double ** get_concentration_matrix() override
Getter for array of concentrations per element.
Field< 3, FieldValue< 3 >::Scalar > porosity
Mobile porosity.
void calculate_cumulative_balance() override
vector< unsigned int > subst_idx
List of indices used to call balance methods for a set of quantities.
Distribution * get_el_ds() const
Vec * vconc
Concentration vectors for mobile phase.
void mark_input_times(const TimeGovernor &tg)
FieldSet output_fields
Fields indended for output, i.e. all input fields plus those representing solution.
Field< 3, FieldValue< 3 >::Integer > region_id
void create_transport_matrix_mpi()
Support classes for parallel programing.
void alloc_transport_structs_mpi()
int set_upper_constraint(double upper, std::string message)
Sets upper constraint for the next time step estimating.
double side_flux(const Side &side) const
temporary replacement for DofHandler accessor, flux through given side
bool is_convection_matrix_scaled
FLOW123D_FORCE_LINK_IN_CHILD(convectionTransport)
#define ELEMENT_FULL_ITER_NULL(_mesh_)
virtual MultiFieldValue::return_type value(const Point &p, const ElementAccessor< spacedim > &elm) const
void output(std::shared_ptr< OutputTime > stream)
void set_components(const std::vector< string > &names)
ElementFullIter element() const
void compute_concentration_sources()
Assembles concentration sources for each substance. note: the source of concentration is multiplied b...
bool evaluate_time_constraint(double &time_constraint) override
VecScatter vconc_out_scatter
Vec vcfl_flow_
Parallel vector for flow contribution to CFL condition.
arma::vec3 centre() const
void set_target_time(double target_time) override
int * get_row_4_el() const
virtual void output_data() override
Write computed fields.
Distributed sparse graphs, partitioning.
Vec vcfl_source_
Parallel vector for source term contribution to CFL condition.
unsigned int bulk_idx() const
Returns index of the region in the bulk set.
int * get_row_4_el() override
Return global array of order of elements within parallel vector.
FieldCommon & name(const string &name)
#define END_TIMER(tag)
Ends a timer with specified tag.
arma::vec::fixed< spacedim > centre() const
boost::shared_ptr< Balance > balance_
object for calculation and writing the mass balance to file.
#define OLD_ASSERT_EQUAL(a, b)
#define FOR_ELM_NEIGHS_VB(i, j)
ElementAccessor< 3 > element_accessor() const
Gets ElementAccessor of this element.
double ** cumulative_corr
void set_mesh(const Mesh &mesh)
Class used for marking specified times at which some events occur.
void get_par_info(int *&el_4_loc, Distribution *&el_ds) override
Return array of indices of local elements and parallel distribution of elements.
FieldCommon & flags(FieldFlag::Flags::Mask mask)
Field< 3, FieldValue< 3 >::Scalar > cross_section
Pointer to DarcyFlow field cross_section.
Class for representation SI units of Fields.
#define MPI_Barrier(comm)
Input::Type::Selection make_output_field_selection(const string &name, const string &desc)
static UnitSI & dimensionless()
Returns dimensionless unit.
Other possible transformation of coordinates:
SideIter side(const unsigned int i) const
ElementAccessor< 3 > element_accessor()
void make_transport_partitioning()
double cfl_max_step
Time step constraint coming from CFL condition.
ElementVector element
Vector of elements of the mesh.
unsigned int lsize(int proc) const
get local size