libMesh
Loading...
Searching...
No Matches
reduced_basis_ex5.C
Go to the documentation of this file.
1// The libMesh Finite Element Library.
2// Copyright (C) 2002-2026 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3
4// This library is free software; you can redistribute it and/or
5// modify it under the terms of the GNU Lesser General Public
6// License as published by the Free Software Foundation; either
7// version 2.1 of the License, or (at your option) any later version.
8
9// This library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12// Lesser General Public License for more details.
13
14// You should have received a copy of the GNU Lesser General Public
15// License along with this library; if not, write to the Free Software
16// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
18// rbOOmit: An implementation of the Certified Reduced Basis method.
19// Copyright (C) 2009, 2010 David J. Knezevic
20// This file is part of rbOOmit.
21
22
23
24// <h1>Reduced Basis: Example 5 - Reduced Basis Cantilever</h1>
25// 1D/2D/3D cantilever beam using the Reduced Basis Method
26// \author David Knezevic
27// \author Kyunghoon "K" Lee
28// \date 2012
29//
30// We consider four parameters in this problem:
31// x_scaling: scales the length of the cantilever
32// load_Fx: the traction in the x-direction on the right boundary of the cantilever
33// load_Fy: the traction in the y-direction on the right boundary of the cantilever
34// load_Fz: the traction in the z-direction on the right boundary of the cantilever
35
36// C++ include files that we need
37#include <iostream>
38#include <algorithm>
39#include <cstdlib> // *must* precede <cmath> for proper std:abs() on PGI, Sun Studio CC
40#include <cmath>
41#include <set>
42
43// Basic include file needed for the mesh functionality.
44#include "libmesh/libmesh.h"
45#include "libmesh/mesh.h"
46#include "libmesh/mesh_generation.h"
47#include "libmesh/exodusII_io.h"
48#include "libmesh/equation_systems.h"
49#include "libmesh/dof_map.h"
50#include "libmesh/getpot.h"
51#include "libmesh/elem.h"
52#include "libmesh/quadrature_gauss.h"
53#include "libmesh/libmesh_logging.h"
54#include "libmesh/nemesis_io.h"
55#include "libmesh/rb_data_serialization.h"
56#include "libmesh/rb_data_deserialization.h"
57#include "libmesh/enum_solver_package.h"
58#include "libmesh/enum_solver_type.h"
59#include "libmesh/elem_side_builder.h"
60
61// local includes
62#include "rb_classes.h"
63#include "assembly.h"
64
65// boundary IDs
66#define BOUNDARY_ID_MIN_Z 0
67#define BOUNDARY_ID_MIN_Y 1
68#define BOUNDARY_ID_MAX_X 2
69#define BOUNDARY_ID_MAX_Y 3
70#define BOUNDARY_ID_MIN_X 4
71#define BOUNDARY_ID_MAX_Z 5
72#define NODE_BOUNDARY_ID 10
73
74// Bring in everything from the libMesh namespace
75using namespace libMesh;
76
77// Define a function to scale the mesh according to the parameter.
79 const RBParameters & mu,
80 const std::string & filename);
81
82// Post-process the solution to compute stresses
84
85// The main program.
86int main(int argc, char ** argv)
87{
88 // Initialize libMesh.
89 LibMeshInit init (argc, argv);
90
91 // This example requires a linear solver package.
92 libmesh_example_requires(libMesh::default_solver_package() != INVALID_SOLVER_PACKAGE,
93 "--enable-petsc, --enable-trilinos, or --enable-eigen");
94
95#if !defined(LIBMESH_HAVE_XDR)
96 // We need XDR support to write out reduced bases
97 libmesh_example_requires(false, "--enable-xdr");
98#elif defined(LIBMESH_DEFAULT_SINGLE_PRECISION)
99 // XDR binary support requires double precision
100 libmesh_example_requires(false, "--disable-singleprecision");
101#elif defined(LIBMESH_DEFAULT_TRIPLE_PRECISION)
102 // I have no idea why long double isn't working here... [RHS]
103 libmesh_example_requires(false, "double precision");
104#endif
105
106 // Trilinos reports "true residual is too large" in the offline mode
107 // portion of this example
108 libmesh_example_requires(libMesh::default_solver_package() != TRILINOS_SOLVERS, "--enable-petsc or --enable-laspack");
109
110 // This example only works on all meshes if libMesh was compiled for 3D
111 libmesh_example_requires(LIBMESH_DIM == 3, "3D support");
112
113#ifndef LIBMESH_ENABLE_DIRICHLET
114 libmesh_example_requires(false, "--enable-dirichlet");
115#else
116
117 std::string parameters_filename = "reduced_basis_ex5.in";
118 GetPot infile(parameters_filename);
119
120 // Override input file arguments from the command line
121 infile.parse_command_line(argc, argv);
122
123 unsigned int n_elem_x = infile("n_elem_x", 0);
124 unsigned int n_elem_y = infile("n_elem_y", 0);
125 unsigned int n_elem_z = infile("n_elem_z", 0);
126 Real x_size = infile("x_size", 0.);
127 Real y_size = infile("y_size", 0.);
128 Real z_size = infile("z_size", 0.);
129
130 bool store_basis_functions = infile("store_basis_functions", true);
131
132 // Read the "online_mode" flag from the command line
133 const int online_mode = libMesh::command_line_next("-online_mode", 0);
134
135 Mesh mesh (init.comm());
136
137 // Read a mesh from file?
138 const std::string mesh_filename = infile("mesh_filename", "NO MESH FILE");
139
140 if (mesh_filename == "NO MESH FILE")
142 (mesh, n_elem_x, n_elem_y, n_elem_z,
143 0., x_size, 0., y_size, 0., z_size, HEX27);
144 else
145 {
146 mesh.read(mesh_filename);
147
148 // We might be using legacy reduced_basis I/O, which relies on
149 // Hilbert curve renumbering ... and if we have overlapping
150 // nodes, as in the case of IGA meshes where FE nodes and spline
151 // nodes can coincide, then we need unique_id() values to
152 // disambiguate them when sorting.
153#if !defined(LIBMESH_HAVE_CAPNPROTO) && !defined(LIBMESH_ENABLE_UNIQUE_ID)
154 libmesh_example_requires(false, "--enable-unique-id or --enable-capnp");
155#endif
156
157 // We don't yet support the experimental BEXT sideset spec, so
158 // for now we'll add our required sidesets manually for our BEXT
159 // file.
160
161 // To avoid extraneous allocation when obtaining element side vertex averages
162 ElemSideBuilder side_builder;
163
164 // Each processor should know about each boundary condition it can
165 // see, so we loop over all elements, not just local elements.
166 for (const auto & elem : mesh.element_ptr_range())
167 for (auto side : elem->side_index_range())
168 if (!elem->neighbor_ptr(side))
169 {
170 const Point side_center = side_builder(*elem, side).vertex_average();
171 // Yes, BOUNDARY_ID_MIN_X is a weird ID to use at
172 // min(z), but we got an IGA cantilever mesh with the
173 // lever arm in the z direction
174 if (side_center(2) < 0.1)
175 mesh.get_boundary_info().add_side(elem, side, BOUNDARY_ID_MIN_X);
176 if (side_center(2) > 11.9)
177 mesh.get_boundary_info().add_side(elem, side, BOUNDARY_ID_MAX_X);
178 }
179 }
180
181 // Let's add a node boundary condition so that we can impose a point
182 // load and get more test coverage in the build_cube case.
183
184 // Each processor should know about each boundary condition it can
185 // see, so we loop over all elements, not just local elements.
186 for (const auto & elem : mesh.element_ptr_range())
187 {
188 unsigned int side_max_x = 0, side_max_y = 0, side_max_z = 0;
189 bool found_side_max_x = false, found_side_max_y = false, found_side_max_z = false;
190 for (auto side : elem->side_index_range())
191 {
192 if (mesh.get_boundary_info().has_boundary_id(elem, side, BOUNDARY_ID_MAX_X))
193 {
194 side_max_x = side;
195 found_side_max_x = true;
196 }
197
198 if (mesh.get_boundary_info().has_boundary_id(elem, side, BOUNDARY_ID_MAX_Y))
199 {
200 side_max_y = side;
201 found_side_max_y = true;
202 }
203
204 if (mesh.get_boundary_info().has_boundary_id(elem, side, BOUNDARY_ID_MAX_Z))
205 {
206 side_max_z = side;
207 found_side_max_z = true;
208 }
209 }
210
211 // If elem has sides on boundaries
212 // BOUNDARY_ID_MAX_X, BOUNDARY_ID_MAX_Y, BOUNDARY_ID_MAX_Z
213 // then let's set a node boundary condition
214 if (found_side_max_x && found_side_max_y && found_side_max_z)
215 {
216 for (auto n : elem->node_index_range())
217 {
218 if (elem->is_node_on_side(n, side_max_x) &&
219 elem->is_node_on_side(n, side_max_y) &&
220 elem->is_node_on_side(n, side_max_z))
221 {
222 mesh.get_boundary_info().add_node(elem->node_ptr(n), NODE_BOUNDARY_ID);
223 }
224 }
225 }
226 }
227
229
230 const unsigned int dim = mesh.mesh_dimension();
231
232 // Create an equation systems object.
233 EquationSystems equation_systems(mesh);
234
235 // We override RBConstruction with ElasticityRBConstruction in order to
236 // specialize a few functions for this particular problem.
237 ElasticityRBConstruction & rb_con =
238 equation_systems.add_system<ElasticityRBConstruction>("RBElasticity");
239
240 unsigned int order = infile("order", 1);
241
242 rb_con.var_order = Order(order);
243
244 // Also, initialize an ExplicitSystem to store stresses
245 ExplicitSystem & stress_system =
246 equation_systems.add_system<ExplicitSystem> ("StressSystem");
247 stress_system.add_variable("sigma_00", CONSTANT, MONOMIAL);
248
249 // Lots of ifs to keep order consistent
250 if (dim > 1)
251 stress_system.add_variable("sigma_01", CONSTANT, MONOMIAL);
252 if (dim > 2)
253 stress_system.add_variable("sigma_02", CONSTANT, MONOMIAL);
254 if (dim > 1)
255 stress_system.add_variable("sigma_10", CONSTANT, MONOMIAL);
256 if (dim > 1)
257 stress_system.add_variable("sigma_11", CONSTANT, MONOMIAL);
258 if (dim > 2)
259 {
260 stress_system.add_variable("sigma_12", CONSTANT, MONOMIAL);
261 stress_system.add_variable("sigma_20", CONSTANT, MONOMIAL);
262 stress_system.add_variable("sigma_21", CONSTANT, MONOMIAL);
263 stress_system.add_variable("sigma_22", CONSTANT, MONOMIAL);
264 }
265 stress_system.add_variable("vonMises", CONSTANT, MONOMIAL);
266
267 // Initialize the data structures for the equation system.
268 equation_systems.init ();
269 equation_systems.print_info();
270
271 // Build a new RBEvaluation object which will be used to perform
272 // Reduced Basis calculations. This is required in both the
273 // "Offline" and "Online" stages.
275
276 // We need to give the RBConstruction object a pointer to
277 // our RBEvaluation object
278 rb_con.set_rb_evaluation(rb_eval);
279
280 if (!online_mode) // Perform the Offline stage of the RB method
281 {
282 // Use CG solver. This echoes the Petsc command line options set
283 // in run.sh, but also works for non-PETSc linear solvers.
285
286 // Read in the data that defines this problem from the specified text file
287 rb_con.process_parameters_file(parameters_filename);
288
289 // Print out info that describes the current setup of rb_con
290 rb_con.print_info();
291
292 // Prepare rb_con for the Construction stage of the RB method.
293 // This sets up the necessary data structures and performs
294 // initial assembly of the "truth" affine expansion of the PDE.
296
297 // Compute the reduced basis space by computing "snapshots", i.e.
298 // "truth" solves, at well-chosen parameter values and employing
299 // these snapshots as basis functions.
300 rb_con.train_reduced_basis();
301
302 // Write out the data that will subsequently be required for the Evaluation stage
303#if defined(LIBMESH_HAVE_CAPNPROTO)
305 rb_eval_writer.write_to_file("rb_eval.bin");
306#else
308#endif
309
310 // If requested, write out the RB basis functions for visualization purposes
311 if (store_basis_functions)
312 {
313 // Write out the basis functions
315 }
316 }
317 else // Perform the Online stage of the RB method
318 {
319 // Read in the reduced basis data
320#if defined(LIBMESH_HAVE_CAPNPROTO)
322 rb_eval_reader.read_from_file("rb_eval.bin", /*read_error_bound_data*/ true);
323#else
325#endif
326
327 // Initialize online parameters
328 Real online_x_scaling = infile("online_x_scaling", 0.);
329 Real online_load_Fx = infile("online_load_Fx", 0.);
330 Real online_load_Fy = infile("online_load_Fy", 0.);
331 Real online_load_Fz = infile("online_load_Fz", 0.);
332 Real online_point_load_Fx = infile("online_point_load_Fx", 0.);
333 Real online_point_load_Fy = infile("online_point_load_Fy", 0.);
334 Real online_point_load_Fz = infile("online_point_load_Fz", 0.);
335 RBParameters online_mu;
336 online_mu.set_value("x_scaling", online_x_scaling);
337 online_mu.set_value("load_Fx", online_load_Fx);
338 online_mu.set_value("load_Fy", online_load_Fy);
339 online_mu.set_value("load_Fz", online_load_Fz);
340 online_mu.set_value("point_load_Fx", online_point_load_Fx);
341 online_mu.set_value("point_load_Fy", online_point_load_Fy);
342 online_mu.set_value("point_load_Fz", online_point_load_Fz);
343 rb_eval.set_parameters(online_mu);
344 rb_eval.print_parameters();
345
346 // Now do the Online solve using the precomputed reduced basis
347 rb_eval.rb_solve(rb_eval.get_n_basis_functions());
348
349 if (store_basis_functions)
350 {
351 // Read in the basis functions
352 rb_eval.read_in_basis_functions(rb_con);
353
354 // Plot the solution
355 rb_con.load_rb_solution();
356
357 const RBParameters & rb_eval_params = rb_eval.get_parameters();
358 scale_mesh_and_plot(equation_systems, rb_eval_params, "RB_sol");
359 }
360 }
361
362#endif // LIBMESH_ENABLE_DIRICHLET
363
364 return 0;
365}
366
367#ifdef LIBMESH_ENABLE_DIRICHLET
368
370 const RBParameters & mu,
371 const std::string & file_basename)
372{
373 // Loop over the mesh nodes and move them!
374 MeshBase & mesh = es.get_mesh();
375
376 for (auto & node : mesh.node_ptr_range())
377 (*node)(0) *= mu.get_value("x_scaling");
378
379 // Post-process the solution to compute the stresses
381
382#ifdef LIBMESH_HAVE_EXODUS_API
383 // Distributed IGA meshes don't yet support re-gathering to serial
384 bool do_exodus_write =
385 (es.get_mesh().get_constraint_rows().empty() ||
386 es.get_mesh().is_serial());
387 es.comm().min(do_exodus_write);
388 if (do_exodus_write)
389 ExodusII_IO (mesh).write_equation_systems (file_basename+".e", es);
390#ifdef LIBMESH_HAVE_NEMESIS_API
391 else
392 Nemesis_IO (mesh).write_equation_systems (file_basename+".nem", es);
393#endif
394#endif
395
396 // Avoid unused variable warnings when Exodus is not enabled
397 libmesh_ignore(file_basename);
398
399 // Loop over the mesh nodes and move them!
400 for (auto & node : mesh.node_ptr_range())
401 (*node)(0) /= mu.get_value("x_scaling");
402}
403
405{
406 LOG_SCOPE("compute_stresses()", "main");
407
408 const MeshBase & mesh = es.get_mesh();
409
410 const unsigned int dim = mesh.mesh_dimension();
411 libmesh_assert_less_equal(dim, 3);
412
413 ElasticityRBConstruction & system = es.get_system<ElasticityRBConstruction>("RBElasticity");
414
415 unsigned int displacement_vars[3];
416 displacement_vars[0] = system.variable_number ("u");
417 if (dim > 1)
418 displacement_vars[1] = system.variable_number ("v");
419 if (dim > 2)
420 displacement_vars[2] = system.variable_number ("w");
421 const unsigned int u_var = system.variable_number ("u");
422
423 const DofMap & dof_map = system.get_dof_map();
424 FEType fe_type = dof_map.variable_type(u_var);
425 std::unique_ptr<FEBase> fe (FEBase::build(dim, fe_type));
426 QGauss qrule (dim, fe_type.default_quadrature_order());
427 fe->attach_quadrature_rule (&qrule);
428
429 const std::vector<Real> & JxW = fe->get_JxW();
430 const std::vector<std::vector<RealGradient>> & dphi = fe->get_dphi();
431
432 // Also, get a reference to the ExplicitSystem
433 ExplicitSystem & stress_system = es.get_system<ExplicitSystem>("StressSystem");
434 const DofMap & stress_dof_map = stress_system.get_dof_map();
435 unsigned int sigma_vars[3][3];
436 sigma_vars[0][0] = stress_system.variable_number ("sigma_00");
437
438 if (dim > 1)
439 {
440 sigma_vars[0][1] = stress_system.variable_number ("sigma_01");
441 sigma_vars[1][0] = stress_system.variable_number ("sigma_10");
442 sigma_vars[1][1] = stress_system.variable_number ("sigma_11");
443 }
444
445 if (dim > 2)
446 {
447 sigma_vars[0][2] = stress_system.variable_number ("sigma_02");
448 sigma_vars[1][2] = stress_system.variable_number ("sigma_12");
449 sigma_vars[2][0] = stress_system.variable_number ("sigma_20");
450 sigma_vars[2][1] = stress_system.variable_number ("sigma_21");
451 sigma_vars[2][2] = stress_system.variable_number ("sigma_22");
452 }
453 unsigned int vonMises_var = stress_system.variable_number ("vonMises");
454
455 // Storage for the stress dof indices on each element
456 std::vector<std::vector<dof_id_type>> dof_indices_var(system.n_vars());
457 std::vector<dof_id_type> stress_dof_indices_var;
458
459 // To store the stress tensor on each element
460 DenseMatrix<Number> elem_sigma;
461
462 for (const auto & elem : mesh.active_local_element_ptr_range())
463 {
464 // We'll only be computing stresses on the primary manifold of a
465 // mesh, not, for instance, on spline nodes
466 if (elem->dim() != dim)
467 continue;
468
469 for (unsigned int var=0; var<dim; var++)
470 dof_map.dof_indices (elem, dof_indices_var[var], displacement_vars[var]);
471
472 fe->reinit (elem);
473
474 elem_sigma.resize(dim, dim);
475
476 for (unsigned int qp=0; qp<qrule.n_points(); qp++)
477 for (unsigned int C_i=0; C_i<dim; C_i++)
478 for (unsigned int C_j=0; C_j<dim; C_j++)
479 for (unsigned int C_k=0; C_k<dim; C_k++)
480 {
481 const unsigned int n_var_dofs = dof_indices_var[C_k].size();
482
483 // Get the gradient at this quadrature point
484 Gradient displacement_gradient;
485 for (unsigned int l=0; l<n_var_dofs; l++)
486 displacement_gradient.add_scaled(dphi[l][qp], system.current_solution(dof_indices_var[C_k][l]));
487
488 for (unsigned int C_l=0; C_l<dim; C_l++)
489 elem_sigma(C_i,C_j) += JxW[qp] * (elasticity_tensor(C_i, C_j, C_k, C_l) * displacement_gradient(C_l));
490 }
491
492 // Get the average stresses by dividing by the element volume
493 elem_sigma.scale(1./elem->volume());
494
495 // load elem_sigma data into stress_system
496 for (unsigned int i=0; i<dim; i++)
497 for (unsigned int j=0; j<dim; j++)
498 {
499 stress_dof_map.dof_indices (elem, stress_dof_indices_var, sigma_vars[i][j]);
500
501 // We are using CONSTANT MONOMIAL basis functions, hence we only need to get
502 // one dof index per variable
503 dof_id_type dof_index = stress_dof_indices_var[0];
504
505 if ((stress_system.solution->first_local_index() <= dof_index) &&
506 (dof_index < stress_system.solution->last_local_index()))
507 {
508 stress_system.solution->set(dof_index, elem_sigma(i,j));
509 }
510
511 }
512
513 // Also, the von Mises stress
514
515 // We're solving with general plane stress if in 2D, or with
516 // uniaxial stress if in 1D
517 Number sigma00 = elem_sigma(0,0);
518 Number sigma11 = (dim > 1) ? elem_sigma(1,1) : 0;
519 Number sigma22 = (dim > 2) ? elem_sigma(2,2) : 0;
520 Number sum_term = pow(sigma00 - sigma11,2);
521 if (dim > 1)
522 sum_term += pow(sigma11 - sigma22,2) +
523 6.*pow(elem_sigma(0,1),2);
524 if (dim > 2)
525 sum_term += pow(sigma22 - sigma00,2) +
526 6.*(pow(elem_sigma(1,2),2) + pow(elem_sigma(2,0),2));
527 Number vonMises_value = std::sqrt(0.5*sum_term);
528 stress_dof_map.dof_indices (elem, stress_dof_indices_var, vonMises_var);
529 dof_id_type dof_index = stress_dof_indices_var[0];
530 if ((stress_system.solution->first_local_index() <= dof_index) &&
531 (dof_index < stress_system.solution->last_local_index()))
532 {
533 stress_system.solution->set(dof_index, vonMises_value);
534 }
535
536 }
537
538 // Should call close and update when we set vector entries directly
539 stress_system.solution->close();
540 stress_system.update();
541}
542
543#endif // LIBMESH_ENABLE_DIRICHLET
unsigned int dim
void min(const T &r, T &o, Request &req) const
bool has_boundary_id(const Node *const node, const boundary_id_type id) 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.
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.
Defines a dense matrix for use in Finite Element-type computations.
void resize(const unsigned int new_m, const unsigned int new_n)
Resizes the matrix to the specified size and calls zero().
void scale(const T factor)
Multiplies every element in the matrix by factor.
This class handles the numbering of degrees of freedom on a mesh.
Definition dof_map.h:181
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
Definition dof_map.C:2201
const FEType & variable_type(const unsigned int i) const
Definition dof_map.h:2388
Helper for building element sides that minimizes the construction of new elements.
This is the EquationSystems class.
void print_info(std::ostream &os=libMesh::out) const
Prints information about the equation systems, by default to libMesh::out.
const MeshBase & get_mesh() const
virtual void init()
Initialize all the systems.
virtual System & add_system(std::string_view system_type, std::string_view name)
Add the system of type system_type named name to the systems array.
const T_sys & get_system(std::string_view name) const
The ExodusII_IO class implements reading meshes in the ExodusII file format from Sandia National Labs...
Definition exodusII_io.h:53
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.
static std::unique_ptr< FEGenericBase > build(const unsigned int dim, const FEType &type)
Builds a specific finite element type.
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
Definition fe_type.h:197
Order default_quadrature_order() const
Definition fe_type.h:415
The LibMeshInit class, when constructed, initializes the dependent libraries (e.g.
Definition libmesh.h:92
virtual LinearSolver< Number > * get_linear_solver() const override
void set_solver_type(const SolverType st)
Sets the type of solver to use.
This is the MeshBase class.
Definition mesh_base.h:81
virtual bool is_serial() const
Definition mesh_base.h:357
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
Definition mesh_base.h:170
unsigned int mesh_dimension() const
Definition mesh_base.C:430
virtual void read(const std::string &name, void *mesh_data=nullptr, bool skip_renumber_nodes_and_elements=false, bool skip_find_neighbors=false, bool skip_detect_interior_parents=false)=0
Interfaces for reading/writing a mesh to/from a file.
constraint_rows_type & get_constraint_rows()
Constraint rows accessors.
Definition mesh_base.h:1935
void print_info(std::ostream &os=libMesh::out, const unsigned int verbosity=0, const bool global=true) const
Prints relevant information about the mesh.
Definition mesh_base.C:1755
virtual void write_equation_systems(const std::string &, const EquationSystems &, const std::set< std::string > *system_names=nullptr)
This method implements writing a mesh with data to a specified file where the data is taken from the ...
Definition mesh_output.C:31
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
Definition mesh.h:51
The Nemesis_IO class implements reading parallel meshes in the Nemesis file format from Sandia Nation...
Definition nemesis_io.h:54
const Parallel::Communicator & comm() const
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition point.h:40
unsigned int n_points() const
Definition quadrature.h:131
This class implements specific orders of Gauss quadrature.
void set_rb_evaluation(RBEvaluation &rb_eval_in)
Set the RBEvaluation object.
virtual void print_info() const
Print out info that describes the current setup of this RBConstruction.
RBEvaluation & get_rb_evaluation()
Get a reference to the RBEvaluation object.
virtual void initialize_rb_construction(bool skip_matrix_assembly=false, bool skip_vector_assembly=false)
Allocate all the data structures necessary for the construction stage of the RB method.
virtual Real train_reduced_basis(const bool resize_rb_eval_data=true)
Train the reduced basis.
virtual void load_rb_solution()
Load the RB solution from the most recent solve with rb_eval into this system's solution vector.
virtual void process_parameters_file(const std::string &parameters_filename)
Read in from the file specified by parameters_filename and set the this system's member variables acc...
This class de-serializes an RBEvaluation object using the Cap'n Proto library.
void read_from_file(const std::string &path, bool read_error_bound_data, bool use_packing=false)
Read the Cap'n'Proto buffer from disk.
This class serializes an RBEvaluation object using the Cap'n Proto library.
void write_to_file(const std::string &path, bool use_packing=false)
Write the Cap'n'Proto buffer to disk.
virtual void legacy_write_offline_data_to_files(const std::string &directory_name="offline_data", const bool write_binary_data=true)
Write out all the data to text files in order to segregate the Offline stage from the Online stage.
virtual Real rb_solve(unsigned int N)
Perform online solve with the N RB basis functions, for the set of parameters in current_params,...
virtual unsigned int get_n_basis_functions() const
Get the current number of basis functions.
virtual void write_out_basis_functions(System &sys, const std::string &directory_name="offline_data", const bool write_binary_basis_functions=true)
Write out all the basis functions to file.
virtual void read_in_basis_functions(System &sys, const std::string &directory_name="offline_data", const bool read_binary_basis_functions=true)
Read in all the basis functions from file.
virtual void legacy_read_offline_data_from_files(const std::string &directory_name="offline_data", bool read_error_bound_data=true, const bool read_binary_data=true)
Read in the saved Offline reduced basis data to initialize the system for Online solves.
This class is part of the rbOOmit framework.
Real get_value(const std::string &param_name) const
Get the value of the specified parameter, throw an error if it does not exist.
void set_value(const std::string &param_name, Real value)
Set the value of the specified parameter.
const RBParameters & get_parameters() const
Get the current parameters.
bool set_parameters(const RBParameters &params)
Set the current parameters to params The parameters are checked for validity; an error is thrown if t...
void print_parameters() const
Print the current parameters.
Number current_solution(const dof_id_type global_dof_number) const
Definition system.C:162
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.
Definition system.C:1344
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition system.h:1655
virtual void update()
Update the local values to reflect the solution on neighboring processors.
Definition system.C:498
unsigned int variable_number(std::string_view var) const
Definition system.C:1398
unsigned int n_vars() const
Definition system.C:2674
const DofMap & get_dof_map() const
Definition system.h:2417
void add_scaled(const TypeVector< T2 > &, const T &)
Add a scaled value to this vector without creating a temporary.
This class defines a vector in LIBMESH_DIM dimensional Real or Complex space.
MeshBase & mesh
void build_cube(UnstructuredMesh &mesh, const unsigned int nx=0, const unsigned int ny=0, const unsigned int nz=0, const Real xmin=0., const Real xmax=1., const Real ymin=0., const Real ymax=1., const Real zmin=0., const Real zmax=1., const ElemType type=INVALID_ELEM, const bool gauss_lobatto_grid=false)
Builds a (elements) cube.
The libMesh namespace provides an interface to certain functionality in the library.
void libmesh_ignore(const Args &...)
SolverPackage default_solver_package()
Definition libmesh.C:1064
T command_line_next(std::string name, T default_value)
Use GetPot's search()/next() functions to get following arguments from the command line.
Definition libmesh.C:1025
uint8_t dof_id_type
Definition id_types.h:67
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Real elasticity_tensor(unsigned int i, unsigned int j, unsigned int k, unsigned int l)
Definition assembly.C:43
void scale_mesh_and_plot(EquationSystems &es, const RBParameters &mu, const std::string &filename)
void compute_stresses(EquationSystems &es)
int main()