-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSCC_GridFunctionNdSkin.h
More file actions
273 lines (199 loc) · 6.3 KB
/
SCC_GridFunctionNdSkin.h
File metadata and controls
273 lines (199 loc) · 6.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
/*
* SCC_GridFunctionNdSkin.h
*
* Classes : SCC::GridFunction1dSkin
* SCC::GridFunction2dSkin
* SCC::GridFunction3dSkin
*
*
* These classes provide a GridFunctionNd wrapper (or skin) for existing data.
*
* It is assumed that the data associated with an X-panels x Y-panels x Z-panels
* grid is a single double* array of size (X-panels + 1)(Y-panels + 1)(Z-panels + 1)
* stored by ROWS (C convention).
*
* There is no internal validation on the assumption about the size and storage
* format associated with the data pointer used to initialize an instance
* of the GridFunctionNdSkin class.
*
* The methods are primarily provided as a utility for utilizing
* methods whose input and output arugments are SCC::GridFunctionNd
* instances.
*
* Typical usage
*
* G = a grid object with data stored in a double* objectData
*
* (1) GridFunctionNdSkin GS(G.objectData, xPanels, xMin, xMax, ....)
*
* (2) Call member function requiring GridFunctionNd arguments and specify GS instead of G
*
* Transformations of the data associated with GS will will be performed on the
* data of the associated grid object G.
*
* No data copying is required.
*
*
* Created on: Sep 30, 2016
* Author: anderson
*
*
* Release : 18.09.03
*/
/*
#############################################################################
#
# Copyright 2015-16 Chris Anderson
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the Lesser GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# For a copy of the GNU General Public License see
# <http://www.gnu.org/licenses/>.
#
#############################################################################
*/
#include "SCC_GridFunction1d.h"
#include "SCC_GridFunction2d.h"
#include "SCC_GridFunction3d.h"
#ifndef SCC_GRID_FUNCTION_ND_SKIN_
#define SCC_GRID_FUNCTION_ND_SKIN_
namespace SCC
{
class GridFunction1dSkin : public GridFunction1d
{
public:
GridFunction1dSkin() : GridFunction1d()
{
this->dataPtr = nullptr;
};
GridFunction1dSkin(const GridFunction1dSkin& G)
{
initialize(G.dataPtr, G.xPanels, G.xMin, G.xMax);
};
GridFunction1dSkin(double* data1d, long xPanels, double xMin, double xMax)
{
initialize(data1d, xPanels, xMin, xMax);
}
void initialize(double* data1d, long xPanels, double xMin, double xMax)
{
// Set internal data pointer to null ptr then call base class initialize
this->dataPtr = nullptr;
GridFunction1d::initialize();
// Set internal data pointer to supplied data pointer
this->dataPtr = data1d;
// Pack structure informaiton
// DoubleVector1d structure information
this->index1Size = xPanels+1;
// GridFunction1d structure information
this->xPanels = xPanels;
this->xMin = xMin;
this->xMax = xMax;
this->hx = (xMax-xMin)/(double)(xPanels);
}
virtual ~GridFunction1dSkin()
{
// Don't delete the data associated with the instance
this->dataPtr = nullptr;
}
};
class GridFunction2dSkin : public GridFunction2d
{
public:
GridFunction2dSkin() : GridFunction2d()
{
this->dataPtr = nullptr;
};
GridFunction2dSkin(const GridFunction2dSkin& G)
{
initialize(G.dataPtr, G.xPanels, G.xMin, G.xMax, G.yPanels, G.yMin, G.yMax);
};
GridFunction2dSkin(double* data2d, long xPanels, double xMin, double xMax, long yPanels, double yMin, double yMax)
{
initialize(data2d, xPanels, xMin, xMax, yPanels, yMin, yMax);
}
void initialize(double* data2d, long xPanels, double xMin, double xMax, long yPanels, double yMin, double yMax)
{
// Set internal data pointer to null ptr then call base class initialize
this->dataPtr = nullptr;
GridFunction2d::initialize();
// Set internal data pointer to supplied data pointer
this->dataPtr = data2d;
// Pack structure informaiton
// DoubleVector3d structure information
this->index1Size = xPanels+1;
this->index2Size = yPanels+1;
// GridFunction3d structure information
this->xPanels = xPanels;
this->yPanels = yPanels;
this->xMin = xMin;
this->xMax = xMax;
this->yMin = yMin;
this->yMax = yMax;
this->hx = (xMax-xMin)/(double)(xPanels);
this->hy = (yMax-yMin)/(double)(yPanels);
}
virtual ~GridFunction2dSkin()
{
// Don't delete the data associated with the instance
this->dataPtr = nullptr;
}
};
class GridFunction3dSkin : public GridFunction3d
{
public:
GridFunction3dSkin() : GridFunction3d()
{
this->dataPtr = nullptr;
};
GridFunction3dSkin(const GridFunction3dSkin& G)
{
initialize(G.dataPtr, G.xPanels, G.xMin, G.xMax, G.yPanels, G.yMin, G.yMax, G.zPanels, G.zMin, G.zMax);
};
GridFunction3dSkin(double* data3d, long xPanels, double xMin, double xMax, long yPanels, double yMin, double yMax,
long zPanels, double zMin, double zMax)
{
initialize(data3d, xPanels, xMin, xMax, yPanels, yMin, yMax, zPanels, zMin, zMax);
}
void initialize(double* data3d, long xPanels, double xMin, double xMax, long yPanels, double yMin, double yMax,
long zPanels, double zMin, double zMax)
{
// Set internal data pointer to null ptr then call base class initialize
this->dataPtr = nullptr;
GridFunction3d::initialize();
// Set internal data pointer to supplied data pointer
this->dataPtr = data3d;
// Pack structure informaiton
// DoubleVector3d structure information
this->index1Size = xPanels+1;
this->index2Size = yPanels+1;
this->index3Size = zPanels+1;
// GridFunction3d structure information
this->xPanels = xPanels;
this->yPanels = yPanels;
this->zPanels = zPanels;
this->xMin = xMin;
this->xMax = xMax;
this->yMin = yMin;
this->yMax = yMax;
this->zMin = zMin;
this->zMax = zMax;
this->hx = (xMax-xMin)/(double)(xPanels);
this->hy = (yMax-yMin)/(double)(yPanels);
this->hz = (zMax-zMin)/(double)(zPanels);
}
virtual ~GridFunction3dSkin()
{
// Don't delete the data associated with the instance
this->dataPtr = nullptr;
}
};
}
#endif /*SCC_GridFunctionNdSkin_*/