18 #ifndef ASSEMBLY_ELASTICITY_HH_ 19 #define ASSEMBLY_ELASTICITY_HH_ 34 template <
unsigned int dim>
41 static constexpr
const char *
name() {
return "StiffnessAssemblyElasticity"; }
63 shared_ptr<FE_P<dim>> fe_p = std::make_shared< FE_P<dim> >(1);
64 shared_ptr<
FE_P<dim-1>> fe_p_low = std::make_shared<
FE_P<dim-1> >(1);
65 fe_ = std::make_shared<FESystem<dim>>(fe_p,
FEVector, 3);
83 for (
uint m=0; m<2; ++m) {
85 for (
uint n=0; n<2; ++n)
97 if (cell.
dim() != dim)
return;
105 for (
unsigned int i=0; i<
n_dofs_; i++)
106 for (
unsigned int j=0; j<
n_dofs_; j++)
110 for (
auto p : this->
bulk_points(element_patch_idx) )
112 for (
unsigned int i=0; i<
n_dofs_; i++)
114 for (
unsigned int j=0; j<
n_dofs_; j++)
128 ASSERT_EQ_DBG(cell_side.
dim(), dim).error(
"Dimension of element mismatch!");
136 for (
unsigned int i=0; i<
n_dofs_; i++)
137 for (
unsigned int j=0; j<
n_dofs_; j++)
143 double side_measure = cell_side.
measure();
148 for (
unsigned int i=0; i<
n_dofs_; i++)
149 for (
unsigned int j=0; j<
n_dofs_; j++)
159 for (
unsigned int i=0; i<
n_dofs_; i++)
160 for (
unsigned int j=0; j<
n_dofs_; j++)
174 if (dim == 1)
return;
175 ASSERT_EQ_DBG(cell_lower_dim.
dim(), dim-1).error(
"Dimension of element mismatch!");
186 bool own_element_id[2];
187 own_element_id[0] = cell_lower_dim.
is_own();
188 own_element_id[1] = cell_higher_dim.
is_own();
190 for (
unsigned int n=0; n<2; ++n)
191 for (
unsigned int i=0; i<
n_dofs_; i++)
192 for (
unsigned int m=0; m<2; ++m)
193 for (
unsigned int j=0; j<
n_dofs_; j++)
200 auto p_low = p_high.lower_dim(cell_lower_dim);
203 for (
int n=0; n<2; n++)
205 if (!own_element_id[n])
continue;
213 for (
int m=0; m<2; m++)
214 for (
unsigned int j=0; j<n_dofs_ngh_[m]; j++) {
218 double divuit = (m==1) ? arma::trace(guit) : 0;
236 for (
unsigned int n=0; n<2; ++n)
237 for (
unsigned int m=0; m<2; ++m)
252 shared_ptr<FiniteElement<dim>>
fe_;
277 template <
template<
IntDim...>
class DimAssembly>
283 template <
unsigned int dim>
290 static constexpr
const char *
name() {
return "RhsAssemblyElasticity"; }
314 shared_ptr<FE_P<dim>> fe_p = std::make_shared< FE_P<dim> >(1);
315 shared_ptr<
FE_P<dim-1>> fe_p_low = std::make_shared<
FE_P<dim-1> >(1);
316 fe_ = std::make_shared<FESystem<dim>>(fe_p,
FEVector, 3);
320 fe_values_bdr_side_.initialize(*this->
quad_low_, *fe_,
333 local_rhs_.resize(n_dofs_);
334 local_rhs_ngh_.resize(2);
335 for (
uint n=0; n<2; ++n) local_rhs_ngh_[n].resize(n_dofs_);
337 vec_view_bdr_ = &fe_values_bdr_side_.vector_view(0);
346 if (cell.
dim() != dim)
return;
347 if (!cell.
is_own())
return;
355 fill_n(&(local_rhs_[0]),
n_dofs_, 0);
361 for (
auto p : this->
bulk_points(element_patch_idx) )
363 for (
unsigned int i=0; i<
n_dofs_; i++)
386 ASSERT_EQ_DBG(cell_side.
dim(), dim).error(
"Dimension of element mismatch!");
392 fe_values_bdr_side_.reinit(side);
398 fill_n(&(local_rhs_[0]),
n_dofs_, 0);
405 double side_measure = cell_side.
measure();
408 for (
unsigned int i=0; i<
n_dofs_; i++)
411 fe_values_bdr_side_.JxW(k);
417 double side_measure = cell_side.
measure();
420 for (
unsigned int i=0; i<
n_dofs_; i++)
423 arma::dot(vec_view_bdr_->value(i,k), fe_values_bdr_side_.normal_vector(k)) *
424 fe_values_bdr_side_.JxW(k);
432 for (
unsigned int i=0; i<
n_dofs_; i++)
435 fe_values_bdr_side_.JxW(k);
450 if (dim == 1)
return;
451 ASSERT_EQ_DBG(cell_lower_dim.
dim(), dim-1).error(
"Dimension of element mismatch!");
462 bool own_element_id[2];
463 own_element_id[0] = cell_lower_dim.
is_own();
464 own_element_id[1] = cell_higher_dim.
is_own();
466 for (
unsigned int n=0; n<2; ++n)
467 for (
unsigned int i=0; i<
n_dofs_; i++)
468 local_rhs_ngh_[n][i] = 0;
474 auto p_low = p_high.lower_dim(cell_lower_dim);
477 for (
int n=0; n<2; n++)
479 if (!own_element_id[n])
continue;
493 for (
unsigned int n=0; n<2; ++n)
500 shared_ptr<FiniteElement<dim>>
fe_;
528 template <
template<
IntDim...>
class DimAssembly>
533 template <
unsigned int dim>
540 static constexpr
const char *
name() {
return "OutpuFieldsAssemblyElasticity"; }
559 shared_ptr<FE_P<dim>> fe_p = std::make_shared< FE_P<dim> >(1);
560 fe_ = std::make_shared<FESystem<dim>>(fe_p,
FEVector, 3);
561 fv_.initialize(*this->
quad_, *fe_,
581 if (cell.
dim() != dim)
return;
582 if (!cell.
is_own())
return;
586 auto elm = cell.
elm();
593 auto p = *( this->
bulk_points(element_patch_idx).begin() );
597 for (
unsigned int i=0; i<
n_dofs_; i++)
604 arma::mat33 stress_dev = stress - arma::trace(stress)/3*arma::eye(3,3);
605 double von_mises_stress = sqrt(1.5*arma::dot(stress_dev, stress_dev));
606 output_div_vec_.add(dof_indices_scalar_[0], div);
608 for (
unsigned int i=0; i<3; i++)
609 for (
unsigned int j=0; j<3; j++)
610 output_stress_vec_.add( dof_indices_tensor_[i*3+j], stress(i,j) );
611 output_von_mises_stress_vec_.set( dof_indices_scalar_[0], von_mises_stress );
619 if (dim == 1)
return;
620 ASSERT_EQ_DBG(cell_lower_dim.
dim(), dim-1).error(
"Dimension of element mismatch!");
622 normal_displacement_ = 0;
623 normal_stress_.zeros();
628 fsv_.reinit(neighb_side.
side());
632 auto p_low = p_high.lower_dim(cell_lower_dim);
634 for (
unsigned int i=0; i<
n_dofs_; i++)
643 for (
unsigned int i=0; i<3; i++)
644 for (
unsigned int j=0; j<3; j++)
645 output_stress_vec_.add( dof_indices_tensor_[i*3+j], normal_stress_(i,j) );
646 output_cross_sec_vec_.add( dof_indices_scalar_[0], normal_displacement_ );
653 shared_ptr<FiniteElement<dim>>
fe_;
682 template <
template<
IntDim...>
class DimAssembly>
FEValues< 3 > fe_values_side_
FEValues of side (neighbour integral) object.
shared_ptr< FiniteElement< dim > > fe_
Finite element for the solution of the advection-diffusion equation.
Container for various descendants of FieldCommonBase.
LocDofVec dof_indices_
Vector of local DOF indices of vector fields.
EqFields * eq_fields_
Data objects shared with Elasticity.
const FEValuesViews::Vector< 3 > * vec_view_sub_
Vector view of low dim element in neighbour calculation.
Transformed quadrature weight for cell sides.
void initialize(ElementCacheMap *element_cache_map)
Initialize auxiliary vectors and other data members.
#define ASSERT_EQ_DBG(a, b)
Definition of comparative assert macro (EQual) only for debug mode.
const FEValuesViews::Vector< spacedim > & vector_view(unsigned int i) const
Accessor to vector values of multicomponent FE.
shared_ptr< FiniteElement< dim-1 > > fe_low_
Finite element for the solution of the advection-diffusion equation (dim-1).
Field< 3, FieldValue< 3 >::Scalar > lame_mu
vector< vector< LongIdx > > side_dof_indices_
2 items vector of DOF indices in neighbour calculation.
void cell_integral(DHCellAccessor cell, unsigned int element_patch_idx)
Assemble integral over element.
void dimjoin_intergral(DHCellAccessor cell_lower_dim, DHCellSide neighb_side)
Assembles between elements of different dimensions.
arma::Col< IntIdx > LocDofVec
Quadrature * quad_low_
Quadrature used in assembling methods (dim-1).
int active_integrals_
Holds mask of active integrals.
void cell_integral(DHCellAccessor cell, unsigned int element_patch_idx)
Assemble integral over element.
unsigned int dim() const
Return dimension of element appropriate to the side.
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::VectorFixed > > output_field_ptr
Field< 3, FieldValue< 3 >::Scalar > cross_section
Pointer to DarcyFlow field cross_section.
LinSys * ls
Linear algebra system for the transport equation.
unsigned int n_dofs_
Number of dofs.
~RhsAssemblyElasticity()
Destructor.
unsigned int n_dofs_sub_
Number of dofs (on lower dim element)
unsigned int get_dof_indices(std::vector< LongIdx > &indices) const
Fill vector of the global indices of dofs associated to the cell.
void initialize(ElementCacheMap *element_cache_map)
Initialize auxiliary vectors and other data members.
~OutpuFieldsAssemblyElasticity()
Destructor.
unsigned int n_dofs_
Number of dofs.
shared_ptr< FiniteElement< dim-1 > > fe_low_
Finite element for the solution of the advection-diffusion equation (dim-1).
static constexpr const char * name()
virtual void rhs_set_values(int nrow, int *rows, double *vals)=0
arma::vec::fixed< spacedim > value(unsigned int function_no, unsigned int point_no) const
Return value of vector-valued shape function.
Field< 3, FieldValue< 3 >::Scalar > dirichlet_penalty
const FEValuesViews::Vector< 3 > * vec_view_
Vector view in cell integral calculation.
vector< LongIdx > dof_indices_
Vector of global DOF indices.
unsigned int dim() const
Return dimension of element appropriate to cell.
std::vector< unsigned int > n_dofs_ngh_
Number of dofs on lower and higher dimension element (vector of 2 items)
RhsAssemblyElasticity(EqFields *eq_fields, EqData *eq_data)
Constructor.
Directing class of FieldValueCache.
BCField< 3, FieldValue< 3 >::VectorFixed > bc_traction
Cell accessor allow iterate over DOF handler cells.
Class FEValues calculates finite element data on the actual cells such as shape function values...
Elasticity::EqData EqData
void dimjoin_intergral(DHCellAccessor cell_lower_dim, DHCellSide neighb_side)
Assembles between elements of different dimensions.
const FEValuesViews::Vector< 3 > * vec_view_side_
Vector view in neighbour calculation.
FEValues< 3 > fe_values_sub_
FEValues of lower dimension cell object.
Field< 3, FieldValue< 3 >::Scalar > lame_lambda
LocDofVec get_loc_dof_indices() const
Returns the local indices of dofs associated to the cell on the local process.
vector< vector< LongIdx > > side_dof_indices_
2 items vector of DOF indices in neighbour calculation.
shared_ptr< FiniteElement< dim > > fe_
Finite element for the solution of the advection-diffusion equation.
Field< 3, FieldValue< 3 >::VectorFixed > load
bool is_own() const
Return true if accessor represents own element (false for ghost element)
std::shared_ptr< DOFHandlerMultiDim > dh_scalar_
Side side() const
Return Side of given cell and side_idx.
void reinit(const ElementAccessor< spacedim > &cell)
Update cell-dependent data (gradients, Jacobians etc.)
LocDofVec dof_indices_tensor_
Vector of local DOF indices of tensor fields.
void boundary_side_integral(DHCellSide cell_side)
Assembles boundary integral.
VectorMPI output_von_mises_stress_vec_
VectorMPI output_div_vec_
arma::mat33 mat_t(const arma::mat33 &m, const arma::vec3 &n)
EqFields * eq_fields_
Data objects shared with Elasticity.
~StiffnessAssemblyElasticity()
Destructor.
FEM for linear elasticity.
double normal_displacement_
Holds constributions of normal displacement.
Elasticity::EqData EqData
void initialize(ElementCacheMap *element_cache_map)
Initialize auxiliary vectors and other data members.
OutpuFieldsAssemblyElasticity(EqFields *eq_fields, EqData *eq_data)
Constructor.
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::Scalar > > output_cross_section_ptr
Transformed quadrature points.
const ElementAccessor< 3 > elm() const
Return ElementAccessor to element of loc_ele_idx_.
Elasticity::EqFields EqFields
double divergence(unsigned int function_no, unsigned int point_no) const
Return divergence of vector-valued shape function.
EqFields * eq_fields_
Data objects shared with Elasticity.
std::shared_ptr< DOFHandlerMultiDim > dh_tensor_
void boundary_side_integral(DHCellSide cell_side)
Assembles boundary integral.
Compound finite element on dim dimensional simplex.
const FEValuesViews::Vector< 3 > * vec_view_
Vector view in cell integral calculation.
StiffnessAssemblyElasticity(EqFields *eq_fields, EqData *eq_data)
Constructor.
FieldSet used_fields_
Sub field set contains fields used in calculation.
static constexpr const char * name()
Field< 3, FieldValue< 3 >::Scalar > potential_load
Potential of an additional (external) load.
Range< BulkPoint > bulk_points(unsigned int element_patch_idx) const
Return BulkPoint range of appropriate dimension.
Definitions of basic Lagrangean finite elements with polynomial shape functions.
ElementAccessor< 3 > element() const
void initialize(Quadrature &_quadrature, FiniteElement< DIM > &_fe, UpdateFlags _flags)
Initialize structures and calculates cell-independent data.
FEValues< 3 > fe_values_bdr_side_
FEValues of side (boundary integral) object.
virtual Value::return_type const & value(const Point &p, const ElementAccessor< spacedim > &elm) const
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::TensorFixed > > output_stress_ptr
vector< vector< vector< PetscScalar > > > local_matrix_ngh_
Auxiliary vectors for assemble ngh integral.
Elasticity::EqData EqData
FEValues< 3 > fv_
FEValues of cell object (FESystem of P disc finite element type)
arma::mat33 normal_stress_
Holds constributions of normal stress.
Shape function gradients.
unsigned int IntDim
A dimension index type.
const FEValuesViews::Vector< 3 > * vec_view_bdr_
Vector view in boundary calculation.
Elasticity::EqFields EqFields
const FEValuesViews::Vector< 3 > * vec_view_side_
Vector view in neighbour calculation.
FEValues< 3 > fe_values_
FEValues of cell object (FESystem of P disc finite element type)
BCField< 3, FieldValue< 3 >::Enum > bc_type
const FEValuesViews::Vector< 3 > * vec_view_sub_
Vector view of low dim element in neighbour calculation.
static constexpr const char * name()
unsigned int n_dofs_
Number of dofs.
const DHCellAccessor & cell() const
Return DHCellAccessor appropriate to the side.
VectorMPI output_vec_
Data vectors of output fields (FieldFE).
VectorMPI output_stress_vec_
FieldSet used_fields_
Sub field set contains fields used in calculation.
unsigned int n_dofs_sub_
Number of dofs (on lower dim element)
FieldSet used_fields_
Sub field set contains fields used in calculation.
std::shared_ptr< DOFHandlerMultiDim > dh_
Objects for distribution of dofs.
void dimjoin_intergral(DHCellAccessor cell_lower_dim, DHCellSide neighb_side)
Assembles between elements of different dimensions.
vector< vector< PetscScalar > > local_rhs_ngh_
Auxiliary vectors for assemble ngh integral.
FEValues< 3 > fe_values_side_
FEValues of side object.
Conforming Lagrangean finite element on dim dimensional simplex.
arma::mat::fixed< spacedim, spacedim > sym_grad(unsigned int function_no, unsigned int point_no) const
Return symmetric gradient of vector-valued shape function.
Generic class of assemblation.
Definitions of particular quadrature rules on simplices.
LocDofVec dof_indices_scalar_
Vector of local DOF indices of scalar fields.
VectorMPI output_cross_sec_vec_
vector< LongIdx > dof_indices_
Vector of global DOF indices.
shared_ptr< FiniteElement< dim > > fe_
Finite element for the solution of the advection-diffusion equation.
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::Scalar > > output_div_ptr
vector< PetscScalar > local_rhs_
Auxiliary vector for assemble methods.
void cell_integral(DHCellAccessor cell, unsigned int element_patch_idx)
Assemble integral over element.
std::vector< unsigned int > n_dofs_ngh_
Number of dofs on lower and higher dimension element (vector of 2 items)
Range< CouplingPoint > coupling_points(const DHCellSide &cell_side) const
Return CouplingPoint range of appropriate dimension.
const FEValuesViews::Vector< 3 > * vec_view_
Vector view in cell integral calculation.
FEValues< 3 > fsv_
FEValues of side (neighbour integral) object.
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...
FEValues< 3 > fe_values_sub_
FEValues of lower dimension cell object.
virtual void mat_set_values(int nrow, int *rows, int ncol, int *cols, double *vals)=0
Elasticity::EqFields EqFields
Abstract class for the description of a general finite element on a reference simplex in dim dimensio...
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 >::VectorFixed > bc_displacement
Range< BoundaryPoint > boundary_points(const DHCellSide &cell_side) const
Return BoundaryPoint range of appropriate dimension.
arma::mat::fixed< spacedim, spacedim > grad(unsigned int function_no, unsigned int point_no) const
Return gradient of vector-valued shape function.
unsigned int idx() const
Return local idx of element in boundary / bulk part of element vector.
Quadrature * quad_
Quadrature used in assembling methods.
const FEValuesViews::Vector< 3 > * vec_view_side_
Vector view in boundary / neighbour calculation.
Side accessor allows to iterate over sides of DOF handler cell.
ElementAccessor< 3 > element_accessor()
Field< 3, FieldValue< 3 >::Scalar > fracture_sigma
Transition parameter for diffusive transfer on fractures.
ElementCacheMap * element_cache_map_
ElementCacheMap shared with GenericAssembly object.
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::Scalar > > output_von_mises_stress_ptr
FEValues< 3 > fe_values_
FEValues of cell object (FESystem of P disc finite element type)
Transformed quadrature weights.
vector< PetscScalar > local_matrix_
Auxiliary vector for assemble methods.
arma::vec::fixed< spacedim > normal_vector(unsigned int point_no)
Returns the normal vector to a side at given quadrature point.