hydro_properties.c 2.45 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
/*******************************************************************************
 * 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/>.
 *
 ******************************************************************************/

/* This object's header. */
#include "hydro_properties.h"

/* Standard headers */
24
#include <float.h>
25
26
27
28
29
#include <math.h>

/* Local headers. */
#include "error.h"
#include "hydro.h"
30
#include "kernel_hydro.h"
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48

void hydro_props_init(struct hydro_props *p,
                      const struct swift_params *params) {

  /* Kernel properties */
  p->eta_neighbours = parser_get_param_float(params, "SPH:resolution_eta");
  const float eta3 = p->eta_neighbours * p->eta_neighbours * p->eta_neighbours;
  p->target_neighbours = 4.0 * M_PI * kernel_gamma3 * eta3 / 3.0;
  p->delta_neighbours = parser_get_param_float(params, "SPH:delta_neighbours");

  /* Ghost stuff */
  p->max_smoothing_iterations =
      parser_get_param_int(params, "SPH:max_ghost_iterations");

  /* Time integration properties */
  p->CFL_condition = parser_get_param_float(params, "SPH:CFL_condition");
  const float max_volume_change =
      parser_get_param_float(params, "SPH:max_volume_change");
49
  p->log_max_h_change = logf(powf(max_volume_change, 0.33333333333f));
50
51
52
53
54
55
56
57
}

void hydro_props_print(const struct hydro_props *p) {

  message("Hydrodynamic scheme: %s.", SPH_IMPLEMENTATION);
  message("Hydrodynamic kernel: %s with %.2f +/- %.2f neighbours (eta=%f).",
          kernel_name, p->target_neighbours, p->delta_neighbours,
          p->eta_neighbours);
Peter W. Draper's avatar
Peter W. Draper committed
58
  message("Hydrodynamic integration: CFL parameter: %.4f.", p->CFL_condition);
59
  message(
Matthieu Schaller's avatar
Matthieu Schaller committed
60
61
      "Hydrodynamic integration: Max change of volume: %.2f "
      "(max|dlog(h)/dt|=%f).",
62
63
      powf(expf(p->log_max_h_change), 3.f), p->log_max_h_change);
}