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
|
#include "cctk.h"
#include "cctk_Arguments.h"
#include "cctk_Functions.h"
#include "cctk_Parameters.h"
/***
* This is a utility function which reads values of shiftout parameters from
* thorn CoordBase into an integer array offset[]. It is declared at the thorn
* interface as GetFDGridOffsets and can be called from Fortran routines.
* This is necessary since CCTK_ParameterGet is not available in Fortran.
*/
void get_grid_offsets (CCTK_INT *offset) {
DECLARE_CCTK_PARAMETERS;
int i, type;
const CCTK_INT* shiftout_x_lower = (const CCTK_INT*) CCTK_ParameterGet ( "boundary_shiftout_x_lower", "coordbase", &type );
if (shiftout_x_lower != NULL ) {
offset[0] = *shiftout_x_lower;
}
const CCTK_INT* shiftout_x_upper = (const CCTK_INT*) CCTK_ParameterGet ( "boundary_shiftout_x_upper", "coordbase", &type );
if (shiftout_x_upper != NULL ) {
offset[1] = *shiftout_x_upper;
}
const CCTK_INT* shiftout_y_lower = (const CCTK_INT*) CCTK_ParameterGet ( "boundary_shiftout_y_lower", "coordbase", &type );
if (shiftout_y_lower != NULL ) {
offset[2] = *shiftout_y_lower;
}
const CCTK_INT* shiftout_y_upper = (const CCTK_INT*) CCTK_ParameterGet ( "boundary_shiftout_y_upper", "coordbase", &type );
if (shiftout_y_upper != NULL ) {
offset[3] = *shiftout_y_upper;
}
const CCTK_INT* shiftout_z_lower = (const CCTK_INT*) CCTK_ParameterGet ( "boundary_shiftout_z_lower", "coordbase", &type );
if (shiftout_z_lower != NULL ) {
offset[4] = *shiftout_z_lower;
}
const CCTK_INT* shiftout_z_upper = (const CCTK_INT*) CCTK_ParameterGet ( "boundary_shiftout_z_upper", "coordbase", &type );
if (shiftout_z_upper != NULL ) {
offset[5] = *shiftout_z_upper;
}
}
/***
* This function returns the effective values of local index ranges,
* taking into account ghost zones and boundary_shiftout_* values.
* If the use_shiftout=no, boundary offsets are set to zero.
* Index ranges are set in Fortran convention (starting from 1):
* - imin <= i <= imax
* - jmin <= j <= jmax
* - kmin <= k <= kmax
* This function is declared in interface.ccl as GetLSHIndexRanges
* to be used by other thorns, which need to know the actual index
* ranges for the region where SBP thorn will apply derivative /
* dissipation operators.
*/
void get_lsh_iranges ( const CCTK_POINTER_TO_CONST cctkGH_,
CCTK_INT *imin, CCTK_INT *imax,
CCTK_INT *jmin, CCTK_INT *jmax,
CCTK_INT *kmin, CCTK_INT *kmax)
{
cGH const * restrict const cctkGH = cctkGH_;
DECLARE_CCTK_PARAMETERS
DECLARE_CCTK_ARGUMENTS
int i, offset[6];
for (i=0;i<6;i++) offset[i] = 0;
if (use_shiftout) get_grid_offsets (offset);
*imin = 1 + ((cctk_bbox[0]) ? offset[0] : cctk_nghostzones[0]);
*jmin = 1 + ((cctk_bbox[2]) ? offset[2] : cctk_nghostzones[1]);
*kmin = 1 + ((cctk_bbox[4]) ? offset[4] : cctk_nghostzones[2]);
*imax = cctk_lsh[0] - ((cctk_bbox[1]) ? offset[1] : cctk_nghostzones[0] );
*jmax = cctk_lsh[1] - ((cctk_bbox[3]) ? offset[3] : cctk_nghostzones[1] );
*kmax = cctk_lsh[2] - ((cctk_bbox[5]) ? offset[5] : cctk_nghostzones[2] );
}
|