1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 /** \defgroup dom Domains
4  * \ingroup ug
5  */
6 /*! \file domain.h
7  * \ingroup dom
8  */
9 
10 /** \addtogroup dom
11  *
12  * @{
13  */
14 
15 
16 /****************************************************************************/
17 /*                                                                          */
18 /* File:      domain.h                                                      */
19 /*                                                                          */
20 /* Purpose:   standard header file template                                 */
21 /*                                                                          */
22 /* Author:    klaus Johannsen                                               */
23 /*            Institut fuer Computeranwendungen III                         */
24 /*            Universitaet Stuttgart                                        */
25 /*            Pfaffenwaldring 27                                            */
26 /*            70550 Stuttgart                                               */
27 /*            email: ug@ica3.uni-stuttgart.de                               */
28 /*                                                                          */
29 /* History:   18.06.96 begin, ug version 3.2                                */
30 /*                                                                          */
31 /* Remarks:                                                                 */
32 /*                                                                          */
33 /****************************************************************************/
34 
35 
36 
37 /****************************************************************************/
38 /*                                                                          */
39 /* auto include mechanism and other include files                           */
40 /*                                                                          */
41 /****************************************************************************/
42 
43 #ifndef __DOMAIN__
44 #define __DOMAIN__
45 
46 /****************************************************************************/
47 /*                                                                          */
48 /* defines in the following order                                           */
49 /*                                                                          */
50 /*          compile time constants defining static data size (i.e. arrays)  */
51 /*          other constants                                                 */
52 /*          macros                                                          */
53 /*                                                                          */
54 /****************************************************************************/
55 
56 #ifdef ModelP
57 #  include <dune/uggrid/parallel/ddd/dddtypes.hh>
58 #endif
59 
60 #include <dune/uggrid/low/heaps.h>
61 #include <dune/uggrid/low/namespace.h>
62 #include <dune/uggrid/low/ugenv.h>
63 #include <dune/uggrid/low/ugtypes.h>
64 
65 START_UGDIM_NAMESPACE
66 
67 /** \brief Offset of additional parameters for boundary condition function call */
68 enum DOM_IN_PARAMS {
69 
70   DOM_GLB_X,              /*!< General bnd cond. x-coordinate               */
71   DOM_GLB_Y,              /*!< General bnd cond. y-coordinate               */
72   DOM_GLB_Z,              /*!< General bnd cond. z-coordinate               */
73   DOM_EVAL_FOR_SD,        /*!< Evaluate bc for this subdomain               */
74   DOM_N_IN_PARAMS
75 };
76 
77 #define DOM_LOC_X       DOM_GLB_X       /*!< Parametrized bnd cond. local x-coord.*/
78 #define DOM_LOC_Y       DOM_GLB_Y       /*!< parametrized bnd cond. local y-coord.*/
79 
80 #define DOM_PARAM_OFFSET        DOM_N_IN_PARAMS
81 
82 /** \brief Subdomain of BC evaluation unknown */
83 #define DOM_EVAL_SD_UNKNOWN             -1.0
84 
85 /** \brief Boundary types */
86 enum BoundaryType {FIXED, FREE, PERIODIC, NON_PERIODIC};
87 
88 /** \brief Status for mesh */
89 enum MeshStatus {MESHSTAT_NOTINIT,
90                  MESHSTAT_EMPTY,
91                  MESHSTAT_CNODES,
92                  MESHSTAT_SURFMESH,
93                  MESHSTAT_MESH};
94 
95 /** @name Function formats */
96 /*@{*/
97 typedef INT (*ConfigProcPtr)(INT argc, char **argv);
98 typedef INT (*CoeffProcPtr)(DOUBLE *, DOUBLE *);
99 typedef INT (*UserProcPtr)(DOUBLE *, DOUBLE *);
100 /*@}*/
101 
102 /** @name Macros for BVPDescriptor */
103 /*@{*/
104 #define BVPD_NAME(d)         ((d)->name)
105 #define BVPD_MIDPOINT(d)     ((d)->midpoint)
106 #define BVPD_RADIUS(d)       ((d)->radius)
107 #define BVPD_CONVEX(d)       ((d)->convex)
108 #define BVPD_NSUBDOM(d)      ((d)->nSubDomains)
109 #define BVPD_NPARTS(d)       ((d)->nDomainParts)
110 #define BVPD_CONFIG(d)       ((d)->ConfigProc)
111 #define BVPD_S2P_PTR(d)      ((d)->s2p)
112 #define BVPD_S2P(d,s)        ((d)->s2p[s])
113 #define BVPD_NCOEFFF(d)      ((d)->numOfCoeffFct)
114 #define BVPD_NUSERF(d)       ((d)->numOfUserFct)
115 /*@}*/
116 
117 /****************************************************************************/
118 /*                                                                          */
119 /* data structures exported by the corresponding source file                */
120 /*                                                                          */
121 /****************************************************************************/
122 
123 typedef void *BVP;                 /*!< Structure handled by domain module    */
124 typedef void *BNDS;                /*!< Structure handled by domain module    */
125 typedef void *BNDP;                /*!< Structure handled by domain module    */
126 
127 /** \todo Please doc me! */
128 struct BVP_Descriptor
129 {
130   /** @name General part */
131   /*@{*/
132   /** \brief Name of the BVP */
133   char name[NS_PREFIX NAMELEN];
134   /*@}*/
135 
136   /** @name Domain part */
137   /*@{*/
138   /** \brief Number of subdomains, exterior not counted                */
139   INT nSubDomains;
140 
141   /** \brief Number of parts in the domain               */
142   INT nDomainParts;
143 
144   /** \brief Pointer to table subbdom --> part   */
145   INT *s2p;
146   /*@}*/
147 
148   /** @name Problem part */
149   /*@{*/
150   /** \brief Configuration function              */
151   ConfigProcPtr ConfigProc;
152 
153   /** \brief Number of coefficient functions        */
154   INT numOfCoeffFct;
155 
156   /** \brief Number of user functions               */
157   INT numOfUserFct;
158   /*@}*/
159 };
160 typedef struct BVP_Descriptor BVP_DESC;
161 
162 
163 /** \todo Please doc me! */
164 struct mesh
165 {
166 
167   /** \brief Status */
168   enum MeshStatus mesh_status;
169 
170   /** \brief Number of boundary points              */
171   INT nBndP;
172 
173   /** \brief List of boundary points                 */
174   BNDP **theBndPs;
175 
176   /** \brief Number of inner nodes                  */
177   INT nInnP;
178 
179   /** \brief Positions of inner nodes            */
180   DOUBLE **Position;
181 
182   /** \brief Number of subdomains                   */
183   INT nSubDomains;
184 
185   /** \brief Number of boundary sides per subdomain */
186   INT *nSides;
187 
188   /** \brief Number of side corners                 */
189   INT **Side_corners;
190 
191   /** \brief Triangle_id for prism                */
192   INT **xy_Side;
193 
194   /** \brief Corner ids                          */
195   INT ***Side_corner_ids;
196 
197   /** \brief Number of elements per subdomain       */
198   INT *nElements;
199 
200   /** \brief Number of element corners              */
201   INT **Element_corners;
202 
203   /** \brief Number of side corners                 */
204   INT ***Element_corner_ids;
205 
206   /** \brief Number of side corners                 */
207   INT ***nbElements;
208 
209   /** \brief Used bitwise: sides on bnd for elem */
210   INT **ElemSideOnBnd;
211 
212   /** @name Parallel part */
213   /*@}*/
214   /** \brief Level of vertex NULL if all vertex on level 0 */
215   char *VertexLevel;
216 
217   /** \brief Priority of vertex   NULL if all vertex are master               */
218   char *VertexPrio;
219 
220   /** \brief Level of element in subdomain   NULL if all elements on level 0             */
221   char **ElementLevel;
222 
223   /** \brief Priority of element in subdomain  NULL if all elements are master             */
224   char **ElementPrio;
225   /*@}*/
226 };
227 typedef struct mesh MESH;
228 
229 /****************************************************************************/
230 /*                                                                          */
231 /* definition of exported global variables                                  */
232 /*                                                                          */
233 /****************************************************************************/
234 
235 /****************************************************************************/
236 /*                                                                          */
237 /* function declarations                                                    */
238 /*                                                                          */
239 /****************************************************************************/
240 
241 
242 /****************************************************************************/
243 /*                                                                          */
244 /* functions for BVP                                                        */
245 /*                                                                          */
246 /****************************************************************************/
247 
248 
249 /****************************************************************************/
250 /*                                                                          */
251 /* functions called by script commands                                      */
252 /*                                                                          */
253 /****************************************************************************/
254 
255 
256 
257 /****************************************************************************/
258 /*                                                                          */
259 /* functions for BNDP                                                       */
260 /*                                                                          */
261 /****************************************************************************/
262 
263 
264 
265 
266 
267 
268 
269 
270 
271 /****************************************************************************/
272 /*                                                                          */
273 /* functions for BNDS                                                       */
274 /*                                                                          */
275 /****************************************************************************/
276 
277 
278 
279 
280 
281 
282 /****************************************************************************/
283 /** \brief Get pointer to BVP by name
284  *
285  * @param name - name of BVP
286 
287    This function returns the pointer to the BVP specified by its \<name\>.
288 
289  * @return <ul>
290  *   <li> pointer to BVP </li>
291  *   <li> NULL if error. </li>
292  * </ul>
293  */
294 /****************************************************************************/
295 BVP        *BVP_GetByName         (const char *name);
296 
297 void Set_Current_BVP(BVP* theBVP);
298 
299 /****************************************************************************/
300 /** \brief Initialize a BVP and return a mesh
301  *
302  * @param filename - name of file
303  * @param theHeap - heap
304  * @param MarkKey - use key for temporary memory allocation (do not Mark/Release)
305 
306    Function initialize a BVP and returns a mesh.
307 
308  * @return <ul>
309  *   <li>    0 if ok  </li>
310  *   <li>    1 if error.       </li>
311  * </ul>
312  */
313 /****************************************************************************/
314 BVP *BVP_Init (const char *filename, NS_PREFIX HEAP *theHeap, MESH *Mesh, INT MarkKey);
315 
316 /****************************************************************************/
317 /** \brief Dispose a BVP
318  *
319  * @param theBVP - BVP structure
320 
321    This function disposes a BVP.
322 
323  * @return <ul>
324  *   <li> 0 if ok </li>
325  *   <li> 1 if error. </li>
326  * </ul>
327  */
328 /****************************************************************************/
329 INT         BVP_Dispose           (BVP *theBVP);
330 
331 /****************************************************************************/
332 /** \brief Set BVP-descriptor
333  *
334  * @param theBVP - BVP structure
335  * @param theBVPDesc - descriptor to set
336 
337    This function sets the BVP descriptor according to the BVP.
338 
339  * @return <ul>
340  *   <li> 0 if ok </li>
341  *   <li> 1 if error. </li>
342  * </ul>
343  */
344 /****************************************************************************/
345 INT         BVP_SetBVPDesc        (BVP *theBVP, BVP_DESC *theBVPDesc);
346 
347 
348 /****************************************************************************/
349 /** \brief Set coefficient function(s)
350  *
351  * @param theBVP - BVP structure
352  * @param n - Number of coefficient function or -1 for all
353 
354    This function one or all coefficient functions.
355 
356  * @return <ul>
357  *   <li> 0 if ok </li>
358  *   <li> 1 if error. </li>
359  * </ul>
360  */
361 /****************************************************************************/
362 INT         BVP_SetCoeffFct       (BVP *theBVP, INT n, CoeffProcPtr *CoeffFct);
363 
364 /****************************************************************************/
365 /** \brief Set coefficient function(s)
366  *
367  * @param theBVP - BVP structure
368  * @param n - Number of user function or -1 for all
369 
370    This function gives one or all user functions.
371 
372  * @return <ul>
373  *   <li> 0 if ok </li>
374  *   <li> 1 if error. </li>
375  * </ul>
376  */
377 /****************************************************************************/
378 INT         BVP_SetUserFct        (BVP *theBVP, INT n, UserProcPtr *UserFct);
379 
380 /****************************************************************************/
381 /** \brief Check consistency of BVP
382  *
383  * @param aBVP - BVP structure
384 
385    This function checks consistency of BVP
386 
387  * @return <ul>
388  *   <li> 0 if ok </li>
389  *   <li> 1 if error. </li>
390  * </ul>
391  */
392 /****************************************************************************/
393 INT             BVP_Check                         (BVP *aBVP);
394 
395 /****************************************************************************/
396 /** \brief Sets a BNDP from command input
397  *
398  * @param theBVP - BVP structure
399  * @param argc, argv - command parameters
400 
401    This function sets a BNDP from command input parameters.
402    Options are implementation specific.
403 
404  * @return <ul>
405  *   <li> 0 if ok </li>
406  *   <li> 1 if error. </li>
407  * </ul>
408  */
409 /****************************************************************************/
410 BNDP* BVP_InsertBndP (NS_PREFIX HEAP *Heap, BVP *theBVP, INT argc, char **argv);
411 
412 /****************************************************************************/
413 /** \brief Write command to insert this BNDP
414  *
415  * @param theBndP - BNDP structure
416  * @param data - string to store command
417  * @param max_data_size - maximal datasize to use
418 
419    This function writes a command to string which inserts the BNDP.
420 
421  * @return <ul>
422  *   <li> 0 if ok
423  *   <li> 1 if error.
424  * </ul> */
425 /****************************************************************************/
426 INT         BNDP_SaveInsertedBndP (BNDP *theBndP, char *data, INT max_data_size);
427 
428 /****************************************************************************/
429 /** \brief Return global coordinates of BNDP
430  *
431  * @param theBndP - BNDP structure
432  * @param global - global coordinates
433 
434    This function returns global coordinates of BNDP
435 
436  * @return <ul>
437  *   <li> 0 if ok </li>
438  *   <li> 1 if error. </li>
439  * </ul> */
440 /****************************************************************************/
441 INT         BNDP_Global           (BNDP *theBndP, DOUBLE *global);
442 
443 /****************************************************************************/
444 /** \brief Change global coordinates of free boundary point
445  *
446  * @param aBndP - BNDP structure
447  * @param global - new global coordinates
448 
449    This function sets global coordinates of a free BNDP. The local coordinates
450    will be kept fixed which implies that the topology of the boundary triangulation
451    must not be changed!
452 
453  * @return <ul>
454  *   <li> 0 if ok </li>
455  *   <li> 1 if error. </li>
456  * </ul> */
457 /****************************************************************************/
458 INT         BNDP_Move                         (BNDP *aBndP, const DOUBLE global[]);
459 
460 /****************************************************************************/
461 /** \brief Sets descriptor for BNDP
462  *
463  * @param theBndP - BNDP structure
464  * @param move  - movable flag (0: no, 1:yes)
465  * @param part  - domain part
466 
467    This function sets the descriptor for a BNDP.
468 
469  * @return <ul>
470  *   <li> 0 if ok </li>
471  *   <li> 1 if error. </li>
472  * </ul> */
473 /****************************************************************************/
474 INT         BNDP_BndPDesc         (BNDP *theBndP, INT *move, INT *part);
475 
476 /****************************************************************************/
477 /** \brief Sets descriptor for BNDE (boundary edge)
478  *
479  * @param theBndP0 - first BNDP
480  * @param theBndP1 - second BNDP
481  * @param part   - domain part ID
482 
483    This function sets the descriptor for a BNDE.
484 
485  * @return <ul>
486  *   <li> 0 if ok
487  *   <li> 1 if error.
488  * </ul> */
489 /****************************************************************************/
490 INT         BNDP_BndEDesc         (BNDP *theBndP0, BNDP *theBndP1, INT *part);
491 
492 /****************************************************************************/
493 /** \brief Creates a BNDS from a nb of BNDPs
494  *
495  * @param Heap  - heap to allocate from
496  * @param theBndP - Pointer to list of BNDP structures
497  * @param n     - Number of BNDPs
498 
499    This function creates a BNDS from n BNDPs
500 
501  * @return <ul>
502  *   <li> pointer </li>
503  *   <li> NULL if the points describe an inner side </li>
504  * </ul> */
505 /****************************************************************************/
506 BNDS* BNDP_CreateBndS (NS_PREFIX HEAP *Heap, BNDP **theBndP, INT n);
507 
508 /****************************************************************************/
509 /** \brief Sets BNDP from a two of BNDPs
510  *
511  * @param theBndP0 - first BNDP
512  * @param theBndP1 - second BNDP
513  * @param lcoord - local coordinate between P0 and P1 where the BNDP will be created
514 
515    This function sets a BNDP from two BNDPs
516 
517  * @return <ul>
518  *   <li> pointer </li>
519  *   <li> NULL if the points describe an inner point </li>
520  * </ul> */
521 /****************************************************************************/
522 BNDP*       BNDP_CreateBndP (NS_PREFIX HEAP *Heap, BNDP *theBndP0, BNDP *theBndP1, DOUBLE lcoord);
523 
524 /****************************************************************************/
525 /** \brief Dispose a BNDP
526  *
527  * @param Heap - heap
528  * @param theBndP - BNDP
529 
530    This function disposes a BNDP
531 
532  * @return <ul>
533  *   <li>    0 if ok  </li>
534  *   <li>    1 if error.    </li>
535  * </ul> */
536 /****************************************************************************/
537 INT         BNDP_Dispose          (NS_PREFIX HEAP *Heap, BNDP *theBndP);
538 
539 /****************************************************************************/
540 /** \brief Save a BNDP
541  *
542  * @param theBndP - BNDP
543  * @param stream - file
544 
545    This function saves a BNDP on a file.
546 
547  * @return <ul>
548  *   <li>    0 if ok   </li>
549  *   <li>    1 if error.     </li>
550  * </ul> */
551 /****************************************************************************/
552 INT         BNDP_SaveBndP         (BNDP *theBndP);
553 INT         BNDP_SaveBndP_Ext     (BNDP *theBndP);
554 
555 /****************************************************************************/
556 /** \brief Load a BNDP
557  *
558  * @param theBVP - BVP structure
559  * @param Heap   - heap to allocate from
560  * @param stream - file
561 
562    This function loads a BNDP with the format given by BVP_SaveBndP and
563    allocates it from the given heap.
564 
565  * @return <ul>
566  *   <li>    0 if ok  </li>
567  *   <li>    1 if error.      </li>
568  * </ul> */
569 /****************************************************************************/
570 BNDP       *BNDP_LoadBndP         (BVP *theBVP, NS_PREFIX HEAP *Heap);
571 BNDP       *BNDP_LoadBndP_Ext     (void);
572 
573 /****************************************************************************/
574 /** \brief Gets global coordinates of local position on BNDS
575  *
576  * @param theBndS  - BNDS structure
577  * @param local  - local coordinate on BNDS
578  * @param global - global coordinate
579 
580    This function gets global coordinates of local position on BNDS
581 
582  * @return <ul>
583  *   <li> 0 if ok </li>
584  *   <li> 1 if error. </li>
585  * </ul> */
586 /****************************************************************************/
587 INT         BNDS_Global           (BNDS *theBndS, DOUBLE *local, DOUBLE *global);
588 
589 /****************************************************************************/
590 /** \brief Sets descriptor for BNDS
591  *
592  * @param theBndS - BNDS structure
593  * @param id  - subdomain ID of the element with aBndS
594  * @param nbid  - subdomain ID of the neighbour element (across the boundary)
595  * @param part  - domain part
596 
597    This function sets the descriptor for a BNDS.
598 
599  * @return <ul>
600  *   <li> 0 if ok </li>
601  *   <li> 1 if error. </li>
602  * </ul>
603  */
604 /****************************************************************************/
605 INT         BNDS_BndSDesc         (BNDS *theBndS, INT *id, INT *nbid, INT *part);
606 
607 /****************************************************************************/
608 /** \brief Create BNDP on BNDS
609  *
610  * @param Heap  - heap to allocate from
611  * @param theBndS - BNDS structure
612  * @param local - local coordinate on BNDS
613 
614    This function creates a boundary point (BNDP) on a BNDS
615 
616  * @return <ul>
617  *   <li> 0 if ok </li>
618  *   <li> 1 if error. </li>
619  * </ul> */
620 /****************************************************************************/
621 BNDP*       BNDS_CreateBndP       (NS_PREFIX HEAP *Heap, BNDS *theBndS, DOUBLE *local);
622 
623 /****************************************************************************/
624 /** \brief Dispose BNDS
625  *
626  * @param Heap - heap
627  * @param theBndS - BNDS struct
628 
629    This function disposes a BNDS
630 
631  * @return <ul>
632  *   <li> 0 if ok </li>
633  *   <li> 1 if error. </li>
634  * </ul> */
635 /****************************************************************************/
636 INT         BNDS_Dispose          (NS_PREFIX HEAP *Heap, BNDS *theBndS);
637 
638 /****************************************************************************/
639 /** \brief Gets surface ids for a BNDP
640  *
641  * @param aBndP - BNDP structure
642  * @param i     - evaluate on patch i
643  * @param n     - number of BNDS
644 
645    This function returns surface ids of the n surfaces on which
646    the BNDP resides
647 
648  * @return  surface id
649  */
650 /****************************************************************************/
651 INT         BNDP_SurfaceId        (BNDP *aBndP, INT *n, INT i);
652 
653 
654 #ifdef ModelP
655 
656 void DomInitParallel     (INT TypeBndP, INT TypeBndS);
657 void DomHandlerInit      (INT handlerSet);
658 
659 void BElementXferBndS    (DDD::DDDContext& context, BNDS **bnds, int n, int proc, int prio);
660 void BElementGatherBndS  (BNDS **bnds, int n, int cnt, char *data);
661 void BElementScatterBndS (const DDD::DDDContext& context, BNDS **bnds, int n, int cnt, char *data);
662 
663 void BVertexXferBndP     (DDD::DDDContext& context, BNDP *bndp, int proc, int prio);
664 void BVertexGatherBndP   (BNDP *bndp, int cnt, char *data);
665 void BVertexScatterBndP  (const DDD::DDDContext& context, BNDP **bndp, int cnt, char *data);
666 
667 #endif
668 
669 /* miscellaneous */
670 INT         InitDom               (void);
671 
672 
673 END_UGDIM_NAMESPACE
674 
675 #endif
676 
677 /** @} */
678