Initialize cached sync runtime in derived evolvers

This commit is contained in:
2026-05-01 18:34:43 +08:00
parent 35b6ceff02
commit db9383e439
5 changed files with 90 additions and 44 deletions

View File

@@ -113,20 +113,22 @@ void Z4c_class::Initialize()
else
GH->compose_cgh(nprocs);
#ifdef WithShell
SH = new ShellPatch(0, ngfs, pname, Symmetry, myrank, ErrorMonitor);
if (!checkrun)
SH->matchcheck(GH->PatL[0]);
#ifdef WithShell
SH = new ShellPatch(0, ngfs, pname, Symmetry, myrank, ErrorMonitor);
if (!checkrun)
SH->matchcheck(GH->PatL[0]);
SH->compose_sh(nprocs);
SH->setupcordtrans();
SH->Dump_xyz(0, 0, 1);
SH->setupintintstuff(nprocs, GH->PatL[0], Symmetry);
if (checkrun)
CheckPoint->readcheck_sh(SH, myrank);
#endif
double h = GH->PatL[0]->data->blb->data->getdX(0);
if (checkrun)
CheckPoint->readcheck_sh(SH, myrank);
#endif
Initialize_Level_Runtime();
double h = GH->PatL[0]->data->blb->data->getdX(0);
for (int i = 1; i < dim; i++)
h = Mymin(h, GH->PatL[0]->data->blb->data->getdX(i));
dT = Courant * h;

View File

@@ -232,19 +232,21 @@ void bssnEM_class::Initialize()
else
GH->compose_cgh(nprocs);
#ifdef WithShell
SH = new ShellPatch(0, ngfs, pname, Symmetry, myrank, ErrorMonitor);
SH->matchcheck(GH->PatL[0]);
#ifdef WithShell
SH = new ShellPatch(0, ngfs, pname, Symmetry, myrank, ErrorMonitor);
SH->matchcheck(GH->PatL[0]);
SH->compose_sh(nprocs);
SH->setupcordtrans();
SH->Dump_xyz(0, 0, 1);
SH->setupintintstuff(nprocs, GH->PatL[0], Symmetry);
if (checkrun)
CheckPoint->readcheck_sh(SH, myrank);
#endif
double h = GH->PatL[0]->data->blb->data->getdX(0);
if (checkrun)
CheckPoint->readcheck_sh(SH, myrank);
#endif
Initialize_Level_Runtime();
double h = GH->PatL[0]->data->blb->data->getdX(0);
for (int i = 1; i < dim; i++)
h = Mymin(h, GH->PatL[0]->data->blb->data->getdX(i));
dT = Courant * h;

View File

@@ -138,20 +138,22 @@ void bssnEScalar_class::Initialize()
else
GH->compose_cgh(nprocs);
#ifdef WithShell
SH = new ShellPatch(0, ngfs, pname, Symmetry, myrank, ErrorMonitor);
if (!checkrun)
SH->matchcheck(GH->PatL[0]);
#ifdef WithShell
SH = new ShellPatch(0, ngfs, pname, Symmetry, myrank, ErrorMonitor);
if (!checkrun)
SH->matchcheck(GH->PatL[0]);
SH->compose_sh(nprocs);
SH->setupcordtrans();
SH->Dump_xyz(0, 0, 1);
SH->setupintintstuff(nprocs, GH->PatL[0], Symmetry);
if (checkrun)
CheckPoint->readcheck_sh(SH, myrank);
#endif
double h = GH->PatL[0]->data->blb->data->getdX(0);
if (checkrun)
CheckPoint->readcheck_sh(SH, myrank);
#endif
Initialize_Level_Runtime();
double h = GH->PatL[0]->data->blb->data->getdX(0);
for (int i = 1; i < dim; i++)
h = Mymin(h, GH->PatL[0]->data->blb->data->getdX(i));
dT = Courant * h;

View File

@@ -784,6 +784,8 @@ bssn_class::bssn_class(double Couranti, double StartTimei, double TotalTimei,
xc(0), yc(0), zc(0), xr(0), yr(0), zr(0), trigger(0), dTT(0), dumpid(0),
#endif
a_lev(a_levi), maxl(maxli), decn(decni), maxrex(maxrexi), drex(drexi),
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),
CheckPoint(0)
// CheckPoint(0)
{
@@ -1409,6 +1411,38 @@ bssn_class::bssn_class(double Couranti, double StartTimei, double TotalTimei,
//================================================================================================
void bssn_class::Initialize_Level_Runtime()
{
if (!GH)
{
if (ErrorMonitor && ErrorMonitor->outfile)
ErrorMonitor->outfile << "Initialize_Level_Runtime called before GH is initialized" << endl;
MPI_Abort(MPI_COMM_WORLD, 1);
}
if (!ConstraintRefreshLevels)
{
ConstraintRefreshLevels = new int[GH->levels];
for (int il = 0; il < GH->levels; il++)
ConstraintRefreshLevels[il] = 0;
}
if (!sync_cache_pre)
sync_cache_pre = new Parallel::SyncCache[GH->levels];
if (!sync_cache_cor)
sync_cache_cor = new Parallel::SyncCache[GH->levels];
if (!sync_cache_rp_coarse)
sync_cache_rp_coarse = new Parallel::SyncCache[GH->levels];
if (!sync_cache_rp_fine)
sync_cache_rp_fine = new Parallel::SyncCache[GH->levels];
if (!sync_cache_restrict)
sync_cache_restrict = new Parallel::SyncCache[GH->levels];
if (!sync_cache_outbd)
sync_cache_outbd = new Parallel::SyncCache[GH->levels];
}
//================================================================================================
//================================================================================================
@@ -1439,9 +1473,6 @@ void bssn_class::Initialize()
}
}
GH = new cgh(0, ngfs, Symmetry, pname, checkrun, ErrorMonitor);
ConstraintRefreshLevels = new int[GH->levels];
for (int il = 0; il < GH->levels; il++)
ConstraintRefreshLevels[il] = 0;
if (checkrun)
CheckPoint->readcheck_cgh(PhysTime, GH, myrank, nprocs, Symmetry);
else
@@ -1477,13 +1508,7 @@ 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];
Initialize_Level_Runtime();
}
//================================================================================================
@@ -1762,6 +1787,18 @@ bssn_class::~bssn_class()
sync_cache_rp_fine[i].destroy();
delete[] sync_cache_rp_fine;
}
if (sync_cache_restrict)
{
for (int i = 0; i < GH->levels; i++)
sync_cache_restrict[i].destroy();
delete[] sync_cache_restrict;
}
if (sync_cache_outbd)
{
for (int i = 0; i < GH->levels; i++)
sync_cache_outbd[i].destroy();
delete[] sync_cache_outbd;
}
delete GH;
#ifdef WithShell

View File

@@ -178,14 +178,17 @@ public:
virtual void Initialize();
virtual void Read_Ansorg();
virtual void Read_Pablo() {};
virtual void Compute_Psi4(int lev);
virtual void Step(int lev, int YN);
virtual void Interp_Constraint(bool infg);
virtual void Constraint_Out();
virtual void Compute_Constraint();
#ifdef With_AHF
protected:
virtual void Compute_Psi4(int lev);
virtual void Step(int lev, int YN);
virtual void Interp_Constraint(bool infg);
virtual void Constraint_Out();
virtual void Compute_Constraint();
protected:
void Initialize_Level_Runtime();
#ifdef With_AHF
protected:
MyList<var> *AHList, *AHDList, *GaugeList;
int AHfindevery;
double AHdumptime;