Block-Structured AMR Software Framework
Loading...
Searching...
No Matches
AMReX_MLPoisson.H
Go to the documentation of this file.
1#ifndef AMREX_MLPOISSON_H_
2#define AMREX_MLPOISSON_H_
3#include <AMReX_Config.H>
4
5#include <AMReX_iMultiFab.H>
7#include <AMReX_MLPoisson_K.H>
9#include <AMReX_MultiFab.H>
10
11namespace amrex {
12
18
19// del dot grad phi
20
29template <typename MF>
31 : public MLCellABecLapT<MF>
32{
33public:
34
35 using FAB = typename MF::fab_type;
36 using RT = typename MF::value_type;
37
40
42 MLPoissonT () = default;
53 const Vector<BoxArray>& a_grids,
54 const Vector<DistributionMapping>& a_dmap,
55 const LPInfo& a_info = LPInfo(),
56 const Vector<FabFactory<FAB> const*>& a_factory = {});
61 const Vector<BoxArray>& a_grids,
62 const Vector<DistributionMapping>& a_dmap,
63 const Vector<iMultiFab const*>& a_overset_mask, // 1: unknown, 0: known
64 const LPInfo& a_info = LPInfo(),
65 const Vector<FabFactory<FAB> const*>& a_factory = {});
66 ~MLPoissonT () override;
67
68 MLPoissonT (const MLPoissonT<MF>&) = delete;
72
82 void define (const Vector<Geometry>& a_geom,
83 const Vector<BoxArray>& a_grids,
84 const Vector<DistributionMapping>& a_dmap,
85 const LPInfo& a_info = LPInfo(),
86 const Vector<FabFactory<FAB> const*>& a_factory = {});
87
98 void define (const Vector<Geometry>& a_geom,
99 const Vector<BoxArray>& a_grids,
100 const Vector<DistributionMapping>& a_dmap,
101 const Vector<iMultiFab const*>& a_overset_mask,
102 const LPInfo& a_info = LPInfo(),
103 const Vector<FabFactory<FAB> const*>& a_factory = {});
104
106 void prepareForSolve () final;
107
108 [[nodiscard]] bool supportsMixedPrecision () const override {
109 return typeid(*this) == typeid(MLPoissonT<MF>);
110 }
111
112 [[nodiscard]] bool isSingular (int amrlev) const final { return m_is_singular[amrlev]; }
114 [[nodiscard]] bool isBottomSingular () const final { return m_is_singular[0]; }
116 void Fapply (int amrlev, int mglev, MF& out, const MF& in) const final;
118 void Fsmooth (int amrlev, int mglev, MF& sol, const MF& rhs, int redblack) const final;
123 void FFlux (int amrlev, const MFIter& mfi,
124 const Array<FAB*,AMREX_SPACEDIM>& flux,
125 const FAB& sol, Location loc, int face_only=0) const final;
126
128 void normalize (int amrlev, int mglev, MF& mf) const final;
129
131 [[nodiscard]] RT getAScalar () const final { return RT(0.0); }
133 [[nodiscard]] RT getBScalar () const final { return RT(-1.0); }
135 [[nodiscard]] MF const* getACoeffs (int /*amrlev*/, int /*mglev*/) const final { return nullptr; }
137 [[nodiscard]] Array<MF const*,AMREX_SPACEDIM> getBCoeffs (int /*amrlev*/, int /*mglev*/) const final
138 { return {{ AMREX_D_DECL(nullptr,nullptr,nullptr)}}; }
139
141 [[nodiscard]] std::unique_ptr<MLLinOpT<MF>> makeNLinOp (int grid_size) const final;
142
144 [[nodiscard]] bool supportNSolve () const final;
145
147 void copyNSolveSolution (MF& dst, MF const& src) const final;
148
155 void get_dpdn_on_domain_faces (Array<MF*,AMREX_SPACEDIM> const& dpdn,
156 MF const& phi);
157
158private:
159
160 Vector<int> m_is_singular;
161};
162
163template <typename MF>
165 const Vector<BoxArray>& a_grids,
166 const Vector<DistributionMapping>& a_dmap,
167 const LPInfo& a_info,
168 const Vector<FabFactory<FAB> const*>& a_factory)
169{
170 define(a_geom, a_grids, a_dmap, a_info, a_factory);
171}
172
173template <typename MF>
175 const Vector<BoxArray>& a_grids,
176 const Vector<DistributionMapping>& a_dmap,
177 const Vector<iMultiFab const*>& a_overset_mask,
178 const LPInfo& a_info,
179 const Vector<FabFactory<FAB> const*>& a_factory)
180{
181 define(a_geom, a_grids, a_dmap, a_overset_mask, a_info, a_factory);
182}
183
184template <typename MF>
185void
187 const Vector<BoxArray>& a_grids,
188 const Vector<DistributionMapping>& a_dmap,
189 const LPInfo& a_info,
190 const Vector<FabFactory<FAB> const*>& a_factory)
191{
192 BL_PROFILE("MLPoisson::define()");
193 MLCellABecLapT<MF>::define(a_geom, a_grids, a_dmap, this->dpInfo(a_info), a_factory);
194 this->makeSPLinOp(a_info, [&] (auto const& sp_info) {
195 return std::make_unique<MLPoissonT<fMultiFab>>(this->spGeom(a_geom), a_grids, a_dmap, sp_info);
196 });
197}
198
199template <typename MF>
200void
202 const Vector<BoxArray>& a_grids,
203 const Vector<DistributionMapping>& a_dmap,
204 const Vector<iMultiFab const*>& a_overset_mask,
205 const LPInfo& a_info,
206 const Vector<FabFactory<FAB> const*>& a_factory)
207{
208 BL_PROFILE("MLPoisson::define(overset)");
209 MLCellABecLapT<MF>::define(a_geom, a_grids, a_dmap, a_overset_mask, this->dpInfo(a_info), a_factory);
211 "MLPoisson: overset mask does not support metric terms. Use MLABecLaplacian or LPInfo::setMetricTerm(false).");
212 this->makeSPLinOp(a_info, [&] (auto const& sp_info) {
213 return std::make_unique<MLPoissonT<fMultiFab>>(this->spGeom(a_geom), a_grids, a_dmap, a_overset_mask, sp_info);
214 });
215}
216
217template <typename MF>
218MLPoissonT<MF>::~MLPoissonT () = default;
219
220template <typename MF>
221void
223{
224 BL_PROFILE("MLPoisson::prepareForSolve()");
225
227
228 m_is_singular.clear();
229 m_is_singular.resize(this->m_num_amr_levels, false);
230 auto itlo = std::ranges::find(this->m_lobc[0], BCType::Dirichlet);
231 auto ithi = std::ranges::find(this->m_hibc[0], BCType::Dirichlet);
232 if (itlo == this->m_lobc[0].end() && ithi == this->m_hibc[0].end())
233 { // No Dirichlet
234 for (int alev = 0; alev < this->m_num_amr_levels; ++alev)
235 {
236 // For now this assumes that overset regions are treated as Dirichlet bc's
237 if (this->m_domain_covered[alev] && !this->m_overset_mask[alev][0])
238 {
239 m_is_singular[alev] = true;
240 }
241 }
242 }
243 if (!m_is_singular[0] && this->m_needs_coarse_data_for_bc &&
245 {
246 AMREX_ASSERT(this->m_overset_mask[0][0] == nullptr);
247 auto bbox = this->m_grids[0][0].minimalBox();
248 for (int idim = 0; idim < AMREX_SPACEDIM; ++idim) {
249 if (this->m_lobc[0][idim] == LinOpBCType::Dirichlet) {
250 bbox.growLo(idim,1);
251 }
252 if (this->m_hibc[0][idim] == LinOpBCType::Dirichlet) {
253 bbox.growHi(idim,1);
254 }
255 }
256 if (this->m_geom[0][0].Domain().contains(bbox)) {
257 m_is_singular[0] = true;
258 }
259 }
260}
261
262template <typename MF>
263void
264MLPoissonT<MF>::Fapply (int amrlev, int mglev, MF& out, const MF& in) const
265{
266 BL_PROFILE("MLPoisson::Fapply()");
267
268 const Real* dxinv = this->m_geom[amrlev][mglev].InvCellSize();
269
270 AMREX_D_TERM(const RT dhx = RT(dxinv[0]*dxinv[0]);,
271 const RT dhy = RT(dxinv[1]*dxinv[1]);,
272 const RT dhz = RT(dxinv[2]*dxinv[2]););
273
274#if (AMREX_SPACEDIM == 3)
275 RT dh0 = this->get_d0(dhx, dhy, dhz);
276 RT dh1 = this->get_d1(dhx, dhy, dhz);
277#endif
278
279#if (AMREX_SPACEDIM < 3)
280 const RT dx = RT(this->m_geom[amrlev][mglev].CellSize(0));
281 const RT probxlo = RT(this->m_geom[amrlev][mglev].ProbLo(0));
282#endif
283
284#ifdef AMREX_USE_GPU
285 if (Gpu::inLaunchRegion() && out.isFusingCandidate() && !this->hasHiddenDimension()) {
286 auto const& xma = in.const_arrays();
287 auto const& yma = out.arrays();
288 if (this->m_overset_mask[amrlev][mglev]) {
290 const auto& osmma = this->m_overset_mask[amrlev][mglev]->const_arrays();
291 ParallelFor(out,
292 [=] AMREX_GPU_DEVICE (int box_no, int i, int j, int k) noexcept
293 {
295 mlpoisson_adotx_os(AMREX_D_DECL(i,j,k), yma[box_no], xma[box_no], osmma[box_no],
296 AMREX_D_DECL(dhx,dhy,dhz));
297 });
298 } else {
299#if (AMREX_SPACEDIM < 3)
300 if (this->m_has_metric_term) {
301 ParallelFor(out,
302 [=] AMREX_GPU_DEVICE (int box_no, int i, int j, int k) noexcept
303 {
305 mlpoisson_adotx_m(AMREX_D_DECL(i,j,k), yma[box_no], xma[box_no],
306 AMREX_D_DECL(dhx,dhy,dhz), dx, probxlo);
307 });
308 } else
309#endif
310 {
311 ParallelFor(out,
312 [=] AMREX_GPU_DEVICE (int box_no, int i, int j, int k) noexcept
313 {
315 mlpoisson_adotx(AMREX_D_DECL(i,j,k), yma[box_no], xma[box_no],
316 AMREX_D_DECL(dhx,dhy,dhz));
317 });
318 }
319 }
320 if (!Gpu::inNoSyncRegion()) {
322 }
323 } else
324#endif
325 {
326#ifdef AMREX_USE_OMP
327#pragma omp parallel if (Gpu::notInLaunchRegion())
328#endif
329 for (MFIter mfi(out, TilingIfNotGPU()); mfi.isValid(); ++mfi)
330 {
331 const Box& bx = mfi.tilebox();
332 const auto& xfab = in.array(mfi);
333 const auto& yfab = out.array(mfi);
334
335 if (this->m_overset_mask[amrlev][mglev]) {
337 const auto& osm = this->m_overset_mask[amrlev][mglev]->const_array(mfi);
339 {
341 mlpoisson_adotx_os(AMREX_D_DECL(i,j,k), yfab, xfab, osm,
342 AMREX_D_DECL(dhx,dhy,dhz));
343 });
344 } else {
345#if (AMREX_SPACEDIM == 3)
346 if (this->hasHiddenDimension()) {
347 Box const& bx2d = this->compactify(bx);
348 const auto& xfab2d = this->compactify(xfab);
349 const auto& yfab2d = this->compactify(yfab);
351 {
353 TwoD::mlpoisson_adotx(i, j, yfab2d, xfab2d, dh0, dh1);
354 });
355 } else {
357 {
358 mlpoisson_adotx(i, j, k, yfab, xfab, dhx, dhy, dhz);
359 });
360 }
361#elif (AMREX_SPACEDIM == 2)
362 if (this->m_has_metric_term) {
364 {
366 mlpoisson_adotx_m(i, j, yfab, xfab, dhx, dhy, dx, probxlo);
367 });
368 } else {
370 {
372 mlpoisson_adotx(i, j, yfab, xfab, dhx, dhy);
373 });
374 }
375#elif (AMREX_SPACEDIM == 1)
376 if (this->m_has_metric_term) {
378 {
380 mlpoisson_adotx_m(i, yfab, xfab, dhx, dx, probxlo);
381 });
382 } else {
384 {
386 mlpoisson_adotx(i, yfab, xfab, dhx);
387 });
388 }
389#endif
390 }
391 }
392 }
393}
394
395template <typename MF>
396void
397MLPoissonT<MF>::normalize (int amrlev, int mglev, MF& mf) const
398{
399 amrex::ignore_unused(amrlev,mglev,mf);
400#if (AMREX_SPACEDIM != 3)
401 BL_PROFILE("MLPoisson::normalize()");
402
403 if (!this->m_has_metric_term) { return; }
404
405 const Real* dxinv = this->m_geom[amrlev][mglev].InvCellSize();
406 AMREX_D_TERM(const RT dhx = RT(dxinv[0]*dxinv[0]);,
407 const RT dhy = RT(dxinv[1]*dxinv[1]);,
408 const RT dhz = RT(dxinv[2]*dxinv[2]););
409 const RT dx = RT(this->m_geom[amrlev][mglev].CellSize(0));
410 const RT probxlo = RT(this->m_geom[amrlev][mglev].ProbLo(0));
411
412#ifdef AMREX_USE_GPU
413 if (Gpu::inLaunchRegion() && mf.isFusingCandidate()) {
414 auto const& ma = mf.arrays();
415 ParallelFor(mf,
416 [=] AMREX_GPU_DEVICE (int box_no, int i, int j, int k) noexcept
417 {
418 mlpoisson_normalize(i,j,k, ma[box_no], AMREX_D_DECL(dhx,dhy,dhz), dx, probxlo);
419 });
420 if (!Gpu::inNoSyncRegion()) {
422 }
423 } else
424#endif
425 {
426#ifdef AMREX_USE_OMP
427#pragma omp parallel if (Gpu::notInLaunchRegion())
428#endif
429 for (MFIter mfi(mf, TilingIfNotGPU()); mfi.isValid(); ++mfi)
430 {
431 const Box& bx = mfi.tilebox();
432 const auto& fab = mf.array(mfi);
433
434#if (AMREX_SPACEDIM == 2)
436 {
437 mlpoisson_normalize(i,j,k, fab, dhx, dhy, dx, probxlo);
438 });
439#else
441 {
442 mlpoisson_normalize(i,j,k, fab, dhx, dx, probxlo);
443 });
444#endif
445 }
446 }
447#endif
448}
449
450template <typename MF>
451void
452MLPoissonT<MF>::Fsmooth (int amrlev, int mglev, MF& sol, const MF& rhs, int redblack) const
453{
454 BL_PROFILE("MLPoisson::Fsmooth()");
455
456 MF Ax;
457 if (! this->m_use_gauss_seidel) { // jacobi
458 Ax.define(sol.boxArray(), sol.DistributionMap(), sol.nComp(), 0,
459 MFInfo().SetArena(The_Async_Arena()));
460 Fapply(amrlev, mglev, Ax, sol);
461 }
462
463 const auto& undrrelxr = this->m_undrrelxr[amrlev][mglev];
464 const auto& maskvals = this->m_maskvals [amrlev][mglev];
465
466 OrientationIter oitr;
467
468 const auto& f0 = undrrelxr[oitr()]; ++oitr;
469 const auto& f1 = undrrelxr[oitr()]; ++oitr;
470#if (AMREX_SPACEDIM > 1)
471 const auto& f2 = undrrelxr[oitr()]; ++oitr;
472 const auto& f3 = undrrelxr[oitr()]; ++oitr;
473#if (AMREX_SPACEDIM > 2)
474 const auto& f4 = undrrelxr[oitr()]; ++oitr;
475 const auto& f5 = undrrelxr[oitr()]; ++oitr;
476#endif
477#endif
478
479 const MultiMask& mm0 = maskvals[0];
480 const MultiMask& mm1 = maskvals[1];
481#if (AMREX_SPACEDIM > 1)
482 const MultiMask& mm2 = maskvals[2];
483 const MultiMask& mm3 = maskvals[3];
484#if (AMREX_SPACEDIM > 2)
485 const MultiMask& mm4 = maskvals[4];
486 const MultiMask& mm5 = maskvals[5];
487#endif
488#endif
489
490 const Real* dxinv = this->m_geom[amrlev][mglev].InvCellSize();
491 AMREX_D_TERM(const RT dhx = RT(dxinv[0]*dxinv[0]);,
492 const RT dhy = RT(dxinv[1]*dxinv[1]);,
493 const RT dhz = RT(dxinv[2]*dxinv[2]););
494
495#if (AMREX_SPACEDIM == 3)
496 RT dh0 = RT(this->get_d0(dhx, dhy, dhz));
497 RT dh1 = RT(this->get_d1(dhx, dhy, dhz));
498#endif
499
500#if (AMREX_SPACEDIM < 3)
501 const RT dx = RT(this->m_geom[amrlev][mglev].CellSize(0));
502 const RT probxlo = RT(this->m_geom[amrlev][mglev].ProbLo(0));
503#endif
504
505 MFItInfo mfi_info;
506 if (Gpu::notInLaunchRegion()) { mfi_info.EnableTiling().SetDynamic(true); }
507
508#ifdef AMREX_USE_GPU
509 // Gauss-Seidel uses a fused launch over the cells of one color.
511 && (this->m_use_gauss_seidel || sol.isFusingCandidate())
512 && ! this->hasHiddenDimension())
513 {
514 const auto& m0ma = mm0.const_arrays();
515 const auto& m1ma = mm1.const_arrays();
516#if (AMREX_SPACEDIM > 1)
517 const auto& m2ma = mm2.const_arrays();
518 const auto& m3ma = mm3.const_arrays();
519#if (AMREX_SPACEDIM > 2)
520 const auto& m4ma = mm4.const_arrays();
521 const auto& m5ma = mm5.const_arrays();
522#endif
523#endif
524
525 const auto& solnma = sol.arrays();
526 const auto& rhsma = rhs.const_arrays();
527 const IntVect rhs_ng = rhs.nGrowVect();
528
529 const auto& f0ma = f0.const_arrays();
530 const auto& f1ma = f1.const_arrays();
531#if (AMREX_SPACEDIM > 1)
532 const auto& f2ma = f2.const_arrays();
533 const auto& f3ma = f3.const_arrays();
534#if (AMREX_SPACEDIM > 2)
535 const auto& f4ma = f4.const_arrays();
536 const auto& f5ma = f5.const_arrays();
537#endif
538#endif
539
540 if (this->m_overset_mask[amrlev][mglev]) {
542 const auto& osmma = this->m_overset_mask[amrlev][mglev]->const_arrays();
543 if (this->m_use_gauss_seidel) {
544 ParallelForRedBlack(sol, redblack,
545 [=] AMREX_GPU_DEVICE (int box_no, int i, int j, int k) noexcept
546 {
547 Box vbx = amrex::grow(Box(rhsma[box_no]), -rhs_ng);
548 mlpoisson_gsrb_os(i, j, k, solnma[box_no], rhsma[box_no],
549 osmma[box_no], AMREX_D_DECL(dhx, dhy, dhz),
550 f0ma[box_no], m0ma[box_no],
551 f1ma[box_no], m1ma[box_no],
552#if (AMREX_SPACEDIM > 1)
553 f2ma[box_no], m2ma[box_no],
554 f3ma[box_no], m3ma[box_no],
555#if (AMREX_SPACEDIM > 2)
556 f4ma[box_no], m4ma[box_no],
557 f5ma[box_no], m5ma[box_no],
558#endif
559#endif
560 vbx, redblack);
561 });
562 } else {
563 const auto& axma = Ax.const_arrays();
564 ParallelFor(sol,
565 [=] AMREX_GPU_DEVICE (int box_no, int i, int j, int k) noexcept
566 {
567 Box vbx = amrex::grow(Box(rhsma[box_no]), -rhs_ng);
568 mlpoisson_jacobi_os(i, j, k, solnma[box_no], rhsma[box_no],
569 axma[box_no], osmma[box_no],
570 AMREX_D_DECL(dhx, dhy, dhz),
571 f0ma[box_no], m0ma[box_no],
572 f1ma[box_no], m1ma[box_no],
573#if (AMREX_SPACEDIM > 1)
574 f2ma[box_no], m2ma[box_no],
575 f3ma[box_no], m3ma[box_no],
576#if (AMREX_SPACEDIM > 2)
577 f4ma[box_no], m4ma[box_no],
578 f5ma[box_no], m5ma[box_no],
579#endif
580#endif
581 vbx);
582 });
583 }
584 }
585#if (AMREX_SPACEDIM < 3)
586 else if (this->m_has_metric_term) {
587 if (this->m_use_gauss_seidel) {
588 ParallelForRedBlack(sol, redblack,
589 [=] AMREX_GPU_DEVICE (int box_no, int i, int j, int k) noexcept
590 {
591 Box vbx = amrex::grow(Box(rhsma[box_no]), -rhs_ng);
592 mlpoisson_gsrb_m(i, j, k, solnma[box_no], rhsma[box_no],
593 AMREX_D_DECL(dhx, dhy, dhz),
594 f0ma[box_no], m0ma[box_no],
595 f1ma[box_no], m1ma[box_no],
596#if (AMREX_SPACEDIM > 1)
597 f2ma[box_no], m2ma[box_no],
598 f3ma[box_no], m3ma[box_no],
599#endif
600 vbx, redblack,
601 dx, probxlo);
602 });
603 } else {
604 const auto& axma = Ax.const_arrays();
605 ParallelFor(sol,
606 [=] AMREX_GPU_DEVICE (int box_no, int i, int j, int k) noexcept
607 {
608 Box vbx = amrex::grow(Box(rhsma[box_no]), -rhs_ng);
609 mlpoisson_jacobi_m(i, j, k, solnma[box_no], rhsma[box_no],
610 axma[box_no], AMREX_D_DECL(dhx, dhy, dhz),
611 f0ma[box_no], m0ma[box_no],
612 f1ma[box_no], m1ma[box_no],
613#if (AMREX_SPACEDIM > 1)
614 f2ma[box_no], m2ma[box_no],
615 f3ma[box_no], m3ma[box_no],
616#endif
617 vbx, dx, probxlo);
618 });
619 }
620 }
621#endif
622 else {
623 if (this->m_use_gauss_seidel) {
624 ParallelForRedBlack(sol, redblack,
625 [=] AMREX_GPU_DEVICE (int box_no, int i, int j, int k) noexcept
626 {
627 Box vbx = amrex::grow(Box(rhsma[box_no]), -rhs_ng);
628 mlpoisson_gsrb(i, j, k, solnma[box_no], rhsma[box_no],
629 AMREX_D_DECL(dhx, dhy, dhz),
630 f0ma[box_no], m0ma[box_no],
631 f1ma[box_no], m1ma[box_no],
632#if (AMREX_SPACEDIM > 1)
633 f2ma[box_no], m2ma[box_no],
634 f3ma[box_no], m3ma[box_no],
635#if (AMREX_SPACEDIM > 2)
636 f4ma[box_no], m4ma[box_no],
637 f5ma[box_no], m5ma[box_no],
638#endif
639#endif
640 vbx, redblack);
641 });
642 } else {
643 const auto& axma = Ax.const_arrays();
644 ParallelFor(sol,
645 [=] AMREX_GPU_DEVICE (int box_no, int i, int j, int k) noexcept
646 {
647 Box vbx = amrex::grow(Box(rhsma[box_no]), -rhs_ng);
648 mlpoisson_jacobi(i, j, k, solnma[box_no], rhsma[box_no],
649 axma[box_no], AMREX_D_DECL(dhx, dhy, dhz),
650 f0ma[box_no], m0ma[box_no],
651 f1ma[box_no], m1ma[box_no],
652#if (AMREX_SPACEDIM > 1)
653 f2ma[box_no], m2ma[box_no],
654 f3ma[box_no], m3ma[box_no],
655#if (AMREX_SPACEDIM > 2)
656 f4ma[box_no], m4ma[box_no],
657 f5ma[box_no], m5ma[box_no],
658#endif
659#endif
660 vbx);
661 });
662 }
663 }
664 if (!Gpu::inNoSyncRegion()) {
666 }
667 } else
668#endif
669 {
670#ifdef AMREX_USE_OMP
671#pragma omp parallel if (Gpu::notInLaunchRegion())
672#endif
673 for (MFIter mfi(sol,mfi_info); mfi.isValid(); ++mfi)
674 {
675 const auto& m0 = mm0.array(mfi);
676 const auto& m1 = mm1.array(mfi);
677#if (AMREX_SPACEDIM > 1)
678 const auto& m2 = mm2.array(mfi);
679 const auto& m3 = mm3.array(mfi);
680#if (AMREX_SPACEDIM > 2)
681 const auto& m4 = mm4.array(mfi);
682 const auto& m5 = mm5.array(mfi);
683#endif
684#endif
685
686 const Box& tbx = mfi.tilebox();
687 const Box& vbx = mfi.validbox();
688 const auto& solnfab = sol.array(mfi);
689 const auto& rhsfab = rhs.array(mfi);
690
691 const auto& f0fab = f0.array(mfi);
692 const auto& f1fab = f1.array(mfi);
693#if (AMREX_SPACEDIM > 1)
694 const auto& f2fab = f2.array(mfi);
695 const auto& f3fab = f3.array(mfi);
696#if (AMREX_SPACEDIM > 2)
697 const auto& f4fab = f4.array(mfi);
698 const auto& f5fab = f5.array(mfi);
699#endif
700#endif
701
702#if (AMREX_SPACEDIM == 1)
703 if (this->m_overset_mask[amrlev][mglev]) {
705 const auto& osm = this->m_overset_mask[amrlev][mglev]->const_array(mfi);
706 if (this->m_use_gauss_seidel) {
708 {
709 mlpoisson_gsrb_os(i, j, k, solnfab, rhsfab, osm, dhx,
710 f0fab, m0,
711 f1fab, m1,
712 vbx, redblack);
713 });
714 } else {
715 const auto& axfab = Ax.const_array(mfi);
717 {
718 mlpoisson_jacobi_os(i, j, k, solnfab, rhsfab, axfab,
719 osm, dhx,
720 f0fab, m0,
721 f1fab, m1,
722 vbx);
723 });
724 }
725 } else if (this->m_has_metric_term) {
726 if (this->m_use_gauss_seidel) {
728 {
729 mlpoisson_gsrb_m(i, j, k, solnfab, rhsfab, dhx,
730 f0fab, m0,
731 f1fab, m1,
732 vbx, redblack,
733 dx, probxlo);
734 });
735 } else {
736 const auto& axfab = Ax.const_array(mfi);
738 {
739 mlpoisson_jacobi_m(i, j, k, solnfab, rhsfab, axfab, dhx,
740 f0fab, m0,
741 f1fab, m1,
742 vbx, dx, probxlo);
743 });
744 }
745 } else {
746 if (this->m_use_gauss_seidel) {
748 {
749 mlpoisson_gsrb(i, j, k, solnfab, rhsfab, dhx,
750 f0fab, m0,
751 f1fab, m1,
752 vbx, redblack);
753 });
754 } else {
755 const auto& axfab = Ax.const_array(mfi);
757 {
758 mlpoisson_jacobi(i, j, k, solnfab, rhsfab, axfab, dhx,
759 f0fab, m0,
760 f1fab, m1,
761 vbx);
762 });
763 }
764 }
765#endif
766
767#if (AMREX_SPACEDIM == 2)
768 if (this->m_overset_mask[amrlev][mglev]) {
770 const auto& osm = this->m_overset_mask[amrlev][mglev]->const_array(mfi);
771 if (this->m_use_gauss_seidel) {
773 {
774 mlpoisson_gsrb_os(i, j, k, solnfab, rhsfab, osm, dhx, dhy,
775 f0fab, m0,
776 f1fab, m1,
777 f2fab, m2,
778 f3fab, m3,
779 vbx, redblack);
780 });
781 } else {
782 const auto& axfab = Ax.const_array(mfi);
784 {
785 mlpoisson_jacobi_os(i, j, k, solnfab, rhsfab, axfab,
786 osm, dhx, dhy,
787 f0fab, m0,
788 f1fab, m1,
789 f2fab, m2,
790 f3fab, m3,
791 vbx);
792 });
793 }
794 } else if (this->m_has_metric_term) {
795 if (this->m_use_gauss_seidel) {
797 {
798 mlpoisson_gsrb_m(i, j, k, solnfab, rhsfab, dhx, dhy,
799 f0fab, m0,
800 f1fab, m1,
801 f2fab, m2,
802 f3fab, m3,
803 vbx, redblack,
804 dx, probxlo);
805 });
806 } else {
807 const auto& axfab = Ax.const_array(mfi);
809 {
810 mlpoisson_jacobi_m(i, j, k, solnfab, rhsfab, axfab, dhx, dhy,
811 f0fab, m0,
812 f1fab, m1,
813 f2fab, m2,
814 f3fab, m3,
815 vbx, dx, probxlo);
816 });
817 }
818 } else {
819 if (this->m_use_gauss_seidel) {
821 {
822 mlpoisson_gsrb(i, j, k, solnfab, rhsfab, dhx, dhy,
823 f0fab, m0,
824 f1fab, m1,
825 f2fab, m2,
826 f3fab, m3,
827 vbx, redblack);
828 });
829 } else {
830 const auto& axfab = Ax.const_array(mfi);
832 {
833 mlpoisson_jacobi(i, j, k, solnfab, rhsfab, axfab, dhx, dhy,
834 f0fab, m0,
835 f1fab, m1,
836 f2fab, m2,
837 f3fab, m3,
838 vbx);
839 });
840 }
841 }
842#endif
843
844#if (AMREX_SPACEDIM == 3)
845 if (this->m_overset_mask[amrlev][mglev]) {
847 const auto& osm = this->m_overset_mask[amrlev][mglev]->const_array(mfi);
848 if (this->m_use_gauss_seidel) {
850 {
851 mlpoisson_gsrb_os(i, j, k, solnfab, rhsfab, osm, dhx, dhy, dhz,
852 f0fab, m0,
853 f1fab, m1,
854 f2fab, m2,
855 f3fab, m3,
856 f4fab, m4,
857 f5fab, m5,
858 vbx, redblack);
859 });
860 } else {
861 const auto& axfab = Ax.const_array(mfi);
863 {
864 mlpoisson_jacobi_os(i, j, k, solnfab, rhsfab, axfab,
865 osm, dhx, dhy, dhz,
866 f0fab, m0,
867 f1fab, m1,
868 f2fab, m2,
869 f3fab, m3,
870 f4fab, m4,
871 f5fab, m5,
872 vbx);
873 });
874 }
875 } else if (this->hasHiddenDimension()) {
876 Box const& tbx_2d = this->compactify(tbx);
877 Box const& vbx_2d = this->compactify(vbx);
878 const auto& solnfab_2d = this->compactify(solnfab);
879 const auto& rhsfab_2d = this->compactify(rhsfab);
880 const auto& f0fab_2d = this->compactify(this->get_d0(f0fab,f1fab,f2fab));
881 const auto& f1fab_2d = this->compactify(this->get_d1(f0fab,f1fab,f2fab));
882 const auto& f2fab_2d = this->compactify(this->get_d0(f3fab,f4fab,f5fab));
883 const auto& f3fab_2d = this->compactify(this->get_d1(f3fab,f4fab,f5fab));
884 const auto& m0_2d = this->compactify(this->get_d0(m0,m1,m2));
885 const auto& m1_2d = this->compactify(this->get_d1(m0,m1,m2));
886 const auto& m2_2d = this->compactify(this->get_d0(m3,m4,m5));
887 const auto& m3_2d = this->compactify(this->get_d1(m3,m4,m5));
888 if (this->m_use_gauss_seidel) {
889 AMREX_HOST_DEVICE_PARALLEL_FOR_3D ( tbx_2d, i, j, k,
890 {
891 TwoD::mlpoisson_gsrb(i, j, k, solnfab_2d, rhsfab_2d, dh0, dh1,
892 f0fab_2d, m0_2d,
893 f1fab_2d, m1_2d,
894 f2fab_2d, m2_2d,
895 f3fab_2d, m3_2d,
896 vbx_2d, redblack);
897 });
898 } else {
899 const auto& axfab = Ax.const_array(mfi);
900 const auto& axfab_2d = this->compactify(axfab);
901 AMREX_HOST_DEVICE_PARALLEL_FOR_3D ( tbx_2d, i, j, k,
902 {
903 TwoD::mlpoisson_jacobi(i, j, k, solnfab_2d, rhsfab_2d,
904 axfab_2d, dh0, dh1,
905 f0fab_2d, m0_2d,
906 f1fab_2d, m1_2d,
907 f2fab_2d, m2_2d,
908 f3fab_2d, m3_2d,
909 vbx_2d);
910 });
911 }
912 } else {
913 if (this->m_use_gauss_seidel) {
915 {
916 mlpoisson_gsrb(i, j, k, solnfab, rhsfab, dhx, dhy, dhz,
917 f0fab, m0,
918 f1fab, m1,
919 f2fab, m2,
920 f3fab, m3,
921 f4fab, m4,
922 f5fab, m5,
923 vbx, redblack);
924 });
925 } else {
926 const auto& axfab = Ax.const_array(mfi);
928 {
929 mlpoisson_jacobi(i, j, k, solnfab, rhsfab, axfab,
930 dhx, dhy, dhz,
931 f0fab, m0,
932 f1fab, m1,
933 f2fab, m2,
934 f3fab, m3,
935 f4fab, m4,
936 f5fab, m5,
937 vbx);
938 });
939 }
940 }
941#endif
942 }
943 }
944}
945
946template <typename MF>
947void
948MLPoissonT<MF>::FFlux (int amrlev, const MFIter& mfi,
949 const Array<FAB*,AMREX_SPACEDIM>& flux,
950 const FAB& sol, Location, const int face_only) const
951{
952 BL_PROFILE("MLPoisson::FFlux()");
953
954 const int mglev = 0;
955 const Box& box = mfi.tilebox();
956 const Real* dxinv = this->m_geom[amrlev][mglev].InvCellSize();
957
958 AMREX_D_TERM(const auto& fxarr = flux[0]->array();,
959 const auto& fyarr = flux[1]->array();,
960 const auto& fzarr = flux[2]->array(););
961 const auto& solarr = sol.array();
962
963#if (AMREX_SPACEDIM != 3)
964 const RT dx = RT(this->m_geom[amrlev][mglev].CellSize(0));
965 const RT probxlo = RT(this->m_geom[amrlev][mglev].ProbLo(0));
966#endif
967
968#if (AMREX_SPACEDIM == 3)
969 if (face_only) {
970 if (this->hiddenDirection() != 0) {
971 RT fac = RT(dxinv[0]);
972 Box blo = amrex::bdryLo(box, 0);
973 int blen = box.length(0);
975 {
976 mlpoisson_flux_xface(tbox, fxarr, solarr, fac, blen);
977 });
978 } else {
979 flux[0]->template setVal<RunOn::Device>(RT(0.0));
980 }
981 if (this->hiddenDirection() != 1) {
982 RT fac = RT(dxinv[1]);
983 Box blo = amrex::bdryLo(box, 1);
984 int blen = box.length(1);
986 {
987 mlpoisson_flux_yface(tbox, fyarr, solarr, fac, blen);
988 });
989 } else {
990 flux[1]->template setVal<RunOn::Device>(RT(0.0));
991 }
992 if (this->hiddenDirection() != 2) {
993 RT fac = RT(dxinv[2]);
994 Box blo = amrex::bdryLo(box, 2);
995 int blen = box.length(2);
997 {
998 mlpoisson_flux_zface(tbox, fzarr, solarr, fac, blen);
999 });
1000 } else {
1001 flux[2]->template setVal<RunOn::Device>(RT(0.0));
1002 }
1003 } else {
1004 if (this->hiddenDirection() != 0) {
1005 RT fac = RT(dxinv[0]);
1006 Box bflux = amrex::surroundingNodes(box, 0);
1008 {
1009 mlpoisson_flux_x(tbox, fxarr, solarr, fac);
1010 });
1011 } else {
1012 flux[0]->template setVal<RunOn::Device>(RT(0.0));
1013 }
1014 if (this->hiddenDirection() != 1) {
1015 RT fac = RT(dxinv[1]);
1016 Box bflux = amrex::surroundingNodes(box, 1);
1018 {
1019 mlpoisson_flux_y(tbox, fyarr, solarr, fac);
1020 });
1021 } else {
1022 flux[1]->template setVal<RunOn::Device>(RT(0.0));
1023 }
1024 if (this->hiddenDirection() != 2) {
1025 RT fac = RT(dxinv[2]);
1026 Box bflux = amrex::surroundingNodes(box, 2);
1028 {
1029 mlpoisson_flux_z(tbox, fzarr, solarr, fac);
1030 });
1031 } else {
1032 flux[2]->template setVal<RunOn::Device>(RT(0.0));
1033 }
1034 }
1035#elif (AMREX_SPACEDIM == 2)
1036 if (face_only) {
1037 if (this->hiddenDirection() != 0) {
1038 RT fac = RT(dxinv[0]);
1039 Box blo = amrex::bdryLo(box, 0);
1040 int blen = box.length(0);
1041 if (this->m_has_metric_term) {
1043 {
1044 mlpoisson_flux_xface_m(tbox, fxarr, solarr, fac, blen, dx, probxlo);
1045 });
1046 } else {
1048 {
1049 mlpoisson_flux_xface(tbox, fxarr, solarr, fac, blen);
1050 });
1051 }
1052 } else {
1053 flux[0]->template setVal<RunOn::Device>(RT(0.0));
1054 }
1055 if (this->hiddenDirection() != 1) {
1056 RT fac = RT(dxinv[1]);
1057 Box blo = amrex::bdryLo(box, 1);
1058 int blen = box.length(1);
1059 if (this->m_has_metric_term) {
1061 {
1062 mlpoisson_flux_yface_m(tbox, fyarr, solarr, fac, blen, dx, probxlo);
1063 });
1064 } else {
1066 {
1067 mlpoisson_flux_yface(tbox, fyarr, solarr, fac, blen);
1068 });
1069 }
1070 } else {
1071 flux[1]->template setVal<RunOn::Device>(RT(0.0));
1072 }
1073 } else {
1074 if (this->hiddenDirection() != 0) {
1075 RT fac = RT(dxinv[0]);
1076 Box bflux = amrex::surroundingNodes(box, 0);
1077 if (this->m_has_metric_term) {
1079 {
1080 mlpoisson_flux_x_m(tbox, fxarr, solarr, fac, dx, probxlo);
1081 });
1082 } else {
1084 {
1085 mlpoisson_flux_x(tbox, fxarr, solarr, fac);
1086 });
1087 }
1088 } else {
1089 flux[0]->template setVal<RunOn::Device>(RT(0.0));
1090 }
1091 if (this->hiddenDirection() != 1) {
1092 RT fac = RT(dxinv[1]);
1093 Box bflux = amrex::surroundingNodes(box, 1);
1094 if (this->m_has_metric_term) {
1096 {
1097 mlpoisson_flux_y_m(tbox, fyarr, solarr, fac, dx, probxlo);
1098 });
1099 } else {
1101 {
1102 mlpoisson_flux_y(tbox, fyarr, solarr, fac);
1103 });
1104 }
1105 } else {
1106 flux[1]->template setVal<RunOn::Device>(RT(0.0));
1107 }
1108 }
1109#else
1110 if (face_only) {
1111 RT fac = RT(dxinv[0]);
1112 Box blo = amrex::bdryLo(box, 0);
1113 int blen = box.length(0);
1114 if (this->m_has_metric_term) {
1116 {
1117 mlpoisson_flux_xface_m(tbox, fxarr, solarr, fac, blen, dx, probxlo);
1118 });
1119 } else {
1121 {
1122 mlpoisson_flux_xface(tbox, fxarr, solarr, fac, blen);
1123 });
1124 }
1125 } else {
1126 RT fac = RT(dxinv[0]);
1127 Box bflux = amrex::surroundingNodes(box, 0);
1128 if (this->m_has_metric_term) {
1130 {
1131 mlpoisson_flux_x_m(tbox, fxarr, solarr, fac, dx, probxlo);
1132 });
1133 } else {
1135 {
1136 mlpoisson_flux_x(tbox, fxarr, solarr, fac);
1137 });
1138 }
1139 }
1140#endif
1141}
1142
1143template <typename MF>
1144bool
1146{
1147 bool support = true;
1148 if (this->m_domain_covered[0]) { support = false; }
1149 if (this->doAgglomeration()) { support = false; }
1150 if (AMREX_SPACEDIM != 3) { support = false; }
1151 return support;
1152}
1153
1154template <typename MF>
1155std::unique_ptr<MLLinOpT<MF>>
1156MLPoissonT<MF>::makeNLinOp (int grid_size) const
1157{
1158 const Geometry& geom = this->m_geom[0].back();
1159 const BoxArray& ba = this->makeNGrids(grid_size);
1160
1162 {
1163 const std::vector<std::vector<int> >& sfc = DistributionMapping::makeSFC(ba);
1164 Vector<int> pmap(ba.size());
1166 const int nprocs = ParallelDescriptor::NProcs();
1167 for (int iproc = 0; iproc < nprocs; ++iproc) {
1168 for (int ibox : sfc[iproc]) {
1169 pmap[ibox] = iproc;
1170 }
1171 }
1172 dm.define(std::move(pmap));
1173 }
1174
1175 LPInfo minfo{};
1176 minfo.has_metric_term = this->info.has_metric_term;
1177
1178 std::unique_ptr<MLLinOpT<MF>> r{new MLALaplacianT<MF>({geom}, {ba}, {dm}, minfo)};
1179 auto nop = dynamic_cast<MLALaplacianT<MF>*>(r.get());
1180 if (!nop) {
1181 return nullptr;
1182 }
1183
1184 nop->m_parent = this;
1185
1186 nop->setMaxOrder(this->maxorder);
1187 nop->setVerbose(this->verbose);
1188
1189 nop->setDomainBC(this->m_lobc, this->m_hibc);
1190
1191 if (this->needsCoarseDataForBC())
1192 {
1193 const Real* dx0 = this->m_geom[0][0].CellSize();
1195 fac *= Real(0.5);
1196 RealVect cbloc {AMREX_D_DECL(dx0[0]*fac[0], dx0[1]*fac[1], dx0[2]*fac[2])};
1197 nop->setCoarseFineBCLocation(cbloc);
1198 }
1199
1200 nop->setScalars(1.0, -1.0);
1201
1202 const Real* dxinv = geom.InvCellSize();
1203 RT dxscale = RT(dxinv[0]);
1204#if (AMREX_SPACEDIM >= 2)
1205 dxscale = std::max(dxscale,RT(dxinv[1]));
1206#endif
1207#if (AMREX_SPACEDIM == 3)
1208 dxscale = std::max(dxscale,RT(dxinv[2]));
1209#endif
1210
1211 MF alpha(ba, dm, 1, 0, MFInfo().SetArena(The_Async_Arena()));
1212 alpha.setVal(RT(1.e30)*dxscale*dxscale);
1213
1214 MF foo(this->m_grids[0].back(), this->m_dmap[0].back(), 1, 0, MFInfo().SetAlloc(false));
1215 const FabArrayBase::CPC& cpc = alpha.getCPC(IntVect(0),foo,IntVect(0),Periodicity::NonPeriodic());
1216 alpha.setVal(RT(0.0), cpc, 0, 1);
1217
1218 nop->setACoeffs(0, alpha);
1219
1220 return r;
1221}
1222
1223template <typename MF>
1224void
1225MLPoissonT<MF>::copyNSolveSolution (MF& dst, MF const& src) const
1226{
1227 dst.ParallelCopy(src);
1228}
1229
1230template <typename MF>
1231void
1233 MF const& phi)
1234{
1235 BL_PROFILE("MLPoisson::dpdn_faces()");
1236
1237 // We do not need to call applyBC because this function is used by the
1238 // OpenBC solver after solver has converged. That means the BC has been
1239 // filled to check the residual.
1240
1241 Box const& domain0 = this->m_geom[0][0].Domain();
1242 AMREX_D_TERM(const RT dxi = RT(this->m_geom[0][0].InvCellSize(0));,
1243 const RT dyi = RT(this->m_geom[0][0].InvCellSize(1));,
1244 const RT dzi = RT(this->m_geom[0][0].InvCellSize(2));)
1245
1246#ifdef AMREX_USE_OMP
1247#pragma omp parallel if (Gpu::notInLaunchRegion())
1248#endif
1249 for (MFIter mfi(phi); mfi.isValid(); ++mfi)
1250 {
1251 Box const& vbx = mfi.validbox();
1252 for (OrientationIter oit; oit.isValid(); ++oit) {
1253 Orientation face = oit();
1254 if (vbx[face] == domain0[face]) {
1255 int dir = face.coordDir();
1256 auto const& p = phi.const_array(mfi);
1257 auto const& gp = dpdn[dir]->array(mfi);
1258 Box const& b2d = amrex::bdryNode(vbx,face);
1259 if (dir == 0) {
1260 // because it's dphi/dn, not dphi/dx.
1261 RT fac = dxi * (face.isLow() ? RT(-1.0) : RT(1.));
1263 {
1264 gp(i,j,k) = fac * (p(i,j,k) - p(i-1,j,k));
1265 });
1266 }
1267#if (AMREX_SPACEDIM > 1)
1268 else if (dir == 1) {
1269 RT fac = dyi * (face.isLow() ? RT(-1.0) : RT(1.));
1271 {
1272 gp(i,j,k) = fac * (p(i,j,k) - p(i,j-1,k));
1273 });
1274 }
1275#if (AMREX_SPACEDIM > 2)
1276 else {
1277 RT fac = dzi * (face.isLow() ? RT(-1.0) : RT(1.));
1279 {
1280 gp(i,j,k) = fac * (p(i,j,k) - p(i,j,k-1));
1281 });
1282 }
1283#endif
1284#endif
1285 }
1286 }
1287 }
1288}
1289
1290extern template class MLPoissonT<MultiFab>;
1291#ifdef AMREX_MLMG_HAS_FLOAT
1292extern template class MLPoissonT<fMultiFab>;
1293#endif
1294
1297
1298}
1299
1300#endif
#define BL_PROFILE(a)
Definition AMReX_BLProfiler.H:593
#define AMREX_ALWAYS_ASSERT_WITH_MESSAGE(EX, MSG)
Definition AMReX_BLassert.H:49
#define AMREX_ASSERT(EX)
Definition AMReX_BLassert.H:38
#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_GPU_LAUNCH_HOST_DEVICE_LAMBDA_RANGE(TN, TI, block)
Definition AMReX_GpuLaunchMacrosC.nolint.H:4
#define AMREX_GPU_DEVICE
Definition AMReX_GpuQualifiers.H:18
while parser_exe_t p
Definition AMReX_Parser_Exe_Body.H:33
#define AMREX_D_TERM(a, b, c)
Definition AMReX_SPACE.H:172
#define AMREX_D_DECL(a, b, c)
Definition AMReX_SPACE.H:171
Reference-counted collection of Boxes.
Definition AMReX_BoxArray.H:681
Long size() const noexcept
Return the number of boxes in the BoxArray.
Definition AMReX_BoxArray.H:758
__host__ __device__ IntVectND< dim > length() const noexcept
Return the length of the BoxND.
Definition AMReX_Box.H:167
const Real * InvCellSize() const noexcept
Returns the inverse cellsize for each coordinate direction.
Definition AMReX_CoordSys.H:91
Calculates the distribution of FABs to MPI processes.
Definition AMReX_DistributionMapping.H:55
void define(const BoxArray &boxes, int nprocs=ParallelDescriptor::NProcs())
Build a mapping from a BoxArray using the current strategy.
Definition AMReX_DistributionMapping.cpp:345
static DistributionMapping makeSFC(const MultiFab &weight, bool sort=true)
Build an SFC map weighted by the sum of component 0 over each valid box of weight; sort enables load-...
Definition AMReX_DistributionMapping.cpp:1778
Abstract factory interface for creating, aliasing, and destroying FAB objects.
Definition AMReX_FabFactory.H:73
Rectangular problem domain geometry.
Definition AMReX_Geometry.H:87
Iterator for looping ever tiles and boxes of amrex::FabArray based containers.
Definition AMReX_MFIter.H:88
Box tilebox() const noexcept
Return the tile Box at the current index.
Definition AMReX_MFIter.cpp:389
bool isValid() const noexcept
Is the iterator valid i.e. is it associated with a FAB?
Definition AMReX_MFIter.H:176
Multi-component ALaplacian (a scalar plus optional spatial a coeffs).
Definition AMReX_MLALaplacian.H:22
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
void prepareForSolve() override
Standard hook called before MLMG iterates (fixes BC data, etc.).
Definition AMReX_MLCellABecLap.H:323
BoxArray makeNGrids(int grid_size) const
Helper that builds a BoxArray for NSolve with boxes no larger than the requested grid_size.
Definition AMReX_MLCellLinOp.H:1252
Vector< Vector< BndryRegisterT< MF > > > m_undrrelxr
Definition AMReX_MLCellLinOp.H:509
bool m_has_metric_term
Definition AMReX_MLCellLinOp.H:454
bool m_use_gauss_seidel
Definition AMReX_MLCellLinOp.H:518
Vector< Vector< Array< MultiMask, 2 *3 > > > m_maskvals
Definition AMReX_MLCellLinOp.H:512
T get_d0(T const &dx, T const &dy, T const &) const noexcept
Definition AMReX_MLLinOp.H:1312
bool doAgglomeration() const noexcept
Definition AMReX_MLLinOp.H:1244
Vector< Geometry > spGeom(const Vector< Geometry > &a_geom)
Definition AMReX_MLLinOp.H:1102
Vector< Array< BCType, 3 > > m_hibc
Definition AMReX_MLLinOp.H:966
Vector< Vector< BoxArray > > m_grids
Definition AMReX_MLLinOp.H:1008
Vector< Vector< DistributionMapping > > m_dmap
Definition AMReX_MLLinOp.H:1009
int verbose
Definition AMReX_MLLinOp.H:983
IntVect m_coarse_data_crse_ratio
Definition AMReX_MLLinOp.H:1037
bool needsCoarseDataForBC() const noexcept
Needs coarse data for bc?
Definition AMReX_MLLinOp.H:249
bool hasHiddenDimension() const noexcept
Definition AMReX_MLLinOp.H:1293
int hiddenDirection() const noexcept
Definition AMReX_MLLinOp.H:1294
Vector< Array< BCType, 3 > > m_lobc
Definition AMReX_MLLinOp.H:965
Vector< int > m_domain_covered
Definition AMReX_MLLinOp.H:1011
Vector< Vector< Geometry > > m_geom
first Vector is for amr level and second is mg level
Definition AMReX_MLLinOp.H:1007
LPInfo dpInfo(LPInfo const &a_info) const
Definition AMReX_MLLinOp.H:1128
Box compactify(Box const &b) const noexcept
Definition AMReX_MLLinOp.H:2068
bool m_needs_coarse_data_for_bc
Definition AMReX_MLLinOp.H:1035
int maxorder
Definition AMReX_MLLinOp.H:986
LinOpEnumType::Location Location
Definition AMReX_MLLinOp.H:174
LPInfo info
Definition AMReX_MLLinOp.H:981
void makeSPLinOp(LPInfo const &a_info, F const &f)
Definition AMReX_MLLinOp.H:1145
T get_d1(T const &, T const &dy, T const &dz) const noexcept
Definition AMReX_MLLinOp.H:1322
LinOpBCType m_coarse_fine_bc_type
Definition AMReX_MLLinOp.H:1036
int m_num_amr_levels
Definition AMReX_MLLinOp.H:992
Cell-centered Laplacian operator \nabla^2 \phi.
Definition AMReX_MLPoisson.H:32
LinOpBCType BCType
Definition AMReX_MLPoisson.H:38
bool supportsMixedPrecision() const override
Definition AMReX_MLPoisson.H:108
typename MF::value_type RT
Definition AMReX_MLPoisson.H:36
MLPoissonT< MF > & operator=(const MLPoissonT< MF > &)=delete
void copyNSolveSolution(MultiFab &dst, MultiFab const &src) const final
void get_dpdn_on_domain_faces(Array< MultiFab *, 3 > const &dpdn, MultiFab const &phi)
bool isBottomSingular() const final
True if the coarsest level is singular (e.g., pure Neumann BCs).
Definition AMReX_MLPoisson.H:114
void prepareForSolve() final
Prepare coefficients and singularity flags before entering MLMG.
Definition AMReX_MLPoisson.H:222
void Fapply(int amrlev, int mglev, MF &out, const MF &in) const final
Apply the discrete Laplacian to in at (amrlev,mglev), storing the result in out.
Definition AMReX_MLPoisson.H:264
void normalize(int amrlev, int mglev, MultiFab &mf) const final
MLPoissonT(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={})
Convenience constructor with overset-mask support (1 = unknown, 0 = known).
Definition AMReX_MLPoisson.H:174
typename MF::fab_type FAB
Definition AMReX_MLPoisson.H:35
Array< MF const *, 3 > getBCoeffs(int, int) const final
Poisson never supplies explicit b Multifabs, so this always returns null pointers.
Definition AMReX_MLPoisson.H:137
bool isSingular(int amrlev) const final
True if the operator is singular on AMR level amrlev.
Definition AMReX_MLPoisson.H:112
~MLPoissonT() override
MLPoissonT(const MLPoissonT< MF > &)=delete
bool supportNSolve() const final
Report whether this operator has nodal-solve support.
Definition AMReX_MLPoisson.H:1145
MLPoissonT(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={})
Convenience constructor that forwards to define().
Definition AMReX_MLPoisson.H:164
MLPoissonT(MLPoissonT< MF > &&)=delete
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={})
Define the hierarchy for standard cell-centered data.
Definition AMReX_MLPoisson.H:186
RT getAScalar() const final
Definition AMReX_MLPoisson.H:131
RT getBScalar() const final
Return the constant b coefficient (-1, cancelling the minus in the ABec form to give \nabla^2).
Definition AMReX_MLPoisson.H:133
MF const * getACoeffs(int, int) const final
Poisson never supplies explicit a coefficients, so this always returns nullptr.
Definition AMReX_MLPoisson.H:135
MLPoissonT()=default
Construct an empty operator; call define() before using it.
void FFlux(int amrlev, const MFIter &mfi, const Array< FAB *, 3 > &flux, const FAB &sol, Location loc, int face_only=0) const final
Compute per-face fluxes from sol on the tilebox described by mfi and write them to flux with location...
Definition AMReX_MLPoisson.H:948
typename MLLinOpT< MF >::Location Location
Definition AMReX_MLPoisson.H:39
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={})
Define the hierarchy including overset regions.
Definition AMReX_MLPoisson.H:201
void Fsmooth(int amrlev, int mglev, MF &sol, const MF &rhs, int redblack) const final
Perform a smoothing sweep on (amrlev,mglev). redblack selects the red (0) or black (1) half of the gr...
Definition AMReX_MLPoisson.H:452
std::unique_ptr< MLLinOpT< MF > > makeNLinOp(int grid_size) const final
Build the NSolve counterpart with tile size grid_size.
Definition AMReX_MLPoisson.H:1156
Definition AMReX_MultiMask.H:23
MultiArray4< int const > const_arrays() const noexcept
Return const multi-array views (alias of arrays()).
Definition AMReX_MultiMask.H:86
Array4< int const > array(const MFIter &mfi) const noexcept
Return an Array4 view (const) for iterator mfi.
Definition AMReX_MultiMask.H:69
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
static const Periodicity & NonPeriodic() noexcept
Definition AMReX_Periodicity.cpp:52
This class is a thin wrapper around std::vector. Unlike vector, Vector::operator[] provides bound che...
Definition AMReX_Vector.H:29
amrex_real Real
Floating Point Type for Fields.
Definition AMReX_REAL.H:80
__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:1584
__host__ __device__ BoxND< dim > bdryLo(const BoxND< dim > &b, int dir, int len=1) noexcept
Return the BoxND of length len on the low boundary of b along coordinate direction dir.
Definition AMReX_Box.H:1717
__host__ __device__ BoxND< dim > bdryNode(const BoxND< dim > &b, Orientation face, int len=1) noexcept
Similar to bdryLo and bdryHi except that it operates on the given face of BoxND b.
Definition AMReX_Box.H:1778
__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:1328
std::array< T, N > Array
Definition AMReX_Array.H:31
Arena * The_Async_Arena()
Definition AMReX_Arena.cpp:849
int NProcs() noexcept
Definition AMReX_ParallelDescriptor.H:255
MLPoissonT< MultiFab > MLPoisson
Definition AMReX_MLPoisson.H:1296
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
MPI_Comm Communicator() noexcept
Definition AMReX_ParallelDescriptor.H:223
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
void ParallelForRedBlack(MF const &mf, int redblack, F &&f)
ParallelFor over the red or black points of the valid region of a MultiFab/FabArray.
Definition AMReX_MFParallelFor.H:529
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
LinOpBCType
Definition AMReX_LO_BCTYPES.H:27
@ Neumann
Definition AMReX_LO_BCTYPES.H:30
@ Dirichlet
Definition AMReX_LO_BCTYPES.H:29
bool TilingIfNotGPU() noexcept
Definition AMReX_MFIter.H:12
IntVectND< 3 > IntVect
IntVect is an alias for amrex::IntVectND instantiated with AMREX_SPACEDIM.
Definition AMReX_BaseFwd.H:38
RealVectND< 3 > RealVect
Definition AMReX_ParmParse.H:40
__host__ __device__ Dim3 end(BoxND< dim > const &box) noexcept
Return the iterator end coordinate of box as Dim3.
Definition AMReX_Box.H:2259
void setVal(MF &dst, typename MF::value_type val)
dst = val
Definition AMReX_FabArrayUtility.H:2174
parallel copy or add
Definition AMReX_FabArrayBase.H:651
Configuration knobs for multilevel linear operators (grid agglomeration, metrics, etc....
Definition AMReX_MLLinOp.H:54
bool has_metric_term
Definition AMReX_MLLinOp.H:62
FabArray memory allocation information.
Definition AMReX_FabArray.H:73
Definition AMReX_MFIter.H:20
MFItInfo & SetDynamic(bool f) noexcept
Definition AMReX_MFIter.H:43
MFItInfo & EnableTiling(const IntVect &ts=FabArrayBase::mfiter_tile_size) noexcept
Definition AMReX_MFIter.H:31