3939TaskCollection KHARMADriver::MakeSimpleTaskCollection (BlockList_t &blocks, int stage)
4040{
4141 // This is probably incompatible with everything
42-
43- // TODO check for incompatibilities at some point:
44- // At least implicit, jcon output, various electrons tests, etc.
45-
4642 TaskCollection tc;
4743 TaskID t_none (0 );
4844
4945 // Which packages we've loaded affects which tasks we'll add to the list
5046 auto & pkgs = blocks[0 ]->packages .AllPackages ();
5147 auto & flux_pkg = pkgs.at (" Flux" )->AllParams ();
5248
49+ if (pkgs.count (" B_Cleanup" ) || pkgs.count (" B_CT" ) ||
50+ pkgs.count (" Electrons" ) || flux_pkg.Get <bool >(" use_fofc" ) ||
51+ pkgs.count (" Implicit" ) || pkgs.count (" Current" ) ||
52+ pkgs.count (" EMHD" ) || pkgs.count (" ISMR" ) || pmesh->multilevel )
53+ throw std::runtime_error (" Simple driver cannot be used with any advanced features! Use KHARMA or ImEx driver instead!" );
54+
5355 // Allocate the fluid states ("containers") we need for each block
54- for (auto & pmb : blocks) {
55- auto &base = pmb->meshblock_data .Get (" base" );
56- if (stage == 1 ) {
57- pmb->meshblock_data .Add (" dUdt" , base);
58- for (int i = 1 ; i < integrator->nstages ; i++)
59- pmb->meshblock_data .Add (integrator->stage_name [i], base);
60- }
56+ if (stage == 1 ) {
57+ auto &base = pmesh->mesh_data .Get (" base" );
58+ // Fluxes
59+ pmesh->mesh_data .Add (" dUdt" );
60+ for (int i = 1 ; i < integrator->nstages ; i++)
61+ pmesh->mesh_data .Add (integrator->stage_name [i]);
6162 }
6263
6364
6465
6566 // Big synchronous region: get & apply fluxes to advance the fluid state
6667 // num_partitions is nearly always 1
6768 const int num_partitions = pmesh->DefaultNumPartitions ();
68- TaskRegion &single_tasklist_per_pack_region = tc.AddRegion (num_partitions);
69+ TaskRegion &flux_region = tc.AddRegion (num_partitions);
6970 for (int i = 0 ; i < num_partitions; i++) {
70- auto &tl = single_tasklist_per_pack_region [i];
71+ auto &tl = flux_region [i];
7172 // Container names:
7273 // '_full_step_init' refers to the fluid state at the start of the full time step (Si in iharm3d)
7374 // '_sub_step_init' refers to the fluid state at the start of the sub step (Ss in iharm3d)
@@ -78,6 +79,9 @@ TaskCollection KHARMADriver::MakeSimpleTaskCollection(BlockList_t &blocks, int s
7879 auto &md_sub_step_final = pmesh->mesh_data .GetOrAdd (integrator->stage_name [stage], i);
7980 auto &md_flux_src = pmesh->mesh_data .GetOrAdd (" dUdt" , i);
8081
82+ auto t_start_recv_bound = tl.AddTask (t_none, parthenon::StartReceiveBoundBufs<parthenon::BoundaryType::any>, md_sub_step_final);
83+
84+
8185 // Calculate the flux of each variable through each face
8286 // This reconstructs the primitives (P) at faces and uses them to calculate fluxes
8387 // of the conserved variables (U) through each face.
@@ -96,30 +100,14 @@ TaskCollection KHARMADriver::MakeSimpleTaskCollection(BlockList_t &blocks, int s
96100 // Add any source terms: geometric \Gamma * T, wind, damping, etc etc
97101 auto t_sources = tl.AddTask (t_flux_div, Packages::AddSource, md_sub_step_init.get (), md_flux_src.get (), IndexDomain::interior);
98102
99- // Perform the update using the source term
100- // Add any proportion of the step start required by the integrator (e.g., RK2)
101- auto t_avg_data = tl.AddTask (t_sources, Update::WeightedSumData<std::vector<MetadataFlag>, MeshData<Real>>,
102- std::vector<MetadataFlag>({Metadata::Independent}),
103- md_sub_step_init.get (), md_full_step_init.get (),
104- integrator->gam0 [stage-1 ], integrator->gam1 [stage-1 ],
105- md_sub_step_final.get ());
106- // apply du/dt to the result
107- auto t_update = tl.AddTask (t_sources, Update::WeightedSumData<std::vector<MetadataFlag>, MeshData<Real>>,
108- std::vector<MetadataFlag>({Metadata::Independent}),
109- md_sub_step_final.get (), md_flux_src.get (),
110- 1.0 , integrator->beta [stage-1 ] * integrator->dt ,
111- md_sub_step_final.get ());
112-
113- // UtoP needs a guess in order to converge, so we copy in md_sub_step_init
114- auto t_copy_prims = t_update;
115- if (integrator->nstages > 1 ) {
116- t_copy_prims = tl.AddTask (t_none, Copy<MeshData<Real>>, std::vector<MetadataFlag>({Metadata::GetUserFlag (" HD" ), Metadata::GetUserFlag (" Primitive" )}),
117- md_sub_step_init.get (), md_sub_step_final.get ());
118- }
119-
103+ // Update explicit state with the explicit fluxes/sources
104+ auto t_update = KHARMADriver::AddStateUpdate (t_sources, tl, md_full_step_init.get (), md_sub_step_init.get (),
105+ md_flux_src.get (), md_sub_step_final.get (),
106+ std::vector<MetadataFlag>{Metadata::GetUserFlag (" Explicit" ), Metadata::Independent},
107+ false , stage);
120108
121109 // Make sure the primitive values are updated.
122- auto t_UtoP = tl.AddTask (t_copy_prims , Packages::MeshUtoP, md_sub_step_final.get (), IndexDomain::interior , false );
110+ auto t_UtoP = tl.AddTask (t_update , Packages::MeshUtoP, md_sub_step_final.get (), IndexDomain::entire , false );
123111
124112 // Apply any floors
125113 auto t_floors = tl.AddTask (t_UtoP, Packages::MeshApplyFloors, md_sub_step_final.get (), IndexDomain::interior);
0 commit comments