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++) {
173 template <
template<
IntDim...>
class DimAssembly>
185 template <
unsigned int dim,
class TEqData>
192 static constexpr
const char *
name() {
return "Convection_ConcSourcesBdr_Assembly"; }
219 ASSERT_EQ(cell.
dim(), dim).error(
"Dimension of element mismatch!");
220 if (!
eq_data_->sources_changed_)
return;
231 for (
unsigned int sbi = 0; sbi <
eq_data_->n_substances(); sbi++)
236 eq_data_->corr_vec[sbi].set(local_p0_dof, source);
239 eq_data_->tm_diag[sbi].set(local_p0_dof, - diag);
242 max_cfl = std::max(max_cfl, fabs(diag));
245 {- eq_fields_->sources_sigma[sbi](p) * elm.measure() * eq_fields_->cross_section(p)},
246 {source * elm.measure()});
249 eq_data_->cfl_source_.set(local_p0_dof, max_cfl);
255 ASSERT_EQ(cell_side.
dim(), dim).error(
"Dimension of element mismatch!");
261 LongIdx glob_p0_dof =
eq_data_->dh_->get_local_to_global_map()[local_p0_dof];
270 for (sbi=0; sbi<
eq_data_->n_substances(); sbi++)
274 VecSetValue(
eq_data_->bcvcorr[sbi], glob_p0_dof,
value * aij, ADD_VALUES);
279 {local_p0_dof}, {0.0}, flux*
value);
282 for (sbi=0; sbi<
eq_data_->n_substances(); sbi++)
283 VecSetValue(
eq_data_->bcvcorr[sbi], glob_p0_dof, 0, ADD_VALUES);
285 for (sbi=0; sbi<
eq_data_->n_substances(); sbi++)
287 {local_p0_dof}, {flux}, 0.0);
303 for(
unsigned int sbi=0; sbi <
eq_data_->n_substances(); sbi++) VecZeroEntries(
eq_data_->bcvcorr[sbi]);
314 for (
unsigned int sbi=0; sbi<
eq_data_->n_substances(); sbi++) VecAssemblyBegin(
eq_data_->bcvcorr[sbi]);
315 for (
unsigned int sbi=0; sbi<
eq_data_->n_substances(); sbi++) VecAssemblyEnd(
eq_data_->bcvcorr[sbi]);
336 template <
template<
IntDim...>
class DimAssembly>
357 template <
unsigned int dim,
class TEqData>
364 static constexpr
const char *
name() {
return "Convection_MatrixMpi_Assembly"; }
394 ASSERT_EQ(edge_side_range.
begin()->element().dim(), dim).error(
"Dimension of element mismatch!");
396 unsigned int sid=0, s1, s2, i_col;
412 unsigned int n_edge_sides = edge_side_range.
begin()->n_edge_sides();
413 if (n_edge_sides<2)
return;
414 for( s1=0; s1<n_edge_sides; s1++ )
416 for( s2=0, i_col=0; s2<n_edge_sides; s2++ )
418 if (s2==s1)
continue;
432 if (dim == 3)
return;
433 ASSERT_EQ(cell_lower_dim.
dim(), dim).error(
"Dimension of element mismatch!");
470 eq_data_->cfl_flow_.set(dh_cell.local_idx(), fabs(
eq_data_->cfl_flow_.get(dh_cell.local_idx())) );
473 MatAssemblyBegin(
eq_data_->tm, MAT_FINAL_ASSEMBLY);
474 MatAssemblyEnd(
eq_data_->tm, MAT_FINAL_ASSEMBLY);
475 VecAssemblyBegin(
eq_data_->cfl_flow_.petsc_vec());
476 VecAssemblyEnd(
eq_data_->cfl_flow_.petsc_vec());
478 eq_data_->is_convection_matrix_scaled =
false;
508 template <
template<
IntDim...>
class DimAssembly>
#define ASSERT_EQ(a, b)
Definition of comparative assert macro (EQual) only for debug mode.
std::shared_ptr< CouplingIntegralAcc< dim > > create_coupling_integral(Quadrature *quad)
std::shared_ptr< BulkIntegralAcc< dim > > create_bulk_integral(Quadrature *quad)
Quadrature * quad_low_
Quadrature used in assembling methods (dim-1).
Quadrature * quad_
Quadrature used in assembling methods.
std::shared_ptr< EdgeIntegralAcc< dim > > create_edge_integral(Quadrature *quad)
std::shared_ptr< BoundaryIntegralAcc< dim > > create_boundary_integral(Quadrature *quad)
ElementAccessor< 3 > element_accessor()
ConcSourcesBdrAssemblyConvection(EqData *eq_data, AssemblyInternals *asm_internals)
Constructor.
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.
ElQ< Vector > normal_bdr_
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.
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.
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.
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.
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.
std::vector< double > elm_meassures_
void initialize()
Initialize auxiliary vectors and other data members.
std::vector< LongIdx > all_elem_dofs_
ElQ< Vector > normal_side_
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.
~MatrixMpiAssemblyConvection()
Destructor.
std::vector< double > side_flux_
ElQ< Vector > normal_join_
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.
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.
Class FEValues calculates finite element data on the actual cells such as shape function values,...
Store finite element reinit functions.
Definitions of particular quadrature rules on simplices.
Holds common data shared between GenericAssemblz and Assembly<dim> classes.