aboutsummaryrefslogtreecommitdiff
path: root/src/Whisky_RegisterVars.cc
blob: 981b759a5040276938e74a629bd974a64bc542ca (plain)
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// Whisky_RegisterVars.cc
//
// converted from F90 to improve readability and maintainability
//
// Frank Loeffler

#include <cstdio>
#include <string>

#include "cctk.h"
#include "cctk_Arguments.h"
#include "cctk_Parameters.h"

using namespace std;

// Utility functions to register variables with MoL
// Note: We could check for the return value here, but MoL issues a
//       level 0 warning in that case anyway. If that changes in the
//       future, a check can simply be inserted here.
static void register_evolved(string v1, string v2)
{
  MoLRegisterEvolvedGroup(CCTK_GroupIndex(v1.c_str()), CCTK_GroupIndex(v2.c_str()));
}
static void register_constrained(string v1)
{
  MoLRegisterConstrainedGroup(CCTK_GroupIndex(v1.c_str()));
}
static void register_saveandrestore(string v1)
{
  MoLRegisterSaveAndRestoreGroup(CCTK_GroupIndex(v1.c_str()));
}

// Main function called by Cactus to register variables with MoL

extern "C"void Whisky_Register(CCTK_ARGUMENTS)
{
  DECLARE_CCTK_ARGUMENTS;
  DECLARE_CCTK_PARAMETERS;

  // We need some aliased functions, so we first check if they are available
  string needed_funs[5] = {"MoLRegisterEvolvedGroup",
                           "MoLRegisterConstrainedGroup",
                           "MoLRegisterSaveAndRestoreGroup",
                           "MoLRegisterEvolved",
                           "MoLRegisterConstrained"};
  for (int i = 0; i < 5; i++)
    if (!CCTK_IsFunctionAliased(needed_funs[i].c_str()))
      CCTK_VWarn(0, __LINE__, __FILE__, CCTK_THORNSTRING,
                 "The function \"%s\" has not been aliased!",
                 needed_funs[i].c_str());

  // Now we can set which variables have to be registered as which type with MoL
  register_constrained("HydroBase::rho");
  register_constrained("HydroBase::press");
  register_constrained("HydroBase::eps");
  register_constrained("HydroBase::vel");
  register_constrained("Whisky::w_lorentz");

  if (CCTK_EQUALS(evolution_method, "whisky"))
  {
    // dens and scon
    register_evolved("whisky::dens", "whisky::densrhs");
    register_evolved("whisky::scon", "whisky::srhs");

    // tau
    if (CCTK_EQUALS(whisky_eos_type, "General"))
      register_evolved("whisky::tau" , "whisky::taurhs");
    else if (CCTK_EQUALS(whisky_eos_type, "Polytype"))
      register_constrained("whisky::tau");
    else
      CCTK_WARN(0, "Don't recognize the type of EOS!");

    // lapse, metric, curv
    register_saveandrestore("admbase::lapse");
    register_saveandrestore("admbase::metric");
    register_saveandrestore("admbase::curv");

    // shift
    if (!CCTK_EQUALS(initial_shift, "none"))
    {
      if (CCTK_EQUALS(shift_evolution_method, "Comoving"))
      {
        register_constrained("admbase::shift");
        register_evolved("Whisky::whisky_coords", "Whisky::whisky_coords_rhs");
      }
      else
        register_saveandrestore("admbase::shift");
    }

    // tracer
    if (evolve_tracer != 0)
      register_evolved("whisky::whisky_cons_tracers", "whisky::whisky_tracer_rhs");

    // particles
    if (number_of_particles > 0)
      register_evolved("whisky::particles", "whisky::particle_rhs");
  }
  else if (CCTK_EQUALS(evolution_method, "none"))
  {
    register_constrained("whisky::dens");
    register_constrained("whisky::scon");
    register_constrained("whisky::tau");
  }
}