1#ifndef AMREX_EB2_LEVEL_H_
2#define AMREX_EB2_LEVEL_H_
3#include <AMReX_Config.H>
14#if (AMREX_SPACEDIM == 3)
18#include <AMReX_EB2_C.H>
29#include <unordered_map>
39template <
typename G>
class GShopLevel;
40template <
typename G>
class IndexSpaceImp;
135 void write_to_chkpt_file (
const std::string& fname,
bool extend_domain_face,
int max_grid_size)
const;
145 void setShift (
int direction,
int ncells);
187 if (idim != face_dir) { edge_type[idim] = 0; }
192 [[nodiscard]]
bool hasFCData (
int face_dir)
const noexcept {
193 return face_dir >= 0 && face_dir < AMREX_SPACEDIM &&
253#if (AMREX_SPACEDIM == 3)
283 void setRegularLevel () {
299 int ngrow,
bool extend_domain_face,
int num_crse_opt);
309 int max_grid_size,
int ngrow,
bool extend_domain_face,
int num_crse_opt);
311#if (AMREX_SPACEDIM == 3)
315 template <
typename GS = G>
316 requires (std::same_as<GS,STLtools>)
318 int max_grid_size,
int ngrow,
bool extend_domain_face,
int num_crse_opt);
333 void buildFCData (G
const& gshop,
int face_dir,
int max_grid_size);
339 void prepare_grids (G
const& gshop,
Geometry const& geom,
int max_grid_size,
int ngrow,
340 bool extend_domain_face,
int num_crse_opt);
351 int max_grid_size,
int ngrow,
bool extend_domain_face,
int num_crse_opt)
354 if (std::is_same_v<typename G::FunctionType, AllRegularIF>) {
360 define_fine(gshop, geom, max_grid_size, ngrow, extend_domain_face, num_crse_opt);
366 int max_grid_size,
int ngrow,
bool extend_domain_face,
int num_crse_opt)
369 amrex::Print() <<
"AMReX WARNING: extend_domain_face=false is not recommended!\n";
372 BL_PROFILE(
"EB2::GShopLevel()-prepare_grids");
375 m_ngrow =
IntVect{
static_cast<int>(std::ceil(ngrow/16.)) * 16};
378 Box domain_grown = domain;
379 for (
int idim = 0; idim < AMREX_SPACEDIM; ++idim) {
383 m_ngrow[idim] = std::min(m_ngrow[idim], domain_grown.length(idim));
386 domain_grown.grow(m_ngrow);
387 m_bounding_box = (extend_domain_face) ? domain : domain_grown;
388 m_bounding_box.surroundingNodes();
391 BoxList covered_boxes;
396 num_crse_opt = std::max(0,std::min(8,num_crse_opt));
397 for (
int clev = num_crse_opt; clev >= 0; --clev) {
399 if (domain.coarsenable(crse_ratio)) {
403 if (cut_boxes.isEmpty()) {
404 covered_boxes.clear();
405 test_boxes = BoxList(crse_geom.Domain());
406 test_boxes.maxSize(max_grid_size);
408 test_boxes.swap(cut_boxes);
409 test_boxes.coarsen(crse_ratio);
410 test_boxes.maxSize(max_grid_size);
413 const Long nboxes = test_boxes.size();
414 const auto& boxes = test_boxes.data();
415 for (
Long i = iproc; i < nboxes; i += nprocs) {
416 const Box& vbx = boxes[i];
418 auto box_type = gshop.getBoxType(gbx&crse_bounding_box,crse_geom,
RunOn::Gpu);
419 if (box_type == gshop.allcovered) {
421 }
else if (box_type == gshop.mixedcells) {
433 auto grow_at_domain_boundary = [&] (BoxList& bl)
435 const IntVect& domlo = domain.smallEnd();
436 const IntVect& domhi = domain.bigEnd();
438 for (
int idim = 0; idim < AMREX_SPACEDIM; ++idim) {
439 if (m_ngrow[idim] != 0) {
440 if (b.smallEnd(idim) == domlo[idim]) {
441 b.growLo(idim,m_ngrow[idim]);
443 if (b.bigEnd(idim) == domhi[idim]) {
444 b.growHi(idim,m_ngrow[idim]);
450 grow_at_domain_boundary(covered_boxes);
451 grow_at_domain_boundary(cut_boxes);
454 if ( cut_boxes.isEmpty() &&
455 !covered_boxes.isEmpty())
457 amrex::Abort(
"AMReX_EB2_Level.H: Domain is completely covered");
460 if (!covered_boxes.isEmpty()) {
461 if (num_crse_opt > 2) {
462 covered_boxes.maxSize(max_grid_size*4);
464 m_covered_grids = BoxArray(std::move(covered_boxes));
467 if (cut_boxes.isEmpty()) {
468 m_grids = BoxArray();
469 m_dmap = DistributionMapping();
473 m_grids = BoxArray(std::move(cut_boxes));
474 m_dmap = DistributionMapping(m_grids);
481 int max_grid_size,
int ngrow,
bool extend_domain_face,
int num_crse_opt)
485#ifdef AMREX_USE_FLOAT
486 Real small_volfrac = 1.e-5_rt;
488 Real small_volfrac = 1.e-14;
490 bool cover_multiple_cuts =
false;
495 pp.
queryAdd(
"cover_multiple_cuts", cover_multiple_cuts);
498 maxiter = std::min(100000, maxiter);
500 prepare_grids(gshop, geom, max_grid_size, ngrow, extend_domain_face, num_crse_opt);
502 if (m_allregular) {
return; }
504 m_mgf.define(m_grids, m_dmap);
507 mf_info.
SetTag(
"EB2::Level");
508 m_cellflag.define(m_grids, m_dmap, 1, ng, mf_info);
509 m_volfrac.define(m_grids, m_dmap, 1, ng, mf_info);
510 m_centroid.define(m_grids, m_dmap, AMREX_SPACEDIM, ng, mf_info);
511 m_bndryarea.define(m_grids, m_dmap, 1, ng, mf_info);
512 m_bndrycent.define(m_grids, m_dmap, AMREX_SPACEDIM, ng, mf_info);
513 m_bndrynorm.define(m_grids, m_dmap, AMREX_SPACEDIM, ng, mf_info);
514 for (
int idim = 0; idim < AMREX_SPACEDIM; ++idim) {
516 m_dmap, 1, ng, mf_info);
518 m_dmap, AMREX_SPACEDIM-1, ng, mf_info);
519 IntVect edge_type{1}; edge_type[idim] = 0;
520 m_edgecent[idim].define(
amrex::convert(m_grids, edge_type), m_dmap, 1, ng, mf_info);
526 auto bounding_box = m_bounding_box;
527 for (
int idim = 0; idim < AMREX_SPACEDIM; ++idim) {
528 if (!extend_domain_face || geom.
isPeriodic(idim)) {
540 for (; iter < maxiter; ++iter)
545#pragma omp parallel if (Gpu::notInLaunchRegion()) reduction(+:nsmallcells,nmulticuts)
548#if (AMREX_SPACEDIM == 3)
554 auto& gfab = m_mgf[mfi];
555 const Box& vbx = gfab.validbox();
557 auto&
levelset = gfab.getLevelSet();
559 gshop.fillFab(
levelset, geom, gshop_run_on, bounding_box);
586 auto& facetype = gfab.getFaceType();
594#if (AMREX_SPACEDIM == 3)
595 auto& edgetype = gfab.getEdgeType();
608 for (
int idim = 0; idim < AMREX_SPACEDIM; ++idim) {
609 edgetype[idim].prefetchToHost();
610 m_edgecent[idim][mfi].prefetchToHost();
615 gshop.getIntercept({xip,yip,zip}, {xdg,ydg,zdg}, clst,
616 geom, gshop_run_on, bounding_box);
620 for (
int idim = 0; idim < AMREX_SPACEDIM; ++idim) {
621 edgetype[idim].prefetchToDevice();
622 m_edgecent[idim][mfi].prefetchToDevice();
627 gshop.updateIntercept({xip,yip,zip}, {xdg,ydg,zdg}, clst, geom);
630 for (
int idim = 0; idim < AMREX_SPACEDIM; ++idim) {
631 const Box& b = facetype[idim].box();
638 nmc = build_faces(vbx, cfg, ftx, fty, ftz, xdg, ydg, zdg, lst,
640 xm2, ym2, zm2, dx, problo, cover_multiple_cuts);
642 cellflagtmp.
resize(m_cellflag[mfi].box());
646 build_cells(vbx, cfg, ftx, fty, ftz,
apx,
apy,
apz,
647 fcx,
fcy,
fcz, xm2, ym2, zm2, dx, vfr, ctr,
648 bar, bct, bnm, cfgtmp, lst,
649 small_volfrac, geom, extend_domain_face, cover_multiple_cuts,
657#elif (AMREX_SPACEDIM == 2)
665 for (
int idim = 0; idim < AMREX_SPACEDIM; ++idim) {
666 facetype[idim].prefetchToHost();
667 m_edgecent[idim][mfi].prefetchToHost();
673 gshop.getIntercept({xip,yip},
674 {facetype[1].const_array(), facetype[0].const_array()},
675 clst, geom, gshop_run_on, bounding_box);
679 for (
int idim = 0; idim < AMREX_SPACEDIM; ++idim) {
680 facetype[idim].prefetchToDevice();
681 m_edgecent[idim][mfi].prefetchToDevice();
686 gshop.updateIntercept({xip,yip},
687 {facetype[1].const_array(), facetype[0].const_array()},
691 nmc = build_faces(vbx, cfg, ftx, fty, lst, xip, yip,
apx,
apy,
fcx,
fcy,
692 dx, problo, cover_multiple_cuts, nsm);
694 build_cells(vbx, cfg, ftx, fty,
apx,
apy, dx, vfr, ctr,
695 bar, bct, bnm, lst, small_volfrac, geom, extend_domain_face,
704 if (nsmallcells == 0 && nmulticuts == 0) {
707 auto ls = m_mgf.getLevelSet();
712 amrex::Print() <<
"AMReX EB: Iter. " << iter+1 <<
" fixed " << nsmallcells
713 <<
" small cells" <<
'\n';
716 amrex::Print() <<
"AMReX EB: Iter. " << iter+1 <<
" fixed " << nmulticuts
717 <<
" multicuts" <<
'\n';
726#pragma omp parallel if (Gpu::notInLaunchRegion())
730 auto& gfab = m_mgf[mfi];
731 auto const&
levelset = gfab.getLevelSet();
737#
if (AMREX_SPACEDIM == 3)
738 auto const& edgetype = gfab.getEdgeType();
743 intercept_to_edge_centroid(xip, yip, zip, xdg, ydg, zdg, clst, dx, problo);
745#elif (AMREX_SPACEDIM == 2)
746 auto& facetype = gfab.getFaceType();
750 intercept_to_edge_centroid(xip, yip, fty, ftx, clst, dx, problo);
754 m_levelset = m_mgf.getLevelSet();
759#if (AMREX_SPACEDIM == 3)
761template <
typename GS>
762requires (std::same_as<GS,STLtools>)
765 int max_grid_size,
int ngrow,
bool extend_domain_face,
int num_crse_opt)
769 prepare_grids(gshop, geom, max_grid_size, ngrow, extend_domain_face, num_crse_opt);
771 if (m_allregular) {
return; }
776 gshop.fillSignedDistance(m_sdf, m_sdf.nGrowVect(), geom);
779 m_marching_cubes[mfi.index()] = std::make_unique<MC::MCFab>();
784#if defined(AMREX_USE_OMP) && !defined(AMREX_USE_GPU)
814 const int coarse_ratio = 2;
815 const int min_width = 8;
816 bool coarsenable = fine_grids.
coarsenable(coarse_ratio, min_width)
817 && (fine_covered_grids.
empty() || fine_covered_grids.
coarsenable(coarse_ratio));
844 AMREX_ASSERT(face_dir >= 0 && face_dir < AMREX_SPACEDIM);
847 if (!m_fc_data[face_dir]) {
848 m_fc_data[face_dir] = std::make_unique<FCData>();
851 if (m_fc_data[face_dir]->m_built) {
return; }
858 m_fc_data[face_dir]->m_built =
true;
866 Level const* refined_cc_level =
nullptr;
867 std::unique_ptr<GShopLevel<G>> transient_level;
872 transient_level = std::make_unique<GShopLevel<G>>(
873 m_parent, gshop, refined_geom,
874 max_grid_size, m_ngrow[0] > 0 ? m_ngrow[0] : 4,
true, 0);
876 if (!transient_level->isOK()) {
877 amrex::Abort(
"GShopLevel::buildFCData: failed to build refined level");
879 refined_cc_level = transient_level.get();
896 m_fc_data[face_dir]->m_covered_grids_fc =
904 auto const& f_levelset = refined_cc_level->
m_levelset;
913#pragma omp parallel reduction(max:mvmc_error)
918 auto const&
fine = f_levelset.const_array(mfi);
922 [=,&tile_error] (
int i,
int j,
int k)
noexcept
924 int ierror = check_mvmc(i,j,k,
fine);
925 tile_error = std::max(tile_error,ierror);
928 mvmc_error = std::max(mvmc_error, tile_error);
935 using ReduceTuple =
typename decltype(reduce_data)::Type;
939 const Box& ndbx = mfi.validbox();
941 auto const&
fine = f_levelset.const_array(mfi);
942 reduce_op.
eval(ndbx, reduce_data,
947 ierror = check_mvmc(i,j,k,fine);
954 ReduceTuple rv = reduce_data.
value(reduce_op);
955 mvmc_error =
amrex::max(0, amrex::get<0>(rv));
972 auto& fc_cellflag = m_fc_data[face_dir]->m_cellflag_fc;
973 MultiFab& fc_volfrac = m_fc_data[face_dir]->m_volfrac_fc;
974 MultiFab& fc_centroid = m_fc_data[face_dir]->m_centroid_fc;
975 MultiFab& fc_bndryarea = m_fc_data[face_dir]->m_bndryarea_fc;
976 MultiFab& fc_bndrycent = m_fc_data[face_dir]->m_bndrycent_fc;
977 MultiFab& fc_bndrynorm = m_fc_data[face_dir]->m_bndrynorm_fc;
978 auto& fc_areafrac = m_fc_data[face_dir]->m_areafrac_fc;
979 auto& fc_facecent = m_fc_data[face_dir]->m_facecent_fc;
980 auto& fc_edgecent = m_fc_data[face_dir]->m_edgecent_fc;
1011 fc_cellflag.define(fc_grids, fc_dmap, 1, ng);
1012 fc_volfrac.
define(fc_grids, fc_dmap, 1, ng);
1013 fc_centroid.
define(fc_grids, fc_dmap, AMREX_SPACEDIM, ng);
1014 fc_bndryarea.
define(fc_grids, fc_dmap, 1, ng);
1015 fc_bndrycent.
define(fc_grids, fc_dmap, AMREX_SPACEDIM, ng);
1016 fc_bndrynorm.
define(fc_grids, fc_dmap, AMREX_SPACEDIM, ng);
1018 for (
int idim = 0; idim < AMREX_SPACEDIM; ++idim) {
1019 fc_areafrac[idim].define(fc_grids, fc_dmap, 1, ng);
1020 fc_facecent[idim].define(fc_grids, fc_dmap, AMREX_SPACEDIM-1, ng);
1030 auto const& cc_cellflag = refined_cc_level->
m_cellflag;
1036 auto const& cc_areafrac = refined_cc_level->
m_areafrac;
1037 auto const& cc_facecent = refined_cc_level->
m_facecent;
1038 auto const& cc_edgecent = refined_cc_level->
m_edgecent;
1045#pragma omp parallel reduction(max:error)
1050 auto const& cvol = fc_volfrac.
array(mfi);
1051 auto const& ccent = fc_centroid.
array(mfi);
1052 auto const& cba = fc_bndryarea.
array(mfi);
1053 auto const& cbc = fc_bndrycent.
array(mfi);
1054 auto const& cbn = fc_bndrynorm.
array(mfi);
1055 AMREX_D_TERM(
auto const& capx = fc_areafrac[0].array(mfi);,
1056 auto const& capy = fc_areafrac[1].array(mfi);,
1057 auto const& capz = fc_areafrac[2].array(mfi););
1058 AMREX_D_TERM(
auto const& cfcx = fc_facecent[0].array(mfi);,
1059 auto const& cfcy = fc_facecent[1].array(mfi);,
1060 auto const& cfcz = fc_facecent[2].array(mfi););
1061 AMREX_D_TERM(
auto const& cecx = fc_edgecent[0].array(mfi);,
1062 auto const& cecy = fc_edgecent[1].array(mfi);,
1063 auto const& cecz = fc_edgecent[2].array(mfi););
1064 auto const& cflag = fc_cellflag.array(mfi);
1072 AMREX_D_TERM(
auto const& fapx = cc_areafrac[0].const_array(mfi);,
1073 auto const& fapy = cc_areafrac[1].const_array(mfi);,
1074 auto const& fapz = cc_areafrac[2].const_array(mfi););
1075 AMREX_D_TERM(
auto const& ffcx = cc_facecent[0].const_array(mfi);,
1076 auto const& ffcy = cc_facecent[1].const_array(mfi);,
1077 auto const& ffcz = cc_facecent[2].const_array(mfi););
1078 AMREX_D_TERM(
auto const& fecx = cc_edgecent[0].const_array(mfi);,
1079 auto const& fecy = cc_edgecent[1].const_array(mfi);,
1080 auto const& fecz = cc_edgecent[2].const_array(mfi););
1081 auto const& fflag = cc_cellflag.const_array(mfi);
1083 Box const& bx = mfi.validbox();
1084 Box const& ndgbx = mfi.grownnodaltilebox(-1,2);
1088 [=,&tile_error] (
int i,
int j,
int k)
noexcept
1091 int ierr = coarsen_from_fine(
AMREX_D_DECL(i,j,k), bx, 2,
1092 cvol,ccent,cba,cbc,cbn,
1096 cflag,fvol,fcent,fba,fbc,fbn,
1101 tile_error = std::max(tile_error,ierr);
1104 error = std::max(error,tile_error);
1111 using ReduceTuple =
typename decltype(reduce_data)::Type;
1115 auto const& cvol = fc_volfrac.
array(mfi);
1116 auto const& ccent = fc_centroid.
array(mfi);
1117 auto const& cba = fc_bndryarea.
array(mfi);
1118 auto const& cbc = fc_bndrycent.
array(mfi);
1119 auto const& cbn = fc_bndrynorm.
array(mfi);
1120 AMREX_D_TERM(
auto const& capx = fc_areafrac[0].array(mfi);,
1121 auto const& capy = fc_areafrac[1].array(mfi);,
1122 auto const& capz = fc_areafrac[2].array(mfi););
1123 AMREX_D_TERM(
auto const& cfcx = fc_facecent[0].array(mfi);,
1124 auto const& cfcy = fc_facecent[1].array(mfi);,
1125 auto const& cfcz = fc_facecent[2].array(mfi););
1128 AMREX_D_TERM(
auto const& cecx = fc_edgecent[0].arrays();,
1129 auto const& cecy = fc_edgecent[1].arrays();,
1130 auto const& cecz = fc_edgecent[2].arrays(););
1131 auto const& cflag = fc_cellflag.array(mfi);
1138 AMREX_D_TERM(
auto const& fapx = cc_areafrac[0].const_array(mfi);,
1139 auto const& fapy = cc_areafrac[1].const_array(mfi);,
1140 auto const& fapz = cc_areafrac[2].const_array(mfi););
1141 AMREX_D_TERM(
auto const& ffcx = cc_facecent[0].const_array(mfi);,
1142 auto const& ffcy = cc_facecent[1].const_array(mfi);,
1143 auto const& ffcz = cc_facecent[2].const_array(mfi););
1144 AMREX_D_TERM(
auto const& fecx = cc_edgecent[0].const_arrays();,
1145 auto const& fecy = cc_edgecent[1].const_arrays();,
1146 auto const& fecz = cc_edgecent[2].const_arrays(););
1147 auto const& fflag = cc_cellflag.const_array(mfi);
1149 const int lidx = mfi.LocalIndex();
1150 Box const& bx = mfi.validbox();
1154 reduce_op.
eval(ndgbx, reduce_data,
1158 int ierr = coarsen_from_fine(
AMREX_D_DECL(i,j,k), bx, 2,
1159 cvol,ccent,cba,cbc,cbn,
1163 cflag,fvol,fcent,fba,fbc,fbn,
1172 ReduceTuple rv = reduce_data.
value(reduce_op);
1182 m_fc_data[face_dir]->m_built =
true;
1185 buildCellFlagFC(face_dir);
Fixed-size array types for use on GPU and CPU.
#define BL_PROFILE(a)
Definition AMReX_BLProfiler.H:562
#define AMREX_ALWAYS_ASSERT_WITH_MESSAGE(EX, MSG)
Definition AMReX_BLassert.H:49
#define AMREX_ASSERT(EX)
Definition AMReX_BLassert.H:38
Problem-domain geometry: maps between index space and physical space.
#define AMREX_GPU_DEVICE
Definition AMReX_GpuQualifiers.H:18
amrex::ParmParse pp
Input file parser instance for the given namespace.
Definition AMReX_HypreIJIface.cpp:15
Array4< Real > fine
Definition AMReX_InterpFaceRegister.cpp:90
Array4< Real const > vfrac
Definition AMReX_MLEBNodeFDLaplacian.cpp:1468
GpuArray< Array4< Real const >, 3 > edgecent
Definition AMReX_MLEBNodeFDLaplacian.cpp:1557
#define AMREX_D_TERM(a, b, c)
Definition AMReX_SPACE.H:172
#define AMREX_D_DECL(a, b, c)
Definition AMReX_SPACE.H:171
void resize(const Box &b, int N=1, Arena *ar=nullptr)
This function resizes a BaseFab so it covers the Box b with N components.
Definition AMReX_BaseFab.H:1774
Array4< T const > array() const noexcept
Create an Array4 view over all components.
Definition AMReX_BaseFab.H:475
Elixir elixir() noexcept
Transfer owned storage to an Elixir when running in a GPU launch region.
Definition AMReX_BaseFab.H:1817
Reference-counted collection of Boxes.
Definition AMReX_BoxArray.H:681
bool coarsenable(int refinement_ratio, int min_width=1) const
Check whether every Box is coarsenable by refinement_ratio.
Definition AMReX_BoxArray.cpp:628
bool empty() const noexcept
Return whether the BoxArray is empty.
Definition AMReX_BoxArray.H:764
__host__ __device__ BoxND< new_dim > resize() const noexcept
Return a new BoxND of size new_dim by either shrinking or expanding this BoxND.
Definition AMReX_Box.H:927
__host__ __device__ bool contains(const IntVectND< dim > &p) const noexcept
Return true if argument is contained within BoxND.
Definition AMReX_Box.H:233
GpuArray< Real, 3 > CellSizeArray() const noexcept
Returns the cell sizes as a GpuArray for use on host or device.
Definition AMReX_CoordSys.H:85
Calculates the distribution of FABs to MPI processes.
Definition AMReX_DistributionMapping.H:51
static constexpr int ng
Definition AMReX_EB2_MultiGFab.H:26
Definition AMReX_EB2_Level.H:293
GShopLevel(IndexSpace const *is, const Geometry &geom)
Construct an empty level (usually regular) bound to geom.
Definition AMReX_EB2_Level.H:345
void define_fine(G const &gshop, const Geometry &geom, int max_grid_size, int ngrow, bool extend_domain_face, int num_crse_opt)
Define data for the finest level using the supplied GeometryShop.
Definition AMReX_EB2_Level.H:480
void buildFCData(G const &gshop, int face_dir, int max_grid_size)
Build face-centered EB data for face_dir. Builds refined CC transiently.
Definition AMReX_EB2_Level.H:840
GShopLevel(IndexSpace const *is, int ilev, int max_grid_size, int ngrow, const Geometry &geom, GShopLevel< G > &fineLevel)
Construct a coarse level by coarsening fineLevel.
Definition AMReX_EB2_Level.H:799
GShopLevel(IndexSpace const *is, G const &gshop, const Geometry &geom, int max_grid_size, int ngrow, bool extend_domain_face, int num_crse_opt)
Build a level directly from a GeometryShop object.
Definition AMReX_EB2_Level.H:350
static GShopLevel< G > makeAllRegular(IndexSpace const *is, const Geometry &geom)
Build a regular (no EB) level.
Definition AMReX_EB2_Level.H:325
void define_fine_mvmc(GS const &gshop, const Geometry &geom, int max_grid_size, int ngrow, bool extend_domain_face, int num_crse_opt)
Define a fine level for multi-valued multi-cut STL geometries (3-D only)
Definition AMReX_EB2_Level.H:764
Definition AMReX_EB2.H:84
Definition AMReX_EB2.H:28
Definition AMReX_EB2_Level.H:43
MultiFab m_bndryarea
Definition AMReX_EB2_Level.H:261
bool isOK() const noexcept
Definition AMReX_EB2_Level.H:49
void fillFaceCent(Array< MultiCutFab *, 3 > const &facecent, const Geometry &geom) const
Populate face centroids for each direction.
Definition AMReX_EB2_Level.cpp:794
MultiFab m_volfrac
Definition AMReX_EB2_Level.H:259
MultiGFab m_mgf
Definition AMReX_EB2_Level.H:256
bool m_allregular
Definition AMReX_EB2_Level.H:268
IntVect m_shift
Definition AMReX_EB2_Level.H:271
iMultiFab m_cutcellmask
Definition AMReX_EB2_Level.H:267
Array< MultiFab, 3 > m_facecent
Definition AMReX_EB2_Level.H:265
void fillBndryAreaFC(MultiFab &bndryarea, int face_dir, const Geometry &geom) const
Fill face-centered boundary areas for face_dir.
Definition AMReX_EB2_Level.cpp:1215
Array< MultiFab, 3 > m_edgecent
Definition AMReX_EB2_Level.H:266
void fillBndryNormFC(MultiFab &bndrynorm, int face_dir, const Geometry &geom) const
Fill face-centered boundary normals for face_dir.
Definition AMReX_EB2_Level.cpp:1251
void prepareForCoarsening(const Level &rhs, int max_grid_size, IntVect const &ngrow)
Prepare for coarsening by copying from rhs, respecting max grid size and grow vector.
Definition AMReX_EB2_Level.cpp:10
void fillCutCellMask(iMultiFab &cutcellmask, const Geometry &geom) const
Populate the cut-cell mask into cutcellmask.
Definition AMReX_EB2_Level.cpp:946
MultiFab m_centroid
Definition AMReX_EB2_Level.H:260
FabArray< EBCellFlagFab > m_cellflag
Definition AMReX_EB2_Level.H:258
const DistributionMapping & DistributionMap() const noexcept
Definition AMReX_EB2_Level.H:111
BoxArray m_covered_grids
Definition AMReX_EB2_Level.H:250
void fillLevelSet(MultiFab &levelset, const Geometry &geom) const
Write the implicit function values into levelset.
Definition AMReX_EB2_Level.cpp:907
Geometry m_geom
Definition AMReX_EB2_Level.H:247
Array< MultiFab, 3 > m_areafrac
Definition AMReX_EB2_Level.H:264
IntVect m_ngrow
Definition AMReX_EB2_Level.H:248
void fillEBCellFlagFC(FabArray< EBCellFlagFab > &cellflag, int face_dir, const Geometry &geom) const
Fill face-centered EBCellFlags for face_dir.
Definition AMReX_EB2_Level.cpp:1269
IndexSpace const * m_parent
Definition AMReX_EB2_Level.H:272
const FCData & getFCData(int face_dir) const
Get reference to face-centered data for face_dir (0=x, 1=y, 2=z).
Definition AMReX_EB2_Level.H:198
BoxArray m_grids
Definition AMReX_EB2_Level.H:249
void fillEdgeCentFC(Array< MultiFab *, 3 > const &edgecent, int face_dir, const Geometry &geom) const
Fill face-centered edge centroids for face_dir.
Definition AMReX_EB2_Level.cpp:1353
const Geometry & Geom() const noexcept
Definition AMReX_EB2_Level.H:121
std::map< int, std::unique_ptr< MC::MCFab > > m_marching_cubes
Definition AMReX_EB2_Level.H:254
bool hasEBInfo() const noexcept
Definition AMReX_EB2_Level.H:138
void write_to_chkpt_file(const std::string &fname, bool extend_domain_face, int max_grid_size) const
Write this level’s EB data to a checkpoint file fname.
Definition AMReX_EB2_Level.cpp:956
void fillEBCellFlag(FabArray< EBCellFlagFab > &cellflag, const Geometry &geom) const
Fill cellflag with EBCellFlag data using geometry geom.
Definition AMReX_EB2_Level.cpp:429
void fillEdgeCent(Array< MultiCutFab *, 3 > const &edgecent, const Geometry &geom) const
Populate edge centroids for each direction.
Definition AMReX_EB2_Level.cpp:835
int coarsenFromFine(Level &fineLevel, bool fill_boundary)
Coarsen EB data from fineLevel into this level.
Definition AMReX_EB2_Level.cpp:84
MultiFab m_bndrynorm
Definition AMReX_EB2_Level.H:263
bool m_has_eb_info
Definition AMReX_EB2_Level.H:270
void fillAreaFrac(Array< MultiCutFab *, 3 > const &areafrac, const Geometry &geom) const
Populate face area fractions for each direction.
Definition AMReX_EB2_Level.cpp:640
MultiFab m_bndrycent
Definition AMReX_EB2_Level.H:262
MultiFab m_levelset
Definition AMReX_EB2_Level.H:257
void setShift(int direction, int ncells)
Shift this level by ncells cells along direction direction (for periodic tiling).
Definition AMReX_EB2_Level.cpp:1047
void buildCellFlagFC(int face_dir)
Build the face-centered EBCellFlag connectivity for face_dir from its area fractions.
Definition AMReX_EB2_Level.cpp:1062
bool isAllRegular() const noexcept
Definition AMReX_EB2_Level.H:47
static IntVect fcEdgeType(int idim, int face_dir) noexcept
Index type of the face-centered edge centroids for edge direction idim.
Definition AMReX_EB2_Level.H:185
void fillBndryCent(MultiCutFab &bndrycent, const Geometry &geom) const
Populate boundary centroids into bndrycent.
Definition AMReX_EB2_Level.cpp:592
void fillCentroidFC(MultiFab ¢roid, int face_dir, const Geometry &geom) const
Fill face-centered centroids for face_dir.
Definition AMReX_EB2_Level.cpp:1197
void fillBndryNorm(MultiCutFab &bndrynorm, const Geometry &geom) const
Populate boundary normals into bndrynorm.
Definition AMReX_EB2_Level.cpp:616
void fillBndryCentFC(MultiFab &bndrycent, int face_dir, const Geometry &geom) const
Fill face-centered boundary centroids for face_dir.
Definition AMReX_EB2_Level.cpp:1233
MultiFab m_sdf
Definition AMReX_EB2_Level.H:252
IntVect const & nGrowVect() const noexcept
Definition AMReX_EB2_Level.H:126
void fillAreaFracFC(Array< MultiFab *, 3 > const &areafrac, int face_dir, const Geometry &geom) const
Fill face-centered area fractions for face_dir.
Definition AMReX_EB2_Level.cpp:1132
void fillVolFrac(MultiFab &vfrac, const Geometry &geom) const
Populate volume fractions into vfrac using geom.
Definition AMReX_EB2_Level.cpp:483
const BoxArray & boxArray() const noexcept
Definition AMReX_EB2_Level.H:109
Level(IndexSpace const *is, const Geometry &geom)
Construct a Level bound to EB index space is and Geometry geom.
Definition AMReX_EB2_Level.H:114
friend class GShopLevel
Definition AMReX_EB2_Level.H:278
bool m_ok
Definition AMReX_EB2_Level.H:269
void fillCentroid(MultiCutFab ¢roid, const Geometry &geom) const
Populate cut-cell centroids into a MultiCutFab.
Definition AMReX_EB2_Level.cpp:544
Array< std::unique_ptr< FCData >, 3 > m_fc_data
Face-centered data storage: [0]=x-face, [1]=y-face, [2]=z-face.
Definition AMReX_EB2_Level.H:275
DistributionMapping m_dmap
Definition AMReX_EB2_Level.H:251
void fillBndryArea(MultiCutFab &bndryarea, const Geometry &geom) const
Populate boundary-face areas into bndryarea.
Definition AMReX_EB2_Level.cpp:568
void buildCellFlag()
Build EBCellFlag data from the current implicit function field.
Definition AMReX_EB2_Level.cpp:403
void buildCutCellMask(Level const &fine_level)
Build the cut-cell mask by coarsening from fine_level.
Definition AMReX_EB2_Level.cpp:966
bool hasFCData(int face_dir) const noexcept
Check if face-centered data is available for face_dir (0=x, 1=y, 2=z).
Definition AMReX_EB2_Level.H:192
IndexSpace const * getEBIndexSpace() const noexcept
Definition AMReX_EB2_Level.H:123
void fillVolFracFC(MultiFab &vfrac, int face_dir, const Geometry &geom) const
Fill face-centered volume fractions for face_dir.
Definition AMReX_EB2_Level.cpp:1093
void fillFaceCentFC(Array< MultiFab *, 3 > const &facecent, int face_dir, const Geometry &geom) const
Fill face-centered face centroids for face_dir.
Definition AMReX_EB2_Level.cpp:1321
LayoutData wrapper that allocates a GFab per FAB/Box.
Definition AMReX_EB2_MultiGFab.H:86
FAB storing EBCellFlag data per cell.
Definition AMReX_EBCellFlag.H:324
An Array of FortranArrayBox(FAB)-like Objects.
Definition AMReX_FabArray.H:356
Array4< typename FabArray< FAB >::value_type const > array(const MFIter &mfi) const noexcept
Read-only Array4 view for the FAB referenced by iterator mfi.
Definition AMReX_FabArray.H:621
Array4< typename FabArray< FAB >::value_type const > const_array(const MFIter &mfi) const noexcept
Synonym for array(const MFIter&) that highlights read-only semantics.
Definition AMReX_FabArray.H:649
Rectangular problem domain geometry.
Definition AMReX_Geometry.H:85
const Box & Domain() const noexcept
Returns our rectangular domain.
Definition AMReX_Geometry.H:244
Periodicity periodicity() const noexcept
Return the Periodicity based on the length of the domain.
Definition AMReX_Geometry.H:424
GpuArray< Real, 3 > ProbLoArray() const noexcept
Return the lo end of the problem domain in a GpuArray for device code.
Definition AMReX_Geometry.H:217
bool isPeriodic(int dir) const noexcept
Is the domain periodic in the specified direction?
Definition AMReX_Geometry.H:397
Definition AMReX_GpuElixir.H:13
__host__ static __device__ constexpr IntVectND< dim > TheCellVector() noexcept
This static member function returns a reference to a constant IntVectND object, all of whose dim argu...
Definition AMReX_IntVect.H:810
__host__ static __device__ constexpr IntVectND< dim > TheZeroVector() noexcept
This static member function returns a reference to a constant IntVectND object, all of whose dim argu...
Definition AMReX_IntVect.H:771
__host__ static __device__ constexpr IntVectND< dim > TheNodeVector() noexcept
This static member function returns a reference to a constant IntVectND object, all of whose dim argu...
Definition AMReX_IntVect.H:801
__host__ static __device__ constexpr IntVectND< dim > TheDimensionVector(int d) noexcept
This static member function returns a reference to a constant IntVectND object, all of whose dim argu...
Definition AMReX_IntVect.H:790
Iterator for looping ever tiles and boxes of amrex::FabArray based containers.
Definition AMReX_MFIter.H:88
bool isValid() const noexcept
Is the iterator valid i.e. is it associated with a FAB?
Definition AMReX_MFIter.H:176
FabArray façade that only allocates cut-cell Fabs (skipping regular cells).
Definition AMReX_MultiCutFab.H:87
A collection (stored as an array) of FArrayBox objects.
Definition AMReX_MultiFab.H:40
void define(const BoxArray &bxs, const DistributionMapping &dm, int nvar, int ngrow, const MFInfo &info=MFInfo(), const FabFactory< FArrayBox > &factory=FArrayBoxFactory())
Definition AMReX_MultiFab.cpp:519
Parse Parameters From Command Line and Input Files.
Definition AMReX_ParmParse.H:353
int queryAdd(std::string_view name, T &ref)
If name is found, the value in the ParmParse database will be stored in the ref argument....
Definition AMReX_ParmParse.H:1049
This class provides the user with a few print options.
Definition AMReX_Print.H:35
Definition AMReX_Reduce.H:438
Type value()
Definition AMReX_Reduce.H:473
Definition AMReX_Reduce.H:597
void eval(MF const &mf, IntVect const &nghost, D &reduce_data, F &&f)
Definition AMReX_Reduce.H:734
A Collection of IArrayBoxes.
Definition AMReX_iMultiFab.H:34
amrex_real Real
Floating Point Type for Fields.
Definition AMReX_REAL.H:80
amrex_long Long
Definition AMReX_INT.H:30
__host__ __device__ BoxND< dim > convert(const BoxND< dim > &b, const IntVectND< dim > &typ) noexcept
Return a copy of b converted to the nodal flags typ.
Definition AMReX_Box.H:1630
__host__ __device__ BoxND< dim > surroundingNodes(const BoxND< dim > &b, int dir) noexcept
Return a BoxND with NODE based coordinates in direction dir that encloses BoxND b.
Definition AMReX_Box.H:1582
__host__ __device__ BoxND< dim > coarsen(const BoxND< dim > &b, int ref_ratio) noexcept
Return a copy of b coarsened by the isotropic ratio ref_ratio.
Definition AMReX_Box.H:1469
__host__ __device__ BoxND< dim > enclosedCells(const BoxND< dim > &b, int dir) noexcept
Return a BoxND with CELL based coordinates in direction dir that is enclosed by b.
Definition AMReX_Box.H:1664
__host__ __device__ BoxND< dim > grow(const BoxND< dim > &b, int i) noexcept
Return a copy of b grown uniformly by i cells in every direction.
Definition AMReX_Box.H:1326
__host__ __device__ BoxND< dim > refine(const BoxND< dim > &b, int ref_ratio) noexcept
Return a copy of b refined by the isotropic ratio ref_ratio.
Definition AMReX_Box.H:1510
std::array< T, N > Array
Definition AMReX_Array.H:31
void Or(bool &v, MPI_Comm comm)
Definition AMReX_ParallelReduce.H:236
__host__ __device__ constexpr const T & max(const T &a, const T &b) noexcept
Definition AMReX_Algorithm.H:53
Definition AMReX_FabArrayBase.H:38
void streamSynchronize() noexcept
Definition AMReX_GpuDevice.H:310
bool inLaunchRegion() noexcept
Definition AMReX_GpuControl.H:88
bool notInLaunchRegion() noexcept
Definition AMReX_GpuControl.H:89
void write_stl(std::string const &filename, std::map< int, std::unique_ptr< MCFab > > const &mc_fabs)
Write the collected marching-cubes output to an STL file.
Definition AMReX_MarchingCubes.cpp:925
void marching_cubes(Geometry const &geom, FArrayBox &sdf_fab, MCFab &mc_fab)
Run marching cubes on signed-distance field sdf_fab.
Definition AMReX_MarchingCubes.cpp:693
void Initialize()
Initialize internal lookup tables and device buffers for marching cubes.
Definition AMReX_MarchingCubes.cpp:651
MPI_Comm CommunicatorSub() noexcept
sub-communicator for current frame
Definition AMReX_ParallelContext.H:70
int MyProcSub() noexcept
my sub-rank in current frame
Definition AMReX_ParallelContext.H:76
int NProcsSub() noexcept
number of ranks in current frame
Definition AMReX_ParallelContext.H:74
Definition AMReX_Amr.cpp:50
__host__ __device__ void ignore_unused(const Ts &...)
No-op helper that marks variables as intentionally unused.
Definition AMReX.H:259
RunOn
Definition AMReX_GpuControl.H:65
void AllGatherBoxes(Vector< Box > &bxs, int n_extra_reserve)
Gather boxes from all MPI ranks into bxs.
Definition AMReX_Box.cpp:124
BoxND< 3 > Box
Box is an alias for amrex::BoxND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:35
IntVectND< 3 > IntVect
IntVect is an alias for amrex::IntVectND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:38
__host__ __device__ constexpr IntVectND< dim > scale(const IntVectND< dim > &p, int s) noexcept
Returns a IntVectND obtained by multiplying each of the components of this IntVectND by s.
Definition AMReX_IntVect.H:1106
int Verbose() noexcept
Return the verbosity level configured via ParmParse or SetVerbose().
Definition AMReX.cpp:182
void Abort(const std::string &msg)
Print a fatal-error message to stderr and abort execution.
Definition AMReX.cpp:242
void LoopOnCpu(Dim3 lo, Dim3 hi, F const &f) noexcept
Definition AMReX_Loop.H:365
A multidimensional array accessor.
Definition AMReX_Array4.H:289
Face-centered EB data storage structure.
Definition AMReX_EB2_Level.H:150
bool m_built
Definition AMReX_EB2_Level.H:174
Array< MultiFab, 3 > m_areafrac_fc
Definition AMReX_EB2_Level.H:157
MultiFab m_bndryarea_fc
Definition AMReX_EB2_Level.H:154
Array< MultiFab, 3 > m_edgecent_fc
Definition AMReX_EB2_Level.H:159
BoxArray m_covered_grids_fc
Definition AMReX_EB2_Level.H:173
MultiFab m_bndrycent_fc
Definition AMReX_EB2_Level.H:155
MultiFab m_centroid_fc
Definition AMReX_EB2_Level.H:153
MultiFab m_bndrynorm_fc
Definition AMReX_EB2_Level.H:156
MultiFab m_volfrac_fc
Definition AMReX_EB2_Level.H:152
Array< MultiFab, 3 > m_facecent_fc
Definition AMReX_EB2_Level.H:158
FabArray< EBCellFlagFab > m_cellflag_fc
Definition AMReX_EB2_Level.H:151
FabArray memory allocation information.
Definition AMReX_FabArray.H:73
MFInfo & SetTag() noexcept
Terminate a variadic SetTag() call.
Definition AMReX_FabArray.H:90
MFInfo & SetAlloc(bool a) noexcept
Control whether FAB storage is allocated when the FabArray is defined.
Definition AMReX_FabArray.H:81
Definition AMReX_MFIter.H:20
MFItInfo & SetDynamic(bool f) noexcept
Definition AMReX_MFIter.H:43