freepooma-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Freepooma-devel] [PATCH] Support "reverse" slice viewing.


From: Richard Guenther
Subject: [Freepooma-devel] [PATCH] Support "reverse" slice viewing.
Date: Thu, 14 Apr 2005 14:40:02 +0200 (CEST)

This patch adds the capability to apply a "reverse" slice view
to Brick and BrickView engines and Arrays and Fields with such
engines.  A "reverse" slice view provides you with a higher
dimensional view of a lower dimensional brick.  I.e. consider
the one-dimensional array

  Array<1> a(8) = iota(Interval<1>(8)).comp(0);

which you want to assign row-wise to an array of dimension 2:

  Array<2> b(8, 16);

instead of doing this with a loop and such issuing 16 iterates
like

  for (int i=0; i<16; ++i)
    b(SliceInterval<2, 1>(b.domain(), a.domain(), i)) = a;

you can now do this by assigning a reverse slice of array a to b:

  b = ReverseSliceView<Array<1>, SliceInterval<2, 1> >
        ::make(a, SliceInterval<2, 1>(b.domain(), a.domain(), 0),
               b.domain());

see how you specify how you would get from b to a by slicing
(ignore the slicing point which I choose to zero here) and the
original domain of b (as the SliceInterval does not store this).

This reverse slicing is for now only implemented in the Brick
and BrickView engines; other engines, like ExpressionEngine would
need to be updated, if there is a need for it.

Of course the compiler doesn't get to know it accesses the same
data for each row, but only the appropriate strides are zeroed
(the compiler could exploit this using value profiling and loop
versioning).

Not applied anywhere (I'm not sure I will, its a little hackish).

Richard.


2005Apr14  Richard Guenther <address@hidden>

        * src/Engine/BrickBase.h (BrickViewBase): Add new constructors
        for reverse slicing of Bricks and BrickViews.
        * src/Engine/BrickEngine.h (BrickView): Add new constructors
        for reverse slicing of Bricks and BrickViews.
        (NewEngine): Provide appropriate specializations.
        * src/Engine/tests/brickview_test1.cpp: Add simple test for
        reverse slicing.
        * src/Array/Array.h: Add ReverseSliceView specialization for
        Arrays.
        * src/Array/tests/array_test31.cpp: New test.
        * src/Array/tests/makefile: Add array_test31.
        * src/Field/FieldEngine/FieldEngine.h: Add new constructor
        for reverse slicing.
        * src/Field/Field.h: Add ReverseSliceView specialization for
        Fields.
        * src/Field/tests/Slice.cpp: Add reverse slicing operations.

Index: Array/Array.h
===================================================================
RCS file: /cvsroot/freepooma/freepooma/src/Array/Array.h,v
retrieving revision 1.155
diff -u -r1.155 Array.h
--- Array/Array.h       16 Dec 2004 14:16:12 -0000      1.155
+++ Array/Array.h       14 Apr 2005 12:23:08 -0000
@@ -1283,6 +1283,41 @@
     }
 };

+
+/**
+ * Traits class to instantiate a reverse slice view.  In addition
+ * to the workings of the View1 class you need to specify the resulting
+ * total domain to the make function.
+ */
+
+template <class Subject, class Domain>
+struct ReverseSliceView;
+
+template <int SliceDim, class T, class EngineTag, int Dim>
+struct ReverseSliceView<Array<SliceDim, T, EngineTag>, SliceInterval<Dim, 
SliceDim> >
+{
+  typedef Array<SliceDim, T, EngineTag> Subject_t;
+  typedef SliceInterval<Dim, SliceDim> Domain_t;
+
+  typedef typename NewEngine<typename Subject_t::Engine_t, Domain_t>::Type_t 
NewEngine_t;
+
+  // The return type.
+
+  typedef Array<Dim, T, typename NewEngine_t::Tag_t> Type_t;
+
+  inline static
+  Type_t make(const Subject_t &a, const SliceInterval<Dim, SliceDim>& dom,
+             const Interval<Dim>& totalDom)
+  {
+#if POOMA_BOUNDS_CHECK
+    PInsist(contains(a.domain(), dom.sliceDomain()),
+           "Array view bounds error.");
+#endif
+    return Type_t(NewEngine_t(a.engine(), dom, totalDom));
+  }
+};
+
+
 /**
  * Patch specialization for Array.
  */
