1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 /****************************************************************************/
4 /* */
5 /* File: parallel.h */
6 /* */
7 /* Purpose: defines for parallel ugp version 3 */
8 /* */
9 /* Author: Stefan Lang, Klaus Birken */
10 /* Institut fuer Computeranwendungen III */
11 /* Universitaet Stuttgart */
12 /* Pfaffenwaldring 27 */
13 /* 70550 Stuttgart */
14 /* email: stefan@ica3.uni-stuttgart.de */
15 /* phone: 0049-(0)711-685-7003 */
16 /* fax : 0049-(0)711-685-7000 */
17 /* */
18 /* History: 09.05.95 begin, ugp version 3.0 */
19 /* */
20 /* Remarks: */
21 /* */
22 /****************************************************************************/
23
24
25 /****************************************************************************/
26 /* */
27 /* auto include mechanism and other include files */
28 /* */
29 /****************************************************************************/
30
31 #ifndef __PARALLEL_H__
32 #define __PARALLEL_H__
33
34 #include <memory>
35
36 #ifdef ModelP
37 # include <dune/uggrid/parallel/ddd/dddcontext.hh>
38 # include <dune/uggrid/parallel/ppif/ppif.h>
39 #endif
40
41 #include <dune/uggrid/low/heaps.h>
42 #include <dune/uggrid/low/namespace.h>
43
44 #ifdef ModelP
45 #include <dune/uggrid/parallel/ddd/include/ddd.h>
46 #endif
47
48 #include <dune/uggrid/gm/gm.h>
49 #include <dune/uggrid/gm/pargm.h>
50
51 START_UGDIM_NAMESPACE
52
53 /****************************************************************************/
54 /* */
55 /* defines in the following order */
56 /* */
57 /* compile time constants defining static data size (i.e. arrays) */
58 /* other constants */
59 /* macros */
60 /* */
61 /****************************************************************************/
62
63 #ifndef DUNE_UGGRID_HAVE_DDDCONTEXT
64 # define DUNE_UGGRID_HAVE_DDDCONTEXT 1
65 #endif
66
67 #define MAXDDDTYPES 32
68
69 enum HandlerSets
70 {
71 HSET_XFER = 0,
72 HSET_REFINE
73 };
74
75
76 #ifdef ModelP
77
78 /* CE for nodes */
79 /* not used, kb 961216
80 #define KEEP_VECTOR 0*/ /* this is a node with vector */
81 /*#define DEL_VECTOR 1*/ /* this is a node without vector */
82
83 /* status output from different parallel phases */
84 /*
85 #define STAT_OUT
86 */
87
88 /* define DDD_PRIO_ENV to change priority using fast PrioBegin/End env. */
89 /*
90 #define DDD_PRIO_ENV
91 */
92 #ifdef DDD_PRIO_ENV
93 #define DDD_PrioritySet(context, h,p) {ObjectPriorityUpdate(context, (DDD_OBJ)h,p); DDD_PrioChange(context, h,p);}
94 #endif
95
96 #define UGTYPE(context, t) (ddd_ctrl(context).ugtypes[(t)])
97 #define DDDTYPE(context, t) (ddd_ctrl(context).types[(t)])
98 #define HAS_DDDHDR(context, t) (ddd_ctrl(context).dddObj[(t)])
99
100 #define DDD_DOMAIN_DATA DDD_USER_DATA+1
101 #define DDD_EXTRA_DATA DDD_USER_DATA+2
102
103 /* macros for ddd object info */
104 /* for elements */
105 #define EPRIO(e) (Priorities)DDD_InfoPriority(PARHDRE(e))
106 #define SETEPRIO(context, e,p) DDD_PrioritySet(context, PARHDRE(e),p)
107 #define SETEPRIOX(context, e,p) if (EPRIO(e)!=p) DDD_PrioritySet(context, PARHDRE(e),p)
108 #define EMASTER(e) (EPRIO(e) == PrioMaster)
109 #define EGHOST(e) (EPRIO(e)==PrioHGhost || EPRIO(e)==PrioVGhost ||\
110 EPRIO(e)==PrioVHGhost)
111 #define EVHGHOST(e) (EPRIO(e)==PrioVHGhost)
112 #define EVGHOST(e) (EPRIO(e)==PrioVGhost || EPRIO(e)==PrioVHGhost)
113 #define EHGHOST(e) (EPRIO(e)==PrioHGhost || EPRIO(e)==PrioVHGhost)
114 #define EGID(e) DDD_InfoGlobalId(PARHDRE(e))
115 #define EPROCLIST(context, e) DDD_InfoProcList(context, PARHDRE(e))
116 #define EPROCPRIO(context, e,p) DDD_InfoProcPrio(context, PARHDRE(e),p)
117 #define ENCOPIES(context, e) DDD_InfoNCopies(context, PARHDRE(e))
118 #define EATTR(e) DDD_InfoAttr(PARHDRE(e))
119 #define XFEREDELETE(context, e) DDD_XferDeleteObj(context, PARHDRE(e))
120 #define XFERECOPY(context, e,dest,prio) DDD_XferCopyObj(context, PARHDRE(e),dest,prio)
121 #define XFERECOPYX(context, e,dest,prio,size) DDD_XferCopyObjX(context, PARHDRE(e),dest,prio,size)
122
123 /* for nodes, vectors, edges (edges only 3D) */
124 #define PRIO(e) DDD_InfoPriority(PARHDR(e))
125 #define SETPRIO(context, e,p) DDD_PrioritySet(context, PARHDR(e),p)
126 #define SETPRIOX(context, e,p) if (PRIO(e)!=p) DDD_PrioritySet(context, PARHDR(e),p)
127 #define MASTER(e) (PRIO(e)==PrioMaster || PRIO(e)==PrioBorder)
128 #define GHOST(e) (PRIO(e)==PrioHGhost || PRIO(e)==PrioVGhost ||\
129 PRIO(e)==PrioVHGhost)
130 #define VHGHOST(e) (PRIO(e)==PrioVHGhost)
131 #define VGHOST(e) (PRIO(e)==PrioVGhost || PRIO(e)==PrioVHGhost)
132 #define HGHOST(e) (PRIO(e)==PrioHGhost || PRIO(e)==PrioVHGhost)
133 #define GID(e) DDD_InfoGlobalId(PARHDR(e))
134 #define PROCLIST(context, e) DDD_InfoProcList(context, PARHDR(e))
135 #define PROCPRIO(context, e,p) DDD_InfoProcPrio(context, PARHDR(e),p)
136 #define NCOPIES(context, e) DDD_InfoNCopies(context, PARHDR(e))
137 #define ATTR(e) DDD_InfoAttr(PARHDR(e))
138 #define XFERDELETE(context, e) DDD_XferDeleteObj(context, PARHDR(e))
139 #define XFERCOPY(context, e,dest,prio) DDD_XferCopyObj(context, PARHDR(e),dest,prio)
140 #define XFERCOPYX(context, e,dest,prio,size) DDD_XferCopyObjX(context, PARHDR(e),dest,prio,size)
141
142 /* for vertices */
143 #define VXPRIO(e) DDD_InfoPriority(PARHDRV(e))
144 #define SETVXPRIO(context, e,p) DDD_PrioritySet(context, PARHDRV(e),p)
145 #define SETVXPRIOX(context, e,p) if (VXPRIO(e)!=p) DDD_PrioritySet(context, PARHDRV(e),p)
146 #define VXMASTER(e) (VXPRIO(e)==PrioMaster || VXPRIO(e)==PrioBorder)
147 #define VXGHOST(e) (VXPRIO(e)==PrioHGhost || VXPRIO(e)==PrioVGhost ||\
148 VXPRIO(e)==PrioVHGhost)
149 #define VXVHGHOST(e) (VXPRIO(e)==PrioVHGhost)
150 #define VXVGHOST(e) (VXPRIO(e)==PrioVGhost || VXPRIO(e)==PrioVHGhost)
151 #define VXHGHOST(e) (VXPRIO(e)==PrioHGhost || VXPRIO(e)==PrioVHGhost)
152 #define VXGID(e) DDD_InfoGlobalId(PARHDRV(e))
153 #define VXPROCLIST(context, e) DDD_InfoProcList(context, PARHDRV(e))
154 #define VXPROCPRIO(context, e,p) DDD_InfoProcPrio(context, PARHDRV(e),p)
155 #define VXNCOPIES(context, e) DDD_InfoNCopies(context, PARHDRV(e))
156 #define VXATTR(e) DDD_InfoAttr(PARHDRV(e))
157 #define XFERVXDELETE(context, e) DDD_XferDeleteObj(context, PARHDRV(e))
158 #define XFERVXCOPY(context, e,dest,prio) DDD_XferCopyObj(context, PARHDRV(e),dest,prio,size)
159 #define XFERVXCOPYX(context, e,dest,prio,size) DDD_XferCopyObjX(context, PARHDRV(e),dest,prio,size)
160
161 /* macros for priorities */
162 /* for elements */
163 #define EMASTERPRIO(p) (p==PrioMaster)
164 #define EGHOSTPRIO(p) (p==PrioHGhost || p==PrioVGhost || p==PrioVHGhost)
165 #define EVHGHOSTPRIO(p) (p==PrioVHGhost)
166 #define EVGHOSTPRIO(p) (p==PrioVGhost || p==PrioVHGhost)
167 #define EHGHOSTPRIO(p) (p==PrioHGhost || p==PrioVHGhost)
168
169 /* for nodes, vertices, vectors, edges (edges only 3D) */
170 #define MASTERPRIO(p) (p==PrioMaster || p==PrioBorder)
171 #define GHOSTPRIO(p) (p==PrioHGhost || p==PrioVGhost || p==PrioVHGhost)
172 #define VHGHOSTPRIO(p) (p==PrioVHGhost)
173 #define VGHOSTPRIO(p) (p==PrioVGhost || p==PrioVHGhost)
174 #define HGHOSTPRIO(p) (p==PrioHGhost || p==PrioVHGhost)
175
176 #define EGID_FMT DDD_GID_FMT
177 #define GID_FMT DDD_GID_FMT
178
179 /* This exchanges in the load balancing the connections too.
180 #define __EXCHANGE_CONNECTIONS__ */
181
182 #endif /* ModelP */
183
184
185 /****************************************************************************/
186 /* */
187 /* data structures exported by the corresponding source file */
188 /* */
189 /****************************************************************************/
190
191
192 /****************************************************************************/
193 /* */
194 /* definition of exported global variables */
195 /* */
196 /****************************************************************************/
197
198 #ifdef ModelP
199 /* DDD Interfaces */
200 extern DDD_IF ElementIF, ElementSymmIF, ElementVIF, ElementSymmVIF,
201 ElementVHIF, ElementSymmVHIF;
202 extern DDD_IF BorderNodeIF, BorderNodeSymmIF, OuterNodeIF, NodeVIF,
203 NodeIF, NodeAllIF, Node_InteriorBorder_All_IF;
204 extern DDD_IF BorderVectorIF, BorderVectorSymmIF,
205 OuterVectorIF, OuterVectorSymmIF,
206 VectorVIF, VectorVAllIF, VectorIF;
207 extern DDD_IF Facet_All_All_IF,
208 Facet_InteriorBorder_All_IF;
209 extern DDD_IF EdgeIF, BorderEdgeSymmIF, EdgeHIF, EdgeVHIF,
210 EdgeSymmVHIF;
211
212 /* DDD Global Controls */
213 struct DDD_CTRL
214 {
215 /* data from ug */
216 MULTIGRID *currMG;
217 FORMAT *currFormat;
218 int nodeData;
219 int edgeData;
220 int elemData;
221 int sideData;
222
223 INT ugtypes[MAXDDDTYPES]; /* dddtype -> ugtype */
224 DDD_TYPE types[MAXOBJECTS]; /* ugtype -> dddtype */
225 bool dddObj[MAXOBJECTS];
226
227 /* status of DDDIF */
228 bool allTypesDefined;
229
230 /* DDD objects */
231 DDD_TYPE TypeVector;
232 DDD_TYPE TypeIVertex, TypeBVertex;
233 DDD_TYPE TypeNode;
234
235 DDD_TYPE TypeUnknown;
236
237 #ifdef __TWODIM__
238 DDD_TYPE TypeTrElem, TypeTrBElem, TypeQuElem, TypeQuBElem;
239 #endif
240
241 #ifdef __THREEDIM__
242 DDD_TYPE TypeTeElem, TypeTeBElem;
243 DDD_TYPE TypePyElem, TypePyBElem;
244 DDD_TYPE TypePrElem, TypePrBElem;
245 DDD_TYPE TypeHeElem, TypeHeBElem;
246 #endif
247
248 /* DDD data objects */
249 DDD_TYPE TypeMatrix;
250 DDD_TYPE TypeBndP;
251 DDD_TYPE TypeEdge;
252 DDD_TYPE TypeBndS;
253
254 /* DDD Interfaces */
255 DDD_IF ElementIF, ElementSymmIF, ElementVIF, ElementSymmVIF,
256 ElementVHIF, ElementSymmVHIF;
257 DDD_IF BorderNodeIF, BorderNodeSymmIF, OuterNodeIF, NodeVIF,
258 NodeIF, NodeAllIF, Node_InteriorBorder_All_IF;
259 DDD_IF BorderVectorIF, BorderVectorSymmIF,
260 OuterVectorIF, OuterVectorSymmIF,
261 VectorVIF, VectorVAllIF, VectorIF;
262 DDD_IF Facet_All_All_IF,
263 Facet_InteriorBorder_All_IF;
264 DDD_IF VertexIF;
265 DDD_IF EdgeIF, BorderEdgeSymmIF, EdgeHIF, EdgeVHIF,
266 EdgeSymmVHIF;
267 };
268
269 #endif
270
271 /****************************************************************************/
272 /* */
273 /* function declarations */
274 /* */
275 /****************************************************************************/
276
277 #ifdef ModelP
278
279 /**
280 * accessor function for DDD user context
281 */
282 inline
ddd_ctrl(const DDD::DDDContext & context)283 const DDD_CTRL& ddd_ctrl(const DDD::DDDContext& context)
284 {
285 return *static_cast<const DDD_CTRL*>(context.data());
286 }
287
288 /**
289 * accessor function for DDD user context
290 */
291 inline
ddd_ctrl(DDD::DDDContext & context)292 DDD_CTRL& ddd_ctrl(DDD::DDDContext& context)
293 {
294 return *static_cast<DDD_CTRL*>(context.data());
295 }
296
297 /* from initddd.c */
298 int InitDDD(DDD::DDDContext& context);
299 int ExitDDD(DDD::DDDContext& context);
300 void InitCurrMG (MULTIGRID *);
301
302 /* from debugger.c */
303 void ddd_pstat (DDD::DDDContext& context, char *);
304
305 /* from lb.c */
306 void lbs (const char *argv, MULTIGRID *theMG);
307
308 /* from handler.c */
309 void ddd_HandlerInit (DDD::DDDContext& context, INT);
310 DDD_TYPE NFatherObjType (DDD::DDDContext& context, DDD_OBJ obj, DDD_OBJ ref);
311 void ObjectPriorityUpdate (DDD::DDDContext& context, DDD_OBJ obj, DDD_PRIO newPrio);
312
313 /* from lbrcb.c */
314 void BalanceGridRCB (MULTIGRID *, int);
315
316 /* from gridcons.c */
317 void ConstructConsistentGrid (GRID *theGrid);
318 void ConstructConsistentMultiGrid (MULTIGRID *theMG);
319
320 /* from pgmcheck.c */
321 INT CheckProcListCons (int *proclist, int uniqueTag);
322 INT CheckInterfaces (GRID *theGrid);
323
324 /* from priority.c */
325 INT SetGridBorderPriorities (GRID *theGrid);
326 void SetGhostObjectPriorities (GRID *theGrid);
327
328 /* from trans.c */
329 int TransferGrid (MULTIGRID *theMG);
330 int TransferGridFromLevel (MULTIGRID *theMG, INT level);
331
332 /* from identify.c */
333 void IdentifyInit (MULTIGRID *theMG);
334 void IdentifyExit (void);
335 INT Identify_Objects_of_ElementSide (GRID *theGrid, ELEMENT *theElement, INT i);
336 INT Identify_SonNodesAndSonEdges (GRID *theGrid);
337
338 /* from overlap.c */
339
340 INT UpdateGridOverlap (GRID *theGrid);
341 INT ConnectGridOverlap (GRID *theGrid);
342 INT ConnectVerticalOverlap (MULTIGRID *theMG);
343
344 /* from priority.c */
345 void SetGhostObjectPriorities (GRID *theGrid);
346 INT SetBorderPriorities (GRID *theGrid);
347 INT SetGridBorderPriorities (GRID *theGrid);
348
349 /* from partition.c */
350 INT CheckPartitioning (MULTIGRID *theMG);
351 INT RestrictPartitioning (MULTIGRID *theMG);
352
353 /* from pgmcheck.c */
354 INT CheckInterfaces (GRID *theGrid);
355
356 /*
357 * COMPATABILITY FUNCTIONS FOR OLDER dune-grid RELEASES
358 */
359
360 /**
361 * get global DDD context.
362 * This only exists for compatability with old versions of dune-grid.
363 */
364 DDD::DDDContext& globalDDDContext();
365
366 /**
367 * set global DDD context.
368 * This only exists for compatability with old versions of dune-grid.
369 */
370 void globalDDDContext(const std::shared_ptr<DDD::DDDContext>& context);
371
372 /**
373 * invalidate global DDD context.
374 * This only exists for compatability with old versions of dune-grid.
375 */
376 void globalDDDContext(std::nullptr_t);
377
378 using ComProcPtr = int (*)(DDD_OBJ, void *);
379 void DDD_IFOneway(DDD_IF, DDD_IF_DIR, size_t, ComProcPtr, ComProcPtr);
380 int* DDD_InfoProcList(DDD_HDR);
381
382 #endif /* ModelP */
383
384 END_UGDIM_NAMESPACE
385
386 #endif /* __PARALLEL_H__ */
387