diff --git a/Source/Utils/WarpXTagging.cpp b/Source/Utils/WarpXTagging.cpp index 2a404b5985c..807c92b2f0b 100644 --- a/Source/Utils/WarpXTagging.cpp +++ b/Source/Utils/WarpXTagging.cpp @@ -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 @@ -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; } diff --git a/Source/WarpX.cpp b/Source/WarpX.cpp index d0403b95b60..96cf5edee7d 100644 --- a/Source/WarpX.cpp +++ b/Source/WarpX.cpp @@ -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( + utils::parser::makeParser(ref_patch_function,{"x","y","z"})); } - ref_patch_parser = std::make_unique( - utils::parser::makeParser(ref_patch_function,{"x","y","z"})); } pp_warpx.query("do_dynamic_scheduling", do_dynamic_scheduling);