Nek5000
SEM for Incompressible NS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
findpts_el_2_test2.c
Go to the documentation of this file.
1 #include <stddef.h>
2 #include <stdlib.h>
3 #include <stdio.h>
4 #include <math.h>
5 #include <float.h>
6 #include <string.h>
7 #include "c99.h"
8 #include "types.h"
9 #include "name.h"
10 #include "fail.h"
11 #include "mem.h"
12 #include "tensor.h"
13 #include "poly.h"
14 #include "lob_bnd.h"
15 #include "obbox.h"
16 #include "findpts_el.h"
17 #include "rand_elt_test.h"
18 #include "rdtsc.h"
19 
20 #define USE_HW_COUNTER 0
21 
22 #if USE_HW_COUNTER
24 #endif
25 
26 #define REPEAT 10000
27 
28 #define NR 7
29 #define TNR 8
30 #define NS 8
31 #define TNS 9
32 #define TNTOT (TNR*TNS)
33 #define MR (4*NR)
34 #define MS (4*NS)
35 
36 static const unsigned nr[2] = {NR,NS};
37 
38 /* #define NPT 1 */
39 #define NPT 256
40 /* #define NPT TNR*TNS */
41 
42 #define TOL 1024*DBL_EPSILON
43 
44 static double zr[NR], zs[NS];
45 static double tzr[TNR], tzs[TNS];
46 static double Jr[NR*TNR],Js[NS*TNS];
47 static double elx[NR*NS], ely[NR*NS];
48 static const double *const elxy[2] = {elx,ely};
49 static double telx[2][TNR*TNS];
50 static double work[TNR*NS];
51 
52 int main()
53 {
54  int failure=0, unconv=0;
55  unsigned n,i,ie;
56 
57 #if USE_HW_COUNTER
58  unsigned long long tic,toc, tot=0;
59 #endif
60 
61  struct findpts_el_data_2 fd;
62  struct findpts_el_pt_2 *pt;
63  findpts_el_setup_2(&fd,nr,NPT);
64  pt = findpts_el_points_2(&fd);
65 
68 
69  for(i=0;i<TNR;++i) fd.lag[0](Jr+i*NR, fd.lag_data[0], NR, 0, tzr[i]);
70  for(i=0;i<TNS;++i) fd.lag[1](Js+i*NS, fd.lag_data[1], NS, 0, tzs[i]);
71  for(n=0;n<REPEAT;++n) {
72  rand_elt_2(elx,ely, zr,NR, zs,NS);
73  tensor_2t(telx[0], Jr,TNR,NR, Js,TNS,NS, elx, work);
74  tensor_2t(telx[1], Jr,TNR,NR, Js,TNS,NS, ely, work);
75 #if USE_HW_COUNTER
76  tic = getticks();
77 #endif
78  findpts_el_start_2(&fd, elxy);
79  for(i=0;i<TNTOT;) {
80  unsigned i0=i;
81  ie = i+NPT, ie = ie>TNTOT ? TNTOT : ie;
82  for(;i!=ie;++i) {
83  struct findpts_el_pt_2 *p = pt+(i-i0);
84  const double x=telx[0][i],y=telx[1][i];
85  p->x[0]=x,p->x[1]=y;
86  p->flags = 0;
87  }
88  findpts_el_2(&fd, ie-i0, 1024*DBL_EPSILON);
89 #if !(USE_HW_COUNTER)
90  for(i=i0;i!=ie;++i) {
91  struct findpts_el_pt_2 *p = pt+(i-i0);
92  const double r=tzr[i%TNR], s=tzs[i/TNR];
93  if((p->flags&(1u<<4))==0) ++unconv;
94  if(fabs(p->r[0]-r)+fabs(p->r[1]-s)>1024*DBL_EPSILON) {
95  printf("found (%g,%g) for (%g,%g) ; error (%g,%g)\n",
96  p->r[0],p->r[1], r,s, p->r[0]-r,p->r[1]-s);
97  printf("(%g,%g) for (%.15g,%.15g) ; dist2 = %g\n",
98  p->x[0],p->x[1],
99  telx[0][i],telx[1][i],p->dist2);
100  ++failure;
101  }
102  }
103 #endif
104  }
105 #if USE_HW_COUNTER
106  toc = getticks();
107  printf("element took %llu cycles\n",toc-tic);
108  tot+=toc-tic;
109 #endif
110  }
111 
112  findpts_el_free_2(&fd);
113 
114 #if !(USE_HW_COUNTER)
115  printf("%u failed points (out of %u)\n", failure, REPEAT*TNTOT);
116  printf("%u unconverged points\n", unconv);
117 #else
118  printf("average cycles = %g\n", tot/(double)REPEAT);
119 #endif
120 
121  return failure;
122 }
static double Jr[NR *TNR]
lagrange_fun * lag[2]
Definition: findpts_el.h:27
#define TNTOT
#define findpts_el_2
Definition: findpts_el.h:10
static double ely[NR *NS]
static double telx[2][TNR *TNS]
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 elxy[2]
n
Definition: xxt_test.m:73
static double zr[NR]
void rand_elt_2(double *x, double *y, const double *zr, unsigned nr, const double *zs, unsigned ns)
Definition: rand_elt_test.c:70
int main()
#define x
static void tensor_2t(double *out, const double *Jrt, uint nr, uint mr, const double *Jst, uint ns, uint ms, const double *u, double *work)
Definition: tensor.h:168
#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 REPEAT
#define findpts_el_free_2
Definition: findpts_el.h:9
#define NPT
static double tzs[TNS]
#define DEFINE_HW_COUNTER()
Definition: rdtsc.h:4
static double elx[NR *NS]
static double zs[NS]
static const unsigned nr[2]
for i
Definition: xxt_test.m:74
unsigned flags
Definition: findpts_el.h:15
static double Js[NS *TNS]
static double tzr[TNR]
double * lag_data[2]
Definition: findpts_el.h:28
#define TNR
static double work[TNR *NS]
#define lobatto_nodes
Definition: poly.c:15
establishes some macros to establish naming conventions
double r[2]
Definition: findpts_el.h:14
#define TNS
static double y[NR *NS *NT *N]
Definition: obbox_test.c:31