85#include "libmesh/libmesh.h"
86#include "libmesh/mesh.h"
87#include "libmesh/mesh_generation.h"
88#include "libmesh/exodusII_io.h"
89#include "libmesh/equation_systems.h"
90#include "libmesh/dof_map.h"
91#include "libmesh/getpot.h"
92#include "libmesh/elem.h"
93#include "libmesh/rb_data_serialization.h"
94#include "libmesh/rb_data_deserialization.h"
95#include "libmesh/enum_solver_package.h"
98#include "rb_classes.h"
99#include "eim_classes.h"
108 const std::string & filename);
111int main (
int argc,
char ** argv)
118 "--enable-petsc, --enable-trilinos, or --enable-eigen");
120#if !defined(LIBMESH_HAVE_XDR)
122 libmesh_example_requires(
false,
"--enable-xdr");
123#elif defined(LIBMESH_DEFAULT_SINGLE_PRECISION)
125 libmesh_example_requires(
false,
"--disable-singleprecision");
126#elif defined(LIBMESH_DEFAULT_TRIPLE_PRECISION)
128 libmesh_example_requires(
false,
"double precision");
129#elif defined(LIBMESH_ENABLE_BLOCKED_STORAGE)
132 libmesh_example_requires(
false,
"--disable-blocked-storage");
136 libmesh_example_requires(3 == LIBMESH_DIM,
"3D support");
140#if !defined(LIBMESH_ENABLE_DIRICHLET) || !defined(LIBMESH_HAVE_CAPNPROTO)
141 libmesh_example_requires(
false,
"--enable-dirichlet --enable-capnp");
145 std::string eim_parameters =
"eim.in";
146 std::string rb_parameters =
"rb.in";
147 std::string main_parameters =
"reduced_basis_ex6.in";
148 GetPot infile(main_parameters);
150 unsigned int n_elem_xy = infile(
"n_elem_xy", 1);
151 unsigned int n_elem_z = infile(
"n_elem_z", 1);
154 const int online_mode =
164 n_elem_xy, n_elem_xy, n_elem_z,
174 libMesh::out <<
"Perform EIM training" << std::endl << std::endl;
184 equation_systems.
init ();
208 eim_rb_eval.write_out_basis_functions(
"eim_data",
false);
212 libMesh::out << std::endl <<
"Perform RB training" << std::endl << std::endl;
223 equation_systems.
init ();
237 rb_construction.set_rb_evaluation(rb_eval);
241 eim_rb_eval.read_in_basis_functions(rb_construction,
"eim_data",
false);
244 rb_construction.process_parameters_file(rb_parameters);
247 eim_rb_eval.initialize_eim_theta_objects();
252 rb_construction.get_rb_assembly_expansion().attach_multiple_A_assembly(eim_construction.
get_eim_assembly_objects());
255 rb_construction.print_info();
259 rb_construction.initialize_rb_construction();
260 rb_construction.train_reduced_basis();
266 rb_construction.get_rb_evaluation().write_out_basis_functions(rb_construction,
279 eim_rb_eval.initialize_eim_theta_objects();
286 Real online_curvature = infile(
"online_curvature", 0.);
287 Real online_Bi = infile(
"online_Bi", 0.);
288 Real online_kappa = infile(
"online_kappa", 0.);
290 online_mu.
set_value(
"curvature", online_curvature);
292 online_mu.
set_value(
"kappa", online_kappa);
302 equation_systems.
init ();
318#ifdef LIBMESH_ENABLE_DIRICHLET
322 const std::string & filename)
327 for (
auto & node :
mesh.node_ptr_range())
332 (*node)(0) = -1./curvature + (1./curvature + x)*cos(curvature*z);
333 (*node)(2) = (1./curvature + x)*sin(curvature*z);
336#ifdef LIBMESH_HAVE_EXODUS_API
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.
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.
This is the MeshBase class.
void print_info(std::ostream &os=libMesh::out, const unsigned int verbosity=0, const bool global=true) const
Prints relevant information about the mesh.
const Parallel::Communicator & comm() const
void set_rb_evaluation(RBEvaluation &rb_eval_in)
Set the RBEvaluation object.
virtual void load_rb_solution()
Load the RB solution from the most recent solve with rb_eval into this system's solution vector.
This class de-serializes a RBEIMEvaluation object using the Cap'n Proto library.
void read_from_file(const std::string &path, bool use_packing=false)
Read the Cap'n'Proto buffer from disk.
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 RBEIMEvaluation 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.
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.
void initialize_eim_construction()
Perform initialization of this object to prepare for running train_eim_approximation().
std::vector< std::unique_ptr< ElemAssembly > > & get_eim_assembly_objects()
virtual void initialize_eim_assembly_objects()
Build a vector of ElemAssembly objects that accesses the basis functions stored in this RBEIMConstruc...
void set_rb_eim_evaluation(RBEIMEvaluation &rb_eim_eval_in)
Set the RBEIMEvaluation object.
virtual Real train_eim_approximation()
Generate the EIM approximation for the specified parametrized function using either POD or the Greedy...
virtual void print_info()
Print out info that describes the current setup of this RBConstruction.
virtual void process_parameters_file(const std::string ¶meters_filename)
Read parameters in from file and set up this system accordingly.
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.
RBThetaExpansion & get_rb_theta_expansion()
Get a reference to the rb_theta_expansion.
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.
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.
bool set_parameters(const RBParameters ¶ms)
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.
virtual void attach_multiple_A_theta(std::vector< std::unique_ptr< RBTheta > > &theta_q_a)
Attach a vector of pointers to functor objects that each define one of the theta_q_a terms.
The ReplicatedMesh class is derived from the MeshBase class, and is used to store identical copies of...
The libMesh namespace provides an interface to certain functionality in the library.
void libmesh_ignore(const Args &...)
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 transform_mesh_and_plot(EquationSystems &es, Real curvature, const std::string &filename)