411{
412
414
415
417 "--enable-petsc, --enable-trilinos, or --enable-eigen");
418
419
420 const unsigned int dim = 3;
421
422
423 libmesh_example_requires(
dim == LIBMESH_DIM,
"3D support");
424
425
426#ifndef LIBMESH_ENABLE_DIRICHLET
427 libmesh_example_requires(false, "--enable-dirichlet");
428#endif
429
430
434
435
438 nx,
439 ny,
440 nz,
441 0., 1.*x_scaling,
442 0., 0.3,
443 0., 0.1,
445
446
448
449
450
451
452 for (
const auto & elem :
mesh.element_ptr_range())
453 {
454 unsigned int
455 side_max_x = 0, side_min_y = 0,
456 side_max_y = 0, side_max_z = 0;
457
458 bool
459 found_side_max_x = false, found_side_max_y = false,
460 found_side_min_y = false, found_side_max_z = false;
461
462 for (auto side : elem->side_index_range())
463 {
465 {
466 side_max_x = side;
467 found_side_max_x = true;
468 }
469
471 {
472 side_min_y = side;
473 found_side_min_y = true;
474 }
475
477 {
478 side_max_y = side;
479 found_side_max_y = true;
480 }
481
483 {
484 side_max_z = side;
485 found_side_max_z = true;
486 }
487 }
488
489
490
491
492 if (found_side_max_x && found_side_max_y && found_side_max_z)
493 for (auto n : elem->node_index_range())
494 if (elem->is_node_on_side(n, side_max_x) &&
495 elem->is_node_on_side(n, side_max_y) &&
496 elem->is_node_on_side(n, side_max_z))
497 mesh.get_boundary_info().add_node(elem->node_ptr(n), NODE_BOUNDARY_ID);
498
499
500
501
502
503 if (found_side_max_x && found_side_min_y)
504 for (auto e : elem->edge_index_range())
505 if (elem->is_edge_on_side(e, side_max_x) &&
506 elem->is_edge_on_side(e, side_min_y))
507 mesh.get_boundary_info().add_edge(elem, e, EDGE_BOUNDARY_ID);
508 }
509
510
511
513
514
516
517
518
521
522#ifdef LIBMESH_HAVE_PETSC
523
528 petsc_linear_solver->set_solver_configuration(petsc_solver_config);
529#endif
530
533
534#ifdef LIBMESH_ENABLE_DIRICHLET
535
539
540
542
543
544
546 EDGE_BOUNDARY_ID},
547 {u_var, v_var, w_var}, zf,
549
550
551
553#endif
554
555
558
566
567
568 equation_systems.init();
569
570
571 equation_systems.print_info();
572
573
575
576
577 le.compute_stresses();
578
579
580#ifdef LIBMESH_HAVE_EXODUS_API
581
582
584 exo_io.write_discontinuous_exodusII("displacement_and_stress.exo", equation_systems);
585
586#endif
587
588
589 return 0;
590}
bool has_boundary_id(const Node *const node, const boundary_id_type id) const
void regenerate_id_sets()
Clears and regenerates the cached sets of ids.
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...
Manages consistently variables, degrees of freedom, and coefficient vectors for explicit systems.
The LibMeshInit class, when constructed, initializes the dependent libraries (e.g.
Manages consistently variables, degrees of freedom, coefficient vectors, matrices and linear solvers ...
virtual LinearSolver< Number > * get_linear_solver() const override
virtual void solve() override
Assembles & solves the linear system A*x=b.
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
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.
This class provides an interface to PETSc iterative solvers that is compatible with the libMesh Linea...
void attach_assemble_object(Assembly &assemble)
Register a user object to use in assembling the system matrix and RHS.
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.
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.
SolverPackage default_solver_package()
T command_line_next(std::string name, T default_value)
Use GetPot's search()/next() functions to get following arguments from the command line.