aboutsummaryrefslogtreecommitdiff
path: root/Carpet/Carpet/src/functions.hh
blob: d513d154b0c03334fd6c2cfff70dee94ba5716eb (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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
#ifndef FUNCTIONS_HH
#define FUNCTIONS_HH

#include <cctk.h>
#include <cctk_Schedule.h>

#include <map>
#include <string>
#include <vector>

#ifdef CCTK_MPI
#  include <mpi.h>
#else
#  include "nompi.h"
#endif

#include <bbox.hh>
#include <dh.hh>
#include <gh.hh>
#include <vect.hh>


  
namespace Carpet {
  
  using namespace std;
  using namespace CarpetLib;
  
  int SyncGroupsByDirI (const cGH* cctkGH, int num_groups,
                        const int* groups, const int* directions);
  int EnableGroupComm (const cGH* cgh, const char* groupname);
  int DisableGroupComm (const cGH* cgh, const char* groupname);
  int EnableGroupStorage (const cGH* cgh, const char* groupname);
  int DisableGroupStorage (const cGH* cgh, const char* groupname); 
  int GroupStorageIncrease (const cGH* cgh, int n_groups, const int* groups,
                            const int* timelevels, int* status);
  int GroupStorageDecrease (const cGH* cgh, int n_groups, const int* groups,
                            const int* timelevels, int* status);
  int Barrier (const cGH* cgh);
  int NamedBarrier (const cGH* cgh, unsigned int id, const char* name);
  int Exit (const cGH* cgh, int retval);
  int Abort (const cGH* cgh, int retval);
  int MyProc (const cGH* cgh) CCTK_ATTRIBUTE_PURE;
  int nProcs (const cGH* cgh) CCTK_ATTRIBUTE_PURE;
  const int* ArrayGroupSizeB (const cGH* cgh, int dir, int group,
			      const char* groupname) CCTK_ATTRIBUTE_PURE;
  int QueryGroupStorageB (const cGH* cgh, int group, const char* groupname)
    CCTK_ATTRIBUTE_PURE;
  int GroupDynamicData (const cGH* cgh, int group, cGroupDynamicData* data);
  
  void Restrict (const cGH* cgh);
  
  
  
  // Multi-Model
  void
  SplitUniverse (MPI_Comm const world, string const model, MPI_Comm & comm,
                 bool verbose);
  
  // Model id to model name
  vector <string> const & ModelNames ();
  string ModelName (int id);
  
  // Model name to model id
  std::map <string, int> const & ModelMap ();
  int ModelId (string name);
  
  // Processor to model id
  vector <int> const & ModelIds ();
  int ModelId (int proc);
  
  // Model id to processes
  vector <vector <int> > const & ModelProcs ();
  vector <int> const & ModelProcs (int id);
  
  
  
  // Host mapping
  void
  DetermineHosts (string host,
                  bool verbose);
  
  // Host id to host name
  vector <string> const & HostNames ();
  string HostName (int id);
  
  // Host name to host id
  std::map <string, int> const & HostMap ();
  int HostId (string name);
  
  // Processor to host id
  vector <int> const & HostIds ();
  int HostId (int proc);
  
  // Host id to processes
  vector <vector <int> > const & HostProcs ();
  vector <int> const & HostProcs (int id);
  
  
  
  extern "C" {
    CCTK_POINTER_TO_CONST
    Carpet_GetMPICommUniverse (CCTK_POINTER_TO_CONST cctkGH);
    CCTK_POINTER_TO_CONST
    Carpet_GetMPICommWorld (CCTK_POINTER_TO_CONST cctkGH);
    CCTK_INT
    Carpet_GetCoordRange (CCTK_POINTER_TO_CONST const         cctkGH_,
                          CCTK_INT              const         m,
                          CCTK_INT              const         ml,
                          CCTK_INT              const         size,
                          CCTK_INT                    * const gsh,
                          CCTK_REAL                   * const lower,
                          CCTK_REAL                   * const upper,
                          CCTK_REAL                   * const delta);
  }
  
  
  
  // Helpers for storage
  void GroupsStorageCheck (cGH const * const cctkGH);

  // Helpers for recomposing the grid hierarchy
  void
  RegridMap (cGH const * cctkGH,
             int m,
             gh::rregs const & supeerregss,
             gh::mregs const & regsss,
             bool do_init);
  void
  PostRegrid (cGH const * cctkGH);
  bool
  Recompose (cGH const * cctkGH,
             int rl,
             bool do_init);
  void
  RegridFree (cGH const * cctkGH,
              bool do_init);
  
  void
  CheckRegions (gh::mregs const & regsss);
  
  void
  OutputSuperregions (cGH const * cctkGH,
                      int m,
                      gh const & hh,
                      gh::rregs const & superregss);
  void
  OutputGrids (cGH const * cctkGH,
               int const m,
               gh const & hh,
               dh const & dd);
  
  void
  OutputGridStructure (cGH const * cctkGH,
                       int const m,
                       gh::mregs const & regsss);
  
  void
  OutputGridCoordinates (cGH const * cctkGH,
                         int const m,
                         gh::mregs const & regsss);
  
  void
  OutputGridStatistics (cGH const * cctkGH);
  
  
  
  // Functions for recomposing the grid hierarchy
  void
  SplitRegions (cGH const * cctkGH,
                vector<region_t> & superregs,
                vector<region_t> & regs);
  void
  SplitRegions_AlongZ (cGH const * cctkGH,
                       vector<region_t> & superregs,
                       vector<region_t> & regs);
  void
  SplitRegions_AlongDir (cGH const * cctkGH,
                         vector<region_t> & superregs,
                         vector<region_t> & regs,
                         int dir);
  void
  SplitRegions_Automatic (cGH const * cctkGH,
                          vector<region_t> & superregs,
                          vector<region_t> & regs);
  void
  SplitRegionsMaps_Recursively (cGH const * cctkGH,
                                vector<vector<region_t> > & superregss,
                                vector<vector<region_t> > & regss);
  
  void
  SplitRegionsMaps (cGH const * cctkGH,
                    vector<vector<region_t> > & superregss,
                    vector<vector<region_t> > & regss);
  void
  SplitRegionsMaps_Automatic (cGH const * cctkGH,
                              vector<vector<region_t> > & superregss,
                              vector<vector<region_t> > & regss);
  void
  SplitRegionsMaps_Recursively (cGH const * cctkGH,
                                vector<vector<region_t> > & superregss,
                                vector<vector<region_t> > & regss);
  
  void
  MakeMultigridBoxes (cGH const * cctkGH,
                      int m,
                      gh::rregs const & regss,
                      gh::mregs       & regsss);
  
  void
  MakeMultigridBoxesMaps (cGH const * cctkGH,
                          vector<gh::rregs> const & regsss,
                          vector<gh::mregs>       & regssss);
  
  
  
  // Timing statistics functions
  void InitTimingStats (cGH const * cctkGH);
  void BeginTimingEvolution (cGH const * cctkGH);
  void StepTimingEvolution (cGH const * cctkGH);
  void BeginTimingLevel (cGH const * cctkGH);
  void EndTimingLevel (cGH const * cctkGH);
  void BeginTimingIO (cGH const * cctkGH);
  void EndTimingIO (cGH const * cctkGH,
                    CCTK_REAL files, CCTK_REAL bytes, bool is_binary);
  void BeginTimingCommunication (cGH const * cctkGH);
  void EndTimingCommunication (cGH const * cctkGH,
                               CCTK_REAL messages, CCTK_REAL bytes);
  void UpdateTimingStats (cGH const * cctkGH);
  void PrintTimingStats (cGH const * cctkGH);

} // namespace Carpet

#endif // !defined(FUNCTIONS_HH)