[PATCH] remove (grow|shrink)InPlace(), add (grow|shrink)Left()

Richard Guenther rguenth at tat.physik.uni-tuebingen.de
Fri Aug 2 11:20:53 UTC 2002


Hi!

As suggested - this removes the nearly unused InPlace variants of the
domain grow/shrink functions. The compiler should optimize this anyway.

Note: this patch contains changes to documentation to be recognized by
the doxygen tool. This crept in from my local changes to the tree to
autogenerate reference documentation. I'd like to hear if having local
diversions of documentation is ok.

Richard.

--
Richard Guenther <richard.guenther at uni-tuebingen.de>
WWW: http://www.tat.physik.uni-tuebingen.de/~rguenth/
The GLAME Project: http://www.glame.de/
-------------- next part --------------
2002Aug02  Richard Guenther <richard.guenther at uni-tuebingen.de>

        * Domain/Shrink.h: Doxygen documentation.
	shrinkRightInPlace(), growRightInPlace(): removed.
	shrinkLeft(), growLeft(): new.
	* Field/FieldEngine/FieldEngine.h: Doxygen documentation.
	FieldEngine(): use shrinkRight(), shrink().
	* Layout/GuardLayers.h: Doxygen documentation.
	growInPlace(), shrinkInPlace(): removed.

-------------- next part --------------
Index: src/Domain/Shrink.h
===================================================================
RCS file: /home/pooma/Repository/r2/src/Domain/Shrink.h,v
retrieving revision 1.7
diff -u -r1.7 Shrink.h
--- src/Domain/Shrink.h	2000/07/25 01:08:39	1.7
+++ src/Domain/Shrink.h	2002/08/02 10:27:45
@@ -37,12 +37,15 @@
 
 //////////////////////////////////////////////////////////////////////
 
-//-----------------------------------------------------------------------------
-// Overview: 
-//
-// shrinkRight(Interval<Dim>,Loc<Dim>) returns an Interval<Dim> which is
-// Loc<Dim> shorter in each direction.
-//-----------------------------------------------------------------------------
+/** @file
+ * @ingroup Domain
+ * @brief
+ * Interval<Dim> shrinking and growing on either side by int or Loc<Dim>.
+ *
+ * Examples:
+ * - shrinkRight(Interval<1>(0, 4), 1) == Interval<1>(0, 3)
+ * - growLeft(Interval<1>(0, 4), 1) == Interval<1>(-1, 4)
+ */
 
 //-----------------------------------------------------------------------------
 // Typedefs:
@@ -59,94 +62,126 @@
 // Forward Declarations:
 //-----------------------------------------------------------------------------
 
-//-----------------------------------------------------------------------------
-//
-// Full Description:
-//
-//-----------------------------------------------------------------------------
 
+/// Shrinks the Interval dom from the right by s[i] in direction i.
 template<int Dim>
-Interval<Dim> &
-shrinkRightInPlace(Interval<Dim> &dom, const Loc<Dim> &s)
+inline Interval<Dim> 
+shrinkRight(const Interval<Dim> &dom, const Loc<Dim> &s)
 {
+  Interval<Dim> ret = Pooma::NoInit();
   for (int d = 0; d < Dim; ++d)
     {
       int a = dom[d].first();
       int b = dom[d].last() - s[d].first();
-      dom[d] = Interval<1>(a, b);
+      ret[d] = Interval<1>(a, b);
     }
-  return dom;
+  return ret;
 }
 
+/// Shrinks the Interval dom from the right by s in every direction.
 template<int Dim>
-Interval<Dim> &
-shrinkRightInPlace(Interval<Dim> &dom, int s)
+inline Interval<Dim> 
+shrinkRight(const Interval<Dim> &dom, int s)
 {
+  Interval<Dim> ret = Pooma::NoInit();
   for (int d = 0; d < Dim; ++d)
     {
       int a = dom[d].first();
       int b = dom[d].last() - s;
-      dom[d] = Interval<1>(a, b);
+      ret[d] = Interval<1>(a, b);
     }
-  return dom;
+  return ret;
 }
 
+/// Grows the Interval dom to the right by s[i] in direction i.
 template<int Dim>
-Interval<Dim> &
-growRightInPlace(Interval<Dim> &dom, const Loc<Dim> &s)
+inline Interval<Dim> 
+growRight(const Interval<Dim> &dom, const Loc<Dim> &s)
 {
+  Interval<Dim> ret = Pooma::NoInit();
   for (int d = 0; d < Dim; ++d)
     {
       int a = dom[d].first();
       int b = dom[d].last() + s[d].first();
-      dom[d] = Interval<1>(a, b);
+      ret[d] = Interval<1>(a, b);
     }
-  return dom;
+  return ret;
 }
 
