PLUTO
set_output.c File Reference

Set/retrieve output data attributes. More...

#include "pluto.h"
Include dependency graph for set_output.c:

Go to the source code of this file.

Macros

#define VTK_VECTOR_DUMP   NO
 

Functions

void SetOutput (Data *d, Runtime *runtime)
 
int SetDumpVar (char *var_name, int out_type, int flag)
 
double *** GetUserVar (char *var_name)
 

Variables

static Outputall_outputs
 

Detailed Description

Set/retrieve output data attributes.

The function SetOutput() sets, for each output data type (DBL, FLT, VTK etc..) the default attributes of the corresponding Output structures. These include the variable name, a pointer to the actual 3D array, the centering of the variable (center/staggered), a conditional inclusion flag (telling if the corresponding variable has to be written in the specified format), and so on.

The function SetDumpVar() can be used to include or exclude a given variable to be written using a particular output format.

The function GetUserVar() returns the memory address to a user-defined 3D array.

Note
Starting with PLUTO 4.1 velocity and magnetic field components will be saved as scalars when writing VTK output. If this is not what you want and prefer to save them as vector fields (VTK VECTOR attribute), set VTK_VECTOR_DUMP to YES in your definitions.h.
Authors
A. Mignone (migno.nosp@m.ne@p.nosp@m.h.uni.nosp@m.to.i.nosp@m.t)
Date
Aug 24, 2015

Definition in file set_output.c.

Macro Definition Documentation

#define VTK_VECTOR_DUMP   NO

Definition at line 32 of file set_output.c.

Function Documentation

double*** GetUserVar ( char *  var_name)

return a pointer to the 3D array associated with the variable named 'var_name'.

Definition at line 251 of file set_output.c.

257 {
258  int indx = -1;
259 
260  while (strcmp(all_outputs->var_name[++indx], var_name)){
261  if (all_outputs->V[indx] == NULL){
262  print1 ("! Error: uservar '%s' is not allocated\n");
263  QUIT_PLUTO(1);
264  }
265  }
266  return (all_outputs->V[indx]);
267 }
double *** V[64]
pointer to arrays being written - same for all
Definition: structs.h:247
void print1(const char *fmt,...)
Definition: amrPluto.cpp:511
static Output * all_outputs
Definition: set_output.c:35
#define QUIT_PLUTO(e_code)
Definition: macros.h:125
char ** var_name
variable names - same for all
Definition: structs.h:242

Here is the call graph for this function:

Here is the caller graph for this function:

int SetDumpVar ( char *  var_name,
int  out_type,
int  flag 
)

Include ('flag == YES') or exclude ('flag == NO') the variable associated to 'var_name' in or from the output type 'out_type'. If 'out_type' corresponds to an image (ppm or png), create a correspdonding Image structure.

Parameters
[in]var_namethe name of the variable (e.g. "rho", "vx1",...)
[in]out_typeselect the output type (e.g., DBL_OUTPUT, VTK_OUTPUT, and so forth)
[in]flagan integer values (YES/NO).

Definition at line 211 of file set_output.c.

224 {
225  int k, nv;
226  Output *output;
227 
228  for (k = 0; k < MAX_OUTPUT_TYPES; k++){
229  output = all_outputs + k;
230  if (output->type == out_type) break;
231  }
232 
233  for (nv = output->nvar; nv--; ) {
234  if (strcmp(output->var_name[nv], var_name) == 0) {
235  output->dump_var[nv] = flag;
236  if (flag == YES){
237  if (out_type == PPM_OUTPUT || out_type == PNG_OUTPUT){
238  CreateImage (var_name);
239  }
240  }
241  return(0);
242  }
243  }
244 
245  print1 ("! var_name '%s' cannot be set/unset for writing\n",var_name);
246  return(1);
247 
248 }
#define PPM_OUTPUT
Definition: pluto.h:85
void print1(const char *fmt,...)
Definition: amrPluto.cpp:511
#define YES
Definition: pluto.h:25
int k
Definition: analysis.c:2
void CreateImage(char *)
Definition: set_image.c:8
int nvar
tot.
Definition: structs.h:234
static Output * all_outputs
Definition: set_output.c:35
#define MAX_OUTPUT_TYPES
Definition: pluto.h:95
int * dump_var
select vars being written - one per output
Definition: structs.h:240
int type
output format (DBL, FLT, ...) - one per output
Definition: structs.h:233
#define PNG_OUTPUT
Definition: pluto.h:86
char ** var_name
variable names - same for all
Definition: structs.h:242

