18 #ifndef ASSEMBLY_CONVECTION_HH_
19 #define ASSEMBLY_CONVECTION_HH_
34 template <
unsigned int dim,
class TEqData>
41 static constexpr
const char *
name() {
return "Convection_Mass_Assembly"; }
61 ASSERT_EQ(cell.
dim(), dim).error(
"Dimension of element mismatch!");
69 for (
unsigned int sbi=0; sbi<
eq_data_->n_substances(); ++sbi)
70 eq_data_->balance_->add_mass_values(
eq_data_->subst_idx[sbi], cell, {local_p0_dof},
73 VecSetValue(
eq_data_->mass_diag,
eq_data_->dh_->get_local_to_global_map()[local_p0_dof],
80 VecZeroEntries(eq_data_->mass_diag);
81 eq_data_->balance_->start_mass_assembly(eq_data_->subst_idx);
87 eq_data_->balance_->finish_mass_assembly(eq_data_->subst_idx);
89 VecAssemblyBegin(eq_data_->mass_diag);
90 VecAssemblyEnd(eq_data_->mass_diag);
92 eq_data_->is_mass_diag_changed =
true;
96 shared_ptr<FiniteElement<dim>>
fe_;
108 template <
template<
IntDim...>
class DimAssembly>
118 template <
unsigned int dim,
class TEqData>
125 static constexpr
const char *
name() {
return "Convection_InitCond_Assembly"; }
139 for (
unsigned int sbi=0; sbi<
eq_data_->n_substances(); sbi++) {
148 ASSERT_EQ(cell.
dim(), dim).error(
"Dimension of element mismatch!");
153 for (
unsigned int sbi=0; sbi<
eq_data_->n_substances(); sbi++) {
159 shared_ptr<FiniteElement<dim>>
fe_;
173 template <
template<
IntDim...>
class DimAssembly>
185 template <
unsigned int dim,
class TEqData>
192 static constexpr
const char *
name() {
return "Convection_ConcSourcesBdr_Assembly"; }
212 fe_ = std::make_shared< FE_P_disc<dim> >(0);
221 ASSERT_EQ(cell.
dim(), dim).error(
"Dimension of element mismatch!");
222 if (!
eq_data_->sources_changed_)
return;
233 for (
unsigned int sbi = 0; sbi <
eq_data_->n_substances(); sbi++)
238 eq_data_->corr_vec[sbi].set(local_p0_dof, source);
241 eq_data_->tm_diag[sbi].set(local_p0_dof, - diag);
244 max_cfl = std::max(max_cfl, fabs(diag));
247 {- eq_fields_->sources_sigma[sbi](p) * elm.measure() * eq_fields_->cross_section(p)},
248 {source * elm.measure()});
251 eq_data_->cfl_source_.set(local_p0_dof, max_cfl);
257 ASSERT_EQ(cell_side.
dim(), dim).error(
"Dimension of element mismatch!");
263 LongIdx glob_p0_dof =
eq_data_->dh_->get_local_to_global_map()[local_p0_dof];
274 for (sbi=0; sbi<
eq_data_->n_substances(); sbi++)
278 VecSetValue(
eq_data_->bcvcorr[sbi], glob_p0_dof,
value * aij, ADD_VALUES);
283 {local_p0_dof}, {0.0}, flux*
value);
286 for (sbi=0; sbi<
eq_data_->n_substances(); sbi++)
287 VecSetValue(
eq_data_->bcvcorr[sbi], glob_p0_dof, 0, ADD_VALUES);
289 for (sbi=0; sbi<
eq_data_->n_substances(); sbi++)
291 {local_p0_dof}, {flux}, 0.0);
307 for(
unsigned int sbi=0; sbi <
eq_data_->n_substances(); sbi++) VecZeroEntries(
eq_data_->bcvcorr[sbi]);
318 for (
unsigned int sbi=0; sbi<
eq_data_->n_substances(); sbi++) VecAssemblyBegin(
eq_data_->bcvcorr[sbi]);
319 for (
unsigned int sbi=0; sbi<
eq_data_->n_substances(); sbi++) VecAssemblyEnd(
eq_data_->bcvcorr[sbi]);
327 shared_ptr<FiniteElement<dim>>
fe_;
341 template <
template<
IntDim...>
class DimAssembly>
362 template <
unsigned int dim,
class TEqData>
369 static constexpr
const char *
name() {
return "Convection_MatrixMpi_Assembly"; }
384 fe_ = std::make_shared< FE_P_disc<dim> >(0);
387 fe_high_ = std::make_shared< FE_P_disc<dim+1> >(0);
391 for (
unsigned int sid=0; sid<
eq_data_->max_edg_sides; sid++)
406 ASSERT_EQ(edge_side_range.
begin()->element().dim(), dim).error(
"Dimension of element mismatch!");
408 unsigned int sid=0, s1, s2, i_col;
425 unsigned int n_edge_sides = edge_side_range.
begin()->n_edge_sides();
426 if (n_edge_sides<2)
return;
427 for( s1=0; s1<n_edge_sides; s1++ )
429 for( s2=0, i_col=0; s2<n_edge_sides; s2++ )
431 if (s2==s1)
continue;
445 if (dim == 3)
return;
446 ASSERT_EQ(cell_lower_dim.
dim(), dim).error(
"Dimension of element mismatch!");
484 eq_data_->cfl_flow_.set(dh_cell.local_idx(), fabs(
eq_data_->cfl_flow_.get(dh_cell.local_idx())) );
487 MatAssemblyBegin(
eq_data_->tm, MAT_FINAL_ASSEMBLY);
488 MatAssemblyEnd(
eq_data_->tm, MAT_FINAL_ASSEMBLY);
489 VecAssemblyBegin(
eq_data_->cfl_flow_.petsc_vec());
490 VecAssemblyEnd(
eq_data_->cfl_flow_.petsc_vec());
492 eq_data_->is_convection_matrix_scaled =
false;
497 shared_ptr<FiniteElement<dim>>
fe_;
522 template <
template<
IntDim...>
class DimAssembly>
#define ASSERT_EQ(a, b)
Definition of comparative assert macro (EQual) only for debug mode.
Quadrature * quad_
Quadrature used in assembling methods.
std::shared_ptr< CouplingIntegralAcc< dim > > create_coupling_integral(Quadrature *quad)
std::shared_ptr< EdgeIntegralAcc< dim > > create_edge_integral(Quadrature *quad)
std::shared_ptr< BoundaryIntegralAcc< dim > > create_boundary_integral(Quadrature *quad)
std::shared_ptr< BulkIntegralAcc< dim > > create_bulk_integral(Quadrature *quad)
Quadrature * quad_low_
Quadrature used in assembling methods (dim-1).
ElementAccessor< 3 > element_accessor()
ConcSourcesBdrAssemblyConvection(EqData *eq_data, AssemblyInternals *asm_internals)
Constructor.
shared_ptr< FiniteElement< dim > > fe_
Finite element for the solution of the advection-diffusion equation.
TEqData::EqFields EqFields
std::shared_ptr< BulkIntegralAcc< dim > > bulk_integral_
Bulk integral of assembly class.
static constexpr const char * name()
void initialize()
Initialize auxiliary vectors and other data members.
FieldSet used_fields_
Sub field set contains fields used in calculation.
void boundary_side_integral(DHCellSide cell_side)
Assembles the fluxes on the boundary.
std::shared_ptr< BoundaryIntegralAcc< dim > > bdr_integral_
Boundary integral of assembly class.
void end() override
Implements AssemblyBase::end.
void cell_integral(DHCellAccessor cell, unsigned int element_patch_idx)
Assemble integral over element.
~ConcSourcesBdrAssemblyConvection()
Destructor.
EqFields * eq_fields_
Data objects shared with ConvectionTransport.
FEValues< 3 > fe_values_side_
FEValues of object (of P disc finite element type)
void begin() override
Implements AssemblyBase::begin.
Cell accessor allow iterate over DOF handler cells.
bool is_own() const
Return true if accessor represents own element (false for ghost element)
LocDofVec get_loc_dof_indices() const
Returns the local indices of dofs associated to the cell on the local process.
unsigned int get_dof_indices(std::vector< LongIdx > &indices) const
Fill vector of the global indices of dofs associated to the cell.
unsigned int dim() const
Return dimension of element appropriate to cell.
ElementAccessor< 3 > elm() const
Return ElementAccessor to element of loc_ele_idx_.
unsigned int local_idx() const
Return local index to element (index of DOF handler).
Side accessor allows to iterate over sides of DOF handler cell.
Side side() const
Return Side of given cell and side_idx.
const DHCellAccessor & cell() const
Return DHCellAccessor appropriate to the side.
unsigned int dim() const
Return dimension of element appropriate to the side.
ElementAccessor< 3 > element() const
double measure() const
Computes the measure of the element.
void initialize(Quadrature &_quadrature, FiniteElement< DIM > &_fe, UpdateFlags _flags)
Initialize structures and calculates cell-independent data.
void reinit(const ElementAccessor< spacedim > &cell)
Update cell-dependent data (gradients, Jacobians etc.)
Container for various descendants of FieldCommonBase.
Generic class of assemblation.
FieldSet used_fields_
Sub field set contains fields used in calculation.
void initialize()
Initialize auxiliary vectors and other data members.
std::vector< VectorMPI > vecs_
Set of data vectors of conc_mobile_fe objects.
std::shared_ptr< BulkIntegralAcc< dim > > bulk_integral_
Bulk integral of assembly class.
shared_ptr< FiniteElement< dim > > fe_
Finite element for the solution of the advection-diffusion equation.
TEqData::EqFields EqFields
EqFields * eq_fields_
Data objects shared with TransportDG.
void cell_integral(DHCellAccessor cell, unsigned int element_patch_idx)
Assemble integral over element.
static constexpr const char * name()
InitCondAssemblyConvection(EqData *eq_data, AssemblyInternals *asm_internals)
Constructor.
~InitCondAssemblyConvection()
Destructor.
MassAssemblyConvection(EqData *eq_data, AssemblyInternals *asm_internals)
Constructor.
FieldSet used_fields_
Sub field set contains fields used in calculation.
~MassAssemblyConvection()
Destructor.
std::shared_ptr< BulkIntegralAcc< dim > > mass_integral_
Bulk integral of assembly class.
shared_ptr< FiniteElement< dim > > fe_
Finite element for the solution of the advection-diffusion equation.
TEqData::EqFields EqFields
void begin() override
Implements AssemblyBase::begin.
static constexpr const char * name()
void cell_integral(DHCellAccessor cell, unsigned int element_patch_idx)
Assemble integral over element.
void initialize()
Initialize auxiliary vectors and other data members.
void end() override
Implements AssemblyBase::end.
EqFields * eq_fields_
Data objects shared with TransportDG.
vector< FEValues< 3 > > fe_values_vec_
Vector of FEValues of object (of P disc finite element types)
std::vector< double > elm_meassures_
shared_ptr< FiniteElement< dim+1 > > fe_high_
Same as previous but represents finite element of higher dim of join integral.
void initialize()
Initialize auxiliary vectors and other data members.
std::vector< LongIdx > all_elem_dofs_
std::shared_ptr< EdgeIntegralAcc< dim > > edge_integral_
Edge integral of assembly class.
void end() override
Implements AssemblyBase::end.
static constexpr const char * name()
void dimjoin_intergral(DHCellAccessor cell_lower_dim, DHCellSide neighb_side)
Assembles the fluxes between elements of different dimensions.
EqFields * eq_fields_
Data objects shared with ConvectionTransport.
FieldSet used_fields_
Sub field set contains fields used in calculation.
FEValues< 3 > fe_values_side_
FEValues of object (of P disc finite element type)
~MatrixMpiAssemblyConvection()
Destructor.
std::vector< double > side_flux_
shared_ptr< FiniteElement< dim > > fe_
Finite element for the solution of the advection-diffusion equation.
std::shared_ptr< CouplingIntegralAcc< dim > > coupling_integral_
Coupling integral of assembly class.
std::vector< LongIdx > side_dofs_
void begin() override
Implements AssemblyBase::begin.
vector< LongIdx > dof_indices_j_
Global DOF indices.
vector< LongIdx > dof_indices_i_
std::vector< double > row_values_
MatrixMpiAssemblyConvection(EqData *eq_data, AssemblyInternals *asm_internals)
Constructor.
TEqData::EqFields EqFields
void edge_integral(RangeConvert< DHEdgeSide, DHCellSide > edge_side_range)
Assembles the fluxes between sides of elements of the same dimension.
IterConvert< ObjectIn, ObjectOut > begin()
Iterator to begin item of range.
unsigned int bulk_idx() const
Returns index of the region in the bulk set.
Definitions of basic Lagrangean finite elements with polynomial shape functions.
Class FEValues calculates finite element data on the actual cells such as shape function values,...
int LongIdx
Define type that represents indices of large arrays (elements, nodes, dofs etc.)
static constexpr bool value
unsigned int IntDim
A dimension index type.
Definitions of particular quadrature rules on simplices.
Holds common data shared between GenericAssemblz and Assembly<dim> classes.
UpdateFlags
Enum type UpdateFlags indicates which quantities are to be recomputed on each finite element cell.
@ update_values
Shape function values.
@ update_normal_vectors
Normal vectors.
@ update_side_JxW_values
Transformed quadrature weight for cell sides.
@ update_quadrature_points
Transformed quadrature points.