freepooma-devel
[Top][All Lists]
Advanced

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

[pooma-dev] Patch: ScalarCode fixes


From: Stephen A. Smith
Subject: [pooma-dev] Patch: ScalarCode fixes
Date: Wed, 28 Mar 2001 14:55:30 -0700

* IndirectionEngine.h
        minor fix to reflect a change in PETE from last fall

* Evaluator/LoopApply.h
* Evaluator/MultiArgEvaluator.h
* Evaluator/ScalarCode.h
* Evaluator/ScalarCodeInfo.h
* Functions/MultiArg.h
* NewField/tests/ScalarCode.cpp
* NewField/tests/makefile
       fixed a problem that John Hall found with ScalarCode
       that index into guard layers.  The problem came from
       the loops in LoopApply.h (currently this is only used
       by ScalarCode).  Also, fixed the evaluator to apply
       updaters to the fields used, and made sure the interior
       guard layers are filled.  While working on this, I expanded
       the test code ScalarCode.cpp to test for these issues
       and filled in the MultiArg structures and functions for
       4,5, and 6 arguments.

       Note: NewField is still missing a couple features to
       support messaging, so ScalarCode has yet to be tested
       in parallel.

Tested on  sequential, Linux, with egcs-2.95.2
Reviewed by Scott Haney

     Stephen Smith


