73 "--enable-petsc, --enable-trilinos, or --enable-eigen");
76 libmesh_example_requires(LIBMESH_DIM > 2,
"3D support");
79 #ifndef LIBMESH_ENABLE_DIRICHLET 80 libmesh_example_requires(
false,
"--enable-dirichlet");
84 GetPot infile(
"fem_system_ex5.in");
87 infile.parse_command_line(argc, argv);
90 const Real deltat = infile(
"deltat", 0.25);
91 unsigned int n_timesteps = infile(
"n_timesteps", 1);
93 #ifdef LIBMESH_HAVE_EXODUS_API 94 const unsigned int write_interval = infile(
"write_interval", 1);
98 const unsigned int dim = infile(
"dim", 2);
99 libmesh_example_requires(
dim <= LIBMESH_DIM,
"2D/3D support");
105 const bool use_iga = infile(
"use_iga",
true);
110 const std::string iga_filename = infile(
"iga_filename",
"DIE!");
119 dyna_io.read(iga_filename);
130 (
mesh, 32, 8, 4, 0., 1.*x_scaling, 0., 0.3, 0., 0.1,
HEX8);
133 (
mesh, 8, 4, 0., 1.*x_scaling, 0., 0.3,
QUAD4);
135 libmesh_error_msg(
"Unsupported dim = " <<
dim);
155 for (
const auto & elem :
mesh.element_ptr_range())
159 unsigned int side_max_x = 0, side_max_y = 0, side_min_z = 0;
161 found_side_max_x =
false, found_side_max_y =
false,
162 found_side_min_z =
false;
163 for (
auto side : elem->side_index_range())
168 found_side_max_x =
true;
174 found_side_max_y =
true;
181 found_side_min_z =
true;
188 if (found_side_max_x && found_side_max_y && found_side_min_z)
189 for (
auto n : elem->node_index_range())
190 if (elem->is_node_on_side(n, side_max_x) &&
191 elem->is_node_on_side(n, side_max_y) &&
192 (
dim == 2 || elem->is_node_on_side(n, side_min_z)))
198 if (found_side_max_x && found_side_min_z)
199 for (
auto e : elem->edge_index_range())
200 if (elem->is_edge_on_side(e, side_max_x) &&
201 (
dim == 2 || elem->is_edge_on_side(e, side_min_z)))
214 if (elem->type() ==
QUAD9 && !elem->neighbor_ptr(3))
219 if (elem->type() ==
QUAD9 && !elem->neighbor_ptr(1))
223 if (elem->type() ==
QUAD9 && !elem->neighbor_ptr(2))
240 std::string time_solver = infile(
"time_solver",
"DIE!");
245 if (time_solver ==
"newmark")
248 v_system = &equation_systems.add_system<
ExplicitSystem> (
"Velocity");
255 a_system = &equation_systems.add_system<
ExplicitSystem> (
"Acceleration");
262 if (time_solver ==
"newmark")
263 system.
time_solver = std::make_unique<NewmarkSolver>(system);
265 else if (time_solver ==
"euler")
267 system.
time_solver = std::make_unique<EulerSolver>(system);
269 euler_solver.theta = infile(
"theta", 1.0);
272 else if (time_solver ==
"euler2")
274 system.
time_solver = std::make_unique<Euler2Solver>(system);
276 euler_solver.theta = infile(
"theta", 1.0);
279 else if (time_solver ==
"steady")
281 system.
time_solver = std::make_unique<SteadySolver>(system);
282 libmesh_assert_equal_to (n_timesteps, 1);
285 libmesh_error_msg(std::string(
"ERROR: invalid time_solver ")+time_solver);
288 equation_systems.init ();
295 solver.
quiet = infile(
"solver_quiet",
true);
316 equation_systems.print_info();
323 (time_solver ==
"euler" || time_solver ==
"euler2"))
325 #ifdef LIBMESH_HAVE_EIGEN_SPARSE 330 if (eigen_linear_solver )
335 if (time_solver ==
"newmark")
346 #ifdef LIBMESH_HAVE_EXODUS_API 350 std::ostringstream file_name;
353 file_name << std::string(
"out.")+time_solver+std::string(
".e-s.")
365 #endif // #ifdef LIBMESH_HAVE_EXODUS_API 369 for (
unsigned int t_step=0; t_step != n_timesteps; ++t_step)
385 if (time_solver ==
"newmark")
391 #ifdef LIBMESH_HAVE_EXODUS_API 395 ((t_step+1)%write_interval == 0))
397 std::ostringstream file_name;
400 file_name << std::string(
"out.")+time_solver+std::string(
".e-s.")
412 #endif // #ifdef LIBMESH_HAVE_EXODUS_API class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
FEFamily family
The type of finite element.
Real time
For time-dependent problems, this is the time t at the beginning of the current timestep.
boundary_id_type boundary_id_min_x
LinearSolver< Number > & get_linear_solver()
This is the EquationSystems class.
const boundary_id_type edge_boundary_id
Reading and writing meshes in (a subset of) LS-DYNA format.
bool has_boundary_id(const Node *const node, const boundary_id_type id) const
bool quiet
The DiffSolver should not print anything to libMesh::out unless quiet is set to false; default is tru...
bool print_jacobian_norms
Set print_jacobian_norms to true to print |J| whenever it is assembled.
The ExodusII_IO class implements reading meshes in the ExodusII file format from Sandia National Labs...
unsigned int max_nonlinear_iterations
The DiffSolver should exit in failure if max_nonlinear_iterations is exceeded and continue_after_max_...
void prepare_for_use(const bool skip_renumber_nodes_and_elements, const bool skip_find_neighbors)
Prepare a newly ecreated (or read) mesh for use.
Real absolute_residual_tolerance
The DiffSolver should exit after the residual is reduced to either less than absolute_residual_tolera...
std::unique_ptr< TimeSolver > time_solver
A pointer to the solver object we're going to use.
This class provides an interface to Eigen iterative solvers that is compatible with the libMesh Linea...
This class defines a Newmark time integrator for second order (in time) DifferentiableSystems.
void set_dim(unsigned int dim)
OrderWrapper order
The approximation order of the element.
The LibMeshInit class, when constructed, initializes the dependent libraries (e.g.
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
bool print_jacobians
Set print_jacobians to true to print J whenever it is assembled.
boundary_id_type boundary_id_max_x
This class defines a solver which uses the default libMesh linear solver in a quasiNewton method to h...
virtual void compute_initial_accel()
This method uses the specified initial displacement and velocity to compute the initial acceleration ...
bool print_element_residuals
Set print_element_residuals to true to print each R_elem contribution.
bool print_element_solutions
Set print_element_solutions to true to print each U_elem input.
SolverPackage default_solver_package()
This is a generic class that defines a solver to handle ImplicitSystem classes, including NonlinearIm...
virtual bool is_serial() const
void add_node(const Node *node, const boundary_id_type id)
Add Node node with boundary id id to the boundary information data structures.
This class defines a theta-method (defaulting to Backward Euler with theta = 1.0) solver to handle ti...
This is the MeshCommunication class.
bool print_residual_norms
Set print_residual_norms to true to print |F| whenever it is assembled.
boundary_id_type boundary_id_max_z
const boundary_id_type node_boundary_id
Real deltat
For time-dependent problems, this is the amount delta t to advance the solution in time...
unsigned int max_linear_iterations
Each linear solver step should exit after max_linear_iterations is exceeded.
void print_info(std::ostream &os=libMesh::out, const unsigned int verbosity=0, const bool global=true) const
Prints relevant information about the mesh.
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
bool print_residuals
Set print_residuals to true to print F whenever it is assembled.
void init(triangulateio &t)
Initializes the fields of t to nullptr/0 as necessary.
void set_fe_type(const FEType &fe_type)
boundary_id_type boundary_id_max_y
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 set_solver_type(const SolverType st)
Sets the type of solver to use.
const boundary_id_type pressure_boundary_id
This class defines a theta-method Euler (defaulting to Backward Euler with theta = 1...
bool verbose
The DiffSolver may print a lot more to libMesh::out if verbose is set to true; default is false...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void write_timestep(const std::string &fname, const EquationSystems &es, const int timestep, const Real time, const std::set< std::string > *system_names=nullptr)
Writes out the solution at a specific timestep.
void broadcast(MeshBase &) const
Finds all the processors that may contain elements that neighbor my elements.
void add_side(const dof_id_type elem, const unsigned short int side, const boundary_id_type id)
Add side side of element number elem with boundary id id to the boundary information data structure...
const boundary_id_type fixed_u_boundary_id
bool print_element_jacobians
Set print_element_jacobians to true to print each J_elem contribution.
virtual void solve() override
Invokes the solver associated with the system.
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
processor_id_type processor_id() const
boundary_id_type boundary_id_min_y
double initial_linear_tolerance
Any required linear solves will at first be done with this tolerance; the DiffSolver may tighten the ...
Manages consistently variables, degrees of freedom, and coefficient vectors for explicit systems...
Real relative_residual_tolerance
Real relative_step_tolerance
const NumericVector< Number > & get_vector(std::string_view vec_name) const
void add_edge(const dof_id_type elem, const unsigned short int edge, const boundary_id_type id)
Add edge edge of element number elem with boundary id id to the boundary information data structure...
boundary_id_type boundary_id_min_z
const boundary_id_type fixed_v_boundary_id