71 ConvectionTransport::get_input_type().size();
73 const
IT::Record &ConvectionTransport::get_input_type()
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),
161 sources_corr(nullptr),
176 dh_ = make_shared<DOFHandlerMultiDim>(init_mesh);
177 shared_ptr<DiscreteSpace> ds = make_shared<EqualOrderDiscreteSpace>( &init_mesh, fe);
178 dh_->distribute_dofs(ds);
206 output_field_ptr[sbi] = std::make_shared< FieldFE<3, FieldValue<3>::Scalar> >();
304 LongIdx index = dh_cell.local_idx();
317 unsigned int sbi, n_subst;
321 tm_diag =
new double*[n_subst];
323 for (sbi = 0; sbi < n_subst; sbi++) {
329 conc =
new double*[n_subst];
330 vconc =
new Vec[n_subst];
335 for (sbi = 0; sbi < n_subst; sbi++) {
353 vpconc =
new Vec[n_subst];
360 for (sbi = 0; sbi < n_subst; sbi++) {
365 VecZeroEntries(
vpconc[sbi]);
378 VecZeroEntries(
out_conc[sbi].petsc_vec());
410 ASSERT_DBG(dh_cell.get_loc_dof_indices().size() == 1);
411 Idx local_p0_dof = dh_cell.get_loc_dof_indices()[0];
412 LongIdx glob_p0_dof =
dh_->get_local_to_global_map()[local_p0_dof];
414 for(
DHCellSide dh_side: dh_cell.side_range()) {
415 if (dh_side.side().is_boundary()) {
419 double aij = -(flux / elm.
measure() );
425 VecSetValue(
bcvcorr[sbi], glob_p0_dof, value * aij, ADD_VALUES);
430 {local_p0_dof}, {0.0}, flux*
value);
434 VecSetValue(
bcvcorr[sbi], glob_p0_dof, 0, ADD_VALUES);
438 {local_p0_dof}, {flux}, 0.0);
461 double csection, source, diag;
478 ASSERT_DBG(dh_cell.get_loc_dof_indices().size() == 1);
479 Idx local_p0_dof = dh_cell.get_loc_dof_indices()[0];
495 diag = src_sigma * csection;
496 tm_diag[sbi][local_p0_dof] = - diag;
499 max_cfl = std::max(max_cfl, fabs(diag));
502 {- src_sigma * elm.
measure() * csection},
523 std::stringstream ss;
549 bool cfl_changed =
false;
557 DebugOut() <<
"CFL changed - flow.\n";
564 DebugOut() <<
"CFL changed - mass matrix.\n";
574 DebugOut() <<
"CFL changed - source.\n";
582 VecCreateMPI(PETSC_COMM_WORLD,
el_ds->
lsize(),PETSC_DETERMINE, &cfl);
636 DebugOut() <<
"SRC - rescale dt.\n";
670 for (
unsigned int sbi = 0; sbi <
n_substances(); sbi++) {
744 ASSERT_DBG(dh_cell.get_loc_dof_indices().size() == 1);
745 Idx local_p0_dof = dh_cell.get_loc_dof_indices()[0];
752 balance_->add_mass_values(
subst_idx[sbi], dh_cell, {local_p0_dof}, {csection*por_m*elm.measure()}, 0);
754 VecSetValue(
mass_diag,
dh_->get_local_to_global_map()[local_p0_dof], csection*por_m, INSERT_VALUES);
781 double flux, flux2, edg_flux;
785 unsigned int loc_el = 0;
787 new_i =
row_4_el[ dh_cell.elm_idx() ];
789 for(
DHCellSide cell_side : dh_cell.side_range() ) {
791 if (! cell_side.side().is_boundary()) {
796 if ( flux2 > 0) edg_flux+= flux2;
799 if (edge_side != cell_side) {
800 j = edge_side.element().idx();
805 if ( flux2 > 0.0 && flux <0.0)
806 aij = -(flux * flux2 / ( edg_flux * dh_cell.elm().measure() ) );
808 MatSetValue(
tm, new_i, new_j, aij, INSERT_VALUES);
812 aii -= (flux / dh_cell.elm().measure() );
815 for(
DHCellSide neighb_side : dh_cell.neighb_sides() )
817 ASSERT( neighb_side.elem_idx() != dh_cell.elm_idx() ).error(
"Elm. same\n");
818 new_j =
row_4_el[ neighb_side.elem_idx() ];
823 if (flux > 0.0) aij = flux / dh_cell.elm().measure();
825 MatSetValue(
tm, new_i, new_j, aij, INSERT_VALUES);
830 aii -= (-flux) / dh_cell.elm().measure();
831 aij = (-flux) / neighb_side.element().measure();
833 MatSetValue(
tm, new_j, new_i, aij, INSERT_VALUES);
836 MatSetValue(
tm, new_i, new_i, aii, INSERT_VALUES);
842 MatAssemblyBegin(
tm, MAT_FINAL_ASSEMBLY);
843 MatAssemblyEnd(
tm, MAT_FINAL_ASSEMBLY);
858 el_distribution_out = this->
el_ds;
892 if (cell_side.
dim()==3)
return calculate_side_flux<3>(cell_side);
893 else if (cell_side.
dim()==2)
return calculate_side_flux<2>(cell_side);
894 else return calculate_side_flux<1>(cell_side);
897 template<
unsigned int dim>
900 ASSERT_EQ(cell_side.
dim(), dim).error(
"Element dimension mismatch!");
void output_type(OutputTime::DiscreteSpace rt)
unsigned int size() const
get global size
const Element * element() const
static auto subdomain(Mesh &mesh) -> IndexField
Quadrature & q(unsigned int dim)
bool is_mass_diag_changed
Flag indicates that porosity or cross_section changed during last time.
Transformed quadrature weight for cell sides.
RegionSet get_region_set(const std::string &set_name) const
void update_solution() override
double end_time() const
End time.
LongIdx * get_row_4_el() const
double transport_matrix_time
double calculate_side_flux(const DHCellSide &cell)
Calculate flux on side of given element specified by dimension.
unsigned int dim() const
Return dimension of element appropriate to the side.
const std::vector< std::string > & names()
QGauss::array q_
Quadratures used in assembling methods.
void alloc_transport_vectors()
unsigned int n_substances() override
Returns number of transported substances.
void output(TimeStep step)
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...
void set_initial_condition()
Field< 3, FieldValue< 3 >::Scalar > region_id
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()
Fields computed from the mesh data.
EquationOutput output_fields
Fields indended for output, i.e. all input fields plus those representing solution.
Cell accessor allow iterate over DOF handler cells.
Class FEValues calculates finite element data on the actual cells such as shape function values...
MultiField< 3, FieldValue< 3 >::Scalar > sources_conc
BCMultiField< 3, FieldValue< 3 >::Scalar > bc_conc
void chkerr(unsigned int ierr)
Replacement of new/delete operator in the spirit of xmalloc.
std::vector< std::shared_ptr< FieldFE< 3, FieldValue< 3 >::Scalar > > > output_field_ptr
Fields correspond with out_conc.
double side_flux(const DHCellSide &cell_side)
Wrapper of following method, call side_flux with correct template parameter.
const RegionDB & region_db() const
void set_balance_object(std::shared_ptr< Balance > balance) override
#define ASSERT(expr)
Allow use shorter versions of macro names if these names is not used with external library...
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
Side side() const
Return Side of given cell and side_idx.
void reinit(const ElementAccessor< spacedim > &cell)
Update cell-dependent data (gradients, Jacobians etc.)
static TimeMarks & marks()
Basic time management class.
virtual ElementAccessor< 3 > element_accessor(unsigned int idx) const
Create and return ElementAccessor to element of given idx.
const Input::Record input_rec
Record with input specification.
Base class for quadrature rules on simplices in arbitrary dimensions.
static constexpr bool value
Symmetric Gauss-Legendre quadrature formulae on simplices.
Field< 3, FieldValue< 3 >::Scalar > subdomain
const string _equation_name
arma::vec::fixed< spacedim > centre() const
Computes the barycenter.
Discontinuous Lagrangean finite element on dim dimensional simplex.
Transformed quadrature points.
static constexpr Mask equation_result
Match result fields. These are never given by input or copy of input.
RangeConvert< DHEdgeSide, DHCellSide > edge_sides() const
Returns range of all sides looped over common Edge.
FieldCommon & input_default(const string &input_default)
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) ...
Definitions of basic Lagrangean finite elements with polynomial shape functions.
static constexpr Mask equation_external_output
Match an output field, that can be also copy of other field.
ElementAccessor< 3 > element() const
static auto region_id(Mesh &mesh) -> IndexField
ConvectionTransport(Mesh &init_mesh, const Input::Record in_rec)
void initialize(Quadrature &_quadrature, FiniteElement< DIM > &_fe, UpdateFlags _flags)
Initialize structures and calculates cell-independent data.
bool is_changed_dt() const
#define START_TIMER(tag)
Starts a timer with specified tag.
std::vector< VectorMPI > out_conc
SubstanceList substances_
Transported substances.
LongIdx * get_row_4_el() override
Return global array of order of elements within parallel vector.
virtual Value::return_type const & value(const Point &p, const ElementAccessor< spacedim > &elm) const
FEValues< 3 > & fe_values(unsigned int dim)
double ** get_concentration_matrix() override
Getter for array of concentrations per element.
Field< 3, FieldValue< 3 >::Scalar > porosity
Mobile porosity - usually saturated water content in the case of unsaturated flow model...
std::shared_ptr< Balance > balance_
object for calculation and writing the mass balance to file.
std::shared_ptr< DOFHandlerMultiDim > dh_
double measure() const
Computes the measure of the element.
vector< unsigned int > subst_idx
List of indices used to call balance methods for a set of quantities.
Shape function gradients.
Distribution * get_el_ds() const
std::shared_ptr< Balance > balance() const
FEValues< 3 > fe_values_[3]
FESideValues objects for side flux calculating.
Field< 3, FieldValue< 3 >::Scalar > water_content
Water content - result of unsaturated water flow model or porosity.
Vec * vconc
Concentration vectors for mobile phase.
void mark_input_times(const TimeGovernor &tg)
TimeMark add(const TimeMark &mark)
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.
int LongIdx
Define type that represents indices of large arrays (elements, nodes, dofs etc.)
FieldCommon & description(const string &description)
bool is_convection_matrix_scaled
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.
void initialize(std::shared_ptr< OutputTime > stream, Mesh *mesh, Input::Record in_rec, const TimeGovernor &tg)
bool changed_
Indicator of change in velocity field.
#define ASSERT_PTR(ptr)
Definition of assert macro checking non-null pointer (PTR)
void set_components(const std::vector< string > &names)
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
FiniteElement< 1 > * fe1_
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::VectorFixed > > velocity_field_ptr_
Pointer to velocity field given from Flow equation.
Vec vcfl_flow_
Parallel vector for flow contribution to CFL condition.
void set_target_time(double target_time) override
virtual void output_data() override
Write computed fields.
bool set_time(const TimeStep &time, LimitSide limit_side)
void get_par_info(LongIdx *&el_4_loc, Distribution *&el_ds) override
Return array of indices of local elements and parallel distribution of elements.
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.
Definitions of particular quadrature rules on simplices.
#define WarningOut()
Macro defining 'warning' record of log.
FieldCommon & name(const string &name)
#define END_TIMER(tag)
Ends a timer with specified tag.
#define OLD_ASSERT_EQUAL(a, b)
double ** cumulative_corr
void set_mesh(const Mesh &mesh)
Class used for marking specified times at which some events occur.
FETransportObjects feo_
Finite element objects.
FieldCommon & flags(FieldFlag::Flags::Mask mask)
double JxW(const unsigned int point_no)
Return the product of Jacobian determinant and the quadrature weight at given quadrature point...
Field< 3, FieldValue< 3 >::Scalar > cross_section
Pointer to DarcyFlow field cross_section.
Class for representation SI units of Fields.
#define MPI_Barrier(comm)
static UnitSI & dimensionless()
Returns dimensionless unit.
#define DebugOut()
Macro defining 'debug' record of log.
static bool print_message_table(ostream &stream, std::string equation_name)
Other possible transformation of coordinates:
FiniteElement< 3 > * fe3_
FiniteElement< 0 > * fe0_
Finite elements for the solution of the advection-diffusion equation.
LongIdx * get_el_4_loc() const
Implementation of range helper class.
Side accessor allows to iterate over sides of DOF handler cell.
#define FLOW123D_FORCE_LINK_IN_CHILD(x)
#define ASSERT_EQ(a, b)
Definition of comparative assert macro (EQual)
void make_transport_partitioning()
double cfl_max_step
Time step constraint coming from CFL condition.
FiniteElement< 2 > * fe2_
unsigned int lsize(int proc) const
get local size
arma::vec::fixed< spacedim > normal_vector(unsigned int point_no)
Returns the normal vector to a side at given quadrature point.
arma::vec3 centre() const
Side centre.