13 #include <gsl/gsl_rng.h>
63 #define NODECACHE_SIZE 100
69 double * oldmass = malloc(
sizeof(
double) * tb->
numnodes);
76 for(i=0; i<numpart; i++)
80 assert_true(fnode >= tb->
firstnode && fnode < tb->lastnode);
85 assert_true((fnode >= tb->
firstnode && fnode < tb->lastnode) || fnode == -1);
93 assert_true(node >= -1 && node < tb->lastnode && node >= tb->
firstnode);
103 if(sfather !=
father && sib != -1) {
111 assert_int_equal(ances, sfather);
118 printf(
"node %d (%d) mass %g / %g TL %d DLM %d ITL %d\n",
127 int nn = nop->
s.
suns[i];
128 printf(
"particles P[%d], Mass=%g\n", nn,
P[nn].Mass);
140 node = nop->
s.
suns[0];
143 assert_true(counter <= nrealnode);
144 assert_true(sibcntr < counter/100);
156 int tot_empty = 0, nrealnode = 0, sevens = 0;
158 for(i=firstnode; i<nnodes+firstnode; i++)
172 int child = pNode->
s.
suns[j];
173 assert_true(child >= 0);
174 assert_true(child < firstnode);
183 int child = pNode->
s.
suns[j];
184 assert_true(child < firstnode+nnodes);
185 assert_true(child >= firstnode);
186 assert_true(fabs(tb->
Nodes[child].
len/pNode->
len - 0.5) < 1e-4);
199 for(i=0; i<numpart; i++)
201 assert_int_equal(
P[i].PI, 1);
203 printf(
"Tree filling factor: %g on %d nodes (wasted: %d empty: %d)\n", tot_empty/(8.*nrealnode), nrealnode, nnodes - nrealnode, sevens);
204 return nrealnode - sevens;
211 #pragma omp parallel for
212 for(i=0; i<numpart; i++) {
222 assert_true(tb.
Nodes != NULL);
224 for(i=0; i< maxnode; i++)
231 assert_true(nodes < maxnode);
233 double ms = (end - start)*1000;
234 printf(
"Number of nodes used: %d. Built tree in %.3g ms\n", nodes,ms);
235 int nrealnode =
check_tree(&tb, nodes, numpart);
240 ms = (end - start)*1000;
249 int numpart = ncbrt*ncbrt*ncbrt;
254 #pragma omp parallel for
255 for(i=0; i<numpart; i++) {
279 int numpart = ncbrt*ncbrt*ncbrt;
284 #pragma omp parallel for
285 for(i=0; i<numpart; i++) {
287 P[i].Pos[0] = 4. + (i/ncbrt/ncbrt)/close;
288 P[i].Pos[1] = 4. + ((i/ncbrt) % ncbrt) /close;
289 P[i].Pos[2] = 4. + (i % ncbrt)/close;
305 for(i=0; i<numpart/4; i++) {
311 for(i=numpart/4; i<3*numpart/4; i++) {
317 for(i=3*numpart/4; i<numpart; i++) {
331 gsl_rng *
r = (gsl_rng *) data->
r;
332 int numpart = ncbrt*ncbrt*ncbrt;
337 assert_true(tb.Nodes != NULL);
381 data->
r = gsl_rng_alloc(gsl_rng_mt19937);
382 gsl_rng_set(data->
r, 0);
383 *state = (
void *) data;
398 const struct CMUnitTest tests[] = {
int force_tree_create_nodes(const ForceTree tb, const int npart, int mask, DomainDecomp *ddecomp, const int HybridNuGrav)
ForceTree force_treeallocate(int64_t maxnodes, int64_t maxpart, DomainDecomp *ddecomp)
void force_update_node_parallel(const ForceTree *tree, const DomainDecomp *ddecomp)
void init_forcetree_params(const int FastParticleType)
void force_tree_free(ForceTree *tree)
int force_get_father(int no, const ForceTree *tree)
#define PARTICLE_NODE_TYPE
static peano_t PEANO(double *Pos, double BoxSize)
#define BITS_PER_DIMENSION
struct topnode_data * TopNodes
struct topleaf_data * TopLeaves
int domain_allocated_flag
unsigned int DependsOnLocalMass
unsigned int InternalTopLevel
static void test_rebuild_flat(void **state)
static void test_rebuild_close(void **state)
struct part_manager_type PartManager[1]
double walltime_measure_full(char *name, char *file, int line)
static void do_tree_test(const int numpart, ForceTree tb, DomainDecomp *ddecomp)
static int setup_tree(void **state)
struct slots_manager_type SlotsManager[1]
static int order_by_type_and_key(const void *a, const void *b)
void trivial_domain(DomainDecomp *ddecomp)
static int check_moments(const ForceTree *tb, const int numpart, const int nrealnode)
static int teardown_tree(void **state)
static int check_tree(const ForceTree *tb, const int nnodes, const int numpart)
void do_random_test(gsl_rng *r, const int numpart, const ForceTree tb, DomainDecomp *ddecomp)
static void test_rebuild_random(void **state)