Skip to content

Commit

Permalink
TestSubcyclingMC: add calculation of errors
Browse files Browse the repository at this point in the history
  • Loading branch information
lwJi committed Apr 15, 2024
1 parent f4e61d7 commit 2899e94
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
5 changes: 3 additions & 2 deletions TestSubcyclingMC/interface.ccl
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ CCTK_REAL energy CENTERING={CCC} TYPE=gf TAGS='checkpoint="no"'



CCTK_REAL uerror TYPE=gf CENTERING={vvv} TAGS='checkpoint="no"'
CCTK_REAL error TYPE=gf TAGS='checkpoint="no"'
{
u_err
} "Scalar wave error"
rho_err
} "Error in scalar wave state vector"
8 changes: 8 additions & 0 deletions TestSubcyclingMC/schedule.ccl
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,11 @@ SCHEDULE TestSubcyclingMC_CalcK4 IN TestSubcyclingMC_RK4Group AFTER TestSubcycli
WRITES: k4(interior) ustate(interior)
SYNC: ustate
} "Calculate k4"

SCHEDULE TestSybcyclingMC_Error AT poststep
{
LANG: C
READS: ustate(interior)
WRITES: error(interior)
SYNC: error
} "Calculate error in scalar wave state"
35 changes: 35 additions & 0 deletions TestSubcyclingMC/src/testsubcyclingmc.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -398,4 +398,39 @@ extern "C" void TestSubcyclingMC_Sync(CCTK_ARGUMENTS) {
// do nothing
}

extern "C" void TestSybcyclingMC_Error(CCTK_ARGUMENTS) {
DECLARE_CCTK_ARGUMENTSX_TestSybcyclingMC_Error;
DECLARE_CCTK_PARAMETERS;

CCTK_VINFO(" at time %g", cctk_time);

if (CCTK_EQUALS(initial_condition, "standing wave")) {

grid.loop_int_device<0, 0, 0>(
grid.nghostzones,
[=] CCTK_DEVICE(const Loop::PointDesc &p) CCTK_ATTRIBUTE_ALWAYS_INLINE {
CCTK_REAL u0, rho0;
standing_wave(amplitude, standing_wave_kx, standing_wave_ky,
standing_wave_kz, cctk_time, p.x, p.y, p.z, u0, rho0);
u_err(p.I) = u(p.I) - u0;
rho_err(p.I) = rho(p.I) - rho0;
});

} else if (CCTK_EQUALS(initial_condition, "Gaussian")) {

grid.loop_int_device<0, 0, 0>(
grid.nghostzones,
[=] CCTK_DEVICE(const Loop::PointDesc &p) CCTK_ATTRIBUTE_ALWAYS_INLINE {
CCTK_REAL u0, rho0;
gaussian(amplitude, gaussian_width, cctk_time, p.x, p.y, p.z, u0,
rho0);
u_err(p.I) = u(p.I) - u0;
rho_err(p.I) = rho(p.I) - rho0;
});

} else {
CCTK_ERROR("Unknown initial condition");
}
}

} // namespace TestSubcyclingMC

0 comments on commit 2899e94

Please sign in to comment.