18 #ifndef ASSEMBLY_ELASTICITY_HH_
19 #define ASSEMBLY_ELASTICITY_HH_
36 template <
unsigned int dim>
43 static constexpr
const char *
name() {
return "StiffnessAssemblyElasticity"; }
74 shared_ptr<
FE_P<dim-1>> fe_p_low = std::make_shared<
FE_P<dim-1> >(1);
91 if (cell.
dim() != dim)
return;
99 for (
unsigned int i=0; i<
n_dofs_; i++)
100 for (
unsigned int j=0; j<
n_dofs_; j++)
103 for (
auto p : this->
bulk_points(element_patch_idx) )
105 for (
unsigned int i=0; i<
n_dofs_; i++)
107 for (
unsigned int j=0; j<
n_dofs_; j++)
119 ASSERT_EQ(cell_side.
dim(), dim).error(
"Dimension of element mismatch!");
126 for (
unsigned int i=0; i<
n_dofs_; i++)
127 for (
unsigned int j=0; j<
n_dofs_; j++)
133 double side_measure = cell_side.
measure();
137 for (
unsigned int i=0; i<
n_dofs_; i++)
138 for (
unsigned int j=0; j<
n_dofs_; j++)
146 for (
unsigned int i=0; i<
n_dofs_; i++)
147 for (
unsigned int j=0; j<
n_dofs_; j++)
160 if (dim == 1)
return;
161 ASSERT_EQ(cell_lower_dim.
dim(), dim-1).error(
"Dimension of element mismatch!");
164 for(
unsigned int i=0; i<n_indices; ++i) {
170 for(
unsigned int i=0; i<n_indices; ++i) {
175 bool own_element_id[2];
176 own_element_id[0] = cell_lower_dim.
is_own();
177 own_element_id[1] = cell_higher_dim.
is_own();
188 auto p_low = p_high.lower_dim(cell_lower_dim);
193 if (!own_element_id[is_high_i])
continue;
197 arma::mat33 semi_sym_grad_i = 0.5*(semi_grad_i + semi_grad_i.t());
204 arma::mat33 semi_sym_grad_j = 0.5*(semi_grad_j + semi_grad_j.t());
215 * 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())))
261 template <
template<
IntDim...>
class DimAssembly>
267 template <
unsigned int dim>
274 static constexpr
const char *
name() {
return "RhsAssemblyElasticity"; }
309 shared_ptr<
FE_P<dim-1>> fe_p_low = std::make_shared<
FE_P<dim-1> >(1);
326 if (cell.
dim() != dim)
return;
327 if (!cell.
is_own())
return;
337 for (
auto p : this->
bulk_points(element_patch_idx) )
339 for (
unsigned int i=0; i<
n_dofs_; i++)
362 ASSERT_EQ(cell_side.
dim(), dim).error(
"Dimension of element mismatch!");
379 for (
unsigned int i=0; i<
n_dofs_; i++)
388 double side_measure = cell_side.
measure();
392 for (
unsigned int i=0; i<
n_dofs_; i++)
400 double side_measure = cell_side.
measure();
404 for (
unsigned int i=0; i<
n_dofs_; i++)
416 for (
unsigned int i=0; i<
n_dofs_; i++)
427 for (
unsigned int i=0; i<
n_dofs_; i++)
446 if (dim == 1)
return;
447 ASSERT_EQ(cell_lower_dim.
dim(), dim-1).error(
"Dimension of element mismatch!");
450 for(
unsigned int i=0; i<n_indices; ++i) {
456 for(
unsigned int i=0; i<n_indices; ++i) {
461 bool own_element_id[2];
462 own_element_id[0] = cell_lower_dim.
is_own();
463 own_element_id[1] = cell_higher_dim.
is_own();
465 for (
unsigned int i=0; i<2*
n_dofs_; i++)
471 auto p_low = p_high.lower_dim(cell_lower_dim);
476 if (!own_element_id[is_high_i])
continue;
518 template <
template<
IntDim...>
class DimAssembly>
523 template <
unsigned int dim>
530 static constexpr
const char *
name() {
return "OutpuFieldsAssemblyElasticity"; }
572 if (cell.
dim() != dim)
return;
573 if (!cell.
is_own())
return;
581 auto p = *( this->
bulk_points(element_patch_idx).begin() );
585 for (
unsigned int i=0; i<
n_dofs_; i++)
592 arma::mat33 stress_dev = stress - arma::trace(stress)/3*arma::eye(3,3);
593 double von_mises_stress = sqrt(1.5*arma::dot(stress_dev, stress_dev));
594 double mean_stress = arma::trace(stress) / 3;
597 for (
unsigned int i=0; i<3; i++)
598 for (
unsigned int j=0; j<3; j++)
609 if (dim == 1)
return;
610 ASSERT_EQ(cell_lower_dim.
dim(), dim-1).error(
"Dimension of element mismatch!");
621 auto p_low = p_high.lower_dim(cell_lower_dim);
623 for (
unsigned int i=0; i<
n_dofs_; i++)
632 for (
unsigned int i=0; i<3; i++)
633 for (
unsigned int j=0; j<3; j++)
672 template <
template<
IntDim...>
class DimAssembly>
682 template <
unsigned int dim>
689 static constexpr
const char *
name() {
return "ConstraintAssemblyElasticity"; }
720 if (dim == 1)
return;
721 if (!cell_lower_dim.
is_own())
return;
723 ASSERT_EQ(cell_lower_dim.
dim(), dim-1).error(
"Dimension of element mismatch!");
728 for (
unsigned int i=0; i<
n_dofs_; i++)
734 double local_vector = 0;
737 auto p_low = p_high.lower_dim(cell_lower_dim);
742 for (
unsigned int i=0; i<
n_dofs_; i++)
776 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
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).
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 > 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_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.
FieldSet used_fields_
Sub field set contains fields used in calculation.
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.
Elasticity::EqFields EqFields
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.
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.
Declares top level factory classes of FE operations.
Store finite element reinit functions.
Definitions of particular quadrature rules on simplices.