18 #ifndef ASSEMBLY_ELASTICITY_HH_
19 #define ASSEMBLY_ELASTICITY_HH_
34 template <
unsigned int dim,
class TEqData>
41 static constexpr
const char *
name() {
return "Elasticity_Stiffness_Assembly"; }
73 shared_ptr<
FE_P<dim-1>> fe_p_low = std::make_shared<
FE_P<dim-1> >(1);
88 if (cell.
dim() != dim)
return;
96 for (
unsigned int i=0; i<
n_dofs_; i++)
97 for (
unsigned int j=0; j<
n_dofs_; j++)
102 for (
unsigned int i=0; i<
n_dofs_; i++)
104 for (
unsigned int j=0; j<
n_dofs_; j++)
116 ASSERT_EQ(cell_side.
dim(), dim).error(
"Dimension of element mismatch!");
123 for (
unsigned int i=0; i<
n_dofs_; i++)
124 for (
unsigned int j=0; j<
n_dofs_; j++)
129 unsigned int bc_type =
eq_fields_->bc_type(p_bdr);
130 double side_measure = cell_side.
measure();
131 if (bc_type == EqFields::bc_type_displacement)
134 for (
unsigned int i=0; i<
n_dofs_; i++)
135 for (
unsigned int j=0; j<
n_dofs_; j++)
140 else if (bc_type == EqFields::bc_type_displacement_normal)
143 for (
unsigned int i=0; i<
n_dofs_; i++)
144 for (
unsigned int j=0; j<
n_dofs_; j++)
157 if (dim == 3)
return;
158 ASSERT_EQ(cell_lower_dim.
dim(), dim).error(
"Dimension of element mismatch!");
161 for(
unsigned int i=0; i<n_indices; ++i) {
167 for(
unsigned int i=0; i<n_indices; ++i) {
172 bool own_element_id[2];
173 own_element_id[0] = cell_lower_dim.
is_own();
174 own_element_id[1] = cell_higher_dim.
is_own();
185 auto p_low = p_high.lower_dim(cell_lower_dim);
190 if (!own_element_id[is_high_i])
continue;
193 arma::mat33 semi_grad_i = grad_deform_i + n_neighs/
eq_fields_->cross_section(p_low)*arma::kron(diff_deform_i,nv.t());
194 arma::mat33 semi_sym_grad_i = 0.5*(semi_grad_i + semi_grad_i.t());
200 arma::mat33 semi_grad_j = grad_deform_j + n_neighs/
eq_fields_->cross_section(p_low)*arma::kron(diff_deform_j,nv.t());
201 arma::mat33 semi_sym_grad_j = 0.5*(semi_grad_j + semi_grad_j.t());
206 * arma::dot(semi_sym_grad_i,
eq_fields_->stress_tensor(p_low,semi_sym_grad_j))
212 * arma::dot(0.5*(grad_deform_i+grad_deform_i.t()),
eq_fields_->stress_tensor(p_low,0.5*(grad_deform_j+grad_deform_j.t())))
263 template <
template<
IntDim...>
class DimAssembly>
269 template <
unsigned int dim,
class TEqData>
276 static constexpr
const char *
name() {
return "Elasticity_Rhs_Assembly"; }
313 shared_ptr<
FE_P<dim-1>> fe_p_low = std::make_shared<
FE_P<dim-1> >(1);
328 if (cell.
dim() != dim)
return;
329 if (!cell.
is_own())
return;
341 for (
unsigned int i=0; i<
n_dofs_; i++)
364 ASSERT_EQ(cell_side.
dim(), dim).error(
"Dimension of element mismatch!");
372 unsigned int bc_type =
eq_fields_->bc_type(p_bdr);
381 for (
unsigned int i=0; i<
n_dofs_; i++)
388 if (bc_type == EqFields::bc_type_displacement)
390 double side_measure = cell_side.
measure();
394 for (
unsigned int i=0; i<
n_dofs_; i++)
400 else if (bc_type == EqFields::bc_type_displacement_normal)
402 double side_measure = cell_side.
measure();
406 for (
unsigned int i=0; i<
n_dofs_; i++)
413 else if (bc_type == EqFields::bc_type_traction)
418 for (
unsigned int i=0; i<
n_dofs_; i++)
424 else if (bc_type == EqFields::bc_type_stress)
429 for (
unsigned int i=0; i<
n_dofs_; i++)
448 if (dim == 3)
return;
449 ASSERT_EQ(cell_lower_dim.
dim(), dim).error(
"Dimension of element mismatch!");
452 for(
unsigned int i=0; i<n_indices; ++i) {
458 for(
unsigned int i=0; i<n_indices; ++i) {
463 bool own_element_id[2];
464 own_element_id[0] = cell_lower_dim.
is_own();
465 own_element_id[1] = cell_higher_dim.
is_own();
467 for (
unsigned int i=0; i<2*
n_dofs_; i++)
473 auto p_low = p_high.lower_dim(cell_lower_dim);
478 if (!own_element_id[is_high_i])
continue;
526 template <
template<
IntDim...>
class DimAssembly>
531 template <
unsigned int dim,
class TEqData>
538 static constexpr
const char *
name() {
return "Elasticity_OutpuFields_Assembly"; }
578 if (cell.
dim() != dim)
return;
579 if (!cell.
is_own())
return;
591 for (
unsigned int i=0; i<
n_dofs_; i++)
598 arma::mat33 stress_dev = stress - arma::trace(stress)/3*arma::eye(3,3);
599 double von_mises_stress = sqrt(1.5*arma::dot(stress_dev, stress_dev));
600 double mean_stress = arma::trace(stress) / 3;
603 for (
unsigned int i=0; i<3; i++)
604 for (
unsigned int j=0; j<3; j++)
615 if (dim == 3)
return;
616 ASSERT_EQ(cell_lower_dim.
dim(), dim).error(
"Dimension of element mismatch!");
627 auto p_low = p_high.lower_dim(cell_lower_dim);
638 for (
unsigned int i=0; i<3; i++)
639 for (
unsigned int j=0; j<3; j++)
682 template <
template<
IntDim...>
class DimAssembly>
692 template <
unsigned int dim,
class TEqData>
699 static constexpr
const char *
name() {
return "Elasticity_Constraint_Assembly"; }
725 if (dim == 3)
return;
726 if (!cell_lower_dim.
is_own())
return;
728 ASSERT_EQ(cell_lower_dim.
dim(), dim).error(
"Dimension of element mismatch!");
733 for (
unsigned int i=0; i<
n_dofs_; i++)
739 double local_vector = 0;
742 auto p_low = p_high.lower_dim(cell_lower_dim);
747 for (
unsigned int i=0; i<
n_dofs_; i++)
755 VecSetValue(
eq_data_->constraint_vec, arow[0], local_vector, ADD_VALUES);
783 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)
unsigned int n_dofs_high()
Return number of DOFs of higher dim element.
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.
unsigned int n_dofs()
Return number of DOFs.
std::shared_ptr< BoundaryIntegralAcc< dim > > create_boundary_integral(Quadrature *quad)
ElementAccessor< 3 > element_accessor()
FeQArray< Vector > deform_join_
static constexpr const char * name()
ElQ< Vector > normal_join_
TEqData::EqFields EqFields
FieldSet used_fields_
Sub field set contains fields used in calculation.
vector< LongIdx > dof_indices_
Vector of global DOF indices.
vector< vector< LongIdx > > side_dof_indices_
2 items vector of DOF indices in neighbour calculation.
unsigned int n_dofs_
Number of dofs.
EqFields * eq_fields_
Data objects shared with Elasticity.
void dimjoin_intergral(DHCellAccessor cell_lower_dim, DHCellSide neighb_side)
Assembles between elements of different dimensions.
void initialize()
Initialize auxiliary vectors and other data members.
~ConstraintAssemblyElasticity()
Destructor.
std::shared_ptr< CouplingIntegralAcc< dim > > coupling_integral_
Coupling integral of assembly class.
vector< PetscScalar > local_matrix_
Auxiliary vector for assemble methods.
FeQ< Scalar > JxW_join_
Following data members represent Element quantities and FE quantities.
ConstraintAssemblyElasticity(EqData *eq_data, AssemblyInternals *asm_internals)
Constructor.
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 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.
unsigned int elm_idx() const
Return serial idx to element of loc_ele_idx_.
ElementAccessor< 3 > elm() const
Return ElementAccessor to element of loc_ele_idx_.
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.
unsigned int idx() const
We need this method after replacing Region by RegionIdx, and movinf RegionDB instance into particular...
unsigned int n_neighs_vb() const
Return number of neighbours.
Compound finite element on dim dimensional simplex.
Conforming Lagrangean finite element on dim dimensional simplex.
FeQ< ValueType > shape(unsigned int i_shape_fn_idx) const
Container for various descendants of FieldCommonBase.
Abstract class for the description of a general finite element on a reference simplex in dim dimensio...
Generic class of assemblation.
LocDofVec dof_indices_tensor_
Vector of local DOF indices of tensor fields.
std::shared_ptr< BulkIntegralAcc< dim > > bulk_integral_
Bulk integral of assembly class.
~OutpuFieldsAssemblyElasticity()
Destructor.
FeQArray< Vector > deform_join_
static constexpr const char * name()
FieldSet used_fields_
Sub field set contains fields used in calculation.
VectorMPI output_stress_vec_
double normal_displacement_
Holds constributions of normal displacement.
TEqData::EqFields EqFields
OutpuFieldsAssemblyElasticity(EqData *eq_data, AssemblyInternals *asm_internals)
Constructor.
LocDofVec dof_indices_
Vector of local DOF indices of vector fields.
VectorMPI output_div_vec_
EqFields * eq_fields_
Data objects shared with Elasticity.
void initialize()
Initialize auxiliary vectors and other data members.
LocDofVec dof_indices_scalar_
Vector of local DOF indices of scalar fields.
std::shared_ptr< CouplingIntegralAcc< dim > > coupling_integral_
Coupling integral of assembly class.
arma::mat33 normal_stress_
Holds constributions of normal stress.
unsigned int n_dofs_
Number of dofs.
ElQ< Vector > normal_join_
Following data members represent Element quantities and FE quantities.
VectorMPI output_vec_
Data vectors of output fields (FieldFE).
FeQArray< Tensor > grad_deform_
VectorMPI output_mean_stress_vec_
void cell_integral(DHCellAccessor cell, unsigned int element_patch_idx)
Assemble integral over element.
VectorMPI output_cross_sec_vec_
void dimjoin_intergral(DHCellAccessor cell_lower_dim, DHCellSide neighb_side)
Assembles between elements of different dimensions.
unsigned int n_dofs_high_
Number of dofs of higher dim element.
FeQArray< Tensor > sym_grad_deform_
FeQArray< Scalar > div_deform_
VectorMPI output_von_mises_stress_vec_
~RhsAssemblyElasticity()
Destructor.
TEqData::EqFields EqFields
void boundary_side_integral(DHCellSide cell_side)
Assembles boundary integral.
FeQ< Scalar > JxW_
Following data members represent Element quantities and FE quantities.
FeQArray< Tensor > grad_deform_
std::shared_ptr< BoundaryIntegralAcc< dim > > bdr_integral_
Boundary integral of assembly class.
void dimjoin_intergral(DHCellAccessor cell_lower_dim, DHCellSide neighb_side)
Assembles between elements of different dimensions.
RhsAssemblyElasticity(EqData *eq_data, AssemblyInternals *asm_internals)
Constructor.
vector< LongIdx > dof_indices_
Vector of global DOF indices.
FeQArray< Vector > deform_
EqFields * eq_fields_
Data objects shared with Elasticity.
void cell_integral(DHCellAccessor cell, unsigned int element_patch_idx)
Assemble integral over element.
FeQArray< Scalar > div_deform_
void initialize()
Initialize auxiliary vectors and other data members.
ElQ< Vector > normal_join_
std::shared_ptr< CouplingIntegralAcc< dim > > coupling_integral_
Coupling integral of assembly class.
std::shared_ptr< BulkIntegralAcc< dim > > bulk_integral_
Bulk integral of assembly class.
FieldSet used_fields_
Sub field set contains fields used in calculation.
vector< LongIdx > side_dof_indices_
2 items vector of DOF indices in neighbour calculation.
FeQJoin< Vector > deform_join_
static constexpr const char * name()
vector< PetscScalar > local_rhs_
Auxiliary vector for assemble methods.
std::vector< unsigned int > n_dofs_ngh_
Number of dofs on lower and higher dimension element (vector of 2 items)
unsigned int n_dofs_high_
Number of dofs (on higher dim element)
FeQArray< Vector > deform_side_
unsigned int n_dofs_
Number of dofs.
FieldSet used_fields_
Sub field set contains fields used in calculation.
vector< PetscScalar > local_matrix_
Auxiliary vector for assemble methods.
static constexpr const char * name()
void cell_integral(DHCellAccessor cell, unsigned int element_patch_idx)
Assemble integral over element.
vector< LongIdx > side_dof_indices_
vector of DOF indices in neighbour calculation.
void initialize()
Initialize auxiliary vectors and other data members.
~StiffnessAssemblyElasticity()
Destructor.
std::shared_ptr< BulkIntegralAcc< dim > > bulk_integral_
Bulk integral of assembly class.
arma::mat33 mat_t(const arma::mat33 &m, const arma::vec3 &n)
unsigned int n_dofs_
Number of dofs.
TEqData::EqFields EqFields
StiffnessAssemblyElasticity(EqData *eq_data, AssemblyInternals *asm_internals)
Constructor.
std::vector< unsigned int > n_dofs_ngh_
Number of dofs on lower and higher dimension element (vector of 2 items)
vector< LongIdx > dof_indices_
Vector of global DOF indices.
unsigned int n_dofs_high_
Number of dofs (on lower dim element)
EqFields * eq_fields_
Data objects shared with Elasticity.
void dimjoin_intergral(DHCellAccessor cell_lower_dim, DHCellSide neighb_side)
Assembles between elements of different dimensions.
FeQArray< Tensor > grad_deform_
std::shared_ptr< BoundaryIntegralAcc< dim > > bdr_integral_
Boundary integral of assembly class.
FeQJoin< Vector > deform_join_
FeQJoin< Tensor > deform_join_grad_
void boundary_side_integral(DHCellSide cell_side)
Assembles boundary integral.
FeQArray< Tensor > sym_grad_deform_
FeQArray< Vector > deform_side_
FeQ< Scalar > JxW_
Following data members represent Element quantities and FE quantities.
std::shared_ptr< CouplingIntegralAcc< dim > > coupling_integral_
Coupling integral of assembly class.
ElQ< Vector > normal_join_
double get(unsigned int pos) const
Return value on given position.
void set(unsigned int pos, double val)
Set value on given position.
void add(unsigned int pos, double val)
Add value to item on given position.
FEM for linear elasticity.
Definitions of basic Lagrangean finite elements with polynomial shape functions.
arma::Col< IntIdx > LocDofVec
unsigned int IntDim
A dimension index type.
Store finite element reinit functions.
Definitions of particular quadrature rules on simplices.
Holds common data shared between GenericAssemblz and Assembly<dim> classes.