Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maintain sanity (or madness) #165

Merged
merged 28 commits into from
May 4, 2023
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
e82a155
First attempt
brryan Mar 30, 2023
90645c0
Merge branch 'main' of github.com:lanl/phoebus into brryan/maintain_s…
brryan Apr 18, 2023
32f4655
First attempt
brryan Apr 18, 2023
884a4da
sing?
brryan Apr 18, 2023
1910658
This is better maybe it even works
brryan Apr 18, 2023
35ce897
Fix bug in A
brryan Apr 19, 2023
9a5e2f4
start time for phi adjustment
brryan Apr 19, 2023
96bce20
phi not Phi
brryan Apr 19, 2023
e495489
Formatting
brryan Apr 19, 2023
2186e97
Update torus input file
brryan Apr 19, 2023
abfff6a
Cleanup
brryan Apr 19, 2023
6602af1
Hopefully fix CI
brryan Apr 20, 2023
047a8ae
Have gold_comparison in regression_test provide more (any) informatio…
brryan Apr 27, 2023
54529db
Test of git with vscode
brryan Apr 27, 2023
da90bf9
Merge branch 'brryan/maintain_sanity' of github.com:lanl/phoebus into…
brryan Apr 27, 2023
5f95e36
Working on net field tasking
brryan Apr 27, 2023
29d7281
First pass seems to work with new machinery
brryan Apr 28, 2023
fce5dc1
Better dphi_dt damper
brryan Apr 28, 2023
fd227af
history geom bugfix
brryan Apr 28, 2023
a37c8fa
working pre-formatting
brryan Apr 28, 2023
02c0f1c
Merge branch 'main' of github.com:lanl/phoebus into brryan/maintain_s…
brryan May 2, 2023
36dd811
Properly deal with phoedf geom issue
brryan May 2, 2023
9f7883b
Back to main versions of submodules
brryan May 2, 2023
dec72de
More general ghost cell removal
brryan May 2, 2023
4c490e1
Remove unused variable
brryan May 2, 2023
780b9ea
Remove unnecessary check
brryan May 3, 2023
09ed3a5
No default value for enforced phi
brryan May 3, 2023
c3bfe65
Only set other phi enforcement values if active
brryan May 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Cleanup
brryan committed Apr 19, 2023
commit abfff6aba415dce3c90b5c8f855e0a8288118c67
38 changes: 1 addition & 37 deletions src/fixup/fixup.cpp
Original file line number Diff line number Diff line change
@@ -710,7 +710,6 @@ TaskStatus EndOfStepModify(MeshData<Real> *md, const Real t, const Real dt,
// Update B field
parthenon::par_for(
parthenon::LoopPatternMDRange(), "Phoebus::Fixup::EndOfStepModify::EvaluateQ",
// DevExecSpace(), 0, pack.GetDim(5) - 1, jb.s + 1, jb.e, ib.s + 1, ib.e,
DevExecSpace(), 0, pack.GetDim(5) - 1, jb.s, jb.e + 1, ib.s, ib.e + 1,
KOKKOS_LAMBDA(const int b, const int j, const int i) {
const auto &coords = pack.GetCoords(b);
@@ -719,10 +718,6 @@ TaskStatus EndOfStepModify(MeshData<Real> *md, const Real t, const Real dt,
const Real r = tr.bl_radius(x1);
const Real th = tr.bl_theta(x1, x2);

// if (i == 10) {
// printf("[%i %i %i] r: %e th: %e\n", 0,j,i,r,th);
//}

const Real x = r * sin(th);
const Real z = r * cos(th);
const Real a_hyp = 1.2;
@@ -732,9 +727,6 @@ TaskStatus EndOfStepModify(MeshData<Real> *md, const Real t, const Real dt,
if (x < x_hyp) {
A(b, j, i) = q;
}
// if (i == 10) {
// printf("[%i %i %i] r: %e th: %e A = %e\n", 0,j,i,r,th, A(b,j,i));
// }
});

// Recalculate dphi_dt occasionally
@@ -748,14 +740,10 @@ TaskStatus EndOfStepModify(MeshData<Real> *md, const Real t, const Real dt,
// Measure phi
const Real phi_proc = History::ReduceMagneticFluxPhi(md);
const Real phi = reduction::Sum(phi_proc) / std::sqrt(mdot);
// printf("Original phi: %e\n", phi);

// Calculate amount of phi to add this timestep
const Real dphi =
(enforced_phi - phi) * dt / enforced_phi_timescale; //*enforced_phi_cadence;
const Real dphi = (enforced_phi - phi) * dt / enforced_phi_timescale;
dphi_dt = dphi / dt;
// printf("dphi: %e\n", dphi);
// printf("dphi_dt: %e\n", dphi_dt);

parthenon::par_for(
parthenon::LoopPatternMDRange(),
@@ -779,10 +767,7 @@ TaskStatus EndOfStepModify(MeshData<Real> *md, const Real t, const Real dt,
// Measure change in phi
const Real fiducial_phi_proc = History::ReduceMagneticFluxPhi(md);
const Real fiducial_phi = reduction::Sum(fiducial_phi_proc) / std::sqrt(mdot);
// printf("here! phi: %e\n", fiducial_phi);
phi_factor = dphi / (fiducial_phi - phi) / dt;
// printf("phi_factor: %e\n", phi_factor);
// exit(-1);

// Remove the fiducial contribution
parthenon::par_for(
@@ -805,11 +790,7 @@ TaskStatus EndOfStepModify(MeshData<Real> *md, const Real t, const Real dt,
});
}

// Temporary!!
// phi_factor = 1.e5;

// Properly update B field
// printf("fac: %e\n", phi_factor*dt);
parthenon::par_for(
parthenon::LoopPatternMDRange(),
"Phoebus::Fixup::EndOfStepModify::EvaluateBField", DevExecSpace(), 0,
@@ -818,12 +799,6 @@ TaskStatus EndOfStepModify(MeshData<Real> *md, const Real t, const Real dt,
const auto &coords = pack.GetCoords(b);
const Real gammadet = geom.DetGamma(CellLocation::Cent, b, k, j, i);

// if (i == 10) {
// printf("[%i %i %i]\n", k, j, i);
// printf(" before b: %e %e %e\n", pack(b, pblo, k, j, i),
// pack(b, pblo+1, k, j, i), pack(b, pblo+2, k, j, i));
// }

pack(b, pblo, k, j, i) +=
phi_factor * dt *
(-(A(b, j, i) - A(b, j + 1, i) + A(b, j, i + 1) - A(b, j + 1, i + 1)) /
@@ -832,17 +807,6 @@ TaskStatus EndOfStepModify(MeshData<Real> *md, const Real t, const Real dt,
phi_factor * dt *
((A(b, j, i) + A(b, j + 1, i) - A(b, j, i + 1) - A(b, j + 1, i + 1)) /
(2.0 * coords.CellWidthFA(X1DIR, k, j, i) * gammadet));

// if (i == 10) {
// printf(" after b: %e %e %e\n", pack(b, pblo, k, j, i),
// pack(b, pblo+1, k, j, i), pack(b, pblo+2, k, j, i));
// }

// if (i == 5 && j == 5) {
// printf("b: %e %e %e\n", pack(b, pblo, k, j, i), pack(b, pblo+1, k, j,
// i),
/// pack(b, pblo+2, k, j, i));
// }
});
} // enforced_phi_start_time
} // enable_phi_enforcement
22 changes: 0 additions & 22 deletions src/phoebus_driver.cpp
Original file line number Diff line number Diff line change
@@ -637,28 +637,6 @@ TaskCollection PhoebusDriver::RungeKuttaStage(const int stage) {
}
}

//// Extra per-step user work
// TaskRegion &sync_region_5 = tc.AddRegion(num_partitions);
// PARTHENON_REQUIRE(num_partitions == 1, "Reductions don't work for multiple
// partitions?"); for (int i = 0; i < num_partitions; i++) {
// auto &tl = sync_region_5[i];

// auto &md = pmesh->mesh_data.GetOrAdd(stage_name[stage], i);

// auto end_mods = tl.AddTask(none, fixup::EndOfStepModify, md.get(), t, dt,
// stage==integrator->nstages);

//}
//// This is a bad pattern. Having a per-mesh data p2c would help.
// TaskRegion &async_region_4 = tc.AddRegion(num_independent_task_lists);
// for (int i = 0; i < blocks.size(); i++) {
// auto &pmb = blocks[i];
// auto &tl = async_region_3[i];
// auto &sc = pmb->meshblock_data.Get(stage_name[stage]);

// auto p2c = tl.AddTask(none, PrimitiveToConserved, sc);
//}

return tc;
} // namespace phoebus