49 std::string(equation_name),
50 "FEM for linear elasticity.")
53 "Settings for computing balance.")
55 "Parameters of output stream.")
57 "Linear solver for elasticity.")
60 .make_field_descriptor_type(equation_name)),
62 "Input fields of the equation.")
64 EqFields().output_fields.make_output_type(equation_name,
""),
66 "Setting of the field output.")
76 double lame_mu(
double young,
double poisson)
78 return young*0.5/(poisson+1.);
84 return young*poisson/((poisson+1.)*(1.-2.*poisson));
89 inline double operator() (
double young,
double poisson) {
90 return young * 0.5 / (poisson+1.);
96 inline double operator() (
double young,
double poisson) {
97 return young * poisson / ((poisson+1.)*(1.-2.*poisson));
114 return Selection(
"Elasticity_BC_Type",
"Types of boundary conditions for mechanics.")
115 .
add_value(bc_type_displacement,
"displacement",
116 "Prescribed displacement.")
117 .
add_value(bc_type_displacement_normal,
"displacement_n",
118 "Prescribed displacement in the normal direction to the boundary.")
120 "Prescribed traction.")
130 "Type of boundary condition.")
132 .input_default(
"\"traction\"")
133 .input_selection( get_bc_type_selection() )
136 *
this+=bc_displacement
137 .name(
"bc_displacement")
138 .description(
"Prescribed displacement on boundary.")
140 .input_default(
"0.0")
145 .description(
"Prescribed traction on boundary.")
147 .input_default(
"0.0")
152 .description(
"Prescribed bulk load.")
153 .units(
UnitSI().N().m(-3) )
154 .input_default(
"0.0")
158 .name(
"young_modulus")
159 .description(
"Young's modulus.")
161 .input_default(
"0.0")
162 .flags_add(in_main_matrix & in_rhs);
165 .name(
"poisson_ratio")
166 .description(
"Poisson's ratio.")
167 .units(
UnitSI().dimensionless() )
168 .input_default(
"0.0")
169 .flags_add(in_main_matrix & in_rhs);
171 *
this+=fracture_sigma
172 .name(
"fracture_sigma")
174 "Coefficient of transfer of forces through fractures.")
176 .input_default(
"1.0")
177 .flags_add(in_main_matrix & in_rhs);
179 *
this += region_id.name(
"region_id")
183 *
this += subdomain.name(
"subdomain")
188 .name(
"cross_section")
189 .units(
UnitSI().m(3).md() )
190 .flags(input_copy & in_time_term & in_main_matrix & in_rhs);
192 *
this+=potential_load
193 .name(
"potential_load")
195 .flags(input_copy & in_rhs);
198 .name(
"displacement")
199 .description(
"Displacement vector field output.")
201 .flags(equation_result);
203 *
this += output_stress
205 .description(
"Stress tensor output.")
207 .flags(equation_result);
209 *
this += output_von_mises_stress
210 .name(
"von_mises_stress")
211 .description(
"von Mises stress output.")
213 .flags(equation_result);
215 *
this += output_cross_section
216 .name(
"cross_section_updated")
217 .description(
"Cross-section after deformation - output.")
219 .flags(equation_result);
221 *
this += output_divergence
222 .name(
"displacement_divergence")
223 .description(
"Displacement divergence output.")
224 .units(
UnitSI().dimensionless() )
225 .flags(equation_result);
227 *
this +=
lame_mu.name(
"lame_mu")
228 .description(
"Field lame_mu.")
229 .input_default(
"0.0")
233 .description(
"Field lame_lambda.")
234 .input_default(
"0.0")
237 *
this += dirichlet_penalty.name(
"dirichlet_penalty")
238 .description(
"Field dirichlet_penalty.")
239 .input_default(
"0.0")
243 output_fields += *
this;
249 ASSERT_EQ(fe_order, 1)(fe_order).error(
"Unsupported polynomial order for finite elements in Elasticity");
253 std::shared_ptr<DiscreteSpace> ds = std::make_shared<EqualOrderDiscreteSpace>(mesh, fe);
254 dh_ = std::make_shared<DOFHandlerMultiDim>(*mesh);
256 dh_->distribute_dofs(ds);
260 dh_scalar_ = make_shared<DOFHandlerMultiDim>(*mesh);
261 std::shared_ptr<DiscreteSpace> ds_scalar = std::make_shared<EqualOrderDiscreteSpace>( mesh, fe_p_disc);
262 dh_scalar_->distribute_dofs(ds_scalar);
266 dh_tensor_ = make_shared<DOFHandlerMultiDim>(*mesh);
267 std::shared_ptr<DiscreteSpace> dst = std::make_shared<EqualOrderDiscreteSpace>( mesh, fe_t);
268 dh_tensor_->distribute_dofs(dst);
275 stiffness_matrix(nullptr),
277 allocation_done(false),
278 stiffness_assembly_(nullptr),
279 rhs_assembly_(nullptr),
280 output_fields_assembly_(nullptr)
286 eq_data_ = std::make_shared<EqData>();
288 eq_fields_->add_coords_field();
299 ASSERT( time_from_rec.
is_default() ).error(
"Duplicate key 'time', time in elasticity is already initialized from parent class!");
305 eq_fields_->set_mesh(init_mesh);
312 DebugOut().fmt(
"Mechanics: solution size {}\n",
eq_data_->dh_->n_global_dofs());
335 eq_fields_->output_field_ptr = create_field_fe<3, FieldValue<3>::VectorFixed>(
eq_data_->dh_);
339 eq_fields_->output_stress_ptr = create_field_fe<3, FieldValue<3>::TensorFixed>(
eq_data_->dh_tensor_);
343 eq_fields_->output_von_mises_stress_ptr = create_field_fe<3, FieldValue<3>::Scalar>(
eq_data_->dh_scalar_);
347 eq_fields_->output_cross_section_ptr = create_field_fe<3, FieldValue<3>::Scalar>(
eq_data_->dh_scalar_);
351 eq_fields_->output_div_ptr = create_field_fe<3, FieldValue<3>::Scalar>(
eq_data_->dh_scalar_);
365 std::string petsc_default_opts;
366 petsc_default_opts =
"-ksp_type cg -pc_type hypre -pc_hypre_type boomeramg";
391 if (
rhs!=
nullptr) VecDestroy(&
rhs);
406 eq_fields_->output_field_ptr->vec().local_to_ghost_begin();
407 eq_fields_->output_field_ptr->vec().local_to_ghost_end();
410 eq_fields_->output_stress_ptr->vec().zero_entries();
411 eq_fields_->output_cross_section_ptr->vec().zero_entries();
412 eq_fields_->output_div_ptr->vec().zero_entries();
416 eq_fields_->output_stress_ptr->vec().local_to_ghost_begin();
417 eq_fields_->output_stress_ptr->vec().local_to_ghost_end();
418 eq_fields_->output_von_mises_stress_ptr->vec().local_to_ghost_begin();
419 eq_fields_->output_von_mises_stress_ptr->vec().local_to_ghost_end();
420 eq_fields_->output_cross_section_ptr->vec().local_to_ghost_begin();
421 eq_fields_->output_cross_section_ptr->vec().local_to_ghost_end();
422 eq_fields_->output_div_ptr->vec().local_to_ghost_begin();
423 eq_fields_->output_div_ptr->vec().local_to_ghost_end();
434 std::stringstream ss;
449 MatSetOption(*
eq_data_->ls->get_matrix(), MAT_KEEP_NONZERO_PATTERN, PETSC_TRUE);
456 MessageOut().fmt(
"[mech solver] lin. it: {}, reason: {}, residual: {}\n",
512 DebugOut() <<
"Mechanics: Assembling matrix.\n";
528 DebugOut() <<
"Mechanics: Assembling right hand side.\n";
534 if (
rhs ==
nullptr) VecDuplicate(*(
eq_data_->ls->get_rhs() ), &
rhs);
540 MessageOut().fmt(
"[mech solver] lin. it: {}, reason: {}, residual: {}\n",
static const Input::Type::Record & get_input_type()
Main balance input record type.
static auto subdomain(Mesh &mesh) -> IndexField
static constexpr const char * name()
static constexpr Mask in_main_matrix
A field is part of main "stiffness matrix" of the equation.
Solver based on the original PETSc solver using MPIAIJ matrix and succesive Schur complement construc...
static const Input::Type::Record & get_input_type()
The specification of output stream.
std::shared_ptr< EqFields > eq_fields_
Fields for model parameters.
void set_from_input(const Input::Record in_rec) override
#define MessageOut()
Macro defining 'message' record of log.
void next_time()
Proceed to the next time according to current estimated time step.
static const Input::Type::Record & get_input_type()
Declare input record type for the equation TransportDG.
void assemble(std::shared_ptr< DOFHandlerMultiDim > dh)
General assemble methods.
static std::shared_ptr< OutputTime > create_output_stream(const std::string &equation_name, const Input::Record &in_rec, std::string unit_str)
This method delete all object instances of class OutputTime stored in output_streams vector...
Fields computed from the mesh data.
Class FEValues calculates finite element data on the actual cells such as shape function values...
std::shared_ptr< EqData > eq_data_
Data for model parameters.
Class FESystem for compound finite elements.
double lame_mu(double young, double poisson)
#define ASSERT(expr)
Allow use shorter versions of macro names if these names is not used with external library...
const TimeStep & step(int index=-1) const
void update_solution() override
Computes the solution in one time instant.
Basic time management functionality for unsteady (and steady) solvers (class Equation).
Input::Record input_rec
Record with input specification.
Vec rhs
Vector of right hand side.
void view(const char *name="") const
GenericAssembly< OutpuFieldsAssemblyElasticity > * output_fields_assembly_
void create_dh(Mesh *mesh, unsigned int fe_order)
Create DOF handler objects.
static Input::Type::Record & record_template()
Template Record with common keys for derived equations.
FEM for linear elasticity.
bool allocation_done
Indicates whether matrices have been preallocated.
GenericAssembly< RhsAssemblyElasticity > * rhs_assembly_
static const Input::Type::Selection & get_bc_type_selection()
void solve_linear_system()
Solve without updating time step and without output.
Definitions of basic Lagrangean finite elements with polynomial shape functions.
static constexpr Mask equation_external_output
Match an output field, that can be also copy of other field.
void update_output_fields()
GenericAssembly< StiffnessAssemblyElasticity > * stiffness_assembly_
general assembly objects, hold assembly objects of appropriate dimension
static auto region_id(Mesh &mesh) -> IndexField
#define START_TIMER(tag)
Starts a timer with specified tag.
void zero_time_step() override
Initialize solution in the zero time.
static constexpr Mask in_rhs
A field is part of the right hand side of the equation.
void output_data()
Postprocesses the solution and writes to output file.
Mat stiffness_matrix
The stiffness matrix.
std::shared_ptr< Balance > balance() const
void set_solution(Vec sol_vec)
static const int registrar
Registrar of class to factory.
void next_time()
Pass to next time and update equation data.
void initialize() override
double lame_lambda(double young, double poisson)
MixedPtr< FESystem > mixed_fe_system(MixedPtr< FiniteElement > fe, Args &&...args)
Definitions of particular quadrature rules on simplices.
#define WarningOut()
Macro defining 'warning' record of log.
#define END_TIMER(tag)
Ends a timer with specified tag.
static string default_output_field()
void set_initial_guess_nonzero(bool set_nonzero=true)
static const Input::Type::Record & get_input_type()
Class for representation SI units of Fields.
void calculate_cumulative_balance()
Elasticity(Mesh &init_mesh, const Input::Record in_rec, TimeGovernor *tm=nullptr)
Constructor.
static UnitSI & dimensionless()
Returns dimensionless unit.
#define DebugOut()
Macro defining 'debug' record of log.
static bool print_message_table(ostream &stream, std::string equation_name)
Definitions of Raviart-Thomas finite elements.
std::shared_ptr< OutputTime > output_stream_
#define ASSERT_EQ(a, b)
Definition of comparative assert macro (EQual)