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


Main Page   Class Hierarchy   Compound List   File List  

GridDataOpsRed3.h

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


Quickstart     Users Guide     Programmers Reference     Installation      Examples     Download



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