48 std::string equation_name = std::string(name_) +
"_FE";
50 std::string(equation_name),
51 "FEM for linear elasticity.")
55 "Settings for computing balance.")
57 "Parameters of output stream.")
59 "Linear solver for elasticity.")
62 .make_field_descriptor_type(equation_name)),
64 "Input fields of the equation.")
66 EqFields().output_fields.make_output_type(equation_name,
""),
67 IT::Default(
"{ \"fields\": [ \"displacement\" ] }"),
68 "Setting of the field output.")
74 Input::register_class< Elasticity, Mesh &, const Input::Record>(std::string(name_) +
"_FE") +
79 double lame_mu(
double young,
double poisson)
81 return young*0.5/(poisson+1.);
87 return young*poisson/((poisson+1.)*(1.-2.*poisson));
92 inline double operator() (
double young,
double poisson) {
93 return young * 0.5 / (poisson+1.);
99 inline double operator() (
double young,
double poisson) {
100 return young * poisson / ((poisson+1.)*(1.-2.*poisson));
114 return 2*
lame_mu(p)*strain_tensor +
lame_lambda(p)*arma::trace(strain_tensor)*arma::eye(3,3);
121 return Selection(
"Elasticity_BC_Type",
"Types of boundary conditions for mechanics.")
122 .
add_value(bc_type_displacement,
"displacement",
123 "Prescribed displacement.")
124 .
add_value(bc_type_displacement_normal,
"displacement_n",
125 "Prescribed displacement in the normal direction to the boundary.")
127 "Prescribed traction.")
129 "Prescribed stress tensor.")
139 "Type of boundary condition.")
141 .input_default(
"\"traction\"")
142 .input_selection( get_bc_type_selection() )
145 *
this+=bc_displacement
146 .name(
"bc_displacement")
147 .description(
"Prescribed displacement on boundary.")
149 .input_default(
"0.0")
154 .description(
"Prescribed traction on boundary.")
156 .input_default(
"0.0")
161 .description(
"Prescribed stress on boundary.")
163 .input_default(
"0.0")
168 .description(
"Prescribed bulk load.")
169 .units(
UnitSI().N().m(-3) )
170 .input_default(
"0.0")
174 .name(
"young_modulus")
175 .description(
"Young's modulus.")
177 .input_default(
"0.0")
178 .flags_add(in_main_matrix & in_rhs);
181 .name(
"poisson_ratio")
182 .description(
"Poisson's ratio.")
183 .units(
UnitSI().dimensionless() )
184 .input_default(
"0.0")
185 .flags_add(in_main_matrix & in_rhs);
187 *
this+=fracture_sigma
188 .name(
"fracture_sigma")
190 "Coefficient of transfer of forces through fractures.")
192 .input_default(
"1.0")
193 .flags_add(in_main_matrix & in_rhs);
195 *
this+=initial_stress
196 .name(
"initial_stress")
197 .description(
"Initial stress tensor.")
199 .input_default(
"0.0")
202 *
this += region_id.name(
"region_id")
206 *
this += subdomain.name(
"subdomain")
211 .name(
"cross_section")
212 .units(
UnitSI().m(3).md() )
213 .flags(input_copy & in_time_term & in_main_matrix & in_rhs);
215 *
this+=cross_section_min
216 .name(
"cross_section_min")
217 .description(
"Minimal cross-section of fractures.")
218 .units(
UnitSI().m(3).md() )
219 .input_default(
"0.0");
221 *
this+=potential_load
222 .name(
"potential_load")
224 .flags(input_copy & in_rhs);
227 .name(
"displacement")
228 .description(
"Displacement vector field output.")
230 .flags(equation_result);
232 *
this += output_stress
234 .description(
"Stress tensor output.")
236 .flags(equation_result);
238 *
this += output_von_mises_stress
239 .name(
"von_mises_stress")
240 .description(
"von Mises stress output.")
242 .flags(equation_result);
244 *
this += output_mean_stress
246 .description(
"mean stress output.")
248 .flags(equation_result);
250 *
this += output_cross_section
251 .name(
"cross_section_updated")
252 .description(
"Cross-section after deformation - output.")
254 .flags(equation_result);
256 *
this += output_divergence
257 .name(
"displacement_divergence")
258 .description(
"Displacement divergence output.")
259 .units(
UnitSI().dimensionless() )
260 .flags(equation_result);
262 *
this +=
lame_mu.name(
"lame_mu")
263 .description(
"Field lame_mu.")
264 .input_default(
"0.0")
268 .description(
"Field lame_lambda.")
269 .input_default(
"0.0")
272 *
this += dirichlet_penalty.name(
"dirichlet_penalty")
273 .description(
"Field dirichlet_penalty.")
274 .input_default(
"0.0")
278 output_fields += *
this;
280 this->add_coords_field();
281 this->set_default_fieldset();
287 ASSERT_EQ(quad_order(), 1).error(
"Unsupported polynomial order for finite elements in Elasticity");
291 std::shared_ptr<DiscreteSpace> ds = std::make_shared<EqualOrderDiscreteSpace>(mesh, fe);
292 dh_ = std::make_shared<DOFHandlerMultiDim>(*mesh);
294 dh_->distribute_dofs(ds);
299 ASSERT_EQ(quad_order(), 0).error(
"Unsupported polynomial order for output in Elasticity");
302 dh_scalar_ = make_shared<DOFHandlerMultiDim>(*mesh);
303 std::shared_ptr<DiscreteSpace> ds_scalar = std::make_shared<EqualOrderDiscreteSpace>( mesh, fe_p_disc);
304 dh_scalar_->distribute_dofs(ds_scalar);
308 dh_tensor_ = make_shared<DOFHandlerMultiDim>(*mesh);
309 std::shared_ptr<DiscreteSpace> dst = std::make_shared<EqualOrderDiscreteSpace>( mesh, fe_t);
310 dh_tensor_->distribute_dofs(dst);
317 stiffness_assembly_(nullptr),
318 rhs_assembly_(nullptr),
319 constraint_assembly_(nullptr),
320 output_fields_assembly_(nullptr)
339 ASSERT( time_from_rec.
is_default() ).error(
"Duplicate key 'time', time in elasticity is already initialized from parent class!");
353 DebugOut().fmt(
"Mechanics: solution size {}\n",
eq_data_->dh_->n_global_dofs());
376 eq_fields_->output_field_ptr = create_field_fe<3, FieldValue<3>::VectorFixed>(
eq_data_->dh_);
417 std::string petsc_default_opts;
418 petsc_default_opts =
"-ksp_type cg -pc_type hypre -pc_hypre_type boomeramg";
424 #ifndef FLOW123D_HAVE_PERMON
425 ASSERT(
false).error(
"Flow123d was not built with PERMON library, therefore contact conditions are unsupported.");
430 unsigned int n_own_constraints = 0;
431 for (
auto cell :
eq_data_->dh_->own_range())
432 if (cell.elm()->n_neighs_vb() > 0)
434 unsigned int n_constraints = 0;
436 if (elm->n_neighs_vb() > 0)
437 eq_data_->constraint_idx[elm.idx()] = n_constraints++;
441 MatCreateAIJ(PETSC_COMM_WORLD, n_own_constraints,
eq_data_->dh_->lsize(), PETSC_DECIDE, PETSC_DECIDE, nnz, 0, nnz, 0, &
eq_data_->constraint_matrix);
442 VecCreateMPI(PETSC_COMM_WORLD, n_own_constraints, PETSC_DECIDE, &
eq_data_->constraint_vec);
485 eq_fields_->output_field_ptr->vec().local_to_ghost_begin();
486 eq_fields_->output_stress_ptr->vec().zero_entries();
487 eq_fields_->output_cross_section_ptr->vec().zero_entries();
488 eq_fields_->output_div_ptr->vec().zero_entries();
489 eq_fields_->output_field_ptr->vec().local_to_ghost_end();
495 eq_fields_->output_stress_ptr->vec().local_to_ghost_begin();
496 eq_fields_->output_von_mises_stress_ptr->vec().local_to_ghost_begin();
497 eq_fields_->output_mean_stress_ptr->vec().local_to_ghost_begin();
498 eq_fields_->output_cross_section_ptr->vec().local_to_ghost_begin();
499 eq_fields_->output_div_ptr->vec().local_to_ghost_begin();
500 eq_fields_->output_stress_ptr->vec().local_to_ghost_end();
501 eq_fields_->output_von_mises_stress_ptr->vec().local_to_ghost_end();
502 eq_fields_->output_mean_stress_ptr->vec().local_to_ghost_end();
503 eq_fields_->output_cross_section_ptr->vec().local_to_ghost_end();
504 eq_fields_->output_div_ptr->vec().local_to_ghost_end();
515 std::stringstream ss;
529 MatSetOption(*
eq_data_->ls->get_matrix(), MAT_KEEP_NONZERO_PATTERN, PETSC_TRUE);
536 MessageOut().fmt(
"[mech solver] lin. it: {}, reason: {}, residual: {}\n",
574 if (
eq_data_->ls->get_matrix() == NULL
577 DebugOut() <<
"Mechanics: Assembling matrix.\n";
588 DebugOut() <<
"Mechanics: Assembling right hand side.\n";
597 MessageOut().fmt(
"[mech solver] lin. it: {}, reason: {}, residual: {}\n",
640 MatZeroEntries(
eq_data_->constraint_matrix);
641 VecZeroEntries(
eq_data_->constraint_vec);
643 MatAssemblyBegin(
eq_data_->constraint_matrix, MAT_FINAL_ASSEMBLY);
644 MatAssemblyEnd(
eq_data_->constraint_matrix, MAT_FINAL_ASSEMBLY);
645 VecAssemblyBegin(
eq_data_->constraint_vec);
646 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.
GenericAssembly< RhsAssemblyDim > * rhs_assembly_
std::shared_ptr< EqData > eq_data_
Data for model parameters.
static const int registrar
Registrar of class to factory.
void update_output_fields()
GenericAssembly< StiffnessAssemblyDim > * stiffness_assembly_
general assembly objects, hold assembly objects of appropriate dimension
void assemble_constraint_matrix()
GenericAssembly< OutpuFieldsAssemblyDim > * output_fields_assembly_
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.
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.
GenericAssembly< ConstraintAssemblyDim > * constraint_assembly_
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.
Generic class of assemblation.
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)
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.