HyPar
1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
|
Class implementing interface with libROM. More...
#include <librom_interface.h>
Public Member Functions | |
libROMInterface () | |
libROMInterface (void *a_s, int a_nsims, int a_rank, int a_nproc, double a_dt) | |
void | define (void *, int, int, int, double) |
~libROMInterface () | |
int | samplingFrequency () const |
const std::string & | mode () const |
const std::string & | componentMode () const |
const std::string & | type () const |
double | trainWallclockTime () const |
double | predictWallclockTime () const |
void | takeSample (void *a_s, const double a_t) |
void | projectInitialSolution (void *a_s) |
void | train () |
void | predict (void *a_s, const double a_t) const |
void | saveROM (const std::string &a_fname_root="") const |
void | loadROM (const std::string &a_fname_root="") |
void | copyFromHyPar (std::vector< CAROM::Vector *> &, void *) |
void | copyToHyPar (const CAROM::Vector &, void *, int) const |
void | copyToHyPar (const CAROM::Vector &, void *, int, int) const |
Protected Attributes | |
bool | m_is_defined |
int | m_rank |
int | m_nproc |
int | m_nsims |
std::vector< int > | m_vec_size |
int | m_rdim |
int | m_sampling_freq |
std::string | m_mode |
std::string | m_comp_mode |
std::string | m_rom_type |
std::vector< int > | m_ncomps |
std::vector< ROMObject * > | m_rom |
std::vector< CAROM::Vector * > | m_U |
struct timeval | m_train_start |
struct timeval | m_train_end |
struct timeval | m_predict_start |
struct timeval | m_predict_end |
double | m_train_wctime |
double | m_predict_wctime |
bool | m_save_ROM |
Class implementing interface with libROM.
Class implementing interface with libROM This class implements the interface between HyPar and libROM. For details on libROM, see: https://github.com/LLNL/libROM.
This class implements the interface between HyPar and libROM. For details on libROM, see: https://github.com/LLNL/libROM.
Definition at line 45 of file librom_interface.h.
|
inline |
|
inline |
Constructor
a_s | Array of simulation objects of type SimulationObject |
a_nsims | number of simulation objects |
a_rank | MPI rank of this process |
a_nproc | Number of MPI processes |
a_dt | Time step size |
Definition at line 70 of file librom_interface.h.
|
inline |
void define | ( | void * | a_s, |
int | a_nsims, | ||
int | a_rank, | ||
int | a_nproc, | ||
double | a_dt | ||
) |
Define the interface
Define the libROM interface
This function also reads libROM-related inputs from the file librom.inp. Rank 0 reads in the inputs and broadcasts them to all the processors.
The format of librom.inp is as follows:
begin <keyword> <value> ... <keyword> <value> end
where the list of keywords and their type that this function will read are:
Keyword name | Type | Variable | Default value --— |
---|---|---|---|
rdim | int | libROMInterface::m_rdim | -1 |
sampling_frequency | int | libROMInterface::m_sampling_freq | 1 |
mode | string | libROMInterface::m_mode | "train" |
component_mode | string | libROMInterface::m_comp_mode | "monolithic" |
type | string | libROMInterface::m_rom_type | "DMD" |
save_to_file | string | libROMInterface::m_save_ROM | "true" |
Note: other keywords in this file may be read by other functions. The default value for rdim is invalid, so it must be specified.
a_s | Array of simulation objects of type SimulationObject |
a_nsims | number of simulation objects |
a_rank | MPI rank of this process |
a_nproc | Number of MPI processes |
a_dt | Time step size |
Definition at line 40 of file libROMInterface.cpp.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
void takeSample | ( | void * | a_s, |
const double | a_t | ||
) |
Take a sample for training
a_s | Array of simulation objects of type SimulationObject |
a_t | Current simulation time |
Definition at line 196 of file libROMInterface.cpp.
void projectInitialSolution | ( | void * | a_s | ) |
Project initial solution for prediction
a_s | Array of simulation objects of type SimulationObject |
Definition at line 228 of file libROMInterface.cpp.
void train | ( | ) |
void predict | ( | void * | a_s, |
const double | a_t | ||
) | const |
Predict the solution at a given time
a_s | Array of simulation objects of type SimulationObject |
a_t | time at which to predict solution |
Definition at line 268 of file libROMInterface.cpp.
void saveROM | ( | const std::string & | a_fname_root = "" | ) | const |
Save ROM object to file
a_fname_root | filename root |
Definition at line 318 of file libROMInterface.cpp.
void loadROM | ( | const std::string & | a_fname_root = "" | ) |
load ROM object from file
a_fname_root | filename root |
Definition at line 367 of file libROMInterface.cpp.
void copyFromHyPar | ( | std::vector< CAROM::Vector *> & | a_U, |
void * | a_s | ||
) |
Copy HyPar solution to the work vectors m_U
Copy HyPar solution to the work vectors a_U. Note that the HyPar solution has ghost points but the work vectors a_U is a serialized vector of the solution without ghost points
a_U | work vector |
a_s | Array of simulation objects of type SimulationObject |
Definition at line 414 of file libROMInterface.cpp.
void copyToHyPar | ( | const CAROM::Vector & | a_vec, |
void * | a_s, | ||
int | a_idx | ||
) | const |
Copy a vector to HyPar
Copy a vector a_vec to HyPar solution. Note that the HyPar solution has ghost points but the vector a_vec is a serialized vector of the solution without ghost points.
Note: if libROMInterface::m_mode is "predict", then the vector will be copied into the main solution variable HyPar::u; otherwise it will be copied into the variable for ROM prediction HyPar::u_rom_predicted
a_vec | Work vector |
a_s | Array of simulation objects of type SimulationObject |
a_idx | Simulation object index |
Definition at line 475 of file libROMInterface.cpp.
void copyToHyPar | ( | const CAROM::Vector & | a_vec, |
void * | a_s, | ||
int | a_idx, | ||
int | a_var | ||
) | const |
Copy a vector to HyPar
Copy a vector a_vec to a component of the HyPar solution. Note that the HyPar solution has ghost points but the vector a_vec is a serialized vector of one of the solution components without ghost points.
Note: if libROMInterface::m_mode is "predict", then the vector will be copied into the main solution variable HyPar::u; otherwise it will be copied into the variable for ROM prediction HyPar::u_rom_predicted
a_vec | Work vector |
a_s | Array of simulation objects of type SimulationObject |
a_idx | Simulation object index |
a_var | Vector component to copy |
Definition at line 509 of file libROMInterface.cpp.
|
protected |
Boolean to show if this object is defined
Definition at line 133 of file librom_interface.h.
|
protected |
MPI rank
Definition at line 135 of file librom_interface.h.
|
protected |
Number of MPI ranks
Definition at line 136 of file librom_interface.h.
|
protected |
Number of simulations
Definition at line 137 of file librom_interface.h.
|
protected |
Solution vector size for each simulation
Definition at line 139 of file librom_interface.h.
|
protected |
Reduced model dimensionality
Definition at line 141 of file librom_interface.h.
|
protected |
Frequency at which to take samples
Definition at line 142 of file librom_interface.h.
|
protected |
Mode: none, train, predict
Definition at line 144 of file librom_interface.h.
|
protected |
Component mode: monolithic, component-wise
Definition at line 145 of file librom_interface.h.
|
protected |
Type of ROM (eg: DMD)
Definition at line 146 of file librom_interface.h.
|
protected |
Number of vector components for each simulation
Definition at line 148 of file librom_interface.h.
|
protected |
ROM objects
Definition at line 150 of file librom_interface.h.
|
protected |
Work vectors
Definition at line 151 of file librom_interface.h.
|
protected |
Definition at line 153 of file librom_interface.h.
|
protected |
Definition at line 154 of file librom_interface.h.
|
protected |
Definition at line 155 of file librom_interface.h.
|
protected |
Definition at line 156 of file librom_interface.h.
|
mutableprotected |
Wallclock time for training
Definition at line 157 of file librom_interface.h.
|
mutableprotected |
Wallclock time for prediction
Definition at line 158 of file librom_interface.h.
|
protected |
Save ROM objects to file (default: yes)
Definition at line 160 of file librom_interface.h.