23 static constexpr
const char*
name =
"bmp";
29 BMP (amrex::Vector<amrex::Geometry> &_geom) :
IC(_geom) {}
45 amrex::Box domain =
geom[lev].Domain();
55 amrex::IndexType type = a_field[lev]->ixType();
61 for (amrex::MFIter mfi(*a_field[lev],amrex::TilingIfNotGPU()); mfi.isValid(); ++mfi)
64 if (type == amrex::IndexType::TheNodeType()) bx = mfi.grownnodaltilebox();
65 if (type == amrex::IndexType::TheCellType()) bx = mfi.growntilebox();
69 amrex::Array4<Set::Scalar>
const& field = a_field[lev]->array(mfi);
70 amrex::ParallelFor (bx,[=] AMREX_GPU_DEVICE(
int i,
int j,
int k)
74 if (type == amrex::IndexType::TheNodeType())
76 x(0) = domlo(0) + ((amrex::Real)(i)) *
geom[lev].CellSize()[0];
77 x(1) = domlo(1) + ((amrex::Real)(j)) *
geom[lev].CellSize()[1];
79 else if (type == amrex::IndexType::TheCellType())
81 x(0) = domlo(0) + ((amrex::Real)(i) + 0.5) *
geom[lev].CellSize()[0];
82 x(1) = domlo(1) + ((amrex::Real)(j) + 0.5) *
geom[lev].CellSize()[1];
88 if (
fit == Fit::Stretch)
90 ximg(0) = (x(0) - domlo(0)) / (domhi(0) - domlo(0));
91 ximg(1) = (x(1) - domlo(1)) / (domhi(1) - domlo(1));
93 else if (
fit == Fit::FitWidth)
96 ximg(0) = (x(0) - domlo(0)) / (domhi(0) - domlo(0));
97 ximg(1) = (x(1) - domlo(1)) / (domhi(1) - domlo(1));
98 ximg(1) -= 0.5 - 0.5 / aspect_ratio;
99 ximg(1) *= aspect_ratio;
101 else if (
fit == Fit::FitHeight)
104 ximg(0) = (x(0) - domlo(0)) / (domhi(0) - domlo(0));
105 ximg(1) = (x(1) - domlo(1)) / (domhi(1) - domlo(1));
106 ximg(0) -= 0.5 - 0.5 / aspect_ratio;
107 ximg(0) *= aspect_ratio;
109 else if (
fit == Fit::Coord)
115 ximg(0) = std::min(ximg(0),1.0); ximg(1) = std::min(ximg(1),1.0);
116 ximg(0) = std::max(ximg(0),0.0); ximg(1) = std::max(ximg(1),0.0);
118 ximg(0) *= img_width;
119 ximg(1) *= img_height;
121 int I = (int)(ximg(0));
122 int J = (int)(ximg(1));
135 (fQ11*(x2-ximg(0))*(y2-ximg(1)) + fQ21*(ximg(0)-x1)*(y2-ximg(1)) + fQ12*(x2-ximg(0))*(ximg(1)-y1) + fQ22*(ximg(0)-x1)*(ximg(1)-y1)) / (img_dx * img_dy);
141 field(i,j,k) = fQ11 + (fQ12-fQ11) * (ximg(1) - y1);
147 field(i,j,k) = fQ11 + (fQ21-fQ11) * (ximg(0) - x1);
159 if (field.nComp() > 1) field(i,j,k,1) = 1.0 - field(i,j,k,0);
163 a_field[lev]->FillBoundary();
185 if (
fit==
"stretch") value.
fit = Fit::Stretch;
186 else if (
fit==
"fitheight") value.
fit = Fit::FitHeight;
187 else if (
fit==
"fitwidth") value.
fit = Fit::FitWidth;
188 else if (
fit==
"coord")
190 value.
fit = Fit::Coord;
194 else Util::Abort(
INFO,
"Invalid value for bmp fit - should be stretch/fitheight/fitwidth but received '",
fit,
"'");