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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26