AMROC Main     Blockstructured Adaptive Mesh Refinement in object-oriented C++


Main Page   Class Hierarchy   Compound List   File List  

amrsds.h

Go to the documentation of this file.
00001 #ifndef __AMRSDS_H_
00002 #define __AMRSDS_H_
00003 
00010 /*-----------------------------
00011 CPROTO's for people stuck with K&R compilers (ie. Sun's)
00012 ------------------------------*/
00013 #ifndef ANSI
00014 #if defined(__STDC__) ||defined(__cplusplus)||defined(_LANGUAGE_C_PLUS_PLUS)
00015 #define ANSI
00016 #endif
00017 #endif
00018 
00019 #ifdef ANSI
00020 #define CPROTO(x) x
00021 #else
00022 #define CPROTO(x) ()
00023 #endif
00024 
00025 #include <hdf.h>
00026 extern int AmrDebug; /* set this flag to 1 to get verbose error messages */
00027 
00028 /*@@
00029   @header amrsds.h
00030   @date Wed Feb 28 20:30:57 1996 @author John Shalf
00031   @version 0.9a
00032 @@*/
00033 
00034 
00035 /*========================================================================
00036 Explanation of Parameters
00037 
00038 Taxonomy
00039 The AMR heirarchy resembles a tree.  The root of the tree is level 0
00040 and the lower levels are numbered consecutively.  The nodes of this
00041 tree are "grids".  A "grid" is a rectilinear array of data at a
00042 particular AMR level.  At a particular level there can be multiple
00043 "steps" of the level as it evolves.  The grid can be of a different
00044 size and location on every timestep.
00045 
00046 AMR Parameters  (the same names are used for all function calls)
00047 level:  The level in the amr heirarchy, starting from 0.
00048 gridID: At a particular level, there can be multiple grids.
00049         This is an integer (starting from 0) that differentiates
00050         grids at the same level.  There is no other implied meaning
00051         for this number.
00052 step:   This is the current integer step for a particular 
00053         level.  It need not be associated with time so that the
00054         AMR file can store more than one component as successive
00055         steps in the same graph if they share the same tree structure.
00056 
00057 rank:   As with regular HDF, this is the number of dimensions of 
00058         the data
00059 
00060 dims:   An n-element array of the dimensions of the data where
00061         n=the rank of the data.
00062 
00063 origin: An n-element array locating the origin of the current
00064         grid with respect to the origin of the toplevel grid
00065         (n = rank of the data at top level).  The resolution
00066         of the coordinates is with respect to the current level
00067         is with respect to the toplevel.  ie. A 1D grid that is
00068         offset by 2 top-level grid points with respect to
00069         the toplevel origin, and has a refinement factor of 5
00070         has its origin[0]=10.
00071 
00072 resolution: This is the integer refinement factor by which the 
00073        current level grid has been refined with respect to the 
00074        toplevel grid (ie. a refinement factor of 3 means  
00075        3 grid points at this level fit in the space of one grid point 
00076        at the toplevel.  It is an (n+1) element array where n=rank 
00077        of the toplevel grid.  So each dimension can be of a different
00078        refinement factor.  The last element is the refinement
00079        factor for time with respect to the toplevel.
00080 
00081 realTime: Since this may not be derivable from any combination of
00082         the time resolution and level/gridID/step, then we'd best
00083         store this explicitly.  Since it is a floating point number,
00084         it can't be relied upon for searching or seeking through
00085         the heirarchy, but it does provide useful information
00086         once the grid is found.
00087 ====================================================================*/
00088 
00089 
00090 /*------------------------------------------------------
00091 Name: AMRwriteData
00092 Purpose: Works just like DFSDadddata(), except it includes
00093          all of the AMR attributes as well.
00094 returns: 0 on success
00095          -1 on failure
00096 -------------------------------------------------------*/
00097 int AMRwriteData CPROTO((char *filename,
00098                          char *dataname,
00099                          int32 proc,
00100                          int32 level,
00101                          int32 gridID,
00102                          int32 step,
00103                          float64 realTime,
00104                          int32 rank,
00105                          int32 *dims,
00106                          int32 *origin,
00107                          int32 *resolution,
00108                          void *data));
00109 
00110 /*------------------------------------------------------
00111 Name: AMRreadAttribs
00112 Purpose: Analogous to DFSDgetdims() but gets amr attribs
00113          as well.  Can be used to step through an AMR/HDF file
00114 returns: 0 on success
00115          -1 on failure
00116 -------------------------------------------------------*/
00117 int AMRreadAttribs CPROTO((char *filename,
00118                            char *dataname,
00119                            int32 *proc,
00120                            int32 *level,
00121                            int32 *gridID,
00122                            int32 *step,
00123                            float64 *realtime,
00124                            int32 *rank,
00125                            int32 *dims,
00126                            int32 *origin,
00127                            int32 *resolution));
00128 /*---------------------------------------------------------
00129 Name: AMRgetNumAttribs
00130 --------------------------------------------------------*/
00131 int AMRgetNumAttribs CPROTO((char *filename));
00132 
00133 /*------------------------------------------------------
00134 Name: AMRreadData
00135 Purpose: Identical in function to DFSDgetdata() or
00136          SDread() or SDSreadData()
00137 returns: 0 on success
00138          -1 on failure
00139 -------------------------------------------------------*/
00140 int AMRreadData CPROTO((char *filename,
00141                       int32 rank,
00142                       int32 *dims,
00143                       void *data));
00144 
00145 /*------------------------------------------------------
00146 Name: AMRseek
00147 Purpose: A generally inefficient seek function for
00148          AMR-SDS files.  It searches linearly through
00149          the file (hence the inefficiency) to find
00150          an SDS of the specified level,gridID, and
00151          step.  You can use AMR_ANYVAL as a wildcard
00152          for any of the level, grid & step.
00153 returns: 0 on success
00154          -1 on failure
00155 Note: This can be made more efficient in the future
00156       by building a table of all grids & their associated
00157       attributes and SDS ref-numbers in memory.  Then 
00158       the SDSseek() can go directly to the proper SDS instead
00159       of searching linearly through the file.
00160 -------------------------------------------------------*/
00161 int AMRseek CPROTO((char *filename,
00162                     int32 level,
00163                     int32 gridID,
00164                     int32 step));
00165 
00166 int AMRseekTime CPROTO((char *filename,
00167                         float64 realtime,
00168                         char *matchtype));
00169 
00170 /* Interpolates a rectilinear dataset of a specified resolution
00171    out of the heirarchial data */
00172 int AMRgetRegion CPROTO((char *filename,
00173                          int32 level,/* get at level of detail of this level */
00174                          int32 step, /* get at this step at specified level */
00175                          int32 rank,
00176                          int32 *dims,
00177                          int32 *lb,
00178                          int32 *ub,
00179                          void *data));
00180 
00181 /* returns TRUE if the source & destination regions overlap */
00182 int RegionOverlap CPROTO((int *rank,
00183                          int32 *sourceDims,
00184                          int32 *sourceOrigin,
00185                          int32 *sourceResolution,
00186                          int32 *destDims, 
00187                          int32 *destOrigin,
00188                          int32 *destResolution));
00189 
00190 /* 
00191    type definition for 
00192    function interpolates source 
00193    grid into destination grid 
00194 */
00195 typedef void (*AMRinterpolator) CPROTO((int32 *rank,/*pointer for f77 compat */
00196                                         int32 *sourceDims,
00197                                         int32 *sourceOrigin,
00198                                         int32 *sourceResolution,
00199                                         void *sourcedata,
00200                                         int32 *destdims, 
00201                                         int32 *destOrigin,
00202                                         int32 *destResolution,
00203                                         void *destdata));
00204 
00205 /* Select an interpolation function.  Default=PatchReplace */
00206 void AMRsetInterpolator CPROTO((AMRinterpolator interp));
00207 
00208 /* 
00209    A Simple Patch-Replacement heirarchial interpolator
00210    It linearly interpolates data from the source Grid into
00211    the resolution of the destination grid and overwrites
00212    patches in the destination grid that it replaces.  A
00213    more sophisticated interpolator would make some attempt
00214    at flux normalization (ie. interpolate the source data
00215    into the destination grid so as to minimize mismatches)
00216 */
00217 void PatchReplace CPROTO((int32 *rank,/*pointer for f77 compat */
00218                           int32 *sourceDims,
00219                           int32 *sourceOrigin,
00220                           int32 *sourceResolution,
00221                           void *sourcedata,
00222                           int32 *destdims, 
00223                           int32 *destOrigin,
00224                           int32 *destResolution,
00225                           void *destdata));
00226 
00227 #define AMR_ANYVAL -1
00228 #endif /* __AMRSDS_H_ */


Quickstart     Users Guide     Programmers Reference     Installation      Examples     Download



AMROC Main      Home      Contact
last update: 06/01/04