Commit 86ce4df5 authored by whitlocb's avatar whitlocb

Enhanced the AMR database reader.

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@23622 18c085ea-50e0-402c-830e-de6fd14e8384
parent 0e375eea
......@@ -16,14 +16,24 @@
<Files components="M">
avtAMRFileFormat.C
EOS.C
AMRreaderInterface.C
AMRreader.C
AMRreaderAgg.C
AMRreaderLowRes.C
AMRreaderBlkConso.C
AMRreaderLowResBlkConso.C
AMRreaderWithLevels.C
OctKey.C
</Files>
<Files components="E">
avtAMRFileFormat.C
EOS.C
AMRreaderInterface.C
AMRreader.C
AMRreaderAgg.C
AMRreaderLowRes.C
AMRreaderBlkConso.C
AMRreaderLowResBlkConso.C
AMRreaderWithLevels.C
OctKey.C
</Files>
<Attribute name="" purpose="" persistent="false" keyframe="true" exportAPI="" exportInclude="">
</Attribute>
......
/*****************************************************************************
*
* Copyright (c) 2000 - 2013, Lawrence Livermore National Security, LLC
* Copyright (c) 2000 - 2010, Lawrence Livermore National Security, LLC
* Produced at the Lawrence Livermore National Laboratory
* LLNL-CODE-442911
* LLNL-CODE-400124
* All rights reserved.
*
* This file is part of VisIt. For details, see https://visit.llnl.gov/. The
......
/*****************************************************************************
*
* Copyright (c) 2000 - 2013, Lawrence Livermore National Security, LLC
* Copyright (c) 2000 - 2010, Lawrence Livermore National Security, LLC
* Produced at the Lawrence Livermore National Laboratory
* LLNL-CODE-442911
* LLNL-CODE-400124
* All rights reserved.
*
* This file is part of VisIt. For details, see https://visit.llnl.gov/. The
......
/*****************************************************************************
*
* Copyright (c) 2000 - 2013, Lawrence Livermore National Security, LLC
* Copyright (c) 2000 - 2010, Lawrence Livermore National Security, LLC
* Produced at the Lawrence Livermore National Laboratory
* LLNL-CODE-442911
* LLNL-CODE-400124
* All rights reserved.
*
* This file is part of VisIt. For details, see https://visit.llnl.gov/. The
......
/*****************************************************************************
*
* Copyright (c) 2000 - 2013, Lawrence Livermore National Security, LLC
* Copyright (c) 2000 - 2010, Lawrence Livermore National Security, LLC
* Produced at the Lawrence Livermore National Laboratory
* LLNL-CODE-442911
* LLNL-CODE-400124
* All rights reserved.
*
* This file is part of VisIt. For details, see https://visit.llnl.gov/. The
......@@ -43,7 +43,7 @@
#include <AMRPluginInfo.h>
#include <visit-config.h>
VISIT_PLUGIN_VERSION(AMR,DBP_EXPORT)
extern "C" DBP_EXPORT const char *AMRVisItPluginVersion = VISIT_VERSION;
// ****************************************************************************
// Function: GetGeneralInfo
......
/*****************************************************************************
*
* Copyright (c) 2000 - 2013, Lawrence Livermore National Security, LLC
* Copyright (c) 2000 - 2010, Lawrence Livermore National Security, LLC
* Produced at the Lawrence Livermore National Laboratory
* LLNL-CODE-442911
* LLNL-CODE-400124
* All rights reserved.
*
* This file is part of VisIt. For details, see https://visit.llnl.gov/. The
......
This diff is collapsed.
......@@ -3,149 +3,160 @@
*/
#ifndef AMR_READER_H
#define AMR_READER_H
#include <math.h>
#include <AMRreaderInterface.h>
#include <EOS.h>
#include <hdf5.h>
#include <string>
#include <hdf5.h>
class AMRreader : public AMRreaderInterface
{
public:
AMRreader() : AMRreaderInterface()
{
init();
}
virtual ~AMRreader()
{
freedata();
init();
}
void init();
virtual int freedata();
virtual int getInfo( const char* filename );
virtual void BuildMetaData() { }
#include <EOS.h>
public:
virtual int GetNumCycles() const
{
return ncycle_;
}
virtual double GetSimuTime() const
{
return tttttt_;
}
virtual int GetNumberOfBlocks() const
{
return nblks_;
};
virtual int GetBlockDimensions( int bid, int* dim ) const
{
dim[0] = blkdim_[0];
dim[1] = blkdim_[1];
dim[2] = blkdim_[2];
return 0;
}
virtual int GetBlockDefaultDimensions(int *dim) const
{
dim[0] = blkdim_[0];
dim[1] = blkdim_[1];
dim[2] = blkdim_[2];
return 0;
}
virtual int GetBlockHierarchicalIndices(int bid, int *level,
int *ijk_start, int *ijk_end)
{
*level = 0;
// We could compute these off of the block key... later.
ijk_start[0] = ijk_start[1] = ijk_start[2] = 0;
ijk_end[0] = ijk_end[1] = ijk_end[2] = 0;
return 0;
}
virtual int GetNumberOfLevels()
{
return 1;
}
virtual int GetBlockSize( int bid ) const
{
return blksz_;
}
virtual int GetBlockMesh( int bid, float* xs, float* dx );
virtual int GetBlockVariable( int bid, int vid, float* dat );
virtual OctKey GetBlockKey(int bid);
virtual void GetInterfaceSizes( int* np, int* ne ) const
{
*np = nvert_;
*ne = nrect_;
}
virtual int GetInterfaceVariable( int vid, void* dat );
virtual bool HasTag() const
{
return blktag_==1;
}
class AMRreader
{
public:
AMRreader() { init(); }
~AMRreader() { freedata(); init(); }
void init();
int freedata();
int getInfo( const char* filename );
public:
int GetNumCycles() const { return ncycle_; }
double GetSimuTime() const { return tttttt_; }
int GetNumberOfBlocks() const { return nblks_; };
int GetBlockDimensions( int* dim ) const {
dim[0] = blkdim_[0];
dim[1] = blkdim_[1];
dim[2] = blkdim_[2];
return 0;
}
int GetBlockSize() const { return blksz_; }
int GetBlockMesh( int bid, float* xs, float* dx );
int GetBlockVariable( int bid, int vid, float* dat );
void GetInterfaceSizes( int* np, int* ne ) const {
*np = nvert_;
*ne = nrect_;
}
int GetInterfaceVariable( int vid, void* dat );
protected:
int getAMRinfo( hid_t gid );
int getIntfInfo( hid_t gid );
int readAMRmesh();
int readAMRdata();
int readAMRadditionData();
/* virtual int readblk( int bid ); */
protected:
int compvar( int vid, float* blk, float* buf, int sz );
int comp_dens( float*, float*, int sz );
int comp_uvel( float*, float*, int sz );
int comp_vvel( float*, float*, int sz );
int comp_wvel( float*, float*, int sz );
int comp_pres( float*, float*, int sz );
int comp_temp( float*, float*, int sz );
int comp_sndv( float*, float*, int sz );
int comp_xmnt( float*, float*, int sz );
int comp_ymnt( float*, float*, int sz );
int comp_zmnt( float*, float*, int sz );
int comp_etot( float*, float*, int sz );
int comp_eint( float*, float*, int sz );
int comp_eknt( float*, float*, int sz );
int comp_velo( float*, float*, int sz );
protected:
std::string filename_;
int ncycle_; // number of cycles
double tttttt_; // simulation time
int nblks_; // number of leaf blocks
int blkdim_[4]; // number of dimensions in each block
int blksz_;
float* blkxs_;
float* blkdx_;
float* datbuf_;
float* prebuf_;
float* sndbuf_;
float* tmpbuf_;
int nrect_, nvert_;
EOS* eos_;
protected:
int getAMRinfo( hid_t gid );
int getAMRtagInfo( hid_t gid );
int getIntfInfo( hid_t gid );
int readAMRmesh();
int readAMRdata();
int readAMRadditionData();
int readAMRtagData();
int PreprocessData();
public:
static const int v_dens = 0;
static const int v_uvel = 1;
static const int v_vvel = 2;
static const int v_wvel = 3;
static const int v_pres = 4;
static const int v_temp = 5;
static const int v_sndv = 6;
static const int v_xmnt = 7;
static const int v_ymnt = 8;
static const int v_zmnt = 9;
static const int v_etot =10;
static const int v_eint =11;
static const int v_eknt =12;
static const int v_velo =13;
static const int i_coor=20;
static const int i_velo=21;
static const int i_pres=22;
static const int i_segt=23;
/* static const int i_uvel=24; */
/* static const int i_vvel=25; */
/* static const int i_wvel=26; */
/* virtual int readblk( int bid ); */
protected:
int compvar( int vid, float* blk, float* buf, int sz );
int comp_dens( float*, float*, int sz );
int comp_uvel( float*, float*, int sz );
int comp_vvel( float*, float*, int sz );
int comp_wvel( float*, float*, int sz );
int comp_pres( float*, float*, int sz );
int comp_temp( float*, float*, int sz );
int comp_sndv( float*, float*, int sz );
int comp_xmnt( float*, float*, int sz );
int comp_ymnt( float*, float*, int sz );
int comp_zmnt( float*, float*, int sz );
int comp_etot( float*, float*, int sz );
int comp_eint( float*, float*, int sz );
int comp_eknt( float*, float*, int sz );
int comp_velo( float*, float*, int sz );
int comp_tags( float*, float*, int sz );
protected:
static const char* amr_grpname;
static const char* amr_dimname;
static const char* amr_time_name;
static const char* amr_iter_name;
static const char* amr_keyname;
static const char* amr_crdname;
static const char* amr_stpname;
static const char* amr_datname;
static const char* amr_prename;
static const char* amr_sndname;
static const char* amr_tmpname;
static const char* amr_idealname;
static const char* amr_jwlname;
static const char* amr_sesamename;
static const char* intf_grp_name;
static const char* intf_np_name;
static const char* intf_ne_name;
static const char* intf_coor_name;
static const char* intf_velo_name;
static const char* intf_pres_name;
static const char* intf_segt_name;
std::string filename_;
int ncycle_; // number of cycles
double tttttt_; // simulation time
int blktag_;
int nblks_; // number of leaf blocks
int blkdim_[4]; // number of dimensions in each block
int blksz_;
float* blkxs_;
float* blkdx_;
OctKey *blkkey_;
float* datbuf_;
float* prebuf_;
float* sndbuf_;
float* tmpbuf_;
float* tagbuf_;
int nrect_, nvert_;
EOS* eos_;
};
extern int CompareKid2Kid0(const float* xs0, const float* xe0, const float* dx0,
int kid, const float* xsk, const float* dxk );
extern int isSeqEightSibling( const int* blkdim, const float*blkxs, const float* blkdx,
const int fst );
extern int ConsolidateBlocks(int nblks, const int* blkdim,
const float* blkxs, const float* blkdx,
int* ncb, int* sft );
#endif
This diff is collapsed.
......@@ -3,7 +3,7 @@
*/
#ifndef AMR_AGG_H
#define AMR_AGG_H
#include <DebugStream.h>
#include <AMRreader.h>
......@@ -19,7 +19,7 @@ class AMRreaderAgg
{
public:
AMRreaderAgg() { init(); }
~AMRreaderAgg(){ freedata(); }
virtual ~AMRreaderAgg(){ freedata(); }
void init() {
AMRreader::init();
......@@ -27,16 +27,15 @@ public:
aggbid_=NULL;
aggsft_=NULL;
}
int freedata() {
virtual int freedata() {
AMRreader::freedata();
if( aggbid_!=NULL ) delete [] aggbid_;
if( aggsft_!=NULL ) delete [] aggsft_;
nagg_=aggdat_=0;
aggbid_=NULL;
aggsft_=NULL;
return 0;
}
int getInfo( const char* filename ) {
virtual int getInfo( const char* filename ) {
int err = AMRreader::getInfo( filename );
if( err!=0 ) {
debug1 << "Failed to get AMR file info in AMRreaderAgg::getInfo()\n";
......@@ -57,8 +56,8 @@ public:
}
public:
int GetNumberOfBlocks() const { return nagg_; };
int GetBlockDimensions( int bid, int* dim ) const {
virtual int GetNumberOfBlocks() const { return nagg_; };
virtual int GetBlockDimensions( int bid, int* dim ) const {
if( aggbid_[bid]>=0 ) {
dim[0] = blkdim_[0];
dim[1] = blkdim_[1];
......@@ -71,14 +70,14 @@ public:
}
return 0;
}
int GetBlockSize( int bid ) const {
virtual int GetBlockSize( int bid ) const {
if( aggbid_[bid]>=0 )
return blksz_;
else
return 8*blksz_;
}
int GetBlockMesh( int bid, float* xs, float* dx );
int GetBlockVariable( int bid, int vid, float* dat );
virtual int GetBlockMesh( int bid, float* xs, float* dx );
virtual int GetBlockVariable( int bid, int vid, float* dat );
protected:
......@@ -86,6 +85,7 @@ protected:
int genAggInfo();
int genAggData();
int genAggAdditionData();
int genAggTags();
int genAggScalar( float* dat );
......
#include <stdlib.h>
#include <DebugStream.h>
#include <AMRreaderBlkConso.h>
void AMRreaderBlkConso::
init()
{
AMRreader::init();
nbc_=0;
bcsft_=NULL;
ldata_=0;
}
int AMRreaderBlkConso::
freedata()
{
AMRreader::freedata();
if( bcsft_!=NULL ) free( bcsft_ );
nbc_=0;
bcsft_=NULL;
ldata_=0;
return 0;
}
int AMRreaderBlkConso::
FlagLowBid()
{
bcsft_ = (int*)malloc( (nblks_+1)*sizeof(int) );
if( bcsft_==NULL )
{
debug1 << "Failed to allocate lowbid_ in AMRreaderBlkConso::FlagLowBid().\n";
return -1;
}
int ierr = ConsolidateBlocks( nblks_, blkdim_, blkxs_, blkdx_, &nbc_, bcsft_ );
if( ierr!=0 )
{
debug1 << "Failed in ConsolidateBlocks() in AMRreaderBlkConso::FlagLowBid().\n";
return -1;
}
bcsft_ = (int*)realloc( bcsft_, (nbc_+1)*sizeof(int) );
return 0;
}
int AMRreaderBlkConso::
getInfo( const char* filename )
{
int ierr = AMRreader::getInfo( filename );
if( ierr!=0 )
{
debug1 << "Failed in AMRreader::getInfo().\n";
return ierr;
}
ierr = readAMRmesh();
if( ierr!=0 )
{
debug1 << "Failed in AMRreader::readAMRmesh().\n";
return ierr;
}
ierr = FlagLowBid();
if( ierr!=0 )
{
debug1 << "Failed in AMRreaderBlkConso::FlagLowBid().\n";
return ierr;
}
debug5 << "Number of blocks (AMRreaderBlkConso) = " << nbc_ << "\n";
return 0;
}
int AMRreaderBlkConso::
GetBlockDimensions( int bid, int* dim ) const
{
dim[0] = blkdim_[0];
dim[1] = blkdim_[1];
dim[2] = blkdim_[2];
if( bcsft_[bid]+8==bcsft_[bid+1] )
{
dim[0] *= 2;
dim[1] *= 2;
dim[2] *= 2;
}
return 0;
}
int AMRreaderBlkConso::
GetBlockSize( int bid ) const
{
int sz = blksz_;
if( bcsft_[bid]+8 == bcsft_[bid+1] ) sz*=8;
return sz;
}
int AMRreaderBlkConso::
GetBlockMesh( int bid, float* xs, float* dx )
{
int sft=3*bcsft_[bid];
xs[0] = blkxs_[sft];
xs[1] = blkxs_[sft+1];
xs[2] = blkxs_[sft+2];
dx[0] = blkdx_[sft];
dx[1] = blkdx_[sft+1];
dx[2] = blkdx_[sft+2];
return 0;
}
OctKey
AMRreaderBlkConso::GetBlockKey(int bid)
{
OctKey k(blkkey_[bcsft_[bid]]);
// If the data were combined then we shift the key right 3 to remove the
// octree level that was combined.
// if( bcsft_[bid]+8 == bcsft_[bid+1] )
// k = OctKey(k.key.eb >> 3);
return k;
}
int AMRreaderBlkConso::
GetBlockVariable( int bid, int vid, float* dat )
{
int ierr = PreprocessData();
if( ierr!=0 )
{
debug1 << "Failed to PreprocessData() in GetBlockVariable()\n";
return ierr;
}
int sz = blksz_;
int tid = bcsft_[bid];
if( tid+8 == bcsft_[bid+1] ) sz*=8;
//#define RADIAL_TEST_PATTERN
#ifdef RADIAL_TEST_PATTERN
// Compute distance from 0,0,0 to cell centers so we return data
// that makes sense for testing.
int dims[3];
GetBlockDimensions(bid, dims);
float xs[3], dx[3];
GetBlockMesh(bid, xs, dx);
float *ptr = dat;
for(int k = 0; k < dims[2]; ++k)
for(int j = 0; j < dims[1]; ++j)
for(int i = 0; i < dims[0]; ++i)
{
float x = xs[0] + (float(i) + 0.5) * dx[0];
float y = xs[1] + (float(j) + 0.5) * dx[1];
float z = xs[2] + (float(k) + 0.5) * dx[2];
*ptr++ = sqrt(x*x + y*y + z*z);
}
return 0;
#endif
ierr = compvar( vid, datbuf_+(tid*5*blksz_), dat, sz );
if( ierr!=0 )
{
debug1 << "Failed to compute requested variable: " << vid << " .\n";
return ierr;
}
return 0;
}
int AMRreaderBlkConso::
PreprocessData()
{
if( ldata_==1 ) return 0;
int ierr = AMRreader::PreprocessData();
if( ierr!=0 )
{
debug1 << "Failed in AMRreader::PreprocessData()\n";
return ierr;
}
if( CombineData() != 0 )
{
debug1 << "Failed in CombineData().\n";
return -2;
}
ldata_=1;
return 0;
}
int AMRreaderBlkConso::
CombineBlockData( int nv, float* bd[8], float* src )
{
int lsft=0;
for( int k=0; k<8; k++ )
for( int j=0; j<nv*blksz_; j++ )
bd[k][j] = src[lsft++];
for( int k=0; k<8; k++ )
{
int is = kid2i[k]*blkdim_[0];
int js = kid2j[k]*blkdim_[1];
int ks = kid2k[k]*blkdim_[2];
int ksft=0;
for( int n=0; n<blkdim_[2]; n++ )
{
int kk = (ks+n) * 4 * blkdim_[1] * blkdim_[0];
for( int m=0; m<blkdim_[1]; m++ )
{
int jj = (js+m) * 2 * blkdim_[0];
for( int l=0; l<blkdim_[0]; l++ )
{
int ii = is+l;
lsft = nv*( ii + jj + kk );
for( int v=0; v<nv; v++ )
src[lsft++] = bd[k][ksft++];
}
}
}
}
return 0;
}
int AMRreaderBlkConso::
CombineScalarArray( float*bd[8], float* scl )
{
for( int i=0; i<nbc_; i++ )
{
int bid = bcsft_[i];
float* src = scl + bid*blksz_;
if( bid+8 == bcsft_[i+1] )
{
CombineBlockData( 1, bd, src );
}
}
return 0;
}
int AMRreaderBlkConso::
CombineData()
{
float* bd[8];