Nek5000
SEM for Incompressible NS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
lob_bnd.h
Go to the documentation of this file.
1 #ifndef LOB_BND_H
2 #define LOB_BND_H
3 
4 #if !defined(TYPES_H) || !defined(NAME_H)
5 #warning "lob_bnd.h" requires "types.h" and "name.h"
6 #endif
7 
8 #define lob_bnd_setup PREFIXED_NAME(lob_bnd_setup)
9 #define lob_bnd_lin_1 PREFIXED_NAME(lob_bnd_lin_1)
10 #define lob_bnd_lin_2 PREFIXED_NAME(lob_bnd_lin_2)
11 #define lob_bnd_lin_3 PREFIXED_NAME(lob_bnd_lin_3)
12 #define lob_bnd_1 PREFIXED_NAME(lob_bnd_1 )
13 #define lob_bnd_2 PREFIXED_NAME(lob_bnd_2 )
14 #define lob_bnd_3 PREFIXED_NAME(lob_bnd_3 )
15 
16 /*--------------------------------------------------------------------------
17  Bounds for Polynomials on [-1,1]^d
18  given in the Lagrangian basis on
19  Gauss-Lobatto-Legendre quadrature nodes
20 
21  The main parameters are the number of GLL nodes in each dimension
22  unsigned nr = ..., ns = ..., nt = ...;
23 
24  The number of points in the constructed piecewise (tri-,bi-)linear bounds
25  is a parameter; more points give tighter bounds, and we expect m>n.
26 
27  unsigned mr = 4*nr, ms = 4*ns, mt = 4*nt;
28 
29  The necessary setup is accomplished via:
30  double *data_r = tmalloc(double, lob_bnd_size(nr,mr));
31  double *data_s = tmalloc(double, lob_bnd_size(ns,ms));
32  double *data_t = tmalloc(double, lob_bnd_size(nt,mt));
33  lob_bnd_setup(data_r, nr,mr);
34  lob_bnd_setup(data_s, ns,ms);
35  lob_bnd_setup(data_t, nt,mt);
36 
37  Bounds may then be computed via:
38  double work1r[2*mr], work1s[2*ms];
39  double work2[2*mr*(ns+ms+1)];
40  double work3[2*mr*ms*(nt+mt+1)];
41  double ur[nr], us[ns]; // 1-d polynomials on the zr[] and zs[] nodes
42  double u2[ns][nr]; // 2-d polynomial on zr[] (x) zs[]
43  double u3[nt][ns][nr]; // 3-d polynomial on zr[] (x) zs[] (x) zt[]
44  struct dbl_range bound;
45 
46  bound = lob_bnd_1(data_r,nr,mr, ur, work1r); // compute bounds on ur
47  bound = lob_bnd_1(data_s,ns,ms, us, work1s); // compute bounds on us
48  bound = lob_bnd_2(data_r,nr,mr, data_s,ns,ms,
49  (const double*)&u2[0][0], work2); // compute bounds on u2
50  bound = lob_bnd_3(data_r,nr,mr, data_s,ns,ms, data_t,nt,mt,
51  (const double*)&u3[0][0], work3); // compute bounds on u3
52 
53  free(data_r), free(data_s), free(data_t);
54 
55  The functions lob_bnd_lin_d compute the piecewise d-linear bounds.
56  Nodes for these are Chebyshev-Lobatto:
57  h[0] = -1, h[m-1] = 1;
58  for(j=1;j<m-1;++j) h[j] = cos((m-1-j)*PI/(m-1));
59  The functions lob_bnd_d simply call these and return the min and max
60  over all nodes.
61 
62  --------------------------------------------------------------------------*/
63 
64 static unsigned lob_bnd_size(unsigned n, unsigned m)
65 { return m+3*n*(2*m+1); }
66 
67 void lob_bnd_setup(double *restrict data, unsigned n, unsigned m);
68 
69 void lob_bnd_lin_1(double *restrict b,
70  const double *restrict lob_bnd_data, unsigned n, unsigned m,
71  const double *restrict u, uint un);
72 
73 /* work holds 2*mr + 2*ns*mr doubles */
74 void lob_bnd_lin_2(
75  double *restrict b,
76  const double *lob_bnd_data_r, unsigned nr, unsigned mr,
77  const double *lob_bnd_data_s, unsigned ns, unsigned ms,
78  const double *restrict u, uint un, double *restrict work);
79 
80 /* work holds 2*mr*ms + 2*nt*ms*mr doubles */
81 void lob_bnd_lin_3(
82  double *restrict b,
83  const double *lob_bnd_data_r, unsigned nr, unsigned mr,
84  const double *lob_bnd_data_s, unsigned ns, unsigned ms,
85  const double *lob_bnd_data_t, unsigned nt, unsigned mt,
86  const double *restrict u, uint un, double *restrict work);
87 
88 struct dbl_range { double min, max; };
89 
90 /* work holds 2*m doubles */
91 struct dbl_range lob_bnd_1(
92  const double *restrict lob_bnd_data, unsigned n, unsigned m,
93  const double *restrict u, double *restrict work);
94 
95 /* work holds 2*mr*ms + 2*mr + 2*mr*ns
96  =2*mr*(ns+ms+1) doubles */
97 struct dbl_range lob_bnd_2(
98  const double *lob_bnd_data_r, unsigned nr, unsigned mr,
99  const double *lob_bnd_data_s, unsigned ns, unsigned ms,
100  const double *restrict u, double *restrict work);
101 
102 /* work holds 2*mr*ms*mt + 2*mr*ms + 2*nt*ms*mr
103  =2*mr*ms*(nt+mt+1) doubles */
104 struct dbl_range lob_bnd_3(
105  const double *lob_bnd_data_r, unsigned nr, unsigned mr,
106  const double *lob_bnd_data_s, unsigned ns, unsigned ms,
107  const double *lob_bnd_data_t, unsigned nt, unsigned mt,
108  const double *restrict u, double *restrict work);
109 
110 #endif
111 
#define uint
Definition: types.h:70
#define lob_bnd_1
Definition: lob_bnd.h:12
static const unsigned mr[D]
#define lob_bnd_setup
Definition: lob_bnd.h:8
#define lob_bnd_lin_3
Definition: lob_bnd.h:11
n
Definition: xxt_test.m:73
double max
Definition: lob_bnd.c:21
ns
Definition: xxt_test.m:43
#define lob_bnd_lin_1
Definition: lob_bnd.h:9
#define restrict
Definition: c99.h:11
static unsigned lob_bnd_size(unsigned n, unsigned m)
Definition: lob_bnd.h:64
double min
Definition: lob_bnd.c:21
static const unsigned nr[3]
#define lob_bnd_3
Definition: lob_bnd.h:14
#define lob_bnd_lin_2
Definition: lob_bnd.h:10
#define lob_bnd_2
Definition: lob_bnd.h:13
static double work[TNR *NS]