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


Main Page   Class Hierarchy   Compound List   File List  

GridFunctionFuncs1.h

Go to the documentation of this file.
00001 #ifndef _included_GridFunctionFunc1_h
00002 #define _included_GridFunctionFunc1_h
00003 
00009 /*****************************************************************************/
00010 /**** Use Pred-defined Functions  ****/
00011 /*****************************************************************************/
00012 
00013 /**** Initialization ****/
00014 template <class DAGH_GFType>
00015 void GridFunction(1)<DAGH_GFType>::GF_Init(const int time, const int level, 
00016                                                char *args, const int cnt) {
00017   if (!initialize()) return;
00018   assert (ifunc != 0);
00019   register const int t = dagh_timeindex(time,level);
00020   register const int l = level;
00021   for (register int i=0; i<length[l]; i++) if (gdb[t][l][i]) 
00022     (*ifunc)(FORTRAN_ARGS(1,gdb[t][l][i]->griddata()), 
00023              BOUNDING_BOX(gdb[t][l][i]->griddata()),
00024              args, &cnt);
00025 }
00026 
00027 template <class DAGH_GFType>
00028 void GridFunction(1)<DAGH_GFType>::GF_Init(const int time, const int level, 
00029                                                const BBox &bb,
00030                                                char *args, const int cnt) {
00031   if (!initialize()) return;
00032   assert (ifunc != 0);
00033   register const int t = dagh_timeindex(time,level);
00034   register const int l = level;
00035   for (register int i=0; i<length[l]; i++) if (gdb[t][l][i]) 
00036     (*ifunc)(FORTRAN_ARGS(1,gdb[t][l][i]->griddata()), 
00037              BOUNDING_BOX(bb),
00038              args, &cnt);
00039 }
00040 
00041 /**** Update ****/
00042 template <class DAGH_GFType>
00043 void GridFunction(1)<DAGH_GFType>::GF_Update(const int time_from, const int time_to, 
00044                                                  const int level, 
00045                                                  char *args, const int cnt) {
00046   if (!update()) return;
00047   assert (ufunc != 0);
00048   register const int t_from = dagh_timeindex(time_from,level);
00049   register const int t_to = dagh_timeindex(time_to,level);
00050   register const int l = level;
00051   for (register int i=0; i<length[l]; i++)
00052     if (gdb[t_from][l][i] && gdb[t_to][l][i]) 
00053       (*ufunc)(FORTRAN_ARGS(1,gdb[t_from][l][i]->griddata()), 
00054                FORTRAN_ARGS(1,gdb[t_to][l][i]->griddata()),
00055                BOUNDING_BOX(gdb[t_to][l][i]->griddata()),
00056                args, &cnt);
00057 }
00058 
00059 template <class DAGH_GFType>
00060 void GridFunction(1)<DAGH_GFType>::GF_Update(const int time_from, const int time_to, 
00061                                                  const int level, 
00062                                                  const BBox &bb,
00063                                                  char *args, const int cnt) {
00064   if (!update()) return;
00065   assert (ufunc != 0);
00066   register const int t_from = dagh_timeindex(time_from,level);
00067   register const int t_to = dagh_timeindex(time_to,level);
00068   register const int l = level;
00069   for (register int i=0; i<length[l]; i++)
00070     if (gdb[t_from][l][i] && gdb[t_to][l][i]) 
00071       (*ufunc)(FORTRAN_ARGS(1,gdb[t_from][l][i]->griddata()), 
00072                FORTRAN_ARGS(1,gdb[t_to][l][i]->griddata()),
00073                BOUNDING_BOX(bb),
00074                args, &cnt);
00075 }
00076 
00077 /**** Prolong ****/
00078 template <class DAGH_GFType>
00079 void GridFunction(1)<DAGH_GFType>::GF_Prolong(const int time_from, const int level_from,
00080                                                   const int time_to, const int level_to,
00081                                                   char *args, const int cnt) {
00082 
00083   if (!prolong()) return;
00084   assert (pfunc != 0);
00085   register const int fl = level_from;
00086   register const int ft = dagh_timeindex(time_from,fl);
00087   register const int tl = level_to;
00088   register const int tt = dagh_timeindex(time_to,tl);
00089   GDB_Interaction* pi;  
00090   int npi;
00091   assert (tl>0);
00092 
00093   if (fl==tl-1) {
00094     for (register int i=0; i<length[tl]; i++) if (gdb[tt][tl][i]) 
00095       if ((npi=gdb[tt][tl][i]->gdb_parent_index)>0 &&
00096           (pi=gdb[tt][tl][i]->gdb_parent_info)) 
00097         for (register int j=0; j<npi; j++) if (gdb[ft][fl][pi[j].idx]) 
00098           (*pfunc)(FORTRAN_ARGS(1,gdb[ft][fl][pi[j].idx]->griddata()), 
00099                    FORTRAN_ARGS(1,gdb[tt][tl][i]->griddata()),
00100                    BOUNDING_BOX(pi[j].bbox),args,&cnt);
00101   }
00102   else 
00103     for (register int i=0; i<length[tl]; i++) if (gdb[tt][tl][i]) 
00104       for (register int j=0; j<length[fl]; j++) if (gdb[ft][fl][j]) 
00105         (*pfunc)(FORTRAN_ARGS(1,gdb[ft][fl][j]->griddata()), 
00106                  FORTRAN_ARGS(1,gdb[tt][tl][i]->griddata()),
00107                  BOUNDING_BOX(gdb[tt][tl][i]->boundingbox()),args,&cnt);
00108 }
00109 
00110 template <class DAGH_GFType>
00111 void GridFunction(1)<DAGH_GFType>::GF_Prolong(const int time_from, const int level_from, 
00112                                                   const int time_to, const int level_to,
00113                                                   const BBox &bbp, char *args, const int cnt) {
00114 
00115   if (!prolong()) return;
00116   assert (pfunc != 0);
00117   register const int fl = level_from;
00118   register const int ft = dagh_timeindex(time_from,fl);
00119   register const int tl = level_to;
00120   register const int tt = dagh_timeindex(time_to,tl);
00121   GDB_Interaction* pi;
00122   int npi;
00123   assert (tl>0);
00124 
00125   if (fl==tl-1) {
00126     for (register int i=0; i<length[tl]; i++) if (gdb[tt][tl][i])
00127       if ((npi=gdb[tt][tl][i]->gdb_parent_index)>0 &&
00128           (pi=gdb[tt][tl][i]->gdb_parent_info)) 
00129         for (register int j=0; j<npi; j++) if (gdb[ft][fl][pi[j].idx]) {
00130           BBox bb = pi[j].bbox*bbp;
00131           if (!bb.empty())
00132             (*pfunc)(FORTRAN_ARGS(1,gdb[ft][fl][pi[j].idx]->griddata()), 
00133                      FORTRAN_ARGS(1,gdb[tt][tl][i]->griddata()),
00134                      BOUNDING_BOX(bb),args,&cnt);
00135         }
00136   }
00137   else
00138     for (register int i=0; i<length[tl]; i++) if (gdb[tt][tl][i]) 
00139       for (register int j=0; j<length[fl]; j++) if (gdb[ft][fl][j]) 
00140         (*pfunc)(FORTRAN_ARGS(1,gdb[ft][fl][j]->griddata()), 
00141                  FORTRAN_ARGS(1,gdb[tt][tl][i]->griddata()),
00142                  BOUNDING_BOX(gdb[tt][tl][i]->boundingbox()),args,&cnt);
00143 }
00144 
00145 /**** Restrict ****/
00146 template <class DAGH_GFType>
00147 void GridFunction(1)<DAGH_GFType>::GF_Restrict(const int time_from, const int level_from, 
00148                                                    const int time_to, const int level_to,
00149                                                    char *args, const int cnt) {
00150 
00151   if (!Restrict()) return;
00152   assert (rfunc != 0);
00153   register const int fl = level_from;
00154   register const int ft = dagh_timeindex(time_from,fl);
00155   register const int tl = level_to;
00156   register const int tt = dagh_timeindex(time_to,tl);
00157   GDB_Interaction* pi;
00158   int npi;
00159   assert (fl>0);
00160 
00161   if (fl-1==tl) {
00162     for (register int i=0; i<length[fl]; i++) if (gdb[ft][fl][i]) 
00163       if ((npi=gdb[ft][fl][i]->gdb_parent_index)>0 &&
00164           (pi=gdb[ft][fl][i]->gdb_parent_info)) 
00165         for (register int j=0; j<npi; j++) if (gdb[tt][tl][pi[j].idx]) {
00166           BBox bb = pi[j].bbox;
00167           bb.coarsen(gdb[tt][tl][pi[j].idx]->griddata().stepsize()/
00168                      gdb[ft][fl][i]->griddata().stepsize());
00169           (*rfunc)(FORTRAN_ARGS(1,gdb[ft][fl][i]->griddata()), 
00170                    FORTRAN_ARGS(1,gdb[tt][tl][pi[j].idx]->griddata()),
00171                    BOUNDING_BOX(bb),args, &cnt);
00172         }
00173   }
00174   else
00175     for (register int i=0; i<length[fl]; i++) if (gdb[ft][fl][i]) 
00176       for (register int j=0; j<length[tl]; j++) if (gdb[tt][tl][j]) 
00177         (*rfunc)(FORTRAN_ARGS(1,gdb[ft][fl][i]->griddata()), 
00178                  FORTRAN_ARGS(1,gdb[tt][tl][j]->griddata()),
00179                  BOUNDING_BOX(gdb[tt][tl][j]->boundingbox()),args, &cnt);
00180 
00181 }
00182 
00183 template <class DAGH_GFType>
00184 void GridFunction(1)<DAGH_GFType>::GF_Restrict(const int time_from, const int level_from, 
00185                                                    const int time_to, const int level_to, 
00186                                                    const BBox &bbr, char *args, const int cnt) {
00187 
00188   if (!Restrict()) return;
00189   assert (rfunc != 0);
00190   register const int fl = level_from;
00191   register const int ft = dagh_timeindex(time_from,fl);
00192   register const int tl = level_to;
00193   register const int tt = dagh_timeindex(time_to,tl);
00194   GDB_Interaction* pi;
00195   int npi;
00196   assert (fl>0);
00197 
00198   if (fl-1==tl) { 
00199     for (register int i=0; i<length[fl]; i++) if (gdb[ft][fl][i]) 
00200       if ((npi=gdb[ft][fl][i]->gdb_parent_index)>0 &&
00201           (pi=gdb[ft][fl][i]->gdb_parent_info)) 
00202         for (register int j=0; j<npi; j++) if (gdb[tt][tl][pi[j].idx]) {
00203           BBox bb = pi[j].bbox;
00204           bb.coarsen(gdb[tt][tl][pi[j].idx]->griddata().stepsize()/
00205                      gdb[ft][fl][i]->griddata().stepsize());
00206           bb *= bbr;
00207           if (!bb.empty()) 
00208             (*rfunc)(FORTRAN_ARGS(1,gdb[ft][fl][i]->griddata()), 
00209                      FORTRAN_ARGS(1,gdb[tt][tl][pi[j].idx]->griddata()),
00210                      BOUNDING_BOX(bb),args,&cnt);
00211         }
00212   }
00213   else 
00214     for (register int i=0; i<length[fl]; i++) if (gdb[ft][fl][i]) 
00215       for (register int j=0; j<length[tl]; j++) if (gdb[tt][tl][j]) 
00216         (*rfunc)(FORTRAN_ARGS(1,gdb[ft][fl][i]->griddata()), 
00217                  FORTRAN_ARGS(1,gdb[tt][tl][j]->griddata()),
00218                  BOUNDING_BOX(gdb[tt][tl][j]->boundingbox()),args, &cnt);
00219 }
00220 
00221 /**** IO ****/
00222 template <class DAGH_GFType>
00223 void GridFunction(1)<DAGH_GFType>::GF_IO(const int time, const int level,
00224                                              char *args, const int cnt) {
00225   if (!io()) return;
00226   assert (iofunc != 0);
00227   register const int t = dagh_timeindex(time,level);
00228   register const int l = level;
00229   for (register int i=0; i<length[l]; i++) if (gdb[t][l][i])
00230     (*iofunc)(FORTRAN_ARGS(1,gdb[t][l][i]->griddata()), 
00231               BOUNDING_BOX(gdb[t][l][i]->boundingbox()),
00232               args, &cnt);
00233 }
00234 
00235 template <class DAGH_GFType>
00236 void GridFunction(1)<DAGH_GFType>::GF_IO(const int time, const int level,
00237                                              const BBox &bb,
00238                                              char *args, const int cnt) {
00239   if (!io()) return;
00240   assert (iofunc != 0);
00241   register const int t = dagh_timeindex(time,level);
00242   register const int l = level;
00243   for (register int i=0; i<length[l]; i++) if (gdb[t][l][i])
00244     (*iofunc)(FORTRAN_ARGS(1,gdb[t][l][i]->griddata()), 
00245               BOUNDING_BOX(bb),
00246               args, &cnt);
00247 }
00248 #endif


Quickstart     Users Guide     Programmers Reference     Installation      Examples     Download



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