Nek5000
SEM for Incompressible NS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
findpts_el_2_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 
18 static const unsigned nr[3]={NR,NS};
19 
20 static double elx[NR*NS], ely[NR*NS];
21 static const double *const elx2[2] = {elx,ely};
22 
23 int main()
24 {
25  int pass=1;
26  unsigned i,j;
27  double zr[NR], zs[NS];
28  struct findpts_el_data_2 fd;
29  struct findpts_el_pt_2 *pt;
31  pt = findpts_el_points_2(&fd);
32 
33  lobatto_nodes(zr,NR);
34  lobatto_nodes(zs,NS);
35 
36  for(j=0;j<NS;++j) for(i=0;i<NR;++i)
37  elx[j*NR+i] = zr[i],
38  ely[j*NR+i] = zs[j];
39 
41 
42  for(j=0;j<NS;++j) for(i=0;i<NR;++i) {
43  struct findpts_el_pt_2 *p = pt + j*NR+i;
44  p->x[0] = zr[i]*2, p->x[1] = zs[j]*2;
45  p->r[0] = 0, p->r[1] = 0;
46  p->flags = 0;
47  }
48 
49  findpts_el_2(&fd, NR*NS, 1024*DBL_EPSILON);
50 
51  for(j=0;j<NS;++j) for(i=0;i<NR;++i) {
52  double r,s;
53  struct findpts_el_pt_2 *p = pt + j*NR+i;
54  printf("x = (%g,%g), r = (%g,%g), flags = %x, dist2 = %g\n",
55  p->x[0],p->x[1], p->r[0],p->r[1],
56  p->flags, p->dist2);
57  #define CLAMP(x,r) \
58  do { double temp=r; x = temp<-1?-1:(temp>1?1:temp); } while(0)
59  CLAMP(r,zr[i]*2); CLAMP(s,zs[j]*2);
60  #undef CLAMP
61  if( fabs(r-p->r[0])+fabs(s-p->r[1]) > 1024*DBL_EPSILON )
62  { printf("off by %g\n", fabs(r-p->r[0])+fabs(s-p->r[1]));
63  pass=0; goto fin; }
64  }
65 
66 fin:
67 
68  findpts_el_free_2(&fd);
69 
70  printf("Tests %s\n", pass?"passed":"failed");
71 
72  return 0;
73 }
#define findpts_el_2
Definition: findpts_el.h:10
static void findpts_el_start_2(struct findpts_el_data_2 *const fd, const double *const x[2])
Definition: findpts_el.h:51
static const double *const elx2[2]
static double zr[NR]
#define NS
#define NR
static struct findpts_el_pt_2 * findpts_el_points_2(struct findpts_el_data_2 *const fd)
Definition: findpts_el.h:57
double x[2]
Definition: findpts_el.h:14
p
Definition: xxt_test2.m:1
#define findpts_el_setup_2
Definition: findpts_el.h:8
#define findpts_el_free_2
Definition: findpts_el.h:9
static double zs[NS]
#define CLAMP(x, r)
static double elx[NR *NS]
int main()
for i
Definition: xxt_test.m:74
unsigned flags
Definition: findpts_el.h:15
static const unsigned nr[3]
#define lobatto_nodes
Definition: poly.c:15
establishes some macros to establish naming conventions
double r[2]
Definition: findpts_el.h:14
static double ely[NR *NS]