aboutsummaryrefslogtreecommitdiff
path: root/src/GRHydro_RegisterGZ.cc
blob: 6029145bddc9d76a3ead2e7fdd3e72d6def48d67 (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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
// register.cc -- register variables with various thorns that need-to-know
// $Header$
//
// GRHydro_register_GZPatchSystem - register with GZPatchSystem
//
// Cut 'n paste job from BackgroundWaveToy, author J Thornburg...

#include <cstdio>
#include <string>

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

using namespace std;

//******************************************************************************

//
// This function is called by the Cactus scheduler to (maybe) register
// our to-be-interpatch-synchronized variables with GZPatchSystem.  It
// checks if the GZPatchSystem registration function has been provided
// (which it should be if and only if GZPatchSystem is active), and if so,
// does the registration.
//
// If we're using Carpet, this function must be called in meta mode.
//
extern "C"void GRHydro_register_GZPatchSystem(CCTK_ARGUMENTS)
{
  DECLARE_CCTK_PARAMETERS;

  if (CCTK_IsFunctionAliased("GZPatchSystem_register_sync"))
  {
    CCTK_VInfo(CCTK_THORNSTRING,
               "registering to-be-interpatch-synchronized variables "
               "with GZPatchSystem");
    
    if(CCTK_EQUALS(Bvec_evolution_method,"GRHydro")) {
      if(clean_divergence) {
	string var[10] = {"HydroBase::rho", "HydroBase::press", "HydroBase::eps",
			  "HydroBase::vel",
			  "GRHydro::dens", "GRHydro::tau", "HydroBase::w_lorentz",
			  "GRHydro::scon", "HydroBase::Bvec", "GRHydro::psidc"};
	for (int i = 0; i < 10; i++)
	  {
	    int status = 
	      GZPatchSystem_register_sync(var[i].c_str());
	    if (status < 0)
	      {
		CCTK_VWarn(0, __LINE__, __FILE__, CCTK_THORNSTRING,
			   "***** GRHydro_register_GZPatchSystem():\n"
			   "        error registering var group %s to be "
			   "interpatch-synchronized!\n"
			   "        (GZPatchSystem_register_sync() error code %d)\n",
			   var[i].c_str(), status);
	      }
	  }
      } else {
	string var[9] = {"HydroBase::rho", "HydroBase::press", "HydroBase::eps",
			 "HydroBase::vel",
			 "GRHydro::dens", "GRHydro::tau", "HydroBase::w_lorentz",
			 "GRHydro::scon", "HydroBase::Bvec"};
	for (int i = 0; i < 9; i++)
	  {
	    int status = 
	      GZPatchSystem_register_sync(var[i].c_str());
	    if (status < 0)
	      {
		CCTK_VWarn(0, __LINE__, __FILE__, CCTK_THORNSTRING,
			   "***** GRHydro_register_GZPatchSystem():\n"
			   "        error registering var group %s to be "
			   "interpatch-synchronized!\n"
			   "        (GZPatchSystem_register_sync() error code %d)\n",
			   var[i].c_str(), status);
	      }
	  }
      }
    } else {
      string var[8] = {"HydroBase::rho", "HydroBase::press", "HydroBase::eps",
		       "HydroBase::vel",
		       "GRHydro::dens", "GRHydro::tau", "HydroBase::w_lorentz",
		       "GRHydro::scon"};
      for (int i = 0; i < 8; i++)
	{
	  int status = 
	    GZPatchSystem_register_sync(var[i].c_str());
	  if (status < 0)
	    {
	      CCTK_VWarn(0, __LINE__, __FILE__, CCTK_THORNSTRING,
			 "***** GRHydro_register_GZPatchSystem():\n"
			 "        error registering var group %s to be "
			 "interpatch-synchronized!\n"
			 "        (GZPatchSystem_register_sync() error code %d)\n",
			 var[i].c_str(), status);
	    }
	}
    } 
  }
  else
  {
    CCTK_WARN(1, "Function GZPatchSystem_register_sync not registered!");
  }

  if (CCTK_IsFunctionAliased("GZPatchSystem_register_cxform"))
  {
    CCTK_VInfo(CCTK_THORNSTRING,
               "registering to-be-cxformed variables with GZPatchSystem");
    
    if(CCTK_EQUALS(Bvec_evolution_method,"GRHydro")) {
      if(clean_divergence) {
	string var[13] = {"HydroBase::rho", "HydroBase::press", "HydroBase::eps",
			  "HydroBase::vel",
			  "GRHydro::dens", "GRHydro::tau", "HydroBase::w_lorentz",
			  "GRHydro::scon", "HydroBase::Bvec", "GRHydro::psidc",
			  "ADMBase::metric", "ADMBase::curv", "ADMBase::shift"};
	for (int i = 0; i < 13; i++)
	  for (int j = 0; j < 3; j++)
	    {
	      int ps_status = 
		GZPatchSystem_register_cxform(j, var[i].c_str());
	      if (ps_status < 0)
		{
		  CCTK_VWarn(0, __LINE__, __FILE__, CCTK_THORNSTRING,
			     "***** GRHydro_register_GZPatchSystem():\n"
			     "        error registering var group %s to be "
			     "interpatch-cxformhronized!\n"
			     "        (GZPatchSystem_register_cxform() error code %d)\n",
			     var[i].c_str(), ps_status);
		}
	    }
      } else {
	string var[12] = {"HydroBase::rho", "HydroBase::press", "HydroBase::eps",
			  "HydroBase::vel",
			  "GRHydro::dens", "GRHydro::tau", "HydroBase::w_lorentz",
			  "GRHydro::scon", "HydroBase::Bvec",
			  "ADMBase::metric", "ADMBase::curv", "ADMBase::shift"};
	for (int i = 0; i < 12; i++)
	  for (int j = 0; j < 3; j++)
	    {
	      int ps_status = 
		GZPatchSystem_register_cxform(j, var[i].c_str());
	      if (ps_status < 0)
		{
		  CCTK_VWarn(0, __LINE__, __FILE__, CCTK_THORNSTRING,
			     "***** GRHydro_register_GZPatchSystem():\n"
			     "        error registering var group %s to be "
			     "interpatch-cxformhronized!\n"
			     "        (GZPatchSystem_register_cxform() error code %d)\n",
			     var[i].c_str(), ps_status);
		}
	    }
      }
      
    } else {
      string var[11] = {"HydroBase::rho", "HydroBase::press", "HydroBase::eps",
			"HydroBase::vel",
			"GRHydro::dens", "GRHydro::tau", "HydroBase::w_lorentz",
			"GRHydro::scon",
			"ADMBase::metric", "ADMBase::curv", "ADMBase::shift"};
      for (int i = 0; i < 11; i++)
	for (int j = 0; j < 3; j++)
	  {
	    int ps_status = 
	      GZPatchSystem_register_cxform(j, var[i].c_str());
	    if (ps_status < 0)
	      {
		CCTK_VWarn(0, __LINE__, __FILE__, CCTK_THORNSTRING,
			   "***** GRHydro_register_GZPatchSystem():\n"
			   "        error registering var group %s to be "
			   "interpatch-cxformhronized!\n"
			   "        (GZPatchSystem_register_cxform() error code %d)\n",
			   var[i].c_str(), ps_status);
	      }
	  }
    }
  }
  else
    {
      CCTK_WARN(1, "Function GZPatchSystem_register_cxform not registered!");
    }
  
}