Actual source code: ex13.c
1: /*$Id: ex13.c,v 1.29 2001/08/07 21:30:54 bsmith Exp $*/
3: static char help[] = "Solves a variable Poisson problem with SLES.nn";
5: /*T
6: Concepts: SLES^basic sequential example
7: Concepts: SLES^Laplacian, 2d
8: Concepts: Laplacian, 2d
9: Processors: 1
10: T*/
12: /*
13: Include "petscsles.h" so that we can use SLES solvers. Note that this file
14: automatically includes:
15: petsc.h - base PETSc routines petscvec.h - vectors
16: petscsys.h - system routines petscmat.h - matrices
17: petscis.h - index sets petscksp.h - Krylov subspace methods
18: petscviewer.h - viewers petscpc.h - preconditioners
19: */
20: #include petscsles.h
22: /*
23: User-defined context that contains all the data structures used
24: in the linear solution process.
25: */
26: typedef struct {
27: Vec x,b; /* solution vector, right-hand-side vector */
28: Mat A; /* sparse matrix */
29: SLES sles; /* linear solver context */
30: int m,n; /* grid dimensions */
31: PetscScalar hx2,hy2; /* 1/(m+1)*(m+1) and 1/(n+1)*(n+1) */
32: } UserCtx;
34: extern int UserInitializeLinearSolver(int,int,UserCtx *);
35: extern int UserFinalizeLinearSolver(UserCtx *);
36: extern int UserDoLinearSolver(PetscScalar *,UserCtx *userctx,PetscScalar *b,PetscScalar *x);
38: int main(int argc,char **args)
39: {
40: UserCtx userctx;
41: int ierr,m = 6,n = 7,t,tmax = 2,i,I,j,N;
42: PetscScalar *userx,*rho,*solution,*userb,hx,hy,x,y;
43: PetscReal enorm;
45: /*
46: Initialize the PETSc libraries
47: */
48: PetscInitialize(&argc,&args,(char *)0,help);
50: /*
51: The next two lines are for testing only; these allow the user to
52: decide the grid size at runtime.
53: */
54: PetscOptionsGetInt(PETSC_NULL,"-m",&m,PETSC_NULL);
55: PetscOptionsGetInt(PETSC_NULL,"-n",&n,PETSC_NULL);
57: /*
58: serves as the preconditioning matt>,norm,its);
190: /*
191: Free work space. All PETSc objects should be destroyed when they
192: are no longer needed.
193: */
194: SLESDestroy(sles);
195: VecDestroy(u); VecDestroy(x);
196: VecDestroy(b); MatDestroy(A);
198: /*
199: Always call PetscFinalize() before exiting a program. This routine
200: - finalizes the PETSc libraries as well as MPI
201: - provides summary and diagnostic information if certain runtime
202: options are chosen (e.g., -log_summary).
203: */
204: PetscFinalize();
205: return 0;
206: }
./usr/share/doc/petsc2.1.3-doc/src/sles/examples/tutorials/ex13.c.html 0100644 0000000 0000000 00000065100 07475722272 024145 0 ustar root root Actual source code: ex13.c
1: /*$Id: ex13.c,v 1.29 2001/08/07 21:30:54 bsmith Exp $*/
3: static char help[] = "Solves a variable Poisson problem with SLES.nn";
5: /*T
6: Concepts: SLES^basic sequential example
7: Concepts: SLES^Laplacian, 2d
8: Concepts: Laplacian, 2d
9: Processors: 1
10: T*/
12: /*
13: Include "petscsles.h" so that we can use SLES solvers. Note that this file
14: automatically includes:
15: petsc.h - base PETSc routines petscvec.h - vectors
16: petscsys.h - system routines petscmat.h - matrices
17: petscis.h - index sets petscksp.h - Krylov subspace methods
18: petscviewer.h - viewers petscpc.h - preconditioners
19: */
20: #include petscsles.h
22: /*
23: User-defined context that contains all the data structures used
24: in the linear solution process.
25: */
26: typedef struct {
27: Vec x,b; /* solution vector, right-hand-side vector */
28: Mat A; /* sparse matrix */
29: SLES sles; /* linear solver context */
30: int m,n; /* grid dimensions */
31: PetscScalar hx2,hy2; /* 1/(m+1)*(m+1) and 1/(n+1)*(n+1) */
32: } UserCtx;
34: extern int UserInitializeLinearSolver(int,int,UserCtx *);
35: extern int UserFinalizeLinearSolver(UserCtx *);
36: extern int UserDoLinearSolver(PetscScalar *,UserCtx *userctx,PetscScalar *b,PetscScalar *x);
38: int main(int argc,char **args)
39: {
40: UserCtx userctx;
41: int ierr,m = 6,n = 7,t,tmax = 2,i,I,j,N;
42: PetscScalar *userx,*rho,*solution,*userb,hx,hy,x,y;
43: PetscReal enorm;
45: /*
46: Initialize the PETSc libraries
47: */
48: PetscInitialize(&argc,&args,(char *)0,help);
50: /*
51: The next two lines are for testing only; these allow the user to
52: decide the grid size at runtime.
53: */
54: PetscOptionsGetInt(PETSC_NULL,"-m",&m,PETSC_NULL);
55: PetscOptionsGetInt(PETSC_NULL,"-n",&n,PETSC_NULL);
57: /*
58: serves as the preconditioning matt>,norm,its);
190: /*
191: Free work space. All PETSc objects should be destroyed when they
192: are no longer needed.
193: */
194: SLESDestroy(sles);
195: VecDestroy(u); VecDestroy(x);
196: VecDestroy(b); MatDestroy(A);
198: /*
199: Always call PetscFinalize() before exiting a program. This routine
200: - finalizes the PETSc libraries as well as MPI
201: - provides summary and diagnostic information if certain runtime
202: options are chosen (e.g., -log_summary).
203: */
204: PetscFinalize();
205: return 0;
206: }
./usr/share/doc/petsc2.1.3-doc/src/sles/examples/tutorials/ex13.c.html 0100644 0000000 0000000 00000065100 07475722272 024145 0 ustar root root Actual source code: ex13.c
1: /*$Id: ex13.c,v 1.29 2001/08/07 21:30:54 bsmith Exp $*/
3: static char help[] = "Solves a variable Poisson problem with SLES.nn";
5: /*T
6: Concepts: SLES^basic sequential example
7: Concepts: SLES^Laplacian, 2d
8: Concepts: Laplacian, 2d
9: Processors: 1
10: T*/
12: /*
13: Include "petscsles.h" so that we can use SLES solvers. Note that this file
14: automatically includes:
15: petsc.h - base PETSc routines petscvec.h - vectors
16: petscsys.h - system routines petscmat.h - matrices
17: petscis.h - index sets petscksp.h - Krylov subspace methods
18: petscviewer.h - viewers petscpc.h - preconditioners
19: */
20: #include petscsles.h
22: /*
23: User-defined context that contains all the data structures used
24: in the linear solution process.
25: */
26: typedef struct {
27: Vec x,b; /* solution vector, right-hand-side vector */
28: Mat A; /* sparse matrix */
29: SLES sles; /* linear solver context */
30: int m,n; /* grid dimensions */
31: PetscScalar hx2,hy2; /* 1/(m+1)*(m+1) and 1/(n+1)*(n+1) */
32: } UserCtx;
34: extern int UserInitializeLinearSolver(int,int,UserCtx *);
35: extern int UserFinalizeLinearSolver(UserCtx *);
36: extern int UserDoLinearSolver(PetscScalar *,UserCtx *userctx,PetscScalar *b,PetscScalar *x);
38: int main(int argc,char **args)
39: {
40: UserCtx userctx;
41: int ierr,m = 6,n = 7,t,tmax = 2,i,I,j,N;
42: PetscScalar *userx,*rho,*solution,*userb,hx,hy,x,y;
43: PetscReal enorm;
45: /*
46: Initialize the PETSc libraries
47: */
48: PetscInitialize(&argc,&args,(char *)0,help);
50: /*
51: The next two lines are for testing only; these allow the user to
52: decide the grid size at runtime.
53: */
54: PetscOptionsGetInt(PETSC_NULL,"-m",&m,PETSC_NULL);
55: PetscOptionsGetInt(PETSC_NULL,"-n",&n,PETSC_NULL);
57: /*
58: serves as the preconditioning matt>,norm,its);
190: /*
191: Free work space. All PETSc objects should be destroyed when they
192: are no longer needed.
193: */
194: SLESDestroy(sles);
195: VecDestroy(u); VecDestroy(x);
196: VecDestroy(b); MatDestroy(A);
198: /*
199: Always call PetscFinalize() before exiting a program. This routine
200: - finalizes the PETSc libraries as well as MPI
201: - provides summary and diagnostic information if certain runtime
202: options are chosen (e.g., -log_summary).
203: */
204: PetscFinalize();
205: return 0;
206: }
./usr/share/doc/petsc2.1.3-doc/src/sles/examples/tutorials/ex13.c.html 0100644 0000000 0000000 00000065100 07475722272 024145 0 ustar root root Actual source code: ex13.c
1: /*$Id: ex13.c,v 1.29 2001/08/07 21:30:54 bsmith Exp $*/
3: static char help[] = "Solves a variable Poisson problem with SLES.nn";
5: /*T
6: Concepts: SLES^basic sequential example
7: Concepts: SLES^Laplacian, 2d
8: Concepts: Laplacian, 2d
9: Processors: 1
10: T*/
12: /*
13: Include "petscsles.h" so that we can use SLES solvers. Note that this file
14: automatically includes:
15: petsc.h - base PETSc routines petscvec.h - vectors
16: petscsys.h - system routines petscmat.h - matrices
17: petscis.h - index sets petscksp.h - Krylov subspace methods
18: petscviewer.h - viewers petscpc.h - preconditioners
19: */
20: #include petscsles.h
22: /*
23: User-defined context that contains all the data structures used
24: in the linear solution process.
25: */
26: typedef struct {
27: