This file is indexed.

/usr/include/ug/lgm_domain.h is in libug-dev 3.12.1-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
/** \defgroup lgm The LGM Domain
 * \ingroup dom
 */
/*! \file lgm_domain.h
 * \ingroup lgm
 */

/****************************************************************************/
/*                                                                                                                                                      */
/* File:          lgm_domain.h                                                                                                  */
/*                                                                                                                                                      */
/* Purpose:   header file for lgm_domain                                                                        */
/*                                                                                                                                                      */
/* Author:        Klaus Johannsen                                                                                               */
/*                        Institut fuer Computeranwendungen III                                                 */
/*                        Universitaet Stuttgart                                                                                */
/*                        Pfaffenwaldring 27                                                                                    */
/*                        70550 Stuttgart                                                                                               */
/*                        email: klaus@ica3.uni-stuttgart.de                                                    */
/*                                                                                                                                                      */
/* History:   07.09.96 begin                                                                                            */
/*                                                                                                                                                      */
/* Remarks:                                                                                                                             */
/*                                                                                                                                                      */
/****************************************************************************/


/* RCS_ID
   $Header$
 */

/****************************************************************************/
/*                                                                                                                                                      */
/* auto include mechanism and other include files                                                       */
/*                                                                                                                                                      */
/****************************************************************************/

#ifndef __LGM_DOM__
#define __LGM_DOM__

#ifdef Grape

#include "grape.h"

#define SHORT  short
#define INT    int
#define FLOAT  float
#define DOUBLE double
#define COORD  float
#define SCREEN_COORD  float

/*dummy types */
#define ENVDIR char
#define ENVVAR char
#define ConfigProcPtr char

#warning LGM_DIM 3 for Grape is overwritten later anyway ?!
#define LGM_DIM 3

#else

#include "ugenv.h"
#include "heaps.h"
#include "domain.h"

#endif

/* need dimension defines even */
#include "dimension.h"

/* OS_CHANGED */
/* Set LGM_VERBOSE 1 to get a more verbose LGM module */
#define LGM_VERBOSE 1

/* Undefine the following line to get the old lgm geometry routines (3D) */
#define NEW_LGM
/* Undefine the following line to switch off accelerated lgm geometry access (3D) */
#define LGM_ACCELERATE

/* new lgm only for 3D, acceleration only for new lgm */
#ifdef _2
#undef NEW_LGM
#endif
#ifndef NEW_LGM
#undef LGM_ACCELERATE
#endif
#ifdef LGM_ACCELERATE
#include "bbtree.h"
#endif

#include "namespace.h"

START_UGDIM_NAMESPACE

/****************************************************************************/
/*                                                                                                                                                      */
/* defines in the following order                                                                                       */
/*                                                                                                                                                      */
/*                compile time constants defining static data size (i.e. arrays)        */
/*                other constants                                                                                                       */
/*                macros                                                                                                                        */
/*                                                                                                                                                      */
/****************************************************************************/

/****************************************************************************/
/*                                                                                                                                                      */
/*      defines for basic configuration                                                                                 */
/*                                                                                                                                                      */
/****************************************************************************/

#ifdef _2
#define LGM_DIM                                                         2
#endif

#ifdef _3
#define LGM_DIM                                                         3
#endif

/****************************************************************************/
/*																			*/
/*	other																	*/
/*																			*/
/****************************************************************************/

#define LGM_PROBLEM_NAME(p)                                     ENVITEM_NAME(p)
#define LGM_PROBLEM_INIT(p)                                     ((p)->InitProblem)
#define LGM_PROBLEM_CONFIG(p)                           ((p)->ConfigProblem)
#define LGM_PROBLEM_DOMCONFIG(p)                        ((p)->ConfigDomainSize)
#define LGM_PROBLEM_NCOEFF(p)                           ((p)->numOfCoeffFct)
#define LGM_PROBLEM_NUSERF(p)                           ((p)->numOfUserFct)
#define LGM_PROBLEM_COEFF(p,i)                          (CoeffProcPtr)(p)->CU_ProcPtr[(i)]
#define LGM_PROBLEM_SETCOEFF(p,i,q)                     (p)->CU_ProcPtr[(i)]=(void*)(q)
#define LGM_PROBLEM_USERF(p,i)                          (UserProcPtr)(p)->CU_ProcPtr[(i)+LGM_PROBLEM_NCOEFF(p)]
#define LGM_PROBLEM_SETUSERF(p,i,q)                     (p)->CU_ProcPtr[(i)+LGM_PROBLEM_NCOEFF(p)]=(void*)(q)
#define LGM_PROBLEM_BNDCOND(p)                          ((p)->BndCond)
#define LGM_PROBLEM_INNERBNDCOND(p)                     ((p)->InnerBndCond)
#define LGM_DOMAIN_S2P_PTR(p)                           ((p)->s2p)
#define LGM_DOMAIN_S2P(p,s)                                     ((p)->s2p[s])

