-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSCC_GridFunction2dSliceOp.h
More file actions
162 lines (135 loc) · 3.75 KB
/
SCC_GridFunction2dSliceOp.h
File metadata and controls
162 lines (135 loc) · 3.75 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
/*
* GridFunction2dSliceOp: A utility class to facilitate thread-safe insertion and extraction
* of coordinate slices of data associated with GridFunction2d instances.
*
* The only data member of this class is a pointer to a SCC::GridFunction2d instance
* to which one wants to extract coordinate slices or insert coordinate slices.
*
* To create thread-safe code one typically creates a vector of instances of this class that
* are all associated with a single SCC::GridFunction2d instance. One then multi-threads
* an insertion or extraction loop using the instance with index equal to the thread index
* inside the loop. As long as the overall insertion or extraction loop is
* indexing disjoint data of the SCC::GridFunction2d, the extraction or insertion
* will be thread-safe.
*
*
* Warning: When inserting data you have to be a bit careful that one doesn't insert
* data that "crosses", e.g. insert data slices corresponding to different coordinate
* directions.
*
*
*
* SCC_GridFunction2dSliceOp3d.h
*
* Created on: Feb 25, 2016
* Author: anderson
*
* Release : 18.09.03
*/
/*
#############################################################################
#
# Copyright 2016 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/>.
#
###
*/
#ifndef SCC_GRID_FUNCTION_2D_SLICE_OP_
#define SCC_GRID_FUNCTION_2D_SLICE_OP_
#include "SCC_GridFunction1d.h"
#include "SCC_GridFunction2d.h"
#include "SCC_GridFunction2d.h"
namespace SCC
{
class GridFunction2dSliceOp
{
public:
GridFunction2dSliceOp()
{
gridFunPtr= nullptr;
};
GridFunction2dSliceOp(GridFunction2d& R)
{
gridFunPtr= &R;
};
GridFunction2dSliceOp(const GridFunction2dSliceOp& R)
{
gridFunPtr= R.gridFunPtr;
};
void initialize()
{
gridFunPtr= nullptr;
};
void initialize(GridFunction2d& R)
{
gridFunPtr= &R;
};
void initialize(const GridFunction2dSliceOp& R)
{
gridFunPtr= R.gridFunPtr;
};
GridFunction1d getConstantYslice(long yIndex) const // (x function)
{
GridFunction1d R(gridFunPtr->xPanels, gridFunPtr->xMin, gridFunPtr->xMax);
for(long i = 0; i <= gridFunPtr->xPanels; i++)
{
R.Values(i) = gridFunPtr->Values(i,yIndex);
}
return R;
}
void getConstantYslice(long yIndex, GridFunction1d& R) const // (x function)
{
for(long i = 0; i <= gridFunPtr->xPanels; i++)
{
R.Values(i) = gridFunPtr->Values(i,yIndex);
}
}
GridFunction1d getConstantXslice(long xIndex) const //( y function)
{
GridFunction1d R(gridFunPtr->yPanels,gridFunPtr->yMin,gridFunPtr->yMax);
for(long j = 0; j <= gridFunPtr->yPanels; j++)
{
R.Values(j) = gridFunPtr->Values(xIndex,j);
}
return R;
}
void getConstantXslice(long xIndex, GridFunction1d& R) const //( y function)
{
for(long j = 0; j <= gridFunPtr->yPanels; j++)
{
R.Values(j) = gridFunPtr->Values(xIndex,j);
}
}
///
/// Insertion
///
void setConstantYslice(long yIndex, const GridFunction1d& R) const // (x function)
{
for(long i = 0; i <= gridFunPtr->xPanels; i++)
{
gridFunPtr->Values(i,yIndex) = R.Values(i);
}
}
void setConstantXslice(long xIndex, const GridFunction1d& R) const //( y function)
{
for(long j = 0; j <= gridFunPtr->yPanels; j++)
{
gridFunPtr->Values(xIndex,j) = R.Values(j);
}
}
SCC::GridFunction2d* gridFunPtr;
};
} // Namespace SCC
#endif /* CLAQ_GridFunction2dSliceOp */