aboutsummaryrefslogtreecommitdiff
path: root/src/patch/patch_info.cc
blob: 2f54a21cda5d41d867c6a860b98bda9b34362890 (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
// patch_info.cc -- POD struct of minimal info varying from one patch to another
// $Header$

//
// patch_info::grid_array_pars
// patch_info::grid_pars
//

#include <stdio.h>
#include <math.h>
#include <assert.h>

#include "cctk.h"

#include "config.h"
#include "stdc.h"
#include "../jtutil/util.hh"
#include "../jtutil/array.hh"
#include "../jtutil/cpm_map.hh"
#include "../jtutil/linear_map.hh"

#include "coords.hh"
#include "grid.hh"
#include "patch_info.hh"

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

//
// This function computes, and returns a reference to, a
//  struct grid_arrays::grid_array_pars  from the info in a
//  struct patch_info  and the additional information in the arguments.
//
// The result refers to an internal static buffer in this function; the
// usual caveats about lifetimes/overwriting apply.
//
// Arguments:
// N_ghost_points = Width in grid points of all ghost zones.
// N_extend_points = Number of grid points to extend each patch past
//		     "just touching" so as to overlap neighboring patches.
//		     Thus patches overlap by
//			N_overlap_points = 2*N_extend_points + 1
//		     grid points.  For example, with N_extend_points == 2,
//		     here are the grid points of two neighboring patches:
//			x   x   x   x   x   X   X
//                                      |
//			        O   O   o   o   o   o   o
//		     Here | marks the "just touching" boundary,
//		     x and o the grid points before this extension,
//		     and X and O the extra grid points added by this
//		     extension.
// delta_drho_dsigma = Grid spacing (both rho and sigma) in degrees.
//
const grid_arrays::grid_array_pars&
  patch_info::grid_array_pars(int N_ghost_points, int N_extend_points,
			      fp delta_drho_dsigma)
	const
{
static
  struct grid_arrays::grid_array_pars grid_array_pars_buffer;

grid_array_pars_buffer.min_irho
	= jtutil::round<fp>::to_integer(min_drho  /delta_drho_dsigma);
grid_array_pars_buffer.min_isigma
	= jtutil::round<fp>::to_integer(min_dsigma/delta_drho_dsigma);
grid_array_pars_buffer.max_irho
	= grid_array_pars_buffer.min_irho
	  + jtutil::round<fp>::to_integer(
		(max_drho  -min_drho  ) / delta_drho_dsigma
					 );
grid_array_pars_buffer.max_isigma
	= grid_array_pars_buffer.min_isigma
	  + jtutil::round<fp>::to_integer(
		(max_dsigma-min_dsigma) / delta_drho_dsigma
					 );
grid_array_pars_buffer.min_irho   -= N_extend_points;
grid_array_pars_buffer.min_isigma -= N_extend_points;
grid_array_pars_buffer.max_irho   += N_extend_points;
grid_array_pars_buffer.max_isigma += N_extend_points;

grid_array_pars_buffer.min_rho_N_ghost_points = N_ghost_points;
grid_array_pars_buffer.max_rho_N_ghost_points = N_ghost_points;
grid_array_pars_buffer.min_sigma_N_ghost_points = N_ghost_points;
grid_array_pars_buffer.max_sigma_N_ghost_points = N_ghost_points;

return grid_array_pars_buffer;
}

//******************************************************************************
//
//
// This function computes, and returns a reference to, a
//  struct grid_arrays::grid_pars  from the info in a  struct patch_info
// and the additional information in the arguments.
//
// The result refers to an internal static buffer in this function; the
// usual caveats about lifetimes/overwriting apply.
//
// Arguments:
// N_extend_points = Number of grid points to extend each patch past
//		     "just touching" so as to overlap neighboring patches.
//		     Thus patches overlap by  2*N_extend_points + 1  grid
//		     points.  For example, with N_extend_points == 2, here
//		     are the grid points of two neighboring patches:
//			x   x   x   x   x   X   X
//                                      |
//			        O   O   o   o   o   o   o
//		     Here | marks the "just touching" boundary,
//		     x and o the grid points before this extension,
//		     and X and O the extra grid points added by this
//		     extension.
// delta_drho_dsigma = Grid spacing (both rho and sigma) in degrees.
//
const grid::grid_pars& patch_info::grid_pars(int N_extend_points,
					     fp delta_drho_dsigma)
	const
{
static
  struct grid::grid_pars grid_pars_buffer;

const fp extend_drho_dsigma = fp(N_extend_points) * delta_drho_dsigma;

grid_pars_buffer.  min_drho   = min_drho   - extend_drho_dsigma;
grid_pars_buffer.delta_drho   = delta_drho_dsigma;
grid_pars_buffer.  max_drho   = max_drho   + extend_drho_dsigma;
grid_pars_buffer.  min_dsigma = min_dsigma - extend_drho_dsigma;
grid_pars_buffer.delta_dsigma = delta_drho_dsigma;
grid_pars_buffer.  max_dsigma = max_dsigma + extend_drho_dsigma;

return grid_pars_buffer;
}