HyPar  1.0
Finite-Difference Hyperbolic-Parabolic PDE Solver on Cartesian Grids
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
OutputROMSolution.cpp
Go to the documentation of this file.
1 #ifdef with_librom
2 
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <string.h>
11 #include <math.h>
12 #include <basic.h>
13 #include <common_cpp.h>
14 #include <arrayfunctions.h>
15 #include <io_cpp.h>
16 #include <plotfuncs_cpp.h>
17 #include <mpivars_cpp.h>
18 #include <simulation_object.h>
19 
20 /* Function declarations */
21 extern "C" void IncrementFilenameIndex(char*,int);
22 
24 int OutputROMSolution( void* s,
25  int nsims,
26  double a_time )
27 {
28  SimulationObject* simobj = (SimulationObject*) s;
29  int ns;
30 
31  for (ns = 0; ns < nsims; ns++) {
32 
33  HyPar* solver = &(simobj[ns].solver);
34  MPIVariables* mpi = &(simobj[ns].mpi);
35 
36  if ((!solver->WriteOutput) && (strcmp(solver->plot_solution,"yes"))) continue;
37 
38  char fname_root[_MAX_STRING_SIZE_];
39  strcpy(fname_root, solver->op_rom_fname_root);
40 
41  if (nsims > 1) {
42  char index[_MAX_STRING_SIZE_];
43  GetStringFromInteger(ns, index, (int)log10(nsims)+1);
44  strcat(fname_root, "_");
45  strcat(fname_root, index);
46  }
47 
48  WriteArray( solver->ndims,
49  solver->nvars,
50  solver->dim_global,
51  solver->dim_local,
52  solver->ghosts,
53  solver->x,
54  solver->u_rom_predicted,
55  solver,
56  mpi,
57  fname_root );
58 
59  if (!strcmp(solver->plot_solution, "yes")) {
60  PlotArray( solver->ndims,
61  solver->nvars,
62  solver->dim_global,
63  solver->dim_local,
64  solver->ghosts,
65  solver->x,
66  solver->u,
67  a_time,
68  solver,
69  mpi,
70  fname_root );
71  }
72 
73  /* increment the index string, if required */
74  if ((!strcmp(solver->output_mode,"serial")) && (!strcmp(solver->op_overwrite,"no"))) {
76  }
77 
78  }
79 
80  return 0;
81 }
82 
83 #endif
int * dim_global
Definition: hypar.h:33
double * u
Definition: hypar.h:116
Function declarations for file I/O functions.
void GetStringFromInteger(int, char *, int)
char plot_solution[_MAX_STRING_SIZE_]
Definition: hypar.h:194
int * dim_local
Definition: hypar.h:37
int OutputROMSolution(void *s, int nsims, double a_time)
int ghosts
Definition: hypar.h:52
char * filename_index
Definition: hypar.h:197
int WriteArray(int, int, int *, int *, int, double *, double *, void *, void *, char *)
Definition: WriteArray.c:27
#define _MAX_STRING_SIZE_
Definition: basic.h:14
char op_overwrite[_MAX_STRING_SIZE_]
Definition: hypar.h:191
char op_rom_fname_root[_MAX_STRING_SIZE_]
Definition: hypar.h:407
Simulation object.
int nvars
Definition: hypar.h:29
Some common functions used here and there (C++ declarations)
int PlotArray(int, int, int *, int *, int, double *, double *, double, void *, void *, char *)
Definition: PlotArray.c:31
Structure defining a simulation.
Some basic definitions and macros.
int ndims
Definition: hypar.h:26
Function declarations for plotting functions.
double * u_rom_predicted
Definition: hypar.h:403
Contains macros and function definitions for common array operations.
int index_length
Definition: hypar.h:199
Structure of MPI-related variables.
double * x
Definition: hypar.h:107
C++ declarations for MPI-related functions.
char output_mode[_MAX_STRING_SIZE_]
Definition: hypar.h:183
Structure containing all solver-specific variables and functions.
Definition: hypar.h:23
void IncrementFilenameIndex(char *f, int len)
int(* WriteOutput)(int, int, int *, double *, double *, char *, int *)
Definition: hypar.h:211