/[escript]/branches/subworld2/escriptcore/src/DataReady.h
ViewVC logotype

Contents of /branches/subworld2/escriptcore/src/DataReady.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5504 - (show annotations)
Wed Mar 4 22:58:13 2015 UTC (4 years, 1 month ago) by jfenwick
File MIME type: text/plain
File size: 3376 byte(s)
Again with a more up to date copy


1
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2015 by University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Open Software License version 3.0
9 * http://www.opensource.org/licenses/osl-3.0.php
10 *
11 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 * Development 2012-2013 by School of Earth Sciences
13 * Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 *
15 *****************************************************************************/
16
17
18 #if !defined escript_DataReady_20081008_H
19 #define escript_DataReady_20081008_H
20 #include "system_dep.h"
21
22 #include "DataAbstract.h"
23
24 namespace escript {
25
26 // Anything which requires getVector should be moved down here
27
28
29
30 /**
31 \class DataReady
32 Base class for Data which do not need to be resolved.
33 Internally this means they have getVectorRO and getVectorRW methods.
34 */
35 class DataReady : public DataAbstract
36 {
37 typedef DataAbstract parent;
38 public:
39 DataReady(const FunctionSpace& what, const ShapeType& shape, bool isDataEmpty=false);
40 ~DataReady(){};
41
42
43
44 /**
45 \brief
46 Return the sample data for the given sample number.
47 */
48 ESCRIPT_DLL_API
49 double*
50 getSampleDataRW(ValueType::size_type sampleNo);
51
52 ESCRIPT_DLL_API
53 const double*
54 getSampleDataRO(ValueType::size_type sampleNo) const;
55
56 /**
57 \brief Provide access to underlying storage. Internal use only!
58 */
59
60 ESCRIPT_DLL_API
61 virtual DataTypes::ValueType&
62 getVectorRW()=0;
63
64
65 ESCRIPT_DLL_API
66 virtual const DataTypes::ValueType&
67 getVectorRO() const=0;
68
69 /**
70 \brief return true if data contains NaN.
71 \warning This is dependent on the ability to reliably detect NaNs on your compiler.
72 See the nancheck function in LocalOps for details.
73 */
74 ESCRIPT_DLL_API
75 virtual bool
76 hasNaN() const=0;
77
78 /**
79 \brief replaces all NaN values with value
80 */
81 ESCRIPT_DLL_API
82 virtual void
83 replaceNaN(double value) = 0;
84
85 /**
86 \brief
87 Copy the specified region from the given object.
88
89 \param value - Input - Data to copy from
90 \param region - Input - Region to copy.
91 */
92 ESCRIPT_DLL_API
93 virtual
94 void
95 setSlice(const DataAbstract* value,
96 const DataTypes::RegionType& region) = 0;
97
98
99 /**
100 \brief get a reference to the beginning of a data point
101 */
102 ESCRIPT_DLL_API
103 DataTypes::ValueType::const_reference
104 getDataAtOffsetRO(DataTypes::ValueType::size_type i) const;
105
106
107 ESCRIPT_DLL_API
108 DataTypes::ValueType::reference
109 getDataAtOffsetRW(DataTypes::ValueType::size_type i);
110
111 ESCRIPT_DLL_API
112 DataReady_ptr
113 resolve();
114
115 };
116
117
118 inline
119 DataAbstract::ValueType::value_type*
120 DataReady::getSampleDataRW(ValueType::size_type sampleNo)
121 {
122 return &(getVectorRW()[getPointOffset(sampleNo,0)]); // exclusive write checks will be done in getVectorRW()
123 }
124
125 inline const double*
126 DataReady::getSampleDataRO(ValueType::size_type sampleNo) const
127 {
128 return &(getVectorRO()[getPointOffset(sampleNo,0)]);
129 }
130
131
132 inline
133 DataTypes::ValueType::const_reference
134 DataReady::getDataAtOffsetRO(DataTypes::ValueType::size_type i) const
135 {
136 return getVectorRO()[i];
137 }
138
139 inline
140 DataTypes::ValueType::reference
141 DataReady::getDataAtOffsetRW(DataTypes::ValueType::size_type i) // exclusive write checks will be done in getVectorRW()
142 {
143 return getVectorRW()[i];
144 }
145
146
147
148 }
149
150 #endif

  ViewVC Help
Powered by ViewVC 1.1.26