#if (LGM_DIM==2)

/* macros for LGM_POINT */
#define LGM_POINT_POS(p)                                        ((p)->position)
#define LGM_POINT_DIST(p,q)                                     (sqrt((LGM_POINT_POS(p)[0]-LGM_POINT_POS(q)[0])*(LGM_POINT_POS(p)[0]-LGM_POINT_POS(q)[0])+(LGM_POINT_POS(p)[1]-LGM_POINT_POS(q)[1])*(LGM_POINT_POS(p)[1]-LGM_POINT_POS(q)[1])))

/* macros for LGM_LINE */
#define LGM_LINE_ID(p)                                          ((p)->id)
#define LGM_LINE_FLAG(p)                                        ((p)->flag)
#define LGM_LINE_NPOINT(p)                                      ((p)->nPoint)
#define LGM_LINE_LEFT(p)                                        ((p)->left)
#define LGM_LINE_RIGHT(p)                                       ((p)->right)
#define LGM_LINE_BEGIN(p)                                       ((p)->begin)
#define LGM_LINE_END(p)                                         ((p)->end)
#define LGM_LINE_BNDCOND(p)                                     ((p)->Bndcond)
#define LGM_LINE_POINT(p,i)                                     ((p)->point+(i))
#define LGM_LINE_POINTDIST(p,i,j)                       LGM_POINT_DIST(LGM_LINE_POINT(p,i),LGM_LINE_POINT(p,j))
#define LGM_LINE_ID_2_LINE(i)                           (LinePtrArray[i])

/* macros for LGM_SUBDOMAIN */
#define LGM_SUBDOMAIN_UNIT(p)                           ((p)->Unit)
#define LGM_SUBDOMAIN_ID(p)                                     ((p)->id)
#define LGM_SUBDOMAIN_SDDATA(p)                         ((p)->SubDomData)
#define LGM_SUBDOMAIN_NLINE(p)                          ((p)->nLines)
#define LGM_SUBDOMAIN_LINE(p,i)                         ((p)->line[(i)])

/* macros for LGM_DOMAIN */
#define LGM_DOMAIN_NAME(p)                                      ENVITEM_NAME(p)
#define LGM_DOMAIN_PROBLEMNAME(p)                       ((p)->ProblemName)
#define LGM_DOMAIN_PROBLEM(p)                           ((p)->theProblem)
#define LGM_DOMAIN_CONVEX(p)                            ((p)->convex)
#define LGM_DOMAIN_RADIUS(p)                            ((p)->radius)
#define LGM_DOMAIN_MIDPOINT(p)                          ((p)->midpoint)
#define LGM_DOMAIN_DOMDATA(p)                           ((p)->DomainData)
#define LGM_DOMAIN_NSUBDOM(p)                           ((p)->nSubDomain)
#define LGM_DOMAIN_NPART(p)                                     ((p)->nDomParts)
#define LGM_DOMAIN_NPOINT(p)                            ((p)->nPoint)
#define LGM_DOMAIN_SUBDOM(p,i)                          ((p)->theSubdom[(i)])

/* macros for LGM_BNDP */
#define LGM_BNDP_N(p)                                           ((p)->n)
#define LGM_BNDP_LINES(p,i)                                     ((p)->Line[(i)])
#define LGM_BNDP_LINE(p,i)                                      ((p)->Line[(i)].l.theLine)
#define LGM_BNDP_ID(p,i)                                        ((p)->Line[(i)].l.theLineID)
#define LGM_BNDP_LOCAL(p,i)                                     ((p)->Line[(i)].local)
#define LGM_BNDP_LINE_GLINE(p)                          ((p).l.theLine)
#define LGM_BNDP_LINE_LOCAL(p)                          ((p).local)

