12#include "gadgetconfig.h"
16#include <gsl/gsl_rng.h>
21#include "../data/allvars.h"
22#include "../data/dtypes.h"
23#include "../data/intposconvert.h"
24#include "../data/mymalloc.h"
25#include "../logs/timer.h"
26#include "../main/simulation.h"
27#include "../mpi_utils/mpi_utils.h"
28#include "../ngenic/ngenic.h"
29#include "../system/system.h"
31void ngenic::create_grid(
void)
33 long long gridSize =
All.GridSize;
34 long long partTotal = gridSize * gridSize * gridSize;
35 long long partPerTask = partTotal / NTask;
45 double m = masstot / (partTotal);
47 for(
int i = 0; i <
NTYPES; i++)
53 Sp->NumPart = partPerTask;
55 if(ThisTask == NTask - 1)
57 Sp->NumPart = partTotal - Sp->NumPart * (NTask - 1);
60 int max_load, max_sphload;
61 MPI_Allreduce(&Sp->NumPart, &max_load, 1, MPI_INT, MPI_MAX, Communicator);
62 MPI_Allreduce(&Sp->NumGas, &max_sphload, 1, MPI_INT, MPI_MAX, Communicator);
64#ifdef GENERATE_GAS_IN_ICS
65 Sp->TotNumGas = partTotal;
66 Sp->TotNumPart = 2 * partTotal;
67 max_sphload = max_load;
70 Sp->TotNumPart = partTotal;
77 Sp->allocate_memory();
79 for(
int i = 0; i < Sp->NumPart; i++)
81 long long ipcell = ThisTask * partPerTask + i;
82 int x = ipcell / (
All.GridSize *
All.GridSize);
83 int xr = ipcell % (
All.GridSize *
All.GridSize);
84 int y = xr /
All.GridSize;
85 int z = xr %
All.GridSize;
92 Sp->pos_to_intpos(xyz, Sp->P[i].IntPos);
98 Sp->P[i].ID.set(ipcell + 1);
103 mpi_printf(
"NGENIC: generated grid of size %d\n",
All.GridSize);
global_data_all_processes All
#define BITS_FOR_POSITIONS
expr pow(half base, half exp)