Index: Array/tests/array_test31.cpp
===================================================================
RCS file: Array/tests/array_test31.cpp
diff -N Array/tests/array_test31.cpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ Array/tests/array_test31.cpp        14 Apr 2005 12:23:08 -0000
@@ -0,0 +1,95 @@
+// -*- C++ -*-
+//
+// Copyright (C) 2005  Richard Guenther
+//
+// This file is part of FreePOOMA.
+//
+// FreePOOMA is free software; you can redistribute it and/or modify it
+// under the terms of the Expat license.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Expat
+// license for more details.
+//
+// You should have received a copy of the Expat license along with
+// FreePOOMA; see the file LICENSE.
+//
+
+//-----------------------------------------------------------------------------
+// array_test31: verify widening strides
+//-----------------------------------------------------------------------------
+
+// Include files
+
+#include "Pooma/Arrays.h"
+#include "Utilities/Tester.h"
+#include <iostream>
+
+
+
+int main(int argc, char *argv[])
+{
+  // Initialize POOMA and output stream, using Tester class
+  Pooma::initialize(argc, argv);
+  Pooma::Tester tester(argc, argv);
+
+  Interval<2> domain2(8, 4);
+  Interval<1> domain1(8);
+
+  Array<2, int, Brick> a2d(domain2);
+  Array<1, int, Brick> a1d(domain1);
+
+  // init
+  a2d = 0;
+  a1d = iota(domain1).comp(0);
+
+  typedef ReverseSliceView<Array<1, int, Brick>, SliceInterval<2, 1> >::Type_t 
View_t;
+  View_t a1d2d = ReverseSliceView<Array<1, int, Brick>, SliceInterval<2, 1> >
+    ::make(a1d, SliceInterval<2, 1>(domain2, domain1, 0), domain2);
+
+  tester.out() << "a1d domain " << a1d.domain() << std::endl;
+  tester.out() << "a2d domain " << a2d.domain() << std::endl;
+  tester.out() << "a1d2d domain " << a1d2d.domain() << std::endl;
+
+  tester.out() << "a1d:" << std::endl;
+  tester.out() << a1d << std::endl;
+  tester.out() << "a1d2d:" << std::endl;
+  tester.out() << a1d2d << std::endl;
+
+  a2d = a1d2d;
+
+  tester.check("a2d is correct", all(a2d == iota(domain2).comp(0)));
+
+  tester.out() << a2d << std::endl;
+
+  // check if we can view a1d2d correctly
+  tester.check("viewing of a1d2d",
+              all(a1d2d(Interval<2>(Loc<1>(3), Interval<1>(4))) == 3));
+  tester.out() << a1d2d(Interval<2>(Loc<1>(3), Interval<1>(4))) << std::endl;
+
+  // Try something vastly more complex...
+  typedef View1<Array<2, int, Brick>, SliceInterval<2, 1> >::Type_t SlView_t;
+  SlView_t a2dv(a2d(SliceInterval<2, 1>(domain2, 3, Interval<1>(4))));
+  typedef ReverseSliceView<SlView_t, SliceInterval<2, 1> >::Type_t RSlView_t;
+  RSlView_t a2dv2d = ReverseSliceView<SlView_t, SliceInterval<2, 1> >
+    ::make(a2dv, SliceInterval<2, 1>(domain2, Interval<1>(4), 0), 
Interval<2>(4, 4));
+  a2d = iota(domain2).comp(0) + iota(domain2).comp(1);
+  tester.out() << a2d << std::endl;
+  tester.out() << a2dv << std::endl;
+  tester.out() << a2dv2d << std::endl;
+  a2d(Interval<2>(4, 4)) = a2dv2d;
+  tester.out() << a2d << std::endl;
+  tester.out() << a2dv << std::endl;
+
+  int retval = tester.results("array_test31");
+  Pooma::finalize();
+  return retval;
+}
+
+// ACL:rcsinfo
+// ----------------------------------------------------------------------
+// $RCSfile: array_test30.cpp,v $   $Author: richard $
+// $Revision: 1.2 $   $Date: 2004/11/01 18:16:14 $
+// ----------------------------------------------------------------------
+// ACL:rcsinfo
Index: Array/tests/makefile
===================================================================
RCS file: /cvsroot/freepooma/freepooma/src/Array/tests/makefile,v
retrieving revision 1.56
diff -u -r1.56 makefile
--- Array/tests/makefile        1 Nov 2004 18:16:14 -0000       1.56
+++ Array/tests/makefile        14 Apr 2005 12:23:08 -0000
@@ -13,7 +13,7 @@
        array_test12 array_test13 array_test14 array_test15 array_test16 \
        array_test17 array_test18 array_test19 array_test20 array_test21 \
        array_test22 array_test23 array_test24 array_test25 array_test26 \