/* macros for LGM_BNDS */
#define LGM_BNDS_LINE(p)                                        ((p)->theLine)
#define LGM_BNDS_LOCAL(p,i)                                     ((p)->local[(i)])
#ifdef ModelP
#define LGM_BNDS_SIZE(p)                        (sizeof(LGM_BNDS))
#define LGM_BNDP_SIZE(p)                        (sizeof(LGM_BNDP))
#define LINE_ID_2_LINE(i)                                       (LinePtrArray[i])
#endif


#endif

#if (LGM_DIM==3)

#define NO_PROJECT
#undef NO_PROJECT // OS_CHANGED

#define MAXTRIANGLES 30

/* macros for LGM_POINT */
#define LGM_POINT_POS(p)                                        ((p)->position)
#define LGM_POINT_DIST(p,q)                                     (sqrt( (LGM_POINT_POS(p)[0]-LGM_POINT_POS(q)[0])*(LGM_POINT_POS(p)[0]-LGM_POINT_POS(q)[0])\
                                                                       + (LGM_POINT_POS(p)[1]-LGM_POINT_POS(q)[1])*(LGM_POINT_POS(p)[1]-LGM_POINT_POS(q)[1])\
                                                                       + (LGM_POINT_POS(p)[2]-LGM_POINT_POS(q)[2])*(LGM_POINT_POS(p)[2]-LGM_POINT_POS(q)[2])))

/* macros for LGM_LINEDISC */
#define LGM_LINEDISC_NPOINT(p)                          ((p)->npoint)
#define LGM_LINEDISC_LOCAL(p,i)                         ((p)->local[(i)])

/* macros for LGM_LINEDISCNEW */
#define LGM_LINEDISCNEW_NPOINT(p)                       ((p)->npoints)
#define LGM_LINEDISCNEW_START(p)                        ((p)->start)
#define LGM_LINEDISCNEW_POINT(p)                        ((p)->point)

/* macros for LGM_SURFDISC */
#define LGM_SURFDISC_NPOINT(p)                          ((p)->npoint)
#define LGM_SURFDISC_NTRIANGLE(p)                       ((p)->ntriangle)
#define LGM_SURFDISC_LOCAL(p,i,j)                       ((p)->local[(i)][(j)])
#define LGM_SURFDISC_TRIANGLE(p,i,j)            ((p)->triangle[(i)][(j)])
#define LGM_SURFDISC_TRIANGLE_NEIGHBOUR(p,i,j)          ((p)->neighbour[(i)][(j)])
#define LGM_SURFDISC_MESH_ID(p,i)                       ((p)->mesh_id[i])
#define LGM_SURFDISC_FMESH_ID(p)                        ((p)->mesh_id)
#define LGM_SURFDISC_XY_ID(p,i)                         ((p)->xy_id[i])

/* macros for LGM_LINE */
#define LGM_LINE_ID(p)                                          ((p)->id)
#define LGM_LINE_FLAG(p)                                        ((p)->flag)
#define LGM_LINE_NPOINT(p)                                      ((p)->nPoint)
#define LGM_LINE_POINT(p,i)                                     ((p)->point+(i))
#define LGM_LINE_LINEDISC(p)                            ((p)->ldisc)
#define LGM_LINE_LINEDISCNEW(p)                         ((p)->ldiscnew)
#define LGM_LINE_BEGIN(p)                                       ((p)->begin)
#define LGM_LINE_END(p)                                         ((p)->end)
#define LGM_LINE_USED(p)                                        ((p)->used)
#define LGM_LINE_ID_2_LINE(i)                           (LinePtrArray[i])

/* macros for LGM_TRIANGLE */
#define LGM_TRIANGLE_CORNER(p,i)                        ((p)->corner[(i)])
#define LGM_TRIANGLE_CORNERID(p,i)                      ((p)->cornerid[(i)])
#define LGM_TRIANGLE_NEIGHBOR(p,i)                      ((p)->neighbor[(i)])

