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" 100 #include "assembly.h" 108 const std::string & filename);
111 int 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();
248 rb_eval.get_rb_theta_expansion().attach_multiple_A_theta(eim_rb_eval.get_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,
276 rb_eim_eval_reader.read_from_file(
"rb_eim_eval.bin");
279 eim_rb_eval.initialize_eim_theta_objects();
280 rb_eval.get_rb_theta_expansion().attach_multiple_A_theta(eim_rb_eval.get_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);
293 rb_eval.set_parameters(online_mu);
294 rb_eval.print_parameters();
295 rb_eval.rb_solve(rb_eval.get_n_basis_functions());
302 equation_systems.
init ();
307 rb_eval.read_in_basis_functions(rb_construction,
"rb_data");
313 #endif // LIBMESH_ENABLE_DIRICHLET 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 344 #endif // LIBMESH_ENABLE_DIRICHLET T command_line_next(std::string name, T default_value)
Use GetPot's search()/next() functions to get following arguments from the command line...
This is the EquationSystems class.
The ReplicatedMesh class is derived from the MeshBase class, and is used to store identical copies of...
void initialize_eim_construction()
Perform initialization of this object to prepare for running train_eim_approximation().
This class serializes an RBEvaluation object using the Cap'n Proto library.
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 ...
The ExodusII_IO class implements reading meshes in the ExodusII file format from Sandia National Labs...
virtual Real train_eim_approximation()
Generate the EIM approximation for the specified parametrized function using either POD or the Greedy...
int main(int argc, char **argv)
void print_info(std::ostream &os=libMesh::out) const
Prints information about the equation systems, by default to libMesh::out.
virtual void process_parameters_file(const std::string ¶meters_filename)
Read parameters in from file and set up this system accordingly.
const Parallel::Communicator & comm() const
The LibMeshInit class, when constructed, initializes the dependent libraries (e.g.
The libMesh namespace provides an interface to certain functionality in the library.
This class serializes an RBEIMEvaluation object using the Cap'n Proto library.
This is the MeshBase class.
virtual void print_info()
Print out info that describes the current setup of this RBConstruction.
SolverPackage default_solver_package()
void libmesh_ignore(const Args &...)
void transform_mesh_and_plot(EquationSystems &es, Real curvature, const std::string &filename)
void print_info(std::ostream &os=libMesh::out, const unsigned int verbosity=0, const bool global=true) const
Prints relevant information about the mesh.
void init(triangulateio &t)
Initializes the fields of t to nullptr/0 as necessary.
void read_from_file(const std::string &path, bool read_error_bound_data)
Write the Cap'n'Proto buffer to disk.
This class is part of the rbOOmit framework.
void read_from_file(const std::string &path)
Write the Cap'n'Proto buffer to disk.
void write_to_file(const std::string &path)
Write the Cap'n'Proto buffer to disk.
void write_to_file(const std::string &path)
Write the Cap'n'Proto buffer to disk.
void set_rb_eim_evaluation(RBEIMEvaluation &rb_eim_eval_in)
Set the RBEIMEvaluation object.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual void initialize_eim_assembly_objects()
Build a vector of ElemAssembly objects that accesses the basis functions stored in this RBEIMConstruc...
std::vector< std::unique_ptr< ElemAssembly > > & get_eim_assembly_objects()
void set_value(const std::string ¶m_name, Real value)
Set the value of the specified parameter.
const MeshBase & get_mesh() const
This class de-serializes an RBEvaluation object using the Cap'n Proto library.
virtual void init()
Initialize all the systems.
virtual void load_rb_solution()
Load the RB solution from the most recent solve with rb_eval into this system's solution vector...
void set_rb_evaluation(RBEvaluation &rb_eval_in)
Set the RBEvaluation object.
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.
This class de-serializes a RBEIMEvaluation object using the Cap'n Proto library.