Actual source code: mex35f90.F90

  1: !
  2:       module mex35f90
  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


 53:       end module mex35f90

 55: !
 56: !   These are interface definitions that allow PETSc routines to be
 57: !   called with "nice" names from Fortran90.
 58: !
 59: !   You should not need to change these, someday I hope to be able
 60: !   to no longer require them
 61: !
 62: #define USERMODULE mex35f90
 63: #define USERFIELD1 channelfield
 64: #define USERFIELD2 poolfield

 66:       module mex35f90interfaces
 67:           use mex35f90
 68:       Interface DAVecGetArrayF90
 69:         Subroutine DAVecGetArrayF90user1(Da, v,d1,ierr)
 70:           use USERMODULE
 71:           DA  da
 72:           Vec v
 73:           type(USERFIELD1), pointer :: d1(:)
 74:           PetscErrorCode ierr
 75:         End Subroutine
 76:       End Interface DAVecGetArrayF90

 78:       interface DAVecRestoreArrayF90
 79:         Subroutine DAVecRestoreArrayF90user1(Da, v,d1,ierr)
 80:           use USERMODULE
 81:           DA  da
 82:           Vec v
 83:           type(USERFIELD1), pointer :: d1(:)
 84:           PetscErrorCode ierr
 85:         End Subroutine
 86:       End Interface DAVecRestoreArrayF90

 88:       interface DMMGSetUser
 89:         Subroutine DMMGSetUser(dmmg, level,app,ierr)
 90:           use USERMODULE
 91:           DMMG dmmg
 92:           type(appctx), pointer :: app
 93:           PetscErrorCode ierr
 94:           integer level
 95:         End Subroutine
 96:       End Interface DMMGSetUser

 98:       interface DMMGGetUser
 99:         Subroutine DMMGGetUser(dmmg, app,ierr)
100:           use USERMODULE
101:           DM dmmg
102:           type(appctx), pointer :: app
103:           PetscErrorCode ierr
104:         End Subroutine
105:       End Interface DMMGGetUser

107:       Interface DMCompositeGetAccess
108:         Subroutine DMCompositeGetAccess4(dm, v,d1,d2,d3,d4,ierr)
109:           use USERMODULE
110:           DM  dm
111:           Vec v,d1,d3
112:           type(poolfield),pointer :: d2,d4
113:           PetscErrorCode ierr
114:         End Subroutine
115:       End Interface

117:       Interface DMCompositeRestoreAccess
118:         Subroutine DMCompositeRestoreAccess4(dm, v,d1,d2,d3,d4,ierr)
119:           use USERMODULE
120:           DMComposite  dm
121:           Vec v,d1,d3
122:           type(poolfield),pointer :: d2,d4
123:           PetscErrorCode ierr
124:         End Subroutine
125:       End Interface

127:       Interface DMCompositeGetLocalVectors
128:         Subroutine DMCompositeGetLocalVectors4(dm, d1,p1,d2,p2,ierr)
129:           use USERMODULE
130:           DMComposite  dm
131:           type(poolfield),pointer :: p1,p2
132:           Vec d1,d2
133:           PetscErrorCode ierr
134:         End Subroutine
135:       End Interface

137:       Interface DMCompositeRestoreLocalVectors
138:         Subroutine DMCompositeRestoreLocalVectors4(dm, d1,p1,d2,p2,ierr)
139:           use USERMODULE
140:           DMComposite  dm
141:           type(poolfield),pointer :: p1,p2
142:           Vec d1,d2
143:           PetscErrorCode ierr
144:         End Subroutine
145:       End Interface

147:       Interface DMCompositeScatter
148:         Subroutine DMCompositeScatter4(dm, v,d1,d2,d3,d4,ierr)
149:           use USERMODULE
150:           DM  dm
151:           Vec v,d1,d3
152:           type(poolfield) d2,d4
153:           PetscErrorCode ierr
154:         End Subroutine
155:       End Interface

157:       end module mex35f90interfaces