[cig-commits] commit: Make Update_V_2D use references instead of pointers, and simplify the boundary_positive logic a little

Mercurial hg at geodynamics.org
Sun Apr 24 06:02:26 PDT 2011


changeset:   198:25cba6ed00a5
user:        Walter Landry <wlandry at caltech.edu>
date:        Sat Apr 23 15:19:59 2011 -0700
files:       src/V_Boundary_Refine.h src/V_Boundary_Refine/Update_V_2D.C src/V_Boundary_Refine/refine.C
description:
Make Update_V_2D use references instead of pointers, and simplify the boundary_positive logic a little


diff -r 65904ea96fa8 -r 25cba6ed00a5 src/V_Boundary_Refine.h
--- a/src/V_Boundary_Refine.h	Sat Apr 23 14:01:59 2011 -0700
+++ b/src/V_Boundary_Refine.h	Sat Apr 23 15:19:59 2011 -0700
@@ -139,13 +139,12 @@ private:
    const bool &boundary_positive,
    const pdat::SideIndex &fine,
    const hier::Index &ip, const hier::Index &jp,
-   int &i,
-   int &j,
+   int &i, int &j,
    const int &i_max,
    const int &j_min,
    const int &j_max,
-   tbox::Pointer<pdat::SideData<double> > &v,
-   tbox::Pointer<pdat::SideData<double> > &v_fine) const;
+   pdat::SideData<double> &v,
+   pdat::SideData<double> &v_fine) const;
 
 };
 
diff -r 65904ea96fa8 -r 25cba6ed00a5 src/V_Boundary_Refine/Update_V_2D.C
--- a/src/V_Boundary_Refine/Update_V_2D.C	Sat Apr 23 14:01:59 2011 -0700
+++ b/src/V_Boundary_Refine/Update_V_2D.C	Sat Apr 23 15:19:59 2011 -0700
@@ -10,13 +10,12 @@ void SAMRAI::geom::V_Boundary_Refine::Up
  const bool &boundary_positive,
  const pdat::SideIndex &fine,
  const hier::Index &ip, const hier::Index &jp,
- int &i,
- int &j,
+ int &i, int &j,
  const int &i_max,
  const int &j_min,
  const int &j_max,
- tbox::Pointer<SAMRAI::pdat::SideData<double> > &v,
- tbox::Pointer<SAMRAI::pdat::SideData<double> > &v_fine) const
+ SAMRAI::pdat::SideData<double> &v,
+ SAMRAI::pdat::SideData<double> &v_fine) const
 {
   pdat::SideIndex center(fine);
   center.coarsen(hier::Index(2,2));
@@ -35,32 +34,23 @@ void SAMRAI::geom::V_Boundary_Refine::Up
       /* Compute the derivative at the nearest three coarse points and
          then interpolate */
 
-      const double dv_plus=(*v)(center+jp+ip)-(*v)(center+jp-ip);
-      const double dv_minus=(*v)(center-jp+ip)-(*v)(center-jp-ip);
-      const double dv_center=(*v)(center+ip)-(*v)(center-ip);
+      hier::Index ip_s(boundary_positive ? ip : -ip);
+
+      const double dv_plus=v(center+jp+ip_s)-v(center+jp-ip_s);
+      const double dv_minus=v(center-jp+ip_s)-v(center-jp-ip_s);
+      const double dv_center=v(center+ip_s)-v(center-ip_s);
 
       double dv_fine_minus, dv_fine_plus;
 
       quad_offset_interpolate(dv_plus,dv_minus,dv_center,
                               dv_fine_plus,dv_fine_minus);
 
-      hier::Index offset(ip);
+      hier::Index offset(ip_s*2);
 
-      if(boundary_positive)
-        {
-          offset[axis]=2;
-        }
-      else
-        {
-          offset[axis]=-2;
-          dv_fine_minus=-dv_fine_minus;
-          dv_fine_plus=-dv_fine_plus;
-        }
-        
       if(j%2==0)
         {
-          (*v_fine)(fine)=(*v_fine)(fine-offset) + dv_fine_minus/2;
-          (*v_fine)(fine+jp)=(*v_fine)(fine-offset+jp) + dv_fine_plus/2;
+          v_fine(fine)=v_fine(fine-offset) + dv_fine_minus/2;
+          v_fine(fine+jp)=v_fine(fine-offset+jp) + dv_fine_plus/2;
           /* Since we update two points on j at once, we increment j
              again.  This is ok, since the box in the 'i' direction is
              defined to be only one cell wide */
@@ -68,7 +58,7 @@ void SAMRAI::geom::V_Boundary_Refine::Up
         }
       else
         {
-          (*v_fine)(fine)=(*v_fine)(fine-offset) + dv_fine_plus/2;
+          v_fine(fine)=v_fine(fine-offset) + dv_fine_plus/2;
         }          
     }
   /* Set the value for the tangential direction */
@@ -77,17 +67,17 @@ void SAMRAI::geom::V_Boundary_Refine::Up
       double v_center, v_plus;
 
       v_center=
-        quad_offset_interpolate((*v)(center-jp),(*v)(center),(*v)(center+jp));
+        quad_offset_interpolate(v(center-jp),v(center),v(center+jp));
 
       if(i%2==0)
         {
-          (*v_fine)(fine)=v_center;
+          v_fine(fine)=v_center;
 
           if(i<i_max)
             {
-              v_plus=quad_offset_interpolate((*v)(center+ip-jp),(*v)(center+ip),
-                                             (*v)(center+ip+jp));
-              (*v_fine)(fine+ip)=(v_center+v_plus)/2;
+              v_plus=quad_offset_interpolate(v(center+ip-jp),v(center+ip),
+                                             v(center+ip+jp));
+              v_fine(fine+ip)=(v_center+v_plus)/2;
 
               /* Since we update two points on 'i' at once, we increment 'i' again.
                  This is ok, since the box in the 'j' direction is defined to be
@@ -97,9 +87,9 @@ void SAMRAI::geom::V_Boundary_Refine::Up
         }
       else
         {
-          v_plus=quad_offset_interpolate((*v)(center+ip-jp),(*v)(center+ip),
-                                         (*v)(center+ip+jp));
-          (*v_fine)(fine)=(v_center+v_plus)/2;
+          v_plus=quad_offset_interpolate(v(center+ip-jp),v(center+ip),
+                                         v(center+ip+jp));
+          v_fine(fine)=(v_center+v_plus)/2;
         }
     }
 }
diff -r 65904ea96fa8 -r 25cba6ed00a5 src/V_Boundary_Refine/refine.C
--- a/src/V_Boundary_Refine/refine.C	Sat Apr 23 14:01:59 2011 -0700
+++ b/src/V_Boundary_Refine/refine.C	Sat Apr 23 15:19:59 2011 -0700
@@ -109,11 +109,11 @@ void SAMRAI::geom::V_Boundary_Refine::re
                {
                case 0:
                  Update_V_2D(axis,boundary_direction,boundary_positive,fine,
-                             ip,jp,i,j,p_max[0],p_min[1],p_max[1],v,v_fine);
+                             ip,jp,i,j,p_max[0],p_min[1],p_max[1],*v,*v_fine);
                  break;
                case 1:
                  Update_V_2D(axis,boundary_direction,boundary_positive,fine,
-                             jp,ip,j,i,p_max[1],p_min[0],p_max[0],v,v_fine);
+                             jp,ip,j,i,p_max[1],p_min[0],p_max[0],*v,*v_fine);
                  break;
                default:
                  abort();



More information about the CIG-COMMITS mailing list