1 | /***************************************
2 | $Header$
3 |
4 | Common files for cahnhill.c and programs which use it (e.g. chts.c), based on
5 | PETSc SNES tutorial common8and9.h.
6 | ***************************************/
7 |
8 |
9 | #ifndef CAHNHILL_H
10 | #define CAHNHILL_H
11 |
12 | /*
13 | Include "petscda.h" so that we can use distributed arrays (DAs).
14 | Include "petscts.h" so that we can use TS and SNES solvers.
15 | Note that this file automatically includes:
16 | petsc.h - base PETSc routines petscvec.h - vectors
17 | petscsys.h - system routines petscmat.h - matrices
18 | petscis.h - index sets petscksp.h - Krylov subspace methods
19 | petscviewer.h - viewers petscpc.h - preconditioners
20 | petscsles.h - linear solvers petscsnes.h - nonlinear solvers
21 | */
22 | #include <petscts.h>
23 | #include <petscda.h>
24 |
25 | /*+
26 | User-defined application context for chts.c - contains data needed by the
27 | application-provided callbacks: ch_residual_vector_xd() (x is 2 or 3).
28 | +*/
29 |
30 | typedef struct {
31 | PetscTruth threedee; /* obvious :-) */
32 | PetscScalar kappa,epsilon,gamma,mparam; /* physical parameters */
33 | int mx,my,mz; /* discretization in x, y and z directions */
34 | int mc; /* components in unknown vector */
35 | int chvar; /* Which component in unks is Cahn-Hill */
36 | Vec localX,localF; /* ghosted local vector */
37 | DA da; /* distributed array data structure (unknowns) */
38 | int rank; /* processor rank */
39 | int size; /* number of processors */
40 | MPI_Comm comm; /* MPI communicator */
41 | int ilevel,nlevels; /* current/total levels through problem */
42 | Vec x_old; /* old solution vector */
43 | Mat J, alpha; /* Jacobian matrix, alpha values */
44 | DAPeriodicType period; /* Periodicity: DA_XPERIODIC etc */
45 | ISLocalToGlobalMapping isltog; /* mapping from local-to-global indices */
46 | PetscViewer theviewer; /* Viewer for timesteps */
47 | char **label; /* labels for components */
48 | PetscTruth print_grid; /* flag - 1 indicates printing grid info */
49 | PetscTruth print_vecs; /* flag - 1 indicates printing vectors */
50 | PetscTruth no_contours; /* flag - 1 indicates no contours */
51 | PetscTruth random; /* flag - 1 indicates random initial condition */
52 | PetscTruth save_data; /* flag - 1 indicates save each timestep */
53 | int load_data; /* Timestep to load for IC, -1 if no load */
54 | } AppCtx;
55 |
56 | /*
57 | Define macros to allow us to easily access the components of the PDE
58 | solution and nonlinear residual vectors. mc and chvar must be variables
59 | where these are used.
60 | */
61 | #define C(i) (mc*(i)+chvar)
62 | /* #define U(i) (mc*(i))
63 | #define V(i) (mc*(i)+1)
64 | #define Omega(i) (mc*(i)+2)
65 | #define Temp(i) (mc*(i)+3) */
66 |
67 | /*
68 | User-defined routines in cahnhill.c
69 | */
70 | extern int ch_residual_vector_2d (Vec,Vec,void*);
71 | extern int ch_residual_vector_3d (Vec,Vec,void*);
72 | extern int ch_jacobian_2d (Vec,Mat*,Mat*,MatStructure*,void*);
73 | extern int ch_jacobian_3d (Vec,Mat*,Mat*,MatStructure*,void*);
74 | extern int ch_jacobian_alpha_2d (AppCtx*);
75 | extern int ch_jacobian_alpha_3d (AppCtx*);
76 |
77 | #endif /* CAHNHILL_H */