Flow123d
JS_before_hm-2198-g122e1f2e2
|
Go to the documentation of this file.
18 #ifndef ASSEMBLY_LMH_HH_
19 #define ASSEMBLY_LMH_HH_
44 template <
unsigned int dim>
51 static constexpr
const char *
name() {
return "ReadInitCondAssemblyLMH"; }
72 if (cell.
dim() != dim)
return;
78 auto p = *( this->
bulk_points(element_patch_idx).begin() );
81 for (
unsigned int i=0; i<cell.
elm()->
n_sides(); i++) {
110 template <
template<
IntDim...>
class DimAssembly>
115 template <
unsigned int dim>
124 static constexpr
const char *
name() {
return "MHMatrixAssemblyLMH"; }
153 fe_ = std::make_shared< FE_P_disc<dim> >(0);
181 if (cell.
dim() != dim)
return;
184 auto p = *( this->
bulk_points(element_patch_idx).begin() );
188 auto ele = cell.
elm();
195 for (
unsigned int k=0; k<
qsize_; k++)
196 for (
unsigned int i=0; i<
ndofs_; i++){
201 for (
unsigned int j=0; j<
ndofs_; j++){
203 arma::dot( velocity.value(i,k),
260 ASSERT_EQ_DBG(cell_side.
dim(), dim).error(
"Dimension of element mismatch!");
334 THROW( ExcBCNotSupported() );
338 {eq_data_->loc_system_[bulk_local_idx_].row_dofs[eq_data_->loc_side_dofs[dim-1][sidx_]]},
346 if (dim == 1)
return;
347 ASSERT_EQ_DBG(cell_lower_dim.
dim(), dim-1).error(
"Dimension of element mismatch!");
349 unsigned int neigh_idx =
ngh_idx(cell_lower_dim, neighb_side);
350 unsigned int loc_dof_higher = (2*(cell_lower_dim.
dim()+1) + 1) + neigh_idx;
355 auto p_low = p_high.lower_dim(cell_lower_dim);
411 unsigned int size, loc_size, loc_size_schur, elm_dim;;
417 size = (elm_dim+1) + 1 + (elm_dim+1);
424 dofs.head(dh_cell.n_dofs()) = dh_cell.get_loc_dof_indices();
433 for (
DHCellSide neighb_side : dh_cell.neighb_sides() ) {
444 const unsigned int p = size+i;
446 const unsigned int t = dh_neighb_cell.
n_dofs() - dh_neighb_cr_cell.
n_dofs() + neighb_side.side().side_idx();
450 const unsigned int tt = dh_cr_cell.
n_dofs()+i;
459 for (
DHCellSide dh_side : dh_cell.side_range()) {
460 unsigned int sidx = dh_side.side_idx();
505 for (
unsigned int i=0; i<
n_sides_; i++)
534 for (
uint n_i=0; n_i<dh_cell.
elm()->n_neighs_vb(); ++n_i) {
536 if ( (side->elem_idx() == neighb_side.
elem_idx()) && (side->side_idx() == neighb_side.
side_idx()) )
return n_i;
538 ASSERT(
false)(dh_cell.
elm_idx())(neighb_side.
side_idx()).error(
"Side is not a part of neighbour!\n");
551 if (eq_data_->bc_fluxes_reconstruted[bulk_local_idx_])
555 auto ls = eq_data_->seepage_bc_systems.find(dh_cell.
elm_idx());
556 if (ls != eq_data_->seepage_bc_systems.end())
558 arma::vec schur_solution = eq_data_->p_edge_solution.get_subvec(eq_data_->loc_schur_[bulk_local_idx_].row_dofs);
560 ls->second.reconstruct_solution_schur(eq_data_->schur_offset_[dim-1], schur_solution, reconstructed_solution_);
562 unsigned int pos_in_cache = this->element_cache_map_->position_in_cache(dh_cell.
elm_idx());
563 postprocess_velocity(dh_cell, pos_in_cache, reconstructed_solution_);
565 eq_data_->bc_fluxes_reconstruted[bulk_local_idx_] =
true;
572 auto p = *( this->bulk_points(element_patch_idx).begin() );
575 * eq_fields_->cross_section(p)
578 edge_source_term_ = edge_scale_ *
579 ( eq_fields_->water_source_density(p)
580 + eq_fields_->extra_source(p));
582 postprocess_velocity_specific(dh_cell, p, solution, edge_scale_, edge_source_term_);
587 double edge_scale,
double edge_source_term)
590 for (
unsigned int i=0; i<dh_cell.
elm()->n_sides(); i++) {
592 if( ! eq_data_->use_steady_assembly_)
594 new_pressure_ = eq_data_->p_edge_solution.get(eq_data_->loc_schur_[bulk_local_idx_].row_dofs[i]);
595 old_pressure_ = eq_data_->p_edge_solution_previous_time.get(eq_data_->loc_schur_[bulk_local_idx_].row_dofs[i]);
596 time_term_ = edge_scale * (eq_fields_->storativity(p) + eq_fields_->extra_storativity(p))
597 / eq_data_->time_step_ * (new_pressure_ - old_pressure_);
599 solution[eq_data_->loc_side_dofs[dim-1][i]] += edge_source_term - time_term_;
605 return eq_fields_->conductivity(p);
612 if (switch_dirichlet) {
618 this->load_local_system(cell_side.
cell());
620 if ( reconstructed_solution_[side_row_] < side_flux_) {
622 switch_dirichlet = 0;
635 solution_head_ = eq_data_->p_edge_solution.get(eq_data_->loc_schur_[bulk_local_idx_].row_dofs[sidx_]);
637 if ( solution_head_ > bc_pressure_) {
659 shared_ptr<FiniteElement<dim>>
fe_;
671 unsigned int sidx_, side_row_, edge_row_;
680 template <
template<
IntDim...>
class DimAssembly>
685 template <
unsigned int dim>
692 static constexpr
const char *
name() {
return "ReconstructSchurAssemblyLMH"; }
733 schur_solution, this->reconstructed_solution_);
738 this->eq_data_->schur_offset_[dh_cell.dim()-1]), this->reconstructed_solution_);
740 this->eq_data_->loc_schur_[this->bulk_local_idx_].row_dofs.n_elem), schur_solution);
BCField< 3, FieldValue< 3 >::Scalar > bc_pressure
unsigned int n_neighs_vb() const
Return number of neighbours.
std::vector< bool > save_local_system_
Flag for saving the local system. Currently used only in case of seepage BC.
arma::Col< IntIdx > LocDofVec
LocDofVec l_indices_
Vectors of local DOF indices pre-computed on different DOF handlers.
Raviart-Thomas element of order 0.
Edge edge() const
Returns pointer to the edge connected to the side.
double init_value_on_edge_
Pre-computed values of init_pressure.
virtual double compute_conductivity(FMT_UNUSED const DHCellAccessor &cell, BulkPoint &p)
void begin() override
Implements AssemblyBase::begin.
DarcyLMH::EqFields EqFields
EqFields * eq_fields_
Data objects shared with Flow equation.
FE_RT0< dim > fe_rt_
Assembly volume integrals.
Field< 3, FieldValue< 3 >::Scalar > sigma
Definitions of Raviart-Thomas finite elements.
void reset()
Reset data members.
const FEValuesViews::Vector< spacedim > & vector_view(unsigned int i) const
Accessor to vector values of multicomponent FE.
EqFields * eq_fields_
Data objects shared with DarcyFlow.
unsigned int n_points() const
Returns the number of quadrature points.
Side side() const
Return Side of given cell and side_idx.
void reconstruct_schur_finish()
void dirichlet_switch(FMT_UNUSED char &switch_dirichlet, FMT_UNUSED DHCellSide cell_side) override
void end() override
Implements AssemblyBase::end.
VectorMPI p_edge_solution
Quadrature * quad_low_
Quadrature used in assembling methods (dim-1).
#define ASSERT(expr)
Allow use shorter versions of macro names if these names is not used with external library.
BCField< 3, FieldValue< 3 >::Scalar > bc_robin_sigma
arma::vec::fixed< spacedim > normal_vector(unsigned int point_no)
Returns the normal vector to a side at given quadrature point.
FieldSet used_fields_
Sub field set contains fields used in calculation.
double JxW(const unsigned int point_no)
Return the product of Jacobian determinant and the quadrature weight at given quadrature point.
BCField< 3, FieldValue< 3 >::Scalar > bc_flux
void ghost_to_local_begin()
ghost_to_local_{begin,end} updates the local values by adding ghost values from neighbouring processo...
unsigned int n_sides() const
Returns number of sides aligned with the edge.
std::map< LongIdx, LocalSystem > seepage_bc_systems
Directing class of FieldValueCache.
std::shared_ptr< SubDOFHandlerMultiDim > dh_cr_
DOF handler represents DOFs of edges.
Field< 3, FieldValue< 3 >::Scalar > extra_source
Externally added storativity.
Class FEValues calculates finite element data on the actual cells such as shape function values,...
bool is_own() const
Return true if accessor represents own element (false for ghost element)
virtual ~ReadInitCondAssemblyLMH()
Destructor.
void end() override
Implements AssemblyBase::end.
@ update_values
Shape function values.
Base point accessor class.
void postprocess_velocity(const DHCellAccessor &dh_cell, unsigned int element_patch_idx, arma::vec &solution)
std::array< unsigned int, 3 > schur_offset_
Index offset in the local system for the Schur complement (of dim = 1,2,3).
Field< 3, FieldValue< 3 >::Scalar > init_pressure
void initialize(Quadrature &_quadrature, FiniteElement< DIM > &_fe, UpdateFlags _flags)
Initialize structures and calculates cell-independent data.
#define THROW(whole_exception_expr)
Wrapper for throw. Saves the throwing point.
void dimjoin_intergral(DHCellAccessor cell_lower_dim, DHCellSide neighb_side)
Assembles the fluxes between elements of different dimensions.
@ update_quadrature_points
Transformed quadrature points.
#define ASSERT_EQ_DBG(a, b)
Definition of comparative assert macro (EQual) only for debug mode.
std::shared_ptr< LinSys > lin_sys_schur
void boundary_side_integral(DHCellSide cell_side)
unsigned int dim() const
Return dimension of element appropriate to cell.
@ update_normal_vectors
Normal vectors.
unsigned int dim() const
Return dimension of element appropriate to the side.
void cell_integral(DHCellAccessor cell, unsigned int element_patch_idx)
Assemble integral over element.
FieldSet used_fields_
Sub field set contains fields used in calculation.
Solver based on the original PETSc solver using MPIAIJ matrix and succesive Schur complement construc...
void initialize(ElementCacheMap *element_cache_map)
Initialize auxiliary vectors and other data members.
Lumped mixed-hybrid model of linear Darcy flow, possibly unsteady.
const Element * element() const
Class FESystem for compound finite elements.
std::shared_ptr< DOFHandlerMultiDim > dh_
full DOF handler represents DOFs of sides, elements and edges
unsigned int ndofs_
Number of dofs.
double old_pressure_
Precomputed values in postprocess_velocity_specific.
Definitions of basic Lagrangean finite elements with polynomial shape functions.
void postprocess_bulk_integral(const DHCellAccessor &cell, unsigned int element_patch_idx) override
Side accessor allows to iterate over sides of DOF handler cell.
double bc_sigma_
Precomputed values in boundary assembly.
ReadInitCondAssemblyLMH(EqFields *eq_fields, EqData *eq_data)
Constructor.
Field< 3, FieldValue< 3 >::Scalar > cross_section
unsigned int n_dofs() const
Returns the number of shape functions.
std::array< std::vector< unsigned int >, 3 > loc_edge_dofs
DECLARE_EXCEPTION(ExcBCNotSupported,<< "BC type not supported.\n")
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...
Field< 3, FieldValue< 3 >::Scalar > water_source_density
const DHCellAccessor & cell() const
Return DHCellAccessor appropriate to the side.
static constexpr const char * name()
std::vector< char > bc_switch_dirichlet
Idicator of dirichlet or neumann type of switch boundary conditions.
virtual void assemble_source_term(const DHCellAccessor &cell, BulkPoint &p)
Field< 3, FieldValue< 3 >::Scalar > conductivity
void load_local_system(const DHCellAccessor &dh_cell)
std::vector< arma::vec > postprocess_solution_
std::vector< LocalSystem > loc_schur_
Definitions of particular quadrature rules on simplices.
int is_linear
Hack fo BDDC solver.
unsigned int local_idx() const
Return local index to element (index of DOF handler).
void begin() override
Implements AssemblyBase::begin.
void end() override
Implements AssemblyBase::end.
Assembly explicit Schur complement for the given linear system. Provides method for resolution of the...
std::vector< LocalSystem > loc_system_
Following data members are stored in vectors, one item for every cell.
virtual void postprocess_velocity_specific(const DHCellAccessor &dh_cell, BulkPoint &p, arma::vec &solution, double edge_scale, double edge_source_term)
double cross_section_
Precomputed cross-section value.
BCField< 3, FieldValue< 3 >::Scalar > bc_switch_pressure
const ElementAccessor< 3 > elm() const
Return ElementAccessor to element of loc_ele_idx_.
static constexpr const char * name()
shared_ptr< FiniteElement< dim > > fe_
Finite element for the solution of the advection-diffusion equation.
double source_term_
Variables used in compute lumped source.
arma::vec get_subvec(const LocDofVec &loc_indices)
virtual void postprocess_bulk_integral(FMT_UNUSED const DHCellAccessor &cell, FMT_UNUSED unsigned intelement_patch_idx)
DarcyLMH::EqFields EqFields
double time_term_rhs_
Variables used in compute time term (unsteady)
void ghost_to_local_end()
ghost_to_local_{begin,end} updates the local values by adding ghost values from neighbouring processo...
virtual void dirichlet_switch(char &switch_dirichlet, DHCellSide cell_side)
void local_to_ghost_begin()
local_to_ghost_{begin,end} updates the ghost values on neighbouring processors from local values
double mat_val_
Precomputed RHS and mat value.
double scale_sides_
Precomputed value (1 / cross_section / conductivity)
Container for various descendants of FieldCommonBase.
unsigned int n_dofs() const
Return number of dofs on given cell.
ElementAccessor< 3 > element_accessor()
BCField< 3, FieldValue< 3 >::Enum > bc_type
unsigned int elm_idx() const
Return serial idx to element of loc_ele_idx_.
bool force_no_neumann_bc
auxiliary flag for switchting Dirichlet like BC
unsigned int nonlinear_iteration_
void add(unsigned int pos, double val)
Add value to item on given position.
Symmetric Gauss-Legendre quadrature formulae on simplices.
bool use_steady_assembly_
DarcyLMH::EqFields EqFields
unsigned int elem_idx() const
Range< BulkPoint > bulk_points(unsigned int element_patch_idx) const
Return BulkPoint range of appropriate dimension.
double side_flux_
Precomputed values in boundary assembly.
arma::vec reconstructed_solution_
Vector for reconstructed solution (velocity and pressure on element) from Schur complement.
MHMatrixAssemblyLMH(EqFields *eq_fields, EqData *eq_data)
Constructor.
FEValues< 3 > fe_values_side_
FEValues of object (of P disc finite element type)
unsigned int l_idx_
Local DOF indices extract from previous vectors.
double solution_head_
Precomputed value in boundary assembly.
unsigned int n_sides() const
std::array< std::vector< unsigned int >, 3 > loc_side_dofs
Cell accessor allow iterate over DOF handler cells.
void set_subvec(const LocDofVec &loc_indices, const arma::vec &values)
virtual ~MHMatrixAssemblyLMH()
Destructor.
std::vector< unsigned int > fe_dofs(unsigned int fe_index)
Return dof indices belonging to given sub-FE.
unsigned int ngh_idx(DHCellAccessor &dh_cell, DHCellSide &neighb_side)
Temporary method find neighbour index in higher-dim cell.
int active_integrals_
Holds mask of active integrals.
std::shared_ptr< Balance > balance
arma::vec3 nv_
Normal vector.
@ update_JxW_values
Transformed quadrature weights.
double edge_source_term_
Precomputed values in postprocess_velocity.
void local_to_ghost_end()
local_to_ghost_{begin,end} updates the ghost values on neighbouring processors from local values
LocDofVec get_loc_dof_indices() const
Returns the local indices of dofs associated to the cell on the local process.
unsigned int bulk_local_idx_
Local idx of bulk element.
double bc_switch_pressure_
unsigned int idx() const
We need this method after replacing Region by RegionIdx, and movinf RegionDB instance into particular...
Field< 3, FieldValue< 3 >::Scalar > extra_storativity
double ngh_value_
Precomputed ngh value.
double get(unsigned int pos) const
Return value on given position.
void reinit(const ElementAccessor< spacedim > &cell)
Update cell-dependent data (gradients, Jacobians etc.)
Field< 3, FieldValue< 3 >::Scalar > storativity
std::shared_ptr< Balance > balance_
Shared Balance object.
static constexpr const char * name()
Range< CouplingPoint > coupling_points(const DHCellSide &cell_side) const
Return CouplingPoint range of appropriate dimension.
unsigned int side_idx() const
void initialize(ElementCacheMap *element_cache_map)
Initialize auxiliary vectors and other data members.
SideIter side(const unsigned int loc_index)
unsigned int qsize_
Size of quadrature of dim-1.
std::array< unsigned int, 3 > loc_ele_dof
Field< 3, FieldValue< 3 >::TensorFixed > anisotropy
Generic class of assemblation.
Compound finite element on dim dimensional simplex.
ReconstructSchurAssemblyLMH(EqFields *eq_fields, EqData *eq_data)
Constructor.
Range< BoundaryPoint > boundary_points(const DHCellSide &cell_side) const
Return BoundaryPoint range of appropriate dimension.
void cell_integral(DHCellAccessor cell, unsigned int element_patch_idx)
Assemble source term (integral over element)
ElementCacheMap * element_cache_map_
ElementCacheMap shared with GenericAssembly object.
unsigned int edge_row_
Helper indices in boundary assembly.
double measure() const
Computes the measure of the element.
VectorMPI p_edge_solution_previous_time
unsigned int IntDim
A dimension index type.