/[escript]/branches/arrexp_2137_win_merge/escript/src/DataC.cpp
ViewVC logotype

Contents of /branches/arrexp_2137_win_merge/escript/src/DataC.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2213 - (show annotations)
Wed Jan 14 00:23:39 2009 UTC (10 years, 7 months ago) by jfenwick
File size: 4947 byte(s)
In preparation for merging to trunk

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 extern "C" {
16 #include "DataC.h"
17 }
18
19 #include "Data.h"
20 #include "DataTypes.h"
21
22 int getFunctionSpaceType(struct escriptDataC* data)
23 {
24 escript::Data* temp=(escript::Data*)(data->m_dataPtr);
25 return temp->getFunctionSpace().getTypeCode();
26 }
27
28
29 int isDataPointShapeEqual(struct escriptDataC* data, int rank, int* dimensions)
30 {
31 if (data == (struct escriptDataC*)0) {
32 return true;
33 } else {
34 escript::Data* temp=(escript::Data*)(data->m_dataPtr);
35 if (temp->isEmpty()) {
36 return true;
37 } else {
38 escript::DataTypes::ShapeType givenShape(&dimensions[0],&dimensions[rank]);
39 return (temp->getDataPointShape()==givenShape);
40 }
41 }
42 }
43
44 int getNumDataPointsPerSample(struct escriptDataC* data)
45 {
46 if (data == (struct escriptDataC*)0) {
47 return 0;
48 } else {
49 escript::Data* temp=(escript::Data*)(data->m_dataPtr);
50 if (temp->isEmpty()) {
51 return 0;
52 } else {
53 return (temp->getNumDataPointsPerSample());
54 }
55 }
56 }
57
58 int numSamplesEqual(struct escriptDataC* data, int numDataPointsPerSample,
59 int numSamples)
60 {
61 if (data == (struct escriptDataC*)0) {
62 return true;
63 } else {
64 escript::Data* temp=(escript::Data*)(data->m_dataPtr);
65 if (temp->isEmpty()) {
66 return true;
67 } else {
68 int result=(numDataPointsPerSample==temp->getNumDataPointsPerSample());
69 result=result && (numSamples==temp->getNumSamples());
70 return result;
71 }
72 }
73 }
74
75 int getDataPointRank(struct escriptDataC* data)
76 {
77 if (data == (struct escriptDataC*)0) {
78 return 0;
79 } else {
80 escript::Data* temp=(escript::Data*)(data->m_dataPtr);
81 return temp->getDataPointRank();
82 }
83 }
84
85 int getDataPointShape(struct escriptDataC* data,int i)
86 {
87 if (data == (struct escriptDataC*)0) {
88 return 0;
89 } else {
90 escript::Data* temp=(escript::Data*)(data->m_dataPtr);
91 int rank = temp->getDataPointRank();
92 if (i<0 || i>=rank) {
93 return 1;
94 } else {
95 const escript::DataTypes::ShapeType view=temp->getDataPointShape();
96 return view[i];
97 }
98 }
99 }
100
101 int getDataPointSize(struct escriptDataC* data)
102 {
103 escript::Data* temp=(escript::Data*)(data->m_dataPtr);
104 return temp->getDataPointSize();
105 }
106
107 int getLength(struct escriptDataC* data)
108 {
109 escript::Data* temp=(escript::Data*)(data->m_dataPtr);
110 return temp->getLength();
111 }
112
113 int isExpanded(struct escriptDataC* data)
114 {
115 if (data == (struct escriptDataC*)0) {
116 return false;
117 } else {
118 escript::Data* temp=(escript::Data*)(data->m_dataPtr);
119 if (temp->isEmpty()) {
120 return false;
121 } else {
122 return temp->actsExpanded();
123 }
124 }
125 }
126
127 int isEmpty(escriptDataC* data)
128 {
129 if (data == (struct escriptDataC*)0) {
130 return true;
131 } else {
132 escript::Data* temp=(escript::Data*)(data->m_dataPtr);
133 return temp->isEmpty();
134 }
135 }
136
137 // The unusual (for me) ordering of __const here is because I'm not sure
138 // whether gcc would try to interpret __const as a function attribute rather than
139 // a modifier on the return value. Putting it here should remove any ambiguity
140 // I have used const rather than __const in the cpp because only c++ will be reading the cpp.
141 double const* getSampleDataRO(struct escriptDataC* data, int sampleNo, void* buffer)
142 {
143 if (data == (struct escriptDataC*)0) {
144 return NULL;
145 } else {
146 escript::Data* temp=(escript::Data*)(data->m_dataPtr);
147 if (temp->isEmpty()) {
148 return NULL;
149 } else {
150 return temp->getSampleDataRO(sampleNo,reinterpret_cast<escript::DataTypes::ValueType*>(buffer));
151 }
152 }
153 }
154
155 double* getSampleDataRW(struct escriptDataC* data, int sampleNo)
156 {
157 if (data == (struct escriptDataC*)0) {
158 return NULL;
159 } else {
160 escript::Data* temp=(escript::Data*)(data->m_dataPtr);
161 if (temp->isEmpty()) {
162 return NULL;
163 } else {
164 return temp->getSampleDataRW(sampleNo);
165 }
166 }
167 }
168
169 double* getSampleDataFast(struct escriptDataC* data, int sampleNo)
170 {
171 escript::Data* temp=(escript::Data*)(data->m_dataPtr);
172 return temp->getSampleDataRW(sampleNo);
173 }
174
175 void* allocSampleBuffer(escriptDataC* data)
176 {
177 if (data == (struct escriptDataC*)0) {
178 return NULL;
179 } else {
180 escript::Data* temp=(escript::Data*)(data->m_dataPtr);
181 return temp->allocSampleBuffer();
182 }
183 }
184
185 // Not going to the c++ member for this because I don't need an instance to do this
186 void freeSampleBuffer(void* buffer)
187 {
188 if (buffer!=NULL)
189 {
190 delete (reinterpret_cast<escript::DataTypes::ValueType*>(buffer));
191 }
192 }
193

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26