? EB
? EO
? EP
? EPO
? difs
? difs2
? difs3
? Array/tests/EB
? Array/tests/EO
? Array/tests/EP
? Array/tests/EPO
? BConds/tests/EB
? BConds/tests/EO
? BConds/tests/EP
? BConds/tests/EPO
? Connect/EB
? Connect/EO
? Connect/EP
? Connect/EPO
? Connect/Lux/EB
? Connect/Lux/EO
? Connect/Lux/EP
? Connect/Lux/EPO
? Connect/Lux/tests/EB
? Connect/Lux/tests/EO
? Connect/Lux/tests/EP
? Connect/Lux/tests/EPO
? Connect/Paws/EB
? Connect/Paws/EO
? Connect/Paws/EP
? Connect/Paws/EPO
? Connect/Paws/tests/EB
? Connect/Paws/tests/EO
? Connect/Paws/tests/EP
? Connect/Paws/tests/EPO
? CoordinateSystems/tests/EB
? CoordinateSystems/tests/EO
? CoordinateSystems/tests/EP
? CoordinateSystems/tests/EPO
? DataBrowser/EB
? DataBrowser/EO
? DataBrowser/EP
? DataBrowser/EPO
? DataBrowser/tests/EB
? DataBrowser/tests/EO
? DataBrowser/tests/EP
? DataBrowser/tests/EPO
? Domain/EB
? Domain/EO
? Domain/EP
? Domain/EPO
? Domain/tests/EB
? Domain/tests/EO
? Domain/tests/EP
? Domain/tests/EPO
? DynamicArray/tests/EB
? DynamicArray/tests/EO
? DynamicArray/tests/EP
? DynamicArray/tests/EPO
? Engine/EB
? Engine/EO
? Engine/EP
? Engine/EPO
? Engine/tests/EB
? Engine/tests/EO
? Engine/tests/EP
? Engine/tests/EPO
? Evaluator/tests/EB
? Evaluator/tests/EO
? Evaluator/tests/EP
? Evaluator/tests/EPO
? Field/DiffOps/tests/EB
? Field/DiffOps/tests/EO
? Field/DiffOps/tests/EP
? Field/DiffOps/tests/EPO
? Field/tests/EB
? Field/tests/EO
? Field/tests/EP
? Field/tests/EPO
? Functions/tests/EB
? Functions/tests/EO
? Functions/tests/EP
? Functions/tests/EPO
? Geometry/EB
? Geometry/EO
? Geometry/EP
? Geometry/EPO
? Geometry/tests/EB
? Geometry/tests/EO
? Geometry/tests/EP
? Geometry/tests/EPO
? IO/EB
? IO/EO
? IO/EP
? IO/EPO
? IO/tests/EB
? IO/tests/EO
? IO/tests/EP
? IO/tests/EPO
? Layout/EB
? Layout/EO
? Layout/EP
? Layout/EPO
? Layout/tests/EB
? Layout/tests/EO
? Layout/tests/EP
? Layout/tests/EPO
? Meshes/tests/EB
? Meshes/tests/EO
? Meshes/tests/EP
? Meshes/tests/EPO
? NewField/tests/EB
? NewField/tests/EO
? NewField/tests/EP
? NewField/tests/EPO
? NewField/tests/BasicTest1.out
? NewField/tests/scalar.cpp
? Particles/EB
? Particles/EO
? Particles/EP
? Particles/EPO
? Particles/tests/EB
? Particles/tests/EO
? Particles/tests/EP
? Particles/tests/EPO
? Partition/EB
? Partition/EO
? Partition/EP
? Partition/EPO
? Partition/tests/EB
? Partition/tests/EO
? Partition/tests/EP
? Partition/tests/EPO
? Pooma/EB
? Pooma/EO
? Pooma/EP
? Pooma/EPO
? Pooma/tests/EB
? Pooma/tests/EO
? Pooma/tests/EP
? Pooma/tests/EPO
? Threads/EB
? Threads/EO
? Threads/EP
? Threads/EPO
? Threads/IterateSchedulers/EB
? Threads/IterateSchedulers/EO
? Threads/IterateSchedulers/EP
? Threads/IterateSchedulers/EPO
? Threads/tests/EB
? Threads/tests/EO
? Threads/tests/EP
? Threads/tests/EPO
? Tiny/tests/EB
? Tiny/tests/EO
? Tiny/tests/EP
? Tiny/tests/EPO
? Transform/tests/EB
? Transform/tests/EO
? Transform/tests/EP
? Transform/tests/EPO
? Tulip/EB
? Tulip/EO
? Tulip/EP
? Tulip/EPO
? Tulip/tests/EB
? Tulip/tests/EO
? Tulip/tests/EP
? Tulip/tests/EPO
? Utilities/EB
? Utilities/EO
? Utilities/EP
? Utilities/EPO
? Utilities/tests/EB
? Utilities/tests/EO
? Utilities/tests/EP
? Utilities/tests/EPO
Index: Engine/IndirectionEngine.h
===================================================================
RCS file: /home/pooma/Repository/r2/src/Engine/IndirectionEngine.h,v
retrieving revision 1.21
diff -r1.21 IndirectionEngine.h
302c302
<                         OpAdd(), Combine_t()
---
>                         Combine_t()
Index: Evaluator/LoopApply.h
===================================================================
RCS file: /home/pooma/Repository/r2/src/Evaluator/LoopApply.h,v
retrieving revision 1.2
diff -r1.2 LoopApply.h
102,103c102,103
<     int e0 = domain[0].length();
<     for (int i0 = f0; i0<e0; ++i0)
---
>     int e0 = domain[0].last();
>     for (int i0 = f0; i0 <= e0; ++i0)
113,116c113,116
<     int e0 = domain[0].length();
<     int e1 = domain[1].length();
<     for (int i1 = f1; i1<e1; ++i1)
<       for (int i0 = f0; i0<e0; ++i0)
---
>     int e0 = domain[0].last();
>     int e1 = domain[1].last();
>     for (int i1 = f1; i1 <= e1; ++i1)
>       for (int i0 = f0; i0 <= e0; ++i0)
127,132c127,132
<     int e0 = domain[0].length();
<     int e1 = domain[1].length();
<     int e2 = domain[2].length();
<     for (int i2 = f2; i2<e2; ++i2)
<       for (int i1 = f1; i1<e1; ++i1)
<       for (int i0 = f0; i0<e0; ++i0)
---
>     int e0 = domain[0].last();
>     int e1 = domain[1].last();
>     int e2 = domain[2].last();
>     for (int i2 = f2; i2 <= e2; ++i2)
>       for (int i1 = f1; i1 <= e1; ++i1)
>       for (int i0 = f0; i0 <= e0; ++i0)
144,151c144,151
<     int e0 = domain[0].length();
<     int e1 = domain[1].length();
<     int e2 = domain[2].length();
<     int e3 = domain[3].length();
<     for (int i3 = f3; i3<e3; ++i3)
<       for (int i2 = f2; i2<e2; ++i2)
<       for (int i1 = f1; i1<e1; ++i1)
<         for (int i0 = f0; i0<e0; ++i0)
---
>     int e0 = domain[0].last();
>     int e1 = domain[1].last();
>     int e2 = domain[2].last();
>     int e3 = domain[3].last();
>     for (int i3 = f3; i3 <= e3; ++i3)
>       for (int i2 = f2; i2 <= e2; ++i2)
>       for (int i1 = f1; i1 <= e1; ++i1)
>         for (int i0 = f0; i0 <= e0; ++i0)
164,173c164,173
<     int e0 = domain[0].length();
<     int e1 = domain[1].length();
<     int e2 = domain[2].length();
<     int e3 = domain[3].length();
<     int e4 = domain[4].length();
<     for (int i4 = f4; i4<e4; ++i4)
<       for (int i3 = f3; i3<e3; ++i3)
<       for (int i2 = f2; i2<e2; ++i2)
<         for (int i1 = f1; i1<e1; ++i1)
<           for (int i0 = f0; i0<e0; ++i0)
---
>     int e0 = domain[0].last();
>     int e1 = domain[1].last();
>     int e2 = domain[2].last();
>     int e3 = domain[3].last();
>     int e4 = domain[4].last();
>     for (int i4 = f4; i4 <= e4; ++i4)
>       for (int i3 = f3; i3 <= e3; ++i3)
>       for (int i2 = f2; i2 <= e2; ++i2)
>         for (int i1 = f1; i1 <= e1; ++i1)
>           for (int i0 = f0; i0 <= e0; ++i0)
187,198c187,198
<     int e0 = domain[0].length();
<     int e1 = domain[1].length();
<     int e2 = domain[2].length();
<     int e3 = domain[3].length();
<     int e4 = domain[4].length();
<     int e5 = domain[5].length();
<     for (int i5 = f5; i5<e5; ++i5)
<       for (int i4 = f4; i4<e4; ++i4)
<       for (int i3 = f3; i3<e3; ++i3)
<         for (int i2 = f2; i2<e2; ++i2)
<           for (int i1 = f1; i1<e1; ++i1)
<             for (int i0 = f0; i0<e0; ++i0)
---
>     int e0 = domain[0].last();
>     int e1 = domain[1].last();
>     int e2 = domain[2].last();
>     int e3 = domain[3].last();
>     int e4 = domain[4].last();
>     int e5 = domain[5].last();
>     for (int i5 = f5; i5 <= e5; ++i5)
>       for (int i4 = f4; i4 <= e4; ++i4)
>       for (int i3 = f3; i3 <= e3; ++i3)
>         for (int i2 = f2; i2 <= e2; ++i2)
>           for (int i1 = f1; i1 <= e1; ++i1)
>             for (int i0 = f0; i0 <= e0; ++i0)
213,226c213,226
<     int e0 = domain[0].length();
<     int e1 = domain[1].length();
<     int e2 = domain[2].length();
<     int e3 = domain[3].length();
<     int e4 = domain[4].length();
<     int e5 = domain[5].length();
<     int e6 = domain[6].length();
<     for (int i6 = f6; i6<e6; ++i6)
<       for (int i5 = f5; i5<e5; ++i5)
<       for (int i4 = f4; i4<e4; ++i4)
<         for (int i3 = f3; i3<e3; ++i3)
<           for (int i2 = f2; i2<e2; ++i2)
<             for (int i1 = f1; i1<e1; ++i1)
<               for (int i0 = f0; i0<e0; ++i0)
---
>     int e0 = domain[0].last();
>     int e1 = domain[1].last();
>     int e2 = domain[2].last();
>     int e3 = domain[3].last();
>     int e4 = domain[4].last();
>     int e5 = domain[5].last();
>     int e6 = domain[6].last();
>     for (int i6 = f6; i6 <= e6; ++i6)
>       for (int i5 = f5; i5 <= e5; ++i5)
>       for (int i4 = f4; i4 <= e4; ++i4)
>         for (int i3 = f3; i3 <= e3; ++i3)
>           for (int i2 = f2; i2 <= e2; ++i2)
>             for (int i1 = f1; i1 <= e1; ++i1)
>               for (int i0 = f0; i0 <= e0; ++i0)
Index: Evaluator/MultiArgEvaluator.h
===================================================================
RCS file: /home/pooma/Repository/r2/src/Evaluator/MultiArgEvaluator.h,v
retrieving revision 1.5
diff -r1.5 MultiArgEvaluator.h
75a76
> struct PerformUpdateTag;
122a124,136
> struct UpdateNotifier
> {
>   UpdateNotifier()
>   {
>   }
> 
>   template<class A>
>   void operator()(const A &a) const
>   {
>     forEach(a, PerformUpdateTag(), NullCombine());
>   }
> };
> 
149a164,165
>     applyMultiArg(multiArg, UpdateNotifier());
> 
247d262
<     ExpressionApply<Inter_t> tag(inter);
249c264
<     applyMultiArg(multiArg, inter, info.writers());
---
>     applyMultiArg(multiArg, inter, info.useGuards());
295a311,313
>     // This code is still untested.  NewField doesn't
>     // support remote engines yet.
> 
346,348c364,365
<     typedef Intersector<Dim> Inter_t;
<     Inter_t inter;
<     ExpressionApply<Inter_t> tag(inter);
---
>     typedef SimpleIntersector<Dim> Inter_t;
>     Inter_t inter(domain);
350c367
<     applyMultiArg(multiArg, inter, info.writers());
---
>     applyMultiArg(multiArg, inter, info.useGuards());
354a372,374
>       INode<Dim> inode = info.extendDomain(*i);
>       Interval<Dim> evalDom = info.evaluationDomain((*i).domain());
> 
356c376
<       evaluate(multiArg(*i),
---
>       evaluate(multiArg(inode),
385a406,447
> };
> 
> template<class A1, class A2, class A3, class A4>
> struct MultiArgEvaluatorTag<MultiArg4<A1, A2, A3, A4> >
> {
>   typedef typename EvaluatorTag1<A1>::Evaluator_t Eval1_t;
>   typedef typename EvaluatorTag1<A2>::Evaluator_t Eval2_t;
>   typedef typename EvaluatorTag1<A3>::Evaluator_t Eval3_t;
>   typedef typename EvaluatorTag1<A4>::Evaluator_t Eval4_t;
>   typedef typename EvaluatorCombine<Eval1_t, Eval2_t>::Evaluator_t Eval12_t;
>   typedef typename EvaluatorCombine<Eval3_t, Eval4_t>::Evaluator_t  Eval34_t;
>   typedef typename EvaluatorCombine<Eval12_t, Eval34_t>::Evaluator_t  
> Evaluator_t;
> };
> 
> template<class A1, class A2, class A3, class A4, class A5>
> struct MultiArgEvaluatorTag<MultiArg5<A1, A2, A3, A4, A5> >
> {
>   typedef typename EvaluatorTag1<A1>::Evaluator_t Eval1_t;
>   typedef typename EvaluatorTag1<A2>::Evaluator_t Eval2_t;
>   typedef typename EvaluatorTag1<A3>::Evaluator_t Eval3_t;
>   typedef typename EvaluatorTag1<A4>::Evaluator_t Eval4_t;
>   typedef typename EvaluatorTag1<A5>::Evaluator_t Eval5_t;
>   typedef typename EvaluatorCombine<Eval1_t, Eval2_t>::Evaluator_t Eval12_t;
>   typedef typename EvaluatorCombine<Eval3_t, Eval4_t>::Evaluator_t  Eval34_t;
>   typedef typename EvaluatorCombine<Eval12_t, Eval34_t>::Evaluator_t  
> Eval1234_t;
>   typedef typename EvaluatorCombine<Eval1234_t, Eval5_t>::Evaluator_t  
> Evaluator_t;
> };
> 
> template<class A1, class A2, class A3, class A4, class A5, class A6>
> struct MultiArgEvaluatorTag<MultiArg6<A1, A2, A3, A4, A5, A6> >
> {
>   typedef typename EvaluatorTag1<A1>::Evaluator_t Eval1_t;
>   typedef typename EvaluatorTag1<A2>::Evaluator_t Eval2_t;
>   typedef typename EvaluatorTag1<A3>::Evaluator_t Eval3_t;
>   typedef typename EvaluatorTag1<A4>::Evaluator_t Eval4_t;
>   typedef typename EvaluatorTag1<A5>::Evaluator_t Eval5_t;
>   typedef typename EvaluatorTag1<A6>::Evaluator_t Eval6_t;
>   typedef typename EvaluatorCombine<Eval1_t, Eval2_t>::Evaluator_t Eval12_t;
>   typedef typename EvaluatorCombine<Eval3_t, Eval4_t>::Evaluator_t  Eval34_t;
>   typedef typename EvaluatorCombine<Eval5_t, Eval6_t>::Evaluator_t  Eval56_t;
>   typedef typename EvaluatorCombine<Eval12_t, Eval34_t>::Evaluator_t  
> Eval1234_t;
>   typedef typename EvaluatorCombine<Eval1234_t, Eval56_t>::Evaluator_t  
> Evaluator_t;
Index: Evaluator/ScalarCode.h
===================================================================
RCS file: /home/pooma/Repository/r2/src/Evaluator/ScalarCode.h,v
retrieving revision 1.5
diff -r1.5 ScalarCode.h
211a212,334
> template<class A1, class A2, class A3, class A4, class A5, class A6, class 
> Function>
> struct ApplyMultiArgLoc<MultiArg6<A1, A2, A3, A4, A5, A6>, Function>
> {
>   ApplyMultiArgLoc(const MultiArg6<A1, A2, A3, A4, A5, A6> &multiArg,
>                  const Function &function)
>     : multiArg_m(multiArg), function_m(function)
>   {
>   }
> 
>   void operator()(int i0)
>   {
>     function_m(multiArg_m.a1_m, multiArg_m.a2_m, multiArg_m.a3_m,
>                multiArg_m.a4_m, multiArg_m.a5_m, multiArg_m.a6_m,
>                Loc<1>(i0));
>   }
> 
>   void operator()(int i0, int i1)
>   {
>     function_m(multiArg_m.a1_m, multiArg_m.a2_m, multiArg_m.a3_m,
>                multiArg_m.a4_m, multiArg_m.a5_m, multiArg_m.a6_m,
>                 Loc<2>(i0, i1));
>   }
> 
>   void operator()(int i0, int i1, int i2)
>   {
>     function_m(multiArg_m.a1_m, multiArg_m.a2_m, multiArg_m.a3_m,
>                multiArg_m.a4_m, multiArg_m.a5_m, multiArg_m.a6_m,
>                Loc<3>(i0, i1, i2));
>   }
> 
>   void operator()(int i0, int i1, int i2, int i3)
>   {
>     function_m(multiArg_m.a1_m, multiArg_m.a2_m, multiArg_m.a3_m,
>                multiArg_m.a4_m, multiArg_m.a5_m, multiArg_m.a6_m,
>                Loc<4>(i0, i1, i2, i3));
>   }
> 
>   const MultiArg6<A1, A2, A3, A4, A5, A6> &multiArg_m;
>   const Function &function_m;
> };
> 
> template<class A1, class A2, class A3, class A4, class Function>
> struct ApplyMultiArgLoc<MultiArg4<A1, A2, A3, A4>, Function>
> {
>   ApplyMultiArgLoc(const MultiArg4<A1, A2, A3, A4> &multiArg,
>                  const Function &function)
>     : multiArg_m(multiArg), function_m(function)
>   {
>   }
> 
>   void operator()(int i0)
>   {
>     function_m(multiArg_m.a1_m, multiArg_m.a2_m, multiArg_m.a3_m,
>                multiArg_m.a4_m,
>                Loc<1>(i0));
>   }
> 
>   void operator()(int i0, int i1)
>   {
>     function_m(multiArg_m.a1_m, multiArg_m.a2_m, multiArg_m.a3_m,
>                multiArg_m.a4_m,
>                 Loc<2>(i0, i1));
>   }
> 
>   void operator()(int i0, int i1, int i2)
>   {
>     function_m(multiArg_m.a1_m, multiArg_m.a2_m, multiArg_m.a3_m,
>                multiArg_m.a4_m,
>                Loc<3>(i0, i1, i2));
>   }
> 
>   void operator()(int i0, int i1, int i2, int i3)
>   {
>     function_m(multiArg_m.a1_m, multiArg_m.a2_m, multiArg_m.a3_m,
>                multiArg_m.a4_m,
>                Loc<4>(i0, i1, i2, i3));
>   }
> 
>   const MultiArg4<A1, A2, A3, A4> &multiArg_m;
>   const Function &function_m;
> };
> 
> template<class A1, class A2, class A3, class A4, class A5, class Function>
> struct ApplyMultiArgLoc<MultiArg5<A1, A2, A3, A4, A5>, Function>
> {
>   ApplyMultiArgLoc(const MultiArg5<A1, A2, A3, A4, A5> &multiArg,
>                  const Function &function)
>     : multiArg_m(multiArg), function_m(function)
>   {
>   }
> 
>   void operator()(int i0)
>   {
>     function_m(multiArg_m.a1_m, multiArg_m.a2_m, multiArg_m.a3_m,
>                multiArg_m.a4_m, multiArg_m.a5_m,
>                Loc<1>(i0));
>   }
> 
>   void operator()(int i0, int i1)
>   {
>     function_m(multiArg_m.a1_m, multiArg_m.a2_m, multiArg_m.a3_m,
>                multiArg_m.a4_m, multiArg_m.a5_m,
>                 Loc<2>(i0, i1));
>   }
> 
>   void operator()(int i0, int i1, int i2)
>   {
>     function_m(multiArg_m.a1_m, multiArg_m.a2_m, multiArg_m.a3_m,
>                multiArg_m.a4_m, multiArg_m.a5_m,
>                Loc<3>(i0, i1, i2));
>   }
> 
>   void operator()(int i0, int i1, int i2, int i3)
>   {
>     function_m(multiArg_m.a1_m, multiArg_m.a2_m, multiArg_m.a3_m,
>                multiArg_m.a4_m, multiArg_m.a5_m,
>                Loc<4>(i0, i1, i2, i3));
>   }
> 
>   const MultiArg5<A1, A2, A3, A4, A5> &multiArg_m;
>   const Function &function_m;
> };
> 
281a405,443
>              f1.physicalDomain(),
>              kernel);
>   }
> 
>   template<class F1, class F2, class F3, class F4>
>   void operator()(const F1 &f1, const F2 &f2, const F3 &f3, const F4 &f4)
>   {
>     enum { dimensions = F1::dimensions };
>     MultiArg4<F1, F2, F3, F4> multiArg(f1, f2, f3, f4);
>     EvaluateLocLoop<Function, dimensions> 
> kernel(function_m,f1.physicalDomain());
> 
>     MultiArgEvaluator<MainEvaluatorTag>().
>       evaluate<MultiArg4<F1, F2, F3, F4> >(multiArg, function_m,
>              f1.physicalDomain(),
>              kernel);
>   }
> 
>   template<class F1, class F2, class F3, class F4, class F5>
>   void operator()(const F1 &f1, const F2 &f2, const F3 &f3, const F4 &f4, 
> const F5 &f5)
>   {
>     enum { dimensions = F1::dimensions };
>     MultiArg5<F1, F2, F3, F4, F5> multiArg(f1, f2, f3, f4, f5);
>     EvaluateLocLoop<Function, dimensions> 
> kernel(function_m,f1.physicalDomain());
> 
>     MultiArgEvaluator<MainEvaluatorTag>().
>       evaluate<MultiArg5<F1, F2, F3, F4, F5> >(multiArg, function_m,
>              f1.physicalDomain(),
>              kernel);
>   }
> 
>   template<class F1, class F2, class F3, class F4, class F5, class F6>
>   void operator()(const F1 &f1, const F2 &f2, const F3 &f3, const F4 &f4, 
> const F5 &f5, const F6 &f6)
>   {
>     enum { dimensions = F1::dimensions };
>     MultiArg6<F1, F2, F3, F4, F5, F6> multiArg(f1, f2, f3, f4, f5, f6);
>     EvaluateLocLoop<Function, dimensions> 
> kernel(function_m,f1.physicalDomain());
> 
>     MultiArgEvaluator<MainEvaluatorTag>().
>       evaluate<MultiArg6<F1, F2, F3, F4, F5, F6> >(multiArg, function_m,
Index: Evaluator/ScalarCodeInfo.h
===================================================================
RCS file: /home/pooma/Repository/r2/src/Evaluator/ScalarCodeInfo.h,v
retrieving revision 1.2
diff -r1.2 ScalarCodeInfo.h
163c163
<                   domain[d].last() - domain[d].first() + upper_m[d]
---
>                   domain[d].last() + upper_m[d]
178,180c178,180
< //                lower_m[d],
<             domain[d].first(),
<                   domain[d].last() - domain[d].first() // + lower_m[d]
---
>                   lower_m[d],
>                   //            domain[d].first(),
>                   domain[d].last() - domain[d].first()  + lower_m[d]
Index: Functions/MultiArg.h
===================================================================
RCS file: /home/pooma/Repository/r2/src/Functions/MultiArg.h,v
retrieving revision 1.4
diff -r1.4 MultiArg.h
33a34,35
> // Functions:
> // applyMultiArg
83a86,88
> template<class A1, class A2, class A3, class A4> struct MultiArg4;
> template<class A1, class A2, class A3, class A4, class A5> struct MultiArg5;
> template<class A1, class A2, class A3, class A4, class A5, class A6> struct 
> MultiArg6;
113a119,151
> template<class A1, class A2, class A3, class A4, class Dom>
> struct MultiArgView4
> {
>   typedef typename View1<A1, Dom>::Type_t A1_t;
>   typedef typename View1<A2, Dom>::Type_t A2_t;
>   typedef typename View1<A3, Dom>::Type_t A3_t;
>   typedef typename View1<A4, Dom>::Type_t A4_t;
>   typedef MultiArg4<A1_t, A2_t, A3_t, A4_t> Type_t;
> };
> 
> template<class A1, class A2, class A3, class A4, class A5, class Dom>
> struct MultiArgView5
> {
>   typedef typename View1<A1, Dom>::Type_t A1_t;
>   typedef typename View1<A2, Dom>::Type_t A2_t;
>   typedef typename View1<A3, Dom>::Type_t A3_t;
>   typedef typename View1<A4, Dom>::Type_t A4_t;
>   typedef typename View1<A5, Dom>::Type_t A5_t;
>   typedef MultiArg5<A1_t, A2_t, A3_t, A4_t, A5_t> Type_t;
> };
> 
> template<class A1, class A2, class A3, class A4, class A5, class A6, class 
> Dom>
> struct MultiArgView6
> {
>   typedef typename View1<A1, Dom>::Type_t A1_t;
>   typedef typename View1<A2, Dom>::Type_t A2_t;
>   typedef typename View1<A3, Dom>::Type_t A3_t;
>   typedef typename View1<A4, Dom>::Type_t A4_t;
>   typedef typename View1<A5, Dom>::Type_t A5_t;
>   typedef typename View1<A6, Dom>::Type_t A6_t;
>   typedef MultiArg6<A1_t, A2_t, A3_t, A4_t, A5_t, A6_t> Type_t;
> };
> 
144a183,200
> template<class A1, class A2, class A3, class A4, class Dom>
> struct View1<MultiArg4<A1, A2, A3, A4>, Dom>
> {
>   typedef typename MultiArgView4<A1, A2, A3, A4, Dom>::Type_t Type_t;
> };
> 
> template<class A1, class A2, class A3, class A4, class A5, class Dom>
> struct View1<MultiArg5<A1, A2, A3, A4, A5>, Dom>
> {
>   typedef typename MultiArgView5<A1, A2, A3, A4, A5, Dom>::Type_t Type_t;
> };
> 
> template<class A1, class A2, class A3, class A4, class A5, class A6, class 
> Dom>
> struct View1<MultiArg6<A1, A2, A3, A4, A5, A6>, Dom>
> {
>   typedef typename MultiArgView6<A1, A2, A3, A4, A5, A6, Dom>::Type_t Type_t;
> };
> 
216a273,323
> template<class A1, class A2, class A3, class A4, class A5>
> struct MultiArg5
> {
>   enum { size = 5 };
> 
>   MultiArg5(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 
> &a5)
>     : a1_m(a1), a2_m(a2), a3_m(a3), a4_m(a4), a5_m(a5)
>   {
>   }
> 
>   template<class Dom>
>   typename View1<MultiArg5<A1, A2, A3, A4, A5>, Dom>::Type_t
>   operator()(Dom &dom) const
>   {
>     typedef typename View1<MultiArg5<A1, A2, A3, A4, A5>, Dom>::Type_t Ret_t;
>     return Ret_t(a1_m(dom), a2_m(dom), a3_m(dom), a4_m(dom), a5_m(dom));
>   }
> 
>   A1 a1_m;
>   A2 a2_m;
>   A3 a3_m;
>   A4 a4_m;
>   A5 a5_m;
> };
> 
> template<class A1, class A2, class A3, class A4, class A5, class A6>
> struct MultiArg6
> {
>   enum { size = 6 };
> 
>   MultiArg6(const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 
> &a5, const A6 &a6)
>     : a1_m(a1), a2_m(a2), a3_m(a3), a4_m(a4), a5_m(a5), a6_m(a6)
>   {
>   }
> 
>   template<class Dom>
>   typename View1<MultiArg6<A1, A2, A3, A4, A5, A6>, Dom>::Type_t
>   operator()(Dom &dom) const
>   {
>     typedef typename View1<MultiArg6<A1, A2, A3, A4, A5, A6>, Dom>::Type_t 
> Ret_t;
>     return Ret_t(a1_m(dom), a2_m(dom), a3_m(dom), a4_m(dom), a5_m(dom), 
> a6_m(dom));
>   }
> 
>   A1 a1_m;
>   A2 a2_m;
>   A3 a3_m;
>   A4 a4_m;
>   A5 a5_m;
>   A6 a6_m;
> };
> 
246c353,354
<              const Function &f, int i1)
---
>                  const Function &f,
>                  const std::vector<bool> &condition)
248,262c356
<   f(node.a1_m, i1);
< }
< 
< template<class A1, class Function>
< void applyMultiArg(const MultiArg1<A1> &node,
<              const Function &f, int i1, int i2)
< {
<   f(node.a1_m, i1, i2);
< }
< 
< template<class A1, class A2, class Function>
< void applyMultiArg(const MultiArg2<A1, A2> &node,
<              const Function &f, int i1)
< {
<   f(node.a1_m, node.a2_m, i1);
---
>   f(node.a1_m, condition[0]);
267c361,362
<              const Function &f, int i1, int i2)
---
>                  const Function &f,
>                  const std::vector<bool> &condition)
269c364,365
<   f(node.a1_m, node.a2_m, i1, i2);
---
>   f(node.a1_m, condition[0]);
>   f(node.a2_m, condition[1]);
274c370,371
<              const Function &f, int i1)
---
>                  const Function &f,
>                  const std::vector<bool> &condition)
276c373,375
<   f(node.a1_m, node.a2_m, node.a3_m, i1);
---
>   f(node.a1_m, condition[0]);
>   f(node.a2_m, condition[1]);
>   f(node.a3_m, condition[2]);
279,281c378,381
< template<class A1, class A2, class A3, class Function>
< void applyMultiArg(const MultiArg3<A1, A2, A3> &node,
<              const Function &f, int i1, int i2)
---
> template<class A1, class A2, class A3, class A4, class A5, class Function>
> void applyMultiArg(const MultiArg5<A1, A2, A3, A4, A5> &node,
>                  const Function &f,
>                  const std::vector<bool> &condition)
283c383,387
<   f(node.a1_m, node.a2_m, node.a3_m, i1, i2);
---
>   f(node.a1_m, condition[0]);
>   f(node.a2_m, condition[1]);
>   f(node.a3_m, condition[2]);
>   f(node.a4_m, condition[3]);
>   f(node.a5_m, condition[4]);
286,288c390,393
< template<class A1, class A2, class A3, class A4, class A5, class A6, class 
A7, class Function>
< void applyMultiArg(const MultiArg7<A1, A2, A3, A4, A5, A6, A7> &node,
<              const Function &f, int i1)
---
> template<class A1, class A2, class A3, class A4, class A5, class A6, class 
> Function>
> void applyMultiArg(const MultiArg6<A1, A2, A3, A4, A5, A6> &node,
>                  const Function &f,
>                  const std::vector<bool> &condition)
290c395,400
<   f(node.a1_m, node.a2_m, node.a3_m, node.a4_m, node.a5_m, node.a6_m, 
node.a7_m, i1);
---
>   f(node.a1_m, condition[0]);
>   f(node.a2_m, condition[1]);
>   f(node.a3_m, condition[2]);
>   f(node.a4_m, condition[3]);
>   f(node.a5_m, condition[4]);
>   f(node.a6_m, condition[5]);
295c405,406
<              const Function &f, int i1, int i2)
---
>                  const Function &f,
>                  const std::vector<bool> &condition)
297c408,414
<   f(node.a1_m, node.a2_m, node.a3_m, node.a4_m, node.a5_m, node.a6_m, 
node.a7_m, i1, i2);
---
>   f(node.a1_m, condition[0]);
>   f(node.a2_m, condition[1]);
>   f(node.a3_m, condition[2]);
>   f(node.a4_m, condition[3]);
>   f(node.a5_m, condition[4]);
>   f(node.a6_m, condition[5]);
>   f(node.a7_m, condition[6]);
302,303c419
<              const Function &f,
<              const std::vector<bool> &condition)
---
>                  const Function &f)
305c421
<   f(node.a1_m, condition[0]);
---
>   f(node.a1_m);
310,311c426
<              const Function &f,
<              const std::vector<bool> &condition)
---
>                  const Function &f)
313,314c428,429
<   f(node.a1_m, condition[0]);
<   f(node.a2_m, condition[1]);
---
>   f(node.a1_m);
>   f(node.a2_m);
319,320c434
<              const Function &f,
<              const std::vector<bool> &condition)
---
>                  const Function &f)
322,324c436,471
<   f(node.a1_m, condition[0]);
<   f(node.a2_m, condition[1]);
<   f(node.a3_m, condition[2]);
---
>   f(node.a1_m);
>   f(node.a2_m);
>   f(node.a3_m);
> }
> 
> template<class A1, class A2, class A3, class A4, class Function>
> void applyMultiArg(const MultiArg4<A1, A2, A3, A4> &node,
>                  const Function &f)
> {
>   f(node.a1_m);
>   f(node.a2_m);
>   f(node.a3_m);
>   f(node.a4_m);
> }
> 
> template<class A1, class A2, class A3, class A4, class A5, class Function>
> void applyMultiArg(const MultiArg5<A1, A2, A3, A4, A5> &node,
>                  const Function &f)
> {
>   f(node.a1_m);
>   f(node.a2_m);
>   f(node.a3_m);
>   f(node.a4_m);
>   f(node.a5_m);
> }
> 
> template<class A1, class A2, class A3, class A4, class A5, class A6, class 
> Function>
> void applyMultiArg(const MultiArg6<A1, A2, A3, A4, A5, A6> &node,
>                  const Function &f)
> {
>   f(node.a1_m);
>   f(node.a2_m);
>   f(node.a3_m);
>   f(node.a4_m);
>   f(node.a5_m);
>   f(node.a6_m);
329,330c476
<              const Function &f,
<              const std::vector<bool> &condition)
---
>                  const Function &f)
332,338c478,484
<   f(node.a1_m, condition[0]);
<   f(node.a2_m, condition[1]);
<   f(node.a3_m, condition[2]);
<   f(node.a4_m, condition[3]);
<   f(node.a5_m, condition[4]);
<   f(node.a6_m, condition[5]);
<   f(node.a7_m, condition[6]);
---
>   f(node.a1_m);
>   f(node.a2_m);
>   f(node.a3_m);
>   f(node.a4_m);
>   f(node.a5_m);
>   f(node.a6_m);
>   f(node.a7_m);
375a522,585
> 
> template<class A1, class A2, class A3, class A4, class Function>
> void applyMultiArgIf(const MultiArg4<A1, A2, A3, A4> &node,
>                const Function &f,
>                const std::vector<bool> &condition)
> {
>   if (condition[0])
>     f(node.a1_m);
> 
>   if (condition[1])
>     f(node.a2_m);
> 
>   if (condition[2])
>     f(node.a3_m);
> 
>   if (condition[3])
>     f(node.a4_m);
> }
> 
> template<class A1, class A2, class A3, class A4, class A5, class Function>
> void applyMultiArgIf(const MultiArg5<A1, A2, A3, A4, A5> &node,
>                const Function &f,
>                const std::vector<bool> &condition)
> {
>   if (condition[0])
>     f(node.a1_m);
> 
>   if (condition[1])
>     f(node.a2_m);
> 
>   if (condition[2])
>     f(node.a3_m);
> 
>   if (condition[3])
>     f(node.a4_m);
> 
>   if (condition[4])
>     f(node.a5_m);
> }
> 
> template<class A1, class A2, class A3, class A4, class A5, class A6, class 
> Function>
> void applyMultiArgIf(const MultiArg6<A1, A2, A3, A4, A5, A6> &node,
>                const Function &f,
>                const std::vector<bool> &condition)
> {
>   if (condition[0])
>     f(node.a1_m);
> 
>   if (condition[1])
>     f(node.a2_m);
> 
>   if (condition[2])
>     f(node.a3_m);
> 
>   if (condition[3])
>     f(node.a4_m);
> 
>   if (condition[4])
>     f(node.a5_m);
> 
>   if (condition[5])
>     f(node.a6_m);
> }
> 
Index: NewField/tests/ScalarCode.cpp
===================================================================
RCS file: /home/pooma/Repository/r2/src/NewField/tests/ScalarCode.cpp,v
retrieving revision 1.3
diff -r1.3 ScalarCode.cpp
40a41,42
> #include "NewField/Updater/ConstantFaceBC.h"
> #include "Engine/RemoteEngine.h"
43a46,126
> // Example provided by John Hall
> //-----------------------------------------------------------------------------
> 
> template<int Dim>
> struct EdgeQPressureInfo
> {
>   void scalarCodeInfo(ScalarCodeInfo &info) const
>   {
>     info.arguments(5);
> 
>     info.write(0, true );
>     info.write(1, false);
>     info.write(2, false);
>     info.write(3, false);
>     info.write(4, false);
> 
>     // Does this operation index neighboring
>     // cells?  (Do we need to update the internal
>     // guard layers.)
> 
>     info.useGuards(0, false);
>     info.useGuards(1, false);
>     info.useGuards(2, false);
>     info.useGuards(3, false);
>     info.useGuards(4, false);
> 
>     info.dimensions(Dim);
> 
>     for (int i = 0; i < Dim; ++i)
>     {
>       info.lowerExtent(i) = 0;
>       info.upperExtent(i) = 0;
>     }
>   }
> };
> 
> typedef double Real;
> 
> template<int Dim>
> struct ScalarEdgeQPressure
>   : public EdgeQPressureInfo<Dim>
> {
>   ScalarEdgeQPressure(const Real& inLinearQ )
>       : EdgeQPressureInfo<Dim>(),
>     linearQ(inLinearQ)
>   {
>   }
> 
>   template<class F1, class F2, class F3, class F4, class F5>
>   void operator()(const F1& EdgeQPressure,     const F2& EdgeGammaConstant,
>                 const F3& EdgeSoundSpeed,    const F4& EdgeVelocity,
>                 const F5& EdgePsiLimiter,    const 
>                 Loc<Dim> &loc) const
>        {
>        if( EdgePsiLimiter(loc) < 0.2 ) {  // epsilon
>          EdgeQPressure(loc) = 0.0;
>          return;
>        }
> 
>        Real edgeVelocityMagnitude = 
>          sqrt(dot(EdgeVelocity(loc),EdgeVelocity(loc)));
>        
>        EdgeQPressure(loc) = edgeVelocityMagnitude * 
>          EdgePsiLimiter(loc) *
>          (EdgeGammaConstant(loc) * 
>           edgeVelocityMagnitude +
>           sqrt( linearQ * linearQ * 
>                 EdgeSoundSpeed(loc) * EdgeSoundSpeed(loc) +
>                 EdgeGammaConstant(loc) * 
>                 EdgeGammaConstant(loc) *
>                 edgeVelocityMagnitude * 
>                 edgeVelocityMagnitude));
>        }
> 
> private:
>   Real linearQ;
> };
> 
> 
> 
> //-----------------------------------------------------------------------------
46a130,140
> // This example averages the values from an all-face field and puts the
> // result in a cell-centered field.
> // The example is interesting for 2 reasons:
> // -useGuards for the input field is true, because we will need to
> // index into the guard layers---you need the same face on two different
> // processors, so one of the values comes from the guard layer.
> // -on the other hand, we've written the code to operate on views of
> // the all-face field, so the extents are actually 0.  The view of the
> // all-face field take the cell-based domain and include all the relevant
> // faces.
> 
69c163
<       info.upperExtent(i) = 1;
---
>       info.upperExtent(i) = 0;
109a204,266
> // Gradient example.  (This example exists to test operations that use
> // guard layers and have a left extent to make sure we compute on the
> // correct region.)
> //-----------------------------------------------------------------------------
> 
> struct EdgeFromCenterDerivativeInfo
> {
>   EdgeFromCenterDerivativeInfo(int dimensions)
>     : dimensions_m(dimensions)
>   {
>   }
> 
>   void scalarCodeInfo(ScalarCodeInfo &info) const
>   {
>     info.arguments(2);
> 
>     info.write(0, true );
>     info.write(1, false);
>     info.useGuards(0, false);
>     info.useGuards(1, true);
> 
>     info.dimensions(dimensions_m);
> 
>     int i;
>     for (i = 0; i < dimensions_m; ++i)
>     {
>       info.lowerExtent(i) = 1;
>       info.upperExtent(i) = 0;
>     }
>   }
> 
>   int dimensions_m;
> };
> 
> template<int Dim>
> struct EdgeFromCenterDerivative
>   : public  EdgeFromCenterDerivativeInfo
> {
>   EdgeFromCenterDerivative()
>     : EdgeFromCenterDerivativeInfo(Dim),
>       off_m(0)
>   {
>     off_m[0] = 1;
>   }
> 
>   template<class F1, class F2>
>   inline
>   void operator()(F1 &f1, const F2 &f2, const Loc<Dim> &loc) const
>   {
>     if (f2(loc) > 4.0)
>     {
>       f1(loc) = f2(loc) - 2.0 * f2(loc - off_m);
>     }
>     else
>     {
>       f1(loc) = f2(loc) - 1.1 * f2(loc - off_m);
>     }
>   }
> 
>   Loc<Dim> off_m;
> };
> 
> //-----------------------------------------------------------------------------
112a270,271
> // set the problem dimension here:  must be >= 2
> 
114a274,280
> // switch the definitions here to test the distributed case.
> 
> typedef ReplicatedTag LayoutTag_t;
> typedef Brick BrickTag_t;
> //typedef DistributedTag LayoutTag_t;
> //typedef Remote<Brick> BrickTag_t;
> 
144c310
<                           GuardLayers<dim>(1));
---
>                           GuardLayers<dim>(0));
147,148c313,314
<                         GuardLayers<dim>(1), GuardLayers<dim>(1),
<                         ReplicatedTag());
---
>                         GuardLayers<dim>(1), GuardLayers<dim>(0),
>                         LayoutTag_t());
152c318
<   typedef MultiPatch<GridTag, Brick> MP2_t;
---
>   typedef MultiPatch<GridTag, BrickTag_t> MP2_t;
153a320
>   typedef Field<UniformRectilinear<dim>, Vector<dim>, MP2_t> FieldV_t;
158a326
>   f.addUpdaters(AllConstantFaceBC<double>(4.0, true));
167a336,338
>   tester.out() << "input field:" << std::endl
>              << f << std::endl;
> 
176,177d346
<   tester.out() << "input field:" << std::endl
<              << f << std::endl;
180a350,447
>   Field_t fgCheck(cell, layout2, origin, spacings);
> 
>   Interval<dim> cellDomain = f.physicalCellDomain();
> 
>   fgCheck = 0.0;
>   for(d = 0; d < dim; ++d)
>   {
>     Loc<dim> off(0);
>     off[d] = 1;
>     fgCheck(cellDomain) += f[d](cellDomain) + f[d](cellDomain + off);
>   }
>   fgCheck /= (2.0 * dim);
> 
>   tester.out() << "input field:" << std::endl
>              << f << std::endl;
> 
>   tester.out() << "check:" << std::endl
>              << fgCheck << std::endl;  
> 
>   tester.check("scalar code differs from explicit computation",
>              sum(fgCheck - fg) < 0.001);
> 
>   // Now try a problem relevant to Blanca:
> 
>   GridLayout<dim> layout3(physicalVertexDomain, blocks, 
>                         GuardLayers<dim>(1), GuardLayers<dim>(1),
>                         LayoutTag_t());
> 
>   Edge edge(dim - 1);
> 
>   Field_t EdgeQPressure(edge, layout3, origin, spacings);
>   Field_t EdgeGammaConstant(edge, layout3, origin, spacings);
>   Field_t EdgeSoundSpeed(edge, layout3, origin, spacings);
>   FieldV_t EdgeVelocity(edge, layout3, origin, spacings);
>   Field_t EdgePsiLimiter(edge, layout3, origin, spacings);
> 
>   DomainLayout<dim> layout4(physicalVertexDomain, GuardLayers<dim>(1));
>   XField<Geometry_t>::Type_t xEdge(edge, layout4, origin, spacings);
>   setXField(xEdge);
> 
>   EdgeGammaConstant = 1.4;
>   EdgeSoundSpeed = 42.0 + xEdge.comp(1);
>   EdgeVelocity = 3.0 * xEdge;
>   EdgePsiLimiter = 1.0;
> 
>   typedef ScalarEdgeQPressure<dim> SEQP_t;
>   SEQP_t sEQP(3.4);
>   ScalarCode<SEQP_t> edgeQcompute(sEQP);
> 
>   edgeQcompute(EdgeQPressure,
>              EdgeGammaConstant, EdgeSoundSpeed,
>              EdgeVelocity, EdgePsiLimiter);
> 
>   tester.out() << "EdgeQPressure" << EdgeQPressure << std::endl;
>   tester.out() << "EdgeGamma" << EdgeGammaConstant << std::endl;
>   tester.out() << "EdgeSound" << EdgeSoundSpeed << std::endl;
>   tester.out() << "EdgeV" << EdgeVelocity << std::endl;
>   tester.out() << "EdgePsi" << EdgePsiLimiter << std::endl;
> 
>   // 2) scalar code with extents (lower extent in particular)
> 
>   Edge edgeX(1);
>   Field_t edgeValues(edgeX, layout3, origin, spacings);
>   Field_t cellValues(cell, layout3, origin, spacings);
> 
>   XField<Geometry_t>::Type_t xEdgeX(edgeX, layout4, origin, spacings);
>   setXField(xEdgeX);
> 
>   edgeValues.all() = 42.0;
>   cellValues.all() = 5.0;
>   cellValues = xEdgeX.comp(0);
> 
>   tester.out() << "starting cell values: " << std::endl
>              << cellValues << std::endl
>              << "all" << std::endl
>              << cellValues.all() << std::endl;
>   tester.out() << "starting edge values: " << std::endl
>              << edgeValues << std::endl
>              << "all" << std::endl
>              << edgeValues.all() << std::endl;
> 
>   ScalarCode<EdgeFromCenterDerivative<dim> > edgeFromCenter;
> 
>   edgeFromCenter(edgeValues, cellValues);
> 
>   tester.out() << "final edge values: " << std::endl
>              << edgeValues << std::endl
>              << "all" << std::endl
>              << edgeValues.all() << std::endl;
> 
>   double check2 = sum(edgeValues * edgeValues);
>   tester.out() << "check value: " << check2 << std::endl;
> 
>   tester.check("value from derivative computation", abs(check2 - 134.8) < 
> 0.2);
> 
>   // final cases to consider:
>   // 1) replicated fields
> 
191a459,460
> 
> 
Index: NewField/tests/makefile
===================================================================
RCS file: /home/pooma/Repository/r2/src/NewField/tests/makefile,v
retrieving revision 1.7
diff -r1.7 makefile
53a54
>       $(ODIR)/ScalarCode $(TSTOPTS) 1>ScalarCode.out 2>&1
57c58,59
<       $(ODIR)/WhereTest $(ODIR)/VectorTest
---
>       $(ODIR)/WhereTest $(ODIR)/VectorTest \
>       $(ODIR)/ScalarCode
118a121,128
> .PHONY: ScalarCode
> 
> ScalarCode: $(ODIR)/ScalarCode
> 
> $(ODIR)/ScalarCode: $(ODIR)/ScalarCode.o
>       $(LinkToSuite)
> 
> 
133,140d142
<       $(LinkToSuite)
< 
< 
< .PHONY: ScalarCode
< 
< ScalarCode: $(ODIR)/ScalarCode
< 
< $(ODIR)/ScalarCode: $(ODIR)/ScalarCode.o

reply via email to

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