510{
512
513
515
516
517 libmesh_example_requires(LIBMESH_DIM > 2, "--disable-1D-only --disable-2D-only");
518
519
520#ifndef LIBMESH_ENABLE_DIRICHLET
521 libmesh_example_requires(false, "--enable-dirichlet");
522#endif
523
524 GetPot infile("systems_of_equations_ex7.in");
525
526 infile.parse_command_line(argc,argv);
527
528 const Real x_length = infile(
"x_length", 0.);
529 const Real y_length = infile(
"y_length", 0.);
530 const Real z_length = infile(
"z_length", 0.);
531 const int n_elem_x = infile("n_elem_x", 0);
532 const int n_elem_y = infile("n_elem_y", 0);
533 const int n_elem_z = infile("n_elem_z", 0);
534 const std::string approx_order = infile("approx_order", "FIRST");
535 const std::string fe_family = infile("fe_family", "LAGRANGE");
536
537 const Real young_modulus = infile(
"Young_modulus", 1.0);
538 const Real poisson_ratio = infile(
"poisson_ratio", 0.3);
539 const Real forcing_magnitude = infile(
"forcing_magnitude", 0.001);
540
541 const Real nonlinear_abs_tol = infile(
"nonlinear_abs_tol", 1.e-8);
542 const Real nonlinear_rel_tol = infile(
"nonlinear_rel_tol", 1.e-8);
543 const unsigned int nonlinear_max_its = infile("nonlinear_max_its", 50);
544
545 const unsigned int n_solves = infile("n_solves", 10);
546 const Real force_scaling = infile(
"force_scaling", 5.0);
547
549
551 n_elem_x,
552 n_elem_y,
553 n_elem_z,
554 0., x_length,
555 0., y_length,
556 0., z_length,
558
560
563
567
568 unsigned int u_var =
570 Utility::string_to_enum<Order> (approx_order),
571 Utility::string_to_enum<FEFamily>(fe_family));
572
573 unsigned int v_var =
575 Utility::string_to_enum<Order> (approx_order),
576 Utility::string_to_enum<FEFamily>(fe_family));
577
578 unsigned int w_var =
580 Utility::string_to_enum<Order> (approx_order),
581 Utility::string_to_enum<FEFamily>(fe_family));
582
583
592
593 equation_systems.parameters.set<
Real> (
"nonlinear solver absolute residual tolerance") = nonlinear_abs_tol;
594 equation_systems.parameters.set<
Real> (
"nonlinear solver relative residual tolerance") = nonlinear_rel_tol;
595 equation_systems.parameters.set<unsigned int> ("nonlinear solver maximum iterations") = nonlinear_max_its;
596
599
600 equation_systems.parameters.set<
Real>(
"young_modulus") = young_modulus;
601 equation_systems.parameters.set<
Real>(
"poisson_ratio") = poisson_ratio;
602 equation_systems.parameters.set<
Real>(
"forcing_magnitude") = forcing_magnitude;
603
604#ifdef LIBMESH_ENABLE_DIRICHLET
605
607
608
609
613#endif
615
616 equation_systems.init();
617 equation_systems.print_info();
618
619
620
621
622
623
624 for (unsigned int count=0; count<n_solves; count++)
625 {
626 Real previous_forcing_magnitude = equation_systems.parameters.get<
Real>(
"forcing_magnitude");
627 equation_systems.parameters.set<
Real>(
"forcing_magnitude") = previous_forcing_magnitude*force_scaling;
628
630 << count
631 << ", forcing_magnitude: "
632 << equation_systems.parameters.
get<
Real>(
"forcing_magnitude")
633 << std::endl;
634
636
639 << " , final nonlinear residual norm: "
641 << std::endl
642 << std::endl;
643
645
646 lde.compute_stresses();
647
648#ifdef LIBMESH_HAVE_EXODUS_API
649 std::stringstream filename;
650 filename << "solution_" << count << ".exo";
652#endif
653 }
654
655 return 0;
656}
streamT * get()
Rather than implement every ostream/ios/ios_base function, we'll be lazy and make esoteric uses go th...
This class allows one to associate Dirichlet boundary values with a given set of mesh boundary ids an...
void add_dirichlet_boundary(const DirichletBoundary &dirichlet_boundary)
Adds a copy of the specified Dirichlet boundary to the system.
This is the EquationSystems class.
The ExodusII_IO class implements reading meshes in the ExodusII file format from Sandia National Labs...
virtual void write_equation_systems(const std::string &fname, const EquationSystems &es, const std::set< std::string > *system_names=nullptr) override
Writes out the solution for no specific time or timestep.
Manages consistently variables, degrees of freedom, and coefficient vectors for explicit systems.
The LibMeshInit class, when constructed, initializes the dependent libraries (e.g.
void print_info(std::ostream &os=libMesh::out, const unsigned int verbosity=0, const bool global=true) const
Prints relevant information about the mesh.
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
Manages consistently variables, degrees of freedom, coefficient vectors, matrices and non-linear solv...
virtual void solve() override
Assembles & solves the nonlinear system R(x) = 0.
std::unique_ptr< NonlinearSolver< Number > > nonlinear_solver
The NonlinearSolver defines the default interface used to solve the nonlinear_implicit system.
Real final_nonlinear_residual() const
unsigned int n_nonlinear_iterations() const
unsigned int add_variable(std::string_view var, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
Adds the variable var to the list of variables for this system.
void prefer_hash_table_matrix_assembly(bool preference)
Sets whether to use hash table matrix assembly if the matrix sub-classes support it.
const DofMap & get_dof_map() const
ConstFunction that simply returns 0.
void init(triangulateio &t)
Initializes the fields of t to nullptr/0 as necessary.
void libmesh_ignore(const Args &...)
SolverPackage default_solver_package()
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real