-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathGridPicture.cpp
110 lines (92 loc) · 3.33 KB
/
GridPicture.cpp
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
// -------------------------------------------------------------------
// GridPicture.cpp
// -------------------------------------------------------------------
#include <GridPicture.H>
#include <GlobalUtilities.H>
#include <climits>
#include <cfloat>
using namespace amrex;
// -------------------------------------------------------------------
GridPicture::GridPicture() {
}
// -------------------------------------------------------------------
void GridPicture::GridPictureInit(int /*level*/,
int rratio, int scale, int picSizeH, int picSizeV,
const Box &overlapbox,
const Box &boxWithData, int slicedir)
{
sliceDir = slicedir;
refRatio = rratio;
currentScale = scale;
pictureSizeH = picSizeH;
pictureSizeV = picSizeV;
overlapBox = overlapbox;
BL_ASSERT(overlapBox.sameSize(boxWithData));
imageBox = overlapBox;
imageBox.refine(refRatio * currentScale);
if(sliceDir == Amrvis::ZDIR) {
dataSizeH = boxWithData.length(Amrvis::XDIR);
#if (BL_SPACEDIM == 1)
dataSizeV = 1;
#else
dataSizeV = boxWithData.length(Amrvis::YDIR);
#endif
} else if(sliceDir == Amrvis::YDIR) {
dataSizeV = boxWithData.length(Amrvis::ZDIR);
dataSizeH = boxWithData.length(Amrvis::XDIR);
} else {
dataSizeH = boxWithData.length(Amrvis::YDIR);
dataSizeV = boxWithData.length(Amrvis::ZDIR);
}
imageSizeH = dataSizeH * refRatio * currentScale;
imageSizeV = dataSizeV * refRatio * currentScale;
} // end GridPictureInit
// -------------------------------------------------------------------
GridPicture::~GridPicture() {
}
// -------------------------------------------------------------------
void GridPicture::ChangeScale(int newScale, int picSizeH, int picSizeV) {
currentScale = newScale;
imageBox = overlapBox;
imageBox.refine(refRatio * currentScale);
// use datasize instead of imageBox.length() for node centered boxes
imageSizeH = dataSizeH * refRatio * currentScale;
imageSizeV = dataSizeV * refRatio * currentScale;
pictureSizeH = picSizeH;
pictureSizeV = picSizeV;
}
// -------------------------------------------------------------------
int GridPicture::HPositionInPicture() {
int endLoc;
if(sliceDir == Amrvis::ZDIR) {
endLoc = imageBox.smallEnd()[Amrvis::XDIR];
} else if(sliceDir == Amrvis::YDIR) {
endLoc = imageBox.smallEnd()[Amrvis::XDIR];
} else {
endLoc = imageBox.smallEnd()[Amrvis::YDIR];
}
return (endLoc - ((int) imageSizeH % refRatio));
}
// -------------------------------------------------------------------
int GridPicture::VPositionInPicture() {
int endLoc, nodeAdjustment;
if(sliceDir == Amrvis::ZDIR) {
#if (BL_SPACEDIM == 1)
endLoc = pictureSizeV - 1;
nodeAdjustment = 0;
#else
endLoc = imageBox.bigEnd()[Amrvis::YDIR];
nodeAdjustment = imageBox.type()[Amrvis::YDIR] * (currentScale - 1) * refRatio;
#endif
} else if(sliceDir == Amrvis::YDIR) {
endLoc = imageBox.bigEnd()[Amrvis::ZDIR];
nodeAdjustment = imageBox.type()[Amrvis::ZDIR] * (currentScale - 1) * refRatio;
} else {
endLoc = imageBox.bigEnd()[Amrvis::ZDIR];
nodeAdjustment = imageBox.type()[Amrvis::ZDIR] * (currentScale - 1) * refRatio;
}
return ((pictureSizeV-1) - endLoc - ((int) imageSizeV % refRatio) -
nodeAdjustment);
}
// -------------------------------------------------------------------
// -------------------------------------------------------------------