Actual source code: input.c
2: static char help[] ="Allows inputing a 2d grid into a AO database.\n";
4: /*
6: */
8: #include petscao.h
9: #include petscbt.h
11: int main(int argc, char **argv)
12: {
13: int size, ierr;
14: AOData2dGrid agrid;
15: AOData aodata;
16: PetscViewer binary;
17: PetscDraw draw;
19: /* ---------------------------------------------------------------------
20: Initialize PETSc
21: ------------------------------------------------------------------------*/
23: PetscInitialize(&argc,&argv,(char *)0,help);
24: MPI_Comm_size(PETSC_COMM_WORLD,&size);
25: if (size > 1) {
26: SETERRQ(1,"Must run input program with exactly one processor");
27: }
29: /*---------------------------------------------------------------------
30: Open the graphics window
31: ------------------------------------------------------------------------*/
32: PetscDrawCreate(PETSC_COMM_WORLD,PETSC_NULL,"Input grid",PETSC_DECIDE,PETSC_DECIDE,PETSC_DECIDE,PETSC_DECIDE,&draw);
33: PetscDrawSetFromOptions(draw);
35: AOData2dGridCreate(&agrid);
37: /*
38: Get user to input the cell
39: */
40: AOData2dGridInput(agrid,draw);
42: /*
43: Flip vertex in cell to make sure they are all clockwise
44: */
45: AOData2dGridFlipCells(agrid);
46:
47: /*
48: Generate edge and neighor information
49: */
50: AOData2dGridComputeNeighbors(agrid);
52: AOData2dGridComputeVertexBoundary(agrid);
54: /*
55: Show the numbering of the vertex, cell and edge
56: */
57: AOData2dGridDraw(agrid,draw);
59: PetscDrawPause(draw);
61: /*
62: Create the database
63: */
64: AOData2dGridToAOData(agrid,&aodata);
66: /*
67: Save the grid database to a file
68: */
69: PetscViewerBinaryOpen(PETSC_COMM_WORLD,"gridfile",FILE_MODE_WRITE,&binary);
70: AODataView(aodata,binary);
71: PetscViewerDestroy(binary);
74: /*
75: Close the graphics window and cleanup
76: */
77: PetscDrawDestroy(draw);
79: AODataDestroy(aodata);
81: AOData2dGridDestroy(agrid);
83: PetscFinalize();
85: return 0;
86: }