/[escript]/trunk/escript/test/DataTestCase.cpp
ViewVC logotype

Diff of /trunk/escript/test/DataTestCase.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1026 by phornby, Tue Mar 13 08:25:00 2007 UTC revision 1811 by ksteube, Thu Sep 25 23:11:13 2008 UTC
# Line 1  Line 1 
1  // $Id$  
2  /*  /*******************************************************
3   *****************************************************************************  *
4   *                                                                           *  * Copyright (c) 2003-2008 by University of Queensland
5   *       COPYRIGHT  ACcESS  -  All Rights Reserved                           *  * Earth Systems Science Computational Center (ESSCC)
6   *                                                                           *  * http://www.uq.edu.au/esscc
7   * This software is the property of ACcESS. No part of this code             *  *
8   * may be copied in any form or by any means without the expressed written   *  * Primary Business: Queensland, Australia
9   * consent of ACcESS.  Copying, use or modification of this software         *  * Licensed under the Open Software License version 3.0
10   * by any unauthorised person is illegal unless that person has a software   *  * http://www.opensource.org/licenses/osl-3.0.php
11   * license agreement with ACcESS.                                            *  *
12   *                                                                           *  *******************************************************/
13   *****************************************************************************  
14  */  
15  #include <iostream>  #include <iostream>
16  #if (defined _WIN32) && (defined __INTEL_COMPILER)  #if (defined _WIN32) && (defined __INTEL_COMPILER)
17  #include <mathimf.h>  #include <mathimf.h>
# Line 31  using namespace std; Line 31  using namespace std;
31  using namespace CppUnitTest;  using namespace CppUnitTest;
32  using namespace escript;  using namespace escript;
33  using namespace esysUtils;  using namespace esysUtils;
34    using namespace escript::DataTypes;
35    
36  void DataTestCase::setUp() {  void DataTestCase::setUp() {
37    //    //
# Line 42  void DataTestCase::tearDown() { Line 43  void DataTestCase::tearDown() {
43    // This is called after each test has been run    // This is called after each test has been run
44  }  }
45    
46    
47    
48    namespace
49    {
50    
51    inline
52    DataTypes::ValueType::reference
53    getRef(Data& d,int s1, int p1, int x, int y)
54    {
55        return d.getDataAtOffset(d.getDataOffset(s1,p1)+getRelIndex(d.getDataPointShape(),x,y));
56    }
57    
58    inline
59    DataTypes::ValueType::reference
60    getRef(Data& d, int x, int y)
61    {
62        return d.getDataAtOffset(getRelIndex(d.getDataPointShape(),x,y));
63    }
64    
65    }
66    
67    // This is to test new copy routines, existing tests should remain where they are
68    void DataTestCase::testCopying()
69    {
70      using namespace escript::DataTypes;
71      cout << endl;
72      {
73        // first we test the deep copy
74        cout << "\tTest deep copy DataConstant" << endl;
75        DataTypes::ShapeType shape;
76        shape.push_back(2);
77        shape.push_back(3);
78        DataTypes::ValueType data(DataTypes::noValues(shape),1);
79        DataConstant* dc=new DataConstant(FunctionSpace(),shape,data);
80        Data d(dc);
81        
82        Data* deep=d.copySelf();    // test self copy
83        for (int i=0;i<DataTypes::noValues(shape);++i)
84        {
85           if (d.getDataAtOffset(i)!=deep->getDataAtOffset(i))
86            assert(false);
87        }
88        d.setToZero();
89        for (int i=0;i<DataTypes::noValues(shape);++i)
90        {
91           if (d.getDataAtOffset(i)==deep->getDataAtOffset(i))
92            assert(false);
93        }
94        d.copy(*deep);          // test copy from object
95        for (int i=0;i<DataTypes::noValues(shape);++i)
96        {
97           if (d.getDataAtOffset(i)!=deep->getDataAtOffset(i))
98            assert(false);
99        }
100        d.setToZero();
101        for (int i=0;i<DataTypes::noValues(shape);++i)
102        {
103           if (d.getDataAtOffset(i)==deep->getDataAtOffset(i))
104            assert(false);
105        }
106        delete deep;
107      }
108    
109      {
110        // first we test the deep copy
111        cout << "\tTest deep copy DataExpanded" << endl;
112        DataTypes::ShapeType shape;
113        shape.push_back(2);
114        shape.push_back(3);
115        DataTypes::ValueType data(DataTypes::noValues(shape),1);
116        DataExpanded* dc=new DataExpanded(FunctionSpace(),shape,data);
117        Data d(dc);
118        
119        Data* deep=d.copySelf();    // test self copy
120        for (int i=0;i<DataTypes::noValues(shape);++i)
121        {
122           if (d.getDataAtOffset(i)!=deep->getDataAtOffset(i))
123            assert(false);
124        }
125        d.setToZero();
126        for (int i=0;i<DataTypes::noValues(shape);++i)
127        {
128           if (d.getDataAtOffset(i)==deep->getDataAtOffset(i))
129            assert(false);
130        }
131        d.copy(*deep);          // test copy from object
132        for (int i=0;i<DataTypes::noValues(shape);++i)
133        {
134           if (d.getDataAtOffset(i)!=deep->getDataAtOffset(i))
135            assert(false);
136        }
137        d.setToZero();
138        for (int i=0;i<DataTypes::noValues(shape);++i)
139        {
140           if (d.getDataAtOffset(i)==deep->getDataAtOffset(i))
141            assert(false);
142        }
143        delete deep;
144      }
145      {
146        // first we test the deep copy
147        cout << "\tTest deep copy DataTagged" << endl;
148        DataTypes::ShapeType shape;
149        shape.push_back(2);
150        shape.push_back(3);
151        DataTypes::ValueType data(DataTypes::noValues(shape),1);
152        DataTagged* dc=new DataTagged(FunctionSpace(),shape,data);
153        Data d(dc);
154        
155        Data* deep=d.copySelf();    // test self copy
156        for (int i=0;i<DataTypes::noValues(shape);++i)
157        {
158           if (d.getDataAtOffset(i)!=deep->getDataAtOffset(i))
159            assert(false);
160        }
161        d.setToZero();
162        for (int i=0;i<DataTypes::noValues(shape);++i)
163        {
164           if (d.getDataAtOffset(i)==deep->getDataAtOffset(i))
165            assert(false);
166        }
167        d.copy(*deep);          // test copy from object
168        for (int i=0;i<DataTypes::noValues(shape);++i)
169        {
170           if (d.getDataAtOffset(i)!=deep->getDataAtOffset(i))
171            assert(false);
172        }
173        d.setToZero();
174        for (int i=0;i<DataTypes::noValues(shape);++i)
175        {
176           if (d.getDataAtOffset(i)==deep->getDataAtOffset(i))
177            assert(false);
178        }
179        delete deep;
180      }
181    
182    }
183    
184  void DataTestCase::testSlicing() {  void DataTestCase::testSlicing() {
185    
186      using namespace escript::DataTypes;
187    cout << endl;    cout << endl;
188    
189    {    {
190    
191      cout << "\tTest get-slicing DataConstant" << endl;      cout << "\tTest get-slicing DataConstant" << endl;
192    
193      DataArrayView::ShapeType viewShape;      DataTypes::ShapeType viewShape;
194      viewShape.push_back(2);      viewShape.push_back(2);
195      viewShape.push_back(3);      viewShape.push_back(3);
196      Data data(1.3,viewShape,FunctionSpace(),false);      Data data(1.3,viewShape,FunctionSpace(),false);
197    
198      //cout << data.toString() << endl;      //cout << data.toString() << endl;
199    
200      DataArrayView::RegionType region;      DataTypes::RegionType region;
201      region.push_back(DataArrayView::RegionType::value_type(0,0));      region.push_back(DataTypes::RegionType::value_type(0,0));
202      region.push_back(DataArrayView::RegionType::value_type(0,0));      region.push_back(DataTypes::RegionType::value_type(0,0));
203    
204      Data slice1(data.getSlice(region));      Data slice1(data.getSlice(region));
205    
206      //cout << slice1.toString() << endl;      //cout << slice1.toString() << endl;
207    
208      assert(slice1.getDataPointRank()==0);      assert(slice1.getDataPointRank()==0);
209      assert(slice1.getDataPoint(0,0)()==1.3);      assert(slice1.getDataPoint(0,0)==1.3);
210    
211      region.clear();      region.clear();
212      region.push_back(DataArrayView::RegionType::value_type(0,1));      region.push_back(DataTypes::RegionType::value_type(0,1));
213      region.push_back(DataArrayView::RegionType::value_type(0,1));      region.push_back(DataTypes::RegionType::value_type(0,1));
214    
215      Data slice2(data.getSlice(region));      Data slice2(data.getSlice(region));
216    
217      //cout << slice2.toString() << endl;      //cout << slice2.toString() << endl;
218    
219      assert(slice2.getDataPointRank()==2);      assert(slice2.getDataPointRank()==2);
220      assert(slice2.getDataPoint(0,0)(0,0)==1.3);      int off1=slice2.getDataOffset(0,0);
221    //     assert(slice2.getDataPoint(0,0)(0,0)==1.3);
222        assert(slice2.getDataAtOffset(off1+getRelIndex(slice2.getDataPointShape(),0,0))==1.3);
223    
224      region.clear();      region.clear();
225      region.push_back(DataArrayView::RegionType::value_type(0,1));      region.push_back(DataTypes::RegionType::value_type(0,1));
226      region.push_back(DataArrayView::RegionType::value_type(0,2));      region.push_back(DataTypes::RegionType::value_type(0,2));
227    
228      Data slice3(data.getSlice(region));      Data slice3(data.getSlice(region));
229    
230      //cout << slice3.toString() << endl;      //cout << slice3.toString() << endl;
231    
232      assert(slice3.getDataPointRank()==2);      assert(slice3.getDataPointRank()==2);
233      assert(slice3.getDataPoint(0,0)(0,0)==1.3);      off1=slice3.getDataOffset(0,0);
234      assert(slice3.getDataPoint(0,0)(0,1)==1.3);  //     assert(slice3.getDataPoint(0,0)(0,0)==1.3);
235    //     assert(slice3.getDataPoint(0,0)(0,1)==1.3);
236        assert(slice3.getDataAtOffset(off1+getRelIndex(slice3.getDataPointShape(),0,0))==1.3);
237        assert(slice3.getDataAtOffset(off1+getRelIndex(slice3.getDataPointShape(),0,1))==1.3);
238    
239    }    }
240    
# Line 97  void DataTestCase::testSlicing() { Line 242  void DataTestCase::testSlicing() {
242    
243      cout << "\tTest set-slicing DataConstant" << endl;      cout << "\tTest set-slicing DataConstant" << endl;
244    
245      DataArrayView::ShapeType viewShape;      DataTypes::ShapeType viewShape;
246      Data source(10.0,viewShape,FunctionSpace(),false);      Data source(10.0,viewShape,FunctionSpace(),false);
247    
248      //cout << source.toString() << endl;      //cout << source.toString() << endl;
# Line 108  void DataTestCase::testSlicing() { Line 253  void DataTestCase::testSlicing() {
253    
254      //cout << target.toString() << endl;      //cout << target.toString() << endl;
255    
256      DataArrayView::RegionType region;      DataTypes::RegionType region;
257      region.push_back(DataArrayView::RegionType::value_type(0,0));      region.push_back(DataTypes::RegionType::value_type(0,0));
258      region.push_back(DataArrayView::RegionType::value_type(0,0));      region.push_back(DataTypes::RegionType::value_type(0,0));
259    
260      target.setSlice(source,region);      target.setSlice(source,region);
261    
262      //cout << target.toString() << endl;      //cout << target.toString() << endl;
263    
264      assert(target.getDataPoint(0,0)(0,0)==source.getDataPoint(0,0)());      int off1=target.getDataOffset(0,0);
265        assert(target.getDataAtOffset(off1+getRelIndex(target.getDataPointShape(),0,0)==source.getDataPoint(0,0)));
266    
267    }    }
268    
269    {    {
270    
271      cout << "\tTest get-slicing DataTagged" << endl;      cout << "\tTest get-slicing DataTagged" << endl;
   
272      //      //
273      // create a DataTagged with a default value only      // create a DataTagged with a default value only
274    
275      DataArrayView::ShapeType viewShape;      DataTypes::ShapeType viewShape;
276      viewShape.push_back(2);      viewShape.push_back(2);
277      viewShape.push_back(3);      viewShape.push_back(3);
278      Data data(1.3,viewShape,FunctionSpace(),false);      Data data(1.3,viewShape,FunctionSpace(),false);
279      data.tag();      data.tag();
280      data.getDataPoint(0,0)(0,0)=1.0;      data.getDataAtOffset(data.getDataOffset(0,0)+getRelIndex(viewShape,0,0))=1.0;
281      data.getDataPoint(0,0)(1,1)=2.0;      data.getDataAtOffset(data.getDataOffset(0,0)+getRelIndex(viewShape,1,1))=2.0;  
282    //     data.getDataPoint(0,0)(0,0)=1.0;
283    //     data.getDataPoint(0,0)(1,1)=2.0;
284    
285      //cout << data.toString() << endl;      //cout << data.toString() << endl;
   
286      //      //
287      // create a scalar slice      // create a scalar slice
288    
289      DataArrayView::RegionType region;      DataTypes::RegionType region;
290      region.push_back(DataArrayView::RegionType::value_type(0,0));      region.push_back(DataTypes::RegionType::value_type(0,0));
291      region.push_back(DataArrayView::RegionType::value_type(0,0));      region.push_back(DataTypes::RegionType::value_type(0,0));
292    
293      Data slice1(data.getSlice(region));      Data slice1(data.getSlice(region));
   
294      //cout << slice1.toString() << endl;      //cout << slice1.toString() << endl;
295    
296      assert(slice1.isTagged());      assert(slice1.isTagged());
297      assert(slice1.getDataPointRank()==0);      assert(slice1.getDataPointRank()==0);
298      assert(slice1.getDataPoint(0,0)()==1.0);      assert(slice1.getDataPoint(0,0)==1.0);
   
299      //      //
300      // create a rank 2 slice with one value      // create a rank 2 slice with one value
301    
302      region.clear();      region.clear();
303      region.push_back(DataArrayView::RegionType::value_type(0,1));      region.push_back(DataTypes::RegionType::value_type(0,1));
304      region.push_back(DataArrayView::RegionType::value_type(0,1));      region.push_back(DataTypes::RegionType::value_type(0,1));
305    
306      Data slice2(data.getSlice(region));      Data slice2(data.getSlice(region));
307    
# Line 165  void DataTestCase::testSlicing() { Line 309  void DataTestCase::testSlicing() {
309    
310      assert(slice2.isTagged());      assert(slice2.isTagged());
311      assert(slice2.getDataPointRank()==2);      assert(slice2.getDataPointRank()==2);
312      assert(slice2.getDataPoint(0,0)(0,0)==1.0);  
313        assert(slice2.getDataAtOffset(slice2.getDataOffset(0,0)+getRelIndex(slice2.getDataPointShape(),0,0))==1.0);
314    
315      //      //
316      // create a rank 2 slice with four values      // create a rank 2 slice with four values
317    
318      region.clear();      region.clear();
319      region.push_back(DataArrayView::RegionType::value_type(0,2));      region.push_back(DataTypes::RegionType::value_type(0,2));
320      region.push_back(DataArrayView::RegionType::value_type(0,2));      region.push_back(DataTypes::RegionType::value_type(0,2));
321    
322      Data slice3(data.getSlice(region));      Data slice3(data.getSlice(region));
323    
# Line 180  void DataTestCase::testSlicing() { Line 325  void DataTestCase::testSlicing() {
325    
326      assert(slice3.isTagged());      assert(slice3.isTagged());
327      assert(slice3.getDataPointRank()==2);      assert(slice3.getDataPointRank()==2);
328      assert(slice3.getDataPoint(0,0)(0,0)==1.0);      assert(getRef(slice3,0,0,0,0)==1.0);
329      assert(slice3.getDataPoint(0,0)(0,1)==1.3);      assert(getRef(slice3,0,0,0,1)==1.3);
330      assert(slice3.getDataPoint(0,0)(1,0)==1.3);      assert(getRef(slice3,0,0,1,0)==1.3);
331      assert(slice3.getDataPoint(0,0)(1,1)==2.0);      assert(getRef(slice3,0,0,1,1)==2.0);
332    
333      //      //
334      // add a value for tag "1"      // add a value for tag "1"
335    
336      DataArrayView::ValueType viewData(6);      DataTypes::ValueType viewData(6);
337      for (int i=0;i<viewData.size();i++) {      for (int i=0;i<viewData.size();i++) {
338        viewData[i]=i;        viewData[i]=i;
339      }      }
340      DataArrayView dataView(viewData,viewShape);  //    DataArrayView dataView(viewData,viewShape);
341    
342    //     data.setTaggedValueFromCPP(1, dataView);
343        data.setTaggedValueFromCPP(1, viewShape, viewData);
344    
     data.setTaggedValueFromCPP(1, dataView);  
345    
346      //      //
347      // create a full slice      // create a full slice
348    
349      region.clear();      region.clear();
350      region.push_back(DataArrayView::RegionType::value_type(0,2));      region.push_back(DataTypes::RegionType::value_type(0,2));
351      region.push_back(DataArrayView::RegionType::value_type(0,3));      region.push_back(DataTypes::RegionType::value_type(0,3));
352    
353      Data slice4(data.getSlice(region));      Data slice4(data.getSlice(region));
354    
# Line 209  void DataTestCase::testSlicing() { Line 356  void DataTestCase::testSlicing() {
356    
357      assert(slice4.isTagged());      assert(slice4.isTagged());
358      assert(slice4.getDataPointRank()==2);      assert(slice4.getDataPointRank()==2);
359      assert(slice4.getDataPoint(0,0)(0,0)==0);      assert(getRef(slice4,0,0,0,0)==0);
360      assert(slice4.getDataPoint(0,0)(0,1)==2);      assert(getRef(slice4,0,0,0,1)==2);
361      assert(slice4.getDataPoint(0,0)(0,2)==4);      assert(getRef(slice4,0,0,0,2)==4);
362      assert(slice4.getDataPoint(0,0)(1,0)==1);      assert(getRef(slice4,0,0,1,0)==1);
363      assert(slice4.getDataPoint(0,0)(1,1)==3);      assert(getRef(slice4,0,0,1,1)==3);
364      assert(slice4.getDataPoint(0,0)(1,2)==5);      assert(getRef(slice4,0,0,1,2)==5);
365    
366    }    }
367    
# Line 225  void DataTestCase::testSlicing() { Line 372  void DataTestCase::testSlicing() {
372      //      //
373      // create a source DataTagged with a scalar default value only      // create a source DataTagged with a scalar default value only
374    
375      DataArrayView::ShapeType viewShape;      DataTypes::ShapeType viewShape;
376      Data source(10.0,viewShape,FunctionSpace(),false);      Data source(10.0,viewShape,FunctionSpace(),false);
377      source.tag();      source.tag();
378    
# Line 244  void DataTestCase::testSlicing() { Line 391  void DataTestCase::testSlicing() {
391      //      //
392      // set a slice in target from source      // set a slice in target from source
393    
394      DataArrayView::RegionType region;      DataTypes::RegionType region;
395      region.push_back(DataArrayView::RegionType::value_type(1,1));      region.push_back(DataTypes::RegionType::value_type(1,1));
396      region.push_back(DataArrayView::RegionType::value_type(1,1));      region.push_back(DataTypes::RegionType::value_type(1,1));
397    
398      target.setSlice(source,region);      target.setSlice(source,region);
399    
# Line 254  void DataTestCase::testSlicing() { Line 401  void DataTestCase::testSlicing() {
401    
402      assert(target.isTagged());      assert(target.isTagged());
403      assert(target.getDataPointRank()==2);      assert(target.getDataPointRank()==2);
404      assert(target.getDataPoint(0,0)(0,0)==1.3);      assert(getRef(target,0,0,0,0)==1.3);
405      assert(target.getDataPoint(0,0)(0,1)==1.3);      assert(getRef(target,0,0,0,1)==1.3);
406      assert(target.getDataPoint(0,0)(0,2)==1.3);      assert(getRef(target,0,0,0,2)==1.3);
407      assert(target.getDataPoint(0,0)(1,0)==1.3);      assert(getRef(target,0,0,1,0)==1.3);
408      assert(target.getDataPoint(0,0)(1,1)==source.getDataPoint(0,0)());      assert(getRef(target,0,0,1,1)==source.getDataPoint(0,0));
409      assert(target.getDataPoint(0,0)(1,2)==1.3);      assert(getRef(target,0,0,1,2)==1.3);
410    
411      //      //
412      // add a value for tag "1" to target      // add a value for tag "1" to target
413    
414      DataArrayView::ValueType viewData(6);      DataTypes::ValueType viewData(6);
415      for (int i=0;i<viewData.size();i++) {      for (int i=0;i<viewData.size();i++) {
416        viewData[i]=i;        viewData[i]=i;
417      }      }
418      DataArrayView dataView(viewData,viewShape);  //     DataArrayView dataView(viewData,viewShape);
419    //
420      target.setTaggedValueFromCPP(1, dataView);  //     target.setTaggedValueFromCPP(1, dataView);
421        target.setTaggedValueFromCPP(1, viewShape, viewData);
422    
423      //cout << "target:\n" << target.toString() << endl;      //cout << "target:\n" << target.toString() << endl;
424    
# Line 278  void DataTestCase::testSlicing() { Line 426  void DataTestCase::testSlicing() {
426      // set a slice in target from source      // set a slice in target from source
427    
428      region.clear();      region.clear();
429      region.push_back(DataArrayView::RegionType::value_type(0,0));      region.push_back(DataTypes::RegionType::value_type(0,0));
430      region.push_back(DataArrayView::RegionType::value_type(1,1));      region.push_back(DataTypes::RegionType::value_type(1,1));
431    
432      target.setSlice(source,region);      target.setSlice(source,region);
433    
# Line 287  void DataTestCase::testSlicing() { Line 435  void DataTestCase::testSlicing() {
435    
436      assert(target.isTagged());      assert(target.isTagged());
437      assert(target.getDataPointRank()==2);      assert(target.getDataPointRank()==2);
438      assert(target.getDataPoint(0,0)(0,0)==0);      assert(getRef(target,0,0,0,0)==0);
439      assert(target.getDataPoint(0,0)(0,1)==source.getDataPoint(0,0)());      assert(getRef(target,0,0,0,1)==source.getDataPoint(0,0));
440      assert(target.getDataPoint(0,0)(0,2)==4);      assert(getRef(target,0,0,0,2)==4);
441      assert(target.getDataPoint(0,0)(1,0)==1);      assert(getRef(target,0,0,1,0)==1);
442      assert(target.getDataPoint(0,0)(1,1)==3);      assert(getRef(target,0,0,1,1)==3);
443      assert(target.getDataPoint(0,0)(1,2)==5);      assert(getRef(target,0,0,1,2)==5);
444    
445      //      //
446      // add a value for tag "2" to source      // add a value for tag "2" to source
447    
448      DataArrayView::ShapeType viewShape2;      DataTypes::ShapeType viewShape2;
449      DataArrayView::ValueType viewData2(1);      DataTypes::ValueType viewData2(1);
450      viewData2[0]=6;      viewData2[0]=6;
451      DataArrayView dataView2(viewData2,viewShape2);  //     DataArrayView dataView2(viewData2,viewShape2);
452    //
453      source.setTaggedValueFromCPP(2, dataView2);  //     source.setTaggedValueFromCPP(2, dataView2);
454        source.setTaggedValueFromCPP(2, viewShape2, viewData2);
455    
456      //cout << "source:\n" << source.toString() << endl;      //cout << "source:\n" << source.toString() << endl;
457    
# Line 310  void DataTestCase::testSlicing() { Line 459  void DataTestCase::testSlicing() {
459      // set a slice in target from source      // set a slice in target from source
460    
461      region.clear();      region.clear();
462      region.push_back(DataArrayView::RegionType::value_type(0,0));      region.push_back(DataTypes::RegionType::value_type(0,0));
463      region.push_back(DataArrayView::RegionType::value_type(1,1));      region.push_back(DataTypes::RegionType::value_type(1,1));
464    
465      target.setSlice(source,region);      target.setSlice(source,region);
466    
# Line 351  void DataTestCase::testSlicing() { Line 500  void DataTestCase::testSlicing() {
500    
501      cout << "\tTest get-slicing DataExpanded" << endl;      cout << "\tTest get-slicing DataExpanded" << endl;
502    
503      DataArrayView::ShapeType viewShape;      DataTypes::ShapeType viewShape;
504      viewShape.push_back(2);      viewShape.push_back(2);
505      viewShape.push_back(3);      viewShape.push_back(3);
506      Data temp(1.3,viewShape,FunctionSpace(),true);      Data temp(1.3,viewShape,FunctionSpace(),true);
507    
508      temp.getDataPoint(0,0)(0,0)=0.0;      getRef(temp,0,0,0,0)=0.0;
509      temp.getDataPoint(0,0)(1,1)=1.0;      getRef(temp,0,0,1,1)=1.0;
510    
511      DataArrayView::RegionType region;      DataTypes::RegionType region;
512      region.push_back(DataArrayView::RegionType::value_type(0,0));      region.push_back(DataTypes::RegionType::value_type(0,0));
513      region.push_back(DataArrayView::RegionType::value_type(0,0));      region.push_back(DataTypes::RegionType::value_type(0,0));
514    
515      Data slice(temp.getSlice(region));      Data slice(temp.getSlice(region));
516    
517      assert(slice.getDataPointRank()==0);      assert(slice.getDataPointRank()==0);
518      assert(slice.getDataPoint(0,0)()==0.0);      assert(slice.getDataPoint(0,0)==0.0);
519    
520      region.clear();      region.clear();
521      region.push_back(DataArrayView::RegionType::value_type(0,1));      region.push_back(DataTypes::RegionType::value_type(0,1));
522      region.push_back(DataArrayView::RegionType::value_type(0,1));      region.push_back(DataTypes::RegionType::value_type(0,1));
523    
524      slice=temp.getSlice(region);      slice=temp.getSlice(region);
525    
526      assert(slice.getDataPointRank()==2);      assert(slice.getDataPointRank()==2);
527      assert(slice.getDataPoint(0,0)(0,0)==0.0);      assert(getRef(slice,0,0,0,0)==0.0);
528    
529      region.clear();      region.clear();
530      region.push_back(DataArrayView::RegionType::value_type(0,2));      region.push_back(DataTypes::RegionType::value_type(0,2));
531      region.push_back(DataArrayView::RegionType::value_type(0,2));      region.push_back(DataTypes::RegionType::value_type(0,2));
532    
533      slice=temp.getSlice(region);      slice=temp.getSlice(region);
534    
535      assert(slice.getDataPoint(0,0)(0,0)==0.0);      assert(getRef(slice,0,0,0,0)==0.0);
536      assert(slice.getDataPoint(0,0)(1,1)==1.0);      assert(getRef(slice,0,0,1,1)==1.0);
537    
538    }    }
539    
# Line 392  void DataTestCase::testSlicing() { Line 541  void DataTestCase::testSlicing() {
541    
542      cout << "\tTest set-slicing DataExpanded" << endl;      cout << "\tTest set-slicing DataExpanded" << endl;
543    
544      DataArrayView::ShapeType viewShape;      DataTypes::ShapeType viewShape;
545      Data source(10.0,viewShape,FunctionSpace(),true);      Data source(10.0,viewShape,FunctionSpace(),true);
546    
547      viewShape.push_back(2);      viewShape.push_back(2);
548      viewShape.push_back(3);      viewShape.push_back(3);
549      Data target(1.3,viewShape,FunctionSpace(),true);      Data target(1.3,viewShape,FunctionSpace(),true);
550    
551      DataArrayView::RegionType region;      DataTypes::RegionType region;
552      region.push_back(DataArrayView::RegionType::value_type(0,0));      region.push_back(DataTypes::RegionType::value_type(0,0));
553      region.push_back(DataArrayView::RegionType::value_type(0,0));      region.push_back(DataTypes::RegionType::value_type(0,0));
554    
555      target.setSlice(source,region);      target.setSlice(source,region);
556    
557      assert(target.getDataPoint(0,0)(0,0)==source.getDataPoint(0,0)());      assert(getRef(target,0,0,0,0)==source.getDataPoint(0,0));
558    
559    }    }
560    
# Line 417  void DataTestCase::testAll() { Line 566  void DataTestCase::testAll() {
566    
567    cout << "\tCreate a Data object from a DataArrayView" << endl;    cout << "\tCreate a Data object from a DataArrayView" << endl;
568    
569    DataArrayView::ShapeType viewShape;    DataTypes::ShapeType viewShape;
570    viewShape.push_back(3);    viewShape.push_back(3);
571    DataArrayView::ValueType viewData(3);    DataTypes::ValueType viewData(3);
572    for (int i=0;i<viewShape[0];++i) {    for (int i=0;i<viewShape[0];++i) {
573      viewData[i]=i;      viewData[i]=i;
574    }    }
575    DataArrayView myView(viewData,viewShape);  //   DataArrayView myView(viewData,viewShape);
576    
577    bool expanded=true;    bool expanded=true;
578    Data exData(myView,FunctionSpace(),expanded);    Data exData(viewData,viewShape,FunctionSpace(),expanded);
579    Data cData(myView);  //   Data cData(myView);
580      Data cData(viewData,viewShape,FunctionSpace());
581    Data result;    Data result;
582    
583    assert(exData.isExpanded());    assert(exData.isExpanded());
# Line 446  void DataTestCase::testMore() { Line 596  void DataTestCase::testMore() {
596    
597    cout << "\tCreate a Data object from a DataArrayView" << endl;    cout << "\tCreate a Data object from a DataArrayView" << endl;
598    
599    DataArrayView::ShapeType viewShape;    DataTypes::ShapeType viewShape;
600    viewShape.push_back(3);    viewShape.push_back(3);
601    DataArrayView::ValueType viewData(3);    DataTypes::ValueType viewData(3);
602    for (int i=0;i<viewShape[0];++i) {    for (int i=0;i<viewShape[0];++i) {
603      viewData[i]=i;      viewData[i]=i;
604    }    }
605    DataArrayView myView(viewData,viewShape);  //   DataArrayView myView(viewData,viewShape);
606    
607    bool expanded=true;    bool expanded=true;
608    Data exData(myView,FunctionSpace(),expanded);    Data exData(viewData,viewShape,FunctionSpace(),expanded);
609    Data cData(myView);    Data cData(viewData,viewShape);
610    Data result;    Data result;
611    
612    assert(exData.isExpanded());    assert(exData.isExpanded());
# Line 490  void DataTestCase::testDataConstant() { Line 640  void DataTestCase::testDataConstant() {
640    
641    cout << "\tCreate a DataConstant object from a DataArrayView" << endl;    cout << "\tCreate a DataConstant object from a DataArrayView" << endl;
642    
643    DataArrayView::ShapeType viewShape;    DataTypes::ShapeType viewShape;
644    viewShape.push_back(2);    viewShape.push_back(2);
645    viewShape.push_back(3);    viewShape.push_back(3);
646    viewShape.push_back(4);    viewShape.push_back(4);
647    DataArrayView::ValueType viewData(2*3*4);    DataTypes::ValueType viewData(2*3*4);
648    for (int i=0;i<DataArrayView::noValues(viewShape);++i) {    for (int i=0;i<DataTypes::noValues(viewShape);++i) {
649      viewData[i]=i;      viewData[i]=i;
650    }    }
651    DataArrayView myView(viewData,viewShape);  //   DataArrayView myView(viewData,viewShape);
652    
653    Data left(myView);    Data left(viewData,viewShape);
654    Data right(myView);    Data right(viewData,viewShape);
655    Data result;    Data result;
656    
657    cout << "\tTest some basic operations" << endl;    cout << "\tTest some basic operations" << endl;
# Line 531  void DataTestCase::testDataTagged() { Line 681  void DataTestCase::testDataTagged() {
681    
682      cout << "\tCreate a DataTagged object with a default value only." << endl;      cout << "\tCreate a DataTagged object with a default value only." << endl;
683    
684      DataTagged::TagListType keys;  //    DataTagged::TagListType keys;
685    
686      DataTagged::ValueListType values;  //    DataTagged::ValueListType values;
687    
688      DataArrayView::ShapeType viewShape;      DataTypes::ShapeType viewShape;
689      viewShape.push_back(3);      viewShape.push_back(3);
690    
691      DataArrayView::ValueType viewData(3);      DataTypes::ValueType viewData(3);
692      for (int i=0;i<viewShape[0];i++) {      for (int i=0;i<viewShape[0];i++) {
693        viewData[i]=i;        viewData[i]=i;
694      }      }
695      DataArrayView defaultValue(viewData,viewShape);  /*    DataArrayView defaultValue(viewData,viewShape);
696    
697      bool expanded=false;      bool expanded=false;
698      
699      Data myData(keys,values,defaultValue,FunctionSpace(),expanded);      Data myData(keys,values,defaultValue,FunctionSpace(),expanded);*/
700        int arr[1]={1};     // iso c++ does not like empty arrays
701        DataTagged* dt=new DataTagged(FunctionSpace(),viewShape,arr,viewData);
702        Data myData(dt);
703    
704      // cout << myData.toString() << endl;      // cout << myData.toString() << endl;
705    
# Line 555  void DataTestCase::testDataTagged() { Line 708  void DataTestCase::testDataTagged() {
708      assert(myData.getTagNumber(0)==1);      assert(myData.getTagNumber(0)==1);
709      assert(myData.getDataPointRank()==1);      assert(myData.getDataPointRank()==1);
710      assert(myData.getLength()==3);      assert(myData.getLength()==3);
711        
712      DataArrayView myDataView = myData.getPointDataView();      assert(myData.getNoValues()==3);
713      assert(!myDataView.isEmpty());      assert(myData.getDataAtOffset(0)==0.0);
714      assert(myDataView.getOffset()==0);      assert(myData.getDataAtOffset(1)==1.0);
715      assert(myDataView.getRank()==1);      assert(myData.getDataAtOffset(2)==2.0);
716      assert(myDataView.noValues()==3);  
717      assert(myDataView.getShape().size()==1);  //     DataArrayView myDataView = myData.getPointDataView();
718      assert(myDataView(0)==0.0);  //     assert(!myDataView.isEmpty());
719      assert(myDataView(1)==1.0);  //     assert(myDataView.getOffset()==0);
720      assert(myDataView(2)==2.0);  //     assert(myDataView.getRank()==1);
721    //     assert(myDataView.noValues()==3);
722      myDataView = myData.getDataPoint(0,0);  //     assert(myDataView.getShape().size()==1);
723      assert(!myDataView.isEmpty());  //     assert(myDataView(0)==0.0);
724      assert(myDataView.getOffset()==0);  //     assert(myDataView(1)==1.0);
725      assert(myDataView.getRank()==1);  //     assert(myDataView(2)==2.0);
726      assert(myDataView.noValues()==3);  
727      assert(myDataView.getShape().size()==1);  //     myDataView = myData.getDataPoint(0,0);
728      assert(myDataView(0)==0.0);  //     assert(!myDataView.isEmpty());
729      assert(myDataView(1)==1.0);  //     assert(myDataView.getOffset()==0);
730      assert(myDataView(2)==2.0);  //     assert(myDataView.getRank()==1);
731    //     assert(myDataView.noValues()==3);
732    //     assert(myDataView.getShape().size()==1);
733    //     assert(myDataView(0)==0.0);
734    //     assert(myDataView(1)==1.0);
735    //     assert(myDataView(2)==2.0);
736    
737      double* sampleData=myData.getSampleData(0);      double* sampleData=myData.getSampleData(0);
738      for (int i=0; i<myDataView.noValues(); i++) {      for (int i=0; i<myData.getNoValues(); i++) {
739        assert(sampleData[i]==i);        assert(sampleData[i]==i);
740      }      }
741      // use a non-existent tag so we get a pointer to      // use a non-existent tag so we get a pointer to
# Line 590  void DataTestCase::testDataTagged() { Line 748  void DataTestCase::testDataTagged() {
748      cout << "\tTest setting of a tag and associated value." << endl;      cout << "\tTest setting of a tag and associated value." << endl;
749    
750      // value for tag "1"      // value for tag "1"
751      DataArray eTwo(defaultValue);      DataTypes::ValueType eTwoData(viewData);
752      for (int i=0;i<eTwo.getView().getShape()[0];i++) {   //   DataArrayView eTwoView(eTwoData, viewShape);
753        eTwo.getView()(i)=i+2.0;      for (int i=0;i<viewShape[0];i++) {
754          eTwoData[i]=i+2.0;
755      }      }
756    
757      myData.setTaggedValueFromCPP(1,eTwo.getView());      myData.setTaggedValueFromCPP(1,viewShape, eTwoData);
758    
759      assert(myData.getLength()==6);      assert(myData.getLength()==6);
760    
761      myDataView = myData.getDataPoint(0,0);      int offset=myData.getDataOffset(0,0);
762      assert(myDataView==eTwo.getView());  //    myDataView = myData.getDataPoint(0,0);
763      assert(!myDataView.isEmpty());  //     assert(myDataView==eTwoView);
764      assert(myDataView.getOffset()==3);  //     assert(!myDataView.isEmpty());
765      assert(myDataView.getRank()==1);      assert(offset==3);
766      assert(myDataView.noValues()==3);      assert(myData.getDataPointRank()==1);
767      assert(myDataView.getShape().size()==1);      assert(myData.getNoValues()==3);
768      assert(myDataView(0)==2);  //    assert(myDataView.getShape().size()==1);
769      assert(myDataView(1)==3);  
770      assert(myDataView(2)==4);      assert(myData.getDataAtOffset(offset+0)==2);
771        assert(myData.getDataAtOffset(offset+1)==3);
772        assert(myData.getDataAtOffset(offset+2)==4);
773    
774      sampleData=myData.getSampleDataByTag(1);      sampleData=myData.getSampleDataByTag(1);
775      for (int i=0; i<myDataView.noValues(); i++) {      for (int i=0; i<myData.getNoValues(); i++) {
776        assert(sampleData[i]==i+2);        assert(sampleData[i]==i+2);
777      }      }
778    
# Line 621  void DataTestCase::testDataTagged() { Line 782  void DataTestCase::testDataTagged() {
782    
783      cout << "\tCreate a DataTagged object via tag() method." << endl;      cout << "\tCreate a DataTagged object via tag() method." << endl;
784    
785      DataArrayView::ShapeType viewShape;      DataTypes::ShapeType viewShape;
786      viewShape.push_back(2);      viewShape.push_back(2);
787      viewShape.push_back(3);      viewShape.push_back(3);
788      Data myData(1.3,viewShape,FunctionSpace(),false);      Data myData(1.3,viewShape,FunctionSpace(),false);
# Line 636  void DataTestCase::testDataTagged() { Line 797  void DataTestCase::testDataTagged() {
797      assert(myData.getLength()==6);      assert(myData.getLength()==6);
798    
799      // check default value      // check default value
800      DataArrayView myDataView = myData.getPointDataView();  //     DataArrayView myDataView = myData.getPointDataView();
801      assert(!myDataView.isEmpty());      assert(!myData.isEmpty());
802      assert(myDataView.getOffset()==0);  //     assert(myDataView.getOffset()==0);
803      assert(myDataView.getRank()==2);      assert(myData.getDataPointRank()==2);
804      assert(myDataView.noValues()==6);      assert(myData.getNoValues()==6);
805      assert(myDataView.getShape().size()==2);      assert(myData.getDataPointShape().size()==2);
806      assert(myDataView(0,0)==1.3);      assert(getRef(myData,0,0)==1.3);
807      assert(myDataView(0,1)==1.3);      assert(getRef(myData,0,1)==1.3);
808      assert(myDataView(0,2)==1.3);      assert(getRef(myData,0,2)==1.3);
809      assert(myDataView(1,0)==1.3);      assert(getRef(myData,1,0)==1.3);
810      assert(myDataView(1,1)==1.3);      assert(getRef(myData,1,1)==1.3);
811      assert(myDataView(1,2)==1.3);      assert(getRef(myData,1,2)==1.3);
812    
813      // check value for data-point (0,0).      // check value for data-point (0,0).
814      myDataView = myData.getDataPoint(0,0);  //     myDataView = myData.getDataPoint(0,0);
815      assert(!myDataView.isEmpty());      assert(!myData.isEmpty());
816      assert(myDataView.getOffset()==0);  //     assert(myDataView.getOffset()==0);
817      assert(myDataView.getRank()==2);      assert(myData.getDataPointRank()==2);
818      assert(myDataView.noValues()==6);      assert(myData.getNoValues()==6);
819      assert(myDataView.getShape().size()==2);      assert(myData.getDataPointShape().size()==2);
820      assert(myDataView(0,0)==1.3);      assert(getRef(myData,0,0)==1.3);
821      assert(myDataView(0,1)==1.3);      assert(getRef(myData,0,1)==1.3);
822      assert(myDataView(0,2)==1.3);      assert(getRef(myData,0,2)==1.3);
823      assert(myDataView(1,0)==1.3);      assert(getRef(myData,1,0)==1.3);
824      assert(myDataView(1,1)==1.3);      assert(getRef(myData,1,1)==1.3);
825      assert(myDataView(1,2)==1.3);      assert(getRef(myData,1,2)==1.3);
826    
827    }    }
828    
# Line 674  void DataTestCase::testDataTaggedExcepti Line 835  void DataTestCase::testDataTaggedExcepti
835    cout << "\tTest DataTagged exceptions." << endl;    cout << "\tTest DataTagged exceptions." << endl;
836    
837    Data myData;    Data myData;
   DataArrayView myView;  
