Skip to content

Commit

Permalink
remove function def for fine_taglo/hi
Browse files Browse the repository at this point in the history
  • Loading branch information
RevathiJambunathan committed Nov 15, 2023
1 parent 1038404 commit 595177f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 33 deletions.
21 changes: 14 additions & 7 deletions Source/Utils/WarpXTagging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ WarpX::ErrorEst (int lev, TagBoxArray& tags, Real /*time*/, int /*ngrow*/)
const auto problo = Geom(lev).ProbLoArray();
const auto dx = Geom(lev).CellSizeArray();

amrex::ParserExecutor<3> const& ref_parser = ref_patch_parser->compile<3>();

amrex::ParserExecutor<3> ref_parser;
if (ref_patch_parser) ref_parser = ref_patch_parser->compile<3>();
const auto ftlo = fine_tag_lo;
const auto fthi = fine_tag_hi;
#ifdef AMREX_USE_OMP
#pragma omp parallel if (amrex::Gpu::notInLaunchRegion())
#endif
Expand All @@ -45,15 +47,20 @@ WarpX::ErrorEst (int lev, TagBoxArray& tags, Real /*time*/, int /*ngrow*/)
const RealVect pos {AMREX_D_DECL((i+0.5_rt)*dx[0]+problo[0],
(j+0.5_rt)*dx[1]+problo[1],
(k+0.5_rt)*dx[2]+problo[2])};
bool tag_val = 0;
if (ref_parser) {
#if defined (WARPX_DIM_3D)
amrex::Real tag_val = ref_parser(pos[0], pos[1], pos[2]);
tag_val = (ref_parser(pos[0], pos[1], pos[2]) == 1);
#elif defined (WARPX_DIM_XZ) || defined (WARPX_DIM_RZ)
amrex::Real unused = 0.0;
amrex::Real tag_val = ref_parser(pos[0], unused, pos[1]);
amrex::Real unused = 0.0;
tag_val = (ref_parser(pos[0], unused, pos[1]) == 1);
#elif defined (WARPX_DIM_1D_Z)
amrex::Real unused = 0.0;
amrex::Real tag_val = ref_parser(unused, unused, pos[0]);
amrex::Real unused = 0.0;
tag_val = (ref_parser(unused, unused, pos[0]) == 1);
#endif
} else {
tag_val = (pos > ftlo && pos < fthi);
}
if ( tag_val == 1) {
fab(i,j,k) = TagBox::SET;
}
Expand Down
29 changes: 3 additions & 26 deletions Source/WarpX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1006,34 +1006,11 @@ WarpX::ReadParameters ()
if (fine_tag_lo_specified && fine_tag_hi_specified) {
fine_tag_lo = RealVect{lo};
fine_tag_hi = RealVect{hi};
#if defined (WARPX_DIM_3D)
ref_patch_function = " ( x > " + std::to_string(fine_tag_lo[0]) + " ) "
+ " * ( x < " + std::to_string(fine_tag_hi[0]) + " )"
+ " * ( y > " + std::to_string(fine_tag_lo[1]) + " )"
+ " * ( y < " + std::to_string(fine_tag_hi[1]) + " )"
+ " * ( z > " + std::to_string(fine_tag_lo[2]) + " )"
+ " * ( z < " + std::to_string(fine_tag_hi[2]) + " )";
#elif defined (WARPX_DIM_RZ)
ref_patch_function = " ( x > " + std::to_string(fine_tag_lo[0]) + " ) "
+ " * ( x < " + std::to_string(fine_tag_hi[0]) + " )"
+ " * ( z > " + std::to_string(fine_tag_lo[1]) + " )"
+ " * ( z < " + std::to_string(fine_tag_hi[1]) + " )";
#elif defined (WARPX_DIM_XZ)
ref_patch_function = " ( x > " + std::to_string(fine_tag_lo[0]) + " ) "
+ " * ( x < " + std::to_string(fine_tag_hi[0]) + " )"
+ " * ( z > " + std::to_string(fine_tag_lo[1]) + " )"
+ " * ( z < " + std::to_string(fine_tag_hi[1]) + " )";
#elif defined (WARPX_DIM_1D_Z)
ref_patch_function = " ( z > " + std::to_string(fine_tag_lo[0]) + " ) "
+ " * ( z < " + std::to_string(fine_tag_hi[0]) + " )";
#endif
amrex::Print() << " ref patch func " << ref_patch_function << "\n";
} else {
utils::parser::Store_parserString(pp_warpx, "ref_patch_function(x,y,z)",
ref_patch_function);
utils::parser::Store_parserString(pp_warpx, "ref_patch_function(x,y,z)", ref_patch_function);
ref_patch_parser = std::make_unique<amrex::Parser>(
utils::parser::makeParser(ref_patch_function,{"x","y","z"}));
}
ref_patch_parser = std::make_unique<amrex::Parser>(
utils::parser::makeParser(ref_patch_function,{"x","y","z"}));
}

pp_warpx.query("do_dynamic_scheduling", do_dynamic_scheduling);
Expand Down

0 comments on commit 595177f

Please sign in to comment.