/* macros for LGM_SURFACE */
#define LGM_SURFACE_ID(p)                                       ((p)->id)
#define LGM_SURFACE_FLAG(p)                                     ((p)->flag)
#define LGM_SURFACE_NPOINT(p)                           ((p)->nPoint)
#define LGM_SURFACE_NTRIANGLE(p)                        ((p)->nTriangle)
#define LGM_SURFACE_NLINE(p)                            ((p)->nLine)
#define LGM_SURFACE_LEFT(p)                                     ((p)->left)
#define LGM_SURFACE_RIGHT(p)                            ((p)->right)
#define LGM_SURFACE_BNDCOND(p)                          ((p)->Bndcond)
#define LGM_SURFACE_DISC(p)                                     ((p)->sdisc)
#define LGM_SURFACE_POINT(p,i)                          ((p)->point+(i))
#define LGM_SURFACE_TRIANGLE(p,i)                       ((p)->triangle+(i))
#define LGM_SURFACE_FPOINT(p)                           ((p)->point)
#define LGM_SURFACE_FTRIANGLE(p)                        ((p)->triangle)
#define LGM_SURFACE_LINE(p,i)                           ((p)->line[(i)])
#define LGM_SURFACE_ID_2_SURFACE(i)                     (SurfacePtrArray[i])

/* macros for LGM_SUBDOMAIN */
#define LGM_SUBDOMAIN_UNIT(p)                           ((p)->Unit)
#define LGM_SUBDOMAIN_ID(p)                                     ((p)->id)
#define LGM_SUBDOMAIN_SDDATA(p)                         ((p)->SubDomData)
#define LGM_SUBDOMAIN_NSURFACE(p)                       ((p)->nSurface)
#define LGM_SUBDOMAIN_SURFACE(p,i)                      ((p)->surface[(i)])

/* macros for LGM_DOMAIN */
#define LGM_DOMAIN_NAME(p)                                      ENVITEM_NAME(p)
#define LGM_DOMAIN_PROBLEMNAME(p)                       ((p)->ProblemName)
#define LGM_DOMAIN_PROBLEM(p)                           ((p)->theProblem)
#define LGM_DOMAIN_CONVEX(p)                            ((p)->convex)
#define LGM_DOMAIN_RADIUS(p)                            ((p)->radius)
#define LGM_DOMAIN_MIDPOINT(p)                          ((p)->midpoint)
#define LGM_DOMAIN_DOMDATA(p)                           ((p)->DomainData)
#define LGM_DOMAIN_NPOINT(p)                            ((p)->nPoint)
#define LGM_DOMAIN_NSUBDOM(p)                           ((p)->nSubDomain)
#define LGM_DOMAIN_SUBDOM(p,i)                          ((p)->theSubdom[(i)])
#define LGM_DOMAIN_NPART(p)                                     ((p)->nDomParts)
#define LGM_DOMAIN_S2P_PTR(p)                           ((p)->s2p)
#define LGM_DOMAIN_S2P(p,s)                                     ((p)->s2p[s])

/* macros for LGM_BNDP */
#define LGM_BNDP_NLINE(p)                                       ((p)->nlines)
#define LGM_BNDP_LINES(p,i)                                     ((p)->Line[(i)])
#define LGM_BNDP_LINE(p,i)                                      ((p)->Line[(i)].l.theLine)
#define LGM_BNDP_ID(p,i)                                        ((p)->Line[(i)].l.theLineID)
#ifndef NO_PROJECT
#define LGM_BNDP_LINE_LEFT(p,i)                         ((p)->Line[(i)].local_left)
#define LGM_BNDP_LINE_RIGHT(p,i)                        ((p)->Line[(i)].local_right)
#else
#define LGM_BNDP_LINE_GLOBALLEFT(p,i)           ((p)->Line[(i)].global_left)
#define LGM_BNDP_LINE_GLOBALRIGHT(p,i)          ((p)->Line[(i)].global_right)
#endif
#define LGM_BNDP_LINE_GLINE(p)                          ((p).l.theLine)
#ifndef NO_PROJECT
#define LGM_BNDP_LOCAL_LEFT(p)                          ((p).local_left)
#define LGM_BNDP_LOCAL_RIGHT(p)                         ((p).local_right)
#else
#define LGM_BNDP_GLOBAL_LEFT(p)                         ((p).global_left)
#define LGM_BNDP_GLOBAL_RIGHT(p)                        ((p).global_right)
#endif
#define LGM_BNDP_N(p)                                           ((p)->nsurf)
#define LGM_BNDP_SURFACES(p,i)                          ((p)->Surf[(i)])
#define LGM_BNDP_SURFACE(p,i)                           ((p)->Surf[(i)].s.theSurf)
#define LGM_BNDP_SURFACEID(p,i)                           ((p)->Surf[(i)].s.theSurfID)
#define LGM_BNDP_SURFACEPTR(p)                          ((p)->Surf)
#define LGM_BNDP_LINEPTR(p)                                     ((p)->Line)

