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


Main Page   Class Hierarchy   Compound List   File List  

GridFunctionVoid.C

Go to the documentation of this file.
00001 
00006 #include "GridFunctionVoid.h"
00007 #include "GridHierarchy.h"
00008 #include "GridDataBlockCommon.h"
00009  
00010 
00011 /*****************************************************************************/
00012 /* constructor */
00013 /*****************************************************************************/
00014 
00015 GridFunctionVoid::GridFunctionVoid(const int type,
00016                                    const int rank,
00017                                    const char name[],
00018                                    GridHierarchy &gh,
00019                                    const int loff,
00020                                    const int cfac,
00021                                    const int align,
00022                                    const int bndrywidth,
00023                                    const int extghwidth,
00024                                    const int cflag, 
00025                                    const int bflag,
00026                                    const int adptbflag,
00027                                    const int extghflag)
00028   : gftype(type), gfrank(rank), gfname((char *)name),
00029     loffset(loff), cfactor(cfac), alignment(align), 
00030     bwidth(bndrywidth), extghostwidth(extghwidth),
00031     comm_flag(cflag), 
00032     bndry_flag(bflag), adaptbndry_flag(adptbflag),
00033     extghost_flag(extghflag), compose_flag(DAGHFalse), 
00034     template_flag(DAGHNull),
00035     init_flag(DAGHTrue), update_flag(DAGHTrue), 
00036     prolong_flag(DAGHTrue), restrict_flag(DAGHTrue), 
00037     bndry_update_flag(DAGHTrue), 
00038     adaptbndry_update_flag(DAGHTrue),
00039     io_flag(DAGHTrue), chkpt_flag(DAGHTrue),
00040     lmax_recompose(DAGHAllLevels),
00041     time_sten_rad(0), space_sten_rad(0), 
00042     time_alias(0), phys_time(0),
00043     interactions(gh.rank, DAGHGhostInteraction, 1),
00044     ghost_send_info(0), ghost_recv_cnt(0), ghost_recv_info(0), 
00045     ghost_recv_server(0), data_recv_server(0),
00046     bndrybboxlist(0), prolongbboxlist(0), 
00047     updatedstep(gh.updatedvaluestep()),
00048     gt(0), dagh(gh),
00049     rcvsize(0), sndsize(0), sndbbox(0), 
00050     sndindex(0),rcvindex(0), sndlevel(0), sndcnt(0)
00051   {
00052 
00053    dagh.DAGH_InitOverlaps(gftype,overlap);
00054 
00055    time_alias = new short[2*time_sten_rad+1];
00056    phys_time = new double[(2*time_sten_rad+1)*dagh.totallevels()];
00057    for (register short i=0;i<2*time_sten_rad+1;i++) {
00058      time_alias[i] = i;
00059      for (register int l=0;l<dagh.totallevels();l++) 
00060        phys_time[i*dagh.totallevels()+l] = 0.0;
00061    }
00062 
00063    space_sten_rad = new short[2*gfrank];
00064    for (register int r=0; r<gfrank; r++) {
00065      space_sten_rad[2*r] = 0;
00066      space_sten_rad[2*r+1] = 0;
00067    }
00068 
00069    if (cflag >= DAGHTemplateComm) {
00070      template_flag = cflag - DAGHTemplateComm;
00071 #ifdef DEBUG_PRINT
00072      assert(dagh.gflist[template_flag]);
00073 #endif
00074      comm_flag = dagh.gflist[template_flag]->comm_flag;
00075    }
00076 
00077    for (register int ui=0; ui<DAGHGFVFlagNum; ui++)
00078      userflags[ui] = 0;
00079   }
00080 
00081 GridFunctionVoid::GridFunctionVoid(const int type,
00082                                    const int rank,
00083                                    const char name[],
00084                                    const int tsten, 
00085                                    const int ssten,
00086                                    GridHierarchy &gh,
00087                                    const int loff,
00088                                    const int cfac,
00089                                    const int align, 
00090                                    const int bndrywidth,
00091                                    const int extghwidth,
00092                                    const int cflag, 
00093                                    const int bflag,
00094                                    const int adptbflag,
00095                                    const int extghflag)
00096   : gftype(type), gfrank(rank), gfname((char *)name),
00097     loffset(loff), cfactor(cfac), alignment(align), 
00098     bwidth(bndrywidth), extghostwidth(extghwidth),
00099     comm_flag(cflag), 
00100     bndry_flag(bflag), adaptbndry_flag(adptbflag),
00101     extghost_flag(extghflag), compose_flag(DAGHFalse), 
00102     template_flag(DAGHNull),
00103     init_flag(DAGHTrue), update_flag(DAGHTrue), 
00104     prolong_flag(DAGHTrue), restrict_flag(DAGHTrue), 
00105     bndry_update_flag(DAGHTrue), 
00106     adaptbndry_update_flag(DAGHTrue),
00107     io_flag(DAGHTrue), chkpt_flag(DAGHTrue),
00108     lmax_recompose(DAGHAllLevels),
00109     time_sten_rad(tsten), space_sten_rad(0), 
00110     time_alias(0), phys_time(0),
00111     interactions(gh.rank, DAGHGhostInteraction, 1),
00112     ghost_send_info(0), ghost_recv_cnt(0), ghost_recv_info(0), 
00113     ghost_recv_server(0), data_recv_server(0),
00114     bndrybboxlist(0), prolongbboxlist(0), 
00115     updatedstep(gh.updatedvaluestep()),
00116     gt(0), dagh(gh),
00117     rcvsize(0), sndsize(0), sndbbox(0), 
00118     sndindex(0),rcvindex(0), sndlevel(0), sndcnt(0)
00119   {
00120 
00121    dagh.DAGH_InitOverlaps(gftype,overlap);
00122 
00123    time_alias = new short[2*time_sten_rad+1];
00124    phys_time = new double[(2*time_sten_rad+1)*dagh.totallevels()];
00125    for (register short i=0;i<2*time_sten_rad+1;i++) {
00126      time_alias[i] = i;
00127      for (register int l=0;l<dagh.totallevels();l++) 
00128        phys_time[i*dagh.totallevels()+l] = 0.0;
00129    }
00130 
00131    space_sten_rad = new short[2*gfrank];
00132    for (register int r=0; r<gfrank; r++) {
00133      space_sten_rad[2*r] = ssten;
00134      space_sten_rad[2*r+1] = ssten;
00135    }
00136 
00137    if (cflag >= DAGHTemplateComm) {
00138      template_flag = cflag - DAGHTemplateComm;
00139 #ifdef DEBUG_PRINT
00140      assert(dagh.gflist[template_flag]);
00141 #endif
00142      comm_flag = dagh.gflist[template_flag]->comm_flag;
00143    }
00144 
00145    for (register int ui=0; ui<DAGHGFVFlagNum; ui++)
00146      userflags[ui] = 0;
00147 }
00148 
00149 GridFunctionVoid::GridFunctionVoid(const int type,
00150                                    const int rank,
00151                                    const char name[],
00152                                    const int tsten, 
00153                                    const int *ssten,
00154                                    GridHierarchy &gh,
00155                                    const int loff,
00156                                    const int cfac,
00157                                    const int align, 
00158                                    const int bndrywidth,
00159                                    const int extghwidth,
00160                                    const int cflag, 
00161                                    const int bflag,
00162                                    const int adptbflag,
00163                                    const int extghflag)
00164   : gftype(type), gfrank(rank), gfname((char *)name),
00165     loffset(loff), cfactor(cfac), alignment(align), 
00166     bwidth(bndrywidth), extghostwidth(extghwidth),
00167     comm_flag(cflag), 
00168     bndry_flag(bflag), adaptbndry_flag(adptbflag),
00169     extghost_flag(extghflag), compose_flag(DAGHFalse), 
00170     template_flag(DAGHNull),
00171     init_flag(DAGHTrue), update_flag(DAGHTrue), 
00172     prolong_flag(DAGHTrue), restrict_flag(DAGHTrue), 
00173     bndry_update_flag(DAGHTrue), 
00174     adaptbndry_update_flag(DAGHTrue),
00175     io_flag(DAGHTrue), chkpt_flag(DAGHTrue),
00176     lmax_recompose(DAGHAllLevels),
00177     time_sten_rad(tsten), space_sten_rad(0), 
00178     time_alias(0), phys_time(0),
00179     interactions(gh.rank, DAGHGhostInteraction, 1),
00180     ghost_send_info(0), ghost_recv_cnt(0), ghost_recv_info(0), 
00181     ghost_recv_server(0), data_recv_server(0),
00182     bndrybboxlist(0), prolongbboxlist(0), 
00183     updatedstep(gh.updatedvaluestep()),
00184     gt(0), dagh(gh),
00185     rcvsize(0), sndsize(0), sndbbox(0), 
00186     sndindex(0),rcvindex(0), sndlevel(0), sndcnt(0)
00187   {
00188 
00189    dagh.DAGH_InitOverlaps(gftype,overlap);
00190 
00191    time_alias = new short[2*time_sten_rad+1];
00192    phys_time = new double[(2*time_sten_rad+1)*dagh.totallevels()];
00193    for (register short i=0;i<2*time_sten_rad+1;i++) {
00194      time_alias[i] = i;
00195      for (register int l=0;l<dagh.totallevels();l++) 
00196        phys_time[i*dagh.totallevels()+l] = 0.0;
00197    }
00198 
00199    space_sten_rad = new short[2*gfrank];
00200    for (register int r=0; r<gfrank; r++) {
00201      space_sten_rad[2*r] = ssten[2*r];
00202      space_sten_rad[2*r+1] = ssten[2*r+1];
00203    }
00204 
00205    if (cflag >= DAGHTemplateComm) {
00206      template_flag = cflag - DAGHTemplateComm;
00207 #ifdef DEBUG_PRINT
00208      assert(dagh.gflist[template_flag]);
00209 #endif
00210      comm_flag = dagh.gflist[template_flag]->comm_flag;
00211    }
00212 
00213    for (register int ui=0; ui<DAGHGFVFlagNum; ui++)
00214      userflags[ui] = 0;
00215   }
00216 
00217 GridFunctionVoid::GridFunctionVoid(const char name[],
00218                                    const int rank,
00219                                    const GridFunctionVoid& gfv,
00220                                    const int cflag, 
00221                                    const int bflag,
00222                                    const int adptbflag,
00223                                    const int extghflag)
00224   : gftype(gfv.gftype), gfrank(rank), gfname((char *)name),
00225     loffset(gfv.loffset), cfactor(gfv.cfactor), alignment(gfv.alignment), 
00226     bwidth(gfv.bwidth), extghostwidth(gfv.extghostwidth),
00227     comm_flag(cflag), 
00228     bndry_flag(bflag), adaptbndry_flag(adptbflag),
00229     extghost_flag(extghflag), compose_flag(DAGHFalse), 
00230     template_flag(DAGHNull),
00231     init_flag(DAGHTrue), update_flag(DAGHTrue), 
00232     prolong_flag(DAGHTrue), restrict_flag(DAGHTrue), 
00233     bndry_update_flag(DAGHTrue), 
00234     adaptbndry_update_flag(DAGHTrue),
00235     io_flag(DAGHTrue), chkpt_flag(DAGHTrue),
00236     lmax_recompose(DAGHAllLevels),
00237     time_sten_rad(gfv.time_sten_rad), space_sten_rad(0),
00238     time_alias(0), phys_time(0),
00239     interactions(gfv.dagh.rank, DAGHGhostInteraction, 1),
00240     ghost_send_info(0), ghost_recv_cnt(0), ghost_recv_info(0), 
00241     ghost_recv_server(0), data_recv_server(0),
00242     bndrybboxlist(0), prolongbboxlist(0), 
00243     updatedstep(gfv.dagh.updatedvaluestep()),
00244     gt(0), dagh(gfv.dagh),
00245     rcvsize(0), sndsize(0), sndbbox(0), 
00246     sndindex(0),rcvindex(0), sndlevel(0), sndcnt(0)
00247   {
00248 
00249    dagh.DAGH_InitOverlaps(gftype,overlap);
00250 
00251    time_alias = new short[2*time_sten_rad+1];
00252    phys_time = new double[(2*time_sten_rad+1)*dagh.totallevels()];
00253    for (register short i=0;i<2*time_sten_rad+1;i++) {
00254      time_alias[i] = i;
00255      for (register int l=0;l<dagh.totallevels();l++) 
00256        phys_time[i*dagh.totallevels()+l] = 0.0;
00257    }
00258 
00259    const short* ssten = gfv.space_sten_rad;
00260    space_sten_rad = new short[2*gfrank];
00261    for (register int r=0; r<gfrank; r++) {
00262      space_sten_rad[2*r] = ssten[2*r];
00263      space_sten_rad[2*r+1] = ssten[2*r+1];
00264    }
00265 
00266    if (cflag >= DAGHTemplateComm) {
00267      template_flag = cflag - DAGHTemplateComm;
00268 #ifdef DEBUG_PRINT
00269      assert(dagh.gflist[template_flag]);
00270 #endif
00271      comm_flag = dagh.gflist[template_flag]->comm_flag;
00272    }
00273 
00274    for (register int ui=0; ui<DAGHGFVFlagNum; ui++)
00275      userflags[ui] = 0;
00276   }
00277 
00278 /*****************************************************************************/
00279 /* destructor */
00280 /*****************************************************************************/
00281 GridFunctionVoid::~GridFunctionVoid()
00282    {
00283      if (time_alias) delete [] time_alias;
00284      if (phys_time) delete [] phys_time;
00285      if (space_sten_rad) delete [] space_sten_rad;
00286    }
00287 
00288 /*****************************************************************************/
00289 /* Set GF Type */
00290 /*****************************************************************************/
00291 void GridFunctionVoid::GF_SetGridFunctionType(const int gft)
00292 { gftype = gft; dagh.DAGH_InitOverlaps(gftype,overlap); }
00293 
00294 /*****************************************************************************/
00295 /* set time stencil */ 
00296 /*****************************************************************************/
00297 
00298 void GridFunctionVoid::GF_SetSpaceStencil(const int s_sten)
00299   {
00300    for (int r=0; r<gfrank; r++) {
00301      space_sten_rad[2*r] = s_sten;
00302      space_sten_rad[2*r+1] = s_sten;
00303    }
00304   }
00305 
00306 void GridFunctionVoid::GF_SetSpaceStencil(const int *s_sten)
00307   {
00308    for (int r=0; r<gfrank; r++) {
00309      space_sten_rad[2*r] = s_sten[2*r];
00310      space_sten_rad[2*r+1] = s_sten[2*r+1];
00311    }
00312   }
00313 
00314 /*****************************************************************************/
00315 /* set time stencil */
00316 /*****************************************************************************/
00317 
00318 void GridFunctionVoid::GF_SetTimeStencil(const int t_sten)
00319   {
00320    if (time_sten_rad == t_sten) return;
00321 
00322    time_sten_rad = t_sten;
00323    if (time_alias) delete [] time_alias;
00324    time_alias = new short[2*time_sten_rad+1];
00325    for (register int i=0;i<time_sten_rad;i++)
00326     { time_alias[2*i] = 2*i; time_alias[2*i+1] = 2*i+1; }
00327    time_alias[2*time_sten_rad] = 2*time_sten_rad;
00328   }
00329 
00330 /*****************************************************************************/
00331 /* virtual methods that will be called by GridHierarchy */
00332 /*****************************************************************************/
00333 void GridFunctionVoid::GF_FreeTmpStorage()
00334   {
00335    if (rcvsize) delete [] rcvsize; 
00336    rcvsize = 0;
00337    if (sndsize) delete [] sndsize;
00338    sndsize = 0;
00339    if (sndbbox) delete [] sndbbox;
00340    sndbbox = 0;
00341    if (sndindex) delete [] sndindex;
00342    sndindex = 0;
00343    if (rcvindex) delete [] rcvindex;
00344    rcvindex = 0;
00345    if (sndlevel) delete [] sndlevel;
00346    sndlevel = 0;
00347    if (sndcnt) delete [] sndcnt;
00348    sndcnt = 0;
00349   }
00350 
00351 /*****************************************************************************/
00352 /* virtual methods for time aliasing */
00353 /*****************************************************************************/
00354 void GridFunctionVoid::GF_DeleteGDBStorage(const int t)
00355 { cerr << "Dummy GF_DeleteGDBStorage(t) function\n"; }
00356 
00357 /*****************************************************************************/
00358 /* virtual methods that will be called by GridHierarchy */
00359 /*****************************************************************************/
00360 
00361 void GridFunctionVoid::GF_Compose()
00362      { cerr << "Dummy compose function\n"; }
00363 
00364 void GridFunctionVoid::GF_Recompose(int* reuse_possible, GridBoxList** ollist,
00365                                     GridBoxList** rlist, 
00366                                     GridBoxList** slist,
00367                                     GridBoxList** olist)
00368      { cerr << "Dummy recompose function\n"; }
00369 
00370 void GridFunctionVoid::GF_CheckpointRecompose()
00371      { cerr << "Dummy recompose function\n"; }
00372 
00373 void GridFunctionVoid::GF_CheckpointRecompose(strstream& ifs)
00374      { cerr << "Dummy recompose function\n"; }
00375 
00376 void GridFunctionVoid::GF_Checkpoint(ofstream& ofs)
00377      { cerr << "Dummy GF_Checkpoint(ofs) function\n"; }
00378 
00379 void GridFunctionVoid::GF_Checkpoint(strstream& ofs)
00380      { cerr << "Dummy GF_Checkpoint(ofs) function\n"; }
00381 
00382 int GridFunctionVoid::GF_Checkpoint_StrStream_Memory()
00383      { cerr << "Dummy GF_Checkpoint_StrStream_Memory() function\n"; return 0;}
00384 
00385 void GridFunctionVoid::GF_CheckpointRestart(int proc)
00386      { cerr << "Dummy GF_Restart(name, gul) function\n"; }
00387 
00388 void GridFunctionVoid::GF_CheckpointRestart(strstream& ifs)
00389      { cerr << "Dummy GF_Restart(name, gul) function\n"; }
00390 
00391 /*************************************************************************/
00392 /* BBox internally used for allocation */
00393 /*************************************************************************/
00394 BBox GridFunctionVoid::usedbbox(const BBox& gb, const int& level, const int& align) {
00395   BBox bb(gb); 
00396   int fac = dagh.refinedby(level,level-loffset);
00397   if (fac>0) bb.coarsen(fac);
00398   else bb.refine(-fac);
00399   if (cfactor>0) bb.coarsen(cfactor);
00400   else bb.refine(-cfactor);
00401   bb.growupperbydim(overlap);
00402   if (align != DAGH_All) 
00403     gdbAlignBBox(gfrank, bb, align);
00404   return bb;
00405 }     
00406  
00407 /*****************************************************************************/
00408 /* overloaded stdout */
00409 /*****************************************************************************/
00410 
00411 ostream& operator<<(ostream& os, const GridFunctionVoid& gfv)
00412   { 
00413    if (&gfv == (GridFunctionVoid *) NULL) return os;
00414 
00415    os << "GridFunction "
00416       << "[" << gfv.gfid << "] " 
00417       << "[" << gfv.gftype << "] " 
00418       << "[" << gfv.gfrank << "] " 
00419       << "[" << gfv.gfname << "] "
00420       << "[" << gfv.alignment << "] "
00421       << endl; 
00422 
00423    os << "[Comm:" << gfv.comm_flag << "] " 
00424       << "[Bndry:" << gfv.bndry_flag << "] " 
00425       << "[AdaptBndry:" << gfv.adaptbndry_flag << "] " 
00426       << "[ExtGhost:" << gfv.extghost_flag << "] " 
00427       << endl; 
00428      
00429    os << "[TSten:" << gfv.time_sten_rad << "] "
00430       << "[SSten: ";
00431    
00432    for (int r=0; r<gfv.gfrank; r++) {
00433      os << gfv.space_sten_rad[2*r] << " "
00434         << gfv.space_sten_rad[2*r+1] << " ";
00435    }
00436    os << "]" << endl; 
00437      
00438    os << gfv.interactions;
00439 
00440    return os; 
00441   }
00442 
00443 ostream& operator<<(ostream& os, const GF_Interaction& gfi)
00444   {
00445     if (&gfi == (GF_Interaction *) NULL) return os;
00446 
00447     os << "GF_Interaction[ ";
00448     os << gfi.cnt << "[";
00449     for (register int i=0;i<gfi.cnt;i++) os << gfi.size[i] << " ";
00450     os << "] ";
00451     os << gfi.tsize;
00452     os << "]";
00453     return os;
00454   }
00455 
00456 /*****************************************************************************/
00457 /* binary out for checkpointing */
00458 /*****************************************************************************/
00459 ofstream& operator<<(ofstream& ofs, const GridFunctionVoid& gfv)
00460   { 
00461    if (&gfv == (GridFunctionVoid *) NULL) return ofs;
00462 
00463    // does nothing for now.
00464 
00465    return ofs; 
00466   }
00467 
00468 
00469 strstream& operator>>(strstream& ifs, GridFunctionVoid& gfv)
00470   { 
00471    if (&gfv == (GridFunctionVoid *) NULL) return ifs;
00472 
00473    // does nothing for now.
00474 
00475    return ifs; 
00476   }
00477 
00478 strstream& operator<<(strstream& ofs, const GridFunctionVoid& gfv)
00479   { 
00480    if (&gfv == (GridFunctionVoid *) NULL) return ofs;
00481 
00482    // does nothing for now.
00483 
00484    return ofs; 
00485   }
00486 
00487 
00488 ifstream& operator>>(ifstream& ifs, GridFunctionVoid& gfv)
00489   { 
00490    if (&gfv == (GridFunctionVoid *) NULL) return ifs;
00491 
00492    // does nothing for now.
00493 
00494    return ifs; 
00495   }


Quickstart     Users Guide     Programmers Reference     Installation      Examples     Download



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