Nek5000
SEM for Incompressible NS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
gs_test.c
Go to the documentation of this file.
1 #include <stddef.h>
2 #include <stdlib.h>
3 #include <stdio.h>
4 #include <string.h>
5 #include "c99.h"
6 #include "name.h"
7 #include "fail.h"
8 #include "types.h"
9 #include "comm.h"
10 #include "mem.h"
11 #include "gs_defs.h"
12 #include "gs.h"
13 
14 typedef double T;
15 const gs_dom dom = gs_double;
16 
17 static void test(const struct comm *comm)
18 {
19  struct gs_data *gsh;
20  const uint np = comm->np;
21  slong *id = tmalloc(slong,np+4);
22  T *v = tmalloc(T,np+4);
23  uint i;
24  id[0] = -(slong)(np+10+3*comm->id);
25  for(i=0;i<np;++i) id[i+1] = -(sint)(i+1);
26  id[np+1] = comm->id+1;
27  id[np+2] = comm->id+1;
28  id[np+3] = np-comm->id;
29  gsh = gs_setup(id,np+4,comm,0,gs_auto,1);
30  free(id);
31 
32  for(i=0;i<np+4;++i) v[i] = 1;
33  gs(v,dom,gs_add,0,gsh,0);
34  if(comm->id==0) for(i=0;i<np+4;++i) printf("%g\n",v[i]);
35  if(comm->id==0) printf("\n");
36  for(i=0;i<np+4;++i) v[i] = 1;
37  gs(v,dom,gs_add,1,gsh,0);
38  if(comm->id==0) for(i=0;i<np+4;++i) printf("%g\n",v[i]);
39 
40  gs_free(gsh);
41  free(v);
42 }
43 
44 int main(int narg, char *arg[])
45 {
46  comm_ext world; int np;
47  struct comm comm;
48 
49 #ifdef MPI
50  MPI_Init(&narg,&arg);
51  world = MPI_COMM_WORLD;
52  MPI_Comm_size(world,&np);
53 #else
54  world=0, np=1;
55 #endif
56 
57  comm_init(&comm,world);
58 
59  test(&comm);
60 
61  comm_free(&comm);
62 
63 #ifdef MPI
64  MPI_Finalize();
65 #endif
66 
67  return 0;
68 }
#define slong
Definition: types.h:74
Definition: gs.c:1086
#define uint
Definition: types.h:70
#define tmalloc(type, count)
Definition: mem.h:91
#define sint
Definition: types.h:69
double T
Definition: gs_test.c:14
#define gs
Definition: gs.c:26
int main(int narg, char *arg[])
Definition: gs_test.c:44
Definition: comm.h:85
#define gs_setup
Definition: gs.c:29
static void comm_free(struct comm *c)
Definition: comm.h:176
#define gs_free
Definition: gs.c:30
gs_dom
Definition: gs_defs.h:61
const gs_dom dom
Definition: gs_test.c:15
int comm_ext
Definition: comm.h:69
uint np
Definition: comm.h:86
for i
Definition: xxt_test.m:74
Definition: gs.c:1039
static void test(const struct comm *comm)
Definition: gs_test.c:17
Gather/Scatter Library interface.
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