#ifndef NO_PROJECT
#define LGM_BNDP_LOCAL(p,i)                                     ((p)->Surf[(i)].local)
#else
#define LGM_BNDP_GLOBAL(p,i)                            ((p)->Surf[(i)].global)
#endif
#define LGM_BNDP_SURFACE_GSURFACE(p)            ((p).s.theSurf)
#ifndef NO_PROJECT
#define LGM_BNDP_SURFACE_LOCAL(p)                       ((p).local)
#else
#define LGM_BNDP_SURFACE_GLOBAL(p)                      ((p).global)
#endif

/* macros for LGM_BNDS */
#define LGM_BNDS_N(p)                                           ((p)->nn)
#define LGM_BNDS_SURFACE(p)                                     ((p)->theSurf)
#ifndef NO_PROJECT
#define LGM_BNDS_LOCAL(p,i,j)                           ((p)->local[(i)][(j)])
#else
#define LGM_BNDS_GLOBAL(p,i,j)                          ((p)->global[(i)][(j)])
#endif
#define LGM_BNDS_TRIANGLE(p,i)                          ((p)->triangle[(i)])


#endif

typedef INT (*InitProcPtr)(INT, char **, INT, char *, HEAP *);
typedef INT (*BndCondProcPtr)(DOUBLE *, DOUBLE *, INT *);
typedef INT (*DomainSizeConfig)(DOUBLE *min, DOUBLE *max);


/****************************************************************************/
/*                                                                                                                                                      */
/* data structures exported by the corresponding source file                            */
/*                                                                                                                                                      */
/****************************************************************************/

struct lgm_problem {
  /* fields for environment directory */
  ENVDIR v;

  /* fields for problem */
  InitProcPtr InitProblem;          /* procedure to initialize problem          */
  ConfigProcPtr ConfigProblem;      /* procedure to reinitialize problem		*/
  DomainSizeConfig ConfigDomainSize;      /* procedure to reinitialize size of d*/
  BndCondProcPtr BndCond;               /* global boundary condition				*/
  BndCondProcPtr InnerBndCond;      /* global inner boundary condition                  */
  INT numOfCoeffFct;                            /* number of coefficient functions			*/
  INT numOfUserFct;                             /* number of User functions					*/
  void *CU_ProcPtr[1];                  /* coefficient functions					*/
};


#if (LGM_DIM==2)
/****************************************************************************/
/*                                                                          */
/*      2D structures                                                       */
/*                                                                          */
/****************************************************************************/

struct lgm_point {

  DOUBLE position[LGM_DIM];                              /* position of corner */
};

struct lgm_line {

  INT id;                               /* id of the line                               */
  INT flag;                             /* general purpose flag                 */
  INT nPoint;                           /* nb. of points on the line            */
  INT left, right;                      /* subdomain on left and right side     */
  INT begin, end;                       /* global id's starting from 0          */
  BndCondProcPtr Bndcond;               /* boundary condition                   */
  struct lgm_point point[1];                    /* points of line stored here           */
};

struct lgm_subdom_data {

  INT dummy;
};

struct lgm_subdom {

  /* parameters */
  char Unit[128];                                               /* unit-identification                                                  */
  INT id;                                                               /* unique id, beginning with 1                                  */
  INT nLines;                                                           /* nb. of lines                                                                 */
  struct lgm_subdom_data *SubDomData;           /* data for subdomain                                                   */

  /* references */
  struct lgm_line *line[1];                             /* begin of line reference field                                */
};

