proxy.h 3.46 KB
Newer Older
1
2
/*******************************************************************************
 * This file is part of SWIFT.
3
 * Copyright (c) 2013 Pedro Gonnet (pedro.gonnet@durham.ac.uk)
4
 *
5
6
7
8
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
9
 *
10
11
12
13
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
14
 *
15
16
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
 *
18
 ******************************************************************************/
19
20
#ifndef SWIFT_PROXY_H
#define SWIFT_PROXY_H
21

22
/* Includes. */
23
#include "cell.h"
24
#include "part.h"
25

26
/* Some constants. */
27
28
#define proxy_buffgrow 1.5
#define proxy_buffinit 100
29
30

/* Proxy tag arithmetic. */
31
32
33
34
#define proxy_tag_shift 8
#define proxy_tag_count 0
#define proxy_tag_parts 1
#define proxy_tag_xparts 2
Pedro Gonnet's avatar
Pedro Gonnet committed
35
#define proxy_tag_gparts 3
36
37
#define proxy_tag_sparts 4
#define proxy_tag_cells 5
38

39
40
41
42
43
/**
 * @brief The different reasons a cell can be in a proxy
 */
enum proxy_cell_type {
  proxy_cell_type_none = 0,
Matthieu Schaller's avatar
Matthieu Schaller committed
44
45
  proxy_cell_type_hydro = (1 << 0),
  proxy_cell_type_gravity = (1 << 1)
46
47
};

48
49
50
/* Data structure for the proxy. */
struct proxy {

51
52
53
  /* ID of the node this proxy represents. */
  int mynodeID, nodeID;

54
  /* Incoming cells. */
55
  struct cell **cells_in;
56
  char *cells_in_type;
57
58
  struct pcell *pcells_in;
  int nr_cells_in, size_cells_in, size_pcells_in;
59

60
61
  /* Outgoing cells. */
  struct cell **cells_out;
62
  char *cells_out_type;
63
64
65
66
67
68
  struct pcell *pcells_out;
  int nr_cells_out, size_cells_out, size_pcells_out;

  /* The parts and xparts buffers for input and output. */
  struct part *parts_in, *parts_out;
  struct xpart *xparts_in, *xparts_out;
69
  struct gpart *gparts_in, *gparts_out;
70
  struct spart *sparts_in, *sparts_out;
71
72
  int size_parts_in, size_parts_out;
  int nr_parts_in, nr_parts_out;
73
74
  int size_gparts_in, size_gparts_out;
  int nr_gparts_in, nr_gparts_out;
75
76
  int size_sparts_in, size_sparts_out;
  int nr_sparts_in, nr_sparts_out;
Pedro Gonnet's avatar
Pedro Gonnet committed
77

78
  /* Buffer to hold the incomming/outgoing particle counts. */
79
  int buff_out[3], buff_in[3];
80
81
82
83
84
85

/* MPI request handles. */
#ifdef WITH_MPI
  MPI_Request req_parts_count_out, req_parts_count_in;
  MPI_Request req_parts_out, req_parts_in;
  MPI_Request req_xparts_out, req_xparts_in;
86
  MPI_Request req_gparts_out, req_gparts_in;
87
  MPI_Request req_sparts_out, req_sparts_in;
88
89
90
91
  MPI_Request req_cells_count_out, req_cells_count_in;
  MPI_Request req_cells_out, req_cells_in;
#endif
};
92
93

/* Function prototypes. */
94
void proxy_init(struct proxy *p, int mynodeID, int nodeID);
Pedro Gonnet's avatar
const.    
Pedro Gonnet committed
95
96
97
void proxy_parts_load(struct proxy *p, const struct part *parts,
                      const struct xpart *xparts, int N);
void proxy_gparts_load(struct proxy *p, const struct gpart *gparts, int N);
98
void proxy_sparts_load(struct proxy *p, const struct spart *sparts, int N);
99
100
void proxy_parts_exch1(struct proxy *p);
void proxy_parts_exch2(struct proxy *p);
101
102
void proxy_addcell_in(struct proxy *p, struct cell *c, char type);
void proxy_addcell_out(struct proxy *p, struct cell *c, char type);
103
104
105
106
void proxy_cells_exch1(struct proxy *p);
void proxy_cells_exch2(struct proxy *p);

#endif /* SWIFT_PROXY_H */