1
- ! > @brief Explicit Model Module
2
- ! !
3
- ! ! This module contains the Explicit Model, which is a parent
4
- ! ! class for models that solve themselves. Explicit models are
5
- ! ! added to an Explicit Solution, which is simply a container
6
- ! ! that scrolls through a list of explicit models and calls
7
- ! ! methods in a prescribed sequence.
8
- ! !
9
- ! <
1
+ ! > @brief Models that solve themselves
10
2
module ExplicitModelModule
11
3
12
- use KindModule, only: I4B
4
+ use KindModule, only: I4B, DP
5
+ use ConstantsModule, only: LINELENGTH
13
6
use ListModule, only: ListType
14
7
use BaseModelModule, only: BaseModelType
15
8
use BaseDisModule, only: DisBaseType
9
+ use MemoryManagerModule, only: mem_allocate, mem_deallocate
16
10
17
11
implicit none
18
12
private
@@ -21,17 +15,27 @@ module ExplicitModelModule
21
15
AddExplicitModelToList, &
22
16
GetExplicitModelFromList
23
17
24
- ! > @brief Base type for explicit models.
18
+ ! > @brief Base type for models that solve themselves.
19
+ ! !
20
+ ! ! An explicit solution simply scrolls through a list of explicit
21
+ ! ! models and calls solution procedures in a prescribed sequence.
22
+ ! <
25
23
type, extends(BaseModelType) :: ExplicitModelType
26
- type (ListType), pointer :: bndlist = > null () ! < array of boundary packages for this model
24
+ character (len= LINELENGTH), pointer :: filename = > null () ! < input file name
25
+ integer (I4B), dimension (:), pointer , contiguous :: ibound = > null () ! < ibound array
26
+ type (ListType), pointer :: bndlist = > null () ! < array of boundary packages
27
27
class(DisBaseType), pointer :: dis = > null () ! < discretization object
28
28
contains
29
+ ! -- Overridden methods
29
30
procedure :: model_ad
30
31
procedure :: model_solve
31
32
procedure :: model_cq
32
33
procedure :: model_bd
33
34
procedure :: model_da
35
+ ! -- Utility methods
34
36
procedure :: allocate_scalars
37
+ procedure :: allocate_arrays
38
+ procedure :: set_idsoln
35
39
end type ExplicitModelType
36
40
37
41
contains
@@ -67,41 +71,59 @@ end subroutine model_bd
67
71
! > @ brief Deallocate the model
68
72
! <
69
73
subroutine model_da (this )
70
- ! -- modules
71
- use MemoryManagerModule, only: mem_deallocate
72
74
class(ExplicitModelType) :: this
73
- !
74
- ! -- derived types
75
+
76
+ ! -- deallocate scalars
77
+ deallocate (this% filename)
78
+
79
+ ! -- deallocate arrays
80
+ call mem_deallocate(this% ibound)
81
+
82
+ ! -- nullify pointers
83
+ if (associated (this% ibound)) &
84
+ call mem_deallocate(this% ibound, ' IBOUND' , this% memoryPath)
85
+
86
+ ! -- member derived types
75
87
call this% bndlist% Clear()
76
88
deallocate (this% bndlist)
77
- !
78
- ! -- BaseModelType
89
+
90
+ ! -- deallocate base tpye
79
91
call this% BaseModelType% model_da()
80
92
end subroutine model_da
81
93
82
- ! > @ brief Allocate model scalar variables
94
+ ! > @ brief Allocate scalar variables
83
95
! <
84
96
subroutine allocate_scalars (this , modelname )
85
- use MemoryManagerModule, only: mem_allocate
86
97
class(ExplicitModelType) :: this
87
98
character (len=* ), intent (in ) :: modelname
88
- !
89
- ! -- allocate basetype members
99
+
90
100
call this% BaseModelType% allocate_scalars(modelname)
91
- !
92
- ! -- allocate members from this type
93
101
allocate (this% bndlist)
102
+ allocate (this% filename)
103
+ this% filename = ' '
94
104
end subroutine allocate_scalars
95
105
106
+ ! > @brief Allocate array variables
107
+ ! <
108
+ subroutine allocate_arrays (this )
109
+ class(ExplicitModelType) :: this
110
+ integer (I4B) :: i
111
+
112
+ call mem_allocate(this% ibound, this% dis% nodes, ' IBOUND' , this% memoryPath)
113
+ do i = 1 , this% dis% nodes
114
+ this% ibound(i) = 1 ! active by default
115
+ end do
116
+ end subroutine allocate_arrays
117
+
96
118
! > @ brief Cast a generic object into an explicit model
97
119
! <
98
120
function CastAsExplicitModelClass (obj ) result(res)
99
121
class(* ), pointer , intent (inout ) :: obj
100
122
class(ExplicitModelType), pointer :: res
101
- !
123
+
102
124
res = > null ()
103
125
if (.not. associated (obj)) return
104
- !
126
+
105
127
select type (obj)
106
128
class is (ExplicitModelType)
107
129
res = > obj
@@ -116,7 +138,7 @@ subroutine AddExplicitModelToList(list, model)
116
138
class(ExplicitModelType), pointer , intent (inout ) :: model
117
139
! -- local
118
140
class(* ), pointer :: obj
119
- !
141
+
120
142
obj = > model
121
143
call list% Add(obj)
122
144
end subroutine AddExplicitModelToList
@@ -130,9 +152,17 @@ function GetExplicitModelFromList(list, idx) result(res)
130
152
class(ExplicitModelType), pointer :: res
131
153
! -- local
132
154
class(* ), pointer :: obj
133
- !
155
+
134
156
obj = > list% GetItem(idx)
135
157
res = > CastAsExplicitModelClass(obj)
136
158
end function GetExplicitModelFromList
137
159
160
+ ! > @brief Set the solution ID
161
+ ! <
162
+ subroutine set_idsoln (this , id )
163
+ class(ExplicitModelType) :: this
164
+ integer (I4B), intent (in ) :: id
165
+ this% idsoln = id
166
+ end subroutine set_idsoln
167
+
138
168
end module ExplicitModelModule
0 commit comments