/[escript]/branches/arrexp_2137_win_merge/escript/src/DataReady.h
ViewVC logotype

Contents of /branches/arrexp_2137_win_merge/escript/src/DataReady.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2220 - (show annotations)
Wed Jan 14 05:59:25 2009 UTC (10 years, 7 months ago) by jfenwick
File MIME type: text/plain
File size: 2962 byte(s)
Added getVectorRO to DataReady to deal with some shared data execeptions exposed when using AUTOLAZY.

This version appears to pass most unit tests under AUTOLAZY but build/posix/finley/test/python/run_models.passed  seems very slow.
1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2008 by University of Queensland
5 * Earth Systems Science Computational Center (ESSCC)
6 * http://www.uq.edu.au/esscc
7 *
8 * Primary Business: Queensland, Australia
9 * Licensed under the Open Software License version 3.0
10 * http://www.opensource.org/licenses/osl-3.0.php
11 *
12 *******************************************************/
13
14
15 #if !defined escript_DataReady_20081008_H
16 #define escript_DataReady_20081008_H
17 #include "system_dep.h"
18
19 #include "DataAbstract.h"
20
21 namespace escript {
22
23 // Anything which requires getVector should be moved down here
24
25
26
27 /**
28 \class DataReady ...Purpose...
29 */
30 class DataReady : public DataAbstract
31 {
32 typedef DataAbstract parent;
33 public:
34 DataReady(const FunctionSpace& what, const ShapeType& shape, bool isDataEmpty=false);
35 ~DataReady(){};
36
37
38
39 /**
40 \brief
41 Return the sample data for the given sample number.
42 */
43 ESCRIPT_DLL_API
44 double*
45 getSampleData(ValueType::size_type sampleNo);
46
47 ESCRIPT_DLL_API
48 const double*
49 getSampleDataRO(ValueType::size_type sampleNo) const;
50
51 /**
52 This function is required primarily for LazyData. For ReadyData it returns 1. (Behaviour subject to change).
53 */
54 ESCRIPT_DLL_API
55 size_t
56 getSampleBufferSize() const
57 {
58 return 1;
59 }
60
61 /**
62 \brief Provide access to underlying storage. Internal use only!
63 */
64 ESCRIPT_DLL_API
65 virtual DataTypes::ValueType&
66 getVector()=0;
67
68 ESCRIPT_DLL_API
69 virtual const DataTypes::ValueType&
70 getVector() const=0;
71
72 ESCRIPT_DLL_API
73 virtual const DataTypes::ValueType&
74 getVectorRO() const=0;
75
76
77 /**
78 \brief
79 Copy the specified region from the given object.
80
81 \param value - Input - Data to copy from
82 \param region - Input - Region to copy.
83 */
84 ESCRIPT_DLL_API
85 virtual
86 void
87 setSlice(const DataAbstract* value,
88 const DataTypes::RegionType& region) = 0;
89
90
91 /**
92 \brief get a reference to the beginning of a data point
93 */
94 ESCRIPT_DLL_API
95 DataTypes::ValueType::const_reference
96 getDataAtOffset(DataTypes::ValueType::size_type i) const;
97
98
99 ESCRIPT_DLL_API
100 DataTypes::ValueType::reference
101 getDataAtOffset(DataTypes::ValueType::size_type i);
102
103 ESCRIPT_DLL_API
104 DataReady_ptr
105 resolve();
106
107 };
108
109
110 inline
111 DataAbstract::ValueType::value_type*
112 DataReady::getSampleData(ValueType::size_type sampleNo)
113 {
114 return &(getVector()[getPointOffset(sampleNo,0)]); // exclusive write checks will be done in getVector()
115 }
116
117 inline const double*
118 DataReady::getSampleDataRO(ValueType::size_type sampleNo) const
119 {
120 return &(getVectorRO()[getPointOffset(sampleNo,0)]);
121 }
122
123
124 inline
125 DataTypes::ValueType::const_reference
126 DataReady::getDataAtOffset(DataTypes::ValueType::size_type i) const
127 {
128 return getVectorRO()[i];
129 }
130
131 inline
132 DataTypes::ValueType::reference
133 DataReady::getDataAtOffset(DataTypes::ValueType::size_type i) // exclusive write checks will be done in getVector()
134 {
135 return getVector()[i];
136 }
137
138
139
140 }
141
142 #endif

  ViewVC Help
Powered by ViewVC 1.1.26