MP-Gadget  5.0.1.dev1-76bc7d4726-dirty
Macros | Functions
gdbtools.c File Reference
#include <mpi.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "utils.h"
#include "partmanager.h"
Include dependency graph for gdbtools.c:

Go to the source code of this file.

Macros

#define add(fmt, ...)
 

Functions

int GDB_particle_by_id (MyIDType id, int from)
 
int GDB_particle_by_type (int type, int from)
 
int GDB_particle_by_generation (int gen, int from)
 
char * GDB_particle_by_timebin (int bin)
 
int GDB_find_garbage (int from)
 
char * GDB_format_particle (int i)
 

Macro Definition Documentation

◆ add

#define add (   fmt,
  ... 
)
Value:
snprintf(p, n - 1, fmt, __VA_ARGS__ ); \
p = buf + strlen(buf); \
n = 4096 - strlen(buf)

Function Documentation

◆ GDB_find_garbage()

int GDB_find_garbage ( int  from)

Definition at line 50 of file gdbtools.c.

50  {
51  int i;
52  for(i = from; i < PartManager->NumPart; i++) {
53  if(P[i].IsGarbage) return i;
54  }
55  return -1;
56 }
struct part_manager_type PartManager[1]
Definition: partmanager.c:11
#define P
Definition: partmanager.h:88

References part_manager_type::NumPart, P, and PartManager.

◆ GDB_format_particle()

char* GDB_format_particle ( int  i)

Definition at line 58 of file gdbtools.c.

58  {
59  static char buf[1024];
60  char * p = buf;
61  int n = 1024;
62 
63 #define add(fmt, ...) \
64  snprintf(p, n - 1, fmt, __VA_ARGS__ ); \
65  p = buf + strlen(buf); \
66  n = 4096 - strlen(buf)
67 
68  add("P[%d]: ", i);
69  add("ID : %ld ", P[i].ID);
70  add("Generation: %d ", (int) P[i].Generation);
71  add("Mass : %g ", P[i].Mass);
72  add("Pos: %g %g %g ", P[i].Pos[0], P[i].Pos[1], P[i].Pos[2]);
73  add("Vel: %g %g %g ", P[i].Vel[0], P[i].Vel[1], P[i].Vel[2]);
74  add("GravAccel: %g %g %g ", P[i].GravAccel[0], P[i].GravAccel[1], P[i].GravAccel[2]);
75  add("GravPM: %g %g %g ", P[i].GravPM[0], P[i].GravPM[1], P[i].GravPM[2]);
76  return buf;
77 }
#define add(fmt,...)
static struct gravpm_params GravPM

References add, GravPM, and P.

Referenced by run_gravity_test().

Here is the caller graph for this function:

◆ GDB_particle_by_generation()

int GDB_particle_by_generation ( int  gen,
int  from 
)

Definition at line 28 of file gdbtools.c.

28  {
29  int i;
30  for(i = from; i < PartManager->NumPart; i++) {
31  if(P[i].Generation == gen) return i;
32  }
33  return -1;
34 }

References part_manager_type::NumPart, P, and PartManager.

◆ GDB_particle_by_id()

int GDB_particle_by_id ( MyIDType  id,
int  from 
)

Definition at line 12 of file gdbtools.c.

12  {
13  int i;
14  for(i = from; i < PartManager->NumPart; i++) {
15  if(P[i].ID == id) return i;
16  }
17  return -1;
18 }

References part_manager_type::NumPart, P, and PartManager.

◆ GDB_particle_by_timebin()

char* GDB_particle_by_timebin ( int  bin)

Definition at line 36 of file gdbtools.c.

36  {
37  int i;
38  static char buf[1024];
39  char tmp[20] = {'\0'};
40  strcpy(buf, "");
41  for(i = 0; i < PartManager->NumPart; i++) {
42  if(P[i].TimeBin == bin) {
43  snprintf(tmp, 15, " %d", i);
44  strncat(buf, tmp, 1024-strlen(tmp)-1);
45  }
46  }
47  return buf;
48 }

References part_manager_type::NumPart, P, and PartManager.

◆ GDB_particle_by_type()

int GDB_particle_by_type ( int  type,
int  from 
)

Definition at line 20 of file gdbtools.c.

20  {
21  int i;
22  for(i = from; i < PartManager->NumPart; i++) {
23  if(P[i].Type == type) return i;
24  }
25  return -1;
26 }

References part_manager_type::NumPart, P, and PartManager.