87{
88
90
91
93 "--enable-petsc, --enable-trilinos, or --enable-eigen");
94
95#if !defined(LIBMESH_HAVE_XDR)
96
97 libmesh_example_requires(false, "--enable-xdr");
98#elif defined(LIBMESH_DEFAULT_SINGLE_PRECISION)
99
100 libmesh_example_requires(false, "--disable-singleprecision");
101#elif defined(LIBMESH_DEFAULT_TRIPLE_PRECISION)
102
103 libmesh_example_requires(false, "double precision");
104#endif
105
106
107
109
110
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
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
134
136
137
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 {
147
148
149
150
151
152
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
158
159
160
161
163
164
165
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
172
173
174 if (side_center(2) < 0.1)
176 if (side_center(2) > 11.9)
178 }
179 }
180
181
182
183
184
185
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 {
193 {
194 side_max_x = side;
195 found_side_max_x = true;
196 }
197
199 {
200 side_max_y = side;
201 found_side_max_y = true;
202 }
203
205 {
206 side_max_z = side;
207 found_side_max_z = true;
208 }
209 }
210
211
212
213
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 {
223 }
224 }
225 }
226 }
227
229
231
232
234
235
236
239
240 unsigned int order = infile("order", 1);
241
243
244
248
249
259 {
264 }
266
267
268 equation_systems.init ();
269 equation_systems.print_info();
270
271
272
273
275
276
277
279
280 if (!online_mode)
281 {
282
283
285
286
288
289
291
292
293
294
296
297
298
299
301
302
303#if defined(LIBMESH_HAVE_CAPNPROTO)
305 rb_eval_writer.write_to_file("rb_eval.bin");
306#else
308#endif
309
310
311 if (store_basis_functions)
312 {
313
315 }
316 }
317 else
318 {
319
320#if defined(LIBMESH_HAVE_CAPNPROTO)
322 rb_eval_reader.read_from_file("rb_eval.bin", true);
323#else
324 rb_eval.legacy_read_offline_data_from_files();
325#endif
326
327
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.);
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
347 rb_eval.rb_solve(rb_eval.get_n_basis_functions());
348
349 if (store_basis_functions)
350 {
351
352 rb_eval.read_in_basis_functions(rb_con);
353
354
356
357 const RBParameters & rb_eval_params = rb_eval.get_parameters();
359 }
360 }
361
362#endif
363
364 return 0;
365}
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.
Helper for building element sides that minimizes the construction of new elements.
This is the EquationSystems class.
The LibMeshInit class, when constructed, initializes the dependent libraries (e.g.
virtual LinearSolver< Number > * get_linear_solver() const override
void set_solver_type(const SolverType st)
Sets the type of solver to use.
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
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.
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.
const Parallel::Communicator & comm() const
A Point defines a location in LIBMESH_DIM dimensional Real space.
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 ¶meters_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.
This class serializes an RBEvaluation object using the Cap'n Proto library.
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 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.
This class is part of the rbOOmit framework.
void set_value(const std::string ¶m_name, Real value)
Set the value of the specified parameter.
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 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.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void scale_mesh_and_plot(EquationSystems &es, const RBParameters &mu, const std::string &filename)