Debian Codegraph @

dune/uggrid/gm/gm.h

raw
1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 // SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
4 // SPDX-License-Identifier: LGPL-2.1-or-later
5 /*! \file gm.h
6 * \ingroup gm
7 */
8
9 /******************************************************************************/
10 /* */
11 /* File: gm.h */
12 /* */
13 /* Purpose: grid manager header file (the heart of ug) */
14 /* */
15 /* Author: Peter Bastian, Klaus Johannsen */
16 /* */
17 /* Institut fuer Computeranwendungen III */
18 /* Universitaet Stuttgart */
19 /* Pfaffenwaldring 27 */
20 /* 70569 Stuttgart */
21 /* email: [email protected] */
22 /* */
23 /* blockvector data structure: */
24 /* Christian Wrobel */
25 /* Institut fuer Computeranwendungen III */
26 /* Universitaet Stuttgart */
27 /* Pfaffenwaldring 27 */
28 /* 70569 Stuttgart */
29 /* email: [email protected] */
30 /* */
31 /* History: 09.03.92 begin, ug version 2.0 (as ugtypes2.h) */
32 /* 13.12.94 begin, ug version 3.0 */
33 /* 27.09.95 blockvector implemented (Christian Wrobel) */
34 /* */
35 /* Remarks: */
36 /* */
37 /* */
38 /******************************************************************************/
39
40 /****************************************************************************/
41 /* */
42 /* auto include mechanism and other include files */
43 /* */
44 /****************************************************************************/
45
46 #ifndef __GM__
47 #define __GM__
48
49 #include <climits>
50 #include <cassert>
51 #include <cstdlib>
52 #include <ctime>
53 #include <cmath>
54 #include <memory>
55
56 #include <unordered_map>
57 #include <array>
58 #include <numeric>
59
60 #include <dune/common/fvector.hh>
61 #include <dune/common/math.hh>
62
63 #include <dune/uggrid/domain/std_domain.h>
64 #include <dune/uggrid/low/debug.h>
65 #include <dune/uggrid/low/dimension.h>
66 #include <dune/uggrid/low/heaps.h>
67 #include <dune/uggrid/low/namespace.h>
68 #include <dune/uggrid/low/misc.h>
69 #include <dune/uggrid/low/ugenv.h>
70 #include <dune/uggrid/low/ugtypes.h>
71 #include "pargm.h"
72 #include "cw.h"
73
74 #include <dune/uggrid/parallel/ppif/ppiftypes.hh>
75 #ifdef ModelP
76 # include <dune/uggrid/parallel/ddd/dddcontext.hh>
77 #endif
78
79 /****************************************************************************/
80 /* */
81 /* derive additional switches from commandline specified basic switches */
82 /* */
83 /****************************************************************************/
84
85 #ifdef Debug
86 #define DEBUG_MODE "ON"
87 #else
88 #define DEBUG_MODE "OFF"
89 #endif
90
91 START_UGDIM_NAMESPACE
92
93 /****************************************************************************/
94 /* */
95 /* "hard" switches for interpolation matrix and block-vectors */
96 /* */
97 /****************************************************************************/
98
99 /** \brief Define to have matrices > 4KB (control word too small, adds integer to matrix struct) */
100 #define __XXL_MSIZE__
101
102 /** \brief If pointer between element/centernode is stored */
103 #undef __CENTERNODE__
104
105 /****************************************************************************/
106 /* */
107 /* defines in the following order */
108 /* */
109 /* compile time constants defining static data size (i.e. arrays) */
110 /* other constants */
111 /* macros */
112 /* */
113 /****************************************************************************/
114
115 /* Necessary for most C runtime libraries */
116 #undef DOMAIN
117
118 /** @name Some size parameters */
119 /*@{*/
120 /** \brief maximum depth of triangulation */
121 #define MAXLEVEL 32
122 /** \brief use 5 bits for object identification */
123 #define MAXOBJECTS 32
124 /*@}*/
125
126 /** @name Some size macros for allocation purposes */
127 /*@{*/
128 #ifdef UG_DIM_2
129
130 /** \brief max number of sides of an element */
131 #define MAX_SIDES_OF_ELEM 4
132 /** \brief max number of edges of an element */
133 #define MAX_EDGES_OF_ELEM 4
134 /** \brief max number of corners of an element */
135 #define MAX_CORNERS_OF_ELEM 4
136 /** \brief max number of edges of a side */
137 #define MAX_EDGES_OF_SIDE 1
138 /** \brief max number of edges meeting in a corner */
139 #define MAX_EDGES_OF_CORNER 2
140 /** \brief max number of corners of a side */
141 #define MAX_CORNERS_OF_SIDE 2
142 /** \brief two sides have one edge in common */
143 #define MAX_SIDES_OF_EDGE 2
144 /** \brief max number of sons of an element */
145 enum {MAX_SONS = 4};
146 /** \brief max number of nodes on elem side */
147 #define MAX_SIDE_NODES 3
148
149 #else // UG_DIM_3
150
151 /** \brief max number of sides of an element */
152 #define MAX_SIDES_OF_ELEM 6
153 /** \brief max number of edges of an element */
154 #define MAX_EDGES_OF_ELEM 12
155 /** \brief max number of corners of an element */
156 #define MAX_CORNERS_OF_ELEM 8
157 /** \brief max number of edges of a side */
158 #define MAX_EDGES_OF_SIDE 4
159 /** \brief max number of edges meeting in a corner */
160 #define MAX_EDGES_OF_CORNER 4
161 /** \brief max number of corners of a side */
162 #define MAX_CORNERS_OF_SIDE 4
163 /** \brief two sides have one edge in common */
164 #define MAX_SIDES_OF_EDGE 2
165 /** \brief max number of sons of an element */
166 enum {MAX_SONS = 30};
167 /** \brief max number of nodes on elem side */
168 #define MAX_SIDE_NODES 9
169
170 #endif
171
172 /** \brief an edge has always two corners.. */
173 #define CORNERS_OF_EDGE 2
174 /** \brief max number of son edges of edge */
175 #define MAX_SON_EDGES 2
176
177 /** \brief max number of doubles in a vector or matrix mod 32 */
178 #define MAX_NDOF_MOD_32 256
179 /** \brief max number of doubles in a vector or matrix */
180 #define MAX_NDOF 32*MAX_NDOF_MOD_32
181 /*@}*/
182
183
184 /****************************************************************************/
185 /* */
186 /* defines for algebra */
187 /* */
188 /****************************************************************************/
189
190 /** \brief Number of different data types */
191 #define MAXVOBJECTS 1
192 /** \brief max number of abstract vector types */
193 #define MAXVECTORS 1
194 #if (MAXVECTORS<MAXVOBJECTS)
195 #error *** MAXVECTORS must not be smaller than MAXVOBJECTS ***
196 #endif
197
198 /** \brief transforms type into bitpattern */
199 #define BITWISE_TYPE(t) (1<<(t))
200
201 /* derived sizes for algebra */
202 /** \brief max number of diff. matrix types */
203 #define MAXMATRICES MAXVECTORS*MAXVECTORS
204 /** \brief max number of diff. connections */
205 #define MAXCONNECTIONS (MAXMATRICES + MAXVECTORS)
206
207 /** \todo Please doc me! */
208 #define MATRIXTYPE(rt,ct) ((rt)*MAXVECTORS+(ct))
209 /** \todo Please doc me! */
210 #define DIAGMATRIXTYPE(rt) (MAXMATRICES+rt)
211
212 /** \brief Type of geometric entity which a certain vector is attached to */
213 enum VectorType {NOVTYPE=-1, //** Undefined */
214 SIDEVEC /**< Vector associated to an element side */
215 };
216
217 /****************************************************************************/
218 /* */
219 /* various defines */
220 /* */
221 /****************************************************************************/
222
223 /** @name result codes of user supplied functions*/
224 /*@{*/
225
226 /** \brief Use of GSTATUS (for grids), use power of 2 */
227 enum {GSTATUS_BDF = 1,
228 GSTATUS_INTERPOLATE = 2,
229 GSTATUS_ASSEMBLED = 4,
230 GSTATUS_ORDERED = 8};
231 /*@}*/
232
233 /** \brief Possible values for rule in MarkForRefinement */
234 enum RefinementRule
235 {NO_REFINEMENT = 0,
236 COPY = 1,
237 RED = 2,
238 #ifdef UG_DIM_2
239 BLUE = 3, // For quadrilaterals
240 #endif
241 COARSE = 4,
242 #ifdef UG_DIM_2
243 // The BISECTION* rules are all triangle rules
244 BISECTION_1 = 5,
245 BISECTION_2_Q = 6,
246 BISECTION_2_T1 = 7,
247 BISECTION_2_T2 = 8,
248 BISECTION_3 = 9
249 #endif
250 #ifdef UG_DIM_3
251
252 TETRA_RED_HEX = 5,
253
254 PRISM_BISECT_1_2 = 9,
255 PRISM_QUADSECT = 7,
256 PRISM_BISECT_HEX0 = 5,
257 PRISM_BISECT_HEX1 = 8,
258 PRISM_BISECT_HEX2 = 6,
259 PRISM_ROTATE_LEFT = 10,
260 PRISM_ROTATE_RGHT = 11,
261 PRISM_QUADSECT_HEXPRI0 = 14,
262 PRISM_RED_HEX = 15,
263 PRISM_BISECT_0_1, /* No explicit numbers. Maybe they are not necessary? */
264 PRISM_BISECT_0_2,
265 PRISM_BISECT_0_3,
266
267 HEX_BISECT_0_1 = 5,
268 HEX_BISECT_0_2 = 6,
269 HEX_BISECT_0_3 = 7,
270 HEX_TRISECT_0 = 8,
271 HEX_TRISECT_5 = 9,
272 HEX_QUADSECT_0 = 12,
273 HEX_QUADSECT_1 = 13,
274 HEX_QUADSECT_2 = 14,
275 HEX_BISECT_HEXPRI0 = 15,
276 HEX_BISECT_HEXPRI1 = 16
277
278 #endif
279 };
280
281 /** \brief Values for element class */
282 enum MarkClass {NO_CLASS,
283 YELLOW_CLASS,
284 GREEN_CLASS,
285 RED_CLASS,
286 SWITCH_CLASS};
287
288 /** \brief Values for node types (relative to the father element of the vertex) */
289 enum NodeType {CORNER_NODE,
290 MID_NODE,
291 SIDE_NODE,
292 CENTER_NODE,
293 LEVEL_0_NODE};
294
295 /* REMARK: TOPNODE no more available since 970411
296 because of problems in parallelisation
297 to use it in serial version uncomment define
298 #define TOPNODE(p) ((p)->iv.topnode)
299 */
300
301 /****************************************************************************/
302 /* */
303 /* format definition data structure */
304 /* */
305 /****************************************************************************/
306
307 /*----------- general typedefs ---------------------------------------------*/
308
309 /** @name General typedefs */
310 /*@{*/
311 using DOUBLE_VECTOR = FieldVector<DOUBLE,DIM>;
312 /*@}*/
313
314
315 /*----------- definition of structs ----------------------------------------*/
316
317 /****************************************************************************/
318 /* */
319 /* matrix/vector/blockvector data structure */
320 /* */
321 /****************************************************************************/
322
323 /** \brief Data type for unknowns in sparse matrix structure
324
325 The VECTOR data type is part of the sparse matrix vector data structure.
326 A VECTOR stores a user definable number of DOUBLE values and
327 is associated with a geometric object of the mesh (nodes, edges, sides and elements).
328 The size of the VECTOR can be specified differently for each type of
329 geometric object, but not (yet) for each individual VECTOR object.
330 Since there are four different geometric objects that can have degrees
331 of freedom, there are four different `vector types`. The vector type
332 is stored in the control word (see VTYPE macro) but currently it can only have
333 the value SIDEVECTOR.
334
335 The VECTOR provides access to the rows of the sparse matrix belonging to
336 all degrees of freedom stored in the vector.
337
338 MACROS:
339
340 `General macros in control word`
341
342 \verbatim
343 Macro name Pos Len Purpose
344 -----------------------------------------------------------------------------
345 INT OBJT (VECTOR *p); 27 5 Object type VEOBJ
346 void SETOBJT (VECTOR *p, INT n);
347
348 INT USED (VECTOR *p); 23 1 used only temporarily
349 void SETUSED (VECTOR *p, INT n);
350
351 INT TAG (VECTOR *p); 24 3 not used
352 void SETTAG (VECTOR *p, INT n);
353
354 INT THEFLAG (VECTOR *p); 16 1 used only temporarily
355 void SETTHEFLAG (VECTOR *p, INT n);
356 -----------------------------------------------------------------------------
357 \endverbatim
358
359 `Macros for the VECTOR structure in control`
360
361 \verbatim
362 Macro name Pos Len Purpose
363 -----------------------------------------------------------------------------
364 VTYPE (VECTOR *v); 0 2 Type of geometric object the
365 SETVTYPE (VECTOR *v, INT n); vector belongs to. Values:
366 NODEVECTOR, EDGEVECTOR, SIDEVECTOR
367 or ELEMVECTOR.
368
369 VCOUNT (VECTOR *v); 5 2 internal use
370 SETVCOUNT (VECTOR *v, INT n);
371
372 VECTORSIDE (VECTOR *v); 7 2 Side in VOBJECT where VECTOR
373 SETVECTORSIDE (VECTOR *v, INT n); belongs to (SIDEVECTOR only)
374
375 VCLASS (VECTOR *v); 11 2 Vector class for local multigrid
376 SETVCLASS (VECTOR *v, INT n); between 0 and 3.
377
378 VDATATYPE (VECTOR *v); 13 4 This is 2^VTYPE(v)
379 SETVDATATYPE (VECTOR *v, INT n);
380
381 VNCLASS (VECTOR *v); 17 2 Vector class of vector at same
382 SETVNCLASS (VECTOR *v, INT n); position on finer level
383
384 VNEW (VECTOR *v); 19 1 True if VECTOR has been created
385 SETVNEW (VECTOR *v, INT n); in last refinement step.
386
387 VCNEW (VECTOR *v); 20 1 True if VECTOR got a new
388 SETVCNEW (VECTOR *v, INT n); connection in refinement
389 -----------------------------------------------------------------------------
390 \endverbatim
391
392 \sa NODE, EDGE, ELEMENT.
393
394 */
395 struct vector {
396
397 /** \brief object identification, various flags */
398 UINT control;
399
400 /** \brief associated geometric object */
401 union geom_object *object;
402
403 #ifdef ModelP
404 /** \todo Please doc me! */
405 DDD_HEADER ddd;
406 #endif
407
408 /** \brief double linked list of vectors */
409 struct vector *pred,*succ;
410
411 /** \brief ordering of unknowns */
412 UINT index;
413
414 /** \brief Index if the vector is part of the leaf grid */
415 UINT leafIndex;
416
417 #ifndef ModelP // Dune uses ddd.gid for ids in parallel
418 /** \brief A unique and persistent, but not necessarily consecutive index
419
420 Used to implement face ids for Dune.
421 */
422 INT id;
423 #endif
424
425 /** \brief User data
426 *
427 * Array of double values. This array is allocated dynamically with the
428 * size specified in the FORMAT structure.
429 */
430 DOUBLE value[1];
431 };
432 typedef struct vector VECTOR;
433
434
435 /****************************************************************************/
436 /* */
437 /* unstructured grid data structures */
438 /* */
439 /****************************************************************************/
440
441 /*----------- typedef for functions ----------------------------------------*/
442
443
444 /*----------- definition of structs ----------------------------------------*/
445
446 /** \brief Inner vertex data structure
447 Data type storing level-independent node information
448
449 The VERTEX structure stores the level independent information of
450 a NODE. If several NODEs on different levels of the MULTIGRID structure
451 are at the same position then they share a common VERTEX object.
452 The VERTEX is a union of inner vertex ivertex and boundary vertex bvertex.
453 The bvertex has all of the ivertex plus some extra information where
454 the vertex is on the boundary of the domain. In the code one always works with
455 pointers of type VERTEX * and accesses the components through the macros described
456 below.
457
458 CONTROL WORDS:
459
460 The first word of many UG data structure is used bitwise for various purposes.
461
462 `General macros available for all objects`
463 \verbatim
464 Macro name Pos Len Purpose
465 -----------------------------------------------------------------------------
466 INT OBJT (VERTEX *p); 27 5 Object type IVOBJ for inner
467 void SETOBJT (VERTEX *p, INT n); and BVOBJ for boundary vertex
468
469 INT USED (VERTEX *p); 23 1 used only temporarily
470 void SETUSED (VERTEX *p, INT n);
471
472 INT TAG (VERTEX *p); 24 3 available for user
473 void SETTAG (VERTEX *p, INT n);
474
475 INT LEVEL (VERTEX *p); 17 5 level on which vertex is
476 void SETLEVEL (VERTEX *p, INT n); defined
477
478 INT THEFLAG (VERTEX *p); 16 1 used only temporarily
479 void SETTHEFLAG (VERTEX *p, INT n);
480 -----------------------------------------------------------------------------
481 \endverbatim
482
483 `Macros specific to the VERTEX structure`
484 \verbatim
485 Macro name Pos Len Purpose
486 -----------------------------------------------------------------------------
487 INT MOVE (VERTEX *p); 4 2 Number of dimensions in which
488 void SETMOVE (VERTEX *p, INT n); a vertex can be moved:
489 0: vertices at corners
490 1: boundary vertex in 2D
491 2: inner in 2D, boundary in 3D
492 3: inner in 3D
493
494 INT MOVED (VERTEX *p); 0 1 TRUE if vertex has been moved
495 void SETMOVED (VERTEX *p, INT n); away from initial position.
496
497 INT ONEDGE (VERTEX *p); 1 3 Edge in father element of vertex
498 void SETONEDGE (VERTEX *p, INT n); on which this vertex resides.
499 2D: only valid for boundary vertex!
500 -----------------------------------------------------------------------------
501 \endverbatim
502 D*/
503 struct ivertex {
504
505 /** \brief Object identification, various flags */
506 UINT control;
507
508 /** \brief Unique id used for load/store */
509 INT id;
510
511 /** \brief Vertex position */
512 FieldVector<DOUBLE,DIM> x;
513
514 /** \brief Local coordinates in father element
515 *
516 * This is used to represent the multigrid hierarchy. The father component points
517 * to an ELEMENT of the next coarser grid level and xi gives the position of the VERTEX
518 * within this element in the local coordinate system of the ELEMENT. In this way
519 * also loosely coupled grids can be represented although the grid refinement algorithm
520 * is currently not able to produce such grids. The solvers however would work
521 * also on much more general multigrid hierarchies.
522 */
523 FieldVector<DOUBLE,DIM> xi;
524
525 /* When UG is used as part of the DUNE numerics system we need
526 a few more indices per node */
527
528 /** \brief An index hat is unique and consecutive per level.
529 Controlled by DUNE */
530 int leafIndex;
531
532 #ifdef ModelP
533 /** \todo Please doc me! */
534 DDD_HEADER ddd;
535 #endif
536
537 /** \brief Doubly linked list of vertices
538 *
539 * Pointers realizing a double linked list of VERTEX objects per level.
540 * The beginning of this list is in the GRID structure.
541 */
542 union vertex *pred,*succ;
543
544 /** \brief Associated user data structure */
545 void *data;
546
547 /** \brief Father element */
548 union element *father;
549
550 #ifdef TOPNODE
551 /** \brief Highest node where defect is valid
552 \todo REMARK: TOPNODE no more available since 970411
553 because of problems in parallelisation
554 to use it in serial version uncomment define TOPNODE
555
556 If several NODES share this VERTEX then this pointer refers
557 to the NODE on the highest level. This pointer will probably `not` be supported
558 in the next version, its use is not recommended!
559 */
560 struct node *topnode;
561 #endif
562 };
563
564 /** \brief Boundary vertex data structure
565
566 Data type storing level-independent node information
567
568 The VERTEX structure stores the level independent information of
569 a NODE. If several NODEs on different levels of the MULTIGRID structure
570 are at the same position then they share a common VERTEX object.
571 The VERTEX is a union of inner vertex ivertex and boundary vertex bvertex.
572 The bvertex has all of the ivertex plus some extra information where
573 the vertex is on the boundary of the domain. In the code one always works with
574 pointers of type VERTEX * and accesses the components through the macros described
575 below.
576
577 CONTROL WORDS:
578
579 The first word of many UG data structure is used bitwise for various purposes.
580
581 `General macros available for all objects`
582 \verbatim
583 Macro name Pos Len Purpose
584 -----------------------------------------------------------------------------
585 INT OBJT (VERTEX *p); 27 5 Object type IVOBJ for inner
586 void SETOBJT (VERTEX *p, INT n); and BVOBJ for boundary vertex
587
588 INT USED (VERTEX *p); 23 1 used only temporarily
589 void SETUSED (VERTEX *p, INT n);
590
591 INT TAG (VERTEX *p); 24 3 available for user
592 void SETTAG (VERTEX *p, INT n);
593
594 INT LEVEL (VERTEX *p); 17 5 level on which vertex is
595 void SETLEVEL (VERTEX *p, INT n); defined
596
597 INT THEFLAG (VERTEX *p); 16 1 used only temporarily
598 void SETTHEFLAG (VERTEX *p, INT n);
599 -----------------------------------------------------------------------------
600 \endverbatim
601
602 `Macros specific to the VERTEX structure`
603 \verbatim
604 Macro name Pos Len Purpose
605 -----------------------------------------------------------------------------
606 INT MOVE (VERTEX *p); 4 2 Number of dimensions in which
607 void SETMOVE (VERTEX *p, INT n); a vertex can be moved:
608 0: vertices at corners
609 1: boundary vertex in 2D
610 2: inner in 2D, boundary in 3D
611 3: inner in 3D
612
613 INT MOVED (VERTEX *p); 0 1 TRUE if vertex has been moved
614 void SETMOVED (VERTEX *p, INT n); away from initial position.
615
616 INT ONEDGE (VERTEX *p); 1 3 Edge in father element of vertex
617 void SETONEDGE (VERTEX *p, INT n); on which this vertex resides.
618 2D: only valid for boundary vertex!
619 -----------------------------------------------------------------------------
620 \endverbatim
621 D*/
622 struct bvertex {
623
624 /* variables */
625 /** \brief Object identification, various flags */
626 UINT control;
627
628 /** \brief Unique id used for load/store */
629 INT id;
630
631 /** \brief Vertex position */
632 FieldVector<DOUBLE,DIM> x;
633
634 /** \brief Local coordinates in father element
635 *
636 * This is used to represent the multigrid hierarchy. The father component points
637 * to an ELEMENT of the next coarser grid level and xi gives the position of the VERTEX
638 * within this element in the local coordinate system of the ELEMENT. In this way
639 * also loosely coupled grids can be represented although the grid refinement algorithm
640 * is currently not able to produce such grids. The solvers however would work
641 * also on much more general multigrid hierarchies.
642 */
643 FieldVector<DOUBLE,DIM> xi;
644
645 /* When UG is used as part of the DUNE numerics system we need
646 a few more indices per node */
647
648 /** \brief An index hat is unique and consecutive per level.
649 Controlled by DUNE */
650 int leafIndex;
651
652 #ifdef ModelP
653 /** \brief Information about the parallelization of this object */
654 DDD_HEADER ddd;
655 #endif
656
657 /* pointers */
658 /** \brief Doubly linked list of vertices */
659 union vertex *pred,*succ;
660
661 /** \brief Associated user data structure */
662 void *data;
663
664 /** \brief Father element */
665 union element *father;
666
667 #ifdef TOPNODE
668 /** \brief Highest node where defect is valid
669 \todo REMARK: TOPNODE no more available since 970411
670 because of problems in parallelisation
671 to use it in serial version uncomment define TOPNODE */
672 struct node *topnode;
673 #endif
674
675 /** \brief Pointer to boundary point descriptor */
676 BNDP *bndp;
677 };
678
679 /** \brief Only used to define pointer to vertex */
680 union vertex {
681 struct ivertex iv;
682 struct bvertex bv;
683 };
684
685 /** \brief Level-dependent part of a vertex
686
687 Each node of the mesh is represented by a NODE structure. When a mesh is refined
688 then new NODE objects are allocated on the new grid level
689 even at those positions where nodes were already in the coarse mesh. However, NODEs
690 at the same position share a common VERTEX structure.
691 A node provides access to all neighboring nodes via the LINK structure. There
692 is `no` access from a node to all the elements having the node as a corner!
693
694 CONTROL WORDS:
695
696 `General macros available for all objects`
697 \verbatim
698 Macro name Pos Len Purpose
699 -----------------------------------------------------------------------------
700 INT OBJT (NODE *p); 27 5 Object type NDOBJ for a node.
701 void SETOBJT (NODE *p, INT n);
702
703 INT USED (NODE *p); 23 1 used only temporarily
704 void SETUSED (NODE *p, INT n);
705
706 INT TAG (NODE *p); 24 3 available for user
707 void SETTAG (NODE *p, INT n);
708
709 INT LEVEL (NODE *p); 17 5 level on which node is
710 void SETLEVEL (NODE *p, INT n); allocated
711
712 INT THEFLAG (NODE *p); 16 1 used only temporarily
713 void SETTHEFLAG (NODE *p, INT n);
714 -----------------------------------------------------------------------------
715 \endverbatim
716
717 `Macros for the NODE structure`
718
719 \verbatim
720 Macro name Pos Len Purpose
721 -----------------------------------------------------------------------------
722 INT CLASS (NODE *p); 0 3 node class for local multigrid
723 void SETCLASS (NODE *p, INT n); only for backward compatibility
724
725 INT NCLASS (NODE *p); 3 3 node class for node on next level
726 void SETNCLASS (NODE *p, INT n); only for backward compatibility
727
728 INT MODIFIED (NODE *p); 6 1 is true when node has been created
729 void SETMODIFIED (NODE *p, INT n); or modified during last refinement
730 step. This in 2D only !
731
732 INT NPROP (NODE *p); 7 8 node property derived from
733 void SETNPROP (NODE *p, INT n); element property.
734 -----------------------------------------------------------------------------
735 \endverbatim
736
737 \sa
738
739 VERTEX, LINK, GRID.
740
741 D*/
742 struct node {
743
744 /** \brief Object identification, various flags */
745 UINT control;
746
747 /** \brief Unique id used for load/store */
748 INT id;
749
750 /* When UG is used as part of the DUNE numerics system we need
751 a few more indices per node */
752
753 /** \brief An index hat is unique and consecutive per level.
754 Controlled by DUNE */
755 int levelIndex;
756
757 /** \brief Information if this node is on the leaf. */
758 bool isLeaf;
759
760 #ifdef ModelP
761 /** \brief Per-node message buffer used by Dune for dynamic load-balancing */
762 char* message_buffer_;
763
764 /** \brief Size of the `message_buffer` */
765 std::size_t message_buffer_size_;
766 #endif
767
768 #ifdef ModelP
769 /** \brief Information about the parallelization of this object */
770 DDD_HEADER ddd;
771 #endif
772
773 /* pointers */
774 /** \brief Doubly linked list of nodes per level*/
775 struct node *pred,*succ;
776
777 /** \brief List of links
778 *
779 * Points to the first element of the LINK list. The LINK list
780 * provides access to all neighbors of the node.
781 */
782 struct link *start;
783
784 /** \brief Node or edge on coarser level (NULL if none) */
785 union geom_object *father;
786
787 /** \brief Node on finer level (NULL if none) */
788 struct node *son;
789
790 /** \brief Corresponding vertex structure */
791 union vertex *myvertex;
792
793 #ifdef ModelP
794 const char* message_buffer() const
795 { return message_buffer_; }
796
797 std::size_t message_buffer_size() const
798 { return message_buffer_size_; }
799
800 void message_buffer(char* p, std::size_t size)
801 {
802 message_buffer_ = p;
803 message_buffer_size_ = size;
804 }
805
806 void message_buffer_free()
807 {
808 std::free(message_buffer_);
809 message_buffer(nullptr, 0);
810 }
811 #endif
812 };
813
814 /** \brief Data type realizing a list of neighbors of a node
815
816 The \ref link structures form a single linked list starting in each NODE.
817 Two nodes are said to be neighbors if they are connected by an edge `in the mesh`.
818 Note that this is only the geometric neighborship, which can be different from the
819 algebraic neighborship derived from the non-zero structure of the global stiffness matrix.
820 Each LINK provides a pointer to one neighbor of the NODE where the list
821 starts. The neighbor relationship is symmetric, therefore if node `a` is a neighbor
822 of node `b` then `a` occurs in the list of `b` and vice versa. These two link structures
823 are then combined in an EDGE structure.
824
825 MACROS:
826
827 #NBNODE(LINK *p)
828 #NEXT(LINK *p)
829 #MYEDGE(LINK *p)
830 #REVERSE (LINK *p)
831
832 CONTROL WORDS:
833
834 `General macros available for all objects`
835 \verbatim
836 Macro name Pos Len Purpose
837 -----------------------------------------------------------------------------
838 INT OBJT (LINK *p); 27 5 Object type EDOBJ for first
839 void SETOBJT (LINK *p, INT n); LINK of an EDGE
840
841 INT USED (LINK *p); 23 1 used only temporarily
842 void SETUSED (LINK *p, INT n);
843
844 INT THEFLAG (LINK *p); 16 1 used only temporarily
845 void SETTHEFLAG (LINK *p, INT n);
846 -----------------------------------------------------------------------------
847 \endverbatim
848
849 `Macros for the LINK structure`
850
851 \verbatim
852 Macro name Pos Len Purpose
853 -----------------------------------------------------------------------------
854 INT LOFFSET (LINK *p); 0 1 0 if first LINK of EDGE
855 void SETLOFFSET (LINK *p, INT n); 1 if second LINK of EDGE
856 -----------------------------------------------------------------------------
857 \endverbatim
858
859 \sa edge, node
860 */
861 struct link {
862
863 /** \brief object identification, various flags */
864 UINT control;
865
866 /** \brief ptr to next link */
867 struct link *next;
868
869 /** \brief ptr to neighbor node */
870 struct node *nbnode;
871
872 /** \brief ptr to neighboring elem */
873 #if defined(UG_DIM_2)
874 union element *elem;
875 #endif
876
877 };
878
879 /** \brief Undirected edge of the grid graph
880
881 The EDGE data type combines LINK structures to form an `undirected`
882 connection of two NODEs. An EDGE represents an edge of the mesh.
883
884 CONTROL WORDS:
885
886 `General macros available for all objects`
887 \verbatim
888 Macro name Pos Len Purpose
889 -----------------------------------------------------------------------------
890 INT OBJT (EDGE *p); 27 5 Object type EDOBJ for an edge
891 void SETOBJT (EDGE *p, INT n);
892
893 INT USED (EDGE *p); 23 1 used only temporarily
894 void SETUSED (EDGE *p, INT n);
895
896 INT LEVEL (EDGE *p); 17 5 level on which edge is
897 void SETLEVEL (EDGE *p, INT n); allocated
898
899 INT THEFLAG (EDGE *p); 16 1 used only temporarily
900 void SETTHEFLAG (EDGE *p, INT n);
901 -----------------------------------------------------------------------------
902 \endverbatim
903
904 `Macros for the EDGE structure`
905
906 \verbatim
907 Macro name Pos Len Purpose
908 -----------------------------------------------------------------------------
909 INT EOFFSET (EDGE *p); 0 1 Overlay with bit from LINK
910 void SETEOFFSET (EDGE *p, INT n);
911
912 INT EXTRA (EDGE *p); 1 1 True if additional edge is
913 void SETEXTRA (EDGE *p, INT n); diagonal of quadrilateral. This is
914 provided for backward compatibility
915
916 INT NO_OF_ELEM (EDGE *p); 2 7 Number of elements sharing the
917 void SET_NO_OF_ELEM (EDGE *p, INT n); given edge. This is provided
918 void INC_NO_OF_ELEM (EDGE *p); only in 3D version
919 void DEC_NO_OF_ELEM (EDGE *p);
920
921 INT EDGENEW (EDGE *p); 16 1 True if edge has been created in
922 void SETEDGENEW (EDGE *p, INT n); last refinement step. 3D only!
923 -----------------------------------------------------------------------------
924 \endverbatim
925
926 \sa LINK
927 */
928 struct edge {
929
930 /** \brief The two links that make up this edge
931 *
932 * LINKs are always allocated pairwise and in consecutive memory locations.
933 * This allows to switch easily from a given LINK to the LINK in reverse direction or to the EDGE.
934 */
935 struct link links[2];
936
937 /* When UG is used as part of the DUNE numerics system we need
938 place to store codim dim-1 indices */
939
940 /** \brief An index hat is unique and consecutive per level.
941 Controlled by DUNE */
942 int levelIndex;
943
944 /** \brief An index hat is unique and consecutive on the grid surface.
945 Controlled by DUNE */
946 int leafIndex;
947
948 /** \brief A unique and persistent, but not necessarily consecutive index */
949 INT id;
950
951 #ifdef ModelP
952 /** Bookkeeping information for DDD */
953 DDD_HEADER ddd;
954 #endif
955
956 /** \brief Pointer to mid node on next finer grid
957 *
958 * In 3D a pointer to the node created on the midpoint of an edge is
959 * needed during refinement (This is because many elements share an edge in 3D).
960 */
961 struct node *midnode;
962
963 /** \brief associated vector
964 *
965 * WARNING: the allocation of the vector pointer depends on the format */
966 VECTOR *vector;
967 };
968
969 /** \brief A generic grid element
970
971 No difference between inner and boundary elements
972 */
973 struct generic_element {
974
975 /** \brief object identification, various flags */
976 UINT control;
977
978 /** \brief unique id used for load/store */
979 INT id;
980
981 /** \brief additional flags for elements
982 * A lot of information requiring only a small number of bits must be stored
983 * for each element. Therefore a second control word, the flag, has been introduced.
984 * The flag is also used bitwise.
985 */
986 UINT flag;
987
988 /** \brief to store NodeOrder for hexahedrons
989 *
990 * Since control and flag were full, a third word had to be introduced that
991 * can be used bitwise. A part of this word stores the element property, which is simple
992 * a number per element. This number can be used to distinguish different materials
993 * for example.
994 */
995 INT property;
996
997 /* When UG is used as part of the DUNE numerics system we need
998 a few more indices per element */
999
1000 /** \brief An index hat is unique and consecutive per level.
1001 Controlled by DUNE */
1002 int levelIndex;
1003
1004 /** \brief An index hat is unique and consecutive on the grid surface.
1005 Controlled by DUNE */
1006 int leafIndex;
1007
1008 #ifdef ModelP
1009 /** \brief Per-node message buffer used by Dune for dynamic load-balancing */
1010 char* message_buffer;
1011
1012 /** \brief Size of the `message_buffer` */
1013 std::size_t message_buffer_size;
1014 #endif
1015
1016 #ifdef ModelP
1017 /** \brief Information about the parallelization of this object */
1018 DDD_HEADER ddd;
1019
1020 /** \brief Stores partition information */
1021 INT lb1;
1022 #endif
1023
1024 /** \brief double linked list of elements */
1025 union element *pred, *succ;
1026
1027 #ifdef __CENTERNODE__
1028 /** \brief Pointer to center node */
1029 struct node *centernode;
1030 #endif
1031
1032 /** \brief Element specific part of variable length array managed by ug */
1033 void *refs[1];
1034
1035 };
1036
1037 /** \brief A triangle element in a 2d grid
1038 \implements generic_element
1039 */
1040 struct triangle {
1041
1042 /** \brief Object identification, various flags */
1043 UINT control;
1044
1045 /** \brief Unique id used for load/store */
1046 INT id;
1047
1048 /** \brief Additional flags for elements */
1049 UINT flag;
1050
1051 /** \brief Even more property bits */
1052 INT property;
1053
1054 /* When UG is used as part of the DUNE numerics system we need
1055 a few more indices per element */
1056
1057 /** \brief An index hat is unique and consecutive per level.
1058 Controlled by DUNE */
1059 int levelIndex;
1060
1061 /** \brief An index hat is unique and consecutive on the grid surface.
1062 Controlled by DUNE */
1063 int leafIndex;
1064
1065 #ifdef ModelP
1066 /** \brief Per-node message buffer used by Dune for dynamic load-balancing */
1067 char* message_buffer;
1068
1069 /** \brief Size of the `message_buffer` */
1070 std::size_t message_buffer_size;
1071 #endif
1072
1073 #ifdef ModelP
1074 /** \brief Information about the parallelization of this object */
1075 DDD_HEADER ddd;
1076
1077 /** \brief stores partition information */
1078 INT lb1;
1079 #endif
1080
1081 /** \brief Realize a doubly linked list of elements */
1082 union element *pred, *succ;
1083
1084 #ifdef __CENTERNODE__
1085 /** \brief Pointer to the center node */
1086 struct node *centernode;
1087 #endif
1088
1089 /** \brief Corners of this element */
1090 struct node *n[3];
1091
1092 /** \brief Father element on next-coarser grid */
1093 union element *father;
1094
1095 #ifdef ModelP
1096 /** \brief Element tree */
1097 union element *sons[2];
1098 #else
1099 /** \brief Element tree */
1100 union element *sons[1];
1101 #endif
1102
1103 /** \brief The neighboring elements */
1104 union element *nb[3];
1105
1106 /** \brief Only on the boundary, NULL if interior side */
1107 BNDS *bnds[3];
1108 };
1109
1110 /** \brief A quadrilateral element in a 2d grid
1111 \implements generic_element
1112 */
1113 struct quadrilateral {
1114
1115 /** \brief object identification, various flags */
1116 UINT control;
1117
1118 /** \brief unique id used for load/store */
1119 INT id;
1120
1121 /** \brief additional flags for elements */
1122 UINT flag;
1123
1124 /** \brief Even more flags */
1125 INT property;
1126
1127 /* When UG is used as part of the DUNE numerics system we need
1128 a few more indices per element */
1129
1130 /** \brief An index hat is unique and consecutive per level.
1131 Controlled by DUNE */
1132 int levelIndex;
1133
1134 /** \brief An index hat is unique and consecutive on the grid surface.
1135 Controlled by DUNE */
1136 int leafIndex;
1137
1138 #ifdef ModelP
1139 /** \brief Per-node message buffer used by Dune for dynamic load-balancing */
1140 char* message_buffer;
1141
1142 /** \brief Size of the `message_buffer` */
1143 std::size_t message_buffer_size;
1144 #endif
1145
1146 #ifdef ModelP
1147 /** \brief Information about the parallelization of this object */
1148 DDD_HEADER ddd;
1149
1150 /** \brief stores partition information */
1151 INT lb1;
1152 #endif
1153
1154 /** \brief doubly linked list of elements */
1155 union element *pred, *succ;
1156
1157 #ifdef __CENTERNODE__
1158 /** \brief pointer to center node */
1159 struct node *centernode;
1160 #endif
1161
1162 /** \brief corners of that element */
1163 struct node *n[4];
1164
1165 /** \brief father element on coarser grid */
1166 union element *father;
1167
1168 #ifdef ModelP
1169 /** \brief Element tree */
1170 union element *sons[2];
1171 #else
1172 /** \brief Element tree */
1173 union element *sons[1];
1174 #endif
1175
1176 /** \brief The neighbor elements */
1177 union element *nb[4];
1178
1179 /** \brief only on bnd, NULL if interior side */
1180 BNDS *bnds[4];
1181 };
1182
1183 /** \brief A tetrahedral element in a 3d grid
1184 \implements generic_element
1185 */
1186 struct tetrahedron {
1187
1188 /** \brief object identification, various flags */
1189 UINT control;
1190
1191 /** \brief Unique id used for load/store */
1192 INT id;
1193
1194 /** \brief Additional flags */
1195 UINT flag;
1196
1197 /** \brief Even more flags */
1198 INT property;
1199
1200 /* When UG is used as part of the DUNE numerics system we need
1201 a few more indices per element */
1202
1203 /** \brief An index hat is unique and consecutive per level.
1204 Controlled by DUNE */
1205 int levelIndex;
1206
1207 /** \brief An index hat is unique and consecutive on the grid surface.
1208 Controlled by DUNE */
1209 int leafIndex;
1210
1211 #ifdef ModelP
1212 /** \brief Per-node message buffer used by Dune for dynamic load-balancing */
1213 char* message_buffer;
1214
1215 /** \brief Size of the `message_buffer` */
1216 std::size_t message_buffer_size;
1217 #endif
1218
1219 #ifdef ModelP
1220
1221 /** \brief Information about the parallelization of this element */
1222 DDD_HEADER ddd;
1223
1224 /** \brief Stores partition information */
1225 INT lb1;
1226 #endif
1227
1228 /* pointers */
1229
1230 /** \brief Realize a double linked list of elements */
1231 union element *pred, *succ;
1232
1233 #ifdef __CENTERNODE__
1234 /** \brief Pointer to the center node */
1235 struct node *centernode;
1236 #endif
1237
1238 /** \brief Corners of this element */
1239 struct node *n[4];
1240
1241 /** \brief Father element on coarser grid */
1242 union element *father;
1243
1244 #ifdef ModelP
1245 /** \brief Element tree */
1246 union element *sons[2]; /* element tree */
1247 #else
1248 /** \brief Element tree */
1249 union element *sons[1];
1250 #endif
1251
1252 /** \brief The neighboring elements */
1253 union element *nb[4];
1254
1255 /** \brief Associated vector for sides */
1256 VECTOR *sidevector[4];
1257
1258 /** \brief The boundary segments, NULL if interior side */
1259 BNDS *bnds[4];
1260 };
1261
1262 /** \brief A pyramid element in a 3d grid
1263 \implements generic_element
1264 */
1265 struct pyramid {
1266
1267 /** \brief object identification, various flags */
1268 UINT control;
1269
1270 /** \brief Unique id used for load/store */
1271 INT id;
1272
1273 /** \brief Additional flags for elements */
1274 UINT flag;
1275
1276 /** \brief Even more flags */
1277 INT property;
1278
1279 /* When UG is used as part of the DUNE numerics system we need
1280 a few more indices per element */
1281
1282 /** \brief An index hat is unique and consecutive per level.
1283 Controlled by DUNE */
1284 int levelIndex;
1285
1286 /** \brief An index hat is unique and consecutive on the grid surface.
1287 Controlled by DUNE */
1288 int leafIndex;
1289
1290 #ifdef ModelP
1291 /** \brief Per-node message buffer used by Dune for dynamic load-balancing */
1292 char* message_buffer;
1293
1294 /** \brief Size of the `message_buffer` */
1295 std::size_t message_buffer_size;
1296 #endif
1297
1298 #ifdef ModelP
1299 /** \brief Information about the parallelization of this element */
1300 DDD_HEADER ddd;
1301
1302 /** \brief Stores partition information */
1303 INT lb1;
1304 #endif
1305
1306 /* pointers */
1307 /** \brief Realize a doubly linked list of elements */
1308 union element *pred, *succ;
1309
1310 #ifdef __CENTERNODE__
1311 /** \brief Pointer to center node */
1312 struct node *centernode;
1313 #endif
1314
1315 /** \brief Corners of this element */
1316 struct node *n[5];
1317
1318 /** \brief Father element on coarser grid */
1319 union element *father;
1320
1321 #ifdef ModelP
1322 /** \brief Element tree */
1323 union element *sons[2];
1324 #else
1325 /** \brief Element tree */
1326 union element *sons[1];
1327 #endif
1328
1329 /** \brief The neighbor elements */
1330 union element *nb[5];
1331
1332 /** \brief Associated vector for sides */
1333 VECTOR *sidevector[5];
1334
1335 /** \brief The boundary segments, NULL if interior side */
1336 BNDS *bnds[5];
1337 };
1338
1339 /** \brief A prism element in a 3d grid
1340 \implements generic_element
1341 */
1342 struct prism {
1343
1344 /** \brief object identification, various flags */
1345 UINT control;
1346
1347 /** \brief Unique id used for load/store */
1348 INT id;
1349
1350 /** \brief Additional flags for this element */
1351 UINT flag;
1352
1353 /** \brief Even more flags */
1354 INT property;
1355
1356 /* When UG is used as part of the DUNE numerics system we need
1357 a few more indices per element */
1358
1359 /** \brief An index hat is unique and consecutive per level.
1360 Controlled by DUNE */
1361 int levelIndex;
1362
1363 /** \brief An index hat is unique and consecutive on the grid surface.
1364 Controlled by DUNE */
1365 int leafIndex;
1366
1367 #ifdef ModelP
1368 /** \brief Per-node message buffer used by Dune for dynamic load-balancing */
1369 char* message_buffer;
1370
1371 /** \brief Size of the `message_buffer` */
1372 std::size_t message_buffer_size;
1373 #endif
1374
1375 #ifdef ModelP
1376 /** \brief Information about the parallelization of this element */
1377 DDD_HEADER ddd;
1378
1379 /** \brief Stores partition information */
1380 INT lb1;
1381 #endif
1382
1383 /* pointers */
1384 /** \brief Realize doubly linked list */
1385 union element *pred, *succ;
1386
1387 #ifdef __CENTERNODE__
1388 /** \brief Pointer to center node */
1389 struct node *centernode;
1390 #endif
1391
1392 /** \brief Corners of this element */
1393 struct node *n[6];
1394
1395 /** \brief Father element on next coarser grid */
1396 union element *father;
1397
1398 #ifdef ModelP
1399 /** \brief Element tree */
1400 union element *sons[2];
1401 #else
1402 /** \brief Element tree */
1403 union element *sons[1];
1404 #endif
1405
1406 /** \brief Neighbor elements */
1407 union element *nb[5];
1408
1409 /** \brief Associated vectors for sides */
1410 VECTOR *sidevector[5];
1411
1412 /** \brief Boundary segments, NULL if interior side */
1413 BNDS *bnds[5];
1414 };
1415
1416 /** \brief A hexahedral element in a 3d grid
1417 \implements generic_element
1418 */
1419 struct hexahedron {
1420
1421 /** \brief object identification, various flags */
1422 UINT control;
1423
1424 /** \brief Unique id used for load/store */
1425 INT id;
1426
1427 /** \brief Additional flags for this element */
1428 UINT flag;
1429
1430 /** \brief Even more flags */
1431 INT property;
1432
1433 /* When UG is used as part of the DUNE numerics system we need
1434 a few more indices per element */
1435
1436 /** \brief An index hat is unique and consecutive per level.
1437 Controlled by DUNE */
1438 int levelIndex;
1439
1440 /** \brief An index hat is unique and consecutive on the grid surface.
1441 Controlled by DUNE */
1442 int leafIndex;
1443
1444 #ifdef ModelP
1445 /** \brief Per-node message buffer used by Dune for dynamic load-balancing */
1446 char* message_buffer;
1447
1448 /** \brief Size of the `message_buffer` */
1449 std::size_t message_buffer_size;
1450 #endif
1451
1452 #ifdef ModelP
1453 /** \brief Information about the parallelization of this element */
1454 DDD_HEADER ddd;
1455
1456 /** \brief Stores partition information */
1457 INT lb1;
1458 #endif
1459
1460 /** \brief Realize doubly linked list of elements on one grid level */
1461 union element *pred, *succ;
1462
1463 #ifdef __CENTERNODE__
1464 /** \brief Pointer to center node */
1465 struct node *centernode;
1466 #endif
1467
1468 /** \brief Corners of this element */
1469 struct node *n[8];
1470
1471 /** \brief Father element on coarser grid */
1472 union element *father;
1473
1474 #ifdef ModelP
1475 /** \brief Element tree */
1476 union element *sons[2];
1477 #else
1478 /** \brief Element tree */
1479 union element *sons[1];
1480 #endif
1481
1482 /** \brief The neighboring elements */
1483 union element *nb[6];
1484
1485 /** \brief Associated vectors for sides */
1486 VECTOR *sidevector[6];
1487
1488 /** \brief Boundary segments, NULL if interior side */
1489 BNDS *bnds[6];
1490 } ;
1491
1492 /** \brief Objects that can hold an element */
1493
1494
1495
1496
1497
1498 /** \brief Data type representing an element in the mesh
1499
1500 UG provides a flexible element concept, i.e. there may be different
1501 types of elements in a mesh (currently limited to 8). All element types are derived
1502 from the generic_element where the refs array is allocated to the
1503 appropriate length. Data types for the currently implemented three different
1504 elements triangle, quadrilateral and tetrahedron are provided only
1505 for illustration and debugging purposes. Internally only the generic_element
1506 is used. The TAG field in the control word is used to identify the
1507 element type at run-time, therefore the limitation to eight element types.
1508 Memory requirements are also higher for elements having at least one
1509 side on the boundary because additional pointers to boundary information
1510 is stored.
1511 In 3D, degrees of freedom can be associated also with the sides of an element.
1512 Since there is no data type to represent sides, the degrees of freedom associated
1513 with a side of an element are accessed via the element (a side is shared by exactly
1514 two elements, UG ensures the consistency of the pointers).
1515 as the element has sides.
1516
1517 MACROS:
1518
1519 #SIDES_OF_ELEM (ELEMENT *p)
1520 #EDGES_OF_ELEM (ELEMENT *p)
1521 #CORNERS_OF_ELEM (ELEMENT *p)
1522 #SONS_OF_ELEM (ELEMENT *p)
1523 #EDGES_OF_SIDE (ELEMENT *p,INT i)
1524 #CORNERS_OF_SIDE (ELEMENT *p,INT i)
1525
1526 #EDGE_OF_SIDE (ELEMENT *p,INT s,INT e)
1527 #CORNER_OF_SIDE (ELEMENT *p,INT s,INT c)
1528 #CORNER_OF_EDGE (ELEMENT *p,INT e,INT c)
1529 #EDGE_WITH_CORNERS (ELEMENT *p,INT c0,INT c1)
1530 #SIDE_WITH_EDGE (ELEMENT *p,INT e,INT k)
1531 #CORNER_OF_SIDE_INV (ELEMENT *p,INT s,INT c)
1532 #EDGES_OF_CORNER (ELEMENT *p,INT c,INT k)
1533 #SUCCE (ELEMENT *p)
1534 #PREDE (ELEMENT *p)
1535 #CORNER (ELEMENT *p,INT i)
1536 #EFATHER (ELEMENT *p)
1537 #SON (ELEMENT *p,INT i)
1538 #NBELEM (ELEMENT *p,INT i)
1539 #SVECTOR (ELEMENT *p,INT i)
1540
1541
1542 CONTROL WORDS:
1543
1544 `General macros available for all objects`
1545
1546 \verbatim
1547 Macro name Pos Len Purpose
1548 -----------------------------------------------------------------------------
1549 INT OBJT (ELEMENT *p); 27 5 Object type BEOBJ for an element
1550 void SETOBJT (ELEMENT *p, INT n); with at least one side on a
1551 boundary and IEOBJ else
1552
1553 INT USED (ELEMENT *p); 23 1 used only temporarily
1554 void SETUSED (ELEMENT *p, INT n);
1555
1556 INT TAG (ELEMENT *p); 24 3 identifies element type. E.g.
1557 void SETTAG (ELEMENT *p, INT n); 3=triangle, 4=quadrilateral.
1558 should not be used anymore!
1559
1560 INT LEVEL (ELEMENT *p); 17 5 level on which element is
1561 void SETLEVEL (ELEMENT *p, INT n); allocated
1562
1563 INT THEFLAG (ELEMENT *p); 16 1 True if elements refinement rule
1564 void SETTHEFLAG (ELEMENT *p, INT n); changed during last refinement
1565 step. 3D only !
1566 -----------------------------------------------------------------------------
1567 \endverbatim
1568
1569 `Macros for the ELEMENT structure in control`
1570
1571 \verbatim
1572 Macro name Pos Len Purpose
1573 -----------------------------------------------------------------------------
1574 INT ECLASS (ELEMENT *p); 8 2 stores element class which is
1575 void SETECLASS (ELEMENT *p,INT n); out of COPY_CLASS,
1576 IRREGULAR_CLASS or REGULAR_CLASS
1577
1578 INT NSONS (ELEMENT *p); 10 4 number of sons of an element.
1579 void SETNSONS (ELEMENT *p,INT n);
1580
1581 INT NEWEL (ELEMENT *p); 14 1 Set at creation time but never
1582 void SETNEWEL (ELEMENT *p,INT n); reset. Do not use it!
1583 -----------------------------------------------------------------------------
1584 \endverbatim
1585
1586 `Macros for the ELEMENT structure in flag are all for internal use only`
1587
1588
1589
1590 `Macros for the ELEMENT structure in property`
1591
1592 \verbatim
1593 Macro name Pos Len Purpose
1594 -----------------------------------------------------------------------------
1595 INT PROP (ELEMENT *p); 0 32 Stores element property number.
1596 void SETPROP (ELEMENT *p,INT n);
1597 -----------------------------------------------------------------------------
1598 \endverbatim
1599 */
1600
1601 union element {
1602 struct generic_element ge;
1603 #ifdef UG_DIM_2
1604 struct triangle tr;
1605 struct quadrilateral qu;
1606 #endif
1607 #ifdef UG_DIM_3
1608 struct tetrahedron te;
1609 struct pyramid py;
1610 struct prism pr;
1611 struct hexahedron he;
1612 #endif
1613
1614 #ifdef ModelP
1615 const char* message_buffer() const
1616 { return ge.message_buffer; }
1617
1618 std::size_t message_buffer_size() const
1619 { return ge.message_buffer_size; }
1620
1621 void message_buffer(char* p, std::size_t size)
1622 {
1623 ge.message_buffer = p;
1624 ge.message_buffer_size = size;
1625 }
1626
1627 void message_buffer_free()
1628 {
1629 std::free(ge.message_buffer);
1630 message_buffer(nullptr, 0);
1631 }
1632 #endif
1633 };
1634
1635 /** \brief Union of all geometric objects
1636
1637 This data type unifies all data types that can have references to a
1638 VECTOR structure. This type is never used for allocation.
1639 */
1640 union geom_object {
1641 struct node nd;
1642 struct edge ed;
1643 union element el;
1644 };
1645
1646 /** \brief Objects that can have a key */
1647 union object_with_key {
1648 struct node nd;
1649 union element el;
1650 struct vector ve;
1651 union vertex vertex;
1652 struct edge edge;
1653 };
1654
1655 typedef struct
1656 {
1657 UINT VecReserv[MAXVECTORS][MAX_NDOF_MOD_32];
1658 UINT MatReserv[MAXCONNECTIONS][MAX_NDOF_MOD_32];
1659 /** \todo Is this used anywhere? */
1660 UINT VecConsistentStatus[MAXMATRICES][MAX_NDOF_MOD_32];
1661 /** \todo Is this used anywhere? */
1662 UINT VecCollectStatus[MAXMATRICES][MAX_NDOF_MOD_32];
1663 } DATA_STATUS;
1664
1665 /** \brief Data type giving access to all objects on a grid level
1666
1667 The \ref grid data type provides access to all objects defined on a grid level.
1668 All the pointers to the first list elements are there.
1669
1670 CONTROL WORDS:
1671
1672 No entries of the control word are currently used.
1673
1674 */
1675 struct grid {
1676
1677 /** \brief Object identification, various flags */
1678 UINT control;
1679
1680 /** \brief A word storing status information. This can be used also by the
1681 problem class, e.g. to store whether the grid level is assembled or not. */
1682 INT status;
1683
1684 /** \brief Level within the multigrid structure */
1685 UINT level;
1686
1687 /** \brief Number of vertices */
1688 INT nVert[NS_DIM_PREFIX MAX_PRIOS];
1689
1690 /** \brief Number of nodes on this grid level */
1691 INT nNode[NS_DIM_PREFIX MAX_PRIOS];
1692
1693 /** \brief Number of elements on this grid level */
1694 INT nElem[NS_DIM_PREFIX MAX_PRIOS];
1695
1696 /** \brief Number of edges on this grid level */
1697 INT nEdge;
1698
1699 /** \brief Number of vectors on this grid level */
1700 INT nVector[NS_DIM_PREFIX MAX_PRIOS];
1701
1702 DATA_STATUS data_status; /* memory management for vectors|matrix */
1703 /* status for consistent and collect */
1704 /* pointers */
1705 union element *elements[NS_DIM_PREFIX ELEMENT_LISTPARTS]; /* pointer to first element*/
1706 union element *lastelement[NS_DIM_PREFIX ELEMENT_LISTPARTS]; /*pointer to last element*/
1707 union vertex *vertices[NS_DIM_PREFIX VERTEX_LISTPARTS]; /* pointer to first vertex */
1708 union vertex *lastvertex[NS_DIM_PREFIX VERTEX_LISTPARTS]; /* pointer to last vertex */
1709 struct node *firstNode[NS_DIM_PREFIX NODE_LISTPARTS]; /* pointer to first node */
1710 struct node *lastNode[NS_DIM_PREFIX NODE_LISTPARTS]; /* pointer to last node */
1711 VECTOR *firstVector[NS_DIM_PREFIX VECTOR_LISTPARTS]; /* pointer to first vector */
1712 VECTOR *lastVector[NS_DIM_PREFIX VECTOR_LISTPARTS]; /* pointer to last vector */
1713
1714 struct grid *coarser, *finer; /* coarser and finer grids */
1715 struct multigrid *mg; /* corresponding multigrid structure */
1716
1717 const PPIF::PPIFContext& ppifContext() const;
1718
1719 #ifdef ModelP
1720 const DDD::DDDContext& dddContext() const;
1721 DDD::DDDContext& dddContext();
1722 #endif
1723 };
1724
1725 /** \brief Data type representing a complete multigrid structure
1726
1727 Data type providing access to all information about the complete
1728 multigrid hierarchy, problem description and memory management information.
1729 This is the root of all.
1730 MACROS:
1731
1732 */
1733 struct multigrid {
1734
1735 /** \brief The MULTIGRID is an environment item, i.e. it resides in the environment tree.
1736 *
1737 * v stores also the name of the MULTIGRID as it is declared in the new
1738 * and open commands.
1739 */
1740 NS_PREFIX ENVDIR v;
1741
1742 /** \brief Multigrid status word */
1743 INT status;
1744
1745 /** \brief used for identification */
1746 INT magic_cookie;
1747
1748 /** \brief count objects in that multigrid */
1749 INT vertIdCounter;
1750
1751 /** \brief count objects in that multigrid */
1752 INT nodeIdCounter;
1753
1754 /** \brief count objects in that multigrid */
1755 INT elemIdCounter;
1756
1757 /** \brief count objects in that multigrid */
1758 INT edgeIdCounter;
1759
1760 #ifndef ModelP
1761 /** \brief Count vector objects in that multigrid */
1762 INT vectorIdCounter;
1763 #endif
1764
1765 /** \brief Finest grid level currently allocated in the MULTIGRID */
1766 INT topLevel;
1767
1768 /** \brief last level with complete surface */
1769 INT fullrefineLevel;
1770
1771 /** \brief pointer to BndValProblem */
1772 STD_BVP *theBVP;
1773
1774 /** \brief description of BVP-properties */
1775 std::string BVP_Name;
1776
1777 /** \brief associated heap structure */
1778 NS_PREFIX HEAP *theHeap;
1779
1780 /** \brief max nb of properties used in elements*/
1781 INT nProperty;
1782
1783
1784 /** \brief memory management for vectors|matrix
1785 * status for consistent and collect */
1786 DATA_STATUS data_status;
1787
1788 /* pointers */
1789 /** \brief pointers to the grids */
1790 struct grid *grids[MAXLEVEL];
1791
1792 /** @{ Helper structures to for an O(n) InsertElement */
1793 /** \brief List of pointers to face nodes,
1794 used as an Id of a face
1795 */
1796 struct FaceNodes : public std::array<node*,MAX_CORNERS_OF_SIDE>
1797 {
1798 using array<node*,MAX_CORNERS_OF_SIDE>::array;
1799 };
1800 /** \brief Hasher for FaceNodes */
1801 struct FaceHasher {
1802 std::hash<node*> hasher;
1803 std::size_t operator() (const FaceNodes& key) const {
1804 return std::accumulate(key.begin(), key.end(),
1805 144451, [&](auto a, auto b){
1806 return hasher(a+b);
1807 });
1808 }
1809 };
1810 /** \brief hash-map used for an O(1) search of the neighboring element
1811 during InsertElement
1812 */
1813 std::unordered_map<FaceNodes,
1814 std::pair<element *,int>,
1815 FaceHasher> facemap;
1816 /** @} */
1817
1818 /* i/o handling */
1819 /** \brief 1 if multigrid saved */
1820 INT saved;
1821
1822 /** \brief filename if saved */
1823 char filename[NS_PREFIX NAMESIZE];
1824
1825 /** \brief coarse grid complete */
1826 INT CoarseGridFixed;
1827
1828 /** \brief coarse grid MarkKey for SIMPLE_HEAP Mark/Release */
1829 INT MarkKey;
1830
1831 const PPIF::PPIFContext& ppifContext() const
1832 { return *ppifContext_; }
1833
1834 std::shared_ptr<PPIF::PPIFContext> ppifContext_;
1835
1836 #ifdef ModelP
1837 const DDD::DDDContext& dddContext() const
1838 { return *dddContext_; }
1839
1840 DDD::DDDContext& dddContext()
1841 { return *dddContext_; }
1842
1843 std::shared_ptr<DDD::DDDContext> dddContext_;
1844 #endif
1845 };
1846
1847 /****************************************************************************/
1848 /* */
1849 /* typedef for structs */
1850 /* */
1851 /****************************************************************************/
1852
1853 /* geometrical part */
1854 typedef union vertex VERTEX;
1855 typedef struct node NODE;
1856 typedef union element ELEMENT;
1857 typedef struct link LINK;
1858 typedef struct edge EDGE;
1859 typedef union geom_object GEOM_OBJECT;
1860 typedef struct grid GRID;
1861 typedef struct multigrid MULTIGRID;
1862 typedef union object_with_key KEY_OBJECT;
1863
1864
1865 /****************************************************************************/
1866 /* */
1867 /* dynamic management of control words */
1868 /* */
1869 /****************************************************************************/
1870
1871 #define ControlWord(p,ce) (((UINT *)(p))[control_entries[ce].offset_in_object])
1872
1873 #define CW_READ(p,ce) ((ControlWord(p,ce) & control_entries[ce].mask)>>control_entries[ce].offset_in_word)
1874
1875 #define CW_WRITE(p,ce,n) ControlWord(p,ce) = (ControlWord(p,ce)&control_entries[ce].xor_mask)|(((n)<<control_entries[ce].offset_in_word)&control_entries[ce].mask)
1876
1877 /* static control words */
1878 #define StaticControlWord(p,t) (((UINT *)(p))[t ## OFFSET])
1879 #define StaticControlWordMask(s) ((POW2(s ## LEN) - 1) << s ## SHIFT)
1880
1881 #define CW_READ_STATIC(p,s,t) \
1882 ((StaticControlWord(p,t) & StaticControlWordMask(s)) >> s ## SHIFT)
1883
1884 #define CW_WRITE_STATIC(p,s,t,n) \
1885 StaticControlWord(p,t) = \
1886 (StaticControlWord(p,t) & (~StaticControlWordMask(s))) | \
1887 (((n) << s ## SHIFT) & StaticControlWordMask(s))
1888
1889 /** \brief Enumeration list of all control words of gm.h */
1890 enum GM_CW {
1891 VECTOR_CW,
1892 VERTEX_CW,
1893 NODE_CW,
1894 LINK_CW,
1895 EDGE_CW,
1896 ELEMENT_CW,
1897 FLAG_CW,
1898 PROPERTY_CW,
1899 GRID_CW,
1900 GRID_STATUS_CW,
1901 MULTIGRID_STATUS_CW,
1902
1903 GM_N_CW
1904 };
1905
1906 /** \brief Enumeration list of all control entry of gm.h */
1907 enum GM_CE {
1908 VOTYPE_CE,
1909 VCOUNT_CE,
1910 VECTORSIDE_CE,
1911 VCLASS_CE,
1912 VDATATYPE_CE,
1913 VNCLASS_CE,
1914 VNEW_CE,
1915 VCCUT_CE,
1916 FINE_GRID_DOF_CE,
1917 OBJ_CE,
1918 USED_CE,
1919 TAG_CE,
1920 LEVEL_CE,
1921 THEFLAG_CE,
1922 MOVE_CE,
1923 MOVED_CE,
1924 ONEDGE_CE,
1925 ONSIDE_CE,
1926 ONNBSIDE_CE,
1927 NOOFNODE_CE,
1928 NSUBDOM_CE,
1929 NTYPE_CE,
1930 NPROP_CE,
1931 MODIFIED_CE,
1932 NCLASS_CE,
1933 NNCLASS_CE,
1934 LOFFSET_CE,
1935 NO_OF_ELEM_CE,
1936 AUXEDGE_CE,
1937 EDGENEW_CE,
1938 EDSUBDOM_CE,
1939 ECLASS_CE,
1940 NSONS_CE,
1941 NEWEL_CE,
1942 SUBDOMAIN_CE,
1943 NODEORD_CE,
1944 PROP_CE,
1945 #ifdef ModelP
1946 XFERVECTOR_CE,
1947 #endif
1948
1949 GM_N_CE
1950 };
1951
1952 enum LV_MODIFIERS {
1953
1954 LV_VO_INFO = (1<<1), /* vector object related info */
1955 LV_POS = (1<<2) /* position vector */
1956 };
1957
1958 /****************************************************************************/
1959 /* */
1960 /* Macro definitions for algebra structures */
1961 /* */
1962 /* */
1963 /* Use of the control word: */
1964 /* */
1965 /* macro name|bits |V|M|use */
1966 /* */
1967 /* all objects: */
1968 /* */
1969 /* vectors: */
1970 /* VOTYPE |0 - 1 |*| | node-,edge-,side- or elemvector */
1971 /* VCUSED |4 |*| | flag for general use */
1972 /* VCOUNT |5-6 |*| | The number of elements that reference */
1973 /* the vector (if it is a side vector) */
1974 /* VECTORSIDE|7 - 9 |*| | nb of side the side vect corr. to (in object elem)*/
1975 /* VCLASS |11-12 |*| | class of v. (3: if corr. to red/green elem) */
1976 /* (2: if corr. to first algebraic nb.) */
1977 /* (1: if corr. to second algebraic nb.) */
1978 /* VDATATYPE |13-16 |*| | data type used bitwise */
1979 /* VNCLASS |17-18 |*| | type of elem on finer grid the v. lies geom. in: */
1980 /* 0: no elem on finer grid */
1981 /* 1: elem of 'second alg. nbhood' only */
1982 /* 2: elem of 'first alg. nbhood' only */
1983 /* 3: red or green elem */
1984 /* VNEW |19 |*| | 1 if vector is new */
1985 /* VCNEW |20 |*| | 1 if vector has a new connection */
1986 /* VCCUT |26 |*| | */
1987 /* */
1988 /****************************************************************************/
1989
1990 /****************************************************************************/
1991 /* */
1992 /* general macros */
1993 /* */
1994 /****************************************************************************/
1995
1996 /* macros to calculate from a coordinate (2D/3D) a hopefully unique ID */
1997 #define SIGNIFICANT_DIGITS(d,exp_ptr) (ceil(frexp((d),(exp_ptr))*1e5))
1998
1999 /* the idea to calculate from a 2d/3D position a (hopefully) unique key:
2000 add the weighted significant digits of the coordinates; the weights
2001 may not have a common divisor to ensure uniqueness of the result;
2002 take from this again the sigificant digits */
2003 #ifdef UG_DIM_2
2004 #define COORDINATE_TO_KEY(coord,dummy_int_ptr) ((INT)(SIGNIFICANT_DIGITS((SIGNIFICANT_DIGITS((coord)[0],(dummy_int_ptr))*1.246509423749342 + \
2005 SIGNIFICANT_DIGITS((coord)[1],(dummy_int_ptr))*Dune::StandardMathematicalConstants<double>::pi())\
2006 , (dummy_int_ptr))))
2007 #endif
2008
2009 #ifdef UG_DIM_3
2010 #define COORDINATE_TO_KEY(coord,dummy_int_ptr) ((INT)(SIGNIFICANT_DIGITS((SIGNIFICANT_DIGITS((coord)[0],(dummy_int_ptr))*1.246509423749342 + \
2011 SIGNIFICANT_DIGITS((coord)[1],(dummy_int_ptr))*Dune::StandardMathematicalConstants<double>::pi() + \
2012 SIGNIFICANT_DIGITS((coord)[2],(dummy_int_ptr))*0.76453456834568356936598)\
2013 , (dummy_int_ptr))))
2014 #endif
2015
2016 /****************************************************************************/
2017 /* */
2018 /* macros for VECTORs */
2019 /* */
2020 /****************************************************************************/
2021
2022 /* control word offset */
2023 #define VECTOR_OFFSET offsetof(struct NS_DIM_PREFIX vector, control)/sizeof(UINT)
2024
2025 /* predefined control word entries */
2026 #define VOTYPE_SHIFT 0
2027 #define VOTYPE_LEN 2
2028 #define VOTYPE(p) CW_READ_STATIC(p,VOTYPE_,VECTOR_)
2029 #define SETVOTYPE(p,n) CW_WRITE_STATIC(p,VOTYPE_,VECTOR_,n)
2030 #if (MAXVOBJECTS > POW2(VOTYPE_LEN))
2031 #error *** VOTYPE_LEN too small ***
2032 #endif
2033
2034 #define VDATATYPE_SHIFT 4
2035 #define VDATATYPE_LEN 4
2036 #define VDATATYPE(p) CW_READ_STATIC(p,VDATATYPE_,VECTOR_)
2037 #define SETVDATATYPE(p,n) CW_WRITE_STATIC(p,VDATATYPE_,VECTOR_,n)
2038 #if (MAXVTYPES > VDATATYPE_LEN)
2039 #error *** VDATATYPE_LEN too small ***
2040 #endif
2041
2042 #define VCLASS_SHIFT 8
2043 #define VCLASS_LEN 2
2044 #define VCLASS(p) CW_READ_STATIC(p,VCLASS_,VECTOR_)
2045 #define SETVCLASS(p,n) CW_WRITE_STATIC(p,VCLASS_,VECTOR_,n)
2046
2047 #define VNCLASS_SHIFT 10
2048 #define VNCLASS_LEN 2
2049 #define VNCLASS(p) CW_READ_STATIC(p,VNCLASS_,VECTOR_)
2050 #define SETVNCLASS(p,n) CW_WRITE_STATIC(p,VNCLASS_,VECTOR_,n)
2051
2052 #define VNEW_SHIFT 12
2053 #define VNEW_LEN 1
2054 #define VNEW(p) CW_READ_STATIC(p,VNEW_,VECTOR_)
2055 #define SETVNEW(p,n) CW_WRITE_STATIC(p,VNEW_,VECTOR_,n)
2056
2057 #define VCCUT_SHIFT 13
2058 #define VCCUT_LEN 1
2059 #define VCCUT(p) CW_READ_STATIC(p,VCCUT_,VECTOR_)
2060 #define SETVCCUT(p,n) CW_WRITE_STATIC(p,VCCUT_,VECTOR_,n)
2061
2062 #define VCOUNT_SHIFT 14
2063 #define VCOUNT_LEN 2
2064 #define VCOUNT(p) CW_READ_STATIC(p,VCOUNT_,VECTOR_)
2065 #define SETVCOUNT(p,n) CW_WRITE_STATIC(p,VCOUNT_,VECTOR_,n)
2066
2067 #define VECTORSIDE_SHIFT 16
2068 #define VECTORSIDE_LEN 3
2069 #define VECTORSIDE(p) CW_READ_STATIC(p,VECTORSIDE_,VECTOR_)
2070 #define SETVECTORSIDE(p,n) CW_WRITE_STATIC(p,VECTORSIDE_,VECTOR_,n)
2071
2072 #define FINE_GRID_DOF_SHIFT 20
2073 #define FINE_GRID_DOF_LEN 1
2074 #define FINE_GRID_DOF(p) CW_READ_STATIC(p,FINE_GRID_DOF_,VECTOR_)
2075 #define SETFINE_GRID_DOF(p,n) CW_WRITE_STATIC(p,FINE_GRID_DOF_,VECTOR_,n)
2076
2077 #ifdef ModelP
2078 #define XFERVECTOR_SHIFT 20
2079 #define XFERVECTOR_LEN 2
2080 #define XFERVECTOR(p) CW_READ(p,XFERVECTOR_CE)
2081 #define SETXFERVECTOR(p,n) CW_WRITE(p,XFERVECTOR_CE,n)
2082 #endif /* ModelP */
2083
2084 #define VOBJECT(v) ((v)->object)
2085 #ifdef ModelP
2086 #define PPREDVC(p,v) (((v)==PRIO_FIRSTVECTOR(p,PrioMaster)) ? \
2087 PRIO_LASTVECTOR(p,PrioBorder) : (v)->pred)
2088 #else
2089 #define PPREDVC(p,v) ((v)->pred)
2090 #endif
2091 #define PREDVC(v) ((v)->pred)
2092 #define SUCCVC(v) ((v)->succ)
2093 #define VINDEX(v) ((v)->index)
2094
2095 /****************************************************************************/
2096 /* */
2097 /* Macro definitions for geometric objects */
2098 /* */
2099 /* */
2100 /* Use of the control word: */
2101 /* */
2102 /* macro name|bits |V|N|L|E|V|M| use */
2103 /* C */
2104 /* all objects: */
2105 /* TAG |18-20 | | | |*| | |general purpose tag field */
2106 /* LEVEL |21-25 |*|*| |*| | |level of a node/element (imp. for copies) */
2107 /* THEFLAG |26 |*|*|*|*| | |general purp., leave them as you found 'em*/
2108 /* USED |27 |*|*|*|*| | |object visited, leave them as you found 'em*/
2109 /* OBJT |28-31 |*|*|*|*| | |object type identification */
2110
2111 /* */
2112 /* vertices: */
2113 /* MOVED |0 |*| | | | | |boundary vertex not lying on edge midpoint */
2114 /* MOVE |1-2 |*| | | | | |vertex can be moved on a 0(1,2,3) dim subsp*/
2115 /* ONEDGE |3 - 6 |*| | | | | |no. of edge in father element */
2116 /* ONSIDE |3 - 5 |*| | | | | |no. of side in father element */
2117 /* ONNBSIDE |6 - 8 |*| | | | | |no. of side in the neighbor of the father */
2118 /* NOOFNODE |9 -13 |*| | | | | |??? */
2119 /* */
2120 /* nodes: */
2121 /* NSUBDOM |0-3 | |*| | | | |subdomain id */
2122 /* MODIFIED |6 | |*| | | | |1 if node must be assembled */
2123 /* N_OUTFLOW |0-7 | */
2124 /* N_INFLOW |8-15 | */
2125 /* */
2126 /* links and edges: */
2127 /* LOFFSET |0 | | |*| | | |position of link in links array */
2128 /* EDGENEW |1 | | |*| | | |status of edge */
2129 /* NOOFELEM |2-8 | | |*| | | |nb. of elem. the edge is part of */
2130 /* AUXEDGE |9 | */
2131 /* EDSUBDOM |12-17 | | | |*| | |subdomain of edge if inner edge, 0 else */
2132 /* */
2133 /* elements: */
2134 /* ECLASS |8-9 | | | |*| | |element class from enumeration type */
2135 /* NSONS |10-13 | | | |*| | |number of sons */
2136 /* NEWEL |14 | | | |*| | |element just created */
2137 /* VSIDES |11-14 | | | |*| | |viewable sides */
2138 /* NORDER |15-19 | | | |*| | |view position order of the nodes */
2139 /* CUTMODE |26-27 | | | |*| | |elem intersects cutplane or... */
2140 /* */
2141 /****************************************************************************/
2142
2143 /* object identification */
2144 enum GM_OBJECTS {
2145
2146 MGOBJ, /*!< Multigrid object */
2147 IVOBJ, /*!< Inner vertex */
2148 BVOBJ, /*!< Boundary vertex */
2149 IEOBJ, /*!< Inner element */
2150 BEOBJ, /*!< Boundary element */
2151 EDOBJ, /*!< Edge object */
2152 NDOBJ, /*!< Node object */
2153 GROBJ, /*!< Grid object */
2154
2155 /* object numbers for algebra */
2156 VEOBJ, /*!< Vector object */
2157
2158 NPREDEFOBJ, /*!< Number of predefined objects */
2159
2160 NOOBJ = -1 /*!< No object */
2161 };
2162 #define LIOBJ EDOBJ /* link and edge are identified */
2163
2164 /****************************************************************************/
2165 /* */
2166 /* general macros */
2167 /* */
2168 /****************************************************************************/
2169
2170 /* control word offset */
2171 #define GENERAL_CW NODE_CW /* any of the geom objects */
2172 #define GENERAL_OFFSET 0
2173
2174 #define OBJ_SHIFT 28
2175 #define OBJ_LEN 4
2176 #define OBJT(p) (enum GM_OBJECTS)CW_READ_STATIC(p,OBJ_,GENERAL_)
2177 #define SETOBJT(p,n) CW_WRITE_STATIC(p,OBJ_,GENERAL_,n)
2178 #define OBJT_MAX (POW2(OBJ_LEN)-1)
2179
2180 #define USED_SHIFT 27
2181 #define USED_LEN 1
2182 #define USED(p) CW_READ_STATIC(p,USED_,GENERAL_)
2183 #define SETUSED(p,n) CW_WRITE_STATIC(p,USED_,GENERAL_,n)
2184
2185 #define THEFLAG_SHIFT 26
2186 #define THEFLAG_LEN 1
2187 #define THEFLAG(p) CW_READ_STATIC(p,THEFLAG_,GENERAL_)
2188 #define SETTHEFLAG(p,n) CW_WRITE_STATIC(p,THEFLAG_,GENERAL_,n)
2189
2190 #define LEVEL_SHIFT 21
2191 #define LEVEL_LEN 5
2192 #define LEVEL(p) CW_READ_STATIC(p,LEVEL_,GENERAL_)
2193 #define SETLEVEL(p,n) CW_WRITE_STATIC(p,LEVEL_,GENERAL_,n)
2194
2195 #define TAG_SHIFT 18
2196 #define TAG_LEN 3
2197 #define TAG(p) CW_READ_STATIC(p,TAG_,GENERAL_)
2198 #define SETTAG(p,n) CW_WRITE_STATIC(p,TAG_,GENERAL_,n)
2199
2200 #define REF2TAG(n) (reference2tag[n])
2201
2202 #define CTRL(p) (*((UINT *)(p)))
2203 #define ID(p) (((INT *)(p))[1])
2204
2205 /****************************************************************************/
2206 /* */
2207 /* macros for vertices */
2208 /* */
2209 /****************************************************************************/
2210
2211 /* control word offset */
2212 #define VERTEX_OFFSET offsetof(struct ivertex,control)/sizeof(UINT)
2213
2214 #define MOVE_SHIFT 1
2215 #define MOVE_LEN 2
2216 #define MOVE(p) CW_READ_STATIC(p,MOVE_,VERTEX_)
2217 #define SETMOVE(p,n) CW_WRITE_STATIC(p,MOVE_,VERTEX_,n)
2218
2219 #define MOVED_SHIFT 0
2220 #define MOVED_LEN 1
2221 #define MOVED(p) CW_READ_STATIC(p,MOVED_,VERTEX_)
2222 #define SETMOVED(p,n) CW_WRITE_STATIC(p,MOVED_,VERTEX_,n)
2223
2224 #define ONEDGE_SHIFT 3
2225 #define ONEDGE_LEN 4
2226 #define ONEDGE(p) CW_READ_STATIC(p,ONEDGE_,VERTEX_)
2227 #define SETONEDGE(p,n) CW_WRITE_STATIC(p,ONEDGE_,VERTEX_,n)
2228
2229 /* the following two overlap with ONEDGE */
2230 #define ONSIDE_SHIFT 3
2231 #define ONSIDE_LEN 3
2232 #define ONSIDE(p) CW_READ_STATIC(p,ONSIDE_,VERTEX_)
2233 #define SETONSIDE(p,n) CW_WRITE_STATIC(p,ONSIDE_,VERTEX_,n)
2234
2235 #define ONNBSIDE_SHIFT 6
2236 #define ONNBSIDE_LEN 3
2237 #define ONNBSIDE(p) CW_READ_STATIC(p,ONNBSIDE_,VERTEX_)
2238 #define SETONNBSIDE(p,n) CW_WRITE_STATIC(p,ONNBSIDE_,VERTEX_,n)
2239
2240 #define NOOFNODE_SHIFT 9
2241 #define NOOFNODE_LEN 5
2242 #define NOOFNODEMAX POW2(NOOFNODE_LEN)
2243 #if (MAXLEVEL > NOOFNODEMAX)
2244 #error **** set NOOFNODEMAX/_LEN appropriate to MAXLEVEL: 2^NOOFNODE_LEN = NOOFNODEMAX >= MAXLEVEL ****
2245 #endif
2246 #define NOOFNODE(p) CW_READ_STATIC(p,NOOFNODE_,VERTEX_)
2247 #define SETNOOFNODE(p,n) CW_WRITE_STATIC(p,NOOFNODE_,VERTEX_,n)
2248 #define INCNOOFNODE(p) SETNOOFNODE(p,NOOFNODE(p)+1)
2249 #define DECNOOFNODE(p) SETNOOFNODE(p,NOOFNODE(p)-1)
2250
2251 #define PREDV(p) ((p)->iv.pred)
2252 #define SUCCV(p) ((p)->iv.succ)
2253 #define CVECT(p) ((p)->iv.x)
2254 #define LCVECT(p) ((p)->iv.xi)
2255 #define VDATA(p) ((p)->iv.data)
2256 #define VFATHER(p) ((p)->iv.father)
2257
2258 /* for boundary vertices */
2259 #define V_BNDP(p) ((p)->bv.bndp)
2260
2261 /* parallel macros */
2262 #ifdef ModelP
2263 #define PARHDRV(p) (&((p)->iv.ddd))
2264 #endif /* ModelP */
2265
2266 /****************************************************************************/
2267 /* */
2268 /* macros for nodes */
2269 /* */
2270 /****************************************************************************/
2271
2272 /* control word offset */
2273 #define NODE_OFFSET offsetof(struct node, control)/sizeof(UINT)
2274
2275 #define NTYPE_SHIFT 0
2276 #define NTYPE_LEN 3
2277 #define NTYPE(p) CW_READ_STATIC(p,NTYPE_,NODE_)
2278 #define SETNTYPE(p,n) CW_WRITE_STATIC(p,NTYPE_,NODE_,n)
2279
2280 #define NSUBDOM_SHIFT 3
2281 #define NSUBDOM_LEN 6
2282 #define NSUBDOM(p) CW_READ_STATIC(p,NSUBDOM_,NODE_)
2283 #define SETNSUBDOM(p,n) CW_WRITE_STATIC(p,NSUBDOM_,NODE_,n)
2284
2285 #define NPROP_SHIFT 11
2286 #define NPROP_LEN 4
2287 #define NPROP(p) CW_READ_STATIC(p,NPROP_,NODE_)
2288 #define SETNPROP(p,n) CW_WRITE_STATIC(p,NPROP_,NODE_,n)
2289
2290 #define MODIFIED_SHIFT 15
2291 #define MODIFIED_LEN 1
2292 #define MODIFIED(p) CW_READ_STATIC(p,MODIFIED_,NODE_)
2293 #define SETMODIFIED(p,n) CW_WRITE_STATIC(p,MODIFIED_,NODE_,n)
2294
2295 #define NCLASS_SHIFT 16
2296 #define NCLASS_LEN 2
2297 #define NCLASS(p) CW_READ_STATIC(p,NCLASS_,NODE_)
2298 #define SETNCLASS(p,n) CW_WRITE_STATIC(p,NCLASS_,NODE_,n)
2299
2300 #define NNCLASS_SHIFT 18
2301 #define NNCLASS_LEN 2
2302 #define NNCLASS(p) CW_READ_STATIC(p,NNCLASS_,NODE_)
2303 #define SETNNCLASS(p,n) CW_WRITE_STATIC(p,NNCLASS_,NODE_,n)
2304
2305 #define PREDN(p) ((p)->pred)
2306 #define SUCCN(p) ((p)->succ)
2307 #define START(p) ((p)->start)
2308
2309 #define NFATHER(p) ((NODE*)(p)->father)
2310 #define SETNFATHER(p,n) ((p)->father = n)
2311 #define NFATHEREDGE(p) ((EDGE*)(p)->father)
2312 /*
2313 #define NFATHER(p) ((NTYPE(p) == CORNER_NODE) ? (p)->father : NULL)
2314 #define NFATHEREDGE(p) ((NTYPE(p) == MID_NODE) ? (EDGE *)(p)->father : NULL)
2315 #define SETNFATHEREDGE(p,e) ((p)->father = (NODE *) (e))
2316 */
2317 #define CORNERTYPE(p) (NTYPE(p) == CORNER_NODE)
2318 #define MIDTYPE(p) (NTYPE(p) == MID_NODE)
2319 #define SIDETYPE(p) (NTYPE(p) == SIDE_NODE)
2320 #define CENTERTYPE(p) (NTYPE(p) == CENTER_NODE)
2321
2322 #define SONNODE(p) ((p)->son)
2323 #define MYVERTEX(p) ((p)->myvertex)
2324
2325 #define ELEMENT_PTR(p) ((p)->el)
2326
2327 /****************************************************************************/
2328 /* */
2329 /* macros for links */
2330 /* */
2331 /****************************************************************************/
2332
2333 /* CAUTION: the controlword of LINK0 and its edge are identical (AVOID overlapping of flags) */
2334
2335 /* control word offset */
2336 #define LINK_OFFSET offsetof(struct link, control)/sizeof(UINT)
2337
2338 #define LOFFSET_SHIFT 0
2339 #define LOFFSET_LEN 1
2340 #define LOFFSET(p) CW_READ(p,LOFFSET_CE)
2341 #define SETLOFFSET(p,n) CW_WRITE(p,LOFFSET_CE,n)
2342
2343 /** \brief Get the neighboring node of a link */
2344 #define NBNODE(p) ((p)->nbnode)
2345 #define NEXT(p) ((p)->next)
2346 #define LDATA(p) ((p)->matelem)
2347 #define MATELEM(p) ((p)->matelem) /* can be used for node and link */
2348
2349 #define MYEDGE(p) ((EDGE *)((p)-LOFFSET(p)))
2350 /**
2351 Macro that provides fast access to the LINK in the reverse direction.
2352 If the given LINK connects node `a` with node `b`, then REVERSE
2353 provides the LINK in the list of node `b` pointing to `a`.
2354 */
2355 #define REVERSE(p) ((p)+(1-LOFFSET(p)*2))
2356
2357 #if defined(UG_DIM_2)
2358 #define LELEM(p) ((p)->elem)
2359 #define SET_LELEM(p,e) ((p)->elem = (e))
2360 #endif
2361
2362 /****************************************************************************/
2363 /* */
2364 /* macros for edges */
2365 /* */
2366 /****************************************************************************/
2367
2368 /* control word offset: Use the control word of the link object contained in the edge object */
2369
2370 #define EDGE_OFFSET offsetof(struct edge, links[0].control)/sizeof(UINT)
2371
2372 #define NO_OF_ELEM_SHIFT 2
2373 #define NO_OF_ELEM_LEN 7
2374 #define NO_OF_ELEM_MAX 128
2375 #define NO_OF_ELEM(p) CW_READ(p,NO_OF_ELEM_CE)
2376 #define SET_NO_OF_ELEM(p,n) CW_WRITE(p,NO_OF_ELEM_CE,n)
2377 #define INC_NO_OF_ELEM(p) SET_NO_OF_ELEM(p,NO_OF_ELEM(p)+1)
2378 #define DEC_NO_OF_ELEM(p) SET_NO_OF_ELEM(p,NO_OF_ELEM(p)-1)
2379
2380 #define AUXEDGE_SHIFT 9
2381 #define AUXEDGE_LEN 1
2382 #define AUXEDGE(p) CW_READ(p,AUXEDGE_CE)
2383 #define SETAUXEDGE(p,n) CW_WRITE(p,AUXEDGE_CE,n)
2384
2385 #define EDGENEW_SHIFT 1
2386 #define EDGENEW_LEN 1
2387 #define EDGENEW(p) CW_READ(p,EDGENEW_CE)
2388 #define SETEDGENEW(p,n) CW_WRITE(p,EDGENEW_CE,n)
2389
2390 /* boundary edges will be indicated by a subdomain id of 0 */
2391 #define EDSUBDOM_SHIFT 12
2392 #define EDSUBDOM_LEN 6
2393 #define EDSUBDOM(p) CW_READ(p,EDSUBDOM_CE)
2394 #define SETEDSUBDOM(p,n) CW_WRITE(p,EDSUBDOM_CE,n)
2395
2396 #define LINK0(p) (&((p)->links[0]))
2397 #define LINK1(p) (&((p)->links[1]))
2398 #define MIDNODE(p) ((p)->midnode)
2399 #define EDDATA(p) ((p)->data)
2400 #define EDVECTOR(p) ((p)->vector)
2401
2402 /****************************************************************************/
2403 /* */
2404 /* macros for elements */
2405 /* */
2406 /****************************************************************************/
2407
2408 enum {TRIANGLE = 3,
2409 QUADRILATERAL = 4};
2410
2411 enum {TETRAHEDRON = 4,
2412 PYRAMID = 5,
2413 PRISM = 6,
2414 HEXAHEDRON = 7};
2415
2416 /* control word offsets */
2417 #define ELEMENT_OFFSET offsetof(struct generic_element, control)/sizeof(UINT)
2418 #define FLAG_OFFSET offsetof(struct generic_element, flag)/sizeof(UINT)
2419 #define PROPERTY_OFFSET offsetof(struct generic_element, property)/sizeof(UINT)
2420
2421 /* macros for control word */
2422 #define ECLASS_SHIFT 8
2423 #define ECLASS_LEN 2
2424 #define ECLASS(p) CW_READ(p,ECLASS_CE)
2425 #define SETECLASS(p,n) CW_WRITE(p,ECLASS_CE,n)
2426
2427 #define NSONS_SHIFT 10
2428 #define NSONS_LEN 5
2429 #define NSONS(p) CW_READ(p,NSONS_CE)
2430 #define SETNSONS(p,n) CW_WRITE(p,NSONS_CE,n)
2431
2432 #define NEWEL_SHIFT 17
2433 #define NEWEL_LEN 1
2434 #define NEWEL(p) CW_READ(p,NEWEL_CE)
2435 #define SETNEWEL(p,n) CW_WRITE(p,NEWEL_CE,n)
2436
2437 /* macros for flag word */
2438 /* are obviously all for internal use */
2439
2440 /* the property field */
2441 #define SUBDOMAIN_SHIFT 24
2442 #define SUBDOMAIN_LEN 6
2443 #define SUBDOMAIN(p) CW_READ(p,SUBDOMAIN_CE)
2444 #define SETSUBDOMAIN(p,n) CW_WRITE(p,SUBDOMAIN_CE,n)
2445
2446 #define NODEORD_SHIFT 0
2447 #define NODEORD_LEN 24
2448 #define NODEORD(p) CW_READ(p,NODEORD_CE)
2449 #define SETNODEORD(p,n) CW_WRITE(p,NODEORD_CE,n)
2450
2451 #define PROP_SHIFT 30
2452 #define PROP_LEN 2
2453 #define PROP(p) CW_READ(p,PROP_CE)
2454 #define SETPROP(p,n) CW_WRITE(p,PROP_CE,n)
2455
2456 /* parallel macros */
2457 #ifdef ModelP
2458 #define PARTITION(p) ((p)->ge.lb1)
2459 #define PARHDRE(p) (&((p)->ge.ddd))
2460 #endif
2461
2462 /*******************************/
2463 /* the general element concept */
2464 /*******************************/
2465
2466 /** \brief This structure contains all topological properties
2467 of an element and more ..
2468 */
2469 struct GENERAL_ELEMENT {
2470 INT tag; /**< Element type to be defined */
2471
2472 /* the following parameters determine size of refs array in element */
2473 INT sides_of_elem; /**< How many sides ? */
2474 INT corners_of_elem; /**< How many corners ? */
2475
2476 /* local geometric description of the element */
2477 DOUBLE_VECTOR local_corner[MAX_CORNERS_OF_ELEM]; /**< Local coordinates of the corners of the element */
2478
2479 /* more size parameters */
2480 INT edges_of_elem; /**< How many edges ? */
2481 INT edges_of_side[MAX_SIDES_OF_ELEM]; /**< Number of edges for each side */
2482 INT corners_of_side[MAX_SIDES_OF_ELEM]; /**< Number of corners for each side */
2483
2484 /* index computations */
2485 /* Within each element sides, edges, corners are numbered in some way. */
2486 /* Within each side the edges and corners are numbered, within the edge the */
2487 /* corners are numbered. The following arrays map the local numbers within */
2488 /* the side or edge to the numbering within the element. */
2489 INT edge_of_side[MAX_SIDES_OF_ELEM][MAX_EDGES_OF_SIDE];
2490 INT corner_of_side[MAX_SIDES_OF_ELEM][MAX_CORNERS_OF_SIDE];
2491 INT corner_of_edge[MAX_EDGES_OF_ELEM][CORNERS_OF_EDGE];
2492
2493 /* the following parameters are derived from data above */
2494 GM_OBJECTS mapped_inner_objt = NOOBJ; /* tag to objt mapping for free list*/
2495 GM_OBJECTS mapped_bnd_objt = NOOBJ; /* tag to objt mapping for free list*/
2496 INT inner_size, bnd_size; /* size in bytes used for alloc */
2497 INT edge_with_corners[MAX_CORNERS_OF_ELEM][MAX_CORNERS_OF_ELEM];
2498 INT side_with_edge[MAX_EDGES_OF_ELEM][MAX_SIDES_OF_EDGE];
2499 INT corner_of_side_inv[MAX_SIDES_OF_ELEM][MAX_CORNERS_OF_ELEM];
2500 INT edges_of_corner[MAX_CORNERS_OF_ELEM][MAX_EDGES_OF_ELEM];
2501 INT corner_opp_to_side[MAX_SIDES_OF_ELEM];
2502 INT opposite_edge[MAX_EDGES_OF_ELEM];
2503 INT side_opp_to_corner[MAX_CORNERS_OF_ELEM];
2504 INT edge_of_corner[MAX_CORNERS_OF_ELEM][MAX_EDGES_OF_ELEM];
2505 INT edge_of_two_sides[MAX_SIDES_OF_ELEM][MAX_SIDES_OF_ELEM];
2506
2507 /* ... the refinement rules should be placed here later */
2508 };
2509
2510 END_UGDIM_NAMESPACE
2511
2512 /** \todo move this to include section, when other general element stuff is separated */
2513 #include "elements.h"
2514
2515 START_UGDIM_NAMESPACE
2516
2517 /****************************************************************************/
2518 /* */
2519 /* macros for element descriptors */
2520 /* */
2521 /****************************************************************************/
2522
2523 /** @name Macros to access element descriptors by element pointers */
2524 /*@{*/
2525 /** Returns the number of sides of a given element. In 2D the number of sides and number
2526 of edges of an element coincide. The nb, sidevector and side
2527 arrays are of this size.
2528 */
2529 #define SIDES_OF_ELEM(p) (element_descriptors[TAG(p)]->sides_of_elem)
2530 /** Returns the number of edges of a given element. In 2D the number of sides and number
2531 of edges of an element coincide.
2532 */
2533 #define EDGES_OF_ELEM(p) (element_descriptors[TAG(p)]->edges_of_elem)
2534 /** Returns the number of corners of a given element. This is also the size of the n array.
2535 */
2536 #define CORNERS_OF_ELEM(p) (element_descriptors[TAG(p)]->corners_of_elem)
2537 #define LOCAL_COORD_OF_ELEM(p,c) (element_descriptors[TAG(p)]->local_corner[(c)])
2538
2539 /** \brief Returns the number of edges of side i of the given element.
2540 *
2541 * In 2D a side has always one edge since edges and sides coincide.
2542 */
2543 #define EDGES_OF_SIDE(p,i) (element_descriptors[TAG(p)]->edges_of_side[(i)])
2544
2545 /** \brief Returns the number of corners of side i of the given element. */
2546 #define CORNERS_OF_SIDE(p,i) (element_descriptors[TAG(p)]->corners_of_side[(i)])
2547
2548 /** \brief Returns the number of edge e of side s within the element p. */
2549 #define EDGE_OF_SIDE(p,s,e) (element_descriptors[TAG(p)]->edge_of_side[(s)][(e)])
2550 #define EDGE_OF_TWO_SIDES(p,s,t) (element_descriptors[TAG(p)]->edge_of_two_sides[(s)][(t)])
2551 /** \brief Returns the number of corner c of side s within the element p. */
2552 #define CORNER_OF_SIDE(p,s,c) (element_descriptors[TAG(p)]->corner_of_side[(s)][(c)])
2553 /** \brief Returns the number of corner c of edge e within the element p. */
2554 #define CORNER_OF_EDGE(p,e,c) (element_descriptors[TAG(p)]->corner_of_edge[(e)][(c)])
2555
2556 /** \brief Returns the number of the edge (with respect to numbering in the element p)
2557 * that connects corners with numbers c0 and c1 (with respect to numbering in
2558 * element p).
2559 */
2560 #define EDGE_WITH_CORNERS(p,c0,c1) (element_descriptors[TAG(p)]->edge_with_corners[(c0)][(c1)])
2561
2562 /** SIDE_WITH_EDGE(p,e,0) and SIDE_WITH_EDGE(p,e,1) deliver the numbers
2563 * of the two sides (with respect to numbering in p) that share edge number e
2564 * (also with respect to the element).
2565 */
2566 #define SIDE_WITH_EDGE(p,e,k) (element_descriptors[TAG(p)]->side_with_edge[(e)][(k)])
2567
2568 /** When c is the number of a corner and s is the number of a side
2569 * (both with respect to numbering in the element) then
2570 * CORNER_OF_SIDE_INV returns the number of corner c with respect
2571 * to the numbering in side s or -1 if s does not contain corner c.
2572 */
2573 #define CORNER_OF_SIDE_INV(p,s,c) (element_descriptors[TAG(p)]->corner_of_side_inv[(s)][(c)])
2574
2575 /** If c is the number of a corner with respect to numbering within
2576 * the element then EDGES_OF_CORNER(p,c,k) returns all numbers
2577 * of edges (with respect to p) that are connected to corner c.
2578 * Since this number is variable a value of -1 identifies an invalid entry.
2579 * The edges are numbered consecutively, i.e. if a -1 is encountered
2580 * larger values of k (less than EDGES_OF_ELEM(p)) will lead also to -1).
2581 */
2582 #define EDGES_OF_CORNER(p,c,k) (element_descriptors[TAG(p)]->edges_of_corner[(c)][(k)])
2583 #define CORNER_OPP_TO_SIDE(p,s) (element_descriptors[TAG(p)]->corner_opp_to_side[(s)])
2584 #define OPPOSITE_EDGE(p,e) (element_descriptors[TAG(p)]->opposite_edge[(e)])
2585 #define SIDE_OPP_TO_CORNER(p,c) (element_descriptors[TAG(p)]->side_opp_to_corner[(c)])
2586 #define EDGE_OF_CORNER(p,c,e) (element_descriptors[TAG(p)]->edge_of_corner[(c)][(e)])
2587
2588 #define FLAG(p) ((p)->ge.flag)
2589 #define SUCCE(p) ((p)->ge.succ)
2590 #define PREDE(p) ((p)->ge.pred)
2591
2592 #ifdef __CENTERNODE__
2593 #define CENTERNODE(p) ((p)->ge.centernode)
2594 #endif
2595 /** \brief Returns a pointer to corner i of element p.
2596 *
2597 * i should be less than CORNERS_OF_ELEM(p).
2598 */
2599 #define CORNER(p,i) ((NODE *) (p)->ge.refs[n_offset[TAG(p)]+(i)])
2600
2601 /** \brief Returns a pointer to the father element. */
2602 #define EFATHER(p) ((ELEMENT *) (p)->ge.refs[father_offset[TAG(p)]])
2603
2604 /** \brief Returns a pointer to son i of p in the element hierarchy.
2605 *
2606 * In 3D only i=0 is allowed and the function GetSons should be used instead.
2607 * i should be smaller than NSONS(p).
2608 */
2609 #define SON(p,i) ((ELEMENT *) (p)->ge.refs[sons_offset[TAG(p)]+(i)])
2610
2611 /** \todo NbElem is declared in ugm.h, but never defined.
2612 We need a clean solution. */
2613 /*
2614 #if defined(UG_DIM_2)
2615 #define NBELEM(p,i) NbElem((p),(i))
2616 #else
2617 */
2618 /** \brief Returns a pointer to neighboring element over side i.
2619 *
2620 * i should be less than SIDES_OF_ELEM(p).
2621 */
2622 #define NBELEM(p,i) ((ELEMENT *) (p)->ge.refs[nb_offset[TAG(p)]+(i)])
2623 /*
2624 #endif
2625 */
2626 #define ELEM_BNDS(p,i) ((BNDS *) (p)->ge.refs[side_offset[TAG(p)]+(i)])
2627 #define EVECTOR(p) ((VECTOR *) (p)->ge.refs[0])
2628
2629 /** \brief Returns a pointer to the VECTOR associated with the side i of element p.
2630 *
2631 * i must be less than SIDES_OF_ELEM(p).
2632 */
2633 #define SVECTOR(p,i) ((VECTOR *) (p)->ge.refs[svector_offset[TAG(p)]+(i)])
2634 #define SIDE_ON_BND(p,i) (ELEM_BNDS(p,i) != NULL)
2635 #define INNER_SIDE(p,i) (ELEM_BNDS(p,i) == NULL)
2636 #define INNER_BOUNDARY(p,i) (InnerBoundary(p,i))
2637 /* TODO: replace by function call */
2638
2639 #ifdef UG_DIM_2
2640 #define EDGE_ON_BND(p,i) (ELEM_BNDS(p,i) != NULL)
2641 #endif
2642
2643 #ifdef UG_DIM_3
2644 #define EDGE_ON_BND(p,i) (SIDE_ON_BND(p,SIDE_WITH_EDGE(p,i,0)) || \
2645 SIDE_ON_BND(p,SIDE_WITH_EDGE(p,i,1)))
2646 #endif
2647 /*@}*/
2648
2649 /* use the following macros to assign values, since definition */
2650 /* above is no proper lvalue. */
2651 #ifdef __CENTERNODE__
2652 #define SET_CENTERNODE(p,q) ((p)->ge.centernode = q)
2653 #endif
2654 #define SET_CORNER(p,i,q) ((p)->ge.refs[n_offset[TAG(p)]+(i)] = q)
2655 #define SET_EFATHER(p,q) ((p)->ge.refs[father_offset[TAG(p)]] = q)
2656 #define SET_SON(p,i,q) ((p)->ge.refs[sons_offset[TAG(p)]+(i)] = q)
2657 /** \todo Set_NbElem is declared in ugm.h, but never defined.
2658 We need a clean solution. */
2659 /*
2660 #if defined(UG_DIM_2)
2661 #define SET_NBELEM(p,i,q) Set_NbElem((p),(i),(q))
2662 #else
2663 */
2664 #define SET_NBELEM(p,i,q) ((p)->ge.refs[nb_offset[TAG(p)]+(i)] = q)
2665 /*
2666 #endif
2667 */
2668 #if defined(UG_DIM_2)
2669 #define VOID_NBELEM(p,i) NBELEM(p,i)
2670 #else
2671 #define VOID_NBELEM(p,i) ((p)->ge.refs[nb_offset[TAG(p)]+(i)])
2672 #endif
2673 #define SET_BNDS(p,i,q) ((p)->ge.refs[side_offset[TAG(p)]+(i)] = q)
2674 #define SET_EVECTOR(p,q) ((p)->ge.refs[evector_offset[TAG(p)]] = q)
2675 #if defined(UG_DIM_3)
2676 #define SET_SVECTOR(p,i,q) ((p)->ge.refs[svector_offset[TAG(p)]+(i)] = q)
2677 #endif
2678
2679 /** @name Macros to access corner pointers directly */
2680 /*@{*/
2681 #define CORNER_OF_EDGE_PTR(e,i,j) (CORNER(e,CORNER_OF_EDGE(e,i,j)))
2682 #define CORNER_OF_SIDE_PTR(e,i,j) (CORNER(e,CORNER_OF_SIDE(e,i,j)))
2683 /*@}*/
2684
2685 /** @name Macros to access element descriptors by element tags */
2686 /*@{*/
2687 #define INNER_SIZE_TAG(t) (element_descriptors[t]->inner_size)
2688 #define BND_SIZE_TAG(t) (element_descriptors[t]->bnd_size)
2689 #define MAPPED_INNER_OBJT_TAG(t) (element_descriptors[t]->mapped_inner_objt)
2690 #define MAPPED_BND_OBJT_TAG(t) (element_descriptors[t]->mapped_bnd_objt)
2691
2692 #define SIDES_OF_TAG(t) (element_descriptors[t]->sides_of_elem)
2693 #define EDGES_OF_TAG(t) (element_descriptors[t]->edges_of_elem)
2694 #define CORNERS_OF_TAG(t) (element_descriptors[t]->corners_of_elem)
2695 #define LOCAL_COORD_OF_TAG(t,c) (element_descriptors[t]->local_corner[(c)])
2696
2697 #define EDGES_OF_SIDE_TAG(t,i) (element_descriptors[t]->edges_of_side[(i)])
2698 #define CORNERS_OF_SIDE_TAG(t,i) (element_descriptors[t]->corners_of_side[(i)])
2699
2700 #define EDGE_OF_SIDE_TAG(t,s,e) (element_descriptors[t]->edge_of_side[(s)][(e)])
2701 #define EDGE_OF_TWO_SIDES_TAG(t,s,u) (element_descriptors[t]->edge_of_two_sides[(s)][(u)])
2702 #define CORNER_OF_SIDE_TAG(t,s,c) (element_descriptors[t]->corner_of_side[(s)][(c)])
2703 #define CORNER_OF_EDGE_TAG(t,e,c) (element_descriptors[t]->corner_of_edge[(e)][(c)])
2704
2705 #define EDGE_WITH_CORNERS_TAG(t,c0,c1) (element_descriptors[t]->edge_with_corners[(c0)][(c1)])
2706 #define SIDE_WITH_EDGE_TAG(t,e,k) (element_descriptors[t]->side_with_edge[(e)][(k)])
2707 #define CORNER_OF_SIDE_INV_TAG(t,s,c) (element_descriptors[t]->corner_of_side_inv[(s)][(c)])
2708 #define EDGES_OF_CORNER_TAG(t,c,k) (element_descriptors[t]->edges_of_corner[(c)][(k)])
2709 #define CORNER_OPP_TO_SIDE_TAG(t,s) (element_descriptors[t]->corner_opp_to_side[(s)])
2710 #define OPPOSITE_EDGE_TAG(t,e) (element_descriptors[t]->opposite_edge[(e)])
2711 #define SIDE_OPP_TO_CORNER_TAG(t,c) (element_descriptors[t]->side_opp_to_corner[(c)])
2712 #define EDGE_OF_CORNER_TAG(t,c,e) (element_descriptors[t]->edge_of_corner[(c)][(e)])
2713 /*@}*/
2714
2715 /****************************************************************************/
2716 /* */
2717 /* macros for grids */
2718 /* */
2719 /****************************************************************************/
2720
2721 /* control word offset */
2722 #define GRID_OFFSET offsetof(grid,control)/sizeof(UINT)
2723 #define GRID_STATUS_OFFSET offsetof(grid,status)/sizeof(UINT)
2724
2725 #define GLEVEL(p) ((p)->level)
2726 #define GFORMAT(p) MGFORMAT(MYMG(p))
2727 #define SETGLOBALGSTATUS(p) ((p)->status=~0)
2728 #define GSTATUS(p,n) ((p)->status&(n))
2729 /** \brief Set or reset all bits that are 1 in the mask n. */
2730 #define RESETGSTATUS(p,n) ((p)->status&=~(n))
2731
2732 #ifdef ModelP
2733 #define PFIRSTELEMENT(p) ((LISTPART_FIRSTELEMENT(p,0)!=NULL) ?\
2734 (LISTPART_FIRSTELEMENT(p,0)) : (FIRSTELEMENT(p)))
2735 #define PRIO_FIRSTELEMENT(p,prio) ((p)->elements[PRIO2LISTPART(ELEMENT_LIST,prio)])
2736 #define LISTPART_FIRSTELEMENT(p,part) ((p)->elements[part])
2737 #define FIRSTELEMENT(p) ((p)->elements[PRIO2LISTPART(ELEMENT_LIST,PrioMaster)])
2738
2739 #define PLASTELEMENT(p) LASTELEMENT(p)
2740 #define PRIO_LASTELEMENT(p,prio) ((p)->lastelement[PRIO2LISTPART(ELEMENT_LIST,prio)])
2741 #define LISTPART_LASTELEMENT(p,part) ((p)->lastelement[part])
2742 #define LASTELEMENT(p) ((p)->lastelement[PRIO2LISTPART(ELEMENT_LIST,PrioMaster)])
2743 #else
2744 #define FIRSTELEMENT(p) ((p)->elements[0])
2745 #define PFIRSTELEMENT(p) FIRSTELEMENT(p)
2746 #define LASTELEMENT(p) ((p)->lastelement[0])
2747 #define PLASTELEMENT(p) LASTELEMENT(p)
2748 #endif
2749
2750 #ifdef ModelP
2751 #define PFIRSTVERTEX(p) ((LISTPART_FIRSTVERTEX(p,0)!=NULL) ?\
2752 (LISTPART_FIRSTVERTEX(p,0)) :\
2753 ((LISTPART_FIRSTVERTEX(p,1)!=NULL) ?\
2754 (LISTPART_FIRSTVERTEX(p,1)) : (FIRSTVERTEX(p))))
2755 #define PRIO_FIRSTVERTEX(p,prio) ((p)->vertices[PRIO2LISTPART(VERTEX_LIST,prio)])
2756 #define LISTPART_FIRSTVERTEX(p,part) ((p)->vertices[part])
2757 #define FIRSTVERTEX(p) (((p)->vertices[PRIO2LISTPART(VERTEX_LIST,\
2758 PrioBorder)]!=NULL) ?\
2759 (p)->vertices[PRIO2LISTPART(VERTEX_LIST,PrioBorder)] :\
2760 (p)->vertices[PRIO2LISTPART(VERTEX_LIST,PrioMaster)])
2761 #define SFIRSTVERTEX(p) (p)->vertices[PRIO2LISTPART(VERTEX_LIST,PrioMaster)]
2762
2763 #define PLASTVERTEX(p) LASTVERTEX(p)
2764 #define PRIO_LASTVERTEX(p,prio) ((p)->lastvertex[PRIO2LISTPART(VERTEX_LIST,prio)])
2765 #define LISTPART_LASTVERTEX(p,part) ((p)->lastvertex[part])
2766 #define LASTVERTEX(p) ((p)->lastvertex[PRIO2LISTPART(VERTEX_LIST,PrioMaster)])
2767 #else
2768 #define FIRSTVERTEX(p) ((p)->vertices[0])
2769 #define PFIRSTVERTEX(p) FIRSTVERTEX(p)
2770 #define SFIRSTVERTEX(p) FIRSTVERTEX(p)
2771 #define LASTVERTEX(p) ((p)->lastvertex[0])
2772 #define PLASTVERTEX(p) LASTVERTEX(p)
2773 #endif
2774
2775 #define FIRSTELEMSIDE(p) ((p)->sides)
2776
2777 #ifdef ModelP
2778 #define PFIRSTNODE(p) ((LISTPART_FIRSTNODE(p,0)!=NULL) ?\
2779 (LISTPART_FIRSTNODE(p,0)) :\
2780 ((LISTPART_FIRSTNODE(p,1)!=NULL) ?\
2781 (LISTPART_FIRSTNODE(p,1)) : (FIRSTNODE(p))))
2782 #define PRIO_FIRSTNODE(p,prio) ((p)->firstNode[PRIO2LISTPART(NODE_LIST,prio)])
2783 #define LISTPART_FIRSTNODE(p,part) ((p)->firstNode[part])
2784 #define FIRSTNODE(p) (((p)->firstNode[PRIO2LISTPART(NODE_LIST,\
2785 PrioBorder)]!=NULL) ?\
2786 (p)->firstNode[PRIO2LISTPART(NODE_LIST,PrioBorder)] :\
2787 (p)->firstNode[PRIO2LISTPART(NODE_LIST,PrioMaster)])
2788 #define SFIRSTNODE(p) (p)->firstNode[PRIO2LISTPART(NODE_LIST,PrioMaster)]
2789
2790 #define PLASTNODE(p) LASTNODE(p)
2791 #define PRIO_LASTNODE(p,prio) ((p)->lastNode[PRIO2LISTPART(NODE_LIST,prio)])
2792 #define LISTPART_LASTNODE(p,part) ((p)->lastNode[part])
2793 #define LASTNODE(p) ((p)->lastNode[PRIO2LISTPART(NODE_LIST,PrioMaster)])
2794 #else
2795 #define FIRSTNODE(p) ((p)->firstNode[0])
2796 #define PFIRSTNODE(p) FIRSTNODE(p)
2797 #define SFIRSTNODE(p) FIRSTNODE(p)
2798 #define LASTNODE(p) ((p)->lastNode[0])
2799 #define PLASTNODE(p) LASTNODE(p)
2800 #endif
2801
2802 #ifdef ModelP
2803 #define PFIRSTVECTOR(p) ((LISTPART_FIRSTVECTOR(p,0)!=NULL) ?\
2804 (LISTPART_FIRSTVECTOR(p,0)) :\
2805 ((LISTPART_FIRSTVECTOR(p,1)!=NULL) ?\
2806 (LISTPART_FIRSTVECTOR(p,1)) : (FIRSTVECTOR(p))))
2807 #define PRIO_FIRSTVECTOR(p,prio) ((p)->firstVector[PRIO2LISTPART(VECTOR_LIST,prio)])
2808 #define LISTPART_FIRSTVECTOR(p,part) ((p)->firstVector[part])
2809 #define FIRSTVECTOR(p) (((p)->firstVector[PRIO2LISTPART(VECTOR_LIST,\
2810 PrioBorder)]!=NULL) ?\
2811 (p)->firstVector[PRIO2LISTPART(VECTOR_LIST,PrioBorder)] :\
2812 (p)->firstVector[PRIO2LISTPART(VECTOR_LIST,PrioMaster)])
2813 #define SFIRSTVECTOR(p) (p)->firstVector[PRIO2LISTPART(VECTOR_LIST,PrioMaster)]
2814
2815 #define PLASTVECTOR(p) LASTVECTOR(p)
2816 #define PRIO_LASTVECTOR(p,prio) ((p)->lastVector[PRIO2LISTPART(VECTOR_LIST,prio)])
2817 #define LISTPART_LASTVECTOR(p,part) ((p)->lastVector[part])
2818 #define LASTVECTOR(p) ((p)->lastVector[PRIO2LISTPART(VECTOR_LIST,PrioMaster)])
2819 #else
2820 #define FIRSTVECTOR(p) ((p)->firstVector[0])
2821 #define PFIRSTVECTOR(p) FIRSTVECTOR(p)
2822 #define SFIRSTVECTOR(p) FIRSTVECTOR(p)
2823 #define LASTVECTOR(p) ((p)->lastVector[0])
2824 #define PLASTVECTOR(p) LASTVECTOR(p)
2825 #endif
2826
2827 #define UPGRID(p) ((p)->finer)
2828 #define DOWNGRID(p) ((p)->coarser)
2829 #define MYMG(p) ((p)->mg)
2830 #define NV(p) ((p)->nVert[0])
2831 #define NN(p) ((p)->nNode[0])
2832 #define NT(p) ((p)->nElem[0])
2833 #define NVEC(p) ((p)->nVector[0])
2834 #ifdef ModelP
2835 #define NV_PRIO(p,prio) ((p)->nVert[prio])
2836 #define NN_PRIO(p,prio) ((p)->nNode[prio])
2837 #define NT_PRIO(p,prio) ((p)->nElem[prio])
2838 #define NVEC_PRIO(p,prio) ((p)->nVector[prio])
2839 #endif
2840 #define NE(p) ((p)->nEdge)
2841 #define NS(p) ((p)->nSide)
2842 #ifdef UG_DIM_3
2843 #define VEC_DEF_IN_OBJ_OF_GRID(p,tp) (true) // 3d grids have side vectors
2844 #else
2845 #define VEC_DEF_IN_OBJ_OF_GRID(p,tp) (false) // 2d grids have no vectors at all
2846 #endif
2847 #define NIMAT(p) ((p)->nIMat)
2848
2849 #define GRID_ATTR(g) ((unsigned char) (GLEVEL(g)+32))
2850 #define ATTR_TO_GLEVEL(i) (i-32)
2851
2852 inline const PPIF::PPIFContext&
2853 grid::ppifContext() const
2854 {
2855 return mg->ppifContext();
2856 }
2857
2858 #ifdef ModelP
2859 inline const DDD::DDDContext&
2860 grid::dddContext() const
2861 {
2862 return mg->dddContext();
2863 }
2864
2865 inline DDD::DDDContext&
2866 grid::dddContext()
2867 {
2868 return mg->dddContext();
2869 }
2870 #endif
2871
2872 /****************************************************************************/
2873 /* */
2874 /* macros for multigrids */
2875 /* */
2876 /****************************************************************************/
2877
2878 /* control word offset */
2879 #define MULTIGRID_STATUS_OFFSET offsetof(struct multigrid, status)/sizeof(UINT)
2880
2881 #define MGSTATUS(p) ((p)->status)
2882 #define RESETMGSTATUS(p) {(p)->status=0; (p)->magic_cookie = (int)time(NULL); (p)->saved=0;}
2883 #define MG_MAGIC_COOKIE(p) ((p)->magic_cookie)
2884 #define VIDCNT(p) ((p)->vertIdCounter)
2885 #define NIDCNT(p) ((p)->nodeIdCounter)
2886 #define EIDCNT(p) ((p)->elemIdCounter)
2887 #define TOPLEVEL(p) ((p)->topLevel)
2888 #define FULLREFINELEVEL(p) ((p)->fullrefineLevel)
2889 #define MG_BVP(p) ((p)->theBVP)
2890 #define MG_BVPD(p) (&((p)->theBVPD))
2891 #define MGHEAP(p) ((p)->theHeap)
2892 #define MG_NPROPERTY(p) ((p)->nProperty)
2893 #define GRID_ON_LEVEL(p,i) ((p)->grids[i])
2894 #define MGNAME(p) ((p)->v.name)
2895 #ifdef UG_DIM_3
2896 #define VEC_DEF_IN_OBJ_OF_MG(p,tp) (true) // 3d grids have side vectors
2897 #else
2898 #define VEC_DEF_IN_OBJ_OF_MG(p,tp) (false) // 2d grids have no vectors at all
2899 #endif
2900 #define MG_SAVED(p) ((p)->saved)
2901
2902 /****************************************************************************/
2903 /* */
2904 #define MG_FILENAME(p) ((p)->filename)
2905 #define MG_COARSE_FIXED(p) ((p)->CoarseGridFixed)
2906 #define MG_MARK_KEY(p) ((p)->MarkKey)
2907 /* macros for formats */
2908 /* */
2909 /****************************************************************************/
2910
2911 /** \brief Constants for USED flags of objects */
2912 enum {MG_ELEMUSED = 1,
2913 MG_NODEUSED = 2,
2914 MG_EDGEUSED = 4,
2915 MG_VERTEXUSED = 8,
2916 MG_VECTORUSED = 16,
2917 MG_MATRIXUSED = 32};
2918
2919
2920 /****************************************************************************/
2921 /* */
2922 /* interface functions for module grid manager */
2923 /* */
2924 /****************************************************************************/
2925
2926 /** \brief Return values for functions returning an INT. The usual rule is: 0 ok, >0 error */
2927 enum {GM_OK = 0,
2928 GM_ERROR = 1,
2929 GM_FILEOPEN_ERROR = 2,
2930 GM_RULE_WITH_ORIENTATION = 3,
2931 GM_RULE_WITHOUT_ORIENTATION = 4,
2932 GM_OUT_OF_MEM = 5,
2933 GM_OUT_OF_RANGE = 6,
2934 GM_NOT_FOUND = 7,
2935 GM_INCONSISTENCY = 8,
2936 GM_COARSE_NOT_FIXED = 9,
2937 GM_FATAL = 999};
2938
2939
2940 /** @name Some constants passed as parameters */
2941 /*@{*/
2942 enum {GM_KEEP_BOUNDARY_NODES,
2943 GM_MOVE_BOUNDARY_NODES,
2944 GM_REFINE_TRULY_LOCAL,
2945 GM_COPY_ALL,
2946 GM_REFINE_NOT_CLOSED};
2947
2948 enum {GM_REFINE_PARALLEL, GM_REFINE_SEQUENTIAL};
2949
2950 enum {GM_REFINE_NOHEAPTEST, GM_REFINE_HEAPTEST};
2951
2952 /*@}*/
2953
2954 /* get/set current multigrid, loop through multigrids */
2955 MULTIGRID *MakeMGItem (const char *name, std::shared_ptr<PPIF::PPIFContext> context);
2956 MULTIGRID *GetMultigrid (const char *name);
2957 MULTIGRID *GetFirstMultigrid (void);
2958 MULTIGRID *GetNextMultigrid (const MULTIGRID *theMG);
2959
2960 /* create, saving and disposing a multigrid structure */
2961 MULTIGRID *CreateMultiGrid (char *MultigridName, STD_BVP *theBVP,
2962 const char *format,
2963 INT optimizedIE, INT insertMesh,
2964 std::shared_ptr<PPIF::PPIFContext> ppifContext = nullptr);
2965 MULTIGRID *OpenMGFromDataFile(MULTIGRID *theMG, INT number, char *type,
2966 char *DataFileName, NS_PREFIX MEM heapSize);
2967 INT DisposeGrid (GRID *theGrid);
2968 INT DisposeMultiGrid (MULTIGRID *theMG);
2969 INT Collapse (MULTIGRID *theMG);
2970
2971 /* coarse grid manipulations */
2972 NODE *InsertInnerNode (GRID *theGrid, const DOUBLE *pos);
2973 NODE *InsertBoundaryNode (GRID *theGrid, BNDP *bndp);
2974
2975 INT DeleteNode (GRID *theGrid, NODE *theNode);
2976 ELEMENT *InsertElement (GRID *theGrid, INT n, NODE **NodeList, ELEMENT **ElemList, INT *NbgSdList, INT *bnds_flag);
2977 INT InsertMesh (MULTIGRID *theMG, MESH *theMesh);
2978 INT DeleteElement (MULTIGRID *theMG, ELEMENT *theElement);
2979
2980 /* refinement */
2981 /** \todo !!! should be moved to rm.h [Thimo] */
2982 INT EstimateHere (const ELEMENT *theElement);
2983 INT MarkForRefinement (ELEMENT *theElement, enum RefinementRule rule, INT data);
2984 INT GetRefinementMark (ELEMENT *theElement, INT *rule, void *data);
2985 INT GetRefinementMarkType (ELEMENT *theElement);
2986 INT AdaptMultiGrid (MULTIGRID *theMG, INT flag, INT seq, INT mgtest);
2987 INT SetRefineInfo (MULTIGRID *theMG);
2988
2989
2990 /* moving nodes */
2991 #ifdef UG_DIM_3
2992 INT GetSideIDFromScratch (ELEMENT *theElement, NODE *theNode);
2993 #endif
2994
2995 /* algebraic connections */
2996 INT DisposeConnectionsInGrid (GRID *theGrid);
2997
2998 /* searching */
2999 INT InnerBoundary (ELEMENT *t, INT side);
3000
3001 /* list */
3002 void ListMultiGridHeader (const INT longformat);
3003 void ListMultiGrid (const MULTIGRID *theMG, const INT isCurrent, const INT longformat);
3004 INT MultiGridStatus (const MULTIGRID *theMG, INT gridflag, INT greenflag, INT lbflag, INT verbose);
3005 void ListGrids (const MULTIGRID *theMG);
3006 void ListNode (const MULTIGRID *theMG, const NODE *theNode, INT dataopt, INT bopt, INT nbopt, INT vopt);
3007 void ListElement (const MULTIGRID *theMG, const ELEMENT *theElement, INT dataopt, INT bopt, INT nbopt, INT vopt);
3008 void ListVector (const MULTIGRID *theMG, const VECTOR *theVector, INT dataopt, INT modifiers);
3009
3010 /* query */
3011 LINK *GetLink (const NODE *from, const NODE *to);
3012 EDGE *GetSonEdge (const EDGE *theEdge);
3013 INT GetSonEdges (const EDGE *theEdge, EDGE *SonEdges[MAX_SON_EDGES]);
3014 EDGE *GetFatherEdge (const EDGE *theEdge);
3015 #ifdef UG_DIM_3
3016 EDGE *FatherEdge (NODE **SideNodes, INT ncorners, NODE **Nodes, EDGE *theEdge);
3017 #endif
3018 EDGE *GetEdge (const NODE *from, const NODE *to);
3019 INT GetSons (const ELEMENT *theElement, ELEMENT *SonList[MAX_SONS]);
3020 #ifdef ModelP
3021 INT GetAllSons (const ELEMENT *theElement, ELEMENT *SonList[MAX_SONS]);
3022 #endif
3023 INT VectorPosition (const VECTOR *theVector, FieldVector<DOUBLE,DIM>& position);
3024
3025 /* check */
3026 #ifndef ModelP
3027 INT CheckGrid (GRID *theGrid, INT checkgeom, INT checkalgebra, INT checklists);
3028 #else
3029 INT CheckGrid (GRID *theGrid, INT checkgeom, INT checkalgebra, INT checklists, INT checkif);
3030 #endif
3031 INT CheckLists (GRID *theGrid);
3032 INT CheckSubdomains (MULTIGRID *theMG);
3033
3034 /* multigrid user data space management (using the heaps.c block heap management) */
3035 INT AllocateControlEntry (INT cw_id, INT length, INT *ce_id);
3036 INT FreeControlEntry (INT ce_id);
3037 UINT ReadCW (const void *obj, INT ce);
3038 void WriteCW (void *obj, INT ce, INT n);
3039
3040 /* miscellaneous */
3041 INT MGSetVectorClasses (MULTIGRID *theMG);
3042 INT SetEdgeSubdomainFromElements (GRID *theGrid);
3043 INT SetSubdomainIDfromBndInfo (MULTIGRID *theMG);
3044 INT FixCoarseGrid (MULTIGRID *theMG);
3045 INT ClearMultiGridUsedFlags (MULTIGRID *theMG, INT FromLevel, INT ToLevel, INT mask);
3046 void CalculateCenterOfMass (ELEMENT *theElement, DOUBLE_VECTOR center_of_mass);
3047 INT KeyForObject (KEY_OBJECT *obj);
3048
3049 /** \todo remove the following functions after the code will never need any debugging */
3050 char *PrintElementInfo (ELEMENT *theElement,INT full);
3051
3052 END_UGDIM_NAMESPACE
3053
3054 #endif