From df70c89721279ca41935e322f1e5935eed14e9cf Mon Sep 17 00:00:00 2001 From: David Bold Date: Mon, 24 Feb 2025 13:38:40 +0100 Subject: [PATCH 1/7] Allow to overwrite MYG with options. --- src/mesh/impls/bout/boutmesh.cxx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/mesh/impls/bout/boutmesh.cxx b/src/mesh/impls/bout/boutmesh.cxx index 4aaa760c04..08df213126 100644 --- a/src/mesh/impls/bout/boutmesh.cxx +++ b/src/mesh/impls/bout/boutmesh.cxx @@ -485,8 +485,18 @@ int BoutMesh::load() { } ASSERT0(MXG >= 0); - if (Mesh::get(MYG, "MYG") != 0) { - MYG = options["MYG"].doc("Number of guard cells on each side in Y").withDefault(2); + bool meshHasMyg = Mesh::get(MYG, "MYG") == 0; + int meshMyg; + if (!meshHasMyg) { + MYG = 2; + } else { + meshMyg = MYG; + } + MYG = options["MYG"].doc("Number of guard cells on each side in Y").withDefault(MYG); + if (meshHasMyg && MYG != meshMyg) { + output_warn.write(_("Options changed the number of y-guard cells. Grid has {} but " + "option specified {}! Continuing with {}"), + meshMyg, MYG, MYG); } ASSERT0(MYG >= 0); From 52708afb8ccc7f31729c27a201c925df1ffb9b3d Mon Sep 17 00:00:00 2001 From: David Bold Date: Mon, 3 Mar 2025 13:40:58 +0100 Subject: [PATCH 2/7] Only read `MYG` if it set or mesh:MYG is not set This avoids errors in the MMS tests --- src/mesh/impls/bout/boutmesh.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mesh/impls/bout/boutmesh.cxx b/src/mesh/impls/bout/boutmesh.cxx index 08df213126..acdcc5d0b0 100644 --- a/src/mesh/impls/bout/boutmesh.cxx +++ b/src/mesh/impls/bout/boutmesh.cxx @@ -492,7 +492,9 @@ int BoutMesh::load() { } else { meshMyg = MYG; } - MYG = options["MYG"].doc("Number of guard cells on each side in Y").withDefault(MYG); + if (options.isSet("MYG") or (!meshHasMyg)) { + MYG = options["MYG"].doc("Number of guard cells on each side in Y").withDefault(MYG); + } if (meshHasMyg && MYG != meshMyg) { output_warn.write(_("Options changed the number of y-guard cells. Grid has {} but " "option specified {}! Continuing with {}"), From 1e5f185d5753ca6171bc91b94a306adfeeaf9b80 Mon Sep 17 00:00:00 2001 From: David Bold Date: Mon, 3 Mar 2025 14:02:54 +0100 Subject: [PATCH 3/7] Do not set MYG/MXG if it is not needed --- tests/integrated/test-boutpp/mms-ddz/data/BOUT.inp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/integrated/test-boutpp/mms-ddz/data/BOUT.inp b/tests/integrated/test-boutpp/mms-ddz/data/BOUT.inp index d5ca4c4d71..519faa0403 100644 --- a/tests/integrated/test-boutpp/mms-ddz/data/BOUT.inp +++ b/tests/integrated/test-boutpp/mms-ddz/data/BOUT.inp @@ -1,7 +1,3 @@ - -MXG = 2 -MYG = 2 - [mesh] staggergrids = true n = 1 From 8267681fe80af7cc5ee0be12035ce5fb4a20dc91 Mon Sep 17 00:00:00 2001 From: David Bold Date: Mon, 3 Mar 2025 14:03:41 +0100 Subject: [PATCH 4/7] Do not set MYG/MXG if it is not needed --- tests/integrated/test-boutpp/collect/input/BOUT.inp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/integrated/test-boutpp/collect/input/BOUT.inp b/tests/integrated/test-boutpp/collect/input/BOUT.inp index d5ca4c4d71..519faa0403 100644 --- a/tests/integrated/test-boutpp/collect/input/BOUT.inp +++ b/tests/integrated/test-boutpp/collect/input/BOUT.inp @@ -1,7 +1,3 @@ - -MXG = 2 -MYG = 2 - [mesh] staggergrids = true n = 1 From 8d5cb39e03c2644715a50684f8cd0318b4e82676 Mon Sep 17 00:00:00 2001 From: dschwoerer <5637662+dschwoerer@users.noreply.github.com> Date: Tue, 3 Mar 2026 13:33:29 +0000 Subject: [PATCH 5/7] [bot] Apply format changes --- src/mesh/impls/bout/boutmesh.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mesh/impls/bout/boutmesh.cxx b/src/mesh/impls/bout/boutmesh.cxx index acdcc5d0b0..7f76d6efe0 100644 --- a/src/mesh/impls/bout/boutmesh.cxx +++ b/src/mesh/impls/bout/boutmesh.cxx @@ -497,8 +497,8 @@ int BoutMesh::load() { } if (meshHasMyg && MYG != meshMyg) { output_warn.write(_("Options changed the number of y-guard cells. Grid has {} but " - "option specified {}! Continuing with {}"), - meshMyg, MYG, MYG); + "option specified {}! Continuing with {}"), + meshMyg, MYG, MYG); } ASSERT0(MYG >= 0); From 0ba91f61cd2781bec1da5f29e04c830d5e95a4fc Mon Sep 17 00:00:00 2001 From: dschwoerer <5637662+dschwoerer@users.noreply.github.com> Date: Tue, 3 Mar 2026 13:33:30 +0000 Subject: [PATCH 6/7] [bot] Add last format changes commit to ignore file --- .git-blame-ignore-revs | 1 + 1 file changed, 1 insertion(+) diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index abd11c7762..4e7777ec58 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -11,3 +11,4 @@ a71cad2dd6ace5741a754e2ca7daacd4bb094e0e 2c2402ed59c91164eaff46dee0f79386b7347e9e 05b7c571544c3bcb153fce67d12b9ac48947fc2d c8f38049359170a34c915e209276238ea66b9a1e +8d5cb39e03c2644715a50684f8cd0318b4e82676 From a8c5ea82e28ee4cd903c15297792b1bdc939f62c Mon Sep 17 00:00:00 2001 From: David Bold Date: Wed, 4 Mar 2026 10:07:25 +0100 Subject: [PATCH 7/7] Cleanup code --- src/mesh/impls/bout/boutmesh.cxx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/mesh/impls/bout/boutmesh.cxx b/src/mesh/impls/bout/boutmesh.cxx index 7f76d6efe0..d0bdcf33d8 100644 --- a/src/mesh/impls/bout/boutmesh.cxx +++ b/src/mesh/impls/bout/boutmesh.cxx @@ -485,13 +485,12 @@ int BoutMesh::load() { } ASSERT0(MXG >= 0); - bool meshHasMyg = Mesh::get(MYG, "MYG") == 0; - int meshMyg; + const bool meshHasMyg = Mesh::get(MYG, "MYG") == 0; if (!meshHasMyg) { MYG = 2; - } else { - meshMyg = MYG; } + int meshMyg = MYG; + if (options.isSet("MYG") or (!meshHasMyg)) { MYG = options["MYG"].doc("Number of guard cells on each side in Y").withDefault(MYG); }