escript  Revision_
DataReady.h
Go to the documentation of this file.
1 
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2018 by The University of Queensland
5 * http://www.uq.edu.au
6 *
7 * Primary Business: Queensland, Australia
8 * Licensed under the Apache License, version 2.0
9 * http://www.apache.org/licenses/LICENSE-2.0
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 
35 class DataReady : public DataAbstract
36 {
38 public:
39  DataReady(const FunctionSpace& what, const ShapeType& shape, bool isDataEmpty=false);
41 
42 
43 
51 
55 
57  const DataTypes::real_t*
59 
61  const DataTypes::cplx_t*
63 
64 
71  getVectorRW()=0;
72 
73 
75  virtual const DataTypes::RealVectorType&
76  getVectorRO() const=0;
77 
80  getVectorRWC()=0;
81 
82 
84  virtual const DataTypes::CplxVectorType&
85  getVectorROC() const=0;
86 
93 
95  virtual const DataTypes::RealVectorType&
96  getTypedVectorRO(DataTypes::real_t dummy) const=0;
97 
101 
103  virtual const DataTypes::CplxVectorType&
104  getTypedVectorRO(DataTypes::cplx_t dummy) const=0;
105 
106 
107 
108 
109 
116  virtual bool
117  hasNaN() const=0;
118 
123  virtual void
124  replaceNaN(DataTypes::real_t value) = 0;
125 
130  virtual void
131  replaceNaN(DataTypes::cplx_t value) = 0;
132 
137  virtual bool
138  hasInf() const=0;
139 
144  virtual void
145  replaceInf(DataTypes::real_t value) = 0;
146 
151  virtual void
152  replaceInf(DataTypes::cplx_t value) = 0;
153 
154 
163  virtual
164  void
165  setSlice(const DataAbstract* value,
166  const DataTypes::RegionType& region) = 0;
167 
168 
175 
176 
180 
184 
185 
189 
190 
191 
192 
193 
196  resolve();
197 
198 };
199 
200 
201 inline
204 {
205  return &(getVectorRW()[getPointOffset(sampleNo,0)]); // exclusive write checks will be done in getVectorRW()
206 }
207 
208 inline
211 {
212  return &(getVectorRWC()[getPointOffset(sampleNo,0)]); // exclusive write checks will be done in getVectorRW()
213 }
214 
215 
216 inline const DataTypes::real_t*
218 {
219  return &(getVectorRO()[getPointOffset(sampleNo,0)]);
220 }
221 
222 inline const DataTypes::cplx_t*
224 {
225  return &(getVectorROC()[getPointOffset(sampleNo,0)]);
226 }
227 
228 
229 
230 inline
233 {
234  return getVectorRO()[i];
235 }
236 
237 inline
239 DataReady::getDataAtOffsetRW(DataTypes::RealVectorType::size_type i) // exclusive write checks will be done in getVectorRW()
240 {
241  return getVectorRW()[i];
242 }
243 
244 
245 inline
248 {
249  return getVectorROC()[i];
250 }
251 
252 inline
254 DataReady::getDataAtOffsetRWC(DataTypes::CplxVectorType::size_type i) // exclusive write checks will be done in getVectorRW()
255 {
256  return getVectorRWC()[i];
257 }
258 
259 
260 
261 }
262 
263 #endif
Definition: FunctionSpace.h:34
virtual const DataTypes::CplxVectorType & getVectorROC() const =0
DataTypes::ShapeType ShapeType
Definition: DataAbstract.h:66
ElementType & reference
Definition: DataVectorAlt.h:50
Definition: DataReady.h:35
DataTypes::vec_size_type size_type
Definition: DataVectorAlt.h:49
std::vector< std::pair< int, int > > RegionType
Definition: DataTypes.h:43
Definition: AbstractContinuousDomain.cpp:22
DataTypes::RealVectorType::reference getDataAtOffsetRW(DataTypes::RealVectorType::size_type i)
Definition: DataReady.h:239
DataTypes::CplxVectorType::const_reference getDataAtOffsetROC(DataTypes::CplxVectorType::size_type i) const
Definition: DataReady.h:247
DataTypes::CplxVectorType::reference getDataAtOffsetRWC(DataTypes::CplxVectorType::size_type i)
Definition: DataReady.h:254
DataTypes::real_t * getSampleDataRW(DataTypes::RealVectorType::size_type sampleNo, DataTypes::real_t dummy=0)
Return the sample data for the given sample number.
Definition: DataReady.h:203
virtual DataTypes::RealVectorType::size_type getPointOffset(int sampleNo, int dataPointNo) const =0
Return the offset for the given sample. This returns the offset for the given point into the containe...
virtual DataTypes::CplxVectorType & getVectorRWC()=0
virtual bool hasInf() const =0
Return true if data contains Inf or -Inf.
virtual void setSlice(const DataAbstract *value, const DataTypes::RegionType &region)=0
Copy the specified region from the given object.
virtual bool hasNaN() const =0
return true if data contains NaN.
virtual void replaceInf(DataTypes::real_t value)=0
replaces all (+/-)Inf values with value
DataReady(const FunctionSpace &what, const ShapeType &shape, bool isDataEmpty=false)
Definition: DataReady.cpp:22
~DataReady()
Definition: DataReady.h:40
DataTypes::RealVectorType::const_reference getDataAtOffsetRO(DataTypes::RealVectorType::size_type i) const
get a reference to the beginning of a data point
Definition: DataReady.h:232
const DataTypes::real_t * getSampleDataRO(DataTypes::RealVectorType::size_type sampleNo, DataTypes::real_t dummy=0) const
Definition: DataReady.h:217
virtual const DataTypes::RealVectorType & getTypedVectorRO(DataTypes::real_t dummy) const =0
virtual DataTypes::RealVectorType & getTypedVectorRW(DataTypes::real_t dummy)=0
These versions use the type system rather than method name to determine return type.
std::complex< real_t > cplx_t
complex data type
Definition: DataTypes.h:53
#define ESCRIPT_DLL_API
Definition: escriptcore/src/system_dep.h:29
virtual void replaceNaN(DataTypes::real_t value)=0
replaces all NaN values with value
DataReady_ptr resolve()
Return a data object with all points resolved.
Definition: DataReady.cpp:29
Definition: DataAbstract.h:61
const ElementType & const_reference
Definition: DataVectorAlt.h:51
virtual DataTypes::RealVectorType & getVectorRW()=0
Provide access to underlying storage. Internal use only!
boost::shared_ptr< DataReady > DataReady_ptr
Definition: DataAbstract.h:56
virtual const DataTypes::RealVectorType & getVectorRO() const =0
DataAbstract parent
Definition: DataReady.h:37
double real_t
type of all real-valued scalars in escript
Definition: DataTypes.h:50