Skip to content

Commit

Permalink
Add initplanesreal option (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
dpgrote authored May 31, 2022
1 parent dafe7cb commit a9c20e6
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 13 deletions.
42 changes: 30 additions & 12 deletions AmrPicture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,22 @@ AmrPicture::AmrPicture(GraphicsAttributes *gaptr,
dataSize[ilev] = dataSizeH[ilev] * dataSizeV[ilev]; // for a picture (slice).
}

if(AVGlobals::GivenInitialPlanes()) {
if(AVGlobals::GivenInitialPlanes() || AVGlobals::GivenInitialPlanesReal()) {
BL_ASSERT(BL_SPACEDIM == 3);
IntVect initialplanes;
if (AVGlobals::GivenInitialPlanes()) {
initialplanes = AVGlobals::GetInitialPlanes();
} else if (AVGlobals::GivenInitialPlanesReal()) {
auto const location = AVGlobals::GetInitialPlanesReal();
IntVect ivLoc;
int ivLevel;
amrData.IntVectFromLocation(pltAppStatePtr->FinestLevel(), location, ivLoc, ivLevel, initialplanes);
}
int coarsenCRR = amrex::CRRBetweenLevels(maxAllowableLevel,
pltAppStatePtr->FinestLevel(),
amrData.RefRatio());
int tempSliceV = AVGlobals::GetInitialPlanes()[Amrvis::XDIR]; // at finest lev
int tempSliceH = AVGlobals::GetInitialPlanes()[Amrvis::YDIR]; // at finest lev
int tempSliceV = initialplanes[Amrvis::XDIR]; // at finest lev
int tempSliceH = initialplanes[Amrvis::YDIR]; // at finest lev
tempSliceV /= coarsenCRR;
tempSliceH /= coarsenCRR;
tempSliceH = subDomain[maxAllowableLevel].bigEnd(Amrvis::YDIR) - tempSliceH;
Expand All @@ -121,7 +130,7 @@ AmrPicture::AmrPicture(GraphicsAttributes *gaptr,
subcutY = hLine;
subcut2ndY = hLine;

int tempSlice = AVGlobals::GetInitialPlanes()[Amrvis::YZ - myView]; // at finest lev
int tempSlice = initialplanes[Amrvis::YZ - myView]; // at finest lev
tempSlice /= coarsenCRR;
slice = amrex::max(std::min(tempSlice,
subDomain[maxAllowableLevel].bigEnd(Amrvis::YZ-myView)),
Expand Down Expand Up @@ -245,8 +254,17 @@ AmrPicture::AmrPicture(int view, GraphicsAttributes *gaptr,
subDomain[maxAllowableLevel].bigEnd(Amrvis::YZ-myView)),
subDomain[maxAllowableLevel].smallEnd(Amrvis::YZ-myView));
} else {
if(AVGlobals::GivenInitialPlanes()) {
int tempSlice = AVGlobals::GetInitialPlanes()[Amrvis::YZ - myView]; // finest lev
if(AVGlobals::GivenInitialPlanes() || AVGlobals::GivenInitialPlanesReal()) {
IntVect initialplanes;
if (AVGlobals::GivenInitialPlanes()) {
initialplanes = AVGlobals::GetInitialPlanes();
} else if (AVGlobals::GivenInitialPlanesReal()) {
auto const location = AVGlobals::GetInitialPlanesReal();
IntVect ivLoc;
int ivLevel;
amrData.IntVectFromLocation(pltAppStatePtr->FinestLevel(), location, ivLoc, ivLevel, initialplanes);
}
int tempSlice = initialplanes[Amrvis::YZ - myView]; // finest lev
int coarsenCRR = amrex::CRRBetweenLevels(maxAllowableLevel,
pltAppStatePtr->FinestLevel(),
amrData.RefRatio());
Expand All @@ -257,8 +275,8 @@ AmrPicture::AmrPicture(int view, GraphicsAttributes *gaptr,

int tempSliceV, tempSliceH;
if(myView==Amrvis::XY) {
tempSliceV = AVGlobals::GetInitialPlanes()[Amrvis::XDIR]; // at finest lev
tempSliceH = AVGlobals::GetInitialPlanes()[Amrvis::YDIR]; // at finest lev
tempSliceV = initialplanes[Amrvis::XDIR]; // at finest lev
tempSliceH = initialplanes[Amrvis::YDIR]; // at finest lev
tempSliceV /= coarsenCRR;
tempSliceH /= coarsenCRR;
tempSliceH = subDomain[maxAllowableLevel].bigEnd(Amrvis::YDIR) - tempSliceH;
Expand All @@ -269,8 +287,8 @@ AmrPicture::AmrPicture(int view, GraphicsAttributes *gaptr,
subDomain[maxAllowableLevel].bigEnd(Amrvis::YDIR)),
subDomain[maxAllowableLevel].smallEnd(Amrvis::YDIR));
} else if(myView==Amrvis::XZ) {
tempSliceV = AVGlobals::GetInitialPlanes()[Amrvis::XDIR]; // at finest lev
tempSliceH = AVGlobals::GetInitialPlanes()[Amrvis::ZDIR]; // at finest lev
tempSliceV = initialplanes[Amrvis::XDIR]; // at finest lev
tempSliceH = initialplanes[Amrvis::ZDIR]; // at finest lev
tempSliceV /= coarsenCRR;
tempSliceH /= coarsenCRR;
tempSliceH = subDomain[maxAllowableLevel].bigEnd(Amrvis::ZDIR) - tempSliceH;
Expand All @@ -281,8 +299,8 @@ AmrPicture::AmrPicture(int view, GraphicsAttributes *gaptr,
subDomain[maxAllowableLevel].bigEnd(Amrvis::ZDIR)),
subDomain[maxAllowableLevel].smallEnd(Amrvis::ZDIR));
} else {
tempSliceV = AVGlobals::GetInitialPlanes()[Amrvis::YDIR]; // at finest lev
tempSliceH = AVGlobals::GetInitialPlanes()[Amrvis::ZDIR]; // at finest lev
tempSliceV = initialplanes[Amrvis::YDIR]; // at finest lev
tempSliceH = initialplanes[Amrvis::ZDIR]; // at finest lev
tempSliceV /= coarsenCRR;
tempSliceH /= coarsenCRR;
tempSliceH = subDomain[maxAllowableLevel].bigEnd(Amrvis::ZDIR) - tempSliceH;
Expand Down
4 changes: 3 additions & 1 deletion Docs/Amrvis.tex
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ \subsubsection{Command Line Interface and Utility Files}
[-makeswf_value]
[-valuemodel]
[-initplanes xp yp zp]
[-initplanesreal xp yp zp]
[-useminmax min max]
[<filename(s)>]
Expand Down Expand Up @@ -128,7 +129,8 @@ \subsubsection{Command Line Interface and Utility Files}
note: works in batch mode.
-makeswf_value same as above, with value model rendering.
-valuemodel start with the value model for rendering.
-initplanes xp yp zp set initial planes
-initplanes xp yp zp set initial planes in finest level grid cells
-initplanesreal xp yp zp set initial planes in real units
-useminmax min max use min and max as the global min max values
<filename(s)> must be included if box is specified.
\end{verbatim}
Expand Down
2 changes: 2 additions & 0 deletions GlobalUtilities.H
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ namespace AVGlobals {
int GetFabOutFormat();
bool GivenInitialPlanes();
amrex::IntVect GetInitialPlanes();
bool GivenInitialPlanesReal();
amrex::Vector< Real > GetInitialPlanesReal();
bool IsProfDirName(const std::string &pdname);

// -------------------- cartGrid functions
Expand Down
35 changes: 35 additions & 0 deletions GlobalUtilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ bool bShowBody(true);
Real bodyOpacity(0.05);
bool givenInitialPlanes(false);
IntVect ivInitialPlanes;
bool givenInitialPlanesReal(false);
Vector< Real > ivInitialPlanesReal;
AVGlobals::ENUserVectorNames givenUserVectorNames(AVGlobals::enUserNone);
Vector<string> userVectorNames(BL_SPACEDIM);
bool newPltSet(false);
Expand Down Expand Up @@ -487,6 +489,15 @@ void AVGlobals::GetDefaults(const string &defaultsFile) {
ivInitialPlanes.setVal(Amrvis::ZDIR, tempZ);
givenInitialPlanes = true;
}
else if(strcmp(defaultString, "initplanesreal") == 0) {
float tempX, tempY, tempZ;
sscanf(buffer, "%s%e%e%e", defaultString, &tempX, &tempY, &tempZ);
ivInitialPlanesReal.resize(BL_SPACEDIM);
ivInitialPlanesReal[Amrvis::XDIR] = tempX;
ivInitialPlanesReal[Amrvis::YDIR] = tempY;
ivInitialPlanesReal[Amrvis::ZDIR] = tempZ;
givenInitialPlanesReal = true;
}
#endif
else if(strcmp(defaultString, "setvelnames") == 0) {
#if (BL_SPACEDIM == 2)
Expand Down Expand Up @@ -642,6 +653,8 @@ void AVGlobals::ParseCommandLine(int argc, char *argv[]) {
char clbz[32];
char clPlaneX[32], clPlaneY[32], clPlaneZ[32];
bool givenInitialPlanesOnComline(false);
char clPlaneXReal[32], clPlaneYReal[32], clPlaneZReal[32];
bool givenInitialPlanesRealOnComline(false);
#endif

givenFilename = false;
Expand Down Expand Up @@ -940,6 +953,19 @@ void AVGlobals::ParseCommandLine(int argc, char *argv[]) {
i += 3;
givenInitialPlanes = true;
givenInitialPlanesOnComline = true;
} else if(strcmp(argv[i], "-initplanesreal") == 0) {
if(argc-1<i+1 || ! strcpy(clPlaneXReal, argv[i+1])) {
PrintUsage(argv[0]);
}
if(argc-1<i+2 || ! strcpy(clPlaneYReal, argv[i+2])) {
PrintUsage(argv[0]);
}
if(argc-1<i+3 || ! strcpy(clPlaneZReal, argv[i+3])) {
PrintUsage(argv[0]);
}
i += 3;
givenInitialPlanesReal = true;
givenInitialPlanesRealOnComline = true;
#endif
} else if(strcmp(argv[i],"-palette") == 0) {
PltApp::SetDefaultPalette(argv[i+1]);
Expand Down Expand Up @@ -1104,6 +1130,12 @@ void AVGlobals::ParseCommandLine(int argc, char *argv[]) {
ivInitialPlanes.setVal(Amrvis::YDIR, atoi(clPlaneY));
ivInitialPlanes.setVal(Amrvis::ZDIR, atoi(clPlaneZ));
}
if(givenInitialPlanesRealOnComline) {
ivInitialPlanesReal.resize(BL_SPACEDIM);
ivInitialPlanesReal[Amrvis::XDIR] = atof(clPlaneXReal);
ivInitialPlanesReal[Amrvis::YDIR] = atof(clPlaneYReal);
ivInitialPlanesReal[Amrvis::ZDIR] = atof(clPlaneZReal);
}
#endif


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

bool AVGlobals::GivenInitialPlanesReal() { return givenInitialPlanesReal; }
Vector <Real> AVGlobals::GetInitialPlanesReal() { return ivInitialPlanesReal; }

// -------------------------------------------------------------------
/*int AVGlobals::CRRBetweenLevels(int fromlevel, int tolevel,
const Vector<int> &refratios)
Expand Down

0 comments on commit a9c20e6

Please sign in to comment.