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


Main Page   Class Hierarchy   Compound List   File List  

GridDataOpsRed2.h

Go to the documentation of this file.
00001 #ifndef _included_GridDataOpsRed_2_h
00002 #define _included_GridDataOpsRed_2_h
00003 
00009 /****************************** maxval ***************************************/
00010 
00011 template <class Type>
00012 Type GridData(2)<Type>::maxval (BBox const &where)
00013 
00014   {
00015     Type max_val = (Type) DAGHSmall;
00016     short flag = DAGHTrue;
00017     BBox intersection = _bbox * where;
00018     if (!intersection.empty())
00019       {
00020        Coords max_step = _step.getmax(where.stepsize());
00021        intersection.setstepsize(_step);
00022 
00023        GridData(2)<Type> &dst = *this;
00024 
00025        BeginFastIndex2(dst, dst._bbox, dst._data, Type);
00026 
00027        for_2(i, j, intersection, max_step)
00028          if (flag == DAGHTrue) 
00029            { max_val = FastIndex2(dst,i,j); flag = DAGHFalse; }
00030          else 
00031            max_val = Max(max_val, FastIndex2(dst,i,j));
00032        end_for
00033 
00034        EndFastIndex2(dst);
00035 
00036       }
00037     return (max_val);
00038   }
00039 
00040 /************************************************************************/
00041 
00042 /****************************** minval ***************************************/
00043 
00044 template <class Type>
00045 Type GridData(2)<Type>::minval (BBox const &where)
00046 
00047   {
00048     Type min_val = MAXLIM(Type);
00049     short flag = DAGHTrue;
00050     BBox intersection = _bbox * where;
00051     if (!intersection.empty())
00052       {
00053        Coords max_step = _step.getmax(where.stepsize());
00054        intersection.setstepsize(_step);
00055 
00056        GridData(2)<Type> &dst = *this;
00057 
00058        BeginFastIndex2(dst, dst._bbox, dst._data, Type);
00059 
00060        for_2(i, j, intersection, max_step)
00061          if (flag == DAGHTrue) 
00062            { min_val = FastIndex2(dst,i,j); flag = DAGHFalse; }
00063          else 
00064            min_val = Min(min_val, FastIndex2(dst,i,j));
00065        end_for
00066 
00067        EndFastIndex2(dst);
00068 
00069       }
00070     return (min_val);
00071   }
00072 
00073 /************************************************************************/
00074 
00075 /****************************** sum ***************************************/
00076 
00077 template <class Type>
00078 Type GridData(2)<Type>::sum (BBox const &where)
00079 
00080   {
00081     Type sum_val = (Type) 0;
00082     BBox intersection = _bbox * where;
00083     if (!intersection.empty())
00084       {
00085        Coords max_step = _step.getmax(where.stepsize());
00086        intersection.setstepsize(_step);
00087 
00088        GridData(2)<Type> &dst = *this;
00089 
00090        BeginFastIndex2(dst, dst._bbox, dst._data, Type);
00091 
00092        for_2(i, j, intersection, max_step)
00093          sum_val += FastIndex2(dst,i,j);
00094        end_for
00095 
00096        EndFastIndex2(dst);
00097 
00098       }
00099     return (sum_val);
00100   }
00101 
00102 /************************************************************************/
00103 
00104 /****************************** product ***************************************/
00105 
00106 template <class Type>
00107 Type GridData(2)<Type>::product (BBox const &where)
00108 
00109   {
00110     Type prod_val = (Type) 1;
00111     BBox intersection = _bbox * where;
00112     if (!intersection.empty())
00113       {
00114        Coords max_step = _step.getmax(where.stepsize());
00115        intersection.setstepsize(_step);
00116 
00117        GridData(2)<Type> &dst = *this;
00118 
00119        BeginFastIndex2(dst, dst._bbox, dst._data, Type);
00120 
00121        for_2(i, j, intersection, max_step)
00122          prod_val *= FastIndex2(dst,i,j);
00123        end_for
00124 
00125        EndFastIndex2(dst);
00126 
00127       }
00128     return (prod_val);
00129   }
00130 
00131 /************************************************************************/
00132 
00133 /****************************** moment1 ***************************************/
00134 template <class Type>
00135 Type GridData(2)<Type>::moment1 (int const axis, BBox const &where)
00136 
00137   {
00138     Type m1 = (Type) 0;
00139     BBox intersection = _bbox * where;
00140     if (!intersection.empty())
00141       {
00142        Coords max_step = _step.getmax(where.stepsize());
00143        intersection.setstepsize(_step);
00144 
00145        GridData(2)<Type> &dst = *this;
00146 
00147        BeginFastIndex2(dst, dst._bbox, dst._data, Type);
00148 
00149        if (axis == DAGH_X) {
00150          for_2(i, j, intersection, max_step)
00151            m1 += FastIndex2(dst,i,j) * i;
00152          end_for
00153        }
00154        else if (axis == DAGH_Y) {
00155          for_2(i, j, intersection, max_step)
00156            m1 += FastIndex2(dst,i,j) * j;
00157          end_for
00158        }
00159 
00160        EndFastIndex2(dst);
00161       }
00162     return (m1); 
00163   }
00164 /************************************************************************/
00165 
00166 /****************************** sumsqrd ***************************************/
00167 
00168 template <class Type>
00169 double GridData(2)<Type>::sumsqrd (BBox const &where)
00170 
00171   {
00172     double s = 0.0;
00173     BBox intersection = _bbox * where;
00174     if (!intersection.empty())
00175       {
00176        Coords max_step = _step.getmax(where.stepsize());
00177        intersection.setstepsize(_step);
00178 
00179        GridData(2)<Type> &dst = *this;
00180 
00181        BeginFastIndex2(dst, dst._bbox, dst._data, Type);
00182 
00183        for_2(i, j, intersection, max_step)
00184          s += abs(FastIndex2(dst,i,j)) * abs(FastIndex2(dst,i,j));
00185        end_for
00186 
00187        EndFastIndex2(dst);
00188 
00189       }
00190     return s;
00191   }
00192 
00193 /************************************************************************/
00194 
00195 /****************************** sumabs ***************************************/
00196 
00197 template <class Type>
00198 double GridData(2)<Type>::sumabs (BBox const &where)
00199 
00200   {
00201     double s = 0.0;
00202     BBox intersection = _bbox * where;
00203     if (!intersection.empty())
00204       {
00205        Coords max_step = _step.getmax(where.stepsize());
00206        intersection.setstepsize(_step);
00207 
00208        GridData(2)<Type> &dst = *this;
00209 
00210        BeginFastIndex2(dst, dst._bbox, dst._data, Type);
00211 
00212        for_2(i, j, intersection, max_step)
00213          s += abs(FastIndex2(dst,i,j));
00214        end_for
00215 
00216        EndFastIndex2(dst);
00217 
00218       }
00219     return s;
00220   }
00221 
00222 /************************************************************************/
00223 
00224 /****************************** maxabs ***************************************/
00225 
00226 template <class Type>
00227 double GridData(2)<Type>::maxabs (BBox const &where)
00228 
00229   {
00230     double m = 0.0;
00231     BBox intersection = _bbox * where;
00232     if (!intersection.empty())
00233       {
00234        Coords max_step = _step.getmax(where.stepsize());
00235        intersection.setstepsize(_step);
00236 
00237        GridData(2)<Type> &dst = *this;
00238 
00239        BeginFastIndex2(dst, dst._bbox, dst._data, Type);
00240 
00241        for_2(i, j, intersection, max_step)
00242          double t = abs(FastIndex2(dst,i,j));
00243          m = Max(m,t);
00244        end_for
00245 
00246        EndFastIndex2(dst);
00247 
00248       }
00249     return m;
00250   }
00251 
00252 /************************************************************************/
00253 
00254 #endif


Quickstart     Users Guide     Programmers Reference     Installation      Examples     Download



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