49 std::string equation_name = std::string(name_) +
"_FE";
51 std::string(equation_name),
52 "FEM for linear elasticity.")
56 "Settings for computing balance.")
58 "Parameters of output stream.")
60 "Linear solver for elasticity.")
63 .make_field_descriptor_type(equation_name)),
65 "Input fields of the equation.")
67 EqFields().output_fields.make_output_type(equation_name,
""),
68 IT::Default(
"{ \"fields\": [ \"displacement\" ] }"),
69 "Setting of the field output.")
75 Input::register_class< Elasticity, Mesh &, const Input::Record>(std::string(name_) +
"_FE") +
80 double lame_mu(
double young,
double poisson)
82 return young*0.5/(poisson+1.);
88 return young*poisson/((poisson+1.)*(1.-2.*poisson));
93 inline double operator() (
double young,
double poisson) {
94 return young * 0.5 / (poisson+1.);
100 inline double operator() (
double young,
double poisson) {
101 return young * poisson / ((poisson+1.)*(1.-2.*poisson));
115 return 2*
lame_mu(p)*strain_tensor +
lame_lambda(p)*arma::trace(strain_tensor)*arma::eye(3,3);
122 return Selection(
"Elasticity_BC_Type",
"Types of boundary conditions for mechanics.")
123 .
add_value(bc_type_displacement,
"displacement",
124 "Prescribed displacement.")
125 .
add_value(bc_type_displacement_normal,
"displacement_n",
126 "Prescribed displacement in the normal direction to the boundary.")
128 "Prescribed traction.")
130 "Prescribed stress tensor.")
140 "Type of boundary condition.")
142 .input_default(
"\"traction\"")
143 .input_selection( get_bc_type_selection() )
146 *
this+=bc_displacement
147 .name(
"bc_displacement")
148 .description(
"Prescribed displacement on boundary.")
150 .input_default(
"0.0")
155 .description(
"Prescribed traction on boundary.")
157 .input_default(
"0.0")
162 .description(
"Prescribed stress on boundary.")
164 .input_default(
"0.0")
169 .description(
"Prescribed bulk load.")
170 .units(
UnitSI().N().m(-3) )
171 .input_default(
"0.0")
175 .name(
"young_modulus")
176 .description(
"Young's modulus.")
178 .input_default(
"0.0")
179 .flags_add(in_main_matrix & in_rhs);
182 .name(
"poisson_ratio")
183 .description(
"Poisson's ratio.")
184 .units(
UnitSI().dimensionless() )
185 .input_default(
"0.0")
186 .flags_add(in_main_matrix & in_rhs);
188 *
this+=fracture_sigma
189 .name(
"fracture_sigma")
191 "Coefficient of transfer of forces through fractures.")
193 .input_default(
"1.0")
194 .flags_add(in_main_matrix & in_rhs);
196 *
this+=initial_stress
197 .name(
"initial_stress")
198 .description(
"Initial stress tensor.")
200 .input_default(
"0.0")
203 *
this += region_id.name(
"region_id")
207 *
this += subdomain.name(
"subdomain")
212 .name(
"cross_section")
213 .units(
UnitSI().m(3).md() )
214 .flags(input_copy & in_time_term & in_main_matrix & in_rhs);
216 *
this+=cross_section_min
217 .name(
"cross_section_min")
218 .description(
"Minimal cross-section of fractures.")
219 .units(
UnitSI().m(3).md() )
220 .input_default(
"0.0");
222 *
this+=potential_load
223 .name(
"potential_load")
225 .flags(input_copy & in_rhs);
228 .name(
"displacement")
229 .description(
"Displacement vector field output.")
231 .flags(equation_result);
233 *
this += output_stress
235 .description(
"Stress tensor output.")
237 .flags(equation_result);
239 *
this += output_von_mises_stress
240 .name(
"von_mises_stress")
241 .description(
"von Mises stress output.")
243 .flags(equation_result);
245 *
this += output_mean_stress
247 .description(
"mean stress output.")
249 .flags(equation_result);
251 *
this += output_cross_section
252 .name(
"cross_section_updated")
253 .description(
"Cross-section after deformation - output.")
255 .flags(equation_result);
257 *
this += output_divergence
258 .name(
"displacement_divergence")
259 .description(
"Displacement divergence output.")
260 .units(
UnitSI().dimensionless() )
261 .flags(equation_result);
263 *
this +=
lame_mu.name(
"lame_mu")
264 .description(
"Field lame_mu.")
265 .input_default(
"0.0")
269 .description(
"Field lame_lambda.")
270 .input_default(
"0.0")
273 *
this += dirichlet_penalty.name(
"dirichlet_penalty")
274 .description(
"Field dirichlet_penalty.")
275 .input_default(
"0.0")
279 output_fields += *
this;
281 this->add_coords_field();
282 this->set_default_fieldset();
288 ASSERT_EQ(quad_order(), 1).error(
"Unsupported polynomial order for finite elements in Elasticity");
292 std::shared_ptr<DiscreteSpace> ds = std::make_shared<EqualOrderDiscreteSpace>(mesh, fe);
293 dh_ = std::make_shared<DOFHandlerMultiDim>(*mesh);
295 dh_->distribute_dofs(ds);
300 ASSERT_EQ(quad_order(), 0).error(
"Unsupported polynomial order for output in Elasticity");
303 dh_scalar_ = make_shared<DOFHandlerMultiDim>(*mesh);
304 std::shared_ptr<DiscreteSpace> ds_scalar = std::make_shared<EqualOrderDiscreteSpace>( mesh, fe_p_disc);
305 dh_scalar_->distribute_dofs(ds_scalar);
309 dh_tensor_ = make_shared<DOFHandlerMultiDim>(*mesh);
310 std::shared_ptr<DiscreteSpace> dst = std::make_shared<EqualOrderDiscreteSpace>( mesh, fe_t);
311 dh_tensor_->distribute_dofs(dst);
318 stiffness_assembly_(nullptr),
319 rhs_assembly_(nullptr),
320 constraint_assembly_(nullptr),
321 output_fields_assembly_(nullptr)
327 eq_data_ = std::make_shared<EqData>();
340 ASSERT( time_from_rec.
is_default() ).error(
"Duplicate key 'time', time in elasticity is already initialized from parent class!");
354 DebugOut().fmt(
"Mechanics: solution size {}\n",
eq_data_->dh_->n_global_dofs());
377 eq_fields_->output_field_ptr = create_field_fe<3, FieldValue<3>::VectorFixed>(
eq_data_->dh_);
418 std::string petsc_default_opts;
419 petsc_default_opts =
"-ksp_type cg -pc_type hypre -pc_hypre_type boomeramg";
425 #ifndef FLOW123D_HAVE_PERMON
426 ASSERT(
false).error(
"Flow123d was not built with PERMON library, therefore contact conditions are unsupported.");
431 unsigned int n_own_constraints = 0;
432 for (
auto cell :
eq_data_->dh_->own_range())
433 if (cell.elm()->n_neighs_vb() > 0)
435 unsigned int n_constraints = 0;
437 if (elm->n_neighs_vb() > 0)
438 eq_data_->constraint_idx[elm.idx()] = n_constraints++;
442 MatCreateAIJ(PETSC_COMM_WORLD, n_own_constraints,
eq_data_->dh_->lsize(), PETSC_DECIDE, PETSC_DECIDE, nnz, 0, nnz, 0, &
eq_data_->constraint_matrix);
443 VecCreateMPI(PETSC_COMM_WORLD, n_own_constraints, PETSC_DECIDE, &
eq_data_->constraint_vec);
486 eq_fields_->output_field_ptr->vec().local_to_ghost_begin();
487 eq_fields_->output_stress_ptr->vec().zero_entries();
488 eq_fields_->output_cross_section_ptr->vec().zero_entries();
489 eq_fields_->output_div_ptr->vec().zero_entries();
490 eq_fields_->output_field_ptr->vec().local_to_ghost_end();
496 eq_fields_->output_stress_ptr->vec().local_to_ghost_begin();
497 eq_fields_->output_von_mises_stress_ptr->vec().local_to_ghost_begin();
498 eq_fields_->output_mean_stress_ptr->vec().local_to_ghost_begin();
499 eq_fields_->output_cross_section_ptr->vec().local_to_ghost_begin();
500 eq_fields_->output_div_ptr->vec().local_to_ghost_begin();
501 eq_fields_->output_stress_ptr->vec().local_to_ghost_end();
502 eq_fields_->output_von_mises_stress_ptr->vec().local_to_ghost_end();
503 eq_fields_->output_mean_stress_ptr->vec().local_to_ghost_end();
504 eq_fields_->output_cross_section_ptr->vec().local_to_ghost_end();
505 eq_fields_->output_div_ptr->vec().local_to_ghost_end();
516 std::stringstream ss;
530 MatSetOption(*
eq_data_->ls->get_matrix(), MAT_KEEP_NONZERO_PATTERN, PETSC_TRUE);
537 MessageOut().fmt(
"[mech solver] lin. it: {}, reason: {}, residual: {}\n",
575 if (
eq_data_->ls->get_matrix() == NULL
578 DebugOut() <<
"Mechanics: Assembling matrix.\n";
589 DebugOut() <<
"Mechanics: Assembling right hand side.\n";
598 MessageOut().fmt(
"[mech solver] lin. it: {}, reason: {}, residual: {}\n",
641 MatZeroEntries(
eq_data_->constraint_matrix);
642 VecZeroEntries(
eq_data_->constraint_vec);
644 MatAssemblyBegin(
eq_data_->constraint_matrix, MAT_FINAL_ASSEMBLY);
645 MatAssemblyEnd(
eq_data_->constraint_matrix, MAT_FINAL_ASSEMBLY);
646 VecAssemblyBegin(
eq_data_->constraint_vec);
647 VecAssemblyEnd(
eq_data_->constraint_vec);
#define ASSERT_EQ(a, b)
Definition of comparative assert macro (EQual) only for debug mode.
static const Input::Type::Record & get_input_type()
Main balance input record type.
Base point accessor class.
void create_dh(Mesh *mesh)
Create DOF handler objects.
static const Input::Type::Selection & get_bc_type_selection()
arma::mat33 stress_tensor(BulkPoint &p, const arma::mat33 &strain_tensor)
void create_dh(Mesh *mesh)
Create DOF handler objects.
std::shared_ptr< EqData > eq_data_
Data for model parameters.
static const int registrar
Registrar of class to factory.
GenericAssembly< RhsAssemblyElasticity > * rhs_assembly_
void update_output_fields()
void assemble_constraint_matrix()
GenericAssembly< OutpuFieldsAssemblyElasticity > * output_fields_assembly_
GenericAssembly< StiffnessAssemblyElasticity > * stiffness_assembly_
general assembly objects, hold assembly objects of appropriate dimension
void solve_linear_system()
Solve without updating time step and without output.
std::shared_ptr< OutputTime > output_stream_
void initialize() override
Input::Record input_rec
Record with input specification.
void calculate_cumulative_balance()
void output_data()
Postprocesses the solution and writes to output file.
static const Input::Type::Record & get_input_type()
Declare input record type for the equation TransportDG.
bool has_contact_
Indicator of contact conditions on fractures.
GenericAssembly< ConstraintAssemblyElasticity > * constraint_assembly_
Elasticity(Mesh &init_mesh, const Input::Record in_rec, TimeGovernor *tm=nullptr)
Constructor.
void zero_time_step() override
Initialize solution in the zero time.
std::shared_ptr< OutputEqData > output_eq_data_
Data for output parameters.
std::shared_ptr< EqFields > eq_fields_
Fields for model parameters.
void next_time()
Pass to next time and update equation data.
std::shared_ptr< Balance > balance() const
static Input::Type::Record & record_template()
Template Record with common keys for derived equations.
std::shared_ptr< FieldSet > eq_fieldset_
void init_user_fields(Input::Array user_fields, FieldSet &output_fields)
static Input::Type::Record & user_fields_template(std::string equation_name)
Template Record with common key user_fields for derived equations.
static bool print_message_table(ostream &stream, std::string equation_name)
static constexpr Mask equation_external_output
Match an output field, that can be also copy of other field.
static constexpr Mask in_rhs
A field is part of the right hand side of the equation.
static constexpr Mask in_main_matrix
A field is part of main "stiffness matrix" of the equation.
void assemble(std::shared_ptr< DOFHandlerMultiDim > dh) override
General assemble methods.
static auto region_id(Mesh &mesh) -> IndexField
static auto subdomain(Mesh &mesh) -> IndexField
static const Input::Type::Record & get_input_type()
void set_solution(Vec sol_vec)
virtual void set_from_input(const Input::Record in_rec)
Range< ElementAccessor< 3 > > elements_range() const
Returns range of mesh elements.
unsigned int max_edge_sides(unsigned int dim) const
static const Input::Type::Record & get_input_type()
The specification of output stream.
static std::shared_ptr< OutputTime > create_output_stream(const std::string &equation_name, const Input::Record &in_rec, const std::shared_ptr< TimeUnitConversion > &time_unit_conv)
This method delete all object instances of class OutputTime stored in output_streams vector.
Basic time management functionality for unsteady (and steady) solvers (class Equation).
void view(const char *name="") const
const TimeStep & step(int index=-1) const
void next_time()
Proceed to the next time according to current estimated time step.
Class for representation SI units of Fields.
static UnitSI & dimensionless()
Returns dimensionless unit.
double lame_mu(double young, double poisson)
double lame_lambda(double young, double poisson)
FEM for linear elasticity.
Definitions of basic Lagrangean finite elements with polynomial shape functions.
Definitions of Raviart-Thomas finite elements.
Class FESystem for compound finite elements.
MixedPtr< FESystem > mixed_fe_system(MixedPtr< FiniteElement > fe, Args &&... args)
Class FEValues calculates finite element data on the actual cells such as shape function values,...
PERMON QP solvers and FETI.
Solver based on the original PETSc solver using MPIAIJ matrix and succesive Schur complement construc...
#define WarningOut()
Macro defining 'warning' record of log.
#define MessageOut()
Macro defining 'message' record of log.
#define DebugOut()
Macro defining 'debug' record of log.
Definitions of particular quadrature rules on simplices.
#define END_TIMER(tag)
Ends a timer with specified tag.
#define START_TIMER(tag)
Starts a timer with specified tag.