-
Notifications
You must be signed in to change notification settings - Fork 0
/
buelerprofile.f90
217 lines (196 loc) · 7.57 KB
/
buelerprofile.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
!/*****************************************************************************/
! *
! * Elmer/Ice, a glaciological add-on to Elmer
! * http://elmerice.elmerfem.org
! *
! *
! * This program is free software; you can redistribute it and/or
! * modify it under the terms of the GNU General Public License
! * as published by the Free Software Foundation; either version 2
! * of the License, or (at your option) any later version.
! *
! * This program is distributed in the hope that it will be useful,
! * but WITHOUT ANY WARRANTY; without even the implied warranty of
! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! * GNU General Public License for more details.
! *
! * You should have received a copy of the GNU General Public License
! * along with this program (in file fem/GPL-2); if not, write to the
! * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
! * Boston, MA 02110-1301, USA.
! *
! *****************************************************************************/
! ******************************************************************************
FUNCTION Bueler_old ( Model, nodenumber, xcoord) RESULT(elevation)
USE Types
USE DefUtils
IMPLICIT NONE
TYPE(Model_t) :: Model
INTEGER :: nodenumber
REAL(KIND=dp) :: xcoord, elevation
REAL(KIND=dp), PARAMETER :: L = 361.25d03, H0 = 2.06d03, n = 3.0_dp, minh=100.0_dp
REAL(KIND=dp) :: T1, T2, H, R
R = xcoord
T1 = ( H0/((n - 1.0_dp)**(n/(2.0_dp*n + 2.0_dp))) )
T2 = (n + 1.0_dp)*(R/L) - n*((R/L)**((n + 1.0_dp)/n)) + &
n*((1.0_dp - (R/L))**((n + 1.0_dp)/n) ) - 1.0
H = T1 * ( T2**(n/(2.0*n + 2.0)) )
elevation = MAX(H,minh)
END FUNCTION Bueler_old
FUNCTION Bueler_t ( Model, nodenumber, xcoord) RESULT(elevation)
USE Types
USE DefUtils
IMPLICIT NONE
TYPE(Model_t) :: Model
INTEGER :: nodenumber
REAL(KIND=dp) :: xcoord, elevation
INTEGER :: i,nodesinelement
REAL(KIND=dp), PARAMETER :: n = 3.0_dp
REAL(KIND=dp) :: L = 361.25d03, H0 = 2.06d03, minh, T1, T2, H, R,&
offsetvelo, offsetdistance, offsettime
REAL(KIND=dp), ALLOCATABLE :: auxReal(:)
TYPE(ValueList_t), POINTER :: BC
LOGICAL :: GotIt, OffsetActive=.FALSE.
SAVE OffsetActive
BC => GetBC(Model % CurrentElement)
IF (.NOT.ASSOCIATED(BC)) THEN
CALL FATAL("Bueler_t","No boundary condition found for element")
ELSE
nodesinelement = GetElementNOFNodes()
ALLOCATE (auxReal(nodesinelement))
DO i=1, nodesinelement
IF (NodeNumber== Model % CurrentElement % NodeIndexes( i )) EXIT
END DO
! Get the external (probably water) pressure
! Use the convention Pext > 0 => Compression
!auxReal(1:nodesinelement) = GetReal( BC, 'External Pressure', GotIt )
R = xcoord
auxReal(1:nodesinelement) = GetReal( BC, 'Bueler Reference Length', GotIt )
IF (.NOT.GotIt) CALL FATAL("Bueler_t",">Bueler Reference Length< not found")
L = auxReal(i)
auxReal(1:nodesinelement) = GetReal( BC, 'Bueler Reference Height', GotIt )
IF (.NOT.GotIt) CALL FATAL("Bueler_t",">Bueler Reference Height< not found")
H0 = auxReal(i)
auxReal(1:nodesinelement) = GetReal( BC, 'Bueler Minimum Height', GotIt )
IF (.NOT.GotIt) THEN
CALL INFO("Bueler_t",">Bueler Minimum Height< not found. Defaulting to 10",Level=9)
minh=10.0_dp
ELSE
minh = auxReal(i)
END IF
auxReal(1:nodesinelement) = GetReal( BC, 'Bueler Offset Distance', GotIt )
IF (.NOT.GotIt) THEN
CALL INFO("Bueler_t"," >Bueler Offset Distance< not found. Defaulting to 0",Level=9)
offsetdistance = 0.0_dp
ELSE
offsetdistance = auxReal(i)
END IF
IF ((L >= xcoord) .AND. (H0 > minh)) THEN
offsettime = GetConstReal( BC, 'Bueler Offset Time', GotIt )
IF (.NOT.GotIt) THEN
CALL INFO("Bueler_t",">Bueler Offset Time< not found. Defaulting to 0",Level=9)
OffsetActive = .FALSE.
ELSE
WRITE (Message, *) "Bueler_t"," > Bueler Offset Time< set to",offsettime
CALL INFO("Bueler_t",Message,Level=9)
OffsetActive = .TRUE.
END IF
! offsetdistance = offsetvelo * GetTimestepSize()
! PRINT *,offsetdistance
IF (OffsetActive) THEN
IF(GetTime() <= offsettime) THEN
elevation = minh
ELSE
OffsetActive = .FALSE.
END IF
END IF
IF (.NOT.OffsetActive) THEN
T1 = ( H0/((n - 1.0_dp)**(n/(2.0_dp*n + 2.0_dp))) )
T2 = (n + 1.0_dp)*(R/L) - n*((R/L)**((n + 1.0_dp)/n)) + &
n*((1.0_dp - (R/L))**((n + 1.0_dp)/n) ) - 1.0_dp
H = T1 * ( T2**(n/(2.0_dp*n + 2.0_dp)) )
IF (H > H0) THEN
PRINT *, "H",H,">",H0,"dz",offsetdistance,R,L,n
H = H0
END IF
elevation = MAX(H,minh) + offsetdistance
END IF
ELSE
elevation = minh + offsetdistance
END IF
DEALLOCATE(auxReal)
END IF
END FUNCTION Bueler_t
FUNCTION Bueler_smb ( Model, nodenumber, xcoord) RESULT(smb)
USE Types
USE DefUtils
IMPLICIT NONE
TYPE(Model_t) :: Model
INTEGER :: nodenumber
REAL(KIND=dp) :: xcoord, smb
INTEGER :: i,nodesinelement
REAL(KIND=dp), PARAMETER :: n = 3.0_dp
REAL(KIND=dp) :: L = 361.25d03, H0 = 2.06d03, minh, T1, T2, H, R, A0, &
offsetvelo, offsetdistance, offsettime, aux1, aux2, alpha, auxn, relx
REAL(KIND=dp), ALLOCATABLE :: auxReal(:)
TYPE(ValueList_t), POINTER :: BC
LOGICAL :: GotIt, OffsetActive=.FALSE.
SAVE OffsetActive
BC => GetBC(Model % CurrentElement)
IF (.NOT.ASSOCIATED(BC)) THEN
CALL FATAL("Bueler_smb","No boundary condition found for element")
ELSE
nodesinelement = GetElementNOFNodes()
ALLOCATE (auxReal(nodesinelement))
DO i=1, nodesinelement
IF (NodeNumber== Model % CurrentElement % NodeIndexes( i )) EXIT
END DO
! Get the external (probably water) pressure
! Use the convention Pext > 0 => Compression
!auxReal(1:nodesinelement) = GetReal( BC, 'External Pressure', GotIt )
R = xcoord
auxReal(1:nodesinelement) = GetReal( BC, 'Bueler Reference Length', GotIt )
IF (.NOT.GotIt) CALL FATAL("Bueler_smb",">Bueler Reference Length< not found")
L = auxReal(i)
auxReal(1:nodesinelement) = GetReal( BC, 'Bueler Reference Height', GotIt )
IF (.NOT.GotIt) CALL FATAL("Bueler_smb",">Bueler Reference Height< not found")
H0 = auxReal(i)
auxReal(1:nodesinelement) = GetReal( BC, 'Bueler Minimum Height', GotIt )
IF (.NOT.GotIt) THEN
CALL INFO("Bueler_smb",">Bueler Minimum Height< not found. Defaulting to 10",Level=9)
minh=10.0_dp
ELSE
minh = auxReal(i)
END IF
auxReal(1:nodesinelement) = GetReal( BC, 'Bueler Offset Distance', GotIt )
IF (.NOT.GotIt) THEN
CALL INFO("Bueler_smb",">Bueler Offset Distance< not found. Defaulting to 0",Level=9)
offsetdistance = 0.0_dp
ELSE
offsetdistance = auxReal(i)
END IF
auxReal(1:nodesinelement) = GetReal( BC, 'Bueler Arrhenius Factor' , GotIt )
IF (.NOT.GotIt) THEN
CALL FATAL("Bueler_smb",">Bueler Arrhenius Factor< not found")
ELSE
A0 = 2.0_dp*auxReal(i) * ((917.0_dp*9.81_dp)**n) / (n +2)
END IF
DEALLOCATE(auxReal)
END IF
aux1 = (2.0_dp*L*(n - 1.0_dp)/n)**n
alpha = (H0**(2.0_dp*n + 2.0_dp)) * A0/aux1
relx = xcoord/L
IF (relx <= 0.0) THEN
smb = 0.0_dp
ELSE
IF (relx >= 0.99_dp) relx = 0.99
auxn = 1.0_dp/n
aux1 = ((relx**auxn) + ((1.0_dp - relx)**auxn) - 1.0_dp)**(n - 1.0_dp)
auxn = (1.0_dp/n) - 1.0_dp
aux2 = (relx**auxn) - (1.0_dp - relx)**auxn
smb = (alpha/L) * aux1 * aux2!/(365.25 * 24.0 * 3600.0)
!PRINT *, relx, smb, aux1 * aux2, alpha
!PRINT *, alpha, aux1, aux2
!PRINT *,"SMB:",relx, smb
END IF
END FUNCTION Bueler_smb