+/// Grows the Interval dom to the right by s in every direction.
 template<int Dim>
-Interval<Dim> &
-growRightInPlace(Interval<Dim> &dom, int s)
+inline Interval<Dim> 
+growRight(const Interval<Dim> &dom, int s)
 {
+  Interval<Dim> ret = Pooma::NoInit();
   for (int d = 0; d < Dim; ++d)
     {
       int a = dom[d].first();
       int b = dom[d].last() + s;
-      dom[d] = Interval<1>(a, b);
+      ret[d] = Interval<1>(a, b);
     }
-  return dom;
+  return ret;
 }
 
+
+/// Shrinks the Interval dom from the left by s[i] in direction i.
 template<int Dim>
-inline Interval<Dim> 
-shrinkRight(const Interval<Dim> &dom, const Loc<Dim> &s)
+Interval<Dim>
+shrinkLeft(const Interval<Dim> &dom, const Loc<Dim> &s)
 {
-  Interval<Dim> ret(dom);
-  return shrinkRightInPlace(ret, s);
+  Interval<Dim> ret = Pooma::NoInit();
+  for (int d = 0; d < Dim; ++d)
+    {
+      int a = dom[d].first() + s[d].first();
+      int b = dom[d].last();
+      ret[d] = Interval<1>(a, b);
+    }
+  return ret;
 }
 
+/// Shrinks the Interval dom from the left by s in every direction.
 template<int Dim>
-inline Interval<Dim> 
-shrinkRight(const Interval<Dim> &dom, int s)
+Interval<Dim>
+shrinkLeft(const Interval<Dim> &dom, int s)
 {
-  Interval<Dim> ret(dom);
-  return shrinkRightInPlace(ret, s);
+  Interval<Dim> ret = Pooma::NoInit();
+  for (int d = 0; d < Dim; ++d)
+    {
+      int a = dom[d].first() + s;
+      int b = dom[d].last();
+      ret[d] = Interval<1>(a, b);
+    }
+  return ret;
 }
 
+/// Grows the Interval dom to the left by s[i] in direction i.
 template<int Dim>
-inline Interval<Dim> 
-growRight(const Interval<Dim> &dom, const Loc<Dim> &s)
+Interval<Dim>
+growLeft(const Interval<Dim> &dom, const Loc<Dim> &s)
 {
-  Interval<Dim> ret(dom);
-  return growRightInPlace(ret, s);
+  Interval<Dim> ret = Pooma::NoInit();
+  for (int d = 0; d < Dim; ++d)
+    {
+      int a = dom[d].first() - s[d].first();
+      int b = dom[d].last();
+      ret[d] = Interval<1>(a, b);
+    }
+  return ret;
 }
 
+/// Grows the Interval dom to the left by s in every direction.
 template<int Dim>
-inline Interval<Dim> 
-growRight(const Interval<Dim> &dom, int s)
+Interval<Dim>
+growLeft(const Interval<Dim> &dom, int s)
 {
-  Interval<Dim> ret(dom);
-  return growRightInPlace(ret, s);
+  Interval<Dim> ret = Pooma::NoInit();
+  for (int d = 0; d < Dim; ++d)
+    {
+      int a = dom[d].first() - s;
+      int b = dom[d].last();
+      ret[d] = Interval<1>(a, b);
+    }
+  return ret;
 }
 
 
Index: src/Field/FieldEngine/FieldEngine.h
===================================================================
RCS file: /home/pooma/Repository/r2/src/Field/FieldEngine/FieldEngine.h,v
retrieving revision 1.3
diff -u -r1.3 FieldEngine.h
--- src/Field/FieldEngine/FieldEngine.h	2002/07/01 22:25:53	1.3
+++ src/Field/FieldEngine/FieldEngine.h	2002/08/02 10:27:45
@@ -34,14 +34,16 @@
 #ifndef POOMA_FIELD_FIELDENGINE_FIELDENGINE_H
 #define POOMA_FIELD_FIELDENGINE_FIELDENGINE_H
 
-//-----------------------------------------------------------------------------
-// Overview: 
-// 
-// FieldEngineBase and related classes. POOMA supports a flexible form 
-// of "centering" that allows a hierarchy of multiple centering points per 
-// cell. The centering information, managed by the FieldEngineBase
-// class, is initialized using a flexible set of functors.
-//-----------------------------------------------------------------------------
+/** @file
+ * @ingroup Field
+ * @brief
+ * FieldEngineBase and related classes.
+ *
+ * POOMA supports a flexible form 
+ * of "centering" that allows a hierarchy of multiple centering points per 
+ * cell. The centering information, managed by the FieldEngineBase
+ * class, is initialized using a flexible set of functors.
+ */
 
 //-----------------------------------------------------------------------------
 // Includes:
