18 #ifndef ASSEMBLY_ELASTICITY_HH_
19 #define ASSEMBLY_ELASTICITY_HH_
35 template <
unsigned int dim,
class TEqData>
42 static constexpr
const char *
name() {
return "Elasticity_Stiffness_Assembly"; }
74 shared_ptr<
FE_P<dim-1>> fe_p_low = std::make_shared<
FE_P<dim-1> >(1);
89 if (cell.
dim() != dim)
return;
97 for (
unsigned int i=0; i<
n_dofs_; i++)
98 for (
unsigned int j=0; j<
n_dofs_; j++)
103 for (
unsigned int i=0; i<
n_dofs_; i++)
105 for (
unsigned int j=0; j<
n_dofs_; j++)
117 ASSERT_EQ(cell_side.
dim(), dim).error(
"Dimension of element mismatch!");
124 for (
unsigned int i=0; i<
n_dofs_; i++)
125 for (
unsigned int j=0; j<
n_dofs_; j++)
130 unsigned int bc_type =
eq_fields_->bc_type(p_bdr);
131 double side_measure = cell_side.
measure();
132 if (bc_type == EqFields::bc_type_displacement)
135 for (
unsigned int i=0; i<
n_dofs_; i++)
136 for (
unsigned int j=0; j<
n_dofs_; j++)
141 else if (bc_type == EqFields::bc_type_displacement_normal)
144 for (
unsigned int i=0; i<
n_dofs_; i++)
145 for (
unsigned int j=0; j<
n_dofs_; j++)
158 if (dim == 3)
return;
159 ASSERT_EQ(cell_lower_dim.
dim(), dim).error(
"Dimension of element mismatch!");
162 for(
unsigned int i=0; i<n_indices; ++i) {
168 for(
unsigned int i=0; i<n_indices; ++i) {
173 bool own_element_id[2];
174 own_element_id[0] = cell_lower_dim.
is_own();
175 own_element_id[1] = cell_higher_dim.
is_own();
186 auto p_low = p_high.lower_dim(cell_lower_dim);
191 if (!own_element_id[is_high_i])
continue;
194 arma::mat33 semi_grad_i = grad_deform_i + n_neighs/
eq_fields_->cross_section(p_low)*arma::kron(diff_deform_i,nv.t());
195 arma::mat33 semi_sym_grad_i = 0.5*(semi_grad_i + semi_grad_i.t());
201 arma::mat33 semi_grad_j = grad_deform_j + n_neighs/
eq_fields_->cross_section(p_low)*arma::kron(diff_deform_j,nv.t());
202 arma::mat33 semi_sym_grad_j = 0.5*(semi_grad_j + semi_grad_j.t());
207 * arma::dot(semi_sym_grad_i,
eq_fields_->stress_tensor(p_low,semi_sym_grad_j))
213 * 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())))
264 template <
template<
IntDim...>
class DimAssembly>
270 template <
unsigned int dim,
class TEqData>
277 static constexpr
const char *
name() {
return "Elasticity_Rhs_Assembly"; }
314 shared_ptr<
FE_P<dim-1>> fe_p_low = std::make_shared<
FE_P<dim-1> >(1);
329 if (cell.
dim() != dim)
return;
330 if (!cell.
is_own())
return;
342 for (
unsigned int i=0; i<
n_dofs_; i++)
365 ASSERT_EQ(cell_side.
dim(), dim).error(
"Dimension of element mismatch!");
373 unsigned int bc_type =
eq_fields_->bc_type(p_bdr);
382 for (
unsigned int i=0; i<
n_dofs_; i++)
389 if (bc_type == EqFields::bc_type_displacement)
391 double side_measure = cell_side.
measure();
395 for (
unsigned int i=0; i<
n_dofs_; i++)
401 else if (bc_type == EqFields::bc_type_displacement_normal)
403 double side_measure = cell_side.
measure();
407 for (
unsigned int i=0; i<
n_dofs_; i++)
414 else if (bc_type == EqFields::bc_type_traction)
419 for (
unsigned int i=0; i<
n_dofs_; i++)
425 else if (bc_type == EqFields::bc_type_stress)
430 for (
unsigned int i=0; i<
n_dofs_; i++)
449 if (dim == 3)
return;
450 ASSERT_EQ(cell_lower_dim.
dim(), dim).error(
"Dimension of element mismatch!");
453 for(
unsigned int i=0; i<n_indices; ++i) {
459 for(
unsigned int i=0; i<n_indices; ++i) {
464 bool own_element_id[2];
465 own_element_id[0] = cell_lower_dim.
is_own();
466 own_element_id[1] = cell_higher_dim.
is_own();
468 for (
unsigned int i=0; i<2*
n_dofs_; i++)
474 auto p_low = p_high.lower_dim(cell_lower_dim);
479 if (!own_element_id[is_high_i])
continue;
527 template <
template<
IntDim...>
class DimAssembly>
532 template <
unsigned int dim,
class TEqData>
539 static constexpr
const char *
name() {
return "Elasticity_OutpuFields_Assembly"; }
579 if (cell.
dim() != dim)
return;
580 if (!cell.
is_own())
return;
592 for (
unsigned int i=0; i<
n_dofs_; i++)
599 arma::mat33 stress_dev = stress - arma::trace(stress)/3*arma::eye(3,3);
600 double von_mises_stress = sqrt(1.5*arma::dot(stress_dev, stress_dev));
601 double mean_stress = arma::trace(stress) / 3;
604 for (
unsigned int i=0; i<3; i++)
605 for (
unsigned int j=0; j<3; j++)
616 if (dim == 3)
return;
617 ASSERT_EQ(cell_lower_dim.
dim(), dim).error(
"Dimension of element mismatch!");
628 auto p_low = p_high.lower_dim(cell_lower_dim);
639 for (
unsigned int i=0; i<3; i++)
640 for (
unsigned int j=0; j<3; j++)
683 template <
template<
IntDim...>
class DimAssembly>
693 template <
unsigned int dim,
class TEqData>
700 static constexpr
const char *
name() {
return "Elasticity_Constraint_Assembly"; }
726 if (dim == 3)
return;
727 if (!cell_lower_dim.
is_own())
return;
729 ASSERT_EQ(cell_lower_dim.
dim(), dim).error(
"Dimension of element mismatch!");
734 for (
unsigned int i=0; i<
n_dofs_; i++)
740 double local_vector = 0;
743 auto p_low = p_high.lower_dim(cell_lower_dim);
748 for (
unsigned int i=0; i<
n_dofs_; i++)
756 VecSetValue(
eq_data_->constraint_vec, arow[0], local_vector, ADD_VALUES);
784 template <
template<
IntDim...>
class DimAssembly>
#define ASSERT_EQ(a, b)
Definition of comparative assert macro (EQual) only for debug mode.
unsigned int n_dofs_high()
Return number of DOFs of higher dim element.
unsigned int n_dofs()
Return number of DOFs.
Quadrature * quad_
Quadrature used in assembling methods.
std::shared_ptr< CouplingIntegralAcc< dim > > create_coupling_integral(Quadrature *quad)
std::shared_ptr< BoundaryIntegralAcc< dim > > create_boundary_integral(Quadrature *quad)
std::shared_ptr< BulkIntegralAcc< dim > > create_bulk_integral(Quadrature *quad)
Quadrature * quad_low_
Quadrature used in assembling methods (dim-1).
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.
Class FEValues calculates finite element data on the actual cells such as shape function values,...
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.