aboutsummaryrefslogtreecommitdiff
path: root/src/GRHydro_RegisterVarsM.cc
blob: 897ee2839a0269d0d6278377414136f3aa4d1687 (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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
// GRHydro_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 GRHydro_RegisterM(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("HydroBase::w_lorentz");

  if (CCTK_EQUALS(evolution_method, "GRHydro"))
  {
    // dens and scon
    register_evolved("GRHydro::dens", "GRHydro::densrhs");
    register_evolved("GRHydro::scon", "GRHydro::srhs");
    register_evolved("HydroBase::Bvec", "GRHydro::Bvecrhs");

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

    if(clean_divergence) {
      register_evolved("GRHydro::psidc" , "GRHydro::psidcrhs");
    }

    // 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("GRHydro::GRHydro_coords", "GRHydro::GRHydro_coords_rhs");
      }
      else
        register_saveandrestore("admbase::shift");
    }

    // tracer
    if (evolve_tracer != 0)
      register_evolved("GRHydro::GRHydro_cons_tracers", 
		       "GRHydro::GRHydro_tracer_rhs");
    
    // note that we set in pararamcheck
    // evolve_y_e and evolve_temper, but MoLRegister
    // happens before paramcheck...
    if (CCTK_EQUALS(Y_e_evolution_method,"GRHydro")) {
      register_constrained("HydroBase::Y_e");
      register_evolved("GRHydro::Y_e_con", 
		       "GRHydro::Y_e_con_rhs");
    }

    if (CCTK_EQUALS(temperature_evolution_method,"GRHydro")) {
      register_constrained("HydroBase::temperature");
      register_constrained("HydroBase::entropy");
    }
    // particles
    if (number_of_particles > 0)
      register_evolved("GRHydro::particles", "GRHydro::particle_rhs");
  }
  else if (CCTK_EQUALS(evolution_method, "none"))
  {
    register_constrained("GRHydro::dens");
    register_constrained("GRHydro::scon");
    register_constrained("GRHydro::tau");
    register_constrained("HydroBase::Bvec");
    if(clean_divergence) {
      register_constrained("GRHydro::psidc");
    }
  }
}