18 #ifndef ASSEMBLY_RICHARDS_HH_
19 #define ASSEMBLY_RICHARDS_HH_
28 template <
unsigned int dim,
class TEqData>
35 static constexpr
const char *
name() {
return "Richards_InitCondPostprocess_Assembly"; }
58 ASSERT_EQ(cell.
dim(), dim).error(
"Dimension of element mismatch!");
71 for (
unsigned int i=0; i<cell.
elm()->n_sides(); i++) {
78 fadbad::B<double> x_phead(
phead);
79 fadbad::B<double> evaluated( this->
eq_data_->soil_model_->water_content_diff(x_phead) );
87 this->
eq_data_->balance_->add_mass_values(
eq_data_->water_balance_idx, dh_cell, {local_side},
95 this->
eq_data_->balance_->start_mass_assembly(this->
eq_data_->water_balance_idx);
102 this->
eq_data_->balance_->finish_mass_assembly(this->
eq_data_->water_balance_idx);
111 soil_data.
n = this->
eq_fields_->genuchten_n_exponent(p);
113 soil_data.
Qr = this->
eq_fields_->water_content_residual(p);
114 soil_data.
Qs = this->
eq_fields_->water_content_saturated(p);
118 this->
eq_data_->soil_model_->reset(soil_data);
139 template <
template<
IntDim...>
class DimAssembly>
144 template <
unsigned int dim,
class TEqData>
151 static constexpr
const char *
name() {
return "Richards_MHMatrix_Assembly"; }
188 ASSERT_EQ(cell.
dim(), dim).error(
"Dimension of element mismatch!");
191 auto p = *( this->
bulk_integral_->points(element_patch_idx).begin() );
203 ASSERT_EQ(cell_side.
dim(), dim).error(
"Dimension of element mismatch!");
206 auto p_side = *( this->
bdr_integral_->points(cell_side).begin() );
250 for (
unsigned int i=0; i<ele->
n_sides(); i++)
285 eq_data_->balance_->add_mass_values(
eq_data_->water_balance_idx, cell, {local_side},
294 bool genuchten_on = (this->eq_fields_->genuchten_p_head_scale.field_result({cell.
elm().region()}) !=
result_zeros);
297 soil_data.
n = this->eq_fields_->genuchten_n_exponent(p);
298 soil_data.
alpha = this->eq_fields_->genuchten_p_head_scale(p);
299 soil_data.
Qr = this->eq_fields_->water_content_residual(p);
300 soil_data.
Qs = this->eq_fields_->water_content_saturated(p);
301 soil_data.
Ks = this->eq_fields_->conductivity(p);
304 this->eq_data_->soil_model_->reset(soil_data);
314 bool genuchten_on = reset_soil_model(cell, p);
315 storativity_ = this->eq_fields_->storativity(p)
316 + this->eq_fields_->extra_storativity(p);
317 VectorMPI water_content_vec = this->eq_fields_->water_content_ptr->vec();
319 for (
unsigned int i=0; i<cell.
elm()->n_sides(); i++) {
322 phead = this->eq_data_->p_edge_solution.
get( edge_indices_[i] );
325 fadbad::B<double> x_phead(phead);
326 fadbad::B<double> evaluated( this->eq_data_->soil_model_->water_content_diff(x_phead) );
328 water_content = evaluated.val();
329 capacity = x_phead.d(0);
331 this->eq_data_->capacity.set( cr_disc_dofs_[i], capacity + storativity_ );
332 water_content_vec.
set( cr_disc_dofs_[i], water_content + storativity_ * phead);
339 bool genuchten_on = reset_soil_model(cell, p);
341 double conductivity = 0;
346 for (
unsigned int i=0; i<cell.
elm()->n_sides(); i++)
348 double phead = eq_data_->p_edge_solution.get( loc_dof_vec[i] );
349 conductivity += eq_data_->soil_model_->conductivity(phead);
354 conductivity = eq_fields_->conductivity(p);
363 this->postprocess_velocity(dh_cell, p);
365 this->update_water_content(dh_cell, p);
367 VectorMPI water_content_vec = eq_fields_->water_content_ptr->vec();
369 for (
unsigned int i=0; i<dh_cell.
elm()->n_sides(); i++) {
370 water_content = water_content_vec.
get( this->cr_disc_dofs_[i] );
371 water_content_previous_time = eq_data_->water_content_previous_time.get( this->cr_disc_dofs_[i] );
373 solution[eq_data_->loc_side_dofs[dim-1][i]]
374 += this->edge_source_term_ - this->edge_scale_ * (water_content - water_content_previous_time) / eq_data_->time_step_;
378 eq_fields_->conductivity_ptr->vec().set( p_dof, compute_conductivity(dh_cell, p) );
394 template <
template<
IntDim...>
class DimAssembly>
399 template <
unsigned int dim,
class TEqData>
406 static constexpr
const char *
name() {
return "Richards_ReconstructSchur_Assembly"; }
415 ASSERT_EQ(cell.
dim(), dim).error(
"Dimension of element mismatch!");
418 auto p = *( this->
bulk_integral_->points(element_patch_idx).begin() );
449 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< BulkIntegralAcc< dim > > create_bulk_integral(Quadrature *quad)
ElementAccessor< 3 > element_accessor()
Base point accessor class.
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.
DHCellAccessor cell_with_other_dh(const DOFHandlerMultiDim *dh) const
Create new accessor with same local idx and given DOF handler. Actual and given DOF handler must be c...
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.
double measure() const
Computes the measure of the element.
unsigned int n_sides() const
Container for various descendants of FieldCommonBase.
Generic class of assemblation.
~InitCondPostprocessAssembly()
Destructor.
FieldSet used_fields_
Sub field set contains fields used in calculation.
TEqData::EqFields EqFields
std::shared_ptr< BulkIntegralAcc< dim > > bulk_integral_
Bulk integral of assembly class.
void initialize()
Initialize auxiliary vectors and other data members.
InitCondPostprocessAssembly(EqData *eq_data, AssemblyInternals *asm_internals)
Constructor.
bool reset_soil_model(const DHCellAccessor &cell, BulkPoint &p)
LocDofVec edge_indices_
Dofs of discontinuous fields on element edges.
static constexpr const char * name()
void cell_integral(DHCellAccessor cell, unsigned int element_patch_idx)
LocDofVec cr_disc_dofs_
Vector of local DOF indices pre-computed on different DOF handlers.
EqFields * eq_fields_
Data objects shared with ConvectionTransport.
void end() override
Implements AssemblyBase::end.
void begin() override
Implements AssemblyBase::begin.
void asm_sides(BulkPoint &p, double conductivity, unsigned int element_patch_idx)
Part of cell_integral method, common in all descendants.
void begin_mh_matrix()
Common code of begin method of MH matrix assembly (Darcy and Richards)
void end_reconstruct_schur()
Common code of end method of Reconstruct Schur assembly (Darcy and Richards)
void begin_reconstruct_schur()
Common code of begin method of Reconstruct Schur assembly (Darcy and Richards)
FieldSet used_fields_
Sub field set contains fields used in calculation.
unsigned int bulk_local_idx_
Local idx of bulk element.
void initialize()
Initialize auxiliary vectors and other data members.
void boundary_side_integral_in(DHCellSide cell_side, const ElementAccessor< 3 > &b_ele, BulkPoint &p_bdr)
void asm_element()
Part of cell_integral method, common in all descendants.
DarcyLMH::EqFields::BC_Type type_
Type of boundary condition.
void end_mh_matrix()
Common code of end method of MH matrix assembly (Darcy and Richards)
std::shared_ptr< BulkIntegralAcc< dim > > bulk_integral_
Bulk integral of assembly class.
void use_dirichlet_switch(DHCellSide &cell_side, const ElementAccessor< 3 > &b_ele, BulkPoint &p_bdr)
Update BC switch dirichlet in MH matrix assembly if BC type is seepage.
std::shared_ptr< BoundaryIntegralAcc< dim > > bdr_integral_
Boundary integral of assembly class.
void precompute_boundary_side(DHCellSide &cell_side, BoundaryPoint &p_side, BulkPoint &p_bdr)
Precompute values used in boundary side integral on given DHCellSide.
TEqData::EqFields EqFields
void boundary_side_integral(DHCellSide cell_side)
Assembles between boundary element and corresponding side on bulk element.
void asm_source_term_richards(const DHCellAccessor &cell, BulkPoint &p)
Part of cell_integral method, specialized in Richards equation.
~MHMatrixAssemblyRichards()
Destructor.
bool reset_soil_model(const DHCellAccessor &cell, BulkPoint &p)
void update_water_content(const DHCellAccessor &cell, BulkPoint &p)
void initialize()
Initialize auxiliary vectors and other data members.
void end() override
Implements AssemblyBase::end.
void cell_integral(DHCellAccessor cell, unsigned int element_patch_idx)
Integral over element.
double compute_conductivity(const DHCellAccessor &cell, BulkPoint &p)
Precompute conductivity on bulk point.
void postprocess_velocity_richards(const DHCellAccessor &dh_cell, BulkPoint &p, arma::vec &solution)
Postprocess velocity after calculating of cell integral.
double water_content_diff_
LocDofVec edge_indices_
Dofs of discontinuous fields on element edges.
EqFields * eq_fields_
Data objects shared with ConvectionTransport.
LocDofVec cr_disc_dofs_
Vector of local DOF indices pre-computed on different DOF handlers.
MHMatrixAssemblyRichards(EqData *eq_data, AssemblyInternals *asm_internals)
static constexpr const char * name()
void begin() override
Implements AssemblyBase::begin.
TEqData::EqFields EqFields
void end() override
Implements AssemblyBase::end.
void boundary_side_integral(FMT_UNUSED DHCellSide cell_side)
Assembles between boundary element and corresponding side on bulk element.
void cell_integral(DHCellAccessor cell, unsigned int element_patch_idx)
Integral over element.
ReconstructSchurAssemblyRichards(EqData *eq_data, AssemblyInternals *asm_internals)
static constexpr const char * name()
void dimjoin_intergral(FMT_UNUSED DHCellAccessor cell_lower_dim, FMT_UNUSED DHCellSide neighb_side)
void begin() override
Implements AssemblyBase::begin.
unsigned int bulk_idx() const
Returns index of the region in the bulk set.
double get(unsigned int pos) const
Return value on given position.
void set(unsigned int pos, double val)
Set value on given position.
arma::Col< IntIdx > LocDofVec
unsigned int IntDim
A dimension index type.
Holds common data shared between GenericAssemblz and Assembly<dim> classes.