struct lgm_dom_data {

  INT dummy;
};

struct lgm_domain {

  /* fields for environment directory */
  ENVVAR v;

  /* heap */
  HEAP *theHeap;

  /* parameters */
  INT convex;                                                           /* 0 (no) or 1 (yes)                                                    */
  float radius, midpoint[LGM_DIM];              /* sphere of which domain is a subset                   */
  INT nSubDomain;                                               /* nb. of subdomains                                                    */
  INT nDomParts;                                                /* nb. of domain parts                                                  */
  INT *s2p;                                                             /* pointer to table subbdom --> part                    */
  INT nPoint;                                                           /* nb. of points                                                                */
  struct lgm_dom_data *DomainData;              /* data for domain                                                              */

  /* problem */
  char ProblemName[128];                                /* name of problem                                                              */
  struct lgm_problem *theProblem;               /* ptr to problem                                                               */

  /* reference to domain data */
  struct lgm_subdom *theSubdom[1];              /* begin of subdom reference field                              */
};

struct lgm_bndp_line {
  union {
    struct lgm_line *theLine;   /* real line data                */
    INT theLineID;              /* used by Load_Ext and Save_Ext */
  } l;
  DOUBLE local;                                                 /* local coordinate                                                             */
};

struct lgm_bndp {

  INT n;                                /* number of lines                                      */
  struct lgm_bndp_line Line[1];         /* line(s)                                                          */
};

struct lgm_bnds {

  struct lgm_line *theLine;                             /* line                                                                                 */
  DOUBLE local[2];                                              /* local coordinates                                                    */
};

typedef struct lgm_point LGM_POINT;
typedef struct linedisc LGM_LINEDISC;
typedef struct surfdisc LGM_SURFDISC;
typedef struct lgm_line LGM_LINE;
typedef struct lgm_subdom_data LGM_SUBDOMAIN_DATA;
typedef struct lgm_subdom LGM_SUBDOMAIN;
typedef struct lgm_domain LGM_DOMAIN;
typedef struct lgm_problem LGM_PROBLEM;
typedef struct lgm_bndp_line LGM_BNDP_PLINE;
typedef struct lgm_bndp LGM_BNDP;
typedef struct lgm_bnds LGM_BNDS;

#endif

#if (LGM_DIM==3)
/****************************************************************************/
/*                                                                          */
/*      3D structures                                                                                                                   */
/*                                                                          */
/****************************************************************************/

struct lgm_point {

  DOUBLE position[LGM_DIM];                     /* position of corner                                           */
};

struct linepoint
{
  DOUBLE local;
  struct linepoint *next;
};

typedef struct linepoint LINEPOINT;

struct linediscnew
{
  INT npoints;
  LINEPOINT *start;
  LINEPOINT *point;
};

typedef struct linediscnew LINEDISCNEW;

struct linedisc {

  INT npoint;                                                   /* nb. of discretization points on the line     */
  DOUBLE *local;                                        /* local coorddinates of the points                     */
};

struct lgm_line {
  INT id;                                                       /* id of the line */
  INT flag;                                                     /* general purpose flag         */
  INT nPoint;                                                   /* nb. of points on the line    */
  INT begin, end;                                       /* global id's starting from 0  */
  struct linedisc *ldisc;                       /* discretization of the line   */
  LINEDISCNEW *ldiscnew;                        /* discretization of the line   */

  /* specials for grape */
        #ifdef Grape
  INT active;
        #endif
  INT used;
  struct lgm_point point[1];                    /* points of line stored here   */
};

struct surfdisc {

  INT npoint;                                                   /* nb. of discretization points on the surface*/
  INT ntriangle;                                        /* nb. of ggtriangles on the surface            */
  DOUBLE **local;                                       /* local coorddinates of the points                     */
  INT *mesh_id;                                         /* id of point in mesh-structure                        */
  INT **triangle;                                       /* triangle-list                                                        */
  INT *xy_id;                                                   /* triangle-list                                                        */
  INT **neighbour;                                      /* triangle-neighbour-list                                                      */
  INT dummy;                                                    /* to fill according to the needs                       */
};

struct lgm_triangle {

  struct lgm_point *corner[3];          /* corners of the triangle                                      */
  int cornerid[3];
  int neighbor[3];                                      /* neighbors of the triangle                            */
};