-       array_test27 array_test28 array_test29 array_test30
+       array_test27 array_test28 array_test29 array_test30 array_test31

 default:: build

Index: Engine/BrickBase.h
===================================================================
RCS file: /cvsroot/freepooma/freepooma/src/Engine/BrickBase.h,v
retrieving revision 1.25
diff -u -r1.25 BrickBase.h
--- Engine/BrickBase.h  13 Apr 2005 20:42:04 -0000      1.25
+++ Engine/BrickBase.h  14 Apr 2005 12:23:08 -0000
@@ -538,6 +538,27 @@
     sliceInit(bbase.originalStrides(), SliceRange<BaseDim,Dim>(dom));
   }

+  template<int SliceDim>
+  BrickViewBase(const BrickBase<SliceDim> &bbase,
+               const SliceInterval<Dim,SliceDim> &dom,
+               const Interval<Dim> &totalDomain)
+    : domain_m(Pooma::NoInit()),
+      baseOffset_m(bbase.offset()),
+      compressibleBase_m(bbase.compressibleBase())
+  {
+    sliceInit(bbase.originalStrides(), dom, totalDomain);
+  }
+
+  template<int SliceDim>
+  BrickViewBase(const BrickViewBase<SliceDim> &bvbase,
+               const SliceInterval<Dim,SliceDim> &dom,
+               const Interval<Dim> &totalDomain)
+    : domain_m(Pooma::NoInit()),
+      baseOffset_m(bvbase.baseOffset())
+  {
+    sliceInit(bvbase, dom, totalDomain);
+  }
+
   template <int BaseDim>
   BrickViewBase(const BrickViewBase<BaseDim> &bvbase,
                 const SliceRange<BaseDim,Dim> &dom)
@@ -706,9 +727,16 @@
   template<int BaseDim>
   void sliceInit(const int *baseStrides,
                 const SliceRange<BaseDim,Dim> &dom);
+  template<int SliceDim>
+  void sliceInit(const int *baseStrides,
+                const SliceInterval<Dim,SliceDim> &dom,
+                const Interval<Dim> &totalDomain);

   template<int BaseDim>
   void sliceInit(const BrickViewBase<BaseDim>&, const SliceRange<BaseDim, 
Dim>&);
+  template<int SliceDim>
+  void sliceInit(const BrickViewBase<SliceDim>&, const SliceInterval<Dim, 
SliceDim>&,
+                const Interval<Dim> &totalDomain);

   void viewInit(const This_t &, const Range<Dim> &domain);

@@ -833,6 +861,66 @@
 }

 template <int Dim>
+template<int SliceDim>
+void
+BrickViewBase<Dim>::
+sliceInit(const int *baseStrides,
+         const SliceInterval<Dim,SliceDim> &dom,
+         const Interval<Dim> &domain)
+{
+  // compute the dt-dim base stride along in the loop
+  int dt = 0;
+  for (int d = 0; d < Dim; ++d)
+  {
+    domain_m[d]  = Interval<1>(domain[d].length());
+    if (!dom.ignorable(d))
+    {
+      PBoundAssert(dt < SliceDim);
+      strides_m[d] = baseStrides[dt];
+      baseOffset_m += domain[dt].first() * baseStrides[dt];
+      ++dt;
+    } else {
+      strides_m[d] = 0;
+    }
+  }
+
+  PBoundAssert(dt == SliceDim);
+
+  for (int d = 0; d < Dim; ++d)
+    ostrides_m[d] = strides_m[d];
+}
+
+template <int Dim>
+template<int SliceDim>
+void
+BrickViewBase<Dim>::
+sliceInit(const BrickViewBase<SliceDim>& bvbase,
+         const SliceInterval<Dim,SliceDim> &dom,
+         const Interval<Dim> &domain)
+{
+  // compute the dt-dim base stride along in the loop
+  int dt = 0;
+  for (int d = 0; d < Dim; ++d)
+  {
+    domain_m[d]  = Interval<1>(domain[d].length());
+    if (!dom.ignorable(d))
+    {
+      PBoundAssert(dt < SliceDim);
+      strides_m[d] = bvbase.originalStrides()[dt];
+      baseOffset_m += domain[dt].first() * bvbase.originalStrides()[dt];
+      ++dt;
+    } else {
+      strides_m[d] = 0;
+    }
+  }
+
+  PBoundAssert(dt == SliceDim);
+
+  for (int d = 0; d < Dim; ++d)
+    ostrides_m[d] = strides_m[d];
+}
+
+template <int Dim>
 template<int BaseDim>
 void
 BrickViewBase<Dim>::
