Skip to content

Commit

Permalink
Boundary and B-FluxCT FixFlux fns were only Get()ing base container! …
Browse files Browse the repository at this point in the history
…Always Get() explicit container
  • Loading branch information
bprather committed Jan 7, 2025
1 parent 98ae781 commit c221d5b
Show file tree
Hide file tree
Showing 9 changed files with 81 additions and 80 deletions.
18 changes: 9 additions & 9 deletions kharma/b_cd/b_cd.cpp
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
/*
/*
* File: b_cd.cpp
*
*
* BSD 3-Clause License
*
*
* Copyright (c) 2020, AFD Group at UIUC
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Expand Down Expand Up @@ -246,7 +246,7 @@ TaskStatus PostStepDiagnostics(const SimTime& tm, MeshData<Real> *md)

void FillOutput(MeshBlock *pmb, ParameterInput *pin)
{
auto rc = pmb->meshblock_data.Get().get();
auto rc = pmb->meshblock_data.Get("base").get();
IndexDomain domain = IndexDomain::interior;
int is = pmb->cellbounds.is(domain), ie = pmb->cellbounds.ie(domain);
int js = pmb->cellbounds.js(domain), je = pmb->cellbounds.je(domain);
Expand Down
19 changes: 10 additions & 9 deletions kharma/b_ct/b_ct.cpp
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
/*
/*
* File: b_ct.cpp
*
*
* BSD 3-Clause License
*
*
* Copyright (c) 2020, AFD Group at UIUC
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Expand Down Expand Up @@ -582,7 +582,8 @@ void B_CT::CalcDivB(MeshData<Real> *md, std::string divb_field_name)

void B_CT::FillOutput(MeshBlock *pmb, ParameterInput *pin)
{
auto rc = pmb->meshblock_data.Get();
// This is called after the step, use "base" container
auto rc = pmb->meshblock_data.Get("base");
const int ndim = pmb->pmy_mesh->ndim;
if (ndim < 2) return;

Expand Down
24 changes: 12 additions & 12 deletions kharma/b_flux_ct/b_flux_ct.cpp
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
/*
/*
* File: b_flux_ct.cpp
*
*
* BSD 3-Clause License
*
*
* Copyright (c) 2020, AFD Group at UIUC
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Expand Down Expand Up @@ -410,7 +410,7 @@ void ZeroBoundaryFlux(MeshData<Real> *md, IndexDomain domain, bool coarse)
// Compare this section with calculation of emf3 in FluxCT:
// these changes ensure that boundary emfs emf3(i,js,k)=0, etc.
for (auto &pmb : pmesh->block_list) {
auto& rc = pmb->meshblock_data.Get();
auto& rc = pmb->meshblock_data.Get(md->StageName());
auto& B_F = rc->PackVariablesAndFluxes(std::vector<std::string>{"cons.B"});

if (domain == IndexDomain::inner_x2 &&
Expand Down Expand Up @@ -495,7 +495,7 @@ void Bflux0(MeshData<Real> *md, IndexDomain domain, bool coarse)
// Compare this section with calculation of emf3 in FluxCT:
// these changes ensure that boundary emfs emf3(i,js,k)=0, etc.
for (auto &pmb : pmesh->block_list) {
auto& rc = pmb->meshblock_data.Get();
auto& rc = pmb->meshblock_data.Get(md->StageName());
auto& B_F = rc->PackVariablesAndFluxes(std::vector<std::string>{"cons.B"});

// "Bflux0" prescription for keeping divB~=0 on zone corners of the interior & exterior X1 faces
Expand Down Expand Up @@ -555,7 +555,7 @@ IndexRange ValidDivBX1(MeshBlock *pmb)
{
// All user, physical (not MPI/periodic) boundary conditions in X1 will generate divB on corners
// intersecting the interior & exterior faces. Don't report these zones, as we expect it.
const IndexRange ibl = pmb->meshblock_data.Get()->GetBoundsI(IndexDomain::interior);
const IndexRange ibl = pmb->meshblock_data.Get("base")->GetBoundsI(IndexDomain::interior);
bool avoid_inner = (!pmb->packages.Get("B_FluxCT")->Param<bool>("fix_flux_inner_x1") &&
pmb->boundary_flag[BoundaryFace::inner_x1] == BoundaryFlag::user);
bool avoid_outer = (!pmb->packages.Get("B_FluxCT")->Param<bool>("fix_flux_outer_x1") &&
Expand Down Expand Up @@ -677,7 +677,7 @@ void CalcDivB(MeshData<Real> *md, std::string divb_field_name)
}
void FillOutput(MeshBlock *pmb, ParameterInput *pin)
{
auto rc = pmb->meshblock_data.Get().get();
auto rc = pmb->meshblock_data.Get("base").get();
const int ndim = pmb->pmy_mesh->ndim;
if (ndim < 2) return;

Expand Down
2 changes: 1 addition & 1 deletion kharma/boundaries/boundaries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ TaskStatus KBoundaries::FixFlux(MeshData<Real> *md)
const IndexRange3 b1 = KDomain::GetRange(md, IndexDomain::interior, -1, 1);

for (auto &pmb : pmesh->block_list) {
auto &rc = pmb->meshblock_data.Get();
auto &rc = pmb->meshblock_data.Get(md->StageName());

for (int i = 0; i < BOUNDARY_NFACES; i++) {
BoundaryFace bface = (BoundaryFace)i;
Expand Down
20 changes: 10 additions & 10 deletions kharma/coord_output/coord_output.cpp
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
/*
/*
* File: coord_output.cpp
*
*
* BSD 3-Clause License
*
*
* Copyright (c) 2020, AFD Group at UIUC
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Expand Down Expand Up @@ -70,7 +70,7 @@ std::shared_ptr<KHARMAPackage> CoordinateOutput::Initialize(ParameterInput *pin,
pkg->AddField("coords.r", m0);
pkg->AddField("coords.th", m0);
pkg->AddField("coords.phi", m0);

// Metric
pkg->AddField("coords.gcon", m2);
pkg->AddField("coords.gcov", m2);
Expand Down Expand Up @@ -100,7 +100,7 @@ TaskStatus CoordinateOutput::BlockUserWorkBeforeOutput(MeshBlock *pmb, Parameter
{
auto& globals = pmb->packages.Get("Globals")->AllParams();
if (!globals.Get<bool>("in_loop")) {
auto rc = pmb->meshblock_data.Get();
auto rc = pmb->meshblock_data.Get("base");

PackIndexMap geom_map;
auto Geom = rc->PackVariables({Metadata::GetUserFlag("CoordinateOutput")}, geom_map);
Expand Down
18 changes: 9 additions & 9 deletions kharma/current/current.cpp
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
/*
/*
* File: current.cpp
*
*
* BSD 3-Clause License
*
*
* Copyright (c) 2020, AFD Group at UIUC
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Expand Down Expand Up @@ -118,7 +118,7 @@ void Current::FillOutput(MeshBlock *pmb, ParameterInput *pin)
{
// The "preserve" container will only exist after we've taken a step,
// catch that situation
auto& rc1 = pmb->meshblock_data.Get();
auto& rc1 = pmb->meshblock_data.Get("base");
auto rc0 = rc1; // Avoid writing rc0's type when initializing. Still light.
try {
// Get the state at beginning of the step
Expand Down
22 changes: 11 additions & 11 deletions kharma/driver/simple_step.cpp
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
/*
/*
* File: simple_step.cpp
*
*
* BSD 3-Clause License
*
*
* Copyright (c) 2020, AFD Group at UIUC
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Expand Down Expand Up @@ -52,7 +52,7 @@ TaskCollection KHARMADriver::MakeSimpleTaskCollection(BlockList_t &blocks, int s

// Allocate the fluid states ("containers") we need for each block
for (auto& pmb : blocks) {
auto &base = pmb->meshblock_data.Get();
auto &base = pmb->meshblock_data.Get("base");
if (stage == 1) {
pmb->meshblock_data.Add("dUdt", base);
for (int i = 1; i < integrator->nstages; i++)
Expand All @@ -68,7 +68,7 @@ TaskCollection KHARMADriver::MakeSimpleTaskCollection(BlockList_t &blocks, int s
TaskRegion &single_tasklist_per_pack_region = tc.AddRegion(num_partitions);
for (int i = 0; i < num_partitions; i++) {
auto &tl = single_tasklist_per_pack_region[i];
// Container names:
// Container names:
// '_full_step_init' refers to the fluid state at the start of the full time step (Si in iharm3d)
// '_sub_step_init' refers to the fluid state at the start of the sub step (Ss in iharm3d)
// '_sub_step_final' refers to the fluid state at the end of the sub step (Sf in iharm3d)
Expand All @@ -86,7 +86,7 @@ TaskCollection KHARMADriver::MakeSimpleTaskCollection(BlockList_t &blocks, int s
// Any package modifications to the fluxes. e.g.:
// 1. CT calculations for B field transport
// 2. Zero fluxes through poles
// etc
// etc
auto t_fix_flux = tl.AddTask(t_fluxes, Packages::FixFlux, md_sub_step_init.get());

// Apply the fluxes to calculate a change in cell-centered values "md_flux_src"
Expand Down
20 changes: 10 additions & 10 deletions kharma/prob/post_initialize.cpp
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
/*
/*
* File: post_initialize.cpp
*
*
* BSD 3-Clause License
*
*
* Copyright (c) 2020, AFD Group at UIUC
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Expand Down Expand Up @@ -97,7 +97,7 @@ void KHARMA::PostInitialize(ParameterInput *pin, Mesh *pmesh, bool is_restart)
// since seeding may be based on density
if (pin->GetOrAddBoolean("blob", "add_blob", false)) {
for (auto &pmb : pmesh->block_list) {
auto rc = pmb->meshblock_data.Get();
auto rc = pmb->meshblock_data.Get("base");
// This inserts only in vicinity of some global r,th,phi
InsertBlob(rc.get(), pin);
}
Expand Down Expand Up @@ -172,7 +172,7 @@ void KHARMA::PostInitialize(ParameterInput *pin, Mesh *pmesh, bool is_restart)
}

// The e- initialization is called during problem initialization, but we want an option
// to force it -- for example, if restarting an ideal GRMHD run,
// to force it -- for example, if restarting an ideal GRMHD run,
if (pkgs.count("Electrons") && pin->GetOrAddBoolean("electrons", "reinitialize", false)) {
std::cout << "Reinitializing electron temperatures!" << std::endl;
Electrons::MeshInitElectrons(md.get(), pin);
Expand Down
Loading

0 comments on commit c221d5b

Please sign in to comment.