/[escript]/trunk/escript/src/DataC.h
ViewVC logotype

Contents of /trunk/escript/src/DataC.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4421 - (show annotations)
Tue May 21 05:16:39 2013 UTC (6 years, 4 months ago) by caltinay
File MIME type: text/plain
File size: 5913 byte(s)
Finley... there were actually some long-standing errors in the checks.

1
2 /*****************************************************************************
3 *
4 * Copyright (c) 2003-2013 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 since 2012 by School of Earth Sciences
13 *
14 *****************************************************************************/
15
16
17 #if !defined escript_DataC_20040611_H
18 #define escript_DataC_20040611_H
19 #include "system_dep.h"
20
21 /**
22 \brief
23 Provide a wrapper around a Data object so Data may be accessed from C.
24
25 Description:
26 Provide a wrapper around a Data object so Data may be accessed from C.
27
28 */
29 struct escriptDataC {
30 void* m_dataPtr;
31 };
32
33 typedef struct escriptDataC escriptDataC;
34
35 /**
36 \brief
37 Return the function space type code.
38 \param data Input - C wrapper for Data.
39 */
40 ESCRIPT_DLL_API int getFunctionSpaceType(escriptDataC* data);
41
42 /**
43 \brief
44 sets the int variable _FS to the function space type of _DATA if the data
45 object is not empty.
46 \param _FS Input/Output - variable to be updated.
47 \param _DATA Input - C wrapper for Data.
48 */
49 #define updateFunctionSpaceType(_FS,_DATA) _FS=(isEmpty(_DATA) ? _FS : getFunctionSpaceType(_DATA))
50
51 /**
52 \brief
53 returns true if the function space type of _DATA is equal to _FS or is empty
54 \param _FS Input - function space type to checked against
55 \param _DATA Input - C wrapper for Data.
56 */
57 #define functionSpaceTypeEqual(_FS,_DATA) ( (isEmpty(_DATA) || _FS==getFunctionSpaceType(_DATA)) ) ? 1 : 0
58
59 /**
60 \brief
61 Returns the true if the data are empty or data is NULL.
62 \param data Input - C wrapper for Data.
63 */
64 ESCRIPT_DLL_API int isEmpty(escriptDataC* data);
65
66 /**
67 \brief
68 Return true if the input shape matches the data point shape for data
69 \param data Input - C wrapper for Data.
70 \param rank Input - number of dimensions.
71 \param dimensions Input -
72 */
73 ESCRIPT_DLL_API int isDataPointShapeEqual(escriptDataC* data, int rank, const int* dimensions);
74 /**
75 \brief
76 Return true if the number of data points per sample and the number
77 of samples equal the input values. In the case that data is empty or NULL,
78 true is returned.
79 \param data Input - C wrapper for Data.
80 \param numDataPointsPerSample Input - number of data points per sample
81 \param numSamples Input - number of samples
82 */
83 ESCRIPT_DLL_API int numSamplesEqual(escriptDataC* data, int numDataPointsPerSample,
84 int numSamples);
85
86 /**
87 \brief
88 Returns the number of data points per sample
89 \param data Input - C wrapper for Data.
90 */
91 ESCRIPT_DLL_API int getNumDataPointsPerSample(escriptDataC* data);
92
93 /**
94 \brief
95 Returns the rank of the point data for the data.
96 \param data Input - C wrapper for Data.
97 */
98 ESCRIPT_DLL_API int getDataPointRank(escriptDataC* data);
99
100 /**
101 \brief
102 Returns the value of the i-th component of the shape of the point data.
103 \param data Input - C wrapper for Data.
104 \param i Input - index of shape component.
105 */
106 ESCRIPT_DLL_API int getDataPointShape(escriptDataC* data,int i);
107
108 /**
109 \brief
110 Return the number of doubles needed for each data point.
111 \param data Input - C wrapper for Data.
112 */
113 ESCRIPT_DLL_API int getDataPointSize(escriptDataC* data);
114
115 /*
116 \brief
117 Return the number of doubles stored for the Data object.
118 Argument data may be NULL, in which case 0 is returnd.
119 \param data Input - C wrapper for Data.
120
121 This function has been removed because it does not make sense for LazyData
122 */
123 /*ESCRIPT_DLL_API int getLength(escriptDataC* data);*/
124
125 /**
126 \brief
127 Return true if data can be treated as expanded.
128
129 Argument data may be NULL, in which case false is returnd.
130 \param data Input - C wrapper for Data.
131 \return true if data is expanded or the data is lazy but would resolve to expanded. False otherwise.
132 */
133 ESCRIPT_DLL_API int isExpanded(escriptDataC* data);
134
135 /**
136 \brief
137 Return a pointer to the data for the given sample number.
138 if data is empty NULL is returned.
139 data may be NULL, in which case NULL is returnd.
140 \param data Input - C wrapper for Data.
141 \param sampleNo Input - The sample number.
142
143 */
144 ESCRIPT_DLL_API double __const * getSampleDataRO(escriptDataC* data, int sampleNo);
145 /* Placement of __const might be important. See .cpp */
146
147
148 ESCRIPT_DLL_API double* getSampleDataRW(escriptDataC* data, int sampleNo);
149
150
151 /**
152 \brief
153 Return a pointer to the data for the given sample number.
154 Fast version of getSampledataRO: does no error checking.
155 \param data Input - C wrapper for Data.
156 \param sampleNo Input - The sample number.
157
158 */
159 ESCRIPT_DLL_API double __const* getSampleDataROFast(escriptDataC* data, int sampleNo);
160
161 /**
162 \brief
163 Return a pointer to the data for the given sample number.
164 Fast version of getSampledataRW: does no error checking.
165 \param data Input - C wrapper for Data.
166 \param sampleNo Input - The sample number.
167 */
168 ESCRIPT_DLL_API double* getSampleDataRWFast(escriptDataC* data, int sampleNo);
169
170
171 /**
172 \brief
173 Return getSampleDataRWFast(escriptDataC* data, 0) if there are samples.
174 if not, returns NULL.
175 \warning This function calls requireWrite if there are samples so do not use in parallel sections.
176 \warning Please do not use this in new code.
177 \param data Input - C wrapper for Data.
178 */
179 ESCRIPT_DLL_API double* getDataRW(escriptDataC* data);
180
181
182 /**
183 \brief Ensure that this object is ready for writing.
184 It will be resolved and copied if it is currently shared.
185 Use only in single threaded sections of code.
186 Do not create new Data objects based on this one between this call and
187 writing to the object.
188 */
189 ESCRIPT_DLL_API void requireWrite(escriptDataC* data);
190
191 #endif

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26