65 namespace IT = Input::Type;
76 EqData().output_fields.make_output_field_selection(
"ConvectionTransport_Output")
132 for (
unsigned int sbi=0; sbi<
n_subst_; sbi++)
190 for (sbi = 0; sbi <
n_subst_; sbi++) {
224 for (
unsigned int sbi=0; sbi<
n_subst_; sbi++)
236 int sbi, n_subst, ph;
246 for (sbi = 0; sbi < n_subst; sbi++) {
257 conc[ph] = (
double**)
xmalloc(n_subst *
sizeof(
double*));
259 for (sbi = 0; sbi < n_subst; sbi++) {
263 conc[ph][sbi][i] = 0.0;
281 int sbi, n_subst, rank, np;
297 VecCreateMPIWithArray(PETSC_COMM_WORLD,1,
el_ds->
lsize(), PETSC_DECIDE,
300 for (sbi = 0; sbi < n_subst; sbi++) {
307 VecZeroEntries(
vconc[sbi]);
308 VecZeroEntries(
vpconc[sbi]);
331 unsigned int sbi, loc_el;
337 for (loc_el = 0; loc_el <
el_ds->
lsize(); loc_el++) {
339 if (elm->boundary_idx_ != NULL) {
345 Boundary *b = elm->side(si)->cond();
349 double aij = -(flux / (elm->measure() * csection * por_m) );
353 VecSetValue(
bcvcorr[sbi], new_i, value[sbi] * aij, ADD_VALUES);
374 double conc_diff, csection;
387 for (loc_el = 0; loc_el <
el_ds->
lsize(); loc_el++)
406 for (loc_el = 0; loc_el <
el_ds->
lsize(); loc_el++)
409 if ( conc_diff > 0.0)
422 double conc_diff, csection;
427 VecGetArray(
vpconc[sbi], &pconc);
438 for (loc_el = 0; loc_el <
el_ds->
lsize(); loc_el++)
457 for (loc_el = 0; loc_el <
el_ds->
lsize(); loc_el++)
460 if ( conc_diff > 0.0)
546 for (sbi = 0; sbi <
n_subst_; sbi++) {
555 END_TIMER(
"compute_concentration_sources");
596 int s, j, np, rank, new_j, new_i;
597 double max_sum, aij, aii;
604 double flux, flux2, edg_flux;
610 for(
int s=0; s < edg.
n_sides; s++) {
612 if ( flux > 0) edge_flow[i]+= flux;
619 for (
unsigned int loc_el = 0; loc_el <
el_ds->
lsize(); loc_el++) {
629 if (elm->side(si)->cond() == NULL) {
630 edg = elm->side(si)->edge();
631 edg_flux = edge_flow[ elm->side(si)->edge_idx() ];
635 if (edg->
side(s) != elm->side(si)) {
640 if ( flux2 > 0.0 && flux <0.0)
641 aij = -(flux * flux2 / ( edg_flux * elm->measure() * csection * por_m) );
643 MatSetValue(
tm, new_i, new_j, aij, INSERT_VALUES);
646 aii -= (flux / (elm->measure() * csection * por_m) );
649 aii -= (flux / (elm->measure() * csection * por_m) );
656 ASSERT( el2 != elm,
"Elm. same\n");
661 if (flux > 0.0) aij = flux / (elm->measure() * csection * por_m);
663 MatSetValue(
tm, new_i, new_j, aij, INSERT_VALUES);
668 aii -= (-flux) / (elm->measure() * csection * por_m);
669 aij = (-flux) / (el2->measure() *
673 MatSetValue(
tm, new_j, new_i, aij, INSERT_VALUES);
676 MatSetValue(
tm, new_i, new_i, aii, INSERT_VALUES);
678 if (fabs(aii) > max_sum)
688 MatAssemblyBegin(
tm, MAT_FINAL_ASSEMBLY);
689 MatAssemblyEnd(
tm, MAT_FINAL_ASSEMBLY);
711 for (sbi = 0; sbi <
n_subst_; sbi++) {
726 el_distribution_out = this->
el_ds;
746 VecGetArray(
vpconc[sbi], &pconc[sbi]);
751 int index =
row_4_el[bcd->side()->element().index()];
755 double por_m =
data_.
porosity.
value(bcd->side()->element()->centre(), bcd->side()->element()->element_accessor() );
757 if (water_flux < 0) {
758 arma::vec bc_conc =
data_.
bc_conc.
value( bcd->element()->centre(), bcd->element_accessor() );
760 mass_flux[sbi] = water_flux*bc_conc[sbi]*por_m;
763 mass_flux[sbi] = water_flux*pconc[sbi][loc_index]*por_m;
767 if (! r.
is_valid())
xprintf(
Msg,
"Invalid region, ele % d, edg: % d\n", bcd->bc_ele_idx_, bcd->edge_idx_);
772 bcd_balance[sbi][bc_region_idx] += mass_flux[sbi];
774 if (water_flux > 0) bcd_plus_balance[sbi][bc_region_idx] += mass_flux[sbi];
775 else bcd_minus_balance[sbi][bc_region_idx] += mass_flux[sbi];
798 double sum_sol_phases =
conc[0][sbi][loc_index];
800 mass[sbi][ele_acc.
region().
bulk_idx()] += por_m*csection*sum_sol_phases*elem->measure();
801 src_balance[sbi][ele_acc.
region().
bulk_idx()] += sources[loc_index]*elem->measure();
void output_type(OutputTime::DiscreteSpace rt)
unsigned int size() const
get global size
void set_input_list(Input::Array input_list)
void compute_concentration_sources(unsigned int sbi)
void set_limit_side(LimitSide side)
double *** get_concentration_matrix()
double time_changed() const
void init(const vector< string > &names)
Header: The functions for all outputs.
void update_solution() override
double end_time() const
End time.
double transport_matrix_time
Field< 3, FieldValue< 3 >::Scalar > cross_section
Pointer to DarcyFlow field cross_section.
void id_maps(int n_ids, int *id_4_old, Distribution *&new_ds, int *&id_4_loc, int *&new_4_id)
double *** conc
Concentrations for phase, substance, element.
#define FOR_EDGE_SIDES(i, j)
#define FOR_ELEMENTS(_mesh_, __i)
void alloc_transport_vectors()
BCField< 3, FieldValue< 3 >::Vector > bc_conc
FieldBasePtr(* read_field_descriptor_hook)(Input::Record rec, const FieldCommon &field)
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 next_time()
Proceed to the next time according to current estimated time step.
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()
void set_boundary_conditions()
RegionSet get_region_set(const string &set_name) const
const MH_DofHandler * mh_dh
MassBalance * mass_balance_
object for calculation and writing the mass balance to file.
#define ELEMENT_FULL_ITER(_mesh_, i)
Field< 3, FieldValue< 3 >::Vector > sources_conc
#define FOR_ELEMENT_SIDES(i, j)
bool is_current(const TimeMark::Type &mask) const
Field< 3, FieldValue< 3 >::Scalar > porosity
Mobile porosity.
const RegionDB & region_db() const
ElementAccessor< 3 > element_accessor(unsigned int idx, bool boundary=false)
virtual ~ConvectionTransport()
void get_par_info(int *&el_4_loc, Distribution *&el_ds)
#define ADD_FIELD(name,...)
Basic time management functionality for unsteady (and steady) solvers (class Equation).
FieldCommon & units(const UnitSI &units)
Set basic units of the field.
Partitioning * get_part()
void zero_time_step() override
static TimeMarks & marks()
void output_vector_gather()
Basic time management class.
Specification of transport model interface.
double estimate_dt() const
Estimate choice of next time step according to actual setting of constraints.
OutputTime * output_stream_
ConvectionTransport(Mesh &init_mesh, const Input::Record &in_rec)
unsigned int boundary_idx() const
Returns index of the region in the boundary set.
void compute_concentration_sources_for_mass_balance(unsigned int sbi)
void add(const TimeMark &mark)
unsigned int n_elements() const
bool is_local(unsigned int idx) const
identify local index
static OutputTime * create_output_stream(const Input::Record &in_rec)
This method write all registered data to output streams.
static Input::Type::Selection sorption_type_selection
#define ASSERT_EQUAL(a, b)
Input::Record output_rec
Record with output specification.
void calc_fluxes(vector< vector< double > > &bcd_balance, vector< vector< double > > &bcd_plus_balance, vector< vector< double > > &bcd_minus_balance)
TimeMark::Type equation_fixed_mark_type() const
unsigned int begin(int proc) const
get starting local index
#define START_TIMER(tag)
Starts a timer with specified tag.
void output(double time)
Write computed fields to file.
virtual Value::return_type const & value(const Point &p, const ElementAccessor< spacedim > &elm) const
void mark_input_times(TimeMark::Type mark_type)
unsigned int n_subst_
Number of transported substances.
void mark_output_times(const TimeGovernor &tg)
Vec * vconc
Concentration vectors for mobile phase.
void * xmalloc(size_t size)
Memory allocation with checking.
#define INPUT_CHECK(i,...)
Debugging macros.
void set_time(const TimeGovernor &time)
void calc_elem_sources(vector< vector< double > > &mass, vector< vector< double > > &src_balance)
std::vector< string > subst_names_
Names of transported substances.
FieldSet output_fields
Fields indended for output, i.e. all input fields plus those representing solution.
void create_transport_matrix_mpi()
Support classes for parallel programing.
#define MPI_Allreduce(sendbuf, recvbuf, count, datatype, op, comm)
Field< 3, FieldValue< 3 >::Vector > sources_sigma
Concentration sources - Robin type, in_flux = sources_sigma * (sources_conc - mobile_conc) ...
void alloc_transport_structs_mpi()
void set_n_components(unsigned int n_comp)
double side_flux(const Side &side) const
temporary replacement for DofHandler accessor, flux through given side
bool is_convection_matrix_scaled
#define ELEMENT_FULL_ITER_NULL(_mesh_)
static Input::Type::Selection output_selection
void output(OutputTime *stream)
ElementFullIter element() const
int set_upper_constraint(double upper)
Sets upper constraint for the next time step estimating.
Field< 3, FieldValue< 3 >::Vector > sources_density
Concentration sources - density of substance source, only positive part is used.
VecScatter vconc_out_scatter
double ** sources_density
temporary arrays to store constant values of fields over time interval
void add_admissible_field_names(const Input::Array &in_array, const Input::Type::Selection &in_sel)
Registers names of output fields that can be written using this stream.
arma::vec3 centre() const
virtual void output_data() override
Write computed fields.
std::vector< Edge > edges
Vector of MH edges, this should not be part of the geometrical mesh.
Distributed sparse graphs, partitioning.
#define FOR_BOUNDARIES(_mesh_, i)
void set_target_time(double target_time)
unsigned int bulk_idx() const
Returns index of the region in the bulk set.
FieldCommon & name(const string &name)
#define END_TIMER(tag)
Ends a timer with specified tag.
arma::vec::fixed< spacedim > centre() const
#define FOR_ELM_NEIGHS_VB(i, j)
double ** cumulative_corr
mixed-hybrid model of linear Darcy flow, possibly unsteady.
void set_mesh(const Mesh &mesh)
Class used for marking specified times at which some events occur.
unsigned int n_substances() override
Returns number of trnasported substances.
bool is_valid() const
Returns false if the region has undefined/invalid value.
unsigned int n_edges() const
Class for representation SI units of Fields.
#define MPI_Barrier(comm)
SideIter side(const unsigned int i) const
void set_mesh(const Mesh &mesh) override
Field< 3, FieldValue< 3 >::Vector > init_conc
Initial concentrations.
ElementAccessor< 3 > element_accessor()
void make_transport_partitioning()
ElementVector element
Vector of elements of the mesh.
unsigned int lsize(int proc) const
get local size