838    
839    try {    try {
840        myData.getSampleDataByTag(0);;        myData.getSampleDataByTag(0);;
841        assert(false);        assert(false);
842    }    }
843    catch (EsysException& e) {    catch (EsysException&) {
844        //cout << e.what() << endl;        //cout << e.what() << endl;
845        assert(true);        assert(true);
846    }    }
847    
848    try {    try {
849        myData.setTaggedValueFromCPP(0,myView);;        myData.setTaggedValueFromCPP(0,DataTypes::ShapeType(), DataTypes::ValueType());;
850        assert(false);        assert(false);
851    }    }
852    catch (EsysException& e) {    catch (EsysException&) {
853        //cout << e.what() << endl;        //cout << e.what() << endl;
854        assert(true);        assert(true);
855    }    }
# Line 700  void DataTestCase::testConstructors() { Line 860  void DataTestCase::testConstructors() {
860    
861    cout << endl;    cout << endl;
862    
863    DataArrayView::ShapeType viewShape;    DataTypes::ShapeType viewShape;
864    {    {
865      cout << "\tCreate an Empty Data object" << endl;      cout << "\tCreate an Empty Data object" << endl;
866      Data temp(1.3,viewShape,FunctionSpace(),false);      Data temp(1.3,viewShape,FunctionSpace(),false);
# Line 718  void DataTestCase::testOperations() { Line 878  void DataTestCase::testOperations() {
878    cout << endl;    cout << endl;
879    
880    // define the shape for the DataArrayView test data    // define the shape for the DataArrayView test data
881    DataArrayView::ShapeType shape;    DataTypes::ShapeType shape;
882    shape.push_back(2);    shape.push_back(2);
883    shape.push_back(3);    shape.push_back(3);
884    
885    // allocate the data for the DataArrayView    // allocate the data for the DataArrayView
886    DataArrayView::ValueType data(DataArrayView::noValues(shape),0);    DataTypes::ValueType data(DataTypes::noValues(shape),0);
887    
888    // construct DataArrayView    // construct DataArrayView
889    DataArrayView dataView(data,shape);  //   DataArrayView dataView(data,shape);
890    
891    // assign values to the data    // assign values to the data
892    for (int i=0;i<shape[0];i++) {    for (int i=0;i<shape[0];i++) {
893      for (int j=0;j<shape[1];j++) {      for (int j=0;j<shape[1];j++) {
894        dataView(i,j)=dataView.index(i,j);        data[getRelIndex(shape,i,j)]=getRelIndex(shape,i,j);
895      }      }
896    }    }
897    
898    Data baseEx(dataView,FunctionSpace(),true);    Data baseEx(data,shape,FunctionSpace(),true);
899    Data baseCon(dataView,FunctionSpace(),false);    Data baseCon(data,shape,FunctionSpace(),false);
900    Data baseTag(dataView,FunctionSpace(),false);    Data baseTag(data,shape,FunctionSpace(),false);
901    baseTag.tag();    baseTag.tag();
902    
903    assert(baseEx.isExpanded());    assert(baseEx.isExpanded());
# Line 758  void DataTestCase::testOperations() { Line 918  void DataTestCase::testOperations() {
918    resultTag.copy(baseTag.powD(power));    resultTag.copy(baseTag.powD(power));
919    for (int i=0;i<shape[0];i++) {    for (int i=0;i<shape[0];i++) {
920      for (int j=0;j<shape[1];j++) {      for (int j=0;j<shape[1];j++) {
921        tmp=pow(dataView.index(i,j),3.0);        tmp=pow((double)data[getRelIndex(shape,i,j)],(double)3.0);
922        assert(std::abs(resultEx.getPointDataView()(i,j) - tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultEx,i,j) - tmp) <= REL_TOL*std::abs(tmp));
923        assert(std::abs(resultCon.getPointDataView()(i,j)- tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultCon,i,j) - tmp) <= REL_TOL*std::abs(tmp));
924        assert(std::abs(resultTag.getPointDataView()(i,j)- tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultTag,i,j) - tmp) <= REL_TOL*std::abs(tmp));
925      }      }
926    }    }
927    
# Line 771  void DataTestCase::testOperations() { Line 931  void DataTestCase::testOperations() {
931    resultTag.copy(baseTag.sin());    resultTag.copy(baseTag.sin());
932    for (int i=0;i<shape[0];i++) {    for (int i=0;i<shape[0];i++) {
933      for (int j=0;j<shape[1];j++) {      for (int j=0;j<shape[1];j++) {
934        tmp=sin((double)dataView.index(i,j));        tmp=sin((double)data[getRelIndex(shape,i,j)]);
935        assert(std::abs(resultEx.getPointDataView()(i,j) - tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultEx,i,j) - tmp) <= REL_TOL*std::abs(tmp));
936        assert(std::abs(resultCon.getPointDataView()(i,j)- tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultCon,i,j) - tmp) <= REL_TOL*std::abs(tmp));
937        assert(std::abs(resultTag.getPointDataView()(i,j)- tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultTag,i,j) - tmp) <= REL_TOL*std::abs(tmp));
938      }      }
939    }    }
940    
# Line 784  void DataTestCase::testOperations() { Line 944  void DataTestCase::testOperations() {
944    resultTag.copy(baseTag.cos());    resultTag.copy(baseTag.cos());
945    for (int i=0;i<shape[0];i++) {    for (int i=0;i<shape[0];i++) {
946      for (int j=0;j<shape[1];j++) {      for (int j=0;j<shape[1];j++) {
947        tmp=cos((double)dataView.index(i,j));        tmp=cos((double)data[getRelIndex(shape,i,j)]);
948        assert(std::abs(resultEx.getPointDataView()(i,j) - tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultEx,i,j) - tmp) <= REL_TOL*std::abs(tmp));
949        assert(std::abs(resultCon.getPointDataView()(i,j)- tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultCon,i,j) - tmp) <= REL_TOL*std::abs(tmp));
950        assert(std::abs(resultTag.getPointDataView()(i,j)- tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultTag,i,j) - tmp) <= REL_TOL*std::abs(tmp));
951      }      }
952    }    }
953    
# Line 797  void DataTestCase::testOperations() { Line 957  void DataTestCase::testOperations() {
957    resultTag.copy(baseTag.tan());    resultTag.copy(baseTag.tan());
958    for (int i=0;i<shape[0];i++) {    for (int i=0;i<shape[0];i++) {
959      for (int j=0;j<shape[1];j++) {      for (int j=0;j<shape[1];j++) {
960        tmp=tan((double)dataView.index(i,j));        tmp=tan((double)data[getRelIndex(shape,i,j)]);
961        assert(std::abs(resultEx.getPointDataView()(i,j) - tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultEx,i,j) - tmp) <= REL_TOL*std::abs(tmp));
962        assert(std::abs(resultCon.getPointDataView()(i,j)- tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultCon,i,j)- tmp) <= REL_TOL*std::abs(tmp));
963        assert(std::abs(resultTag.getPointDataView()(i,j)- tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultTag,i,j)- tmp) <= REL_TOL*std::abs(tmp));
964      }      }
965    }    }
966    
# Line 822  void DataTestCase::testOperations() { Line 982  void DataTestCase::testOperations() {
982    resultTag.copy(baseTag.atan());    resultTag.copy(baseTag.atan());
983    for (int i=0;i<shape[0];i++) {    for (int i=0;i<shape[0];i++) {
984      for (int j=0;j<shape[1];j++) {      for (int j=0;j<shape[1];j++) {
985        tmp=atan((double)dataView.index(i,j));        tmp=atan((double)data[getRelIndex(shape,i,j)]);
986        assert(std::abs(resultEx.getPointDataView()(i,j) - tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultEx,i,j) - tmp) <= REL_TOL*std::abs(tmp));
987        assert(std::abs(resultCon.getPointDataView()(i,j)- tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultCon,i,j)- tmp) <= REL_TOL*std::abs(tmp));
988        assert(std::abs(resultTag.getPointDataView()(i,j)- tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultTag,i,j)- tmp) <= REL_TOL*std::abs(tmp));
989      }      }
990    }    }
991    
# Line 835  void DataTestCase::testOperations() { Line 995  void DataTestCase::testOperations() {
995    resultTag.copy(baseTag.sinh());    resultTag.copy(baseTag.sinh());
996    for (int i=0;i<shape[0];i++) {    for (int i=0;i<shape[0];i++) {
997      for (int j=0;j<shape[1];j++) {      for (int j=0;j<shape[1];j++) {
998        tmp=sinh((double)dataView.index(i,j));        tmp=sinh((double)data[getRelIndex(shape,i,j)]);
999        assert(std::abs(resultEx.getPointDataView()(i,j) - tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultEx,i,j) - tmp) <= REL_TOL*std::abs(tmp));
1000        assert(std::abs(resultCon.getPointDataView()(i,j)- tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultCon,i,j)- tmp) <= REL_TOL*std::abs(tmp));
1001        assert(std::abs(resultTag.getPointDataView()(i,j)- tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultTag,i,j)- tmp) <= REL_TOL*std::abs(tmp));
1002      }      }
1003    }    }
1004    
# Line 848  void DataTestCase::testOperations() { Line 1008  void DataTestCase::testOperations() {
1008    resultTag.copy(baseTag.cosh());    resultTag.copy(baseTag.cosh());
1009    for (int i=0;i<shape[0];i++) {    for (int i=0;i<shape[0];i++) {
1010      for (int j=0;j<shape[1];j++) {      for (int j=0;j<shape[1];j++) {
1011        tmp=cosh((double)dataView.index(i,j));        tmp=cosh((double)data[getRelIndex(shape,i,j)]);
1012        assert(std::abs(resultEx.getPointDataView()(i,j) - tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultEx,i,j) - tmp) <= REL_TOL*std::abs(tmp));
1013        assert(std::abs(resultCon.getPointDataView()(i,j)- tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultCon,i,j)- tmp) <= REL_TOL*std::abs(tmp));
1014        assert(std::abs(resultTag.getPointDataView()(i,j)- tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultTag,i,j)- tmp) <= REL_TOL*std::abs(tmp));
1015      }      }
1016    }    }
1017    
# Line 861  void DataTestCase::testOperations() { Line 1021  void DataTestCase::testOperations() {
1021    resultTag.copy(baseTag.tanh());    resultTag.copy(baseTag.tanh());
1022    for (int i=0;i<shape[0];i++) {    for (int i=0;i<shape[0];i++) {
1023      for (int j=0;j<shape[1];j++) {      for (int j=0;j<shape[1];j++) {
1024        tmp=tanh((double)dataView.index(i,j));        tmp=tanh((double)data[getRelIndex(shape,i,j)]);
1025        assert(std::abs(resultEx.getPointDataView()(i,j) - tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultEx,i,j) - tmp) <= REL_TOL*std::abs(tmp));
1026        assert(std::abs(resultCon.getPointDataView()(i,j)- tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultCon,i,j)- tmp) <= REL_TOL*std::abs(tmp));
1027        assert(std::abs(resultTag.getPointDataView()(i,j)- tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultTag,i,j)- tmp) <= REL_TOL*std::abs(tmp));
1028      }      }
1029    }    }
1030    
# Line 898  void DataTestCase::testOperations() { Line 1058  void DataTestCase::testOperations() {
1058    resultTag.copy(baseTag.abs());    resultTag.copy(baseTag.abs());
1059    for (int i=0;i<shape[0];i++) {    for (int i=0;i<shape[0];i++) {
1060      for (int j=0;j<shape[1];j++) {      for (int j=0;j<shape[1];j++) {
1061        tmp=abs((double)dataView.index(i,j));        tmp=abs((double)data[getRelIndex(shape,i,j)]);
1062        assert(std::abs(resultEx.getPointDataView()(i,j) - tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultEx,i,j) - tmp) <= REL_TOL*std::abs(tmp));
1063        assert(std::abs(resultCon.getPointDataView()(i,j)- tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultCon,i,j)- tmp) <= REL_TOL*std::abs(tmp));
1064        assert(std::abs(resultTag.getPointDataView()(i,j)- tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultTag,i,j)- tmp) <= REL_TOL*std::abs(tmp));
1065      }      }
1066    }    }
1067    
# Line 917  void DataTestCase::testOperations() { Line 1077  void DataTestCase::testOperations() {
1077    resultTag.copy(baseTag.exp());    resultTag.copy(baseTag.exp());
1078    for (int i=0;i<shape[0];i++) {    for (int i=0;i<shape[0];i++) {
1079      for (int j=0;j<shape[1];j++) {      for (int j=0;j<shape[1];j++) {
1080        tmp=exp((double)dataView.index(i,j));        tmp=exp((double)data[getRelIndex(shape,i,j)]);
1081        assert(std::abs(resultEx.getPointDataView()(i,j) - tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultEx,i,j) - tmp) <= REL_TOL*std::abs(tmp));
1082        assert(std::abs(resultCon.getPointDataView()(i,j)- tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultCon,i,j)- tmp) <= REL_TOL*std::abs(tmp));
1083        assert(std::abs(resultTag.getPointDataView()(i,j)- tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultTag,i,j)- tmp) <= REL_TOL*std::abs(tmp));
1084      }      }
1085    }    }
1086    
# Line 930  void DataTestCase::testOperations() { Line 1090  void DataTestCase::testOperations() {
1090    resultTag.copy(baseTag.sqrt());    resultTag.copy(baseTag.sqrt());
1091    for (int i=0;i<shape[0];i++) {    for (int i=0;i<shape[0];i++) {
1092      for (int j=0;j<shape[1];j++) {      for (int j=0;j<shape[1];j++) {
1093        tmp=sqrt((double)dataView.index(i,j));        tmp=sqrt((double)data[getRelIndex(shape,i,j)]);
1094        assert(std::abs(resultEx.getPointDataView()(i,j) - tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultEx,i,j) - tmp) <= REL_TOL*std::abs(tmp));
1095        assert(std::abs(resultCon.getPointDataView()(i,j)- tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultCon,i,j)- tmp) <= REL_TOL*std::abs(tmp));
1096        assert(std::abs(resultTag.getPointDataView()(i,j)- tmp) <= REL_TOL*std::abs(tmp));        assert(std::abs(getRef(resultTag,i,j)- tmp) <= REL_TOL*std::abs(tmp));
1097      }      }
1098    }    }
1099    
# Line 949  void DataTestCase::testOperations() { Line 1109  void DataTestCase::testOperations() {
1109    resultTag.copy(baseTag.pos());    resultTag.copy(baseTag.pos());
1110    for (int i=0;i<shape[0];i++) {    for (int i=0;i<shape[0];i++) {
1111      for (int j=0;j<shape[1];j++) {      for (int j=0;j<shape[1];j++) {
1112        assert(std::abs(resultEx.getPointDataView()(i,j) - dataView.index(i,j)) <= REL_TOL*std::abs(dataView.index(i,j)));        assert(std::abs(getRef(resultEx,i,j) - getRelIndex(shape,i,j)) <= REL_TOL*std::abs(data[getRelIndex(shape,i,j)]));
1113        assert(std::abs(resultCon.getPointDataView()(i,j) - dataView.index(i,j)) <= REL_TOL*std::abs(dataView.index(i,j)));        assert(std::abs(getRef(resultCon,i,j) - getRelIndex(shape,i,j)) <= REL_TOL*std::abs(data[getRelIndex(shape,i,j)]));
1114        assert(std::abs(resultTag.getPointDataView()(i,j) - dataView.index(i,j)) <= REL_TOL*std::abs(dataView.index(i,j)));        assert(std::abs(getRef(resultTag,i,j) - getRelIndex(shape,i,j)) <= REL_TOL*std::abs(data[getRelIndex(shape,i,j)]));
1115      }      }
1116    }    }
1117    
# Line 978  void DataTestCase::testOperations() { Line 1138  void DataTestCase::testOperations() {
1138    resultEx.copy(baseEx.minval());    resultEx.copy(baseEx.minval());
1139    resultCon.copy(baseCon.minval());    resultCon.copy(baseCon.minval());
1140    resultTag.copy(baseTag.minval());    resultTag.copy(baseTag.minval());
1141    assert(std::abs(resultEx.getPointDataView()() - 0) <= REL_TOL*0);  //   assert(std::abs(resultEx.getPointDataView()() - 0) <= REL_TOL*0);
1142    assert(std::abs(resultCon.getPointDataView()() - 0) <= REL_TOL*0);  //   assert(std::abs(resultCon.getPointDataView()() - 0) <= REL_TOL*0);
1143    assert(std::abs(resultTag.getPointDataView()() - 0) <= REL_TOL*0);  //   assert(std::abs(resultTag.getPointDataView()() - 0) <= REL_TOL*0);
1144      assert(std::abs(resultEx.getDataAtOffset(0) - 0) <= REL_TOL*0);
1145      assert(std::abs(resultCon.getDataAtOffset(0) - 0) <= REL_TOL*0);
1146      assert(std::abs(resultTag.getDataAtOffset(0) - 0) <= REL_TOL*0);
1147    
1148    cout << "\tTest Data::maxval." << endl;    cout << "\tTest Data::maxval." << endl;
1149    resultEx.copy(baseEx.maxval());    resultEx.copy(baseEx.maxval());
1150    resultCon.copy(baseCon.maxval());    resultCon.copy(baseCon.maxval());
1151    resultTag.copy(baseTag.maxval());    resultTag.copy(baseTag.maxval());
1152    assert(std::abs(resultEx.getPointDataView()() - 5) <= REL_TOL*5);    assert(std::abs(resultEx.getDataAtOffset(0) - 5) <= REL_TOL*5);
1153    assert(std::abs(resultCon.getPointDataView()() - 5) <= REL_TOL*5);    assert(std::abs(resultCon.getDataAtOffset(0) - 5) <= REL_TOL*5);
1154    assert(std::abs(resultTag.getPointDataView()() - 5) <= REL_TOL*5);    assert(std::abs(resultTag.getDataAtOffset(0) - 5) <= REL_TOL*5);
1155    
1156  }  }
1157    
# Line 1002  void DataTestCase::testMemAlloc() { Line 1165  void DataTestCase::testMemAlloc() {
1165    
1166    Data *testData;    Data *testData;
1167    for (int i=0; i<1000; i++) {    for (int i=0; i<1000; i++) {
1168      testData = new Data(0.0, DataArrayView::ShapeType(), FunctionSpace(), true);      testData = new Data(0.0, DataTypes::ShapeType(), FunctionSpace(), true);
1169      delete testData;      delete testData;
1170    }    }
1171    
1172    DataArrayView::ShapeType viewShape;    DataTypes::ShapeType viewShape;
1173    viewShape.push_back(10);    viewShape.push_back(10);
1174    viewShape.push_back(10);    viewShape.push_back(10);
1175    viewShape.push_back(10);    viewShape.push_back(10);
# Line 1026  TestSuite* DataTestCase::suite () Line 1189  TestSuite* DataTestCase::suite ()
1189    //    //
1190    // create the suite of tests to perform.    // create the suite of tests to perform.
1191    TestSuite *testSuite = new TestSuite ("DataTestCase");    TestSuite *testSuite = new TestSuite ("DataTestCase");
1192      testSuite->addTest (new TestCaller< DataTestCase>("testCopying",&DataTestCase::testCopying));
1193    testSuite->addTest (new TestCaller< DataTestCase>("testAll",&DataTestCase::testAll));    testSuite->addTest (new TestCaller< DataTestCase>("testAll",&DataTestCase::testAll));
1194    testSuite->addTest (new TestCaller< DataTestCase>("testMore",&DataTestCase::testMore));    testSuite->addTest (new TestCaller< DataTestCase>("testMore",&DataTestCase::testMore));
1195    testSuite->addTest (new TestCaller< DataTestCase>("testDataConstant",&DataTestCase::testDataConstant));    testSuite->addTest (new TestCaller< DataTestCase>("testDataConstant",&DataTestCase::testDataConstant));

Legend:
Removed from v.1026  
changed lines
  Added in v.1811

  ViewVC Help
Powered by ViewVC 1.1.26