31 Real small_volfrac = 1.e-14;
33 pp.queryAdd(
"small_volfrac", small_volfrac);
34 const Real small_value = 1.e-15;
36 const IntVect vdim(IntVect::TheDimensionVector(a_idim));
38 const BoxArray& grids = amrex::convert(a_grids, vdim);
40 m_cellflags =
new FabArray<EBCellFlagFab>(grids, a_dmap, 1, a_ngrow[0], MFInfo(),
41 DefaultFabFactory<EBCellFlagFab>());
45 for (MFIter mfi(*
m_cellflags,
false); mfi.isValid(); ++mfi) {
46 auto& fab = (*m_cellflags)[mfi];
47 fab.setType(FabType::singlevalued);
50 m_volfrac =
new MultiFab(grids, a_dmap, 1, a_ngrow[1], MFInfo(), FArrayBoxFactory());
51 m_volcent =
new MultiFab(grids, a_dmap, AMREX_SPACEDIM, a_ngrow[2], MFInfo(), FArrayBoxFactory());
53 for (
int idim = 0; idim < AMREX_SPACEDIM; ++idim) {
54 const BoxArray& faceba = amrex::convert(a_grids, IntVect::TheDimensionVector(idim));
55 m_areafrac[idim] =
new MultiFab(faceba, a_dmap, 1, a_ngrow[1], MFInfo(), FArrayBoxFactory());
56 m_facecent[idim] =
new MultiFab(faceba, a_dmap, AMREX_SPACEDIM-1, a_ngrow[2], MFInfo(), FArrayBoxFactory());
59 m_bndryarea =
new MultiFab(grids, a_dmap, 1, a_ngrow[2], MFInfo(), FArrayBoxFactory());
60 m_bndrycent =
new MultiFab(grids, a_dmap, AMREX_SPACEDIM, a_ngrow[2], MFInfo(), FArrayBoxFactory());
61 m_bndrynorm =
new MultiFab(grids, a_dmap, AMREX_SPACEDIM, a_ngrow[2], MFInfo(), FArrayBoxFactory());
66 for (
int idim = 0; idim < AMREX_SPACEDIM; ++idim) {
74 const auto& FlagFab = a_factory->getMultiEBCellFlagFab();
76 for (MFIter mfi(*
m_cellflags,
false); mfi.isValid(); ++mfi) {
78 const Box& bx = mfi.validbox();
79 const Box& bx_grown = mfi.growntilebox();
80 const Box domain = surroundingNodes(a_geom.Domain(), a_idim);
82 if (FlagFab[mfi].getType(bx) == FabType::singlevalued ) {
84 GpuArray<Real, AMREX_SPACEDIM> dx = a_geom.CellSizeArray();
86 Array4<EBCellFlag const>
const& flag = FlagFab.const_array(mfi);
93 Array4<Real const>
const& bnorm = a_factory->getBndryNormal()[mfi].const_array();
94 Array4<Real const>
const& bcent = a_factory->getBndryCent()[mfi].const_array();
97 Array4<EBCellFlag>
const& aux_flag =
m_cellflags->array(mfi);
98 Array4<Real>
const& aux_vfrac =
m_volfrac->array(mfi);
99 Array4<Real>
const& aux_vcent =
m_volcent->array(mfi);
101 Array4<Real>
const& aux_afrac_x =
m_areafrac[0]->array(mfi);
102 Array4<Real>
const& aux_afrac_y =
m_areafrac[1]->array(mfi);
103 Array4<Real>
const& aux_afrac_z =
m_areafrac[2]->array(mfi);
105 Array4<Real>
const& aux_fcent_x =
m_facecent[0]->array(mfi);
106 Array4<Real>
const& aux_fcent_y =
m_facecent[1]->array(mfi);
107 Array4<Real>
const& aux_fcent_z =
m_facecent[2]->array(mfi);
109 Array4<Real>
const& aux_barea =
m_bndryarea->array(mfi);
110 Array4<Real>
const& aux_bcent =
m_bndrycent->array(mfi);
111 Array4<Real>
const& aux_bnorm =
m_bndrynorm->array(mfi);
113 bool l_periodic = a_geom.isPeriodic(a_idim);
119 Box dom_grown = domain;
120 for (
int idim = 0; idim < AMREX_SPACEDIM; ++idim) {
121 if (a_geom.isPeriodic(idim)) {
122 dom_grown.grow(idim, a_ngrow[0]);
126 const IntVect dom_grown_lo = dom_grown.smallEnd();
127 const IntVect dom_grown_hi = dom_grown.bigEnd();
129 BoxList diffList = boxDiff(bx_grown, bx);
130 for (
const Box& b : diffList) {
131 ParallelFor(b, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept
133 if ( i < dom_grown_lo[0] || i > dom_grown_hi[0] ||
134 j < dom_grown_lo[1] || j > dom_grown_hi[1] ||
135 k < dom_grown_lo[2] || k > dom_grown_hi[2] ) {
136 aux_flag(i,j,k).setCovered();
137 aux_flag(i,j,k).setDisconnected();
143 #ifndef AMREX_USE_GPU
146 dx, bx, domain, bnorm, bcent, flag,
147 aux_flag, aux_vfrac, aux_vcent,
148 aux_afrac_x, aux_afrac_y, aux_afrac_z,
149 aux_fcent_x, aux_fcent_y, aux_fcent_z,
150 aux_barea, aux_bcent, aux_bnorm,
151 vdim, idim=a_idim, l_periodic,
152 small_volfrac, small_value ]
153 AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept
158 aux_flag(i,j,k).setCovered();
159 aux_flag(i,j,k).setDisconnected();
161 aux_vfrac(i,j,k) = 0.0;
162 aux_vcent(i,j,k,0) = 0.0;
163 aux_vcent(i,j,k,1) = 0.0;
164 aux_vcent(i,j,k,2) = 0.0;
166 aux_afrac_x(i,j,k) = 0.0;
167 aux_afrac_y(i,j,k) = 0.0;
168 aux_afrac_z(i,j,k) = 0.0;
170 aux_fcent_x(i,j,k,0) = 0.0; aux_fcent_x(i,j,k,1) = 0.0;
171 aux_fcent_y(i,j,k,0) = 0.0; aux_fcent_y(i,j,k,1) = 0.0;
172 aux_fcent_z(i,j,k,0) = 0.0; aux_fcent_z(i,j,k,1) = 0.0;
174 if (i==bx.bigEnd(0)) {
175 aux_afrac_x(i+1,j,k) = 0.0;
176 aux_fcent_x(i+1,j,k,0) = 0.0;
177 aux_fcent_x(i+1,j,k,1) = 0.0;
179 if (j==bx.bigEnd(1)) {
180 aux_afrac_y(i,j+1,k) = 0.0;
181 aux_fcent_y(i,j+1,k,0) = 0.0;
182 aux_fcent_y(i,j+1,k,1) = 0.0;
184 if (k==bx.bigEnd(2)) {
185 aux_afrac_z(i,j,k+1) = 0.0;
186 aux_fcent_z(i,j,k+1,0) = 0.0;
187 aux_fcent_z(i,j,k+1,1) = 0.0;
190 aux_barea(i,j,k) = 0.0;
192 aux_bcent(i,j,k,0) = 0.0;
193 aux_bcent(i,j,k,1) = 0.0;
194 aux_bcent(i,j,k,2) = 0.0;
196 aux_bnorm(i,j,k,0) = 0.0;
197 aux_bnorm(i,j,k,1) = 0.0;
198 aux_bnorm(i,j,k,2) = 0.0;
201 IntVect iv_hi(i,j,k);
202 IntVect iv_lo(iv_hi - vdim);
203 if (!l_periodic && iv_hi[idim]==domain.bigEnd(idim)){
206 if (!l_periodic && iv_hi[idim]==domain.smallEnd(idim)){
210 if ( flag(iv_lo).isCovered() && flag(iv_hi).isCovered()) {
214 }
else if ( flag(iv_lo).isRegular() && flag(iv_hi).isRegular()) {
216 aux_flag(i,j,k).setRegular();
217 aux_flag(i,j,k).setConnected();
219 aux_vfrac(i,j,k) = 1.0;
221 aux_afrac_x(i,j,k) = 1.0;
222 aux_afrac_y(i,j,k) = 1.0;
223 aux_afrac_z(i,j,k) = 1.0;
225 aux_fcent_x(i,j,k,0) = 0.0; aux_fcent_x(i,j,k,1) = 0.0;
226 aux_fcent_y(i,j,k,0) = 0.0; aux_fcent_y(i,j,k,1) = 0.0;
227 aux_fcent_z(i,j,k,0) = 0.0; aux_fcent_z(i,j,k,1) = 0.0;
229 if (i==bx.bigEnd(0)) {
230 aux_afrac_x(i+1,j,k) = 1.0;
231 aux_fcent_x(i+1,j,k,0) = 0.0;
232 aux_fcent_x(i+1,j,k,1) = 0.0;
234 if (j==bx.bigEnd(1)) {
235 aux_afrac_y(i,j+1,k) = 1.0;
236 aux_fcent_y(i,j+1,k,0) = 0.0;
237 aux_fcent_y(i,j+1,k,1) = 0.0;
239 if (k==bx.bigEnd(2)) {
240 aux_afrac_z(i,j,k+1) = 1.0;
241 aux_fcent_z(i,j,k+1,0) = 0.0;
242 aux_fcent_z(i,j,k+1,1) = 0.0;
247 #ifndef AMREX_USE_GPU
248 if (verbose) { Print() <<
"\ncell: " << amrex::IntVect(i,j,k) <<
"\n"; }
250 Array<Real,AMREX_SPACEDIM> lo_arr = {-0.5,-0.5,-0.5};
251 Array<Real,AMREX_SPACEDIM> hi_arr = { 0.5, 0.5, 0.5};
260 RealVect lo_point (bcent(iv_lo,0), bcent(iv_lo,1), bcent(iv_lo,2));
261 RealVect lo_normal(bnorm(iv_lo,0), bnorm(iv_lo,1), bnorm(iv_lo,2));
263 if (!l_periodic && iv_hi[idim]==domain.smallEnd(idim)){
264 lo_point[idim] += 1.0;
267 if (flag(iv_lo).isSingleValued() ) {
269 Real bnorm_x = bnorm(iv_lo,0) * dx[0];
270 Real bnorm_y = bnorm(iv_lo,1) * dx[1];
271 Real bnorm_z = bnorm(iv_lo,2) * dx[2];
273 Real norm = sqrt( bnorm_x*bnorm_x + bnorm_y*bnorm_y + bnorm_z*bnorm_z);
275 RealVect bnorm_isoparam ( bnorm_x / norm, bnorm_y / norm, bnorm_z / norm);
279 lo_normal = bnorm_isoparam;
286 RealBox lo_rbx(lo_arr.data(), hi_arr.data());
288 eb_cut_cell_ lo_eb_cc(flag(iv_lo), lo_rbx, lo_point, lo_normal);
292 AMREX_ASSERT( !flag(iv_lo).isCovered() || lo_eb_cc.isCovered() );
293 AMREX_ASSERT( !flag(iv_lo).isRegular() || lo_eb_cc.isRegular() );
299 RealVect hi_point (bcent(iv_hi,0), bcent(iv_hi,1), bcent(iv_hi,2));
300 RealVect hi_normal(bnorm(iv_hi,0), bnorm(iv_hi,1), bnorm(iv_hi,2));
302 if (!l_periodic && iv_hi[idim]==domain.bigEnd(idim)){
303 lo_point[idim] += -1.0;
306 if (flag(iv_hi).isSingleValued() ) {
308 Real bnorm_x = bnorm(iv_hi,0) * dx[0];
309 Real bnorm_y = bnorm(iv_hi,1) * dx[1];
310 Real bnorm_z = bnorm(iv_hi,2) * dx[2];
312 Real norm = sqrt( bnorm_x*bnorm_x + bnorm_y*bnorm_y + bnorm_z*bnorm_z);
314 RealVect bnorm_isoparam ( bnorm_x / norm, bnorm_y / norm, bnorm_z / norm);
318 hi_normal = bnorm_isoparam;
325 RealBox hi_rbx(lo_arr.data(), hi_arr.data());
327 eb_cut_cell_ hi_eb_cc(flag(iv_hi), hi_rbx, hi_point, hi_normal);
331 AMREX_ASSERT( !flag(iv_hi).isCovered() || hi_eb_cc.isCovered() );
332 AMREX_ASSERT( !flag(iv_hi).isRegular() || hi_eb_cc.isRegular() );
335 #if defined(AMREX_DEBUG) || defined(AMREX_TESTING) || 1
345 eb_cut_cell_ hi_hi_eb_cc(flag(iv_hi), lo_rbx, hi_point, hi_normal);
349 #ifndef AMREX_USE_GPU
350 if ( !(!flag(iv_hi).isRegular() || hi_hi_eb_cc.isRegular()) ||
351 !(!flag(iv_hi).isCovered() || hi_hi_eb_cc.isCovered()) ) {
352 Print() <<
"flag(iv_hi) and hi_hi_eb_cc flags do not agree\n"
353 <<
"\n isRegular() " << flag(iv_hi).isRegular() <<
" " << hi_hi_eb_cc.isRegular()
354 <<
"\n isCovered() " << flag(iv_hi).isCovered() <<
" " << hi_hi_eb_cc.isCovered()
360 AMREX_ALWAYS_ASSERT( !flag(iv_hi).isRegular() || hi_hi_eb_cc.isRegular() );
361 AMREX_ALWAYS_ASSERT( !flag(iv_hi).isCovered() || hi_hi_eb_cc.isCovered() );
368 if ( flag(iv_hi).isSingleValued() ) {
370 Real
const adx = (idim == 0)
371 ? (hi_eb_cc.areaLo(0) - hi_hi_eb_cc.areaHi(0)) * dx[1] * dx[2]
372 : (hi_eb_cc.areaLo(0) + hi_hi_eb_cc.areaLo(0)) * dx[1] * dx[2]
373 - (hi_eb_cc.areaHi(0) + hi_hi_eb_cc.areaHi(0)) * dx[1] * dx[2];
375 Real
const ady = (idim == 1)
376 ? (hi_eb_cc.areaLo(1) - hi_hi_eb_cc.areaHi(1)) * dx[0] * dx[2]
377 : (hi_eb_cc.areaLo(1) + hi_hi_eb_cc.areaLo(1)) * dx[0] * dx[2]
378 - (hi_eb_cc.areaHi(1) + hi_hi_eb_cc.areaHi(1)) * dx[0] * dx[2];
380 Real
const adz = (idim == 2)
381 ? (hi_eb_cc.areaLo(2) - hi_hi_eb_cc.areaHi(2)) * dx[0] * dx[1]
382 : (hi_eb_cc.areaLo(2) + hi_hi_eb_cc.areaLo(2)) * dx[0] * dx[1]
383 - (hi_eb_cc.areaHi(2) + hi_hi_eb_cc.areaHi(2)) * dx[0] * dx[1];
385 Real
const apnorm = std::sqrt(adx*adx + ady*ady + adz*adz);
388 Real
const apnorminv = 1. / apnorm;
389 RealVect
const normal(adx*apnorminv, ady*apnorminv, adz*apnorminv);
390 Real
const dot_normals = normal.dotProduct(hi_normal);
392 #ifndef AMREX_USE_GPU
393 if ( !amrex::almostEqual(dot_normals, 1.0) ) {
394 Print() <<
"\nFail: check-1 dot_normals " << dot_normals
400 }
else if (verbose) {
401 Print() <<
"Pass: dot_normals = 1.0\n";
405 AMREX_ALWAYS_ASSERT( amrex::almostEqual(dot_normals, 1.0) );
410 #ifndef AMREX_USE_GPU
411 Real
const abs_err = std::abs( hi_eb_cc.areaHi(idim) - hi_hi_eb_cc.areaLo(idim) );
413 if ( abs_err >= machine_tol ) {
414 Print() <<
"\nFail: check-2 area abs_err: " << abs_err
415 <<
"\n hi_eb_cc.areaHi " << hi_eb_cc.areaHi(idim)
416 <<
"\n hi_hi_eb_cc.areaLo " << hi_hi_eb_cc.areaLo(idim)
418 }
else if (verbose) {
419 Print() <<
"Pass: hi_eb_cc.areaHi = hi_hi_eb_cc.areaLo"
420 <<
" abs_err: " << abs_err <<
"\n";
422 AMREX_ALWAYS_ASSERT( abs_err < machine_tol );
427 { Real
const abs_err = amrex::max(std::abs(lo_eb_cc.areaHi(idim) - afrac(iv_hi)),
428 std::abs(hi_eb_cc.areaLo(idim) - afrac(iv_hi)));
429 Real compare_tol = 5.0e-6;
430 #ifndef AMREX_USE_GPU
431 if ( abs_err >= compare_tol ) {
433 Print() <<
"\nFail: check-3 area abs_err " << abs_err
434 <<
"\n hi_eb_cc.areaLo(" << idim <<
") = " << hi_eb_cc.areaLo(idim)
435 <<
"\n lo_eb_cc.areaHi(" << idim <<
") = " << lo_eb_cc.areaHi(idim)
436 <<
"\n afrac" << iv_hi <<
" = " << afrac(iv_hi)
438 }
else if (verbose) {
439 Print() <<
"Pass: hi_eb_cc.areaLo = afrac = " << afrac(iv_hi)
440 <<
" abs_err: " << abs_err <<
"\n";
443 AMREX_ALWAYS_ASSERT( abs_err < compare_tol );
448 { Real
const vol = hi_eb_cc.volume() + hi_hi_eb_cc.volume();
449 Real
const abs_err = amrex::Math::abs(vfrac(iv_hi) - vol);
450 Real compare_tol = 5.0e-6;
451 #ifndef AMREX_USE_GPU
452 if ( abs_err >= compare_tol ) {
455 amrex::Print() <<
"\nFail: check-4 volume abs_err: " << abs_err
456 <<
"\n point: " << hi_point
457 <<
"\n normal: " << hi_normal
458 <<
"\n hi_eb_cc.volume() " << hi_eb_cc.volume()
459 <<
"\n hi_hi_eb_cc.volume() " << hi_hi_eb_cc.volume()
460 <<
"\n vfrac: " << vfrac(iv_hi)
462 }
else if (verbose) {
463 Print() <<
"Pass: hi_eb_cc + hi_hi_eb_cc = vfrac = " << vfrac(iv_hi)
464 <<
" abs_err: " << abs_err <<
"\n";
467 AMREX_ALWAYS_ASSERT( abs_err < compare_tol );
477 if (lo_eb_cc.isCovered() && hi_eb_cc.isCovered()) {
481 }
else if (lo_eb_cc.isRegular() && hi_eb_cc.isRegular()) {
483 aux_flag(i,j,k).setRegular();
484 aux_flag(i,j,k).setConnected();
486 aux_vfrac(i,j,k) = 1.0;
488 aux_afrac_x(i,j,k) = 1.0;
489 aux_afrac_y(i,j,k) = 1.0;
490 aux_afrac_z(i,j,k) = 1.0;
492 aux_fcent_x(i,j,k,0) = 0.0; aux_fcent_x(i,j,k,1) = 0.0;
493 aux_fcent_y(i,j,k,0) = 0.0; aux_fcent_y(i,j,k,1) = 0.0;
494 aux_fcent_z(i,j,k,0) = 0.0; aux_fcent_z(i,j,k,1) = 0.0;
496 if (i==bx.bigEnd(0)) {
497 aux_afrac_x(i+1,j,k) = 1.0;
498 aux_fcent_x(i+1,j,k,0) = 0.0; aux_fcent_x(i+1,j,k,1) = 0.0;
500 if (j==bx.bigEnd(1)) {
501 aux_afrac_y(i,j+1,k) = 1.0;
502 aux_fcent_y(i,j+1,k,0) = 0.0; aux_fcent_y(i,j+1,k,1) = 0.0;
504 if (k==bx.bigEnd(2)) {
505 aux_afrac_z(i,j,k+1) = 1.0;
506 aux_fcent_z(i,j,k+1,0) = 0.0; aux_fcent_z(i,j,k+1,1) = 0.0;
509 }
else if ( (lo_eb_cc.isRegular() && hi_eb_cc.isCovered())
510 || (lo_eb_cc.isCovered() && hi_eb_cc.isRegular()) ) {
513 #ifndef AMREX_USE_GPU
514 Print()<<
"eb_aux_ / Check: Regular and Covered cut cells are facing each other." << std::endl;
521 aux_flag(i,j,k).setSingleValued();
525 Real lo_vol {lo_eb_cc.volume()};
526 Real hi_vol {hi_eb_cc.volume()};
528 aux_vfrac(i,j,k) = lo_vol + hi_vol;
540 RealVect lo_vcent {lo_eb_cc.centVol()};
541 RealVect hi_vcent {hi_eb_cc.centVol()};
543 lo_vcent[idim] = lo_vcent[idim] - 0.5;
544 hi_vcent[idim] = hi_vcent[idim] + 0.5;
546 aux_vcent(i,j,k,0) = ( lo_vol * lo_vcent[0] + hi_vol * hi_vcent[0] ) / aux_vfrac(i,j,k);
547 aux_vcent(i,j,k,1) = ( lo_vol * lo_vcent[1] + hi_vol * hi_vcent[1] ) / aux_vfrac(i,j,k);
548 aux_vcent(i,j,k,2) = ( lo_vol * lo_vcent[2] + hi_vol * hi_vcent[2] ) / aux_vfrac(i,j,k);
552 Real lo_areaLo_x {lo_eb_cc.areaLo(0)};
553 Real lo_areaLo_y {lo_eb_cc.areaLo(1)};
554 Real lo_areaLo_z {lo_eb_cc.areaLo(2)};
556 Real hi_areaLo_x {hi_eb_cc.areaLo(0)};
557 Real hi_areaLo_y {hi_eb_cc.areaLo(1)};
558 Real hi_areaLo_z {hi_eb_cc.areaLo(2)};
560 aux_afrac_x(i,j,k) = (idim == 0) ? lo_areaLo_x : lo_areaLo_x + hi_areaLo_x;
561 aux_afrac_y(i,j,k) = (idim == 1) ? lo_areaLo_y : lo_areaLo_y + hi_areaLo_y;
562 aux_afrac_z(i,j,k) = (idim == 2) ? lo_areaLo_z : lo_areaLo_z + hi_areaLo_z;
564 if (i==bx.bigEnd(0)) {
565 Real lo_areaHi_x {lo_eb_cc.areaHi(0)};
566 Real hi_areaHi_x {hi_eb_cc.areaHi(0)};
567 aux_afrac_x(i+1,j,k) = (idim == 0) ? hi_areaHi_x : lo_areaHi_x + hi_areaHi_x;
569 if (j==bx.bigEnd(1)) {
570 Real lo_areaHi_y {lo_eb_cc.areaHi(1)};
571 Real hi_areaHi_y {hi_eb_cc.areaHi(1)};
572 aux_afrac_y(i,j+1,k) = (idim == 1) ? hi_areaHi_y : lo_areaHi_y + hi_areaHi_y;
574 if (k==bx.bigEnd(2)) {
575 Real lo_areaHi_z {lo_eb_cc.areaHi(2)};
576 Real hi_areaHi_z {hi_eb_cc.areaHi(2)};
577 aux_afrac_z(i,j,k+1) = (idim == 2) ? hi_areaHi_z : lo_areaHi_z + hi_areaHi_z;
590 RealVect lo_centLo_x {lo_eb_cc.centLo(0)};
591 RealVect lo_centLo_y {lo_eb_cc.centLo(1)};
592 RealVect lo_centLo_z {lo_eb_cc.centLo(2)};
594 RealVect hi_centLo_x {hi_eb_cc.centLo(0)};
595 RealVect hi_centLo_y {hi_eb_cc.centLo(1)};
596 RealVect hi_centLo_z {hi_eb_cc.centLo(2)};
599 aux_fcent_x(i,j,k,0) = lo_centLo_x[1];
600 aux_fcent_x(i,j,k,1) = lo_centLo_x[2];
601 aux_fcent_y(i,j,k,0) = (aux_afrac_y(i,j,k) > 0.0)
602 ? ( lo_areaLo_y * (lo_centLo_y[0] - 0.5)
603 + hi_areaLo_y * (hi_centLo_y[0] + 0.5) ) / aux_afrac_y(i,j,k)
605 aux_fcent_y(i,j,k,1) = (aux_afrac_y(i,j,k) > 0.0)
606 ? ( lo_areaLo_y * lo_centLo_y[2]
607 + hi_areaLo_y * hi_centLo_y[2] ) / aux_afrac_y(i,j,k)
609 aux_fcent_z(i,j,k,0) = (aux_afrac_z(i,j,k) > 0.0)
610 ? ( lo_areaLo_z * (lo_centLo_z[0] - 0.5)
611 + hi_areaLo_z * (hi_centLo_z[0] + 0.5) ) / aux_afrac_z(i,j,k)
613 aux_fcent_z(i,j,k,1) = (aux_afrac_z(i,j,k) > 0.0)
614 ? ( lo_areaLo_z * lo_centLo_z[1]
615 + hi_areaLo_z * hi_centLo_z[1] ) / aux_afrac_z(i,j,k)
617 }
else if (idim == 1) {
618 aux_fcent_x(i,j,k,0) = (aux_afrac_x(i,j,k) > 0.0)
619 ? ( lo_areaLo_x * (lo_centLo_x[1] - 0.5)
620 + hi_areaLo_x * (hi_centLo_x[1] + 0.5) ) / aux_afrac_x(i,j,k)
622 aux_fcent_x(i,j,k,1) = (aux_afrac_x(i,j,k) > 0.0)
623 ? ( lo_areaLo_x * lo_centLo_x[2]
624 + hi_areaLo_x * hi_centLo_x[2] ) / aux_afrac_x(i,j,k)
626 aux_fcent_y(i,j,k,0) = lo_centLo_y[0];
627 aux_fcent_y(i,j,k,1) = lo_centLo_y[2];
628 aux_fcent_z(i,j,k,0) = (aux_afrac_z(i,j,k) > 0.0)
629 ? ( lo_areaLo_z * lo_centLo_z[0]
630 + hi_areaLo_z * hi_centLo_z[0] ) / aux_afrac_z(i,j,k)
632 aux_fcent_z(i,j,k,1) = (aux_afrac_z(i,j,k) > 0.0)
633 ? ( lo_areaLo_z * (lo_centLo_z[1] - 0.5)
634 + hi_areaLo_z * (hi_centLo_z[1] + 0.5) ) / aux_afrac_z(i,j,k)
636 }
else if (idim == 2) {
637 aux_fcent_x(i,j,k,0) = (aux_afrac_x(i,j,k) > 0.0)
638 ? ( lo_areaLo_x * lo_centLo_x[1]
639 + hi_areaLo_x * hi_centLo_x[1] ) / aux_afrac_x(i,j,k)
641 aux_fcent_x(i,j,k,1) = (aux_afrac_x(i,j,k) > 0.0)
642 ? ( lo_areaLo_x * (lo_centLo_x[2] - 0.5)
643 + hi_areaLo_x * (hi_centLo_x[2] + 0.5) ) / aux_afrac_x(i,j,k)
645 aux_fcent_y(i,j,k,0) = (aux_afrac_y(i,j,k) > 0.0)
646 ? ( lo_areaLo_y * lo_centLo_y[0]
647 + hi_areaLo_y * hi_centLo_y[0] ) / aux_afrac_y(i,j,k)
649 aux_fcent_y(i,j,k,1) = (aux_afrac_y(i,j,k) > 0.0)
650 ? ( lo_areaLo_y * (lo_centLo_y[2] - 0.5)
651 + hi_areaLo_y * (hi_centLo_y[2] + 0.5) ) / aux_afrac_y(i,j,k)
653 aux_fcent_z(i,j,k,0) = lo_centLo_z[0];
654 aux_fcent_z(i,j,k,1) = lo_centLo_z[1];
657 if (i==bx.bigEnd(0)) {
658 Real lo_areaHi_x {lo_eb_cc.areaHi(0)};
659 Real hi_areaHi_x {hi_eb_cc.areaHi(0)};
660 RealVect lo_centHi_x {lo_eb_cc.centHi(0)};
661 RealVect hi_centHi_x {hi_eb_cc.centHi(0)};
663 aux_fcent_x(i+1,j,k,0) = hi_centHi_x[1];
664 aux_fcent_x(i+1,j,k,1) = hi_centHi_x[2];
665 }
else if (idim == 1) {
666 aux_fcent_x(i+1,j,k,0) = (aux_afrac_x(i+1,j,k) > 0.0)
667 ? ( lo_areaHi_x * (lo_centHi_x[1] - 0.5)
668 + hi_areaHi_x * (hi_centHi_x[1] + 0.5) ) / aux_afrac_x(i+1,j,k)
670 aux_fcent_x(i+1,j,k,1) = (aux_afrac_x(i+1,j,k) > 0.0)
671 ? ( lo_areaHi_x * lo_centHi_x[2]
672 + hi_areaHi_x * hi_centHi_x[2] ) / aux_afrac_x(i+1,j,k)
674 }
else if (idim == 2) {
675 aux_fcent_x(i+1,j,k,0) = (aux_afrac_x(i+1,j,k) > 0.0)
676 ? ( lo_areaHi_x * lo_centHi_x[1]
677 + hi_areaHi_x * hi_centHi_x[1] ) / aux_afrac_x(i+1,j,k)
679 aux_fcent_x(i+1,j,k,1) = (aux_afrac_x(i+1,j,k) > 0.0)
680 ? ( lo_areaHi_x * (lo_centHi_x[2] - 0.5)
681 + hi_areaHi_x * (hi_centHi_x[2] + 0.5) ) / aux_afrac_x(i+1,j,k)
685 if (j==bx.bigEnd(1)) {
686 Real lo_areaHi_y {lo_eb_cc.areaHi(1)};
687 Real hi_areaHi_y {hi_eb_cc.areaHi(1)};
688 RealVect lo_centHi_y {lo_eb_cc.centHi(1)};
689 RealVect hi_centHi_y {hi_eb_cc.centHi(1)};
691 aux_fcent_y(i,j+1,k,0) = (aux_afrac_y(i,j+1,k) > 0.0)
692 ? ( lo_areaHi_y * (lo_centHi_y[0] - 0.5)
693 + hi_areaHi_y * (hi_centHi_y[0] + 0.5) ) / aux_afrac_y(i,j+1,k)
695 aux_fcent_y(i,j+1,k,1) = (aux_afrac_y(i,j+1,k) > 0.0)
696 ? ( lo_areaHi_y * lo_centHi_y[2]
697 + hi_areaHi_y * hi_centHi_y[2] ) / aux_afrac_y(i,j+1,k)
699 }
else if (idim == 1) {
700 aux_fcent_y(i,j+1,k,0) = lo_centHi_y[0];
701 aux_fcent_y(i,j+1,k,1) = lo_centHi_y[2];
702 }
else if (idim == 2) {
703 aux_fcent_y(i,j+1,k,0) = (aux_afrac_y(i,j+1,k) > 0.0)
704 ? ( lo_areaHi_y * lo_centHi_y[0]
705 + hi_areaHi_y * hi_centHi_y[0] ) / aux_afrac_y(i,j+1,k)
707 aux_fcent_y(i,j+1,k,1) = (aux_afrac_y(i,j+1,k) > 0.0)
708 ? ( lo_areaHi_y * (lo_centHi_y[2] - 0.5)
709 + hi_areaHi_y * (hi_centHi_y[2] + 0.5) ) / aux_afrac_y(i,j+1,k)
713 if (k==bx.bigEnd(2)) {
714 Real lo_areaHi_z {lo_eb_cc.areaHi(2)};
715 Real hi_areaHi_z {hi_eb_cc.areaHi(2)};
716 RealVect lo_centHi_z {lo_eb_cc.centHi(2)};
717 RealVect hi_centHi_z {hi_eb_cc.centHi(2)};
719 aux_fcent_z(i,j,k+1,0) = (aux_afrac_z(i,j,k+1) > 0.0)
720 ? ( lo_areaHi_z * (lo_centHi_z[0] - 0.5)
721 + hi_areaHi_z * (hi_centHi_z[0] + 0.5) ) / aux_afrac_z(i,j,k+1)
723 aux_fcent_z(i,j,k+1,1) = (aux_afrac_z(i,j,k+1) > 0.0)
724 ? ( lo_areaHi_z * lo_centHi_z[1]
725 + hi_areaHi_z * hi_centHi_z[1] ) / aux_afrac_z(i,j,k+1)
727 }
else if (idim == 1) {
728 aux_fcent_z(i,j,k+1,0) = (aux_afrac_z(i,j,k+1) > 0.0)
729 ? ( lo_areaHi_z * lo_centHi_z[0]
730 + hi_areaHi_z * hi_centHi_z[0] ) / aux_afrac_z(i,j,k+1)
732 aux_fcent_z(i,j,k+1,1) = (aux_afrac_z(i,j,k+1) > 0.0)
733 ? ( lo_areaHi_z * (lo_centHi_z[1] - 0.5)
734 + hi_areaHi_z * (hi_centHi_z[1] + 0.5) ) / aux_afrac_z(i,j,k+1)
736 }
else if (idim == 2) {
737 aux_fcent_z(i,j,k+1,0) = lo_centHi_z[0];
738 aux_fcent_z(i,j,k+1,1) = lo_centHi_z[1];
744 Real lo_areaBoun {lo_eb_cc.areaBoun()};
745 Real hi_areaBoun {hi_eb_cc.areaBoun()};
747 aux_barea(i,j,k) = lo_areaBoun + hi_areaBoun;
751 RealVect lo_centBoun {lo_eb_cc.centBoun()};
752 RealVect hi_centBoun {hi_eb_cc.centBoun()};
755 aux_bcent(i,j,k,0) = ( lo_areaBoun * (lo_centBoun[0]-0.5) + hi_areaBoun * (hi_centBoun[0]+0.5) ) / aux_barea(i,j,k);
756 aux_bcent(i,j,k,1) = ( lo_areaBoun * lo_centBoun[1] + hi_areaBoun * hi_centBoun[1] ) / aux_barea(i,j,k);
757 aux_bcent(i,j,k,2) = ( lo_areaBoun * lo_centBoun[2] + hi_areaBoun * hi_centBoun[2] ) / aux_barea(i,j,k);
758 }
else if (idim == 1) {
759 aux_bcent(i,j,k,0) = ( lo_areaBoun * lo_centBoun[0] + hi_areaBoun * hi_centBoun[0] ) / aux_barea(i,j,k);
760 aux_bcent(i,j,k,1) = ( lo_areaBoun * (lo_centBoun[1]-0.5) + hi_areaBoun * (hi_centBoun[1]+0.5) ) / aux_barea(i,j,k);
761 aux_bcent(i,j,k,2) = ( lo_areaBoun * lo_centBoun[2] + hi_areaBoun * hi_centBoun[2] ) / aux_barea(i,j,k);
762 }
else if (idim == 2) {
763 aux_bcent(i,j,k,0) = ( lo_areaBoun * lo_centBoun[0] + hi_areaBoun * hi_centBoun[0] ) / aux_barea(i,j,k);
764 aux_bcent(i,j,k,1) = ( lo_areaBoun * lo_centBoun[1] + hi_areaBoun * hi_centBoun[1] ) / aux_barea(i,j,k);
765 aux_bcent(i,j,k,2) = ( lo_areaBoun * (lo_centBoun[2]-0.5) + hi_areaBoun * (hi_centBoun[2]+0.5) ) / aux_barea(i,j,k);
770 RealVect eb_normal = ( lo_areaBoun * lo_normal + hi_areaBoun * hi_normal )/ aux_barea(i,j,k);
772 aux_bnorm(i,j,k,0) = eb_normal[0];
773 aux_bnorm(i,j,k,1) = eb_normal[1];
774 aux_bnorm(i,j,k,2) = eb_normal[2];
778 if (aux_vfrac(i,j,k) < small_volfrac) {
779 aux_vfrac(i,j,k) = 0.0;
780 aux_vcent(i,j,k,0) = 0.0;
781 aux_vcent(i,j,k,1) = 0.0;
782 aux_vcent(i,j,k,2) = 0.0;
783 aux_bcent(i,j,k,0) = 0.0;
784 aux_bcent(i,j,k,1) = 0.0;
785 aux_bcent(i,j,k,2) = 0.0;
786 aux_bnorm(i,j,k,0) = 0.0;
787 aux_bnorm(i,j,k,1) = 0.0;
788 aux_bnorm(i,j,k,2) = 0.0;
789 aux_barea(i,j,k) = 0.0;
790 aux_flag(i,j,k).setCovered();
793 if (aux_vcent(i,j,k,0) < small_value) aux_vcent(i,j,k,0) = 0.0;
794 if (aux_vcent(i,j,k,1) < small_value) aux_vcent(i,j,k,1) = 0.0;
795 if (aux_vcent(i,j,k,2) < small_value) aux_vcent(i,j,k,2) = 0.0;
796 if (aux_bcent(i,j,k,0) < small_value) aux_bcent(i,j,k,0) = 0.0;
797 if (aux_bcent(i,j,k,1) < small_value) aux_bcent(i,j,k,1) = 0.0;
798 if (aux_bcent(i,j,k,2) < small_value) aux_bcent(i,j,k,2) = 0.0;
811 m_volfrac->FillBoundary(a_geom.periodicity());
812 m_volcent->FillBoundary(a_geom.periodicity());
813 for (
int idim = 0; idim < AMREX_SPACEDIM; ++idim) {
814 m_areafrac[idim]->FillBoundary(a_geom.periodicity());
815 m_facecent[idim]->FillBoundary(a_geom.periodicity());
823 for (MFIter mfi(*
m_cellflags,
false); mfi.isValid(); ++mfi) {
825 const Box& bx = mfi.validbox();
827 if (FlagFab[mfi].getType(bx) == FabType::singlevalued ) {
829 Array4<EBCellFlag>
const& aux_flag =
m_cellflags->array(mfi);
830 Array4<Real>
const& aux_afrac_x =
m_areafrac[0]->array(mfi);
831 Array4<Real>
const& aux_afrac_y =
m_areafrac[1]->array(mfi);
832 Array4<Real>
const& aux_afrac_z =
m_areafrac[2]->array(mfi);
834 ParallelFor(bx, [=] AMREX_GPU_DEVICE (
int i,
int j,
int k) noexcept
836 EB2::build_cellflag_from_ap (i, j, k, aux_flag, aux_afrac_x, aux_afrac_y, aux_afrac_z);
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real pp(amrex::Real y)
Definition: ERF_MicrophysicsUtils.H:230
amrex::FabArray< amrex::EBCellFlagFab > * m_cellflags
Definition: ERF_EBAux.H:43
amrex::MultiFab * m_bndrynorm
Definition: ERF_EBAux.H:48
amrex::MultiFab * m_bndryarea
Definition: ERF_EBAux.H:46
amrex::MultiFab * m_volfrac
Definition: ERF_EBAux.H:44
amrex::MultiFab * m_bndrycent
Definition: ERF_EBAux.H:47
amrex::Array< amrex::MultiFab *, AMREX_SPACEDIM > m_facecent
Definition: ERF_EBAux.H:51
amrex::MultiFab * m_volcent
Definition: ERF_EBAux.H:45
amrex::Array< amrex::MultiFab *, AMREX_SPACEDIM > m_areafrac
Definition: ERF_EBAux.H:50
Definition: ERF_EBCutCell.H:14
real(c_double), parameter epsilon
Definition: ERF_module_model_constants.F90:12