Stabilize and wire BSSN-EScalar C path

This commit is contained in:
2026-04-25 00:08:35 +08:00
parent b57d80ca61
commit 0f1d0de1e7
6 changed files with 731 additions and 369 deletions

View File

@@ -280,9 +280,9 @@ namespace rhs_kernel_timing_report
//================================================================================================
bssn_class::bssn_class(double Couranti, double StartTimei, double TotalTimei,
double DumpTimei, double d2DumpTimei, double CheckTimei, double AnasTimei,
int Symmetryi, int checkruni, char *checkfilenamei,
bssn_class::bssn_class(double Couranti, double StartTimei, double TotalTimei,
double DumpTimei, double d2DumpTimei, double CheckTimei, double AnasTimei,
int Symmetryi, int checkruni, char *checkfilenamei,
double numepssi, double numepsbi, double numepshi,
int a_levi, int maxli, int decni, double maxrexi, double drexi)
: Courant(Couranti), StartTime(StartTimei), TotalTime(TotalTimei),
@@ -295,12 +295,34 @@ bssn_class::bssn_class(double Couranti, double StartTimei, double TotalTimei,
ConstraintRefreshLevels(0),
CheckPoint(0)
// CheckPoint(0)
{
MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
// setup Monitors
{
{
MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
// Derived classes override Initialize(), so ownership-sensitive members must
// be in a known state before any specialized setup path runs.
GH = 0;
SH = 0;
PhysTime = 0.0;
BH_num = 0;
BH_num_input = 0;
Porg0 = 0;
Porgbr = 0;
Porg = 0;
Porg1 = 0;
Porg_rhs = 0;
Mass = 0;
Pmom = 0;
Spin = 0;
sync_cache_pre = 0;
sync_cache_cor = 0;
sync_cache_rp_coarse = 0;
sync_cache_rp_fine = 0;
sync_cache_restrict = 0;
sync_cache_outbd = 0;
// setup Monitors
{
stringstream a_stream;
a_stream.setf(ios::left);
a_stream << "# Error log information";
@@ -986,13 +1008,21 @@ void bssn_class::Initialize()
Setup_Black_Hole_position();
}
// Initialize sync caches (per-level, for predictor and corrector)
sync_cache_pre = new Parallel::SyncCache[GH->levels];
sync_cache_cor = new Parallel::SyncCache[GH->levels];
sync_cache_rp_coarse = new Parallel::SyncCache[GH->levels];
sync_cache_rp_fine = new Parallel::SyncCache[GH->levels];
sync_cache_restrict = new Parallel::SyncCache[GH->levels];
sync_cache_outbd = new Parallel::SyncCache[GH->levels];
// BSSN-EScalar uses the uncached communication fallback paths.
sync_cache_pre = 0;
sync_cache_cor = 0;
sync_cache_rp_coarse = 0;
sync_cache_rp_fine = 0;
sync_cache_restrict = 0;
sync_cache_outbd = 0;
#if (ABEtype != 1)
sync_cache_pre = new Parallel::SyncCache[GH->levels];
sync_cache_cor = new Parallel::SyncCache[GH->levels];
sync_cache_rp_coarse = new Parallel::SyncCache[GH->levels];
sync_cache_rp_fine = new Parallel::SyncCache[GH->levels];
sync_cache_restrict = new Parallel::SyncCache[GH->levels];
sync_cache_outbd = new Parallel::SyncCache[GH->levels];
#endif
}
//================================================================================================
@@ -1005,9 +1035,16 @@ void bssn_class::Initialize()
//================================================================================================
bssn_class::~bssn_class()
{
#ifdef With_AHF
bssn_class::~bssn_class()
{
#if (ABEtype == 1)
if (myrank == 0)
{
cout << "[dtor] begin" << endl;
cout.flush();
}
#endif
#ifdef With_AHF
AHList->clearList();
AHDList->clearList();
GaugeList->clearList();
@@ -1041,6 +1078,13 @@ bssn_class::~bssn_class()
ConstraintList->clearList();
delete[] ConstraintRefreshLevels;
#if (ABEtype == 1)
if (myrank == 0)
{
cout << "[dtor] lists cleared" << endl;
cout.flush();
}
#endif
delete phio;
delete trKo;
@@ -1216,8 +1260,15 @@ bssn_class::~bssn_class()
delete Cons_Py;
delete Cons_Pz;
delete Cons_Gx;
delete Cons_Gy;
delete Cons_Gz;
delete Cons_Gy;
delete Cons_Gz;
#if (ABEtype == 1)
if (myrank == 0)
{
cout << "[dtor] core vars freed" << endl;
cout.flush();
}
#endif
#ifdef Point_Psi4
delete phix;
@@ -1247,35 +1298,73 @@ bssn_class::~bssn_class()
#endif
// Destroy sync caches before GH
if (sync_cache_pre)
{
for (int i = 0; i < GH->levels; i++)
sync_cache_pre[i].destroy();
delete[] sync_cache_pre;
}
if (sync_cache_cor)
{
for (int i = 0; i < GH->levels; i++)
sync_cache_cor[i].destroy();
delete[] sync_cache_cor;
}
if (sync_cache_rp_coarse)
{
for (int i = 0; i < GH->levels; i++)
sync_cache_rp_coarse[i].destroy();
delete[] sync_cache_rp_coarse;
}
if (sync_cache_rp_fine)
{
for (int i = 0; i < GH->levels; i++)
sync_cache_rp_fine[i].destroy();
delete[] sync_cache_rp_fine;
}
delete GH;
#ifdef WithShell
delete SH;
#endif
if (sync_cache_pre)
{
#if (ABEtype != 1)
for (int i = 0; i < GH->levels; i++)
sync_cache_pre[i].destroy();
#endif
delete[] sync_cache_pre;
}
if (sync_cache_cor)
{
#if (ABEtype != 1)
for (int i = 0; i < GH->levels; i++)
sync_cache_cor[i].destroy();
#endif
delete[] sync_cache_cor;
}
if (sync_cache_rp_coarse)
{
#if (ABEtype != 1)
for (int i = 0; i < GH->levels; i++)
sync_cache_rp_coarse[i].destroy();
#endif
delete[] sync_cache_rp_coarse;
}
if (sync_cache_rp_fine)
{
#if (ABEtype != 1)
for (int i = 0; i < GH->levels; i++)
sync_cache_rp_fine[i].destroy();
#endif
delete[] sync_cache_rp_fine;
}
if (sync_cache_restrict)
{
#if (ABEtype != 1)
for (int i = 0; i < GH->levels; i++)
sync_cache_restrict[i].destroy();
#endif
delete[] sync_cache_restrict;
}
if (sync_cache_outbd)
{
#if (ABEtype != 1)
for (int i = 0; i < GH->levels; i++)
sync_cache_outbd[i].destroy();
#endif
delete[] sync_cache_outbd;
}
#if (ABEtype == 1)
if (myrank == 0)
{
cout << "[dtor] caches freed" << endl;
cout.flush();
}
#endif
delete GH;
#ifdef WithShell
delete SH;
#endif
#if (ABEtype == 1)
if (myrank == 0)
{
cout << "[dtor] grids freed" << endl;
cout.flush();
}
#endif
for (int i = 0; i < BH_num; i++)
{
@@ -1292,20 +1381,41 @@ bssn_class::~bssn_class()
delete[] Porg1;
delete[] Porg_rhs;
delete[] Mass;
delete[] Spin;
delete[] Pmom;
delete ErrorMonitor;
delete Psi4Monitor;
delete[] Mass;
delete[] Spin;
delete[] Pmom;
#if (ABEtype == 1)
if (myrank == 0)
{
cout << "[dtor] puncture arrays freed" << endl;
cout.flush();
}
#endif
delete ErrorMonitor;
delete Psi4Monitor;
delete BHMonitor;
delete MAPMonitor;
delete ConVMonitor;
delete TimingMonitor;
delete Waveshell;
delete CheckPoint;
}
#if (ABEtype == 1)
if (myrank == 0)
{
cout << "[dtor] monitors freed" << endl;
cout.flush();
}
#endif
delete CheckPoint;
#if (ABEtype == 1)
if (myrank == 0)
{
cout << "[dtor] checkpoint freed" << endl;
cout.flush();
}
#endif
}
//================================================================================================