18 #ifndef ASSEMBLY_ELASTICITY_HH_
19 #define ASSEMBLY_ELASTICITY_HH_
34 template <
unsigned int dim>
41 static constexpr
const char *
name() {
return "StiffnessAssemblyElasticity"; }
76 shared_ptr<
FE_P<dim-1>> fe_p_low = std::make_shared<
FE_P<dim-1> >(1);
93 if (cell.
dim() != dim)
return;
101 for (
unsigned int i=0; i<
n_dofs_; i++)
102 for (
unsigned int j=0; j<
n_dofs_; j++)
105 for (
auto p : this->
bulk_points(element_patch_idx) )
107 for (
unsigned int i=0; i<
n_dofs_; i++)
109 for (
unsigned int j=0; j<
n_dofs_; j++)
121 ASSERT_EQ(cell_side.
dim(), dim).error(
"Dimension of element mismatch!");
128 for (
unsigned int i=0; i<
n_dofs_; i++)
129 for (
unsigned int j=0; j<
n_dofs_; j++)
135 double side_measure = cell_side.
measure();
139 for (
unsigned int i=0; i<
n_dofs_; i++)
140 for (
unsigned int j=0; j<
n_dofs_; j++)
148 for (
unsigned int i=0; i<
n_dofs_; i++)
149 for (
unsigned int j=0; j<
n_dofs_; j++)
162 if (dim == 1)
return;
163 ASSERT_EQ(cell_lower_dim.
dim(), dim-1).error(
"Dimension of element mismatch!");
166 for(
unsigned int i=0; i<n_indices; ++i) {
172 for(
unsigned int i=0; i<n_indices; ++i) {
177 bool own_element_id[2];
178 own_element_id[0] = cell_lower_dim.
is_own();
179 own_element_id[1] = cell_higher_dim.
is_own();
190 auto p_low = p_high.lower_dim(cell_lower_dim);
195 if (!own_element_id[is_high_i])
continue;
199 arma::mat33 semi_sym_grad_i = 0.5*(semi_grad_i + semi_grad_i.t());
206 arma::mat33 semi_sym_grad_j = 0.5*(semi_grad_j + semi_grad_j.t());
217 * 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())))
267 template <
template<
IntDim...>
class DimAssembly>
273 template <
unsigned int dim>
280 static constexpr
const char *
name() {
return "RhsAssemblyElasticity"; }
319 shared_ptr<
FE_P<dim-1>> fe_p_low = std::make_shared<
FE_P<dim-1> >(1);
336 if (cell.
dim() != dim)
return;
337 if (!cell.
is_own())
return;
347 for (
auto p : this->
bulk_points(element_patch_idx) )
349 for (
unsigned int i=0; i<
n_dofs_; i++)
372 ASSERT_EQ(cell_side.
dim(), dim).error(
"Dimension of element mismatch!");
389 for (
unsigned int i=0; i<
n_dofs_; i++)
398 double side_measure = cell_side.
measure();
402 for (
unsigned int i=0; i<
n_dofs_; i++)
410 double side_measure = cell_side.
measure();
414 for (
unsigned int i=0; i<
n_dofs_; i++)
426 for (
unsigned int i=0; i<
n_dofs_; i++)
437 for (
unsigned int i=0; i<
n_dofs_; i++)
456 if (dim == 1)
return;
457 ASSERT_EQ(cell_lower_dim.
dim(), dim-1).error(
"Dimension of element mismatch!");
460 for(
unsigned int i=0; i<n_indices; ++i) {
466 for(
unsigned int i=0; i<n_indices; ++i) {
471 bool own_element_id[2];
472 own_element_id[0] = cell_lower_dim.
is_own();
473 own_element_id[1] = cell_higher_dim.
is_own();
475 for (
unsigned int i=0; i<2*
n_dofs_; i++)
481 auto p_low = p_high.lower_dim(cell_lower_dim);
486 if (!own_element_id[is_high_i])
continue;
532 template <
template<
IntDim...>
class DimAssembly>
537 template <
unsigned int dim>
544 static constexpr
const char *
name() {
return "OutpuFieldsAssemblyElasticity"; }
588 if (cell.
dim() != dim)
return;
589 if (!cell.
is_own())
return;
597 auto p = *( this->
bulk_points(element_patch_idx).begin() );
601 for (
unsigned int i=0; i<
n_dofs_; i++)
608 arma::mat33 stress_dev = stress - arma::trace(stress)/3*arma::eye(3,3);
609 double von_mises_stress = sqrt(1.5*arma::dot(stress_dev, stress_dev));
610 double mean_stress = arma::trace(stress) / 3;
613 for (
unsigned int i=0; i<3; i++)
614 for (
unsigned int j=0; j<3; j++)
625 if (dim == 1)
return;
626 ASSERT_EQ(cell_lower_dim.
dim(), dim-1).error(
"Dimension of element mismatch!");
637 auto p_low = p_high.lower_dim(cell_lower_dim);
639 for (
unsigned int i=0; i<
n_dofs_; i++)
648 for (
unsigned int i=0; i<3; i++)
649 for (
unsigned int j=0; j<3; j++)
690 template <
template<
IntDim...>
class DimAssembly>
700 template <
unsigned int dim>
707 static constexpr
const char *
name() {
return "ConstraintAssemblyElasticity"; }
739 if (dim == 1)
return;
740 if (!cell_lower_dim.
is_own())
return;
742 ASSERT_EQ(cell_lower_dim.
dim(), dim-1).error(
"Dimension of element mismatch!");
747 for (
unsigned int i=0; i<
n_dofs_; i++)
753 double local_vector = 0;
756 auto p_low = p_high.lower_dim(cell_lower_dim);
761 for (
unsigned int i=0; i<
n_dofs_; i++)
796 template <
template<
IntDim...>
class DimAssembly>
#define ASSERT_EQ(a, b)
Definition of comparative assert macro (EQual) only for debug mode.
JoinValues< dim > join_values()
Return JoinValues object.
PatchFEValues< 3 > * fe_values_
Common FEValues object over all dimensions.
BulkValues< dim > bulk_values()
Return BulkValues object.
unsigned int n_dofs()
Return BulkValues object.
SideValues< dim > side_values()
Return SideValues object.
Range< BulkPoint > bulk_points(unsigned int element_patch_idx) const
Return BulkPoint range of appropriate dimension.
Quadrature * quad_
Quadrature used in assembling methods.
Quadrature * quad_low_
Quadrature used in assembling methods (dim-1).
Range< CouplingPoint > coupling_points(const DHCellSide &cell_side) const
Return CouplingPoint range of appropriate dimension.
int active_integrals_
Holds mask of active integrals.
Range< BoundaryPoint > boundary_points(const DHCellSide &cell_side) const
Return BoundaryPoint range of appropriate dimension.
ElementCacheMap * element_cache_map_
ElementCacheMap shared with GenericAssembly object.
ElementAccessor< 3 > element_accessor()
~ConstraintAssemblyElasticity()
Destructor.
EqFields * eq_fields_
Data objects shared with Elasticity.
ConstraintAssemblyElasticity(EqFields *eq_fields, EqData *eq_data, PatchFEValues< 3 > *fe_values)
Constructor.
FeQArray< Vector > deform_side_
void dimjoin_intergral(DHCellAccessor cell_lower_dim, DHCellSide neighb_side)
Assembles between elements of different dimensions.
static constexpr const char * name()
vector< vector< LongIdx > > side_dof_indices_
2 items vector of DOF indices in neighbour calculation.
vector< PetscScalar > local_matrix_
Auxiliary vector for assemble methods.
unsigned int n_dofs_
Number of dofs.
FeQ< Scalar > JxW_side_
Following data members represent Element quantities and FE quantities.
vector< LongIdx > dof_indices_
Vector of global DOF indices.
void initialize(ElementCacheMap *element_cache_map)
Initialize auxiliary vectors and other data members.
FieldSet used_fields_
Sub field set contains fields used in calculation.
Elasticity::EqFields EqFields
FeQArray< Vector > ref_vals_side_
Elasticity::EqData EqData
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
Data of equation parameters.
LinSys * ls
Linear algebraic system.
std::shared_ptr< DOFHandlerMultiDim > dh_
Objects for distribution of dofs.
std::map< LongIdx, LongIdx > constraint_idx
Field< 3, FieldValue< 3 >::Scalar > potential_load
Potential of an additional (external) load.
@ bc_type_displacement_normal
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::TensorFixed > > output_stress_ptr
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::Scalar > > output_von_mises_stress_ptr
Field< 3, FieldValue< 3 >::Scalar > cross_section_min
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::Scalar > > output_cross_section_ptr
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::VectorFixed > > output_field_ptr
BCField< 3, FieldValue< 3 >::Enum > bc_type
Field< 3, FieldValue< 3 >::Scalar > lame_lambda
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::Scalar > > output_div_ptr
BCField< 3, FieldValue< 3 >::VectorFixed > bc_displacement
Field< 3, FieldValue< 3 >::TensorFixed > initial_stress
BCField< 3, FieldValue< 3 >::VectorFixed > bc_traction
Field< 3, FieldValue< 3 >::Scalar > ref_potential_load
Potential of reference external load on boundary. TODO: Switch to BCField when possible.
Field< 3, FieldValue< 3 >::VectorFixed > load
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::Scalar > > output_mean_stress_ptr
arma::mat33 stress_tensor(BulkPoint &p, const arma::mat33 &strain_tensor)
Field< 3, FieldValue< 3 >::Scalar > fracture_sigma
Transition parameter for diffusive transfer on fractures.
Field< 3, FieldValue< 3 >::Scalar > dirichlet_penalty
Field< 3, FieldValue< 3 >::Scalar > cross_section
Pointer to DarcyFlow field cross_section.
BCField< 3, FieldValue< 3 >::TensorFixed > bc_stress
Field< 3, FieldValue< 3 >::Scalar > lame_mu
Data of output parameters.
std::shared_ptr< DOFHandlerMultiDim > dh_scalar_
Objects for distribution of dofs.
std::shared_ptr< DOFHandlerMultiDim > dh_tensor_
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...
Directing class of FieldValueCache.
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.
virtual void rhs_set_values(int nrow, int *rows, double *vals)=0
virtual void mat_set_values(int nrow, int *rows, int ncol, int *cols, double *vals)=0
LocDofVec dof_indices_scalar_
Vector of local DOF indices of scalar fields.
VectorMPI output_vec_
Data vectors of output fields (FieldFE).
FeQArray< Tensor > grad_ref_vals_
FeQArray< Vector > ref_vals_side_
unsigned int n_dofs_
Number of dofs.
FieldSet used_fields_
Sub field set contains fields used in calculation.
static constexpr const char * name()
LocDofVec dof_indices_
Vector of local DOF indices of vector fields.
VectorMPI output_div_vec_
VectorMPI output_stress_vec_
VectorMPI output_von_mises_stress_vec_
FeQArray< Tensor > grad_deform_
LocDofVec dof_indices_tensor_
Vector of local DOF indices of tensor fields.
EqFields * eq_fields_
Data objects shared with Elasticity.
arma::mat33 normal_stress_
Holds constributions of normal stress.
Elasticity::EqFields EqFields
VectorMPI output_cross_sec_vec_
void initialize(ElementCacheMap *element_cache_map)
Initialize auxiliary vectors and other data members.
FeQArray< Vector > deform_side_
void dimjoin_intergral(DHCellAccessor cell_lower_dim, DHCellSide neighb_side)
Assembles between elements of different dimensions.
void cell_integral(DHCellAccessor cell, unsigned int element_patch_idx)
Assemble integral over element.
VectorMPI output_mean_stress_vec_
double normal_displacement_
Holds constributions of normal displacement.
ElQ< Vector > normal_
Following data members represent Element quantities and FE quantities.
OutpuFieldsAssemblyElasticity(EqFields *eq_fields, EqData *eq_data, PatchFEValues< 3 > *fe_values)
Constructor.
~OutpuFieldsAssemblyElasticity()
Destructor.
FeQArray< Tensor > sym_grad_deform_
Elasticity::OutputEqData EqData
FeQArray< Scalar > div_deform_
vector< LongIdx > side_dof_indices_
2 items vector of DOF indices in neighbour calculation.
void dimjoin_intergral(DHCellAccessor cell_lower_dim, DHCellSide neighb_side)
Assembles between elements of different dimensions.
vector< LongIdx > dof_indices_
Vector of global DOF indices.
~RhsAssemblyElasticity()
Destructor.
FeQArray< Vector > ref_vals_
FeQArray< Vector > deform_
EqFields * eq_fields_
Data objects shared with Elasticity.
Elasticity::EqFields EqFields
FeQArray< Scalar > div_deform_
void initialize(ElementCacheMap *element_cache_map)
Initialize auxiliary vectors and other data members.
FeQ< Scalar > JxW_
Following data members represent Element quantities and FE quantities.
std::vector< unsigned int > n_dofs_ngh_
Number of dofs on lower and higher dimension element (vector of 2 items)
Elasticity::EqData EqData
FeQArray< Tensor > grad_ref_vals_
FeQArray< Tensor > grad_deform_
RhsAssemblyElasticity(EqFields *eq_fields, EqData *eq_data, PatchFEValues< 3 > *fe_values)
Constructor.
unsigned int n_dofs_sub_
Number of dofs (on lower dim element)
vector< PetscScalar > local_rhs_
Auxiliary vector for assemble methods.
unsigned int n_dofs_
Number of dofs.
void cell_integral(DHCellAccessor cell, unsigned int element_patch_idx)
Assemble integral over element.
static constexpr const char * name()
void boundary_side_integral(DHCellSide cell_side)
Assembles boundary integral.
FeQArray< Tensor > grad_ref_vals_side_
FieldSet used_fields_
Sub field set contains fields used in calculation.
FeQArray< Vector > ref_vals_side_
FeQArray< Vector > deform_side_
FeQJoin< Vector > deform_join_
void dimjoin_intergral(DHCellAccessor cell_lower_dim, DHCellSide neighb_side)
Assembles between elements of different dimensions.
arma::mat33 mat_t(const arma::mat33 &m, const arma::vec3 &n)
FeQArray< Tensor > grad_deform_
FieldSet used_fields_
Sub field set contains fields used in calculation.
FeQArray< Vector > ref_vals_side_
Elasticity::EqFields EqFields
FeQArray< Vector > ref_vals_
FeQArray< Tensor > grad_ref_vals_side_
Elasticity::EqData EqData
vector< LongIdx > side_dof_indices_
vector of DOF indices in neighbour calculation.
static constexpr const char * name()
FeQJoin< Vector > deform_join_
FeQArray< Scalar > div_deform_
vector< PetscScalar > local_matrix_
Auxiliary vector for assemble methods.
~StiffnessAssemblyElasticity()
Destructor.
vector< LongIdx > dof_indices_
Vector of global DOF indices.
EqFields * eq_fields_
Data objects shared with Elasticity.
unsigned int n_dofs_sub_
Number of dofs (on lower dim element)
FeQ< Scalar > JxW_
Following data members represent Element quantities and FE quantities.
unsigned int n_dofs_
Number of dofs.
FeQArray< Tensor > sym_grad_deform_
StiffnessAssemblyElasticity(EqFields *eq_fields, EqData *eq_data, PatchFEValues< 3 > *fe_values)
Constructor.
FeQArray< Tensor > grad_ref_vals_
FeQJoin< Tensor > deform_join_grad_
std::vector< unsigned int > n_dofs_ngh_
Number of dofs on lower and higher dimension element (vector of 2 items)
void initialize(ElementCacheMap *element_cache_map)
Initialize auxiliary vectors and other data members.
void cell_integral(DHCellAccessor cell, unsigned int element_patch_idx)
Assemble integral over element.
void boundary_side_integral(DHCellSide cell_side)
Assembles boundary integral.
FeQArray< Vector > deform_side_
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.
Definitions of particular quadrature rules on simplices.