Block-Structured AMR Software Framework
Loading...
Searching...
No Matches
AMReX_MLCellABecLap.H
Go to the documentation of this file.
1#ifndef AMREX_ML_CELL_ABECLAP_H_
2#define AMREX_ML_CELL_ABECLAP_H_
3#include <AMReX_Config.H>
4
5#include <AMReX_MLCellLinOp.H>
6#include <AMReX_MLCellABecLap_K.H>
7
8namespace amrex {
9
16
18template <typename MF>
20class MLCellABecLapT // NOLINT(cppcoreguidelines-virtual-class-destructor)
21 : public MLCellLinOpT<MF>
22{
23public:
24
25 using FAB = typename MF::fab_type;
26 using RT = typename MF::value_type;
27
29
30 MLCellABecLapT () = default;
31 ~MLCellABecLapT () override = default;
32
37
47 void define (const Vector<Geometry>& a_geom,
48 const Vector<BoxArray>& a_grids,
49 const Vector<DistributionMapping>& a_dmap,
50 const LPInfo& a_info = LPInfo(),
51 const Vector<FabFactory<FAB> const*>& a_factory = {});
52
63 void define (const Vector<Geometry>& a_geom,
64 const Vector<BoxArray>& a_grids,
65 const Vector<DistributionMapping>& a_dmap,
66 const Vector<iMultiFab const*>& a_overset_mask,
67 const LPInfo& a_info = LPInfo(),
68 const Vector<FabFactory<FAB> const*>& a_factory = {});
69
71 [[nodiscard]] iMultiFab const* getOversetMask (int amrlev, int mglev) const {
72 return m_overset_mask[amrlev][mglev].get();
73 }
74
75 [[nodiscard]] bool needsUpdate () const override {
77 }
78
79 void update () override;
80
82 void prepareForSolve () override;
83
88 void setDirichletNodesToZero (int amrlev, int mglev, MF& mf) const override;
89
98 const Vector<MF*>& a_sol,
99 Location a_loc) const final;
104 void getFluxes (const Vector<MF*>& a_flux,
105 const Vector<MF*>& a_sol) const final {
106 amrex::ignore_unused(a_flux, a_sol);
107 amrex::Abort("MLCellABecLap::getFluxes: How did we get here?");
108 }
109
111 virtual RT getAScalar () const = 0;
113 virtual RT getBScalar () const = 0;
115 virtual MF const* getACoeffs (int amrlev, int mglev) const = 0;
117 virtual Array<MF const*,AMREX_SPACEDIM> getBCoeffs (int amrlev, int mglev) const = 0;
118
120 void applyInhomogNeumannTerm (int amrlev, MF& rhs) const final;
121
124 int amrlev, const Array<MF*,AMREX_SPACEDIM>& grad,
125 MF const& sol, bool mult_bcoef) const final;
126
128 void applyOverset (int amrlev, MF& rhs) const override;
129
131 [[nodiscard]] virtual MF const* getEBBCoeffs (int /*amrlev*/, int /*mglev*/) const { return nullptr; }
132
133 [[nodiscard]] std::unique_ptr<MLAlgMG> makeAlgMG (int mglev) const override;
134 [[nodiscard]] bool supportsAlgMG () const override { return std::is_same_v<MF,MultiFab>; }
135
138 [[nodiscard]] Array<MF,AMREX_SPACEDIM> makeDefaultBCoeffs (int mglev) const;
139
140#if defined(AMREX_USE_HYPRE) && (AMREX_SPACEDIM > 1)
142 [[nodiscard]] std::unique_ptr<Hypre> makeHypre (Hypre::Interface hypre_interface) const override;
143#endif
144
145#if defined(AMREX_USE_PETSC) && (AMREX_SPACEDIM > 1)
147 [[nodiscard]] std::unique_ptr<PETScABecLap> makePETSc () const override;
148#endif
149
150protected:
152
154
155 [[nodiscard]] bool supportInhomogNeumannBC () const noexcept override { return true; }
156};
157
158template <typename MF>
159void
161 const Vector<BoxArray>& a_grids,
162 const Vector<DistributionMapping>& a_dmap,
163 const LPInfo& a_info,
164 const Vector<FabFactory<FAB> const*>& a_factory)
165{
166 MLCellLinOpT<MF>::define(a_geom, a_grids, a_dmap, a_info, a_factory);
167
168 this->m_overset_mask.resize(this->m_num_amr_levels);
169 for (int amrlev = 0; amrlev < this->m_num_amr_levels; ++amrlev) {
170 this->m_overset_mask[amrlev].resize(this->m_num_mg_levels[amrlev]);
171 }
172}
173
174template <typename MF>
175void
177 const Vector<BoxArray>& a_grids,
178 const Vector<DistributionMapping>& a_dmap,
179 const Vector<iMultiFab const*>& a_overset_mask,
180 const LPInfo& a_info,
181 const Vector<FabFactory<FAB> const*>& a_factory)
182{
183 BL_PROFILE("MLCellABecLap::define(overset)");
184
186
187 this->m_lpinfo_arg = a_info;
188
189 auto namrlevs = static_cast<int>(a_geom.size());
190 this->m_overset_mask.resize(namrlevs);
191 for (int amrlev = 0; amrlev < namrlevs; ++amrlev)
192 {
193 this->m_overset_mask[amrlev].push_back(std::make_unique<iMultiFab>(a_grids[amrlev],
194 a_dmap[amrlev], 1, 1));
195 iMultiFab::Copy(*(this->m_overset_mask[amrlev][0]), *a_overset_mask[amrlev], 0, 0, 1, 0);
196 if (amrlev > 1) {
197 AMREX_ALWAYS_ASSERT(amrex::refine(a_geom[amrlev-1].Domain(),2)
198 == a_geom[amrlev].Domain());
199 }
200 }
201
202 int amrlev = 0;
203 Box dom = a_geom[0].Domain();
204 for (int mglev = 1; mglev <= a_info.max_coarsening_level; ++mglev)
205 {
207 iMultiFab const& fine = *(this->m_overset_mask[amrlev][mglev-1]);
208 if (dom.coarsenable(2) && fine.boxArray().coarsenable(2)) {
209 dom.coarsen(2);
210 auto crse = std::make_unique<iMultiFab>(amrex::coarsen(fine.boxArray(),2),
211 fine.DistributionMap(), 1, 1);
212 ReduceOps<ReduceOpSum> reduce_op;
213 ReduceData<int> reduce_data(reduce_op);
214 using ReduceTuple = typename decltype(reduce_data)::Type;
215#ifdef AMREX_USE_OMP
216#pragma omp parallel if (Gpu::notInLaunchRegion())
217#endif
218 for (MFIter mfi(*crse, TilingIfNotGPU()); mfi.isValid(); ++mfi)
219 {
220 const Box& bx = mfi.tilebox();
221 Array4<int const> const& fmsk = fine.const_array(mfi);
222 Array4<int> const& cmsk = crse->array(mfi);
223 reduce_op.eval(bx, reduce_data,
224 [=] AMREX_GPU_HOST_DEVICE (Box const& b) -> ReduceTuple
225 {
226 return { coarsen_overset_mask(b, cmsk, fmsk) };
227 });
228 }
229 ReduceTuple hv = reduce_data.value(reduce_op);
230 if (amrex::get<0>(hv) == 0) {
231 this->m_overset_mask[amrlev].push_back(std::move(crse));
232 } else {
233 break;
234 }
235 } else {
236 break;
237 }
238 }
239 int max_overset_mask_coarsening_level = this->m_overset_mask[amrlev].size()-1;
240 ParallelAllReduce::Min(max_overset_mask_coarsening_level, ParallelContext::CommunicatorSub());
241 this->m_overset_mask[amrlev].resize(max_overset_mask_coarsening_level+1);
242
243 LPInfo linfo = a_info;
244 linfo.max_coarsening_level = std::min(a_info.max_coarsening_level,
245 max_overset_mask_coarsening_level);
246 // The overset masks above are coarsened isotropically by 2, so the MG
247 // levels must be too, or the masks and the grids end up in different
248 // index spaces.
249 linfo.do_semicoarsening = false;
250
251 MLCellLinOpT<MF>::define(a_geom, a_grids, a_dmap, linfo, a_factory);
252
253 amrlev = 0;
254 for (int mglev = 1; mglev < this->m_num_mg_levels[amrlev]; ++mglev) {
255 MF foo(this->m_grids[amrlev][mglev], this->m_dmap[amrlev][mglev], 1, 0, MFInfo().SetAlloc(false));
256 if (! amrex::isMFIterSafe(*(this->m_overset_mask[amrlev][mglev]), foo)) {
257 auto osm = std::make_unique<iMultiFab>(this->m_grids[amrlev][mglev],
258 this->m_dmap[amrlev][mglev], 1, 1);
259 osm->ParallelCopy(*(this->m_overset_mask[amrlev][mglev]));
260 std::swap(osm, this->m_overset_mask[amrlev][mglev]);
261#ifdef AMREX_USE_GPU
262 // The old mask is about to be freed
264#endif
265 }
266 }
267
268 for (amrlev = 1; amrlev < this->m_num_amr_levels; ++amrlev) {
269 for (int mglev = 1; mglev < this->m_num_mg_levels[amrlev]; ++mglev) { // for ref_ratio 4
270 this->m_overset_mask[amrlev].push_back(std::make_unique<iMultiFab>(this->m_grids[amrlev][mglev],
271 this->m_dmap[amrlev][mglev],
272 1, 1));
273
274#ifdef AMREX_USE_GPU
275 if (Gpu::inLaunchRegion() && this->m_overset_mask[amrlev][mglev]->isFusingCandidate()) {
276 auto const& crsema = this->m_overset_mask[amrlev][mglev]->arrays();
277 auto const& finema = this->m_overset_mask[amrlev][mglev-1]->const_arrays();
278 ParallelFor(*(this->m_overset_mask[amrlev][mglev]),
279 [=] AMREX_GPU_DEVICE (int box_no, int i, int j, int k) noexcept
280 {
281 coarsen_overset_mask(i,j,k, crsema[box_no], finema[box_no]);
282 });
283 if (!Gpu::inNoSyncRegion()) {
285 }
286 } else
287#endif
288 {
289#ifdef AMREX_USE_OMP
290#pragma omp parallel if (Gpu::notInLaunchRegion())
291#endif
292 for (MFIter mfi(*(this->m_overset_mask[amrlev][mglev]), TilingIfNotGPU()); mfi.isValid(); ++mfi)
293 {
294 const Box& bx = mfi.tilebox();
295 Array4<int> const& cmsk = this->m_overset_mask[amrlev][mglev]->array(mfi);
296 Array4<int const> const fmsk = this->m_overset_mask[amrlev][mglev-1]->const_array(mfi);
298 {
299 coarsen_overset_mask(i,j,k, cmsk, fmsk);
300 });
301 }
302 }
303 }
304 }
305
306 for (amrlev = 0; amrlev < this->m_num_amr_levels; ++amrlev) {
307 for (int mglev = 0; mglev < this->m_num_mg_levels[amrlev]; ++mglev) {
308 this->m_overset_mask[amrlev][mglev]->setBndry(1);
309 this->m_overset_mask[amrlev][mglev]->FillBoundary(this->m_geom[amrlev][mglev].periodicity());
310 }
311 }
312}
313
314template <typename MF>
315void
320
321template <typename MF>
322void
327
328template <typename MF>
329void
330MLCellABecLapT<MF>::setDirichletNodesToZero (int amrlev, int mglev, MF& mf) const
331{
332 auto const* omask = this->getOversetMask(amrlev, mglev);
333 if (omask) {
334 const int ncomp = this->getNComp();
335 auto const& mskma = omask->const_arrays();
336 auto const& ma = mf.arrays();
337 ParallelFor(mf, IntVect(0), ncomp,
338 [=] AMREX_GPU_DEVICE (int bno, int i, int j, int k, int n)
339 {
340 if (mskma[bno](i,j,k) == 0) { ma[bno](i,j,k,n) = RT(0.0); }
341 });
342 if (!Gpu::inNoSyncRegion()) {
344 }
345 }
346}
347
348template <typename MF>
349void
351 const Vector<MF*>& a_sol,
352 Location a_loc) const
353{
354 BL_PROFILE("MLMG::getFluxes()");
355
356 const int ncomp = this->getNComp();
357 const RT betainv = RT(1.0) / getBScalar();
358 const int nlevs = this->NAMRLevels();
359 // Without b coefficients, the metric factor is in the flux kernels, not in
360 // b, so it must be removed before the boundary faces are set using b = 1.
361 const bool has_bcoef = (getBCoeffs(0,0)[0] != nullptr);
362 for (int alev = 0; alev < nlevs; ++alev) {
363 this->compFlux(alev, a_flux[alev], *a_sol[alev], a_loc);
364 for (int idim = 0; idim < AMREX_SPACEDIM; ++idim) {
365 if (betainv != RT(1.0)) {
366 a_flux[alev][idim]->mult(betainv, 0, ncomp);
367 }
368 if (!has_bcoef) {
369 this->unapplyMetricTerm(alev, 0, *a_flux[alev][idim]);
370 }
371 }
372 this->addInhomogNeumannFlux(alev, a_flux[alev], *a_sol[alev], true);
373 if (has_bcoef) {
374 for (int idim = 0; idim < AMREX_SPACEDIM; ++idim) {
375 this->unapplyMetricTerm(alev, 0, *a_flux[alev][idim]);
376 }
377 }
378 }
379}
380
381template <typename MF>
382void
384{
385 bool has_inhomog_neumann = this->hasInhomogNeumannBC();
386 bool has_robin = this->hasRobinBC();
387
388 // A preconditioner must be linear, so it gets no inhomogeneous terms.
389 if (this->m_precond_mode) { return; }
390 if (!has_inhomog_neumann && !has_robin) { return; }
391
392 int ncomp = this->getNComp();
393 const int mglev = 0;
394
395 const auto problo = this->m_geom[amrlev][mglev].ProbLoArray();
396 const auto probhi = this->m_geom[amrlev][mglev].ProbHiArray();
397 amrex::ignore_unused(probhi);
398 const RT dxi = static_cast<RT>(this->m_geom[amrlev][mglev].InvCellSize(0));
399 const RT dyi = static_cast<RT>((AMREX_SPACEDIM >= 2) ? this->m_geom[amrlev][mglev].InvCellSize(1) : Real(1.0));
400 const RT dzi = static_cast<RT>((AMREX_SPACEDIM == 3) ? this->m_geom[amrlev][mglev].InvCellSize(2) : Real(1.0));
401 const RT xlo = static_cast<RT>(problo[0]);
402 const RT dx = static_cast<RT>(this->m_geom[amrlev][mglev].CellSize(0));
403 const Box& domain = this->m_geom[amrlev][mglev].Domain();
404
405 const RT beta = getBScalar();
406 Array<MF const*, AMREX_SPACEDIM> const& bcoef = getBCoeffs(amrlev,mglev);
407 FAB foo(Box(IntVect(0),IntVect(1)));
408 bool has_bcoef = (bcoef[0] != nullptr);
409
410 const auto& maskvals = this->m_maskvals[amrlev][mglev];
411 const auto& bcondloc = *(this->m_bcondloc[amrlev][mglev]);
412 const auto& bndry = *(this->m_bndry_sol[amrlev]);
413
414 MFItInfo mfi_info;
415 if (Gpu::notInLaunchRegion()) { mfi_info.SetDynamic(true); }
416
417#ifdef AMREX_USE_OMP
418#pragma omp parallel if (Gpu::notInLaunchRegion())
419#endif
420 for (MFIter mfi(rhs, mfi_info); mfi.isValid(); ++mfi)
421 {
422 const Box& vbx = mfi.validbox();
423 auto const& rhsfab = rhs.array(mfi);
424
425 const auto & bdlv = bcondloc.bndryLocs(mfi);
426 const auto & bdcv = bcondloc.bndryConds(mfi);
427
428 for (int idim = 0; idim < AMREX_SPACEDIM; ++idim)
429 {
430 auto const bfab = (has_bcoef)
431 ? bcoef[idim]->const_array(mfi) : foo.const_array();
432 const Orientation olo(idim,Orientation::low);
433 const Orientation ohi(idim,Orientation::high);
434 const Box blo = amrex::adjCellLo(vbx, idim);
435 const Box bhi = amrex::adjCellHi(vbx, idim);
436 const auto& mlo = maskvals[olo].array(mfi);
437 const auto& mhi = maskvals[ohi].array(mfi);
438 const auto& bvlo = bndry.bndryValues(olo).array(mfi);
439 const auto& bvhi = bndry.bndryValues(ohi).array(mfi);
440 bool outside_domain_lo = !(domain.contains(blo));
441 bool outside_domain_hi = !(domain.contains(bhi));
442 if ((!outside_domain_lo) && (!outside_domain_hi)) { continue; }
443 for (int icomp = 0; icomp < ncomp; ++icomp) {
444 const BoundCond bctlo = bdcv[icomp][olo];
445 const BoundCond bcthi = bdcv[icomp][ohi];
446 const RT bcllo = bdlv[icomp][olo];
447 const RT bclhi = bdlv[icomp][ohi];
448 if (this->m_lobc_orig[icomp][idim] == LinOpBCType::inhomogNeumann && outside_domain_lo)
449 {
450 if (idim == 0) {
451 RT fac = beta*dxi;
452 if (this->m_has_metric_term && !has_bcoef) {
453#if (AMREX_SPACEDIM == 1)
454 fac *= static_cast<RT>(problo[0]*problo[0]);
455#elif (AMREX_SPACEDIM == 2)
456 fac *= static_cast<RT>(problo[0]);
457#endif
458 }
459 AMREX_HOST_DEVICE_FOR_3D(blo, i, j, k,
460 {
461 mllinop_apply_innu_xlo(i,j,k, rhsfab, mlo, bfab,
462 bctlo, bcllo, bvlo,
463 fac, has_bcoef, icomp);
464 });
465 } else if (idim == 1) {
466 RT fac = beta*dyi;
467 if (this->m_has_metric_term && !has_bcoef) {
468 AMREX_HOST_DEVICE_FOR_3D(blo, i, j, k,
469 {
470 mllinop_apply_innu_ylo_m(i,j,k, rhsfab, mlo,
471 bctlo, bcllo, bvlo,
472 fac, xlo, dx, icomp);
473 });
474 }
475 else {
476 AMREX_HOST_DEVICE_FOR_3D(blo, i, j, k,
477 {
478 mllinop_apply_innu_ylo(i,j,k, rhsfab, mlo, bfab,
479 bctlo, bcllo, bvlo,
480 fac, has_bcoef, icomp);
481 });
482 }
483 } else {
484 RT fac = beta*dzi;
485 AMREX_HOST_DEVICE_FOR_3D(blo, i, j, k,
486 {
487 mllinop_apply_innu_zlo(i,j,k, rhsfab, mlo, bfab,
488 bctlo, bcllo, bvlo,
489 fac, has_bcoef, icomp);
490 });
491 }
492 }
493 if (this->m_hibc_orig[icomp][idim] == LinOpBCType::inhomogNeumann && outside_domain_hi)
494 {
495 if (idim == 0) {
496 RT fac = beta*dxi;
497 if (this->m_has_metric_term && !has_bcoef) {
498#if (AMREX_SPACEDIM == 1)
499 fac *= static_cast<RT>(probhi[0]*probhi[0]);
500#elif (AMREX_SPACEDIM == 2)
501 fac *= static_cast<RT>(probhi[0]);
502#endif
503 }
504 AMREX_HOST_DEVICE_FOR_3D(bhi, i, j, k,
505 {
506 mllinop_apply_innu_xhi(i,j,k, rhsfab, mhi, bfab,
507 bcthi, bclhi, bvhi,
508 fac, has_bcoef, icomp);
509 });
510 } else if (idim == 1) {
511 RT fac = beta*dyi;
512 if (this->m_has_metric_term && !has_bcoef) {
513 AMREX_HOST_DEVICE_FOR_3D(bhi, i, j, k,
514 {
515 mllinop_apply_innu_yhi_m(i,j,k, rhsfab, mhi,
516 bcthi, bclhi, bvhi,
517 fac, xlo, dx, icomp);
518 });
519 } else {
520 AMREX_HOST_DEVICE_FOR_3D(bhi, i, j, k,
521 {
522 mllinop_apply_innu_yhi(i,j,k, rhsfab, mhi, bfab,
523 bcthi, bclhi, bvhi,
524 fac, has_bcoef, icomp);
525 });
526 }
527 } else {
528 RT fac = beta*dzi;
529 AMREX_HOST_DEVICE_FOR_3D(bhi, i, j, k,
530 {
531 mllinop_apply_innu_zhi(i,j,k, rhsfab, mhi, bfab,
532 bcthi, bclhi, bvhi,
533 fac, has_bcoef, icomp);
534 });
535 }
536 }
537
538 if (has_robin) {
539 // For Robin BC, see comments in AMReX_MLABecLaplacian.cpp above
540 // function applyRobinBCTermsCoeffs.
541 auto const& rbc = (*this->m_robin_bcval[amrlev])[mfi].const_array(icomp*3);
542 if (this->m_lobc_orig[icomp][idim] == LinOpBCType::Robin && outside_domain_lo)
543 {
544 if (idim == 0) {
545 RT fac = beta*dxi*dxi;
546 AMREX_HOST_DEVICE_FOR_3D(blo, i, j, k,
547 {
548 RT A = rbc(i,j,k,2)
549 / (rbc(i,j,k,1)*dxi + rbc(i,j,k,0)*RT(0.5));
550 rhsfab(i+1,j,k,icomp) += fac*bfab(i+1,j,k,icomp)*A;
551 });
552 } else if (idim == 1) {
553 RT fac = beta*dyi*dyi;
554 AMREX_HOST_DEVICE_FOR_3D(blo, i, j, k,
555 {
556 RT A = rbc(i,j,k,2)
557 / (rbc(i,j,k,1)*dyi + rbc(i,j,k,0)*RT(0.5));
558 rhsfab(i,j+1,k,icomp) += fac*bfab(i,j+1,k,icomp)*A;
559 });
560 } else {
561 RT fac = beta*dzi*dzi;
562 AMREX_HOST_DEVICE_FOR_3D(blo, i, j, k,
563 {
564 RT A = rbc(i,j,k,2)
565 / (rbc(i,j,k,1)*dzi + rbc(i,j,k,0)*RT(0.5));
566 rhsfab(i,j,k+1,icomp) += fac*bfab(i,j,k+1,icomp)*A;
567 });
568 }
569 }
570 if (this->m_hibc_orig[icomp][idim] == LinOpBCType::Robin && outside_domain_hi)
571 {
572 if (idim == 0) {
573 RT fac = beta*dxi*dxi;
574 AMREX_HOST_DEVICE_FOR_3D(bhi, i, j, k,
575 {
576 RT A = rbc(i,j,k,2)
577 / (rbc(i,j,k,1)*dxi + rbc(i,j,k,0)*RT(0.5));
578 rhsfab(i-1,j,k,icomp) += fac*bfab(i,j,k,icomp)*A;
579 });
580 } else if (idim == 1) {
581 RT fac = beta*dyi*dyi;
582 AMREX_HOST_DEVICE_FOR_3D(bhi, i, j, k,
583 {
584 RT A = rbc(i,j,k,2)
585 / (rbc(i,j,k,1)*dyi + rbc(i,j,k,0)*RT(0.5));
586 rhsfab(i,j-1,k,icomp) += fac*bfab(i,j,k,icomp)*A;
587 });
588 } else {
589 RT fac = beta*dzi*dzi;
590 AMREX_HOST_DEVICE_FOR_3D(bhi, i, j, k,
591 {
592 RT A = rbc(i,j,k,2)
593 / (rbc(i,j,k,1)*dzi + rbc(i,j,k,0)*RT(0.5));
594 rhsfab(i,j,k-1,icomp) += fac*bfab(i,j,k,icomp)*A;
595 });
596 }
597 }
598 }
599 }
600 }
601
602 }
603}
604
605template <typename MF>
606void
608 int amrlev, const Array<MF*,AMREX_SPACEDIM>& grad, MF const& sol,
609 bool mult_bcoef) const
610{
611 /*
612 * if (mult_bcoef == true)
613 * grad is -bceof*grad phi
614 * else
615 * grad is grad phi
616 */
617 RT fac = mult_bcoef ? RT(-1.0) : RT(1.0);
618
619 bool has_inhomog_neumann = this->hasInhomogNeumannBC();
620 bool has_robin = this->hasRobinBC();
621
622 if (!has_inhomog_neumann && !has_robin) { return; }
623
624 int ncomp = this->getNComp();
625 const int mglev = 0;
626
627 const auto dxinv = this->m_geom[amrlev][mglev].InvCellSize();
628 const Box domain = this->m_geom[amrlev][mglev].growPeriodicDomain(1);
629
630 Array<MF const*, AMREX_SPACEDIM> bcoef = {AMREX_D_DECL(nullptr,nullptr,nullptr)};
631 if (mult_bcoef) {
632 bcoef = getBCoeffs(amrlev,mglev);
633 }
634
635 const auto& bndry = *this->m_bndry_sol[amrlev];
636
637 MFItInfo mfi_info;
638 if (Gpu::notInLaunchRegion()) { mfi_info.SetDynamic(true); }
639
640#ifdef AMREX_USE_OMP
641#pragma omp parallel if (Gpu::notInLaunchRegion())
642#endif
643 for (MFIter mfi(sol, mfi_info); mfi.isValid(); ++mfi)
644 {
645 Box const& vbx = mfi.validbox();
646 for (OrientationIter orit; orit.isValid(); ++orit) {
647 const Orientation ori = orit();
648 const int idim = ori.coordDir();
649 const Box& ccb = amrex::adjCell(vbx, ori);
650 const Dim3 os = IntVect::TheDimensionVector(idim).dim3();
651 const RT dxi = static_cast<RT>(dxinv[idim]);
652 if (! domain.contains(ccb)) {
653 for (int icomp = 0; icomp < ncomp; ++icomp) {
654 auto const& phi = sol.const_array(mfi,icomp);
655 auto const& bv = bndry.bndryValues(ori).multiFab().const_array(mfi,icomp);
656 auto const& bc = bcoef[idim] ? bcoef[idim]->const_array(mfi,icomp)
658 auto const& f = grad[idim]->array(mfi,icomp);
659 if (ori.isLow()) {
660 if (this->m_lobc_orig[icomp][idim] ==
662 AMREX_HOST_DEVICE_FOR_3D(ccb, i, j, k,
663 {
664 int ii = i+os.x;
665 int jj = j+os.y;
666 int kk = k+os.z;
667 RT b = bc ? bc(ii,jj,kk) : RT(1.0);
668 f(ii,jj,kk) = fac*b*bv(i,j,k);
669 });
670 } else if (this->m_lobc_orig[icomp][idim] ==
672 auto const& rbc = (*this->m_robin_bcval[amrlev])[mfi].const_array(icomp*3);
673 AMREX_HOST_DEVICE_FOR_3D(ccb, i, j, k,
674 {
675 int ii = i+os.x;
676 int jj = j+os.y;
677 int kk = k+os.z;
678 RT tmp = RT(1.0) /
679 (rbc(i,j,k,1)*dxi + rbc(i,j,k,0)*RT(0.5));
680 RT RA = rbc(i,j,k,2) * tmp;
681 RT RB = (rbc(i,j,k,1)*dxi - rbc(i,j,k,0)*RT(0.5)) * tmp;
682 RT b = bc ? bc(ii,jj,kk) : RT(1.0);
683 f(ii,jj,kk) = fac*b*dxi*((RT(1.0)-RB)*phi(ii,jj,kk)-RA);
684 });
685 }
686 } else {
687 if (this->m_hibc_orig[icomp][idim] ==
689 AMREX_HOST_DEVICE_FOR_3D(ccb, i, j, k,
690 {
691 RT b = bc ? bc(i,j,k) : RT(1.0);
692 f(i,j,k) = fac*b*bv(i,j,k);
693 });
694 } else if (this->m_hibc_orig[icomp][idim] ==
696 auto const& rbc = (*this->m_robin_bcval[amrlev])[mfi].const_array(icomp*3);
697 AMREX_HOST_DEVICE_FOR_3D(ccb, i, j, k,
698 {
699 RT tmp = RT(1.0) /
700 (rbc(i,j,k,1)*dxi + rbc(i,j,k,0)*RT(0.5));
701 RT RA = rbc(i,j,k,2) * tmp;
702 RT RB = (rbc(i,j,k,1)*dxi - rbc(i,j,k,0)*RT(0.5)) * tmp;
703 RT b = bc ? bc(i,j,k) : RT(1.0);
704 f(i,j,k) = fac*b*dxi*(RA+(RB-RT(1.0))*
705 phi(i-os.x,j-os.y,k-os.z));
706 });
707 }
708 }
709 }
710 }
711 }
712 }
713}
714
715template <typename MF>
716void
717MLCellABecLapT<MF>::applyOverset (int amrlev, MF& rhs) const
718{
719 if (m_overset_mask[amrlev][0]) {
720 const int ncomp = this->getNComp();
721#ifdef AMREX_USE_GPU
722 if (Gpu::inLaunchRegion() && m_overset_mask[amrlev][0]->isFusingCandidate()) {
723 auto const& osma = m_overset_mask[amrlev][0]->const_arrays();
724 auto const& rhsa = rhs.arrays();
725 ParallelFor(*m_overset_mask[amrlev][0], IntVect(0), ncomp,
726 [=] AMREX_GPU_DEVICE (int box_no, int i, int j, int k, int n) noexcept
727 {
728 if (osma[box_no](i,j,k) == 0) {
729 rhsa[box_no](i,j,k,n) = RT(0.0);
730 }
731 });
732 if (!Gpu::inNoSyncRegion()) {
734 }
735 } else
736#endif
737 {
738#ifdef AMREX_USE_OMP
739#pragma omp parallel if (Gpu::notInLaunchRegion())
740#endif
741 for (MFIter mfi(*m_overset_mask[amrlev][0],TilingIfNotGPU()); mfi.isValid(); ++mfi)
742 {
743 const Box& bx = mfi.tilebox();
744 auto const& rfab = rhs.array(mfi);
745 auto const& osm = m_overset_mask[amrlev][0]->const_array(mfi);
746 AMREX_HOST_DEVICE_PARALLEL_FOR_4D(bx, ncomp, i, j, k, n,
747 {
748 if (osm(i,j,k) == 0) { rfab(i,j,k,n) = RT(0.0); }
749 });
750 }
751 }
752 }
753}
754
755template <typename MF>
758{
759 const int amrlev = 0;
761 for (int idim = 0; idim < AMREX_SPACEDIM; ++idim) {
762 beta[idim].define(amrex::convert(this->m_grids[amrlev][mglev],
764 this->m_dmap[amrlev][mglev], 1, 0,
765 MFInfo().SetArena(The_Async_Arena()),
766 *(this->m_factory[amrlev][mglev]));
767 beta[idim].setVal(RT(1.0));
768 this->applyMetricTerm(amrlev, mglev, beta[idim]);
769 }
770 return beta;
771}
772
773template <typename MF>
774std::unique_ptr<MLAlgMG>
776{
777 if constexpr (!std::is_same<MF,MultiFab>()) {
779 amrex::Abort("MLCellABecLap: AlgMG only supports MultiFab");
780 return nullptr;
781 } else {
782 const int amrlev = 0;
783 const BoxArray& ba = this->m_grids[amrlev][mglev];
784 const DistributionMapping& dm = this->m_dmap[amrlev][mglev];
785 const Geometry& geom = this->m_geom[amrlev][mglev];
786 const auto& factory = *(this->m_factory[amrlev][mglev]);
787
788 auto const& bcondloc = *(this->m_bcondloc[amrlev][mglev]);
791 for (MFIter mfi(bctype); mfi.isValid(); ++mfi) {
792 for (OrientationIter oit; oit; oit++) {
793 int const cdir = oit();
794 bctype[mfi][cdir] = bcondloc.bndryConds(mfi, 0)[cdir];
795 bcl[mfi][cdir] = bcondloc.bndryLocs(mfi, 0)[cdir];
796 }
797 }
798
799 auto ac = getACoeffs(amrlev, mglev);
800 auto bc = getBCoeffs(amrlev, mglev);
802 if (bc[0] == nullptr) {
803 beta = makeDefaultBCoeffs(mglev);
804 bc = amrex::GetArrOfConstPtrs(beta);
805 }
806 return std::make_unique<MLAlgMG>(mglev, ba, dm, geom, factory,
807 getOversetMask(amrlev, mglev),
808 getAScalar(), getBScalar(), ac, bc,
809 getEBBCoeffs(amrlev, mglev), bctype, bcl,
810 this->getMaxOrder());
811 }
812}
813
814#if defined(AMREX_USE_HYPRE) && (AMREX_SPACEDIM > 1)
815template <typename MF>
816std::unique_ptr<Hypre>
818{
819 if constexpr (!std::is_same<MF,MultiFab>()) {
820 amrex::Abort("MLCellABecLap Hypre interface only supports MultiFab");
821 } else {
822 const BoxArray& ba = this->m_grids[0].back();
823 const DistributionMapping& dm = this->m_dmap[0].back();
824 const Geometry& geom = this->m_geom[0].back();
825 const auto& factory = *(this->m_factory[0].back());
826 MPI_Comm comm = this->BottomCommunicator();
827
828 const int mglev = this->NMGLevels(0)-1;
829
830 auto om = getOversetMask(0, mglev);
831
832 auto hypre_solver = amrex::makeHypre(ba, dm, geom, comm, hypre_interface, om);
833
834 hypre_solver->setScalars(getAScalar(), getBScalar());
835
836 auto ac = getACoeffs(0, mglev);
837 if (ac)
838 {
839 hypre_solver->setACoeffs(*ac);
840 }
841 else
842 {
843 MultiFab alpha(ba,dm,1,0,MFInfo().SetArena(The_Async_Arena()),factory);
844 alpha.setVal(0.0);
845 hypre_solver->setACoeffs(alpha);
846 }
847
848 auto bc = getBCoeffs(0, mglev);
849 if (bc[0])
850 {
851 hypre_solver->setBCoeffs(bc);
852 }
853 else
854 {
855 auto beta = makeDefaultBCoeffs(mglev);
856 hypre_solver->setBCoeffs(amrex::GetArrOfConstPtrs(beta));
857 }
858 hypre_solver->setIsMatrixSingular(this->isBottomSingular());
859
860 return hypre_solver;
861 }
862 return nullptr;
863}
864#endif
865
866#if defined(AMREX_USE_PETSC) && (AMREX_SPACEDIM > 1)
867template <typename MF>
868std::unique_ptr<PETScABecLap>
870{
871 if constexpr (!std::is_same<MF,MultiFab>()) {
872 amrex::Abort("MLCellABecLap PETSc interface only supports MultiFab");
873 } else {
874 const BoxArray& ba = this->m_grids[0].back();
875 const DistributionMapping& dm = this->m_dmap[0].back();
876 const Geometry& geom = this->m_geom[0].back();
877 const auto& factory = *(this->m_factory[0].back());
878 MPI_Comm comm = this->BottomCommunicator();
879
880 auto petsc_solver = makePetsc(ba, dm, geom, comm);
881
882 petsc_solver->setScalars(getAScalar(), getBScalar());
883
884 const int mglev = this->NMGLevels(0)-1;
885 auto ac = getACoeffs(0, mglev);
886 if (ac)
887 {
888 petsc_solver->setACoeffs(*ac);
889 }
890 else
891 {
892 MultiFab alpha(ba,dm,1,0,MFInfo().SetArena(The_Async_Arena()),factory);
893 alpha.setVal(0.0);
894 petsc_solver->setACoeffs(alpha);
895 }
896
897 auto bc = getBCoeffs(0, mglev);
898 if (bc[0])
899 {
900 petsc_solver->setBCoeffs(bc);
901 }
902 else
903 {
904 auto beta = makeDefaultBCoeffs(mglev);
905 petsc_solver->setBCoeffs(amrex::GetArrOfConstPtrs(beta));
906 }
907 return petsc_solver;
908 }
909 return nullptr;
910}
911#endif
912
913extern template class MLCellABecLapT<MultiFab>;
914#ifdef AMREX_MLMG_HAS_FLOAT
915extern template class MLCellABecLapT<fMultiFab>;
916#endif
917
920
921}
922
923#endif
#define BL_PROFILE(a)
Definition AMReX_BLProfiler.H:593
#define AMREX_ALWAYS_ASSERT(EX)
Definition AMReX_BLassert.H:50
#define AMREX_HOST_DEVICE_PARALLEL_FOR_3D(...)
Definition AMReX_GpuLaunchMacrosC.nolint.H:110
#define AMREX_HOST_DEVICE_FOR_3D(...)
Definition AMReX_GpuLaunchMacrosC.nolint.H:106
#define AMREX_HOST_DEVICE_PARALLEL_FOR_4D(...)
Definition AMReX_GpuLaunchMacrosC.nolint.H:111
#define AMREX_GPU_DEVICE
Definition AMReX_GpuQualifiers.H:18
#define AMREX_GPU_HOST_DEVICE
Definition AMReX_GpuQualifiers.H:20
#define AMREX_D_DECL(a, b, c)
Definition AMReX_SPACE.H:171
Maintain an identifier for boundary condition types.
Definition AMReX_BoundCond.H:25
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
__host__ __device__ bool contains(const IntVectND< dim > &p) const noexcept
Return true if argument is contained within BoxND.
Definition AMReX_Box.H:233
__host__ __device__ bool coarsenable(const IntVectND< dim > &refrat, const IntVectND< dim > &min_width) const noexcept
Return whether this Box is coarsenable.
Definition AMReX_Box.H:802
__host__ __device__ BoxND & coarsen(int ref_ratio) noexcept
Coarsen BoxND by given (positive) refinement ratio. NOTE: if type(dir) = CELL centered: lo <- lo/rati...
Definition AMReX_Box.H:754
Calculates the distribution of FABs to MPI processes.
Definition AMReX_DistributionMapping.H:55
const DistributionMapping & DistributionMap() const noexcept
Return constant reference to associated DistributionMapping.
Definition AMReX_FabArrayBase.H:135
const BoxArray & boxArray() const noexcept
Return a constant reference to the BoxArray that defines the valid region associated with this FabArr...
Definition AMReX_FabArrayBase.H:100
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:677
Abstract factory interface for creating, aliasing, and destroying FAB objects.
Definition AMReX_FabFactory.H:73
Rectangular problem domain geometry.
Definition AMReX_Geometry.H:87
Interface
HYPRE interface modes supported.
Definition AMReX_Hypre.H:70
__host__ static __device__ constexpr IntVectND< dim > TheDimensionVector(int d) noexcept
Definition AMReX_IntVect.H:797
a one-thingy-per-box distributed object
Definition AMReX_LayoutData.H:13
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
Cell-centered operator that exposes ABec Laplacian helpers to derived classes.
Definition AMReX_MLCellABecLap.H:22
void addInhomogNeumannFlux(int amrlev, const Array< MF *, 3 > &grad, MF const &sol, bool mult_bcoef) const final
Add inhomogeneous Neumann/Robin flux contributions into grad from sol (include b when mult_bcoef is t...
Definition AMReX_MLCellABecLap.H:607
MLCellABecLapT(const MLCellABecLapT< MF > &)=delete
void getFluxes(const Vector< MF * > &a_flux, const Vector< MF * > &a_sol) const final
Guard overload that aborts if called (cell-centered flux extraction requires per-direction face array...
Definition AMReX_MLCellABecLap.H:104
Array< MF, 3 > makeDefaultBCoeffs(int mglev) const
Definition AMReX_MLCellABecLap.H:757
LPInfo m_lpinfo_arg
Definition AMReX_MLCellABecLap.H:153
virtual MF const * getACoeffs(int amrlev, int mglev) const =0
Cell-centered a coefficient MultiFab for AMR level amrlev and MG level mglev.
std::unique_ptr< MLAlgMG > makeAlgMG(int mglev) const override
Build the algebraic system of MG level mglev of AMR level 0 for the AlgMG solver. Operators that hypr...
Definition AMReX_MLCellABecLap.H:775
void getFluxes(const Vector< Array< MF *, 3 > > &a_flux, const Vector< MF * > &a_sol, Location a_loc) const final
Fill per-face fluxes using the supplied solution hierarchy.
Definition AMReX_MLCellABecLap.H:350
MLCellABecLapT< MF > & operator=(const MLCellABecLapT< MF > &)=delete
MLCellABecLapT(MLCellABecLapT< MF > &&)=delete
virtual Array< MF const *, 3 > getBCoeffs(int amrlev, int mglev) const =0
Face-centered b coefficients for AMR level amrlev and MG level mglev.
typename MF::value_type RT
Definition AMReX_MLCellABecLap.H:26
void setDirichletNodesToZero(int amrlev, int mglev, MF &mf) const override
Zero out Dirichlet nodes on (amrlev,mglev) so that GMRES can treat them as known.
Definition AMReX_MLCellABecLap.H:330
void applyOverset(int amrlev, MF &rhs) const override
Zero RHS entries in rhs that are covered by overset masks on level amrlev.
Definition AMReX_MLCellABecLap.H:717
virtual RT getBScalar() const =0
Scalar applied to b on the current operator.
iMultiFab const * getOversetMask(int amrlev, int mglev) const
Overset mask for (amrlev,mglev); returns nullptr when not defined.
Definition AMReX_MLCellABecLap.H:71
bool needsUpdate() const override
Does it need update if it's reused?
Definition AMReX_MLCellABecLap.H:75
typename MLLinOpT< MF >::Location Location
Definition AMReX_MLCellABecLap.H:28
typename MF::fab_type FAB
Definition AMReX_MLCellABecLap.H:25
Vector< Vector< std::unique_ptr< iMultiFab > > > m_overset_mask
Definition AMReX_MLCellABecLap.H:151
void define(const Vector< Geometry > &a_geom, const Vector< BoxArray > &a_grids, const Vector< DistributionMapping > &a_dmap, const LPInfo &a_info=LPInfo(), const Vector< FabFactory< FAB > const * > &a_factory={})
Describe the AMR hierarchy when overset masks are not required.
Definition AMReX_MLCellABecLap.H:160
bool supportInhomogNeumannBC() const noexcept override
Definition AMReX_MLCellABecLap.H:155
void define(const Vector< Geometry > &a_geom, const Vector< BoxArray > &a_grids, const Vector< DistributionMapping > &a_dmap, const Vector< iMultiFab const * > &a_overset_mask, const LPInfo &a_info=LPInfo(), const Vector< FabFactory< FAB > const * > &a_factory={})
Describe the AMR hierarchy when overset masks participate.
Definition AMReX_MLCellABecLap.H:176
void prepareForSolve() override
Standard hook called before MLMG iterates (fixes BC data, etc.).
Definition AMReX_MLCellABecLap.H:323
~MLCellABecLapT() override=default
bool supportsAlgMG() const override
True if makeAlgMG is implemented for this operator.
Definition AMReX_MLCellABecLap.H:134
virtual RT getAScalar() const =0
Scalar applied to a on the current operator.
void applyInhomogNeumannTerm(int amrlev, MF &rhs) const final
Apply stored Neumann data to the RHS rhs on AMR level amrlev.
Definition AMReX_MLCellABecLap.H:383
void update() override
Average coefficients/metrics when marked dirty.
Definition AMReX_MLCellABecLap.H:316
virtual MF const * getEBBCoeffs(int, int) const
EB Dirichlet b coefficient for the matrix assembly (nullptr without EB).
Definition AMReX_MLCellABecLap.H:131
Vector< std::unique_ptr< MLMGBndryT< MF > > > m_bndry_sol
Definition AMReX_MLCellLinOp.H:456
void update() override
Update for reuse.
Definition AMReX_MLCellLinOp.H:994
void prepareForSolve() override
Prepare multilevel metadata before MLMG iterates (coefficients, BC caches, etc.).
Definition AMReX_MLCellLinOp.H:2007
void unapplyMetricTerm(int amrlev, int mglev, MF &rhs) const final
Remove metric scaling previously applied to the RHS.
Definition AMReX_MLCellLinOp.H:1892
void applyMetricTerm(int amrlev, int mglev, MF &rhs) const final
Multiply the RHS by metric terms appropriate for curvilinear coordinates.
Definition AMReX_MLCellLinOp.H:1836
Vector< Vector< std::unique_ptr< BndryCondLoc > > > m_bcondloc
Definition AMReX_MLCellLinOp.H:506
Vector< std::unique_ptr< MF > > m_robin_bcval
Definition AMReX_MLCellLinOp.H:430
void define(const Vector< Geometry > &a_geom, const Vector< BoxArray > &a_grids, const Vector< DistributionMapping > &a_dmap, const LPInfo &a_info=LPInfo(), const Vector< FabFactory< FAB > const * > &a_factory={})
Bind the operator to an AMR hierarchy.
Definition AMReX_MLCellLinOp.H:668
MLCellLinOpT()
Definition AMReX_MLCellLinOp.H:661
void compFlux(int amrlev, const Array< MF *, 3 > &fluxes, MF &sol, Location loc) const override
Compute face-centered fluxes from the supplied solution.
Definition AMReX_MLCellLinOp.H:1741
bool m_has_metric_term
Definition AMReX_MLCellLinOp.H:454
bool needsUpdate() const override
Does it need update if it's reused?
Definition AMReX_MLCellLinOp.H:93
Vector< Vector< Array< MultiMask, 2 *3 > > > m_maskvals
Definition AMReX_MLCellLinOp.H:512
Vector< Vector< std::unique_ptr< FabFactory< FAB > > > > m_factory
Definition AMReX_MLLinOp.H:1010
int NAMRLevels() const noexcept
Return the number of AMR levels.
Definition AMReX_MLLinOp.H:951
bool hasRobinBC() const noexcept
Definition AMReX_MLLinOp.H:2061
Vector< Vector< BoxArray > > m_grids
Definition AMReX_MLLinOp.H:1008
static constexpr int mg_coarsen_ratio
Definition AMReX_MLLinOp.H:974
int getMaxOrder() const noexcept
Get order of interpolation at coarse/fine boundary.
Definition AMReX_MLLinOp.H:346
virtual int getNComp() const
Return number of components.
Definition AMReX_MLLinOp.H:385
Vector< int > m_num_mg_levels
Definition AMReX_MLLinOp.H:995
Vector< Vector< DistributionMapping > > m_dmap
Definition AMReX_MLLinOp.H:1009
Vector< Array< BCType, 3 > > m_hibc_orig
Definition AMReX_MLLinOp.H:970
Vector< Array< BCType, 3 > > m_lobc_orig
Definition AMReX_MLLinOp.H:969
bool m_precond_mode
Definition AMReX_MLLinOp.H:1042
bool hasHiddenDimension() const noexcept
Definition AMReX_MLLinOp.H:1293
Vector< Vector< Geometry > > m_geom
first Vector is for amr level and second is mg level
Definition AMReX_MLLinOp.H:1007
LinOpEnumType::Location Location
Definition AMReX_MLLinOp.H:174
bool hasInhomogNeumannBC() const noexcept
Definition AMReX_MLLinOp.H:2054
int m_num_amr_levels
Definition AMReX_MLLinOp.H:992
A collection (stored as an array) of FArrayBox objects.
Definition AMReX_MultiFab.H:40
An Iterator over the Orientation of Faces of a Box.
Definition AMReX_Orientation.H:135
__host__ __device__ bool isValid() const noexcept
Is the iterator valid?
Definition AMReX_Orientation.H:156
Encapsulation of the Orientation of the Faces of a Box.
Definition AMReX_Orientation.H:29
__host__ __device__ bool isLow() const noexcept
Returns true if Orientation is low.
Definition AMReX_Orientation.H:89
__host__ __device__ int coordDir() const noexcept
Returns the coordinate direction.
Definition AMReX_Orientation.H:83
@ low
Definition AMReX_Orientation.H:34
@ high
Definition AMReX_Orientation.H:34
Definition AMReX_Reduce.H:556
Type value()
Definition AMReX_Reduce.H:591
Definition AMReX_Reduce.H:715
void eval(MF const &mf, IntVect const &nghost, D &reduce_data, F &&f)
Definition AMReX_Reduce.H:855
This class is a thin wrapper around std::vector. Unlike vector, Vector::operator[] provides bound che...
Definition AMReX_Vector.H:29
Long size() const noexcept
Definition AMReX_Vector.H:54
A Collection of IArrayBoxes.
Definition AMReX_iMultiFab.H:34
static void Copy(iMultiFab &dst, const iMultiFab &src, int srccomp, int dstcomp, int numcomp, int nghost)
Copy from src to dst including nghost ghost cells. The two iMultiFabs MUST have the same underlying B...
Definition AMReX_iMultiFab.cpp:51
amrex_real Real
Floating Point Type for Fields.
Definition AMReX_REAL.H:80
ArrayND< T, 4, true > Array4
Convenient alias for a 4D ArrayND with three spatial dimensions plus a component dimension.
Definition AMReX_Array4.H:1352
__host__ __device__ BoxND< dim > adjCellHi(const BoxND< dim > &b, int dir, int len=1) noexcept
Return the BoxND of length len adjacent to b on the high end along coordinate direction dir.
Definition AMReX_Box.H:1850
__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:1632
__host__ __device__ BoxND< dim > adjCellLo(const BoxND< dim > &b, int dir, int len=1) noexcept
Return the BoxND of length len adjacent to b on the low end along coordinate direction dir.
Definition AMReX_Box.H:1819
__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:1471
__host__ __device__ BoxND< dim > adjCell(const BoxND< dim > &b, Orientation face, int len=1) noexcept
Similar to adjCellLo and adjCellHi except that it operates on the given face of BoxND b.
Definition AMReX_Box.H:1882
__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:1512
std::array< T, N > Array
Definition AMReX_Array.H:31
Arena * The_Async_Arena()
Definition AMReX_Arena.cpp:849
void Min(KeyValuePair< K, V > &vi, MPI_Comm comm)
Definition AMReX_ParallelReduce.H:161
MLCellABecLapT< MultiFab > MLCellABecLap
Definition AMReX_MLCellABecLap.H:919
void streamSynchronize() noexcept
Definition AMReX_GpuDevice.H:329
bool inLaunchRegion() noexcept
Definition AMReX_GpuControl.H:88
bool notInLaunchRegion() noexcept
Definition AMReX_GpuControl.H:89
bool inNoSyncRegion() noexcept
Definition AMReX_GpuControl.H:148
MPI_Comm CommunicatorSub() noexcept
sub-communicator for current frame
Definition AMReX_ParallelContext.H:70
int MPI_Comm
Definition AMReX_ccse-mpi.H:51
Definition AMReX_Amr.cpp:50
__host__ __device__ void ignore_unused(const Ts &...)
No-op helper that marks variables as intentionally unused.
Definition AMReX.H:273
std::array< T const *, 3 > GetArrOfConstPtrs(const std::array< T, 3 > &a) noexcept
Create an array of const-qualified pointers from an array of objects.
Definition AMReX_Array.H:1079
void ParallelFor(TypeList< CTOs... > ctos, std::array< int, sizeof...(CTOs)> const &runtime_options, T N, F &&f)
Definition AMReX_CTOParallelForImpl.H:202
BoxND< 3 > Box
Box is an alias for amrex::BoxND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:35
bool isMFIterSafe(const FabArrayBase &x, const FabArrayBase &y)
Definition AMReX_MFIter.H:256
@ Robin
Definition AMReX_LO_BCTYPES.H:36
@ inhomogNeumann
Definition AMReX_LO_BCTYPES.H:35
std::unique_ptr< Hypre > makeHypre(const BoxArray &grids, const DistributionMapping &dmap, const Geometry &geom, MPI_Comm comm_, Hypre::Interface interface, const iMultiFab *overset_mask)
Factory that instantiates the requested HYPRE interface.
Definition AMReX_Hypre.cpp:12
bool TilingIfNotGPU() noexcept
Definition AMReX_MFIter.H:12
std::unique_ptr< PETScABecLap > makePetsc(const BoxArray &grids, const DistributionMapping &dmap, const Geometry &geom, MPI_Comm comm_)
Factory helper that instantiates a PETSc ABec Laplacian on one level.
Definition AMReX_PETSc.cpp:67
IntVectND< 3 > IntVect
IntVect is an alias for amrex::IntVectND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:38
void Abort(const std::string &msg)
Print a fatal-error message to stderr and abort execution.
Definition AMReX.cpp:239
__host__ __device__ constexpr int get(IntVectND< dim > const &iv) noexcept
Get the Idx-th element of IntVectND<dim>.
Definition AMReX_IntVect.H:1367
A simple struct holding 3 int values for a 3D index.
Definition AMReX_Dim3.H:24
int x
Definition AMReX_Dim3.H:24
int z
Definition AMReX_Dim3.H:24
int y
Definition AMReX_Dim3.H:24
Configuration knobs for multilevel linear operators (grid agglomeration, metrics, etc....
Definition AMReX_MLLinOp.H:54
bool do_semicoarsening
Definition AMReX_MLLinOp.H:57
int max_coarsening_level
Definition AMReX_MLLinOp.H:63
FabArray memory allocation information.
Definition AMReX_FabArray.H:73
Definition AMReX_MFIter.H:20
MFItInfo & SetDynamic(bool f) noexcept
Definition AMReX_MFIter.H:43