Flow123d
PE_user_fields-12e8aadde
|
Go to the documentation of this file.
48 std::string equation_name = std::string(name_) +
"_FE";
50 std::string(equation_name),
51 "FEM for linear elasticity.")
54 "Settings for computing balance.")
56 "Parameters of output stream.")
58 "Linear solver for elasticity.")
61 "Input fields of the equation defined by user.")
64 .make_field_descriptor_type(equation_name)),
66 "Input fields of the equation.")
68 EqFields().output_fields.make_output_type(equation_name,
""),
69 IT::Default(
"{ \"fields\": [ \"displacement\" ] }"),
70 "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));
118 return Selection(
"Elasticity_BC_Type",
"Types of boundary conditions for mechanics.")
119 .
add_value(bc_type_displacement,
"displacement",
120 "Prescribed displacement.")
121 .
add_value(bc_type_displacement_normal,
"displacement_n",
122 "Prescribed displacement in the normal direction to the boundary.")
124 "Prescribed traction.")
126 "Prescribed stress tensor.")
136 "Type of boundary condition.")
138 .input_default(
"\"traction\"")
139 .input_selection( get_bc_type_selection() )
142 *
this+=bc_displacement
143 .name(
"bc_displacement")
144 .description(
"Prescribed displacement on boundary.")
146 .input_default(
"0.0")
151 .description(
"Prescribed traction on boundary.")
153 .input_default(
"0.0")
158 .description(
"Prescribed stress on boundary.")
160 .input_default(
"0.0")
165 .description(
"Prescribed bulk load.")
166 .units(
UnitSI().N().m(-3) )
167 .input_default(
"0.0")
171 .name(
"young_modulus")
172 .description(
"Young's modulus.")
174 .input_default(
"0.0")
175 .flags_add(in_main_matrix & in_rhs);
178 .name(
"poisson_ratio")
179 .description(
"Poisson's ratio.")
180 .units(
UnitSI().dimensionless() )
181 .input_default(
"0.0")
182 .flags_add(in_main_matrix & in_rhs);
184 *
this+=fracture_sigma
185 .name(
"fracture_sigma")
187 "Coefficient of transfer of forces through fractures.")
189 .input_default(
"1.0")
190 .flags_add(in_main_matrix & in_rhs);
192 *
this+=initial_stress
193 .name(
"initial_stress")
194 .description(
"Initial stress tensor.")
196 .input_default(
"0.0")
199 *
this += region_id.name(
"region_id")
203 *
this += subdomain.name(
"subdomain")
208 .name(
"cross_section")
209 .units(
UnitSI().m(3).md() )
210 .flags(input_copy & in_time_term & in_main_matrix & in_rhs);
212 *
this+=potential_load
213 .name(
"potential_load")
215 .flags(input_copy & in_rhs);
218 .name(
"displacement")
219 .description(
"Displacement vector field output.")
221 .flags(equation_result);
223 *
this += output_stress
225 .description(
"Stress tensor output.")
227 .flags(equation_result);
229 *
this += output_von_mises_stress
230 .name(
"von_mises_stress")
231 .description(
"von Mises stress output.")
233 .flags(equation_result);
235 *
this += output_mean_stress
237 .description(
"mean stress output.")
239 .flags(equation_result);
241 *
this += output_cross_section
242 .name(
"cross_section_updated")
243 .description(
"Cross-section after deformation - output.")
245 .flags(equation_result);
247 *
this += output_divergence
248 .name(
"displacement_divergence")
249 .description(
"Displacement divergence output.")
250 .units(
UnitSI().dimensionless() )
251 .flags(equation_result);
253 *
this +=
lame_mu.name(
"lame_mu")
254 .description(
"Field lame_mu.")
255 .input_default(
"0.0")
259 .description(
"Field lame_lambda.")
260 .input_default(
"0.0")
263 *
this += dirichlet_penalty.name(
"dirichlet_penalty")
264 .description(
"Field dirichlet_penalty.")
265 .input_default(
"0.0")
269 output_fields += *
this;
275 ASSERT_EQ(fe_order, 1)(fe_order).error(
"Unsupported polynomial order for finite elements in Elasticity");
279 std::shared_ptr<DiscreteSpace> ds = std::make_shared<EqualOrderDiscreteSpace>(mesh, fe);
280 dh_ = std::make_shared<DOFHandlerMultiDim>(*mesh);
282 dh_->distribute_dofs(ds);
286 dh_scalar_ = make_shared<DOFHandlerMultiDim>(*mesh);
287 std::shared_ptr<DiscreteSpace> ds_scalar = std::make_shared<EqualOrderDiscreteSpace>( mesh, fe_p_disc);
288 dh_scalar_->distribute_dofs(ds_scalar);
292 dh_tensor_ = make_shared<DOFHandlerMultiDim>(*mesh);
293 std::shared_ptr<DiscreteSpace> dst = std::make_shared<EqualOrderDiscreteSpace>( mesh, fe_t);
294 dh_tensor_->distribute_dofs(dst);
301 stiffness_assembly_(nullptr),
302 rhs_assembly_(nullptr),
303 output_fields_assembly_(nullptr)
309 eq_data_ = std::make_shared<EqData>();
322 ASSERT( time_from_rec.
is_default() ).error(
"Duplicate key 'time', time in elasticity is already initialized from parent class!");
335 DebugOut().fmt(
"Mechanics: solution size {}\n",
eq_data_->dh_->n_global_dofs());
358 eq_fields_->output_field_ptr = create_field_fe<3, FieldValue<3>::VectorFixed>(
eq_data_->dh_);
362 eq_fields_->output_stress_ptr = create_field_fe<3, FieldValue<3>::TensorFixed>(
eq_data_->dh_tensor_);
366 eq_fields_->output_von_mises_stress_ptr = create_field_fe<3, FieldValue<3>::Scalar>(
eq_data_->dh_scalar_);
370 eq_fields_->output_mean_stress_ptr = create_field_fe<3, FieldValue<3>::Scalar>(
eq_data_->dh_scalar_);
374 eq_fields_->output_cross_section_ptr = create_field_fe<3, FieldValue<3>::Scalar>(
eq_data_->dh_scalar_);
378 eq_fields_->output_div_ptr = create_field_fe<3, FieldValue<3>::Scalar>(
eq_data_->dh_scalar_);
395 eq_fields_->set_user_fields_map(user_fields_arr);
399 std::string petsc_default_opts;
400 petsc_default_opts =
"-ksp_type cg -pc_type hypre -pc_hypre_type boomeramg";
439 eq_fields_->output_field_ptr->vec().local_to_ghost_begin();
440 eq_fields_->output_stress_ptr->vec().zero_entries();
441 eq_fields_->output_cross_section_ptr->vec().zero_entries();
442 eq_fields_->output_div_ptr->vec().zero_entries();
443 eq_fields_->output_field_ptr->vec().local_to_ghost_end();
449 eq_fields_->output_stress_ptr->vec().local_to_ghost_begin();
450 eq_fields_->output_von_mises_stress_ptr->vec().local_to_ghost_begin();
451 eq_fields_->output_mean_stress_ptr->vec().local_to_ghost_begin();
452 eq_fields_->output_cross_section_ptr->vec().local_to_ghost_begin();
453 eq_fields_->output_div_ptr->vec().local_to_ghost_begin();
454 eq_fields_->output_stress_ptr->vec().local_to_ghost_end();
455 eq_fields_->output_von_mises_stress_ptr->vec().local_to_ghost_end();
456 eq_fields_->output_mean_stress_ptr->vec().local_to_ghost_end();
457 eq_fields_->output_cross_section_ptr->vec().local_to_ghost_end();
458 eq_fields_->output_div_ptr->vec().local_to_ghost_end();
469 std::stringstream ss;
483 MatSetOption(*
eq_data_->ls->get_matrix(), MAT_KEEP_NONZERO_PATTERN, PETSC_TRUE);
490 MessageOut().fmt(
"[mech solver] lin. it: {}, reason: {}, residual: {}\n",
538 if (
eq_data_->ls->get_matrix() == NULL
541 DebugOut() <<
"Mechanics: Assembling matrix.\n";
552 DebugOut() <<
"Mechanics: Assembling right hand side.\n";
561 MessageOut().fmt(
"[mech solver] lin. it: {}, reason: {}, residual: {}\n",
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.
static constexpr Mask in_rhs
A field is part of the right hand side of the equation.
Input::Record input_rec
Record with input specification.
Definitions of Raviart-Thomas finite elements.
void update_output_fields()
static UnitSI & dimensionless()
Returns dimensionless unit.
void next_time()
Pass to next time and update equation data.
void solve_linear_system()
Solve without updating time step and without output.
void set_initial_guess_nonzero(bool set_nonzero=true)
Class FEValues calculates finite element data on the actual cells such as shape function values,...
Solver based on the original PETSc solver using MPIAIJ matrix and succesive Schur complement construc...
static constexpr const char * name_
Class FESystem for compound finite elements.
void assemble(std::shared_ptr< DOFHandlerMultiDim > dh) override
General assemble methods.
static constexpr Mask equation_external_output
Match an output field, that can be also copy of other field.
void calculate_cumulative_balance()
Definitions of basic Lagrangean finite elements with polynomial shape functions.
std::shared_ptr< Balance > balance() const
static const int registrar
Registrar of class to factory.
void initialize() override
FEM for linear elasticity.
Definitions of particular quadrature rules on simplices.
Basic time management functionality for unsteady (and steady) solvers (class Equation).
const TimeStep & step(int index=-1) const
static auto subdomain(Mesh &mesh) -> IndexField
static bool print_message_table(ostream &stream, std::string equation_name)
Class for representation SI units of Fields.
Elasticity(Mesh &init_mesh, const Input::Record in_rec, TimeGovernor *tm=nullptr)
Constructor.
#define ASSERT_EQ(a, b)
Definition of comparative assert macro (EQual) only for debug mode.
MixedPtr< FESystem > mixed_fe_system(MixedPtr< FiniteElement > fe, Args &&... args)
void view(const char *name="") const
std::shared_ptr< OutputTime > output_stream_
static auto region_id(Mesh &mesh) -> IndexField
static constexpr Mask in_main_matrix
A field is part of main "stiffness matrix" of the equation.
void set_from_input(const Input::Record in_rec) override
static const Input::Type::Record & get_input_type()
The specification of output stream.
#define WarningOut()
Macro defining 'warning' record of log.
double lame_mu(double young, double poisson)
static Input::Type::Record & record_template()
Template Record with common keys for derived equations.
void set_solution(Vec sol_vec)
std::shared_ptr< EqFields > eq_fields_
Fields for model parameters.
GenericAssembly< OutpuFieldsAssemblyElasticity > * output_fields_assembly_
static const Input::Type::Record & get_input_type()
Declare input record type for the equation TransportDG.
GenericAssembly< RhsAssemblyElasticity > * rhs_assembly_
void update_solution() override
Computes the solution in one time instant.
double lame_lambda(double young, double poisson)
GenericAssembly< StiffnessAssemblyElasticity > * stiffness_assembly_
general assembly objects, hold assembly objects of appropriate dimension
#define DebugOut()
Macro defining 'debug' record of log.
void next_time()
Proceed to the next time according to current estimated time step.
std::shared_ptr< EqData > eq_data_
Data for model parameters.
void create_dh(Mesh *mesh, unsigned int fe_order)
Create DOF handler objects.
#define START_TIMER(tag)
Starts a timer with specified tag.
void zero_time_step() override
Initialize solution in the zero time.
static const Input::Type::Record & get_input_type()
void output_data()
Postprocesses the solution and writes to output file.
static const Input::Type::Selection & get_bc_type_selection()
static const Input::Type::Record & get_input_type()
Main balance input record type.
#define END_TIMER(tag)
Ends a timer with specified tag.
#define MessageOut()
Macro defining 'message' record of log.