@@ -69,7 +71,7 @@
 
 
 // ----------------------------------------------------------------------------
-// FieldEngineBaseData holds an engine and the relations.
+/// FieldEngineBaseData holds an engine and the relations.
 // ----------------------------------------------------------------------------
 
 template <int Dim, class T, class EngineTag>
@@ -119,8 +121,8 @@
 
 
 // ----------------------------------------------------------------------------
-// FieldEngineBase manages a hierarchy of engines, making it possible for
-// FieldEngine specializations to implement geometry-specific behavior only.
+/// FieldEngineBase manages a hierarchy of engines, making it possible for
+/// FieldEngine specializations to implement geometry-specific behavior only.
 // ----------------------------------------------------------------------------
 
 template<class Mesh, class T, class EngineTag>
@@ -146,7 +148,7 @@
   //---------------------------------------------------------------------------
   // Constructors.
 
-  // Default constructor.
+  /// Default constructor.
   
   FieldEngine()
     : num_materials_m(0),
@@ -154,7 +156,7 @@
       guards_m(0)
   { }
   
-  // General version takes centering, layout, mesh, materials
+  /// General version takes centering, layout, mesh, materials
 
   template<class Layout2>
   FieldEngine(const Centering<Dim> &centering, const Layout2 &layout,
@@ -166,8 +168,7 @@
       guards_m(layout.externalGuards()),
       mesh_m(mesh)
   {
-    shrinkInPlace(physicalCellDomain_m, guards_m);
-    shrinkRightInPlace(physicalCellDomain_m, 1);
+    physicalCellDomain_m = shrinkRight(shrink(physicalCellDomain_m, guards_m), 1);
     addSubFields();
     for (int m = 0; m < num_materials_m; ++m)
     {
@@ -178,7 +179,7 @@
     }
   }
 
-  // Copy constructor.
+  /// Copy constructor.
   
   FieldEngine(const This_t &model)
     : num_materials_m(model.num_materials_m),
@@ -191,8 +192,8 @@
   {
   }
 
-  // Sub-field view constructor. This is when we want to construct a view of
-  // one of the subFields in our top-level list.
+  /// Sub-field view constructor. This is when we want to construct a view of
+  /// one of the subFields in our top-level list.
   
   FieldEngine(const This_t &model, int subField)
     : num_materials_m(1),
@@ -238,7 +239,7 @@
     data_m = model.data_m + c;
   }
 
-  // View constructors.  
+  /// View constructors.  
 
   template<class T2, class EngineTag2>
   FieldEngine(const FieldEngine<Mesh, T2, EngineTag2> &model,
@@ -276,7 +277,7 @@
     }
   }
 
-  // This constructor handle weird things like range views.
+  /// This constructor handle weird things like range views.
 
   template<class Mesh2, class T2, class EngineTag2, class Domain>
   FieldEngine(const FieldEngine<Mesh2, T2, EngineTag2> &model,
@@ -437,7 +438,8 @@
 
 
   //---------------------------------------------------------------------------
-  // Accessors and modifiers.
+  //@name Accessors and modifiers.
+  //@{
     
   void addSubFields()
   {
@@ -449,7 +451,7 @@
     data_m.resize(size);
   }
 
-  // FIXME: This function is deprecated.
+  /// FIXME: This function is deprecated.
   inline int numSubFields() const
   {
     if (numMaterials() > 1)
@@ -509,8 +511,11 @@
     return num_materials_m;
   }
 
+  //@}
+
   //---------------------------------------------------------------------------
-  // Domain accessor functions. 
+  //@name Domain accessor functions. 
+  //@{
         
   inline Domain_t &physicalCellDomain()
   {
@@ -553,8 +558,11 @@
     return cellDomainToCenteringDomain(totalCellDomain(), centering_m, i);
   }
 
+  //@}
+
   //---------------------------------------------------------------------------
-  // Centering accessors.
+  //@name Centering accessors.
+  //@{
 
   const Centering<Dim> &centering() const
   {
@@ -566,8 +574,11 @@
       return centering_m.size();
     }
 
+  //@}
+
   //---------------------------------------------------------------------------
-  // Mesh accessors.
+  //@name Mesh accessors.
+  //@{
 
   Mesh &mesh()
   {
@@ -579,8 +590,10 @@
     return mesh_m;
   }        
 
+  //@}
+
   //---------------------------------------------------------------------------
-  // Make a distinct copy of this fieldEngineBase.   
+  /// Make a distinct copy of this fieldEngineBase.
  
   template<class Subject>
   void makeOwnCopy(const Subject &s)
@@ -609,10 +622,9 @@
 
 
   //---------------------------------------------------------------------------
-  // Domain translation function. 
-  
-  // FIXME: This function should go away.  Currently it's only used by
-  // the lagrangian field engine.
+  /// Domain translation function.
+  /// FIXME: This function should go away.  Currently it's only used by
+  /// the lagrangian field engine.
 
   inline Domain_t
   translateToVertexDomain(const Domain_t &d) const
@@ -633,7 +645,8 @@
   }
 
   //---------------------------------------------------------------------------
