29 #pragma omp parallel for reduction(+: meanacc)
34 PairAccn[i][k] =
P[i].GravPM[k] +
P[i].GravAccel[k];
35 meanacc += fabs(PairAccn[i][k]);
40 MPI_Allreduce(MPI_IN_PLACE, &meanacc, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
41 meanacc/= (tot_npart*3.);
45 void check_accns(
double * meanerr_tot,
double * maxerr_tot,
double (*PairAccn)[3],
double meanacc)
47 double meanerr=0, maxerr=-1;
50 #pragma omp parallel for reduction(+: meanerr) reduction(max:maxerr)
56 if(PairAccn[i][k] != 0)
57 err = fabs((PairAccn[i][k] - (
P[i].
GravPM[k] +
P[i].GravAccel[k]))/meanacc);
63 MPI_Allreduce(&meanerr, meanerr_tot, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
64 MPI_Allreduce(&maxerr, maxerr_tot, 1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD);
67 *meanerr_tot/= (tot_npart*3.);
87 MPI_Comm_size(MPI_COMM_WORLD, &
NTask);
113 double meanerr, maxerr;
115 message(0,
"Force error, open tree vs pairwise. max : %g mean: %g forcetol: %g\n", maxerr, meanerr, treeacc.
ErrTolForceAcc);
118 endrun(2,
"Fully open tree force does not agree with pairwise calculation! maxerr %g > 0.1!\n", maxerr);
127 treeacc = origtreeacc;
137 message(0,
"Force error, open tree vs tree.: %g mean: %g forcetol: %g\n", maxerr, meanerr, treeacc.
ErrTolForceAcc);
140 endrun(2,
"Average force error is underestimated: %g > 1.2 * %g!\n", meanerr, treeacc.
ErrTolForceAcc);
152 message(0,
"Force error, tree vs rcut.: %g mean: %g Rcut = %g\n", maxerr, meanerr, treeacc.
Rcut);
155 endrun(2,
"Rcut decreased below desired value, error too large %g\n", maxerr);
158 treeacc = origtreeacc;
174 message(0,
"Force error, nmesh %d vs %d: %g mean: %g \n", Nmesh, Nmesh/2, maxerr, meanerr);
176 if(maxerr > 0.5 || meanerr > 0.05)
177 endrun(2,
"Nmesh sensitivity worse, something may be wrong\n");
void domain_free(DomainDecomp *ddecomp)
void domain_decompose_full(DomainDecomp *ddecomp)
void message(int where, const char *fmt,...)
void endrun(int where, const char *fmt,...)
void force_tree_rebuild(ForceTree *tree, DomainDecomp *ddecomp, const int HybridNuGrav, const int DoMoments, const char *EmergencyOutputDir)
void force_tree_free(ForceTree *tree)
struct gravshort_tree_params get_gravshort_treepar(void)
void grav_short_pair(const ActiveParticles *act, PetaPM *pm, ForceTree *tree, double Rcut, double rho0, int NeutrinoTracer, int FastParticleType)
void set_gravshort_treepar(struct gravshort_tree_params tree_params)
void gravpm_force(PetaPM *pm, ForceTree *tree, Cosmology *CP, double Time, double UnitLength_in_cm, const char *PowerOutputDir, double TimeIC, int FastParticleType)
void grav_short_tree(const ActiveParticles *act, PetaPM *pm, ForceTree *tree, double rho0, int NeutrinoTracer, int FastParticleType)
void gravpm_init_periodic(PetaPM *pm, double BoxSize, double Asmth, int Nmesh, double G)
static struct gravpm_params GravPM
#define mymalloc2(name, size)
struct part_manager_type PartManager[1]
void destroy_io_blocks(struct IOTable *IOTable)
void register_io_blocks(struct IOTable *IOTable, int WriteGroupID, int MetalReturnOn)
void petaio_save_snapshot(const char *fname, struct IOTable *IOTable, int verbose, const double atime, const Cosmology *CP)
#define SIMPLE_GETTER(name, field, type, items, stype)
#define IO_REG_WRONLY(name, dtype, items, ptype, IOTable)
void petapm_destroy(PetaPM *pm)
void check_accns(double *meanerr_tot, double *maxerr_tot, double(*PairAccn)[3], double meanacc)
void register_extra_blocks(struct IOTable *IOTable)
double copy_and_mean_accn(double(*PairAccn)[3])
char * GDB_format_particle(int i)
void run_gravity_test(int RestartSnapNum, Cosmology *CP, const double Asmth, const int Nmesh, const int FastParticleType, const inttime_t Ti_Current, const char *OutputDir, const struct header_data *header)
char * fastpm_strdup_printf(const char *fmt,...)
DriftKickTimes init_driftkicktime(inttime_t Ti_Current)
int rebuild_activelist(ActiveParticles *act, const DriftKickTimes *const times, int NumCurrentTiStep, const double Time)
static enum TransferType ptype