18 #ifndef ASSEMBLY_ELASTICITY_HH_
19 #define ASSEMBLY_ELASTICITY_HH_
34 template <
unsigned int dim>
41 static constexpr
const char *
name() {
return "StiffnessAssemblyElasticity"; }
66 shared_ptr<FE_P<dim>> fe_p = std::make_shared< FE_P<dim> >(1);
67 shared_ptr<
FE_P<dim-1>> fe_p_low = std::make_shared<
FE_P<dim-1> >(1);
68 fe_ = std::make_shared<FESystem<dim>>(fe_p,
FEVector, 3);
86 for (
uint m=0; m<2; ++m) {
88 for (
uint n=0; n<2; ++n)
98 void patch_reinit(std::array<PatchElementsList, 4> &patch_elements)
override
109 if (cell.
dim() != dim)
return;
115 for (
unsigned int i=0; i<
n_dofs_; i++)
116 for (
unsigned int j=0; j<
n_dofs_; j++)
120 for (
auto p : this->
bulk_points(element_patch_idx) )
122 for (
unsigned int i=0; i<
n_dofs_; i++)
124 for (
unsigned int j=0; j<
n_dofs_; j++)
138 ASSERT_EQ(cell_side.
dim(), dim).error(
"Dimension of element mismatch!");
146 for (
unsigned int i=0; i<
n_dofs_; i++)
147 for (
unsigned int j=0; j<
n_dofs_; j++)
153 double side_measure = cell_side.
measure();
158 for (
unsigned int i=0; i<
n_dofs_; i++)
159 for (
unsigned int j=0; j<
n_dofs_; j++)
169 for (
unsigned int i=0; i<
n_dofs_; i++)
170 for (
unsigned int j=0; j<
n_dofs_; j++)
184 if (dim == 1)
return;
185 ASSERT_EQ(cell_lower_dim.
dim(), dim-1).error(
"Dimension of element mismatch!");
195 bool own_element_id[2];
196 own_element_id[0] = cell_lower_dim.
is_own();
197 own_element_id[1] = cell_higher_dim.
is_own();
199 for (
unsigned int n=0; n<2; ++n)
200 for (
unsigned int i=0; i<
n_dofs_; i++)
201 for (
unsigned int m=0; m<2; ++m)
202 for (
unsigned int j=0; j<
n_dofs_; j++)
209 auto p_low = p_high.lower_dim(cell_lower_dim);
212 for (
int n=0; n<2; n++)
214 if (!own_element_id[n])
continue;
222 for (
int m=0; m<2; m++)
227 double divuft = (m==0) ? arma::trace(guft) : 0;
245 for (
unsigned int n=0; n<2; ++n)
246 for (
unsigned int m=0; m<2; ++m)
261 shared_ptr<FiniteElement<dim>>
fe_;
286 template <
template<
IntDim...>
class DimAssembly>
292 template <
unsigned int dim>
299 static constexpr
const char *
name() {
return "RhsAssemblyElasticity"; }
330 shared_ptr<FE_P<dim>> fe_p = std::make_shared< FE_P<dim> >(1);
331 shared_ptr<
FE_P<dim-1>> fe_p_low = std::make_shared<
FE_P<dim-1> >(1);
332 fe_ = std::make_shared<FESystem<dim>>(fe_p,
FEVector, 3);
360 void patch_reinit(std::array<PatchElementsList, 4> &patch_elements)
override
372 if (cell.
dim() != dim)
return;
373 if (!cell.
is_own())
return;
385 for (
auto p : this->
bulk_points(element_patch_idx) )
387 for (
unsigned int i=0; i<
n_dofs_; i++)
411 ASSERT_EQ(cell_side.
dim(), dim).error(
"Dimension of element mismatch!");
432 for (
unsigned int i=0; i<
n_dofs_; i++)
443 double side_measure = cell_side.
measure();
447 for (
unsigned int i=0; i<
n_dofs_; i++)
456 double side_measure = cell_side.
measure();
460 for (
unsigned int i=0; i<
n_dofs_; i++)
473 for (
unsigned int i=0; i<
n_dofs_; i++)
485 for (
unsigned int i=0; i<
n_dofs_; i++)
505 if (dim == 1)
return;
506 ASSERT_EQ(cell_lower_dim.
dim(), dim-1).error(
"Dimension of element mismatch!");
516 bool own_element_id[2];
517 own_element_id[0] = cell_lower_dim.
is_own();
518 own_element_id[1] = cell_higher_dim.
is_own();
520 for (
unsigned int n=0; n<2; ++n)
521 for (
unsigned int i=0; i<
n_dofs_; i++)
528 auto p_low = p_high.lower_dim(cell_lower_dim);
531 for (
int n=0; n<2; n++)
533 if (!own_element_id[n])
continue;
547 for (
unsigned int n=0; n<2; ++n)
554 shared_ptr<FiniteElement<dim>>
fe_;
582 template <
template<
IntDim...>
class DimAssembly>
587 template <
unsigned int dim>
594 static constexpr
const char *
name() {
return "OutpuFieldsAssemblyElasticity"; }
616 shared_ptr<FE_P<dim>> fe_p = std::make_shared< FE_P<dim> >(1);
617 fe_ = std::make_shared<FESystem<dim>>(fe_p,
FEVector, 3);
637 void patch_reinit(std::array<PatchElementsList, 4> &patch_elements)
override
647 if (cell.
dim() != dim)
return;
648 if (!cell.
is_own())
return;
657 auto p = *( this->
bulk_points(element_patch_idx).begin() );
661 for (
unsigned int i=0; i<
n_dofs_; i++)
668 arma::mat33 stress_dev = stress - arma::trace(stress)/3*arma::eye(3,3);
669 double von_mises_stress = sqrt(1.5*arma::dot(stress_dev, stress_dev));
670 double mean_stress = arma::trace(stress) / 3;
673 for (
unsigned int i=0; i<3; i++)
674 for (
unsigned int j=0; j<3; j++)
685 if (dim == 1)
return;
686 ASSERT_EQ(cell_lower_dim.
dim(), dim-1).error(
"Dimension of element mismatch!");
698 auto p_low = p_high.lower_dim(cell_lower_dim);
700 for (
unsigned int i=0; i<
n_dofs_; i++)
709 for (
unsigned int i=0; i<3; i++)
710 for (
unsigned int j=0; j<3; j++)
719 shared_ptr<FiniteElement<dim>>
fe_;
749 template <
template<
IntDim...>
class DimAssembly>
759 template <
unsigned int dim>
766 static constexpr
const char *
name() {
return "ConstraintAssemblyElasticity"; }
784 shared_ptr<FE_P<dim>> fe_p = std::make_shared< FE_P<dim> >(1);
785 fe_ = std::make_shared<FESystem<dim>>(fe_p,
FEVector, 3);
797 void patch_reinit(std::array<PatchElementsList, 4> &patch_elements)
override
805 if (dim == 1)
return;
806 if (!cell_lower_dim.
is_own())
return;
808 ASSERT_EQ(cell_lower_dim.
dim(), dim-1).error(
"Dimension of element mismatch!");
815 for (
unsigned int i=0; i<
n_dofs_; i++)
822 double local_vector = 0;
825 auto p_low = p_high.lower_dim(cell_lower_dim);
830 for (
unsigned int i=0; i<
n_dofs_; i++)
848 shared_ptr<FiniteElement<dim>>
fe_;
865 template <
template<
IntDim...>
class DimAssembly>
#define ASSERT_EQ(a, b)
Definition of comparative assert macro (EQual) only for debug mode.
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()
Auxiliary data class holds number of elements in cache and allow to set this value explicitly (e....
~ConstraintAssemblyElasticity()
Destructor.
const FEValuesViews::Vector< PatchFEValues_TEMP< 3 >, 3 > * vec_view_side_
Vector view in boundary / neighbour calculation.
PatchFEValues_TEMP< 3 > fe_values_side_
FEValues of side object.
EqFields * eq_fields_
Data objects shared with Elasticity.
void dimjoin_intergral(DHCellAccessor cell_lower_dim, DHCellSide neighb_side)
Assembles between elements of different dimensions.
shared_ptr< FiniteElement< dim > > fe_
Finite element for the solution of the advection-diffusion equation.
static constexpr const char * name()
ConstraintAssemblyElasticity(EqFields *eq_fields, EqData *eq_data)
Constructor.
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.
vector< LongIdx > dof_indices_
Vector of global DOF indices.
void patch_reinit(std::array< PatchElementsList, 4 > &patch_elements) override
Reinit PatchFEValues_TEMP objects (all computed elements in one step).
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.
unsigned int elem_idx() const
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
unsigned int side_idx() const
LinSys * ls
Linear algebraic system.
std::shared_ptr< DOFHandlerMultiDim > dh_scalar_
std::shared_ptr< DOFHandlerMultiDim > dh_tensor_
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
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
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 position_in_cache(unsigned mesh_elm_idx, bool bdr=false) const
Return position of element stored in ElementCacheMap.
unsigned int n_neighs_vb() const
Return number of neighbours.
Compound finite element on dim dimensional simplex.
void initialize(Quadrature &_quadrature, FiniteElement< DIM > &_fe, UpdateFlags _flags)
Initialize structures and calculates cell-independent data.
const FEValuesViews::Vector< FV, spacedim > & vector_view(unsigned int i) const
Accessor to vector values of multicomponent FE.
arma::mat::fixed< spacedim, spacedim > sym_grad(unsigned int function_no, unsigned int point_no) const
Return symmetric gradient of vector-valued shape function.
arma::mat::fixed< spacedim, spacedim > grad(unsigned int function_no, unsigned int point_no) const
Return gradient of vector-valued shape function.
double divergence(unsigned int function_no, unsigned int point_no) const
Return divergence of vector-valued shape function.
arma::vec::fixed< spacedim > value(unsigned int function_no, unsigned int point_no) const
Return value of vector-valued shape function.
Conforming Lagrangean finite element on dim dimensional simplex.
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
Elasticity::EqData EqData
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.
const FEValuesViews::Vector< PatchFEValues_TEMP< 3 >, 3 > * vec_view_side_
Vector view in neighbour 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_
shared_ptr< FiniteElement< dim > > fe_
Finite element for the solution of the advection-diffusion equation.
VectorMPI output_von_mises_stress_vec_
LocDofVec dof_indices_tensor_
Vector of local DOF indices of tensor fields.
PatchFEValues_TEMP< 3 > fsv_
FEValues of side (neighbour integral) object.
EqFields * eq_fields_
Data objects shared with Elasticity.
arma::mat33 normal_stress_
Holds constributions of normal stress.
const FEValuesViews::Vector< PatchFEValues_TEMP< 3 >, 3 > * vec_view_
Vector view in cell integral calculation.
Elasticity::EqFields EqFields
VectorMPI output_cross_sec_vec_
void initialize(ElementCacheMap *element_cache_map)
Initialize auxiliary vectors and other data members.
PatchFEValues_TEMP< 3 > fv_
FEValues of cell object (FESystem of P disc finite element type)
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.
OutpuFieldsAssemblyElasticity(EqFields *eq_fields, EqData *eq_data)
Constructor.
~OutpuFieldsAssemblyElasticity()
Destructor.
void patch_reinit(std::array< PatchElementsList, 4 > &patch_elements) override
Reinit PatchFEValues_TEMP objects (all computed elements in one step).
void get_cell(const unsigned int patch_cell_idx)
Set element that is selected for processing. Element is given by index on patch.
arma::vec::fixed< spacedim > normal_vector(unsigned int point_no)
Returns the normal vector to a side at given quadrature point.
double JxW(const unsigned int point_no)
Return the product of Jacobian determinant and the quadrature weight at given quadrature point.
void get_side(unsigned int patch_cell_idx, unsigned int side_idx)
Set element and side that are selected for processing. Element is given by index on patch.
void reinit(PatchElementsList patch_elements)
Reinit data.
PatchFEValues_TEMP< 3 > fe_values_sub_
FEValues of lower dimension cell object.
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.
const FEValuesViews::Vector< PatchFEValues_TEMP< 3 >, 3 > * vec_view_bdr_
Vector view in boundary calculation.
shared_ptr< FiniteElement< dim-1 > > fe_low_
Finite element for the solution of the advection-diffusion equation (dim-1).
vector< vector< LongIdx > > side_dof_indices_
2 items vector of DOF indices in neighbour calculation.
vector< vector< PetscScalar > > local_rhs_ngh_
Auxiliary vectors for assemble ngh integral.
EqFields * eq_fields_
Data objects shared with Elasticity.
Elasticity::EqFields EqFields
void initialize(ElementCacheMap *element_cache_map)
Initialize auxiliary vectors and other data members.
shared_ptr< FiniteElement< dim > > fe_
Finite element for the solution of the advection-diffusion equation.
PatchFEValues_TEMP< 3 > fe_values_side_
FEValues of side (neighbour integral) object.
std::vector< unsigned int > n_dofs_ngh_
Number of dofs on lower and higher dimension element (vector of 2 items)
Elasticity::EqData EqData
PatchFEValues_TEMP< 3 > fe_values_
FEValues of cell object (FESystem of P disc finite element type)
RhsAssemblyElasticity(EqFields *eq_fields, EqData *eq_data)
Constructor.
unsigned int n_dofs_sub_
Number of dofs (on lower dim element)
vector< PetscScalar > local_rhs_
Auxiliary vector for assemble methods.
const FEValuesViews::Vector< PatchFEValues_TEMP< 3 >, 3 > * vec_view_sub_
Vector view of low dim element in neighbour calculation.
const FEValuesViews::Vector< PatchFEValues_TEMP< 3 >, 3 > * vec_view_side_
Vector view in neighbour calculation.
void patch_reinit(std::array< PatchElementsList, 4 > &patch_elements) override
Reinit PatchFEValues_TEMP objects (all computed elements in one step).
unsigned int n_dofs_
Number of dofs.
const FEValuesViews::Vector< PatchFEValues_TEMP< 3 >, 3 > * vec_view_
Vector view in cell integral calculation.
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.
PatchFEValues_TEMP< 3 > fe_values_bdr_side_
FEValues of side (boundary integral) object.
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)
FieldSet used_fields_
Sub field set contains fields used in calculation.
Elasticity::EqFields EqFields
Elasticity::EqData EqData
PatchFEValues_TEMP< 3 > fe_values_sub_
FEValues of lower dimension cell object.
shared_ptr< FiniteElement< dim > > fe_
Finite element for the solution of the advection-diffusion equation.
static constexpr const char * name()
void patch_reinit(std::array< PatchElementsList, 4 > &patch_elements) override
Reinit PatchFEValues_TEMP objects (all computed elements in one step).
const FEValuesViews::Vector< PatchFEValues_TEMP< 3 >, 3 > * vec_view_side_
Vector view in boundary / neighbour calculation.
PatchFEValues_TEMP< 3 > fe_values_side_
FEValues of side object.
PatchFEValues_TEMP< 3 > fe_values_
FEValues of cell object (FESystem of P disc finite element type)
const FEValuesViews::Vector< PatchFEValues_TEMP< 3 >, 3 > * vec_view_sub_
Vector view of low dim element in neighbour calculation.
shared_ptr< FiniteElement< dim-1 > > fe_low_
Finite element for the solution of the advection-diffusion equation (dim-1).
vector< PetscScalar > local_matrix_
Auxiliary vector for assemble methods.
~StiffnessAssemblyElasticity()
Destructor.
vector< vector< LongIdx > > side_dof_indices_
2 items vector of DOF indices in neighbour calculation.
const FEValuesViews::Vector< PatchFEValues_TEMP< 3 >, 3 > * vec_view_
Vector view in cell integral calculation.
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)
unsigned int n_dofs_
Number of dofs.
vector< vector< vector< PetscScalar > > > local_matrix_ngh_
Auxiliary vectors for assemble ngh integral.
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.
StiffnessAssemblyElasticity(EqFields *eq_fields, EqData *eq_data)
Constructor.
void boundary_side_integral(DHCellSide cell_side)
Assembles boundary integral.
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.
@ update_values
Shape function values.
@ update_normal_vectors
Normal vectors.
@ update_JxW_values
Transformed quadrature weights.
@ update_side_JxW_values
Transformed quadrature weight for cell sides.
@ update_gradients
Shape function gradients.
@ update_quadrature_points
Transformed quadrature points.