@@ -168,6 +168,8 @@ template TaskStatus
168168SendBoundBufs<BoundaryType::gmg_prolongate_send>(std::shared_ptr<MeshData<Real>> &);
169169template TaskStatus
170170SendBoundBufs<BoundaryType::flxcor_send>(std::shared_ptr<MeshData<Real>> &);
171+ template TaskStatus
172+ SendBoundBufs<BoundaryType::gmg_same>(std::shared_ptr<MeshData<Real>> &);
171173
172174template <BoundaryType bound_type>
173175TaskStatus StartReceiveBoundBufs (std::shared_ptr<MeshData<Real>> &md) {
@@ -196,6 +198,8 @@ template TaskStatus StartReceiveBoundBufs<BoundaryType::gmg_prolongate_recv>(
196198 std::shared_ptr<MeshData<Real>> &);
197199template TaskStatus
198200StartReceiveBoundBufs<BoundaryType::flxcor_recv>(std::shared_ptr<MeshData<Real>> &);
201+ template TaskStatus
202+ StartReceiveBoundBufs<BoundaryType::gmg_same>(std::shared_ptr<MeshData<Real>> &);
199203
200204template <BoundaryType bound_type>
201205TaskStatus ReceiveBoundBufs (std::shared_ptr<MeshData<Real>> &md) {
@@ -246,6 +250,8 @@ template TaskStatus
246250ReceiveBoundBufs<BoundaryType::gmg_prolongate_recv>(std::shared_ptr<MeshData<Real>> &);
247251template TaskStatus
248252ReceiveBoundBufs<BoundaryType::flxcor_recv>(std::shared_ptr<MeshData<Real>> &);
253+ template TaskStatus
254+ ReceiveBoundBufs<BoundaryType::gmg_same>(std::shared_ptr<MeshData<Real>> &);
249255
250256template <BoundaryType bound_type>
251257TaskStatus SetBounds (std::shared_ptr<MeshData<Real>> &md) {
@@ -356,6 +362,7 @@ template TaskStatus
356362SetBounds<BoundaryType::gmg_prolongate_recv>(std::shared_ptr<MeshData<Real>> &);
357363template TaskStatus
358364SetBounds<BoundaryType::flxcor_recv>(std::shared_ptr<MeshData<Real>> &);
365+ template TaskStatus SetBounds<BoundaryType::gmg_same>(std::shared_ptr<MeshData<Real>> &);
359366
360367template <BoundaryType bound_type>
361368TaskStatus ProlongateBounds (std::shared_ptr<MeshData<Real>> &md) {
@@ -400,56 +407,55 @@ template TaskStatus
400407ProlongateBounds<BoundaryType::nonlocal>(std::shared_ptr<MeshData<Real>> &);
401408template TaskStatus
402409ProlongateBounds<BoundaryType::gmg_prolongate_recv>(std::shared_ptr<MeshData<Real>> &);
410+ template TaskStatus
411+ ProlongateBounds<BoundaryType::gmg_same>(std::shared_ptr<MeshData<Real>> &);
403412
404- // Adds all relevant boundary communication to a single task list
405- template <BoundaryType bounds>
406- TaskID AddBoundaryExchangeTasks (TaskID dependency, TaskList &tl,
407- std::shared_ptr<MeshData<Real>> &md, bool multilevel) {
408- // TODO(LFR): Splitting up the boundary tasks while doing prolongation can cause some
409- // possible issues for sparse fields. In particular, the order in which
410- // fields are allocated and then set could potentially result in different
411- // results if the default sparse value is non-zero.
412- // const auto any = BoundaryType::any;
413- static_assert (bounds == BoundaryType::any || bounds == BoundaryType::gmg_same);
414- // const auto local = BoundaryType::local;
415- // const auto nonlocal = BoundaryType::nonlocal;
416-
417- // auto send = tl.AddTask(dependency, SendBoundBufs<nonlocal>, md);
418- // auto send_local = tl.AddTask(dependency, SendBoundBufs<local>, md);
419-
420- // auto recv_local = tl.AddTask(dependency, ReceiveBoundBufs<local>, md);
421- // auto set_local = tl.AddTask(recv_local, SetBounds<local>, md);
422-
423- // auto recv = tl.AddTask(dependency, ReceiveBoundBufs<nonlocal>, md);
424- // auto set = tl.AddTask(recv, SetBounds<nonlocal>, md);
413+ template <BoundaryType bound_type>
414+ TaskStatus ProlongateInternalBounds (std::shared_ptr<MeshData<Real>> &md) {
415+ PARTHENON_INSTRUMENT
425416
426- // auto cbound = tl.AddTask(set, ApplyCoarseBoundaryConditions, md);
417+ Mesh *pmesh = md->GetMeshPointer ();
418+ auto &cache = md->GetBvarsCache ().GetSubCache (bound_type, false );
427419
428- // auto pro_local = tl.AddTask(cbound | set_local | set, ProlongateBounds<local>, md);
429- // auto pro = tl.AddTask(cbound | set_local | set, ProlongateBounds<nonlocal>, md);
420+ auto [rebuild, nbound] = CheckReceiveBufferCacheForRebuild<bound_type, false >(md);
430421
431- // auto out = (pro_local | pro);
422+ if (rebuild) {
423+ if constexpr (bound_type == BoundaryType::gmg_prolongate_recv) {
424+ RebuildBufferCache<bound_type, false >(md, nbound, BndInfo::GetSetBndInfo,
425+ ProResInfo::GetInteriorProlongate);
426+ } else if constexpr (bound_type == BoundaryType::gmg_restrict_recv) {
427+ RebuildBufferCache<bound_type, false >(md, nbound, BndInfo::GetSetBndInfo,
428+ ProResInfo::GetNull);
429+ } else {
430+ RebuildBufferCache<bound_type, false >(md, nbound, BndInfo::GetSetBndInfo,
431+ ProResInfo::GetSet);
432+ }
433+ }
432434
433- auto send = tl. AddTask (dependency, TF (SendBoundBufs<bounds>), md);
434- auto recv = tl. AddTask (dependency, TF (ReceiveBoundBufs<bounds>), md );
435- auto set = tl. AddTask (recv, TF (SetBounds<bounds>), md );
435+ if (nbound > 0 && pmesh-> multilevel && md-> NumBlocks () > 0 ) {
436+ auto pmb = md-> GetBlockData ( 0 )-> GetBlockPointer ( );
437+ StateDescriptor *resolved_packages = pmb-> resolved_packages . get ( );
436438
437- auto pro = set;
438- if (md->GetMeshPointer ()->multilevel ) {
439- auto cbound = tl.AddTask (set, TF (ApplyBoundaryConditionsOnCoarseOrFineMD), md, true );
440- pro = tl.AddTask (cbound, TF (ProlongateBounds<bounds>), md);
439+ // Prolongate from coarse buffer
440+ refinement::ProlongateInternal (resolved_packages, cache.prores_cache , pmb->cellbounds ,
441+ pmb->c_cellbounds );
441442 }
442- auto fbound = tl.AddTask (pro, TF (ApplyBoundaryConditionsOnCoarseOrFineMD), md, false );
443-
444- return fbound;
443+ return TaskStatus::complete;
445444}
446- template TaskID
447- AddBoundaryExchangeTasks<BoundaryType::any>(TaskID, TaskList &,
448- std::shared_ptr<MeshData<Real>> &, bool );
445+ template TaskStatus
446+ ProlongateInternalBounds<BoundaryType::any>(std::shared_ptr<MeshData<Real>> &);
447+ template TaskStatus
448+ ProlongateInternalBounds<BoundaryType::local>(std::shared_ptr<MeshData<Real>> &);
449+ template TaskStatus
450+ ProlongateInternalBounds<BoundaryType::nonlocal>(std::shared_ptr<MeshData<Real>> &);
451+ template TaskStatus ProlongateInternalBounds<BoundaryType::gmg_prolongate_recv>(
452+ std::shared_ptr<MeshData<Real>> &);
453+ template TaskStatus
454+ ProlongateInternalBounds<BoundaryType::gmg_same>(std::shared_ptr<MeshData<Real>> &);
449455
450- template TaskID
451- AddBoundaryExchangeTasks<BoundaryType::gmg_same>(TaskID, TaskList &,
452- std::shared_ptr<MeshData<Real>> &, bool );
456+ bool IsMeshMultilevel (std::shared_ptr<MeshData<Real>> &md) {
457+ return md-> GetMeshPointer ()-> multilevel ;
458+ }
453459
454460TaskID AddFluxCorrectionTasks (TaskID dependency, TaskList &tl,
455461 std::shared_ptr<MeshData<Real>> &md, bool multilevel) {
0 commit comments