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


Main Page   Class Hierarchy   Compound List   File List  

GridDataOpsRed1.h

Go to the documentation of this file.
00001 #ifndef _included_GridDataOpsRed_1_h
00002 #define _included_GridDataOpsRed_1_h
00003 
00009 /****************************** maxval ***************************************/
00010 
00011 template <class Type>
00012 Type GridData(1)<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(1)<Type> &dst = *this;
00024 
00025        BeginFastIndex1(dst, dst._bbox, dst._data, Type);
00026 
00027        for_1(i, intersection, max_step)
00028          if (flag == DAGHTrue) 
00029            { max_val = FastIndex1(dst,i); flag = DAGHFalse; }
00030          else 
00031            max_val = Max(max_val,FastIndex1(dst,i));
00032        end_for
00033 
00034        EndFastIndex1(dst);
00035 
00036       }
00037     return (max_val);
00038   }
00039 
00040 /************************************************************************/
00041 
00042 /****************************** minval ***************************************/
00043 
00044 template <class Type>
00045 Type GridData(1)<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(1)<Type> &dst = *this;
00057 
00058        BeginFastIndex1(dst, dst._bbox, dst._data, Type);
00059 
00060        for_1(i, intersection, max_step)
00061          if (flag == DAGHTrue) 
00062            { min_val = FastIndex1(dst,i); flag = DAGHFalse; }
00063          else 
00064            min_val = Min(min_val,FastIndex1(dst,i));
00065        end_for
00066 
00067        EndFastIndex1(dst);
00068 
00069       }
00070     return (min_val);
00071   }
00072 
00073 /************************************************************************/
00074 
00075 /****************************** sum ***************************************/
00076 
00077 template <class Type>
00078 Type GridData(1)<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(1)<Type> &dst = *this;
00089 
00090        BeginFastIndex1(dst, dst._bbox, dst._data, Type);
00091 
00092        for_1(i, intersection, max_step)
00093          sum_val += FastIndex1(dst,i);
00094        end_for
00095 
00096        EndFastIndex1(dst);
00097 
00098       }
00099     return (sum_val);
00100   }
00101 
00102 /************************************************************************/
00103 
00104 /****************************** product ***************************************/
00105 
00106 template <class Type>
00107 Type GridData(1)<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(1)<Type> &dst = *this;
00118 
00119        BeginFastIndex1(dst, dst._bbox, dst._data, Type);
00120 
00121        for_1(i, intersection, max_step)
00122          prod_val *= FastIndex1(dst,i);
00123        end_for
00124 
00125        EndFastIndex1(dst);
00126 
00127       }
00128     return (prod_val);
00129   }
00130 
00131 /************************************************************************/
00132 
00133 /****************************** moment1 ***************************************/
00134 template <class Type>
00135 Type GridData(1)<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(1)<Type> &dst = *this;
00146 
00147        BeginFastIndex1(dst, dst._bbox, dst._data, Type);
00148 
00149        if (axis == DAGH_X) {
00150          for_1(i, intersection, max_step)
00151            m1 += FastIndex1(dst,i) * i;
00152          end_for
00153        }
00154 
00155        EndFastIndex1(dst);
00156       }
00157     return (m1);
00158   }
00159 /************************************************************************/
00160 
00161 /****************************** sumsqrd ***************************************/
00162 
00163 template <class Type>
00164 double GridData(1)<Type>::sumsqrd (BBox const &where)
00165 
00166   {
00167     double s = 0.0;
00168     BBox intersection = _bbox * where;
00169     if (!intersection.empty())
00170       {
00171        Coords max_step = _step.getmax(where.stepsize());
00172        intersection.setstepsize(_step);
00173 
00174        GridData(1)<Type> &dst = *this;
00175 
00176        BeginFastIndex1(dst, dst._bbox, dst._data, Type);
00177 
00178        for_1(i, intersection, max_step)
00179          s += abs(FastIndex1(dst,i)) * abs(FastIndex1(dst,i));
00180        end_for
00181 
00182        EndFastIndex1(dst);
00183 
00184       }
00185     return s;
00186   }
00187 
00188 /************************************************************************/
00189 
00190 /****************************** sumabs ***************************************/
00191 
00192 template <class Type>
00193 double GridData(1)<Type>::sumabs (BBox const &where)
00194 
00195   {
00196     double s = 0.0;
00197     BBox intersection = _bbox * where;
00198     if (!intersection.empty())
00199       {
00200        Coords max_step = _step.getmax(where.stepsize());
00201        intersection.setstepsize(_step);
00202 
00203        GridData(1)<Type> &dst = *this;
00204 
00205        BeginFastIndex1(dst, dst._bbox, dst._data, Type);
00206 
00207        for_1(i, intersection, max_step)
00208          s += abs(FastIndex1(dst,i));
00209        end_for
00210 
00211        EndFastIndex1(dst);
00212 
00213       }
00214     return s;
00215   }
00216 
00217 /************************************************************************/
00218 
00219 /****************************** maxabs ***************************************/
00220 
00221 template <class Type>
00222 double GridData(1)<Type>::maxabs (BBox const &where)
00223 
00224   {
00225     double m = 0.0;
00226     BBox intersection = _bbox * where;
00227     if (!intersection.empty())
00228       {
00229        Coords max_step = _step.getmax(where.stepsize());
00230        intersection.setstepsize(_step);
00231 
00232        GridData(1)<Type> &dst = *this;
00233 
00234        BeginFastIndex1(dst, dst._bbox, dst._data, Type);
00235 
00236        for_1(i, intersection, max_step)
00237          double t = abs(FastIndex1(dst,i));
00238          m = Max(m,t);
00239        end_for
00240 
00241        EndFastIndex1(dst);
00242 
00243       }
00244     return m;
00245   }
00246 
00247 /************************************************************************/
00248 
00249 #endif


Quickstart     Users Guide     Programmers Reference     Installation      Examples     Download



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