67{
68
70
71
73 "--enable-petsc, --enable-trilinos, or --enable-eigen");
74
75
76 libmesh_example_requires(LIBMESH_DIM > 2, "3D support");
77
78
79#ifndef LIBMESH_ENABLE_DIRICHLET
80 libmesh_example_requires(false, "--enable-dirichlet");
81#endif
82
83
84 GetPot infile("fem_system_ex5.in");
85
86
87 infile.parse_command_line(argc, argv);
88
89
90 const Real deltat = infile(
"deltat", 0.25);
91 unsigned int n_timesteps = infile("n_timesteps", 1);
92
93#ifdef LIBMESH_HAVE_EXODUS_API
94 const unsigned int write_interval = infile("write_interval", 1);
95#endif
96
97
98 const unsigned int dim = infile(
"dim", 2);
99 libmesh_example_requires(
dim <= LIBMESH_DIM,
"2D/3D support");
100
101
103
104
105 const bool use_iga = infile("use_iga", true);
106
107
109
110 const std::string iga_filename = infile("iga_filename","DIE!");
111
112
113 if (use_iga)
114 {
116
119 dyna_io.read(iga_filename);
122
125 }
126 else
127 {
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);
134 else
135 libmesh_error_msg(
"Unsupported dim = " <<
dim);
136 }
137
138
140
141
143 {
150 }
151
152
153
154
155 for (
const auto & elem :
mesh.element_ptr_range())
156 {
157 if (!use_iga)
158 {
159 unsigned int side_max_x = 0, side_max_y = 0, side_min_z = 0;
160 bool
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())
164 {
166 {
167 side_max_x = side;
168 found_side_max_x = true;
169 }
170
172 {
173 side_max_y = side;
174 found_side_max_y = true;
175 }
176
179 {
180 side_min_z = side;
181 found_side_min_z = true;
182 }
183 }
184
185
186
187
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)))
194
195
196
197
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)))
203 }
204 else
205 {
206
207
208
209
210
211
212
213
214 if (elem->type() ==
QUAD9 && !elem->neighbor_ptr(3))
216
217
218
219 if (elem->type() ==
QUAD9 && !elem->neighbor_ptr(1))
221
222
223 if (elem->type() ==
QUAD9 && !elem->neighbor_ptr(2))
225 }
226 }
227
228
230
231
233
234
237
239
241
242
243 std::string time_solver = infile("time_solver","DIE!");
244
247
248 if (time_solver == "newmark")
249 {
250
251 v_system = &equation_systems.add_system<
ExplicitSystem> (
"Velocity");
256
257
258 a_system = &equation_systems.add_system<
ExplicitSystem> (
"Acceleration");
263 }
264
265 if (time_solver == "newmark")
266 system.
time_solver = std::make_unique<NewmarkSolver>(system);
267
268 else if (time_solver == "euler")
269 {
270 system.
time_solver = std::make_unique<EulerSolver>(system);
272 euler_solver.
theta = infile(
"theta", 1.0);
273 }
274
275 else if (time_solver == "euler2")
276 {
277 system.
time_solver = std::make_unique<Euler2Solver>(system);
279 euler_solver.
theta = infile(
"theta", 1.0);
280 }
281
282 else if (time_solver == "steady")
283 {
284 system.
time_solver = std::make_unique<SteadySolver>(system);
285 libmesh_assert_equal_to (n_timesteps, 1);
286 }
287 else
288 libmesh_error_msg(std::string("ERROR: invalid time_solver ")+time_solver);
289
290
291 equation_systems.init ();
292
293
295
296
298 solver.
quiet = infile(
"solver_quiet",
true);
304
305
308
309
317
318
319 equation_systems.print_info();
320
321
322
323
325 if (newton_solver &&
326 (time_solver == "euler" || time_solver == "euler2"))
327 {
328#ifdef LIBMESH_HAVE_EIGEN_SPARSE
332
333 if (eigen_linear_solver )
335#endif
336 }
337
338 if (time_solver == "newmark")
339 {
342
343
344
347 }
348
349#ifdef LIBMESH_HAVE_EXODUS_API
350
352 {
353 std::ostringstream file_name;
354
355
356 file_name << std::string("out.")+time_solver+std::string(".e-s.")
357 << std::setw(3)
358 << std::setfill('0')
359 << std::right
360 << 0;
361
363 equation_systems,
364 1,
365
367 }
368#endif
369
370
371
372 for (unsigned int t_step=0; t_step != n_timesteps; ++t_step)
373 {
374
376 << t_step
377 << ", time = "
379 << std::endl;
380
382
383
385
386
387
388 if (time_solver == "newmark")
389 {
392 }
393
394#ifdef LIBMESH_HAVE_EXODUS_API
395
396
398 ((t_step+1)%write_interval == 0))
399 {
400 std::ostringstream file_name;
401
402
403 file_name << std::string("out.")+time_solver+std::string(".e-s.")
404 << std::setw(3)
405 << std::setfill('0')
406 << std::right
407 << t_step+1;
408
410 equation_systems,
411 1,
412
414 }
415#endif
416 }
417
418
419 return 0;
420}
void set_dim(unsigned int dim)
void set_fe_type(const FEType &fe_type)
bool has_boundary_id(const Node *const node, const boundary_id_type id) const
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.
void regenerate_id_sets()
Clears and regenerates the cached sets of ids.
This is a generic class that defines a solver to handle ImplicitSystem classes, including NonlinearIm...
Real absolute_residual_tolerance
The DiffSolver should exit after the residual is reduced to either less than absolute_residual_tolera...
unsigned int max_linear_iterations
Each linear solver step should exit after max_linear_iterations is exceeded.
double initial_linear_tolerance
Any required linear solves will at first be done with this tolerance; the DiffSolver may tighten the ...
Real relative_residual_tolerance
Real relative_step_tolerance
bool verbose
The DiffSolver may print a lot more to libMesh::out if verbose is set to true; default is false.
unsigned int max_nonlinear_iterations
The DiffSolver should exit in failure if max_nonlinear_iterations is exceeded and continue_after_max_...
bool quiet
The DiffSolver should not print anything to libMesh::out unless quiet is set to false; default is tru...
bool print_jacobians
Set print_jacobians to true to print J whenever it is assembled.
bool print_residuals
Set print_residuals to true to print F whenever it is assembled.
Real deltat
For time-dependent problems, this is the amount delta t to advance the solution in time.
bool print_element_jacobians
Set print_element_jacobians to true to print each J_elem contribution.
bool print_element_solutions
Set print_element_solutions to true to print each U_elem input.
bool print_residual_norms
Set print_residual_norms to true to print |F| whenever it is assembled.
bool print_element_residuals
Set print_element_residuals to true to print each R_elem contribution.
bool print_jacobian_norms
Set print_jacobian_norms to true to print |J| whenever it is assembled.
std::unique_ptr< TimeSolver > time_solver
A pointer to the solver object we're going to use.
Reading and writing meshes in (a subset of) LS-DYNA format.
This class provides an interface to Eigen iterative solvers that is compatible with the libMesh Linea...
This is the EquationSystems class.
This class defines a theta-method (defaulting to Backward Euler with theta = 1.0) solver to handle ti...
Real theta
The value for the theta method to employ: 1.0 corresponds to backwards Euler, 0.0 corresponds to forw...
This class defines a theta-method Euler (defaulting to Backward Euler with theta = 1....
Real theta
The value for the theta method to employ: 1.0 corresponds to backwards Euler, 0.0 corresponds to forw...
The ExodusII_IO class implements reading meshes in the ExodusII file format from Sandia National Labs...
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.
Manages consistently variables, degrees of freedom, and coefficient vectors for explicit systems.
virtual void solve() override
Invokes the solver associated with the system.
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
OrderWrapper order
The approximation order of the element (at 0 p-refinement level).
FEFamily family
The type of finite element.
The LibMeshInit class, when constructed, initializes the dependent libraries (e.g.
This base class can be inherited from to provide interfaces to linear solvers from different packages...
void set_solver_type(const SolverType st)
Sets the type of solver to use.
virtual bool is_serial() const
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
void prepare_for_use(const bool skip_renumber_nodes_and_elements, const bool skip_find_neighbors)
Prepare a newly created (or read) mesh for use.
void print_info(std::ostream &os=libMesh::out, const unsigned int verbosity=0, const bool global=true) const
Prints relevant information about the mesh.
This is the MeshCommunication class.
void broadcast(MeshBase &) const
This method takes a mesh (which is assumed to reside on processor 0) and broadcasts it to all the oth...
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
This class defines a Newmark time integrator for second order (in time) DifferentiableSystems.
virtual void compute_initial_accel()
This method uses the specified initial displacement and velocity to compute the initial acceleration ...
This class defines a solver which uses the default libMesh linear solver in a quasiNewton method to h...
LinearSolver< Number > & get_linear_solver()
processor_id_type processor_id() 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.
Real time
For time-dependent problems, this is the time t at the beginning of the current timestep.
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
const NumericVector< Number > & get_vector(std::string_view vec_name) const
boundary_id_type boundary_id_max_x
boundary_id_type boundary_id_min_y
boundary_id_type boundary_id_max_z
boundary_id_type boundary_id_max_y
boundary_id_type boundary_id_min_z
boundary_id_type boundary_id_min_x
const boundary_id_type fixed_v_boundary_id
const boundary_id_type edge_boundary_id
const boundary_id_type pressure_boundary_id
const boundary_id_type node_boundary_id
const boundary_id_type fixed_u_boundary_id
void init(triangulateio &t)
Initializes the fields of t to nullptr/0 as necessary.
SolverPackage default_solver_package()
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real