67 strcpy( save_c_str,
"false" );
77 strcpy( save_c_str,
"true" );
81 ferr = fscanf(in,
"%s", word);
if (ferr != 1)
return;
83 if (std::string(word) ==
"begin") {
84 while (std::string(word) !=
"end") {
85 ferr = fscanf(in,
"%s",word);
if (ferr != 1)
return;
86 if (std::string(word) ==
"rdim") {
87 ferr = fscanf(in,
"%d", &
m_rdim);
if (ferr != 1)
return;
88 }
else if (std::string(word) ==
"sampling_frequency") {
90 }
else if (std::string(word) ==
"mode") {
91 ferr = fscanf(in,
"%s", mode_c_str);
if (ferr != 1)
return;
92 }
else if (std::string(word) ==
"component_mode") {
93 ferr = fscanf(in,
"%s", comp_mode_c_str);
if (ferr != 1)
return;
94 }
else if (std::string(word) ==
"type") {
95 ferr = fscanf(in,
"%s", type_c_str);
if (ferr != 1)
return;
96 }
else if (std::string(word) ==
"save_to_file") {
97 ferr = fscanf(in,
"%s", save_c_str);
if (ferr != 1)
return;
99 if (ferr != 1)
return;
102 fprintf( stderr,
"Error: Illegal format in file \"%s\". Word read is: %s\n",
113 printf(
"libROMInterface inputs and parameters:\n");
114 printf(
" reduced model dimensionality: %d\n",
m_rdim);
116 printf(
" mode: %s\n", mode_c_str);
117 printf(
" component mode: %s\n", comp_mode_c_str);
118 printf(
" type: %s\n", type_c_str);
119 printf(
" save to file: %s\n", save_c_str);
124 MPI_Bcast(&
m_rdim,1,MPI_INT,0,MPI_COMM_WORLD);
132 m_mode = std::string( mode_c_str );
141 for (
int ns = 0; ns <
m_nsims; ns++) {
151 for (
int ns = 0; ns <
m_nsims; ns++) {
163 for (
int ns = 0; ns <
m_nsims; ns++) {
164 m_ncomps.push_back(sim[ns].solver.nvars);
201 printf(
"ERROR in libROMInterface::takeSample(): m_U.size != m_rom.size() on rank %d!!\n",
207 for (
int i = 0; i <
m_rom.size(); i++) {
208 m_rom[i]->takeSample( *(
m_U[i]), a_t );
218 MPI_Allreduce( MPI_IN_PLACE,
232 printf(
"ERROR in libROMInterface::projectInitialSolution(): m_U.size != m_rom.size() on rank %d!\n",
237 for (
int i = 0; i <
m_rom.size(); i++) {
238 m_rom[i]->projectInitialSolution( *(
m_U[i]) );
248 for (
int i = 0; i <
m_rom.size(); i++) {
258 MPI_Allreduce( MPI_IN_PLACE,
269 const double a_t )
const
275 for (
int ns = 0; ns <
m_nsims; ns++) {
277 const CAROM::Vector*
const u_predicted =
m_rom[ns]->predict(a_t);
290 for (
int ns = 0; ns <
m_nsims; ns++) {
291 for (
int v = 0; v <
m_ncomps[ns]; v++) {
293 const CAROM::Vector*
const u_predicted =
m_rom[count]->predict(a_t);
308 MPI_Allreduce( MPI_IN_PLACE,
323 printf(
"libROMInterface::saveROM() - saving ROM objects.\n");
328 for (
int ns = 0; ns <
m_nsims; ns++) {
329 std::string fname_root = a_fname_root;
332 sprintf(idx_string,
"sim%03d", ns);
333 fname_root += std::string(idx_string);
335 m_rom[ns]->save(fname_root);
341 for (
int ns = 0; ns <
m_nsims; ns++) {
342 for (
int v = 0; v <
m_ncomps[ns]; v++) {
343 std::string fname_root = a_fname_root;
346 sprintf(idx_string,
"sim%03d", ns);
347 fname_root += std::string(idx_string);
349 if (m_ncomps[ns] > 1) {
351 sprintf(idx_string,
"var%03d", v);
352 fname_root += std::string(idx_string);
354 m_rom[count]->save(fname_root);
370 printf(
"libROMInterface::loadROM() - loading ROM objects.\n");
375 for (
int ns = 0; ns <
m_nsims; ns++) {
376 std::string fname_root = a_fname_root;
379 sprintf(idx_string,
"sim%03d", ns);
380 fname_root += std::string(idx_string);
382 m_rom[ns]->load(fname_root);
388 for (
int ns = 0; ns <
m_nsims; ns++) {
389 for (
int v = 0; v <
m_ncomps[ns]; v++) {
390 std::string fname_root = a_fname_root;
393 sprintf(idx_string,
"sim%03d", ns);
394 fname_root += std::string(idx_string);
396 if (m_ncomps[ns] > 1) {
398 sprintf(idx_string,
"var%03d", v);
399 fname_root += std::string(idx_string);
401 m_rom[count]->load(fname_root);
422 for (
int ns = 0; ns <
m_nsims; ns++) {
423 double* vec = a_U[ns]->getData();
424 const double* u = sim[ns].
solver.
u;
426 std::vector<int> index(sim[ns].solver.ndims);
441 for (
int ns = 0; ns <
m_nsims; ns++) {
443 double* vec = a_U[count]->getData();
444 const double* u = sim[ns].
solver.
u;
446 std::vector<int> index(sim[ns].solver.ndims);
488 std::vector<int> index(sim[a_idx].solver.ndims);
523 std::vector<int> index(sim[a_idx].solver.ndims);
std::vector< int > m_ncomps
std::vector< int > m_vec_size
void projectInitialSolution(void *a_s)
void saveROM(const std::string &a_fname_root="") const
INLINE int ArrayCopynD(int, const double *, double *, int *, int, int, int *, int)
Dynamic Mode Decomposition ROM object.
#define _ROM_COMP_MODE_COMPONENTWISE_
std::vector< CAROM::Vector * > m_U
#define _LIBROM_INP_FNAME_
void loadROM(const std::string &a_fname_root="")
struct timeval m_train_end
#define _MAX_STRING_SIZE_
std::vector< ROMObject * > m_rom
void copyFromHyPar(std::vector< CAROM::Vector * > &, void *)
#define _ROM_COMP_MODE_MONOLITHIC_
void define(void *, int, int, int, double)
INLINE int ArrayCopynDComponent(int ndims, const double *x, double *y, int *dim, int g1, int g2, int *index, int nvars_from, int nvars_to, int var_from, int var_to)
struct timeval m_predict_end
void copyToHyPar(const CAROM::Vector &, void *, int) const
struct timeval m_train_start
void predict(void *a_s, const double a_t) const
struct timeval m_predict_start
void takeSample(void *a_s, const double a_t)
Structure defining a simulation.
Contains macros and function definitions for common array operations.
ROM object of type DMD (see libROM)