Nek5000
SEM for Incompressible NS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
findpts_el_3_test.c
Go to the documentation of this file.
1 #include <stddef.h>
2 #include <stdlib.h>
3 #include <stdio.h>
4 #include <float.h>
5 #include <math.h>
6 #include <string.h>
7 #include "c99.h"
8 #include "name.h"
9 #include "types.h"
10 #include "fail.h"
11 #include "mem.h"
12 #include "poly.h"
13 #include "findpts_el.h"
14 
15 #define NR 14
16 #define NS 7
17 #define NT 25
18 
19 static const unsigned nr[3]={NR,NS,NT};
20 
21 static double elx[NR*NS*NT], ely[NR*NS*NT], elz[NR*NS*NT];
22 static const double *const elx3[3] = {elx,ely,elz};
23 
24 int main()
25 {
26  int pass=1;
27  unsigned i,j,k;
28  double zr[NR], zs[NS], zt[NT];
29  struct findpts_el_data_3 fd;
30  struct findpts_el_pt_3 *pt;
32  pt = findpts_el_points_3(&fd);
33 
34  lobatto_nodes(zr,NR);
35  lobatto_nodes(zs,NS);
36  lobatto_nodes(zt,NT);
37 
38  for(k=0;k<NT;++k) for(j=0;j<NS;++j) for(i=0;i<NR;++i)
39  elx[(k*NS+j)*NR+i] = zr[i],
40  ely[(k*NS+j)*NR+i] = zs[j],
41  elz[(k*NS+j)*NR+i] = zt[k];
42 
44 
45  for(k=0;k<NT;++k) for(j=0;j<NS;++j) for(i=0;i<NR;++i) {
46  struct findpts_el_pt_3 *p = pt + (k*NS+j)*NR+i;
47  p->x[0] = zr[i]*2, p->x[1] = zs[j]*2, p->x[2] = zt[k]*2;
48  p->r[0] = 0, p->r[1] = 0, p->r[2] = 0;
49  p->flags = 0;
50  }
51 
52  findpts_el_3(&fd, NR*NS*NT, 1024*DBL_EPSILON);
53  /* sort_points(pt,NR*NS*NT); */
54 
55  for(k=0;k<NT;++k) for(j=0;j<NS;++j) for(i=0;i<NR;++i) {
56  double r,s,t;
57  struct findpts_el_pt_3 *p = pt + (k*NS+j)*NR+i;
58  printf("x = (%g,%g,%g), r = (%g,%g,%g), flags = %x, dist2 = %g\n",
59  p->x[0],p->x[1],p->x[2], p->r[0],p->r[1],p->r[2],
60  p->flags, p->dist2);
61  #define CLAMP(x,r) \
62  do { double temp=r; x = temp<-1?-1:(temp>1?1:temp); } while(0)
63  CLAMP(r,zr[i]*2); CLAMP(s,zs[j]*2); CLAMP(t,zt[k]*2);
64  #undef CLAMP
65  if( fabs(r-p->r[0])+fabs(s-p->r[1])+fabs(t-p->r[2]) > 1024*DBL_EPSILON )
66  { printf("off by %g\n", fabs(r-p->r[0])+fabs(s-p->r[1])+fabs(t-p->r[2]));
67  pass=0; goto fin; }
68  }
69 
70 fin:
71 
72  findpts_el_free_3(&fd);
73 
74  printf("Tests %s\n", pass?"passed":"failed");
75 
76  return 0;
77 }
#define NT
double r[3]
Definition: findpts_el.h:69
static double zt[NT]
int main()
static const double *const elx3[3]
#define CLAMP(x, r)
#define findpts_el_3
Definition: findpts_el.h:65
static double zr[NR]
static struct findpts_el_pt_3 * findpts_el_points_3(struct findpts_el_data_3 *const fd)
Definition: findpts_el.h:116
static double elz[NR *NS *NT]
static double ely[NR *NS *NT]
static const unsigned nr[3]
p
Definition: xxt_test2.m:1
#define findpts_el_free_3
Definition: findpts_el.h:64
static double zs[NS]
#define findpts_el_setup_3
Definition: findpts_el.h:63
static void findpts_el_start_3(struct findpts_el_data_3 *const fd, const double *const x[3])
Definition: findpts_el.h:110
#define NS
for i
Definition: xxt_test.m:74
unsigned flags
Definition: findpts_el.h:70
static double elx[NR *NS *NT]
#define NR
double x[3]
Definition: findpts_el.h:69
#define lobatto_nodes
Definition: poly.c:15
establishes some macros to establish naming conventions