Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/elmerice/UserFunctions/USF_CoV.F90
3204 views
1
!/*****************************************************************************/
2
! *
3
! * Elmer/Ice, a glaciological add-on to Elmer
4
! * http://elmerice.elmerfem.org
5
! *
6
! *
7
! * This program is free software; you can redistribute it and/or
8
! * modify it under the terms of the GNU General Public License
9
! * as published by the Free Software Foundation; either version 2
10
! * of the License, or (at your option) any later version.
11
! *
12
! * This program is distributed in the hope that it will be useful,
13
! * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
! * GNU General Public License for more details.
16
! *
17
! * You should have received a copy of the GNU General Public License
18
! * along with this program (in file fem/GPL-2); if not, write to the
19
! * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20
! * Boston, MA 02110-1301, USA.
21
! *
22
! *****************************************************************************/
23
! ******************************************************************************
24
! *
25
! * Authors: F. Gillet-Chaulet (IGE-Grenoble-FR)
26
! * R. Gladstone (Uni Lapland)
27
! * Email:
28
! * Web: http://elmerice.elmerfem.org
29
! *
30
! * Original Date:
31
! * Date modifications:
32
! *
33
! *
34
! *****************************************************************************
35
!#######################################################################
36
!#
37
!# A collection of USER FUNCTIONS to perform variable changes in
38
!inverse methods; i.e. beta=10^a or beta=a^2
39
!#
40
!#######################################################################
41
!# Compute VarOut=10^VarIn
42
FUNCTION TenPowerA(Model,nodenumber,VarIn) RESULT(VarOut)
43
USE DefUtils
44
implicit none
45
!-----------------
46
TYPE(Model_t) :: Model
47
INTEGER :: nodenumber
48
REAL(kind=dp) :: VarIn,VarOut
49
50
VarOut = 10._dp**(VarIn)
51
52
End FUNCTION TenPowerA
53
!# Compute DTenPowerA/DA=ln(10)*10^A
54
!# VarIn=A
55
FUNCTION TenPowerA_d(Model,nodenumber,VarIn) RESULT(VarOut)
56
USE DefUtils
57
implicit none
58
!-----------------
59
TYPE(Model_t) :: Model
60
INTEGER :: nodenumber
61
REAL(kind=dp) :: VarIn,VarOut
62
63
VarOut = (10.0**(VarIn))*log(10.0)
64
65
End FUNCTION TenPowerA_d
66
!# Compute DJDA from DJDB if B=10^A: DJDA=DJDB*ln(10)*10^A
67
!# DJDB=VarIn(1)
68
!# A=VarIn(2)
69
FUNCTION Derivative_TenPowerA(Model,nodenumber,VarIn) RESULT(VarOut)
70
USE DefUtils
71
implicit none
72
!-----------------
73
TYPE(Model_t) :: Model
74
INTEGER :: nodenumber
75
REAL(kind=dp) :: VarIn(2),VarOut
76
77
VarOut = VarIn(1)*(10.0**(VarIn(2)))*log(10.0)
78
79
End FUNCTION Derivative_TenPowerA
80
!# Compute VarOut=Log10(VarIn)
81
FUNCTION Log10A(Model,nodenumber,VarIn) RESULT(VarOut)
82
USE DefUtils
83
implicit none
84
!-----------------
85
TYPE(Model_t) :: Model
86
INTEGER :: nodenumber
87
REAL(kind=dp) :: VarIn,VarOut
88
89
VarOut=log10(VarIn)
90
91
End FUNCTION Log10A
92
!# Compute VarOut=VarIn*VarIn
93
FUNCTION Asquare(Model,nodenumber,VarIn) RESULT(VarOut)
94
USE DefUtils
95
implicit none
96
!-----------------
97
TYPE(Model_t) :: Model
98
INTEGER :: nodenumber
99
REAL(kind=dp) :: VarIn,VarOut
100
101
VarOut = VarIn*VarIn
102
END FUNCTION Asquare
103
!# Compute Compute dA^2/dA=2*A
104
!# VarIn=A
105
FUNCTION Asquare_d(Model,nodenumber,VarIn) RESULT(VarOut)
106
USE DefUtils
107
implicit none
108
!-----------------
109
TYPE(Model_t) :: Model
110
INTEGER :: nodenumber
111
REAL(kind=dp) :: VarIn,VarOut
112
113
VarOut = 2*VarIn
114
END FUNCTION Asquare_d
115
!# Compute DJDA from DJDB if B=A^2: DJDA=DJDB*2A
116
!# DJDB=VarIn(1)
117
!# A=VarIn(2)
118
FUNCTION Derivative_Asquare(Model,nodenumber,VarIn) RESULT(VarOut)
119
USE DefUtils
120
implicit none
121
!-----------------
122
TYPE(Model_t) :: Model
123
INTEGER :: nodenumber
124
REAL(kind=dp) :: VarIn(2),VarOut
125
126
VarOut = 2.0*VarIn(1)*VarIn(2)
127
128
End FUNCTION Derivative_Asquare
129
!# Compute VarOut=sqrt(VarIn)
130
FUNCTION SQRTA(Model,nodenumber,VarIn) RESULT(VarOut)
131
USE DefUtils
132
implicit none
133
!-----------------
134
TYPE(Model_t) :: Model
135
INTEGER :: nodenumber
136
REAL(kind=dp) :: VarIn,VarOut
137
138
VarOut = sqrt(VarIn)
139
END FUNCTION SQRTA
140
141
!# Compute VarOut=10^VarIn, masked
142
! Input arguments:
143
! ArgIn(1) VarIn, the variable upon which to operate
144
! ArgIn(2) mask, a mask variable, typically GroundedMask
145
FUNCTION TenPowerA_masked(Model,nodenumber,ArgIn) RESULT(VarOut)
146
USE DefUtils
147
IMPLICIT none
148
!-----------------
149
TYPE(Model_t) :: Model
150
INTEGER :: nodenumber
151
REAL(kind=dp) :: ArgIn(2),VarOut
152
153
REAL(kind=dp) :: VarIn,mask
154
155
VarIn = ArgIn(1)
156
mask = ArgIn(2)
157
158
! Note that the GroundedMask default behaviour is that -1.0 indicates
159
! floating shelves, 0.0 indicates grounding line nodes and 1.0
160
! indicates grounded nodes.
161
IF (mask.LE.0.0_dp) THEN
162
VarOut = 0.0_dp
163
ELSE
164
VarOut = 10._dp**(VarIn)
165
END IF
166
END FUNCTION TenPowerA_Masked
167
168
!# Compute DTenPowerA/DA=ln(10)*10^A, masked
169
! Input arguments:
170
! ArgIn(1) VarIn, the variable upon which to operate
171
! ArgIn(2) mask, a mask variable, typically GroundedMask
172
FUNCTION TenPowerA_d_Masked(Model,nodenumber,ArgIn) RESULT(VarOut)
173
USE DefUtils
174
implicit none
175
!-----------------
176
TYPE(Model_t) :: Model
177
INTEGER :: nodenumber
178
REAL(kind=dp) :: ArgIn(2),VarOut
179
180
REAL(kind=dp) :: VarIn,mask
181
182
VarIn = ArgIn(1)
183
mask = ArgIn(2)
184
185
IF (mask.LE.0.0_dp) THEN
186
VarOut = 0.0_dp
187
ELSE
188
VarOut = (10.0**(VarIn))*log(10.0)
189
END IF
190
191
END FUNCTION TenPowerA_d_Masked
192
193
!# This function can be used, for example, when computing
194
!# viscosity as a function of enhancement factor and an
195
!# initial guess.
196
FUNCTION Asquare_Scaled(Model,nodenumber,ArgIn) RESULT(VarOut)
197
USE DefUtils
198
implicit none
199
!-----------------
200
TYPE(Model_t) :: Model
201
INTEGER :: nodenumber
202
REAL(kind=dp) :: ArgIn(2),VarOut
203
204
REAL(kind=dp) :: VarIn
205
REAL(kind=dp) :: VarScale ! a scaling variable
206
207
VarIn = ArgIn(1)
208
VarScale = ArgIn(2)
209
210
VarOut = VarIn*VarIn*VarScale
211
212
END FUNCTION Asquare_Scaled
213
214
!# This function can be used, for example, for differentiating
215
!# by parts the viscosity, when computing viscosity as a
216
!# function of enhancement factor and an initial guess.
217
FUNCTION Asquare_d_Scaled(Model,nodenumber,ArgIn) RESULT(VarOut)
218
USE DefUtils
219
implicit none
220
!-----------------
221
TYPE(Model_t) :: Model
222
INTEGER :: nodenumber
223
REAL(kind=dp) :: ArgIn(2),VarOut
224
225
REAL(kind=dp) :: VarIn
226
REAL(kind=dp) :: VarScale ! a scaling variable
227
228
VarIn = ArgIn(1)
229
VarScale = ArgIn(2)
230
231
VarOut = 2*VarIn*VarScale
232
233
END FUNCTION Asquare_d_Scaled
234
235
236