aboutsummaryrefslogtreecommitdiff
path: root/src/Startup.c
blob: 5e6087730d30a7fafd93c6923ee9e7d208bdc0ae (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
 /*@@
   @file      Startup.c
   @date      Sun Jul 04 1999
   @author    Thomas Radke
   @desc
              Startup routines for PUGHInterp
   @enddesc
   @version   $Id$
 @@*/

#include <stdlib.h>

#include "cctk.h"
#include "cctk_Interp.h"
#include "pughInterpGH.h"

/* the rcs ID and its dummy function to use it */
static const char *rcsid = "$Header$";
CCTK_FILEVERSION(CactusPUGH_PUGHInterp_Startup_c)


/* prototypes of routines defined in this source file */
void PUGHInterp_Startup (void);
#ifdef CCTK_MPI
static void *PUGHInterp_SetupGH (tFleshConfig *config,
                                 int convergence_level,
                                 cGH *GH);
#endif


#ifdef CCTK_MPI
 /*@@
   @routine   PUGHInterp_SetupGH
   @date      Sun Jul 04 1999
   @author    Thomas Radke
   @desc
              Allocates the GH extension structure and - for the MPI case -
              the count/displacement buffers used in MPI_Alltoall()
              and MPI_Alltoallv()
   @enddesc
   @calls     CCTK_nProcs

   @returntype void *
   @returndesc
               pointer to the allocated GH extension structure
   @endreturndesc
@@*/
static void *PUGHInterp_SetupGH (tFleshConfig *config,
                                 int convergence_level,
                                 cGH *GH)
{
  int nprocs;
  pughInterpGH *myGH;


  /* suppress compiler warnings about unused variables */
  config = config;
  convergence_level = convergence_level;

  myGH = (pughInterpGH *) malloc (sizeof (pughInterpGH));

  /* allocate once for all fields of same type */
  nprocs = CCTK_nProcs (GH);
  myGH->send_count = (int *) malloc (4 * nprocs * sizeof (int));
  myGH->send_displ = myGH->send_count + nprocs;
  myGH->recv_count = myGH->send_displ + nprocs;
  myGH->recv_displ = myGH->recv_count + nprocs;

  myGH->num_points_from = (CCTK_INT *) malloc (2 * nprocs * sizeof (CCTK_INT));
  myGH->num_points_to   = myGH->num_points_from + nprocs;

  return (myGH);
}
#endif /* CCTK_MPI */


 /*@@
   @routine   PUGHInterp_InterpGV_NthOrder
   @date      Wed 14 Feb 2001
   @author    Thomas Radke
   @desc
              Wrappers for the different interpolation operators 
              registered for first/second/third order interpolation.
              These wrappers just call the common interpolation routine
              passing all arguments plus the interpolation order.
   @enddesc

   @returntype int
   @returndesc
               the return code of the common interpolation routine
   @endreturndesc
@@*/
static int PUGHInterp_InterpGV_1stOrder (cGH *GH,
                                         const char *coord_system,
                                         int num_points,
                                         int num_in_array_indices,
                                         int num_out_arrays,
                                         const void *const interp_coord_arrays[],
                                         const int interp_coord_array_types[],
                                         const int in_array_indices[],
                                         void *const out_arrays[],
                                         const int out_array_types[])
{
  return (PUGHInterp_InterpGV (GH, 1, coord_system, num_points,
                               num_in_array_indices, num_out_arrays,
                               interp_coord_arrays, interp_coord_array_types,
                               in_array_indices, out_arrays, out_array_types));
}
                       

static int PUGHInterp_InterpGV_2ndOrder (cGH *GH,
                                         const char *coord_system,
                                         int num_points,
                                         int num_in_array_indices,
                                         int num_out_arrays,
                                         const void *const interp_coord_arrays[],
                                         const int interp_coord_array_types[],
                                         const int in_array_indices[],
                                         void *const out_arrays[],
                                         const int out_array_types[])
{
  return (PUGHInterp_InterpGV (GH, 2, coord_system, num_points,
                               num_in_array_indices, num_out_arrays,
                               interp_coord_arrays, interp_coord_array_types,
                               in_array_indices, out_arrays, out_array_types));
}
                       

static int PUGHInterp_InterpGV_3rdOrder (cGH *GH,
                                         const char *coord_system,
                                         int num_points,
                                         int num_in_array_indices,
                                         int num_out_arrays,
                                         const void *const interp_coord_arrays[],
                                         const int interp_coord_array_types[],
                                         const int in_array_indices[],
                                         void *const out_arrays[],
                                         const int out_array_types[])
{
  return (PUGHInterp_InterpGV (GH, 3, coord_system, num_points,
                               num_in_array_indices, num_out_arrays,
                               interp_coord_arrays, interp_coord_array_types,
                               in_array_indices, out_arrays, out_array_types));
}
                       

 /*@@
   @routine   PUGHInterp_Startup
   @date      Sun Jul 04 1999
   @author    Thomas Radke
   @desc
              The startup registration routine for PUGHInterp.
              Registers the PUGHInterp GH extensions setup routine
              and the interpolation operators with the flesh.
   @enddesc
   @calls     CCTK_RegisterGHExtensionSetupGH
              CCTK_InterpRegisterOperatorGV
              CCTK_InterpRegisterOperatorLocal
@@*/
void PUGHInterp_Startup (void)
{
#ifdef CCTK_MPI
  CCTK_RegisterGHExtensionSetupGH (CCTK_RegisterGHExtension ("PUGHInterp"),
                                   PUGHInterp_SetupGH);
#endif

  CCTK_InterpRegisterOperatorGV (PUGHInterp_InterpGV_1stOrder,
                                 "first-order uniform cartesian");
  CCTK_InterpRegisterOperatorGV (PUGHInterp_InterpGV_2ndOrder,
                                 "second-order uniform cartesian");
  CCTK_InterpRegisterOperatorGV (PUGHInterp_InterpGV_3rdOrder,
                                 "third-order uniform cartesian");
}