1 |
// $Id$ |
|
2 |
/* |
/******************************************************* |
3 |
****************************************************************************** |
* |
4 |
* * |
* Copyright (c) 2003-2012 by University of Queensland |
5 |
* COPYRIGHT ACcESS 2004 - All Rights Reserved * |
* Earth Systems Science Computational Center (ESSCC) |
6 |
* * |
* http://www.uq.edu.au/esscc |
7 |
* This software is the property of ACcESS. No part of this code * |
* |
8 |
* may be copied in any form or by any means without the expressed written * |
* Primary Business: Queensland, Australia |
9 |
* consent of ACcESS. Copying, use or modification of this software * |
* Licensed under the Open Software License version 3.0 |
10 |
* by any unauthorised person is illegal unless that person has a software * |
* http://www.opensource.org/licenses/osl-3.0.php |
11 |
* license agreement with ACcESS. * |
* |
12 |
* * |
*******************************************************/ |
13 |
****************************************************************************** |
|
|
*/ |
|
14 |
|
|
15 |
extern "C" { |
extern "C" { |
16 |
#include "escript/Data/DataC.h" |
#include "DataC.h" |
17 |
} |
} |
18 |
|
|
19 |
#include "escript/Data/Data.h" |
#include "Data.h" |
20 |
#include "escript/Data/DataArrayView.h" |
#include "DataTypes.h" |
21 |
|
|
22 |
int getFunctionSpaceType(struct escriptDataC* data) |
int getFunctionSpaceType(struct escriptDataC* data) |
23 |
{ |
{ |
35 |
if (temp->isEmpty()) { |
if (temp->isEmpty()) { |
36 |
return true; |
return true; |
37 |
} else { |
} else { |
38 |
escript::DataArrayView::ShapeType givenShape(&dimensions[0],&dimensions[rank]); |
escript::DataTypes::ShapeType givenShape(&dimensions[0],&dimensions[rank]); |
39 |
return (temp->getPointDataView().getShape()==givenShape); |
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 |
} |
} |
82 |
} |
} |
83 |
} |
} |
84 |
|
|
85 |
int* getDataPointShape(struct escriptDataC* data) |
int getDataPointShape(struct escriptDataC* data,int i) |
86 |
{ |
{ |
87 |
escript::Data* temp=(escript::Data*)(data->m_dataPtr); |
if (data == (struct escriptDataC*)0) { |
88 |
const escript::DataArrayView::ShapeType view=temp->getDataPointShape(); |
return 0; |
89 |
return (int*) &(view[0]); |
} 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) |
int getDataPointSize(struct escriptDataC* data) |
119 |
if (temp->isEmpty()) { |
if (temp->isEmpty()) { |
120 |
return false; |
return false; |
121 |
} else { |
} else { |
122 |
return temp->isExpanded(); |
return temp->actsExpanded(); |
123 |
} |
} |
124 |
} |
} |
125 |
} |
} |
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) |
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); |
151 |
|
} |
152 |
|
} |
153 |
|
} |
154 |
|
|
155 |
double* getSampleData(struct escriptDataC* data, int sampleNo) |
double* getSampleDataRW(struct escriptDataC* data, int sampleNo) |
156 |
{ |
{ |
157 |
if (data == (struct escriptDataC*)0) { |
if (data == (struct escriptDataC*)0) { |
158 |
return NULL; |
return NULL; |
161 |
if (temp->isEmpty()) { |
if (temp->isEmpty()) { |
162 |
return NULL; |
return NULL; |
163 |
} else { |
} else { |
164 |
return temp->getSampleData(sampleNo); |
return temp->getSampleDataRW(sampleNo); |
165 |
} |
} |
166 |
} |
} |
167 |
} |
} |
168 |
|
|
169 |
|
const double* getSampleDataROFast(struct escriptDataC* data, int sampleNo) |
170 |
|
{ |
171 |
|
escript::Data* temp=(escript::Data*)(data->m_dataPtr); |
172 |
|
return temp->getSampleDataRO(sampleNo); |
173 |
|
} |
174 |
|
|
175 |
|
double* getSampleDataRWFast(struct escriptDataC* data, int sampleNo) |
176 |
|
{ |
177 |
|
escript::Data* temp=(escript::Data*)(data->m_dataPtr); |
178 |
|
return temp->getSampleDataRW(sampleNo); |
179 |
|
} |
180 |
|
|
181 |
|
double* getDataRW(escriptDataC* data) |
182 |
|
{ |
183 |
|
escript::Data* temp=(escript::Data*)(data->m_dataPtr); |
184 |
|
if (temp->getNumSamples()>0) |
185 |
|
{ |
186 |
|
requireWrite(data); |
187 |
|
return getSampleDataRWFast(data,0); |
188 |
|
} |
189 |
|
return 0; |
190 |
|
} |
191 |
|
|
192 |
|
|
193 |
|
void requireWrite(escriptDataC* data) |
194 |
|
{ |
195 |
|
if (data == (struct escriptDataC*)0) { |
196 |
|
return; |
197 |
|
} else { |
198 |
|
((escript::Data*)(data->m_dataPtr))->requireWrite(); |
199 |
|
} |
200 |
|
} |