#include #include #include "AMRfilereaderPlus.h" #include "FlexArrayTmpl.H" void AMRfilereaderPlus::printGridInfo(AMRgridPlus &g){ printf("Grid level=%u step=%u maxtime=%u\n",g.level,g.timestep,g.maxtime); printf("\trank=%u dims[",g.rank); for(int i=0;i(v))?(u):(v);} #define MINIMIZE(u, v) {(u)=((u)<(v))?(u):(v);} void AMRfilereaderPlus::buildInfoTable(){ // Load all grids Info int index=0; AMRgridPlus g; while(getGridInfo(g,index++)){ if(this->debug) printf("buildInfoTable: getGrid index=%u\n",index); if(this->debug) printGridInfo(g); int i=grids.getSize(); g.data=0; // zero out the data if(g.level>maxlevel) maxlevel=g.level; if(!i){ smin=g.scalarmin; smax=g.scalarmax; mintime = g.timestep; maxtime = g.timestep; maxtimeres = g.timerefinement; maxlevel= g.level; bounds[0]=g.origin[0]; bounds[1]=g.origin[0]+g.delta[0]*g.dims[0]; bounds[2]=g.origin[1]; bounds[3]=g.origin[1]+g.delta[1]*g.dims[1]; bounds[4]=g.origin[2]; bounds[5]=g.origin[2]+g.delta[2]*g.dims[2]; } else{ MINIMIZE(smin, g.scalarmin); MAXIMIZE(smax, g.scalarmax); if (g.level==0){ MINIMIZE(bounds[0], g.origin[0]); MAXIMIZE(bounds[1], g.origin[0]+g.delta[0]*g.dims[0]); MINIMIZE(bounds[2], g.origin[1]); MAXIMIZE(bounds[3], g.origin[1]+g.delta[1]*g.dims[1]); MINIMIZE(bounds[4], g.origin[2]); MAXIMIZE(bounds[5], g.origin[2]+g.delta[2]*g.dims[2]); } } if(g.timestepmaxtime) maxtime=g.timestep; if(g.timerefinement>maxtimeres) maxtimeres=g.timerefinement; grids.append(g); } } void AMRfilereaderPlus::loadGrids(){ if(!gridloading) return; for(int i=0;idebug) printf("buildInfoTable: getGrid index=%u activegridindex %u\n",i,activeGrids[i]); if(this->debug) printGridInfo(grids[activeGrids[i]]); getGridData(grids[activeGrids[i]],activeGrids[i]); } } void AMRfilereaderPlus::reclaimGrids(){ if(!gridloading) return; for(int i=0;imaxtime){ printf("timestep %u is out of range %u:%u\n", timestep,mintime,maxtime); return; } activeGrids.purge(); current_time=timestep; if(this->debug) printf("setTime(%u): mintime=%u maxtime=%u\n",current_time,mintime,maxtime); for(int i=0;idebug) printf("\tgrids[%u].timestep=%u maxtime=%u\n",i,grids[i].timestep, grids[i].maxtime); if(current_time>=grids[i].timestep && current_timedebug) printf("\t\tAppendGrid number %u\n",i); } } if(this->debug) puts("load grids"); loadGrids(); if(this->debug) puts("reclaim grids"); reclaimGrids(); } void AMRfilereaderPlus::showAllLevels(){ for(int i=0;i &g){ g.setSize(activeGrids.getSize()); for(int i=0;i