Here is the call graph for this function:

Here is the caller graph for this function:

void SetOutput ( Data d,
Runtime runtime 
)

Set default attributes (variable names, pointers to data structures, filename extensions, etc...) of the output structures.

Parameters
[in]dpointer to Data structure
[in]runtimepointer to Runtime structure

Definition at line 37 of file set_output.c.

46 {
47  int nv, i, k;
48  Output *output;
49 
50  if (runtime->user_var > 0)
51  d->Vuser = ARRAY_4D(runtime->user_var, NX3_TOT, NX2_TOT, NX1_TOT, double);
52  else
53  d->Vuser = NULL;
54 
55  all_outputs = runtime->output;
56 
57 /* ---------------------------------------------
58  Loop on output types
59  --------------------------------------------- */
60 
61  for (k = 0; k < MAX_OUTPUT_TYPES; k++){
62  output = runtime->output + k;
63  output->var_name = ARRAY_2D(64,128,char);
64  output->stag_var = ARRAY_1D(64, int);
65  output->dump_var = ARRAY_1D(64, int);
66  strcpy(output->dir, runtime->output_dir); /* output directory is the same */
67  /* for all outputs (easy to change) */
68  output->nfile = -1;
69 
70  /* -- set variables names -- */
71 
72  SetDefaultVarNames(output);
73 
74  /* -- Set array pointers -- */
75 
76  for (nv = 0; nv < NVAR; nv++){
77  output->V[nv] = d->Vc[nv];
78  output->stag_var[nv] = -1; /* -- means cell centered -- */
79  }
80  nv = NVAR;
81  #ifdef STAGGERED_MHD
82  D_EXPAND(
83  output->var_name[nv] = "bx1s";
84  output->V[nv] = d->Vs[BX1s];
85  output->stag_var[nv++] = 0; ,
86 
87  output->var_name[nv] = "bx2s";
88  output->V[nv] = d->Vs[BX2s];
89  output->stag_var[nv++] = 1; ,
90 
91  output->var_name[nv] = "bx3s";
92  output->V[nv] = d->Vs[BX3s];
93  output->stag_var[nv++] = 2;
94  )
95  #endif
96 
97  #if UPDATE_VECTOR_POTENTIAL == YES
98  #if DIMENSIONS == 3
99  output->var_name[nv] = "Ax1";
100  output->V[nv] = d->Ax1;
101  output->stag_var[nv++] = -1; /* -- vector potential is
102  computed at cell center -- */
103 
104  output->var_name[nv] = "Ax2";
105  output->V[nv] = d->Ax2;
106  output->stag_var[nv++] = -1;
107  #endif
108  output->var_name[nv] = "Ax3";
109  output->V[nv] = d->Ax3;
110  output->stag_var[nv++] = -1;
111  #endif
112  output->nvar = nv;
113 
114  /* -- repeat for user defined vars -- */
115 
116  for (i = 0; i < runtime->user_var; i++){
117  sprintf (output->var_name[i + nv], "%s", runtime->user_var_name[i]);
118  output->V[i + nv] = d->Vuser[i];
119  output->stag_var[i + nv] = -1; /* -- assume cell-centered -- */
120  }
121 
122  /* -- add user vars to total number of variables -- */
123 
124  output->nvar += runtime->user_var;
125 
126  /* -- select which variables are going to be dumped to disk -- */
127 
128  for (nv = output->nvar; nv--; ) output->dump_var[nv] = YES;
129  #if ENTROPY_SWITCH
130  output->dump_var[ENTR] = NO;
131  #endif
132 
133  switch (output->type){
134  case DBL_OUTPUT: /* -- dump ALL variables -- */
135  sprintf (output->ext,"dbl");
136  break;
137  case FLT_OUTPUT: /* -- do not dump staggered fields (below)-- */
138  sprintf (output->ext,"flt");
139  break;
140  case DBL_H5_OUTPUT: /* -- dump ALL variables -- */
141  sprintf (output->ext,"dbl.h5");
142  break;
143  case FLT_H5_OUTPUT: /* -- do not dump staggered fields (below)-- */
144  sprintf (output->ext,"flt.h5");
145  break;
146  case VTK_OUTPUT: /* -- do not dump staggered fields (below) -- */
147  sprintf (output->ext,"vtk");
148  #if VTK_VECTOR_DUMP == YES
149  D_EXPAND(output->dump_var[VX1] = VTK_VECTOR; ,
150  output->dump_var[VX2] = NO; ,
151  output->dump_var[VX3] = NO;)
152  #if PHYSICS == MHD || PHYSICS == RMHD
153  D_EXPAND(output->dump_var[BX1] = VTK_VECTOR; ,
154  output->dump_var[BX2] = NO; ,
155  output->dump_var[BX3] = NO;)
156  #endif
157  #endif
158  break;
159  case TAB_OUTPUT: /* -- do not dump staggered fields -- */
160  sprintf (output->ext,"tab");
161  break;
162  case PPM_OUTPUT: /* -- dump density only -- */
163  sprintf (output->ext,"ppm");
164  for (nv = output->nvar; nv--; ) output->dump_var[nv] = NO;
165  break;
166  case PNG_OUTPUT: /* -- dump density only -- */
167  sprintf (output->ext,"png");
168  for (nv = output->nvar; nv--; ) output->dump_var[nv] = NO;
169  break;
170  }
171 
172  /* ---------------------------------------------------------------
173  for divergence cleaning never dump the scalar psi unless
174  the output type can be potentially used for restart
175  --------------------------------------------------------------- */
176 
177  #ifdef GLM_MHD
178  if (output->type == DBL_OUTPUT || output->type == DBL_H5_OUTPUT)
179  output->dump_var[PSI_GLM] = YES;
180  else
181  output->dump_var[PSI_GLM] = NO;
182  #endif
183  }
184 
185 /* -- exclude stag components from all output except .dbl -- */
186 
187  #ifdef STAGGERED_MHD
188  D_EXPAND( SetDumpVar ("bx1s", VTK_OUTPUT, NO); ,
189  SetDumpVar ("bx2s", VTK_OUTPUT, NO); ,
190  SetDumpVar ("bx3s", VTK_OUTPUT, NO);)
191  D_EXPAND( SetDumpVar ("bx1s", FLT_OUTPUT, NO); ,
192  SetDumpVar ("bx2s", FLT_OUTPUT, NO); ,
193  SetDumpVar ("bx3s", FLT_OUTPUT, NO);)
194  D_EXPAND( SetDumpVar ("bx1s", FLT_H5_OUTPUT, NO); ,
195  SetDumpVar ("bx2s", FLT_H5_OUTPUT, NO); ,
196  SetDumpVar ("bx3s", FLT_H5_OUTPUT, NO);)
197  D_EXPAND( SetDumpVar ("bx1s", TAB_OUTPUT, NO); ,
198  SetDumpVar ("bx2s", TAB_OUTPUT, NO); ,
199  SetDumpVar ("bx3s", TAB_OUTPUT, NO);)
200  #endif
201 
202 /* -- defaults: dump density only in ppm and png formats -- */
203 
204  SetDumpVar ("rho", PPM_OUTPUT, YES);
205  SetDumpVar ("rho", PNG_OUTPUT, YES);
206 
207  ChangeDumpVar();
208 }
int user_var
The number of additional user-variables being held in memory and written to disk. ...
Definition: structs.h:264
double **** Vs
The main four-index data array used for face-centered staggered magnetic fields.
Definition: structs.h:43
#define VX2
Definition: mod_defs.h:29
#define FLT_H5_OUTPUT
Definition: pluto.h:83
#define PPM_OUTPUT
Definition: pluto.h:85
double *** V[64]
pointer to arrays being written - same for all
Definition: structs.h:247
#define VTK_VECTOR
Definition: pluto.h:88
Output output[MAX_OUTPUT_TYPES]
Definition: structs.h:272
int nfile
current number being saved - one per output
Definition: structs.h:237
char output_dir[256]
The name of the output directory (output_dir for static PLUTO, Output_dir for PLUTO-Chombo) ...
Definition: structs.h:269
#define YES
Definition: pluto.h:25
void SetDefaultVarNames(Output *)
Definition: var_names.c:4
long int NX2_TOT
Total number of zones in the X2 direction (boundaries included) for the local processor.
Definition: globals.h:57
double **** Vc
The main four-index data array used for cell-centered primitive variables.
Definition: structs.h:31
char user_var_name[128][128]
Definition: structs.h:268
double *** Ax3
Vector potential component in the direction.
Definition: structs.h:53
#define PSI_GLM
Definition: mod_defs.h:34
char dir[256]
output directory name
Definition: structs.h:244
#define BX3s
Definition: ct.h:29
#define VX1
Definition: mod_defs.h:28
char ext[8]
output extension
Definition: structs.h:243
#define VTK_OUTPUT
Definition: pluto.h:81
#define DBL_H5_OUTPUT
Definition: pluto.h:82
long int NX3_TOT
Total number of zones in the X3 direction (boundaries included) for the local processor.
Definition: globals.h:59
#define ARRAY_4D(nx, ny, nz, nv, type)
Definition: prototypes.h:173
int k
Definition: analysis.c:2
int nvar
tot.
Definition: structs.h:234
static Output * all_outputs
Definition: set_output.c:35
#define BX1s
Definition: ct.h:27
#define MAX_OUTPUT_TYPES
Definition: pluto.h:95
int * dump_var
select vars being written - one per output
Definition: structs.h:240
#define TAB_OUTPUT
Definition: pluto.h:84
#define FLT_OUTPUT
Definition: pluto.h:80
#define BX3
Definition: mod_defs.h:27
#define ARRAY_1D(nx, type)
Definition: prototypes.h:170
D_EXPAND(tot/[n]=(double) grid[IDIR].np_int_glob;, tot/[n]=(double) grid[JDIR].np_int_glob;, tot/[n]=(double) grid[KDIR].np_int_glob;)
Definition: analysis.c:27
int i
Definition: analysis.c:2
#define DBL_OUTPUT
Definition: pluto.h:79
#define BX1
Definition: mod_defs.h:25
#define VX3
Definition: mod_defs.h:30
int type
output format (DBL, FLT, ...) - one per output
Definition: structs.h:233
int * stag_var
centered or staggered variable - same for all
Definition: structs.h:239
#define BX2s
Definition: ct.h:28
#define ARRAY_2D(nx, ny, type)
Definition: prototypes.h:171
#define BX2
Definition: mod_defs.h:26
double *** Ax1
Vector potential component in the direction.
Definition: structs.h:51
double **** Vuser
Array storing user-defined supplementary variables written to disk.
Definition: structs.h:49
void ChangeDumpVar()
#define NVAR
Definition: pluto.h:609
double *** Ax2
Vector potential component in the direction.
Definition: structs.h:52
#define PNG_OUTPUT
Definition: pluto.h:86
long int NX1_TOT
Total number of zones in the X1 direction (boundaries included) for the local processor.
Definition: globals.h:55
char ** var_name
variable names - same for all
Definition: structs.h:242
#define NO
Definition: pluto.h:26
int SetDumpVar(char *var_name, int out_type, int flag)
Definition: set_output.c:211

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

Output* all_outputs
static

Definition at line 35 of file set_output.c.