PLUTO  4.0
 All Data Structures Files Functions Variables Enumerations Macros Pages
Functions | Variables
input_data.c File Reference

Provide basic functionality for reading input data files. More...

#include "pluto.h"

Functions

void InputDataSet (char *grid_fname, int *get_var)
 
void InputDataRead (char *data_fname)
 
void InputDataInterpolate (double *vs, double x1, double x2, double x3)
 
void InputDataFree (void)
 

Variables

static int id_nvar
 
static int id_var_indx [256]
 
static int id_nx1
 
static int id_nx2
 
static int id_nx3
 
static int id_geom
 
static double * id_x1
 
static double * id_x2
 
static double * id_x3
 
static double *** Vin [256]
 

Detailed Description

Collects a number of functions for opening, reading and assigning initial conditions from user-supplied data file(s). The geometry and dimensions of the input grid can be different from the actual grid employed by PLUTO, as long as the coordinate geometry transformation has been implemented. The input grid and data files should employ the same format and conventions employed by PLUTO.

The InputDataSet() initialize the module and by assigning values to global variables such as size, geometry and dimensions of the input grid. Data values are read through the function InputDataRead() while InputDataInterpolate() can be finally used to map input data onto the grid employed by PLUTO using bi- or tri-linear interpolation to fill the data array at the desired coordinate location.

Authors
A. Mignone (migno.nosp@m.ne@p.nosp@m.h.uni.nosp@m.to.i.nosp@m.t)
P. Tzeferacos
Date
Aug 27, 2012

Function Documentation

void InputDataFree ( void  )

Free memory stored by user-supplied data.

void InputDataInterpolate ( double *  vs,
double  x1,
double  x2,
double  x3 
)

Perform bi- or tri-linear interpolation on external dataset to compute vs[] at the given point {x1,x2,x3}.

Parameters
[in]vsinterpolated value
[in]x1coordinate point at which at interpolates are desired
[in]x2coordinate point at which at interpolates are desired
[in]x3coordinate point at which at interpolates are desired
Returns
This function has no return value.

The function performs the following tasks.

  • Convert PLUTO coordinates to input grid geometry if necessary.
  • Make sure point (x1,x2,x3) does not fall outside input grid range. Limit to input grid edge otherwise.
  • Use table lookup by binary search to find the indices il, jl and kl such that grid points of PLUTO fall between [il, il+1], [jl, jl+1], [kl, kl+1].
  • Define normalized coordinates between [0,1]:
    • x[il+1] < x1[i] < x[il+1] ==> 0 < xx < 1
    • y[jl+1] < x2[j] < y[jl+1] ==> 0 < yy < 1
    • z[kl+1] < x3[k] < z[kl+1] ==> 0 < zz < 1
  • Perform bi- or tri-linear interpolation.
void InputDataRead ( char *  data_fname)

Read input data file and store the contents into the local storage array Vin. Memory allocation is also done here. The grid size and number of variables must have previously set by calling InputDataSet().

Parameters
[in]data_fnamethe data file name
Returns
This function has no return value.
void InputDataSet ( char *  grid_fname,
int *  get_var 
)

Initialize access to input data file by assigning values to grid-related information (geometry, number of points, etc...). This function should be called just once for input-data initialization.

Parameters
[in]gnamethe grid file name
[in]get_varan array of integers specifying which variables have to be read from the input data.
Returns
Thi function has no return value.

The following tasks are performed.

  • Scan grid data file and try to determine the grid geometry (id_geom). Search for tag "GEOMETRY:" and read the word that follows.
  • Move file pointer until the first line that does not begin with a "#".
  • Start reading number of points and grid coordinates. For the input x1 direction these are stored inside the module variables id_nx1 and id_x1.
  • Find out how many and which variables we have to read (:id_nvar and id_var_indx). Stop counting variables as soon as the first occurrence of "-1" in get_var is encountered

Variable Documentation

int id_geom
static

Geometry of the input grid.

int id_nvar
static

Number of variables to be read on input.

int id_nx1
static

Size of input grid in the x1 direction.

int id_nx2
static

Size of input grid in the x2 direction.

int id_nx3
static

Size of input grid in the x3 direction.

int id_var_indx[256]
static

The variable index.

double* id_x1
static

Array of point coordinates of the x1 input grid.

double* id_x2
static

Array of point coordinates of the x2 input grid.

double* id_x3
static

Array of point coordinates of the x3 input grid.

double*** Vin[256]
static

An array of 3D data values containing the initial data file variables.