statistics.h 2.19 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*******************************************************************************
 * This file is part of SWIFT.
 * Copyright (c) 2016 Matthieu Schaller (matthieu.schaller@durham.ac.uk)
 *
 * 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.
 *
 * 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.
 *
 * 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/>.
 *
 ******************************************************************************/
#ifndef SWIFT_STATISTICS_H
#define SWIFT_STATISTICS_H

/* Config parameters. */
#include "../config.h"

/* Local headers. */
26
#include "lock.h"
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "space.h"

/**
 * @brief Quantities collected for physics statistics
 */
struct statistics {

  /*! Kinetic energy */
  double E_kin;

  /*! Internal energy */
  double E_int;

40
41
42
43
44
  /*! Self potential energy */
  double E_pot_self;

  /*! External potential energy */
  double E_pot_ext;
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59

  /*! Radiative energy */
  double E_rad;

  /*! Entropy */
  double entropy;

  /*! Mass */
  double mass;

  /*! Momentum */
  double mom[3];

  /*! Angular momentum */
  double ang_mom[3];
60

61
62
63
  /*! Centre of mass */
  double centre_of_mass[3];

64
65
  /*! Lock for threaded access */
  swift_lock_type lock;
66
67
68
};

void stats_collect(const struct space* s, struct statistics* stats);
69
70
71
72
void stats_add(struct statistics* a, const struct statistics* b);
void stats_print_to_file(FILE* file, const struct statistics* stats,
                         double time);
void stats_init(struct statistics* s);
73
void stats_finalize(struct statistics* s);
74
75
76
77
78
79
80
81

#ifdef WITH_MPI
extern MPI_Datatype statistics_mpi_type;
extern MPI_Op statistics_mpi_reduce_op;

void stats_add_MPI(void* in, void* out, int* len, MPI_Datatype* datatype);
void stats_create_MPI_type();
#endif
82
83

#endif /* SWIFT_STATISTICS_H */