struct lgm_surface {

  INT id;
  INT flag;                                                             /* general purpose flag		                        */
  INT nPoint;                                                           /* nb. of points on the surface			*/
  INT nTriangle;                                                /* nb. of triangles on the surface		*/
  INT nLine;                                                            /* nb. of lines on the surface			*/
  INT left, right;                                              /* subdomain on left and right side		*/
  BndCondProcPtr Bndcond;                               /* boundary condition					*/
  struct surfdisc *sdisc;                               /* discretization of the surface		*/
  struct lgm_point *point;                              /* ptr to first point					*/
  struct lgm_triangle *triangle;                /* ptr to first triangle				*/

  /* specials for grape */
        #ifdef Grape
  INT active;
        #endif

  /* for fast triangle search OS_CHANGED */
        #ifdef LGM_ACCELERATE
  BBT_TREE *bbtree;
        #endif

  /* references */
  struct lgm_line *line[1];                             /* ptr to lines							*/
};

struct lgm_subdom_data {

  INT dummy;
};

struct lgm_subdom {

  /* parameters */
  char Unit[128];                                               /* unit-identification                                  */
  INT id;                                                               /* unique id, beginning with 1                  */
  INT nSurface;                                                 /* nb. of surfaces                                              */
  INT nPoint;                                                           /* nb. of points                                                */
  struct lgm_subdom_data *SubDomData;           /* data for subdomain                                   */

  /* problem */
  char ProblemName[128];                                /* name of problem                                              */
  struct lgm_problem *theProblem;               /* ptr to problem                                               */

  /* specials for grape */
        #ifdef Grape
  INT active;
  SUPROP_DEV *suprop;
        #endif

  /* references */
  struct lgm_surface *surface[1];               /* begin of surface reference field             */
};

struct lgm_dom_data {

  INT dummy;
};

struct lgm_domain {

  /* fields for environment directory */
  ENVVAR v;

  /* heap */
  HEAP *theHeap;

  /* parameters */
  INT convex;                                                           /* 0 (no) or 1 (yes)                                                    */
  float radius, midpoint[LGM_DIM];              /* sphere of which domain is a subset                   */
  INT nSubDomain;                                               /* nb. of subdomains                                                    */
  INT nDomParts;                                                /* nb. of domain parts                                                  */
  INT *s2p;                                                             /* pointer to table subbdom --> part                    */
  INT nPoint;                                                           /* nb. of points                                                                */
  struct lgm_dom_data *DomainData;              /* data for domain                                                              */

  /* problem */
  char ProblemName[128];                                /* name of problem                                                              */
  struct lgm_problem *theProblem;               /* ptr to problem                                                               */

  /* reference to domain data */
  struct lgm_subdom *theSubdom[1];              /* begin of subdom reference field                              */
};

struct lgm_bndp_line {

  union
  {
    struct lgm_line *theLine;  /* either pointer to line data ...  */
    INT theLineID;             /* ... or just an ID (for Save_Ext/Load_Ext) */
  } l;

        #ifdef NO_PROJECT
  DOUBLE global_left[3];                                /* global coordinate of the left neighbor       */
  DOUBLE global_right[3];                               /* global coordinate of the right neighbor      */
        #else
  DOUBLE local_left;                                            /* local coordinate of the left neighbor        */
  DOUBLE local_right;                                           /* local coordinate of the right neighbor       */
        #endif
};

struct lgm_bndp_surf {

  union
  {
    struct lgm_surface *theSurf;  /* surface... */
    INT theSurfID;                /* ... or just ID */
  } s;

    #ifdef NO_PROJECT
  DOUBLE global[3];                                                     /* global coordinate                                                            */
        #else
  DOUBLE local[2];                                                      /* local coordinate                                                             */
    #endif
};

struct lgm_bndp {

  INT nlines;                                                           /* number of lines                                                              */
  struct lgm_bndp_line *Line;                           /* line(s)                                                                              */
  INT nsurf;                                /* number of surfaces                                       */
  struct lgm_bndp_surf *Surf;           /* surface(s)                                                   */
};

struct lgm_bnds_triangle {

