Nek5000
SEM for Incompressible NS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
xxt_test.c
Go to the documentation of this file.
1 #include <stddef.h>
2 #include <stdlib.h>
3 #include <stdio.h>
4 #include "name.h"
5 #include "fail.h"
6 #include "types.h"
7 #include "comm.h"
8 #include "crs.h"
9 
10 /*
11 
12  +---+---+ 1---7---4
13  | 0 | 1 | | | |
14  +---+---+ 3---8---6
15  | 0 | 2 | | | |
16  +---+---+ 2---9---5
17 
18 
19  element laplacian matrix:
20 
21  4 -1 -1 -2
22  -1 4 -2 -1
23  -1 -2 4 -1
24  -2 -1 -1 4
25 
26  assembled matrix:
27 
28 
29  4 -1 -1 -2
30  4 -1 -2 -1
31  -1 -1 8 -2 -2 -2
32  4 -1 -1 -2
33  4 -1 -2 -1
34  -1 -1 8 -2 -2 -2
35  -1 -2 -1 -2 8 -2
36  -2 -2 -2 -2 -2 -2 -2 16 -2
37  -1 -2 -1 -2 -2 8
38 
39 */
40 
41 const uint nx[3] = {8,4,4};
42 /*
43 const ulong x_id[3][8] = { {0,7,3,8, 3,8,2,9},
44  {7,4,8,6},
45  {8,6,9,5} };
46 */
47 const ulong x_id[3][8] = { {0,2,4,5, 4,5,7,8},
48  {2,3,5,6},
49  {5,6,8,9} };
50 
51  double bv[3][8][8] = { { {0,1/2.,0,0,0,0,0,0},
52  {0,0,0,0,0,0,0,0},
53  {0,0,1/2.,0,1/2.,0,0,0},
54  {0,0,0,1/4.,0,1/4.,0,0},
55  {0,0,0,0,0,0,0,0},
56  {0,0,0,0,0,0,1,0},
57  {0,0,0,0,0,0,0,1/2.},
58  {0,0,0,0,0,0,0,0} },
59 
60  { {1/2.,0,0,0},
61  {0,1,0,0},
62  {0,0,0,0},
63  {0,0,1/4.,0},
64  {0,0,0,1/2.},
65  {0,0,0,0},
66  {0,0,0,0},
67  {0,0,0,0} },
68 
69  { {0,0,0,0},
70  {0,0,0,0},
71  {0,0,0,0},
72  {1/4.,0,0,0},
73  {0,1/2.,0,0},
74  {0,0,0,0},
75  {0,0,1/2.,0},
76  {0,0,0,1} } };
77 
78 const uint nz[3] = {32,16,16};
79 const
80 uint Ai[3][32] = { {0,0,0,0, 1,1,1,1, 2,2,2,2, 3,3,3,3,
81  4,4,4,4, 5,5,5,5, 6,6,6,6, 7,7,7,7},
82  {0,0,0,0, 1,1,1,1, 2,2,2,2, 3,3,3,3},
83  {0,0,0,0, 1,1,1,1, 2,2,2,2, 3,3,3,3} };
84 const
85 uint Aj[3][32] = { {0,1,2,3, 0,1,2,3, 0,1,2,3, 0,1,2,3,
86  4,5,6,7, 4,5,6,7, 4,5,6,7, 4,5,6,7},
87  {0,1,2,3, 0,1,2,3, 0,1,2,3, 0,1,2,3},
88  {0,1,2,3, 0,1,2,3, 0,1,2,3, 0,1,2,3} };
89 const
90 double Ar[3][32] = { { 4,-1,-1,-2, -1,4,-2,-1, -1,-2,4,-1, -2,-1,-1,4,
91  4,-1,-1,-2, -1,4,-2,-1, -1,-2,4,-1, -2,-1,-1,4 },
92  { 4,-1,-1,-2, -1,4,-2,-1, -1,-2,4,-1, -2,-1,-1,4 },
93  { 4,-1,-1,-2, -1,4,-2,-1, -1,-2,4,-1, -2,-1,-1,4 } };
94 
95 int main(int narg, char* arg[])
96 {
97  struct crs_data *crs;
98  comm_ext world; int id,np;
99  struct comm comm;
100 #ifdef MPI
101  MPI_Init(&narg,&arg);
102  world = MPI_COMM_WORLD;
103  MPI_Comm_size(world,&np);
104 #else
105  world=0, np=1;
106 #endif
107 
108  comm_init(&comm,world);
109  if(np!=3) { puts("run with 3 procs"); exit(1); }
110  id = comm.id;
111 
112  crs = crs_setup(nx[id], &x_id[id][0],
113  nz[id], &Ai[id][0], &Aj[id][0], &Ar[id][0],
114  0, &comm);
115 
116  crs_stats(crs);
117 
118  if(1) {
119  uint i,j; double xv[8];
120  for(i=0;i<8;++i) {
121  crs_solve(xv,crs,&bv[id][i][0]);
122  printf("%d col %d:",id,i);
123  for(j=0;j<nx[id];++j) printf("\t%.4g",xv[j]);
124  printf("\n");
125  }
126  }
127 
128  crs_free(crs);
129  comm_free(&comm);
130 
131 #ifdef MPI
132  MPI_Finalize();
133 #endif
134  return 0;
135 }
136 
#define crs_stats
Definition: crs.h:10
#define uint
Definition: types.h:70
const double Ar[3][32]
Definition: xxt_test.c:90
double bv[3][8][8]
Definition: xxt_test.c:51
#define crs_solve
Definition: crs.h:9
Definition: comm.h:85
static void comm_free(struct comm *c)
Definition: comm.h:176
#define crs_free
Definition: crs.h:11
const ulong x_id[3][8]
Definition: xxt_test.c:47
const uint Ai[3][32]
Definition: xxt_test.c:80
int comm_ext
Definition: comm.h:69
#define ulong
Definition: types.h:75
for i
Definition: xxt_test.m:74
const uint Aj[3][32]
Definition: xxt_test.c:85
#define crs_setup
Definition: crs.h:8
int main(int narg, char *arg[])
Definition: xxt_test.c:95
static uint id
Definition: findpts_test.c:63
uint id
Definition: comm.h:86
establishes some macros to establish naming conventions
static uint np
Definition: findpts_test.c:63
static void comm_init(struct comm *c, comm_ext ce)
Definition: comm.h:133
const uint nz[3]
Definition: xxt_test.c:78
const uint nx[3]
Definition: xxt_test.c:41