Skip to content

Commit a9c20e6

Browse files
authored
Add initplanesreal option (#24)
1 parent dafe7cb commit a9c20e6

File tree

4 files changed

+70
-13
lines changed

4 files changed

+70
-13
lines changed

AmrPicture.cpp

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,22 @@ AmrPicture::AmrPicture(GraphicsAttributes *gaptr,
100100
dataSize[ilev] = dataSizeH[ilev] * dataSizeV[ilev]; // for a picture (slice).
101101
}
102102

103-
if(AVGlobals::GivenInitialPlanes()) {
103+
if(AVGlobals::GivenInitialPlanes() || AVGlobals::GivenInitialPlanesReal()) {
104104
BL_ASSERT(BL_SPACEDIM == 3);
105+
IntVect initialplanes;
106+
if (AVGlobals::GivenInitialPlanes()) {
107+
initialplanes = AVGlobals::GetInitialPlanes();
108+
} else if (AVGlobals::GivenInitialPlanesReal()) {
109+
auto const location = AVGlobals::GetInitialPlanesReal();
110+
IntVect ivLoc;
111+
int ivLevel;
112+
amrData.IntVectFromLocation(pltAppStatePtr->FinestLevel(), location, ivLoc, ivLevel, initialplanes);
113+
}
105114
int coarsenCRR = amrex::CRRBetweenLevels(maxAllowableLevel,
106115
pltAppStatePtr->FinestLevel(),
107116
amrData.RefRatio());
108-
int tempSliceV = AVGlobals::GetInitialPlanes()[Amrvis::XDIR]; // at finest lev
109-
int tempSliceH = AVGlobals::GetInitialPlanes()[Amrvis::YDIR]; // at finest lev
117+
int tempSliceV = initialplanes[Amrvis::XDIR]; // at finest lev
118+
int tempSliceH = initialplanes[Amrvis::YDIR]; // at finest lev
110119
tempSliceV /= coarsenCRR;
111120
tempSliceH /= coarsenCRR;
112121
tempSliceH = subDomain[maxAllowableLevel].bigEnd(Amrvis::YDIR) - tempSliceH;
@@ -121,7 +130,7 @@ AmrPicture::AmrPicture(GraphicsAttributes *gaptr,
121130
subcutY = hLine;
122131
subcut2ndY = hLine;
123132

124-
int tempSlice = AVGlobals::GetInitialPlanes()[Amrvis::YZ - myView]; // at finest lev
133+
int tempSlice = initialplanes[Amrvis::YZ - myView]; // at finest lev
125134
tempSlice /= coarsenCRR;
126135
slice = amrex::max(std::min(tempSlice,
127136
subDomain[maxAllowableLevel].bigEnd(Amrvis::YZ-myView)),
@@ -245,8 +254,17 @@ AmrPicture::AmrPicture(int view, GraphicsAttributes *gaptr,
245254
subDomain[maxAllowableLevel].bigEnd(Amrvis::YZ-myView)),
246255
subDomain[maxAllowableLevel].smallEnd(Amrvis::YZ-myView));
247256
} else {
248-
if(AVGlobals::GivenInitialPlanes()) {
249-
int tempSlice = AVGlobals::GetInitialPlanes()[Amrvis::YZ - myView]; // finest lev
257+
if(AVGlobals::GivenInitialPlanes() || AVGlobals::GivenInitialPlanesReal()) {
258+
IntVect initialplanes;
259+
if (AVGlobals::GivenInitialPlanes()) {
260+
initialplanes = AVGlobals::GetInitialPlanes();
261+
} else if (AVGlobals::GivenInitialPlanesReal()) {
262+
auto const location = AVGlobals::GetInitialPlanesReal();
263+
IntVect ivLoc;
264+
int ivLevel;
265+
amrData.IntVectFromLocation(pltAppStatePtr->FinestLevel(), location, ivLoc, ivLevel, initialplanes);
266+
}
267+
int tempSlice = initialplanes[Amrvis::YZ - myView]; // finest lev
250268
int coarsenCRR = amrex::CRRBetweenLevels(maxAllowableLevel,
251269
pltAppStatePtr->FinestLevel(),
252270
amrData.RefRatio());
@@ -257,8 +275,8 @@ AmrPicture::AmrPicture(int view, GraphicsAttributes *gaptr,
257275

258276
int tempSliceV, tempSliceH;
259277
if(myView==Amrvis::XY) {
260-
tempSliceV = AVGlobals::GetInitialPlanes()[Amrvis::XDIR]; // at finest lev
261-
tempSliceH = AVGlobals::GetInitialPlanes()[Amrvis::YDIR]; // at finest lev
278+
tempSliceV = initialplanes[Amrvis::XDIR]; // at finest lev
279+
tempSliceH = initialplanes[Amrvis::YDIR]; // at finest lev
262280
tempSliceV /= coarsenCRR;
263281
tempSliceH /= coarsenCRR;
264282
tempSliceH = subDomain[maxAllowableLevel].bigEnd(Amrvis::YDIR) - tempSliceH;
@@ -269,8 +287,8 @@ AmrPicture::AmrPicture(int view, GraphicsAttributes *gaptr,
269287
subDomain[maxAllowableLevel].bigEnd(Amrvis::YDIR)),
270288
subDomain[maxAllowableLevel].smallEnd(Amrvis::YDIR));
271289
} else if(myView==Amrvis::XZ) {
272-
tempSliceV = AVGlobals::GetInitialPlanes()[Amrvis::XDIR]; // at finest lev
273-
tempSliceH = AVGlobals::GetInitialPlanes()[Amrvis::ZDIR]; // at finest lev
290+
tempSliceV = initialplanes[Amrvis::XDIR]; // at finest lev
291+
tempSliceH = initialplanes[Amrvis::ZDIR]; // at finest lev
274292
tempSliceV /= coarsenCRR;
275293
tempSliceH /= coarsenCRR;
276294
tempSliceH = subDomain[maxAllowableLevel].bigEnd(Amrvis::ZDIR) - tempSliceH;
@@ -281,8 +299,8 @@ AmrPicture::AmrPicture(int view, GraphicsAttributes *gaptr,
281299
subDomain[maxAllowableLevel].bigEnd(Amrvis::ZDIR)),
282300
subDomain[maxAllowableLevel].smallEnd(Amrvis::ZDIR));
283301
} else {
284-
tempSliceV = AVGlobals::GetInitialPlanes()[Amrvis::YDIR]; // at finest lev
285-
tempSliceH = AVGlobals::GetInitialPlanes()[Amrvis::ZDIR]; // at finest lev
302+
tempSliceV = initialplanes[Amrvis::YDIR]; // at finest lev
303+
tempSliceH = initialplanes[Amrvis::ZDIR]; // at finest lev
286304
tempSliceV /= coarsenCRR;
287305
tempSliceH /= coarsenCRR;
288306
tempSliceH = subDomain[maxAllowableLevel].bigEnd(Amrvis::ZDIR) - tempSliceH;

Docs/Amrvis.tex

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ \subsubsection{Command Line Interface and Utility Files}
8383
[-makeswf_value]
8484
[-valuemodel]
8585
[-initplanes xp yp zp]
86+
[-initplanesreal xp yp zp]
8687
[-useminmax min max]
8788
[<filename(s)>]
8889
@@ -128,7 +129,8 @@ \subsubsection{Command Line Interface and Utility Files}
128129
note: works in batch mode.
129130
-makeswf_value same as above, with value model rendering.
130131
-valuemodel start with the value model for rendering.
131-
-initplanes xp yp zp set initial planes
132+
-initplanes xp yp zp set initial planes in finest level grid cells
133+
-initplanesreal xp yp zp set initial planes in real units
132134
-useminmax min max use min and max as the global min max values
133135
<filename(s)> must be included if box is specified.
134136
\end{verbatim}

GlobalUtilities.H

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ namespace AVGlobals {
8787
int GetFabOutFormat();
8888
bool GivenInitialPlanes();
8989
amrex::IntVect GetInitialPlanes();
90+
bool GivenInitialPlanesReal();
91+
amrex::Vector< Real > GetInitialPlanesReal();
9092
bool IsProfDirName(const std::string &pdname);
9193

9294
// -------------------- cartGrid functions

GlobalUtilities.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ bool bShowBody(true);
6262
Real bodyOpacity(0.05);
6363
bool givenInitialPlanes(false);
6464
IntVect ivInitialPlanes;
65+
bool givenInitialPlanesReal(false);
66+
Vector< Real > ivInitialPlanesReal;
6567
AVGlobals::ENUserVectorNames givenUserVectorNames(AVGlobals::enUserNone);
6668
Vector<string> userVectorNames(BL_SPACEDIM);
6769
bool newPltSet(false);
@@ -487,6 +489,15 @@ void AVGlobals::GetDefaults(const string &defaultsFile) {
487489
ivInitialPlanes.setVal(Amrvis::ZDIR, tempZ);
488490
givenInitialPlanes = true;
489491
}
492+
else if(strcmp(defaultString, "initplanesreal") == 0) {
493+
float tempX, tempY, tempZ;
494+
sscanf(buffer, "%s%e%e%e", defaultString, &tempX, &tempY, &tempZ);
495+
ivInitialPlanesReal.resize(BL_SPACEDIM);
496+
ivInitialPlanesReal[Amrvis::XDIR] = tempX;
497+
ivInitialPlanesReal[Amrvis::YDIR] = tempY;
498+
ivInitialPlanesReal[Amrvis::ZDIR] = tempZ;
499+
givenInitialPlanesReal = true;
500+
}
490501
#endif
491502
else if(strcmp(defaultString, "setvelnames") == 0) {
492503
#if (BL_SPACEDIM == 2)
@@ -642,6 +653,8 @@ void AVGlobals::ParseCommandLine(int argc, char *argv[]) {
642653
char clbz[32];
643654
char clPlaneX[32], clPlaneY[32], clPlaneZ[32];
644655
bool givenInitialPlanesOnComline(false);
656+
char clPlaneXReal[32], clPlaneYReal[32], clPlaneZReal[32];
657+
bool givenInitialPlanesRealOnComline(false);
645658
#endif
646659

647660
givenFilename = false;
@@ -940,6 +953,19 @@ void AVGlobals::ParseCommandLine(int argc, char *argv[]) {
940953
i += 3;
941954
givenInitialPlanes = true;
942955
givenInitialPlanesOnComline = true;
956+
} else if(strcmp(argv[i], "-initplanesreal") == 0) {
957+
if(argc-1<i+1 || ! strcpy(clPlaneXReal, argv[i+1])) {
958+
PrintUsage(argv[0]);
959+
}
960+
if(argc-1<i+2 || ! strcpy(clPlaneYReal, argv[i+2])) {
961+
PrintUsage(argv[0]);
962+
}
963+
if(argc-1<i+3 || ! strcpy(clPlaneZReal, argv[i+3])) {
964+
PrintUsage(argv[0]);
965+
}
966+
i += 3;
967+
givenInitialPlanesReal = true;
968+
givenInitialPlanesRealOnComline = true;
943969
#endif
944970
} else if(strcmp(argv[i],"-palette") == 0) {
945971
PltApp::SetDefaultPalette(argv[i+1]);
@@ -1104,6 +1130,12 @@ void AVGlobals::ParseCommandLine(int argc, char *argv[]) {
11041130
ivInitialPlanes.setVal(Amrvis::YDIR, atoi(clPlaneY));
11051131
ivInitialPlanes.setVal(Amrvis::ZDIR, atoi(clPlaneZ));
11061132
}
1133+
if(givenInitialPlanesRealOnComline) {
1134+
ivInitialPlanesReal.resize(BL_SPACEDIM);
1135+
ivInitialPlanesReal[Amrvis::XDIR] = atof(clPlaneXReal);
1136+
ivInitialPlanesReal[Amrvis::YDIR] = atof(clPlaneYReal);
1137+
ivInitialPlanesReal[Amrvis::ZDIR] = atof(clPlaneZReal);
1138+
}
11071139
#endif
11081140

11091141

@@ -1195,6 +1227,9 @@ void AVGlobals::GetSpecifiedMinMax(Real &specifiedmin, Real &specifiedmax) {
11951227
bool AVGlobals::GivenInitialPlanes() { return givenInitialPlanes; }
11961228
IntVect AVGlobals::GetInitialPlanes() { return ivInitialPlanes; }
11971229

1230+
bool AVGlobals::GivenInitialPlanesReal() { return givenInitialPlanesReal; }
1231+
Vector <Real> AVGlobals::GetInitialPlanesReal() { return ivInitialPlanesReal; }
1232+
11981233
// -------------------------------------------------------------------
11991234
/*int AVGlobals::CRRBetweenLevels(int fromlevel, int tolevel,
12001235
const Vector<int> &refratios)

0 commit comments

Comments
 (0)