aboutsummaryrefslogtreecommitdiff
path: root/Carpet/Carpet/src/functions.hh
blob: 0f43ff2815c059f1e8b142460047725dc767edaf (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
#ifndef FUNCTIONS_HH
#define FUNCTIONS_HH

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

#include <mpi.h>

#include "cctk.h"
#include "cctk_Schedule.h"

#include "bbox.hh"
#include "dh.hh"
#include "gh.hh"
#include "vect.hh"

#include "defines.hh"


  
namespace Carpet {
  
  using namespace std;
  
  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 Exit (cGH* cgh, int retval);
  int Abort (cGH* cgh, int retval);
  int MyProc (const cGH* cgh);
  int nProcs (const cGH* cgh);
  const int* ArrayGroupSizeB (const cGH* cgh, int dir, int group,
			      const char* groupname);
  int QueryGroupStorageB (const cGH* cgh, int group, const char* groupname);
  int GroupDynamicData (const cGH* cgh, int group, cGroupDynamicData* data);
  
  void Restrict (const cGH* cgh);
  
  
  
  // Strings
  vector <string>
  AllGatherString (MPI_Comm const world,
                   string const & data);
  
  // Multi-Model
  void
  SplitUniverse (MPI_Comm const world, string const model, MPI_Comm & comm,
                 bool verbose);
  
  // Model id to model name
  vector <string> Models ();
  string Model (int id);
  
  // Model name to model id
  std::map <string, int> ModelMap ();
  int ModelMap (string name);
  
  // Processor to model id
  vector <int> ModelIds ();
  int ModelId (int proc);
  
  // Model id to processors
  vector <vector <int> > ModelProcs ();
  vector <int> ModelProcs (int proc);
  
  extern "C" {
    CCTK_POINTER_TO_CONST
    Carpet_GetMPICommUniverse (CCTK_POINTER_TO_CONST cctkGH);
    CCTK_POINTER_TO_CONST
    Carpet_GetMPICommWorld (CCTK_POINTER_TO_CONST cctkGH);
  }
  
  
  
  // Helpers for storage
  void GroupsStorageCheck (cGH const * const cctkGH);

  // Helpers for recomposing the grid hierarchy
  void
  RegridMap (cGH const * cctkGH,
             int m,
             gh::mregs const & regsss);
  void
  PostRegrid (cGH const * cctkGH);
  bool
  Recompose (cGH const * cctkGH,
             int rl,
             bool do_init);
  
  void
  CheckRegions (gh::mregs const & regsss);
  
  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);
  
  
  
  // Functions for recomposing the grid hierarchy
  void
  SplitRegions (cGH const * cctkGH,
                vector<region_t> & regs);
  void
  SplitRegions_AlongZ (cGH const * cctkGH,
                       vector<region_t> & regs);
  void
  SplitRegions_AlongDir (cGH const * cctkGH,
                         vector<region_t> & regs,
                         int const dir);
  void
  SplitRegions_Automatic (cGH const * cctkGH,
                          vector<region_t> & regs);
  void
  SplitRegions (cGH const * cctkGH,
                vector<region_t> & regss);
  
  void
  SplitRegionsMaps_Automatic (cGH const * cctkGH,
                              vector<vector<region_t> > & regss);
  
  void
  SplitRegionsMaps (cGH const * cctkGH,
                    vector<vector<region_t> > & regss);
  
  void
  MakeMultigridBoxes (cGH const * cctkGH,
                      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 InitTimingVariables (cGH const * cctkGH);
  void InitTiming (cGH const * cctkGH);
  void StepTiming (cGH const * cctkGH);
  void PrintTimingStats (cGH const * cctkGH);
  
} // namespace Carpet

#endif // !defined(FUNCTIONS_HH)