  struct lgm_triangle *triangle;                /* ptr to triangle                                                              */
  DOUBLE local[2];                                              /* local coordinate                                                             */
};

struct lgm_bnds {

  INT nn;
  struct lgm_surface *theSurf;                  /* surface										*/
        #ifdef NO_PROJECT
  DOUBLE global[4][3];                                  /* global coordinates							*/
        #else
  DOUBLE local[4][2];                                           /* local coordinates							*/
        #endif
};


typedef struct lgm_point LGM_POINT;
typedef struct linedisc LGM_LINEDISC;
typedef struct linediscnew LGM_LINEDISCNEW;
typedef struct lgm_line LGM_LINE;
typedef struct surfdisc LGM_SURFDISC;
typedef struct lgm_triangle LGM_TRIANGLE;
typedef struct lgm_surface LGM_SURFACE;
typedef struct lgm_subdom_data LGM_SUBDOMAIN_DATA;
typedef struct lgm_subdom LGM_SUBDOMAIN;
typedef struct lgm_domain LGM_DOMAIN;
typedef struct lgm_problem LGM_PROBLEM;
typedef struct lgm_bndp LGM_BNDP;
typedef struct lgm_bnds LGM_BNDS;
typedef struct lgm_bndp_line LGM_BNDP_PLINE;
typedef struct lgm_bndp_surf LGM_BNDP_PSURFACE;

#endif

#ifdef Grape
typedef struct Domain3d
{
  INSTANCE_STRUCT;\
  LGM_DOMAIN *domain;
} DOMAIN3D;
#endif

/****************************************************************************/
/*                                                                                                                                                      */
/* definition of exported global variables                                                                      */
/*                                                                                                                                                      */
/****************************************************************************/


/****************************************************************************/
/*                                                                                                                                                      */
/* function declarations                                                                                                        */
/*                                                                                                                                                      */
/****************************************************************************/
#if (LGM_DIM==2)
LGM_LINE                                *FirstLine                      (LGM_DOMAIN *theDomain);
LGM_LINE                                *NextLine                       (LGM_DOMAIN *theDomain);
#endif
#if (LGM_DIM==3)
LGM_SURFACE                     *FirstSurface           (LGM_DOMAIN *theDomain);
LGM_SURFACE                     *NextSurface            (LGM_DOMAIN *theDomain);
LGM_LINE                                *FirstLine                      (LGM_DOMAIN *theDomain);
LGM_LINE                                *NextLine                       (LGM_DOMAIN *theDomain);
INT                                     LGM_BNDS_SurfId         (BNDS *aBndS);

/*for evaluation of global coordinates*/
INT Line_Local2GlobalNew (LGM_LINE *theLine, DOUBLE *global, DOUBLE local);
INT Surface_Local2Global (LGM_SURFACE *theSurface, DOUBLE *global, DOUBLE *local);

#endif

#ifdef __THREEDIM__
BNDP *BNDP_InsertBndP (HEAP *Heap, BVP *aBVP, double *global);
#endif

#ifndef Grape
LGM_PROBLEM *CreateProblem (const char *name, InitProcPtr config, DomainSizeConfig domconfig, BndCondProcPtr BndCond, int numOfCoefficients, CoeffProcPtr coeffs[], int numOfUserFct, UserProcPtr userfct[]);
LGM_PROBLEM *CreateProblemWithInnerBCs (const char *name, InitProcPtr config, DomainSizeConfig domconfig, BndCondProcPtr BndCond, BndCondProcPtr InnerBndCond, int numOfCoefficients, CoeffProcPtr coeffs[], int numOfUserFct, UserProcPtr userfct[]);
#endif
INT SetBoundaryCondition (LGM_DOMAIN *theDomain, BndCondProcPtr BndCond, BndCondProcPtr InnerBndCond);
INT SetDomainSize (LGM_DOMAIN *theDomain);

INT GetMaximumSurfaceID (LGM_DOMAIN *theDomain);
INT OuterBndSurfaceIDs (LGM_DOMAIN *theDomain, INT *sf); /* OS_CHANGED */
INT SurfaceIDsOfSubdomain (LGM_DOMAIN *theDomain, INT *sf, INT i); /* OS_CHANGED */


END_UGDIM_NAMESPACE

#endif