79{
80
82
83
84#if !defined(LIBMESH_HAVE_SLEPC) || !defined(LIBMESH_HAVE_GLPK)
85 libmesh_example_requires(false, "--enable-slepc --enable-glpk");
86#else
87
88#if !defined(LIBMESH_HAVE_XDR)
89
90 libmesh_example_requires(false, "--enable-xdr");
91#elif defined(LIBMESH_DEFAULT_SINGLE_PRECISION)
92
93 libmesh_example_requires(false, "--disable-singleprecision");
94#endif
95
97
98
99 libmesh_example_requires(
init.comm().size() == 1,
"mpirun -np 1");
100
101
102 libmesh_example_requires(2 <= LIBMESH_DIM, "2D support");
103
104#ifndef LIBMESH_ENABLE_DIRICHLET
105 libmesh_example_requires(false, "--enable-dirichlet");
106#else
107
108
109 std::string parameters_filename = "reduced_basis_ex2.in";
110 GetPot infile(parameters_filename);
111
112 unsigned int n_elem = infile(
"n_elem", 1);
113 const unsigned int dim = 2;
114
115 bool store_basis_functions = infile("store_basis_functions", true);
116
117
119
120
123 n_elem, n_elem,
124 0., 1.,
125 0., 1.,
127
128
130
131
132
135
136
140 rb_scm_con.add_variable(
"p",
FIRST);
141
142
143 equation_systems.init ();
144
145
146 equation_systems.print_info();
148
149
150 equation_systems.parameters.set<unsigned int>("eigenpairs") = 1;
151 equation_systems.parameters.set<unsigned int>("basis vectors") = 3;
152 equation_systems.parameters.set<unsigned int>
153 ("linear solver maximum iterations") = 1000;
154
155
156
157
159
160
161
163
164
166 rb_scm_eval.set_rb_theta_expansion(rb_eval.get_rb_theta_expansion());
167
168
169 rb_eval.rb_scm_eval = &rb_scm_eval;
170
171
172
173 rb_scm_con.set_rb_scm_evaluation(rb_scm_eval);
174
175 if (!online_mode)
176 {
177
179 rb_scm_con.process_parameters_file(parameters_filename);
180
181
183 rb_scm_con.print_info();
184
185
186
187
189
190
191
192 rb_scm_con.perform_SCM_greedy();
193
194
195
196
198
199
200#if defined(LIBMESH_HAVE_CAPNPROTO)
202 rb_eval_writer.write_to_file("rb_eval.bin");
204 rb_scm_eval_writer.write_to_file("rb_scm_eval.bin");
205#else
207 rb_scm_con.get_rb_scm_evaluation().legacy_write_offline_data_to_files("scm_data");
208#endif
209
210
211 if (store_basis_functions)
212 {
213
215 }
216 }
217 else
218 {
219
220
221#if defined(LIBMESH_HAVE_CAPNPROTO)
223 rb_eval_reader.read_from_file("rb_eval.bin", true);
225 rb_scm_eval_reader.read_from_file("rb_scm_eval.bin");
226#else
227 rb_eval.legacy_read_offline_data_from_files("rb_data");
228 rb_scm_eval.legacy_read_offline_data_from_files("scm_data");
229#endif
230
231
232 unsigned int online_N = infile("online_N", 1);
233 Real online_mu_0 = infile(
"online_mu_0", 0.);
234 Real online_mu_1 = infile(
"online_mu_1", 0.);
235 Real online_mu_2 = infile(
"online_mu_2", 0.);
237 online_mu.
set_value(
"mu_0", online_mu_0);
238 online_mu.
set_value(
"mu_1", online_mu_1);
239 online_mu.
set_value(
"mu_2", online_mu_2);
240 rb_eval.set_parameters(online_mu);
241 rb_eval.print_parameters();
242
243
244 rb_eval.rb_solve(online_N);
245
246
247 libMesh::out <<
"output 1, value = " << rb_eval.RB_outputs[0]
248 << ", bound = " << rb_eval.RB_output_error_bounds[0]
249 << std::endl;
250 libMesh::out <<
"output 2, value = " << rb_eval.RB_outputs[1]
251 << ", bound = " << rb_eval.RB_output_error_bounds[1]
252 << std::endl;
253 libMesh::out <<
"output 3, value = " << rb_eval.RB_outputs[2]
254 << ", bound = " << rb_eval.RB_output_error_bounds[2]
255 << std::endl;
256 libMesh::out <<
"output 4, value = " << rb_eval.RB_outputs[3]
257 << ", bound = " << rb_eval.RB_output_error_bounds[3]
258 << std::endl << std::endl;
259
260 if (store_basis_functions)
261 {
262
263 rb_eval.read_in_basis_functions(rb_con, "rb_data");
264
265
267#ifdef LIBMESH_HAVE_EXODUS_API
269#endif
270
271
272
274#ifdef LIBMESH_HAVE_EXODUS_API
276#endif
277 }
278 }
279
280#endif
281
282 return 0;
283
284#endif
285}
This is the EquationSystems class.
The ExodusII_IO class implements reading meshes in the ExodusII file format from Sandia National Labs...
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.
The LibMeshInit class, when constructed, initializes the dependent libraries (e.g.
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
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_basis_function(unsigned int i)
Load the i^th RB function into the RBConstruction solution vector.
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 de-serializes a RBSCMEvaluation object using the Cap'n Proto library.
This class serializes an RBEvaluation object using the Cap'n Proto library.
This class serializes an RBSCMEvaluation 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.
This class is part of the rbOOmit framework.
void set_RB_system_name(const std::string &new_name)
Set the name of the associated RB system — we need this to load the (symmetrized) affine operators.
This class is part of the rbOOmit framework.
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