From 8fe367ecf2cbda79960a68a052fdb84916427c0e Mon Sep 17 00:00:00 2001 From: tradke Date: Wed, 13 Sep 2000 13:49:13 +0000 Subject: Importing latest stuff from development repository git-svn-id: http://svn.cactuscode.org/arrangements/CactusExternal/FlexIO/trunk@2 21a6bef8-4479-4f54-8f8d-0db94a2919ef --- src/AMRPlus/AMRfilereaderPlus.C | 175 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 175 insertions(+) create mode 100644 src/AMRPlus/AMRfilereaderPlus.C (limited to 'src/AMRPlus/AMRfilereaderPlus.C') diff --git a/src/AMRPlus/AMRfilereaderPlus.C b/src/AMRPlus/AMRfilereaderPlus.C new file mode 100644 index 0000000..17d0e45 --- /dev/null +++ b/src/AMRPlus/AMRfilereaderPlus.C @@ -0,0 +1,175 @@ +#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