Index: Engine/BrickEngine.h
===================================================================
RCS file: /cvsroot/freepooma/freepooma/src/Engine/BrickEngine.h,v
retrieving revision 1.138
diff -u -r1.138 BrickEngine.h
--- Engine/BrickEngine.h        2 Dec 2004 12:23:13 -0000       1.138
+++ Engine/BrickEngine.h        14 Apr 2005 12:23:08 -0000
@@ -514,6 +514,39 @@
     PAssert(e.dataBlock().isAtBeginning());
   }

+  /// Build a BrickView from a lower-dimensional Brick, a 
SliceInterval<Dim,Dim2>
+  /// denoting a reverse slicing operation and the resulting total domain.
+
+  template <int Dim2>
+  Engine(const Engine<Dim2,T,Brick> &e, const SliceInterval<Dim,Dim2> &dom,
+        const Interval<Dim> &totalDomain)
+    : Base_t(e, dom, totalDomain), dataBlock_m(e.dataBlock(), 
e.offset(dom.sliceDomain())),
+      data_m(dataBlock_m.currentPointer())
+  {
+  }
+
+  /// Build a BrickView from a lower-dimensional BrickView, a 
SliceInterval<Dim,Dim2>
+  /// denoting a reverse slicing operation and the resulting total domain.
+
+  template <int Dim2>
+  Engine(const Engine<Dim2,T,BrickView> &e, const SliceInterval<Dim,Dim2> &dom,
+        const Interval<Dim> &totalDomain)
+    : Base_t(e, dom, totalDomain), dataBlock_m(e.dataBlock(), 
e.offset(dom.sliceDomain())),
+      data_m(dataBlock_m.currentPointer())
+  {
+  }
+
+  /// Build a BrickView from a lower-dimensional BrickViewU, a 
SliceInterval<Dim,Dim2>
+  /// denoting a reverse slicing operation and the resulting total domain.
+
+  template <int Dim2>
+  Engine(const Engine<Dim2,T,BrickViewU> &e, const SliceInterval<Dim,Dim2> 
&dom,
+        const Interval<Dim> &totalDomain)
+    : Base_t(e, dom, totalDomain), dataBlock_m(e.dataBlock(), 
e.offset(dom.sliceDomain())),
+      data_m(dataBlock_m.currentPointer())
+  {
+  }
+
   /// Build a BrickView from another BrickView and a domain like
   /// an Interval<Dim> or Range<Dim>.

@@ -1095,6 +1128,23 @@
   typedef Engine<SliceDim,T,BrickView> Type_t;
 };

+template <int Dim, class T, int SliceDim>
+struct NewEngine<Engine<SliceDim,T,Brick>, SliceInterval<Dim,SliceDim> >
+{
+  typedef Engine<Dim,T,BrickView> Type_t;
+};
+
+template <int Dim, class T, int SliceDim>
+struct NewEngine<Engine<SliceDim,T,BrickView>, SliceInterval<Dim,SliceDim> >
+{
+  typedef Engine<Dim,T,BrickView> Type_t;
+};
+
+template <int Dim, class T, int SliceDim>
+struct NewEngine<Engine<SliceDim,T,BrickViewU>, SliceInterval<Dim,SliceDim> >
+{
+  typedef Engine<Dim,T,BrickView> Type_t;
+};

 template <int Dim, class T>
 struct NewEngine<Engine<Dim,T,BrickView>, Interval<Dim> >
Index: Engine/tests/brickview_test1.cpp
===================================================================
RCS file: /cvsroot/freepooma/freepooma/src/Engine/tests/brickview_test1.cpp,v
retrieving revision 1.16
diff -u -r1.16 brickview_test1.cpp
--- Engine/tests/brickview_test1.cpp    1 Nov 2004 18:16:38 -0000       1.16
+++ Engine/tests/brickview_test1.cpp    14 Apr 2005 12:23:08 -0000
@@ -42,6 +42,20 @@
     Interval<1> I(5);
     Interval<5> BD(I,I,I,I,I);

