escript  Revision_Unversioneddirectory
DataReady.h
Go to the documentation of this file.
1 
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2016 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 
49  double*
51 
53  const double*
54  getSampleDataRO(ValueType::size_type sampleNo) const;
55 
61  virtual DataTypes::ValueType&
62  getVectorRW()=0;
63 
64 
66  virtual const DataTypes::ValueType&
67  getVectorRO() const=0;
68 
75  virtual bool
76  hasNaN() const=0;
77 
82  virtual void
83  replaceNaN(double value) = 0;
84 
93  virtual
94  void
95  setSlice(const DataAbstract* value,
96  const DataTypes::RegionType& region) = 0;
97 
98 
105 
106 
110 
113  resolve();
114 
115 };
116 
117 
118 inline
121 {
122  return &(getVectorRW()[getPointOffset(sampleNo,0)]); // exclusive write checks will be done in getVectorRW()
123 }
124 
125 inline const double*
127 {
128  return &(getVectorRO()[getPointOffset(sampleNo,0)]);
129 }
130 
131 
132 inline
135 {
136  return getVectorRO()[i];
137 }
138 
139 inline
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
Definition: FunctionSpace.h:34
virtual void replaceNaN(double value)=0
replaces all NaN values with value
DataVector implements an arbitrarily long vector of data values. DataVector is the underlying data co...
Definition: DataVector.h:44
DataTypes::ShapeType ShapeType
Definition: DataAbstract.h:67
Definition: DataReady.h:35
std::vector< std::pair< int, int > > RegionType
Definition: DataTypes.h:39
Definition: AbstractContinuousDomain.cpp:24
DataTypes::ValueType::reference getDataAtOffsetRW(DataTypes::ValueType::size_type i)
Definition: DataReady.h:141
double * getSampleDataRW(ValueType::size_type sampleNo)
Return the sample data for the given sample number.
Definition: DataReady.h:120
virtual DataTypes::ValueType & getVectorRW()=0
Provide access to underlying storage. Internal use only!
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.
DataReady(const FunctionSpace &what, const ShapeType &shape, bool isDataEmpty=false)
Definition: DataReady.cpp:26
const ElementType & const_reference
Definition: DataVector.h:62
const double * getSampleDataRO(ValueType::size_type sampleNo) const
Definition: DataReady.h:126
DataTypes::ValueType::const_reference getDataAtOffsetRO(DataTypes::ValueType::size_type i) const
get a reference to the beginning of a data point
Definition: DataReady.h:134
virtual const DataTypes::ValueType & getVectorRO() const =0
~DataReady()
Definition: DataReady.h:40
#define ESCRIPT_DLL_API
Definition: escriptcore/src/system_dep.h:54
ElementType & reference
Definition: DataVector.h:61
DataReady_ptr resolve()
Return a data object with all points resolved.
Definition: DataReady.cpp:33
ElementType value_type
Definition: DataVector.h:59
Definition: DataAbstract.h:61
boost::shared_ptr< DataReady > DataReady_ptr
Definition: DataAbstract.h:56
long size_type
Definition: DataVector.h:60
virtual ValueType::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...
DataAbstract parent
Definition: DataReady.h:37