From a9c20e6ab8043e182fea79472fb101d5ded7e23a Mon Sep 17 00:00:00 2001 From: David Grote Date: Tue, 31 May 2022 14:37:11 -0700 Subject: [PATCH] Add initplanesreal option (#24) --- AmrPicture.cpp | 42 ++++++++++++++++++++++++++++++------------ Docs/Amrvis.tex | 4 +++- GlobalUtilities.H | 2 ++ GlobalUtilities.cpp | 35 +++++++++++++++++++++++++++++++++++ 4 files changed, 70 insertions(+), 13 deletions(-) diff --git a/AmrPicture.cpp b/AmrPicture.cpp index cb4c518..3373f72 100644 --- a/AmrPicture.cpp +++ b/AmrPicture.cpp @@ -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; @@ -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)), @@ -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()); @@ -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; @@ -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; @@ -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; diff --git a/Docs/Amrvis.tex b/Docs/Amrvis.tex index dc372cc..e610fd8 100644 --- a/Docs/Amrvis.tex +++ b/Docs/Amrvis.tex @@ -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] [] @@ -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 must be included if box is specified. \end{verbatim} diff --git a/GlobalUtilities.H b/GlobalUtilities.H index 909452c..1c88145 100644 --- a/GlobalUtilities.H +++ b/GlobalUtilities.H @@ -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 diff --git a/GlobalUtilities.cpp b/GlobalUtilities.cpp index 23ef5dd..60ad472 100644 --- a/GlobalUtilities.cpp +++ b/GlobalUtilities.cpp @@ -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 userVectorNames(BL_SPACEDIM); bool newPltSet(false); @@ -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) @@ -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; @@ -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 AVGlobals::GetInitialPlanesReal() { return ivInitialPlanesReal; } + // ------------------------------------------------------------------- /*int AVGlobals::CRRBetweenLevels(int fromlevel, int tolevel, const Vector &refratios)