+    Engine<1,double,Brick> bx(I);
+    for (int i=0; i<5; ++i)
+      bx(i) = i;
+
+    SliceInterval<5, 1> slIx(BD, 0, 0, 0, AllDomain<1>(), 0);
+    NewEngine<Engine<1,double,Brick>, SliceInterval<5,1> >::Type_t bxX(bx, 
slIx, BD);
+    for (int i4 = 0; i4 < bxX.domain()[4].length(); ++i4)
+      for (int i3 = 0; i3 < bxX.domain()[3].length(); ++i3)
+       for (int i2 = 0; i2 < bxX.domain()[2].length(); ++i2)
+         for (int i1 = 0; i1 < bxX.domain()[1].length(); ++i1)
+           for (int i0 = 0; i0 < bxX.domain()[0].length(); ++i0)
+             if (bxX(i0,i1,i2,i3,i4) != bx(i3))
+               tester.check(false);
+
     Brick5_t b(BD);

     for (int i4 = 0; i4 < b.domain()[4].length(); ++i4)
Index: Field/Field.h
===================================================================
RCS file: /cvsroot/freepooma/freepooma/src/Field/Field.h,v
retrieving revision 1.91
diff -u -r1.91 Field.h
--- Field/Field.h       14 Apr 2005 12:03:07 -0000      1.91
+++ Field/Field.h       14 Apr 2005 12:23:08 -0000
@@ -86,6 +86,9 @@
 template<class Subject, class Domain, bool SV>
 struct View1Implementation;

+template <class Subject, class Domain>
+struct ReverseSliceView;
+
 class RelationListItem;

 template <int Dim>
@@ -837,6 +840,35 @@
     }
 };

+/**
+ * Traits class to instantiate a reverse slice view.  In addition
+ * to the workings of the View1 class you need to specify the resulting
+ * total domain to the make function.
+ */
+
+template <int SliceDim, class Mesh, class T, class EngineTag, int Dim>
+struct ReverseSliceView<Field<Mesh, T, EngineTag>, SliceInterval<Dim, 
SliceDim> >
+{
+  typedef Field<Mesh, T, EngineTag> Subject_t;
+  typedef SliceInterval<Dim, SliceDim> Domain_t;
+
+  typedef typename NewEngine<typename Subject_t::Engine_t, Domain_t>::Type_t 
NewEngine_t;
+
+  // The return type.
+
+  typedef Field<NoMesh<Dim>, T, typename NewEngine_t::Tag_t> Type_t;
+
+  inline static
+  Type_t make(const Subject_t &a, const SliceInterval<Dim, SliceDim>& dom,
+             const Interval<Dim>& totalDom)
+  {
+    CTAssert(Mesh::dimensions == SliceDim);
+    PBoundInsist(contains(a.domain(), dom.sliceDomain()),
+           "Field view bounds error.");
+    return Type_t(typename Type_t::FieldEngine_t(a.fieldEngine(), dom, 
totalDom));
+  }
+};
+

 //-----------------------------------------------------------------------------
 // Patch specialization for Field.
Index: Field/FieldEngine/FieldEngine.h
===================================================================
RCS file: /cvsroot/freepooma/freepooma/src/Field/FieldEngine/FieldEngine.h,v
retrieving revision 1.12
diff -u -r1.12 FieldEngine.h
--- Field/FieldEngine/FieldEngine.h     13 Apr 2005 18:48:27 -0000      1.12
+++ Field/FieldEngine/FieldEngine.h     14 Apr 2005 12:23:08 -0000
@@ -363,6 +363,16 @@
     initSlice(model, d);
   }

+  /// This constructor handles reverse SliceInterval views.
+
+  template<class Mesh2, class EngineTag2>
+  FieldEngine(const FieldEngine<Mesh2, T, EngineTag2> &model,
+             const SliceInterval<Dim, Mesh2::dimensions> &d,
+             const Interval<Dim>& totalDomain)
+  {
+    initSlice(model, d, totalDomain);
+  }
+
   template<class T2, class EngineTag2>
   FieldEngine(const FieldEngine<Mesh, T2, EngineTag2> &model,
               const INode<Dim> &i)
@@ -808,6 +818,65 @@
                                    guardLayers()));
   }

