Actual source code: mex36f90.F90
1: !
2: module mex36f90
3: #include "finclude/petsc.h90"
5: ! Data structure used to contain information about the problem
6: ! You can add physical values etc here
8: type appctx
9: MPI_Comm :: comm = MPI_COMM_WORLD
10: integer :: nxc = 5 ! number of grid points in channel
11: integer :: np = 2,nc = 1 ! number of unknowns in pool and channel
12: double precision :: P0 ! atmospheric pressure
13: double precision :: rho ! fluid density
14: double precision :: grav ! gravity
15: double precision :: dhhpl0 ! initial height of hot pool level
16: double precision :: dhcpl0 ! initial height of cold pool level
17: double precision :: dhci ! height of core inlet
18: double precision :: dhco ! height of core outlet
19: double precision :: dhii ! height of IHX inlet
20: double precision :: dhio ! height of IHX outlet
21: double precision :: lenc ! core length
22: double precision :: leni ! IHX length
23: double precision :: dxc ! mesh spacing in core
24: double precision :: dxi ! mesh spacing in IHX
25: double precision :: dt ! time step size
26: integer :: nstep = 5 ! number of time steps
27: double precision :: hpvelo ! old time hot pool velocity
28: double precision :: hpvolo ! old time hot pool volume
29: double precision :: cpvelo ! old time cold pool velocity
30: double precision :: cpvolo ! old time cold pool volume
31: double precision :: hpvol0 ! initial hot pool volume
32: double precision :: cpvol0 ! initial cold pool volume
33: double precision :: ahp ! area of the hot pool
34: double precision :: acp ! area of the cold pool
35: double precision :: acore ! area of the core
36: double precision :: aihx ! area of the ihx
37: Vec :: xold ! old time state variables
38: end type appctx
40: ! The names of the fields in the pool and in the channel
41: ! These are accessed via variablename%p0, variablename%p1
42: ! change these to names appropriate for your physics
44: type poolfield
45: double precision :: vel,vol ! unknowns in pool
46: end type poolfield
48: type channelfield
49: double precision :: press ! unknowns in channel
50: end type channelfield
52: ! Stores all the local (ghosted) variables together
53: ! for easy access
55: type LocalForm
56: PetscInt np
57: DA da
58: type(poolfield), pointer :: HotPool,ColdPool
59: type(channelfield), pointer :: IHX(:),Core(:)
60: type(DALocalInfof90) dainfo
61: Vec vIHX,vCore
62: end type LocalForm
64: end module mex36f90
66: !
67: ! These are interface definitions that allow PETSc routines to be
68: ! called with "nice" names from Fortran90.
69: !
70: ! You should not need to change these, someday I hope to be able
71: ! to no longer require them
72: !
73: #define USERMODULE mex36f90
74: #define USERFIELD1 channelfield
75: #define USERFIELD2 poolfield
77: module mex36f90interfaces
78: use mex36f90
79: Interface DAVecGetArrayF90
80: Subroutine DAVecGetArrayF90user1(Da, v,d1,ierr)
81: use USERMODULE
82: DA da
83: Vec v
84: type(USERFIELD1), pointer :: d1(:)
85: PetscErrorCode ierr
86: End Subroutine
87: End Interface DAVecGetArrayF90
89: interface DAVecRestoreArrayF90
90: Subroutine DAVecRestoreArrayF90user1(Da, v,d1,ierr)
91: use USERMODULE
92: DA da
93: Vec v
94: type(USERFIELD1), pointer :: d1(:)
95: PetscErrorCode ierr
96: End Subroutine
97: End Interface DAVecRestoreArrayF90
99: interface DMMGSetUser
100: Subroutine DMMGSetUser(dmmg, level,app,ierr)
101: use USERMODULE
102: DMMG dmmg
103: type(appctx), pointer :: app
104: PetscErrorCode ierr
105: integer level
106: End Subroutine
107: End Interface DMMGSetUser
109: interface DMMGGetUser
110: Subroutine DMMGGetUser(dmmg, app,ierr)
111: use USERMODULE
112: DM dmmg
113: type(appctx), pointer :: app
114: PetscErrorCode ierr
115: End Subroutine
116: End Interface DMMGGetUser
118: Interface DMCompositeGetAccess
119: Subroutine DMCompositeGetAccess4(dm, v,d1,d2,d3,d4,ierr)
120: use USERMODULE
121: DM dm
122: Vec v,d1,d3
123: type(poolfield),pointer :: d2,d4
124: PetscErrorCode ierr
125: End Subroutine
126: End Interface
128: Interface DMCompositeRestoreAccess
129: Subroutine DMCompositeRestoreAccess4(dm, v,d1,d2,d3,d4,ierr)
130: use USERMODULE
131: DMComposite dm
132: Vec v,d1,d3
133: type(poolfield),pointer :: d2,d4
134: PetscErrorCode ierr
135: End Subroutine
136: End Interface
138: Interface DMCompositeGetLocalVectors
139: Subroutine DMCompositeGetLocalVectors4(dm, d1,p1,d2,p2,ierr)
140: use USERMODULE
141: DMComposite dm
142: type(poolfield),pointer :: p1,p2
143: Vec d1,d2
144: PetscErrorCode ierr
145: End Subroutine
146: End Interface
148: Interface DMCompositeRestoreLocalVectors
149: Subroutine DMCompositeRestoreLocalVectors4(dm, d1,p1,d2,p2,ierr)
150: use USERMODULE
151: DMComposite dm
152: type(poolfield),pointer :: p1,p2
153: Vec d1,d2
154: PetscErrorCode ierr
155: End Subroutine
156: End Interface
158: Interface DMCompositeScatter
159: Subroutine DMCompositeScatter4(dm, v,d1,d2,d3,d4,ierr)
160: use USERMODULE
161: DM dm
162: Vec v,d1,d3
163: type(poolfield) d2,d4
164: PetscErrorCode ierr
165: End Subroutine
166: End Interface
168: end module mex36f90interfaces