[PATCH] Add centering and material viewing constructor to FieldEngine

Richard Guenther rguenth at tat.physik.uni-tuebingen.de
Sat Nov 8 17:44:11 UTC 2003


Hi!

The following patch adds sub-field view constructors to FieldEngine that
allow to view a centering point or a material while not affecting the
material or centering structure of the Field. It also deprecates the old
viewing constructors that tried to do the same, but failed.

Patch to use these from Field on the way.

Ok?

Richard.


2003Nov08  Richard Guenther <richard.guenther at uni-tuebingen.de>

	* src/Field/FieldEngine/FieldEngine.h: deprecate
	FieldEngine(model, subfield) and FieldEngine(centering, model).
	New centering and material sub-field viewing constructors.

===== FieldEngine.h 1.7 vs 1.8 =====
--- 1.7/r2/src/Field/FieldEngine/FieldEngine.h	Mon Oct 27 11:25:16 2003
+++ 1.8/r2/src/Field/FieldEngine/FieldEngine.h	Sat Nov  8 18:36:52 2003
@@ -37,7 +37,7 @@
 /** @file
  * @ingroup Field
  * @brief
- * FieldEngineBase and related classes.
+ * FieldEngine and FieldEngineBaseData classes.
  *
  * POOMA supports a flexible form
  * of "centering" that allows a hierarchy of multiple centering points per
@@ -69,6 +69,12 @@
 template<int Dim, class T, class EngineTag> class Engine;
 template<class Components> class ComponentWrapper;

+namespace Pooma {
+  // Tag classes for taking sub-field views.
+  struct MaterialViewTag {};
+  struct CenteringViewTag {};
+}
+

 /**
  * FieldEngineBaseData holds an engine and the relations.
@@ -83,6 +89,9 @@
     : engine_m()
   { }

+  /// Initializer to be used with an engine compatible layout or
+  /// similar initializer.
+
   template<class Initializer>
   FieldEngineBaseData(const Initializer &init)
     : engine_m(init)
@@ -192,9 +201,15 @@
   {
   }

-  /// Sub-field view constructor. This is when we want to construct a view of
-  /// one of the subFields in our top-level list.
-
+  ///@name Sub-field view constructors
+  //@{
+
+  /// Takes a view of
+  ///  - the specified material including all centering points,
+  ///    if there is more than one material
+  ///  - the specified centering, if there is only one material
+  /// These are weird semantics and thus this method is deprecated.
+
   FieldEngine(const This_t &model, int subField)
     : num_materials_m(1),
       stride_m(model.stride_m),
@@ -214,6 +229,8 @@
     }
   }

+  /// Takes a view of the specified centering point of the specified material.
+
   FieldEngine(const This_t &model, int m, int c)
     : num_materials_m(1),
       stride_m(model.stride_m),
@@ -227,6 +244,39 @@
     data_m = model.data_m + model.stride_m * m + c;
   }

+  /// Takes a view of the specified centering point from all
+  /// materials.
+
+  FieldEngine(const This_t &model, int c, const Pooma::CenteringViewTag&)
+    : num_materials_m(model.num_materials_m),
+      stride_m(model.stride_m),
+      physicalCellDomain_m(model.physicalCellDomain_m),
+      guards_m(model.guards_m),
+      mesh_m(model.mesh_m)
+  {
+    PAssert((c >= 0) && (c < model.centeringSize()));
+    centering_m = model.centering()[c];
+    data_m = model.data_m + c;
+  }
+
+  /// Takes a view of the specified material retaining all centering points.
+
+  FieldEngine(const This_t &model, int m, const Pooma::MaterialViewTag&)
+    : num_materials_m(1),
+      centering_m(model.centering_m),
+      stride_m(model.stride_m),
+      physicalCellDomain_m(model.physicalCellDomain_m),
+      guards_m(model.guards_m),
+      mesh_m(model.mesh_m)
+  {
+    PAssert((m >= 0) && (m < model.numMaterials()));
+    data_m = model.data_m + m * model.stride_m;
+  }
+
+  /// Takes a view of the specified centering point of the first material.
+  /// This is useless for fields with multiple materials and thus this
+  /// method is deprecated. Use FieldEngine(field, 0, c).
+
   FieldEngine(int c, const This_t &model)
     : num_materials_m(1),
       stride_m(model.stride_m),
@@ -238,6 +288,8 @@
     centering_m = model.centering()[c];
     data_m = model.data_m + c;
   }
+
+  //@}

   /// View constructors.




More information about the pooma-dev mailing list