-  // Access material, centering subfield data.
+  //@name Access material, centering subfield data.
+  //@{
   
   inline Data_t &
   data(int material, int centering)
@@ -641,14 +654,15 @@
     PAssert(data_m.isValid());
     return data_m[material * stride_m + centering];
   }
-      
+
   inline const Data_t &
   data(int material, int centering) const
   {
     PAssert(data_m.isValid());
     return data_m[material * stride_m + centering];
   }
-      
+
+  //@}      
       
 private:
 
Index: src/Layout/GuardLayers.h
===================================================================
RCS file: /home/pooma/Repository/r2/src/Layout/GuardLayers.h,v
retrieving revision 1.9
diff -u -r1.9 GuardLayers.h
--- src/Layout/GuardLayers.h	2000/07/11 22:10:51	1.9
+++ src/Layout/GuardLayers.h	2002/08/02 10:27:45
@@ -34,11 +34,11 @@
 #ifndef POOMA_LAYOUT_GUARDLAYERS_H
 #define POOMA_LAYOUT_GUARDLAYERS_H
 
-//-----------------------------------------------------------------------------
-// Overview:
-//
-// A simple container for a set of guard layer specifications.
-//-----------------------------------------------------------------------------
+/** @file
+ * @ingroup Layout
+ * @brief
+ * A simple container for a set of guard layer specifications.
+ */
 
 //-----------------------------------------------------------------------------
 // Include Files
@@ -49,12 +49,12 @@
 
 //-----------------------------------------------------------------------------
 //
-// Full Description:
+/**
 //
 // This class is a simple container for two arrays of Dim integers, 
 // specifying the numbers of guard layers at the upper and lower extent
 // of each dimension. 
-//
+*/
 //-----------------------------------------------------------------------------
 
 template <int Dim>
@@ -259,43 +259,31 @@
 };
 
 template<int Dim>
-Interval<Dim> &growInPlace(Interval<Dim> &dom, const GuardLayers<Dim> &gcs)
+inline Interval<Dim> 
+grow(const Interval<Dim> &dom, const GuardLayers<Dim> &gcs)
 {
+  Interval<Dim> ret = Pooma::NoInit();
   for (int d = 0; d < Dim; ++d)
     {
       int a = dom[d].first() - gcs.lower(d);
       int b = dom[d].last()  + gcs.upper(d);
-      dom[d] = Interval<1>(a,b);
+      ret[d] = Interval<1>(a,b);
     }
-  return dom;
+  return ret;
 }
 
 template<int Dim>
-Interval<Dim> &shrinkInPlace(Interval<Dim> &dom, const GuardLayers<Dim> &gcs)
+inline Interval<Dim> 
+shrink(const Interval<Dim> &dom, const GuardLayers<Dim> &gcs)
 {
+  Interval<Dim> ret = Pooma::NoInit();
   for (int d = 0; d < Dim; ++d)
     {
       int a = dom[d].first() + gcs.lower(d);
       int b = dom[d].last()  - gcs.upper(d);
-      dom[d] = Interval<1>(a,b);
+      ret[d] = Interval<1>(a,b);
     }
-  return dom;
-}
-
-template<int Dim>
-inline Interval<Dim> 
-grow(const Interval<Dim> &dom, const GuardLayers<Dim> &gcs)
-{
-  Interval<Dim> ret(dom);
-  return growInPlace(ret, gcs);
-}
-
-template<int Dim>
-inline Interval<Dim> 
-shrink(const Interval<Dim> &dom, const GuardLayers<Dim> &gcs)
-{
-  Interval<Dim> ret(dom);
-  return shrinkInPlace(ret, gcs);
+  return ret;
 }
 
 //-----------------------------------------------------------------------------


More information about the pooma-dev mailing list