+  /// Reverse slicing with SliceInterval.
+
+  template <class FE>
+  void initSlice(const FE& model,
+                const SliceInterval<Dim, FE::dimensions>& d,
+                const Interval<Dim>& totalDomain)
+  {
+    // We cannot deal with multiple centering points here, as we
+    // really would need to remove some of them(?)
+    PAssert(model.centeringSize() == 1);
+
+    num_materials_m = model.numMaterials();
+    stride_m = 1;
+
+    // First, initialize the centering with a one with
+    // increased dimensionality.  Also handle guards_m and
+    // physicalCellDomain_m here.
+    typename Centering<Dim>::Orientation orientation;
+    typename Centering<Dim>::Position position;
+    int j=0;
+    for (int i=0; i<Dim; ++i)
+      {
+       if (d.ignorable(i)) {
+         if (model.centering().centeringType() == CellType) {
+           orientation[i] = 1;
+           position(i) = 0.5;
+         } else {
+           orientation[i] = 0;
+           position(i) = 0.0;
+         }
+         guards_m.lower(i) = 0;
+         guards_m.upper(i) = 0;
+         physicalCellDomain_m[i] = totalDomain[i];
+       } else {
+         orientation[i] = model.centering().orientation(0)[j];
+         position(i) = model.centering().position(0)(j);
+         guards_m.lower(i) = model.guardLayers().lower(j);
+         guards_m.upper(i) = model.guardLayers().upper(j);
+         physicalCellDomain_m[i] = model.physicalCellDomain()[j];
+         ++j;
+       }
+      }
+    centering_m.addValue(orientation, position);
+
+    // Now we can safely add and initialize our subfields
+    addSubFields();
+    for (int m = 0; m < numMaterials(); ++m)
+    {
+      typedef typename NewEngine<typename FE::Engine_t, SliceInterval<Dim, 
FE::dimensions> >::Type_t NewEngine_t;
+      data(m, 0) = Data_t(NewEngine_t(model.data(m, 0).engine(), d, 
totalDomain),
+                          model.data(m, 0).relations());
+    }
+
+    // Initialize the mesh from the physical vertex domain
+    // and guards.
+    mesh_m = Mesh(DomainLayout<Dim>(growRight(physicalCellDomain(), 1),
+                                   guardLayers()));
+  }
+

   unsigned int num_materials_m;
   Centering<Dim> centering_m;
Index: Field/tests/Slice.cpp
===================================================================
RCS file: /cvsroot/freepooma/freepooma/src/Field/tests/Slice.cpp,v
retrieving revision 1.1
diff -u -r1.1 Slice.cpp
--- Field/tests/Slice.cpp       13 Apr 2005 18:48:27 -0000      1.1
+++ Field/tests/Slice.cpp       14 Apr 2005 12:23:08 -0000
@@ -28,6 +28,7 @@
 #include "Utilities/Tester.h"


+
 int main(int argc, char *argv[])
 {
   Pooma::initialize(argc,argv);
@@ -82,6 +83,26 @@
               all(f(sr.totalDomain()) == 1));


+  // Do an evil reverse slicing operation.  Use sv from above as base.
+  tester.out() << "Checking ReverseSliceView with SliceInterval:" << std::endl;
+  typedef ReverseSliceView<View1<Field_t, SliceInterval<2, 1> >::Type_t,
+    SliceInterval<2, 1> >::Type_t RSView_t;
+  RSView_t sv2d = ReverseSliceView<View1<Field_t, SliceInterval<2, 1> 
>::Type_t,
+    SliceInterval<2, 1> >::make(sv, si, f.physicalDomain());
+
+  tester.out() << sv2d << std::endl;
+  tester.out() << f << std::endl;
+
+  // Another one with tmp as base.
+  typedef ReverseSliceView<Field<UniformRectilinearMesh<1>, int, Brick>,
+    SliceInterval<2, 1> >::Type_t RSView2_t;
+  RSView2_t tmp2d = ReverseSliceView<Field<UniformRectilinearMesh<1>, int, 
Brick>,
+    SliceInterval<2, 1> >::make(tmp, si, f.physicalDomain());
+  f = tmp2d;
+  tester.out() << f << std::endl;
+  tester.check("Assign of ReverseSliceView",
+              all(f == 2+iota(f.physicalDomain()).comp(1)));
+
   int ret = tester.results("Slice");
   Pooma::finalize();
   return ret;





reply via email to

[Prev in Thread] Current Thread [Next in Thread]