Flow123d
JS_before_hm-1830-gb19ac973c
|
Go to the documentation of this file.
70 Input::register_class< ConvectionTransport, Mesh &, const Input::Record >(
_equation_name) +
84 "Specification of output fields and output times.")
92 .
description(
"Boundary condition for concentration of substances.")
97 .
description(
"Initial values for concentration of substances.")
113 .
description(
"Subdomain ids of the domain decomposition.");
121 : q_(
QGauss::make_array(0))
160 is_mass_diag_changed(false),
175 dh_ = make_shared<DOFHandlerMultiDim>(init_mesh);
176 shared_ptr<DiscreteSpace> ds = make_shared<EqualOrderDiscreteSpace>( &init_mesh, fe);
177 dh_->distribute_dofs(ds);
300 DebugOut() <<
"ConvectionTransport::set_initial_condition()\n";
307 LongIdx index = dh_cell.local_idx();
321 unsigned int sbi, n_subst;
324 tm_diag =
new double*[n_subst];
326 for (sbi = 0; sbi < n_subst; sbi++) {
347 vpconc =
new Vec[n_subst];
353 for (sbi = 0; sbi < n_subst; sbi++) {
358 VecZeroEntries(
vpconc[sbi]);
392 double csection, source, diag;
412 ASSERT_DBG(dh_cell.get_loc_dof_indices().size() == 1);
413 IntIdx local_p0_dof = dh_cell.get_loc_dof_indices()[0];
414 LongIdx glob_p0_dof =
dh_->get_local_to_global_map()[local_p0_dof];
421 if (sources_changed) {
431 corr_vec[sbi].set(local_p0_dof, source);
433 diag = src_sigma * csection;
434 tm_diag[sbi][local_p0_dof] = - diag;
437 max_cfl = std::max(max_cfl, fabs(diag));
440 {- src_sigma * elm.measure() * csection},
441 {source * elm.measure()});
449 for(
DHCellSide dh_side: dh_cell.side_range()) {
450 if (dh_side.side().is_boundary()) {
454 double aij = -(flux / elm.
measure() );
460 VecSetValue(
bcvcorr[sbi], glob_p0_dof,
value * aij, ADD_VALUES);
465 {local_p0_dof}, {0.0}, flux*
value);
469 VecSetValue(
bcvcorr[sbi], glob_p0_dof, 0, ADD_VALUES);
473 {local_p0_dof}, {flux}, 0.0);
479 balance_->finish_flux_assembly(subst_idx);
480 if (sources_changed) balance_->finish_source_assembly(subst_idx);
482 for (sbi=0; sbi<n_substances(); sbi++) VecAssemblyBegin(bcvcorr[sbi]);
483 for (sbi=0; sbi<n_substances(); sbi++) VecAssemblyEnd(bcvcorr[sbi]);
487 transport_bc_time = time_->last_t();
499 std::stringstream ss;
526 bool cfl_changed =
false;
534 DebugOut() <<
"CFL changed - flow.\n";
541 DebugOut() <<
"CFL changed - mass matrix.\n";
557 DebugOut() <<
"CFL changed - source.\n";
565 VecCreateMPI(PETSC_COMM_WORLD,
el_ds->
lsize(),PETSC_DETERMINE, &cfl);
608 DebugOut() <<
"SRC - rescale dt.\n";
613 VecScale(
corr_vec[sbi].petsc_vec(), dt);
642 for (
unsigned int sbi = 0; sbi <
n_substances(); sbi++) {
660 VecCopy(vconc,
vpconc[sbi]);
664 MatMultAdd(
tm,
vpconc[sbi], vconc, vconc);
666 VecPointwiseDivide(vconc, vconc,
mass_diag);
669 VecPointwiseDivide(vconc, vconc,
mass_diag);
670 VecAXPY(vconc, 1,
vpconc[sbi]);
717 ASSERT_DBG(dh_cell.get_loc_dof_indices().size() == 1);
718 IntIdx local_p0_dof = dh_cell.get_loc_dof_indices()[0];
727 VecSetValue(
mass_diag,
dh_->get_local_to_global_map()[local_p0_dof], csection*por_m, INSERT_VALUES);
730 balance_->finish_mass_assembly(subst_idx);
732 VecAssemblyBegin(mass_diag);
733 VecAssemblyEnd(mass_diag);
735 is_mass_diag_changed =
true;
754 double flux, flux2, edg_flux;
758 unsigned int loc_el = 0;
760 new_i =
row_4_el[ dh_cell.elm_idx() ];
762 for(
DHCellSide cell_side : dh_cell.side_range() ) {
764 if (! cell_side.side().is_boundary()) {
769 if ( flux2 > 0) edg_flux+= flux2;
772 if (edge_side != cell_side) {
773 j = edge_side.element().idx();
778 if ( flux2 > 0.0 && flux <0.0)
779 aij = -(flux * flux2 / ( edg_flux * dh_cell.elm().measure() ) );
781 MatSetValue(
tm, new_i, new_j, aij, INSERT_VALUES);
785 aii -= (flux / dh_cell.elm().measure() );
788 for(
DHCellSide neighb_side : dh_cell.neighb_sides() )
790 ASSERT( neighb_side.elem_idx() != dh_cell.elm_idx() ).error(
"Elm. same\n");
791 new_j =
row_4_el[ neighb_side.elem_idx() ];
796 if (flux > 0.0) aij = flux / dh_cell.elm().measure();
798 MatSetValue(
tm, new_i, new_j, aij, INSERT_VALUES);
803 aii -= (-flux) / dh_cell.elm().measure();
804 aij = (-flux) / neighb_side.element().measure();
806 MatSetValue(
tm, new_j, new_i, aij, INSERT_VALUES);
809 MatSetValue(
tm, new_i, new_i, aii, INSERT_VALUES);
815 MatAssemblyBegin(
tm, MAT_FINAL_ASSEMBLY);
816 MatAssemblyEnd(
tm, MAT_FINAL_ASSEMBLY);
831 el_distribution_out = this->
el_ds;
865 if (cell_side.
dim()==3)
return calculate_side_flux<3>(cell_side);
866 else if (cell_side.
dim()==2)
return calculate_side_flux<2>(cell_side);
867 else return calculate_side_flux<1>(cell_side);
870 template<
unsigned int dim>
873 ASSERT_EQ(cell_side.
dim(), dim).error(
"Element dimension mismatch!");
FieldCommon & units(const UnitSI &units)
Set basic units of the field.
#define OLD_ASSERT_EQUAL(a, b)
const string _equation_name
FEValues< 3 > fe_values_[3]
FESideValues objects for side flux calculating.
FiniteElement< 1 > * fe1_
Distribution * get_el_ds() const
void set_balance_object(std::shared_ptr< Balance > balance) override
MultiField< 3, FieldValue< 3 >::Scalar > conc_mobile
Calculated concentrations in the mobile zone.
Vec vcfl_flow_
Parallel vector for flow contribution to CFL condition.
@ update_gradients
Shape function gradients.
void create_mass_matrix()
static UnitSI & dimensionless()
Returns dimensionless unit.
MultiField< 3, FieldValue< 3 >::Scalar > init_conc
Initial concentrations.
Side side() const
Return Side of given cell and side_idx.
Distributed sparse graphs, partitioning.
bool set_time(const TimeStep &time, LimitSide limit_side)
unsigned int lsize(int proc) const
get local size
Basic time management class.
double end_time() const
End time.
static const Input::Type::Record & get_input_type()
void initialize(std::shared_ptr< OutputTime > stream, Mesh *mesh, Input::Record in_rec, const TimeGovernor &tg)
FETransportObjects feo_
Finite element objects.
Field< 3, FieldValue< 3 >::Scalar > cross_section
Pointer to DarcyFlow field cross_section.
RangeConvert< DHEdgeSide, DHCellSide > edge_sides() const
Returns range of all sides looped over common Edge.
#define ASSERT(expr)
Allow use shorter versions of macro names if these names is not used with external library.
arma::vec::fixed< spacedim > normal_vector(unsigned int point_no)
Returns the normal vector to a side at given quadrature point.
double transport_matrix_time
Field< 3, FieldValue< 3 >::VectorFixed > flow_flux
Flow flux, can be result of water flow model.
TimeMark::Type equation_fixed_mark_type() const
Field< 3, FieldValue< 3 >::Scalar > water_content
Water content - result of unsaturated water flow model or porosity.
double JxW(const unsigned int point_no)
Return the product of Jacobian determinant and the quadrature weight at given quadrature point.
FiniteElement< 0 > * fe0_
Finite elements for the solution of the advection-diffusion equation.
void set(std::vector< typename Field< spacedim, Value >::FieldBasePtr > field_vec, double time, std::vector< std::string > region_set_names={"ALL"})
Support classes for parallel programing.
int set_upper_constraint(double upper, std::string message)
Sets upper constraint for the next time step estimating.
void mark_input_times(const TimeGovernor &tg)
void set_input_list(Input::Array input_list, const TimeGovernor &tg)
double side_flux(const DHCellSide &cell_side)
Wrapper of following method, call side_flux with correct template parameter.
Class FEValues calculates finite element data on the actual cells such as shape function values,...
static constexpr bool value
void output_type(OutputTime::DiscreteSpace rt)
double calculate_side_flux(const DHCellSide &cell)
Calculate flux on side of given element specified by dimension.
@ update_values
Shape function values.
void chkerr(unsigned int ierr)
Replacement of new/delete operator in the spirit of xmalloc.
#define FLOW123D_FORCE_LINK_IN_CHILD(x)
void initialize(Quadrature &_quadrature, FiniteElement< DIM > &_fe, UpdateFlags _flags)
Initialize structures and calculates cell-independent data.
virtual ~ConvectionTransport()
FieldFEScalarVec conc_mobile_fe
Underlaying FieldFE for each substance of conc_mobile.
LongIdx * get_row_4_el() override
Return global array of order of elements within parallel vector.
@ update_quadrature_points
Transformed quadrature points.
FieldCommon & flags(FieldFlag::Flags::Mask mask)
unsigned int n_substances() override
Returns number of transported substances.
FEValues< 3 > & fe_values(unsigned int dim)
LongIdx * get_row_4_el() const
@ update_normal_vectors
Normal vectors.
unsigned int dim() const
Return dimension of element appropriate to the side.
std::shared_ptr< OutputTime > output_stream_
double transport_bc_time
Time of the last update of the boundary condition terms.
const Element * element() const
arma::vec3 centre() const
Side centre.
static constexpr Mask equation_external_output
Match an output field, that can be also copy of other field.
bool is_mass_diag_changed
Flag indicates that porosity or cross_section changed during last time.
virtual unsigned int n_elements() const
Returns count of boundary or bulk elements.
MultiField< 3, FieldValue< 3 >::Scalar > sources_sigma
Concentration sources - Robin type, in_flux = sources_sigma * (sources_conc - mobile_conc)
Definitions of basic Lagrangean finite elements with polynomial shape functions.
double ** cumulative_corr
const std::vector< std::string > & names()
Side accessor allows to iterate over sides of DOF handler cell.
void conc_sources_bdr_conditions()
Assembles concentration sources for each substance and set boundary conditions. note: the source of c...
std::shared_ptr< Balance > balance() const
Class used for marking specified times at which some events occur.
void alloc_transport_structs_mpi()
void set_components(const std::vector< string > &names)
std::shared_ptr< Balance > balance_
object for calculation and writing the mass balance to file.
bool is_convection_matrix_scaled
static constexpr Mask equation_result
Match result fields. These are never given by input or copy of input.
const Input::Record input_rec
Record with input specification.
bool evaluate_time_constraint(double &time_constraint) override
static const int registrar
Registrar of class to factory.
void zero_time_step() override
Definitions of particular quadrature rules on simplices.
void set_initial_condition()
Quadrature & q(unsigned int dim)
const TimeStep & step(int index=-1) const
Vec vcfl_source_
Parallel vector for source term contribution to CFL condition.
virtual void output_data() override
Write computed fields.
std::shared_ptr< DOFHandlerMultiDim > dh_
EquationOutput output_fields
Fields indended for output, i.e. all input fields plus those representing solution.
static auto subdomain(Mesh &mesh) -> IndexField
vector< unsigned int > subst_idx
List of indices used to call balance methods for a set of quantities.
BCMultiField< 3, FieldValue< 3 >::Scalar > bc_conc
Field< 3, FieldValue< 3 >::Scalar > porosity
Mobile porosity - usually saturated water content in the case of unsaturated flow model.
static bool print_message_table(ostream &stream, std::string equation_name)
Class for representation SI units of Fields.
#define ASSERT_EQ(a, b)
Definition of comparative assert macro (EQual)
TimeMark add(const TimeMark &mark)
FiniteElement< 3 > * fe3_
SubstanceList substances_
Transported substances.
virtual const Value::return_type & value(const Point &p, const ElementAccessor< spacedim > &elm) const
Symmetric Gauss-Legendre quadrature formulae on simplices.
ElementAccessor< 3 > element() const
static auto region_id(Mesh &mesh) -> IndexField
Field< 3, FieldValue< 3 >::Scalar > subdomain
Vec get_component_vec(unsigned int sbi) override
Return PETSc vector with solution for sbi-th substance.
FieldCommon & input_default(const string &input_default)
void output(TimeStep step)
FieldFEScalarVec & get_p0_interpolation() override
Getter for P0 interpolation by FieldFE.
int LongIdx
Define type that represents indices of large arrays (elements, nodes, dofs etc.)
void make_transport_partitioning()
static TimeMarks & marks()
Cell accessor allow iterate over DOF handler cells.
TimeMark::Type target_mark_type
TimeMark type for time marks denoting end of every time interval where transport matrix remains const...
void set_mesh(const Mesh &mesh)
#define WarningOut()
Macro defining 'warning' record of log.
void update_solution() override
FiniteElement< 2 > * fe2_
static Input::Type::Abstract & get_input_type()
Common specification of the input record for secondary equations.
bool is_changed_dt() const
ConvectionTransport(Mesh &init_mesh, const Input::Record in_rec)
void reinit(const ElementAccessor< spacedim > &cell)
Update cell-dependent data (gradients, Jacobians etc.)
MultiField< 3, FieldValue< 3 >::Scalar > sources_density
Concentration sources - density of substance source, only positive part is used.
void get_par_info(LongIdx *&el_4_loc, Distribution *&el_ds) override
Return array of indices of local elements and parallel distribution of elements.
void set_target_time(double target_time) override
@ update_side_JxW_values
Transformed quadrature weight for cell sides.
void alloc_transport_vectors()
MultiField< 3, FieldValue< 3 >::Scalar > sources_conc
FieldCommon & description(const string &description)
#define DebugOut()
Macro defining 'debug' record of log.
#define ASSERT_PTR(ptr)
Definition of assert macro checking non-null pointer (PTR)
Base class for quadrature rules on simplices in arbitrary dimensions.
void next_time()
Proceed to the next time according to current estimated time step.
virtual ElementAccessor< 3 > element_accessor(unsigned int idx) const
Create and return ElementAccessor to element of given idx.
double cfl_max_step
Time step constraint coming from CFL condition.
void initialize() override
double fix_dt_until_mark()
Fixing time step until fixed time mark.
QGauss::array q_
Quadratures used in assembling methods.
unsigned int bulk_idx() const
Returns index of the region in the bulk set.
#define START_TIMER(tag)
Starts a timer with specified tag.
#define MPI_Barrier(comm)
vector< VectorMPI > corr_vec
Discontinuous Lagrangean finite element on dim dimensional simplex.
Field< 3, FieldValue< 3 >::Scalar > region_id
double measure() const
Computes the measure of the element.
#define END_TIMER(tag)
Ends a timer with specified tag.
void create_transport_matrix_mpi()
FieldCommon & name(const string &name)
Implementation of range helper class.
arma::vec::fixed< spacedim > centre() const
Computes the barycenter.
LongIdx * get_el_4_loc() const