Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/elmerice/UserFunctions/USF_WaterTransfer.F90
3196 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: Basile de Fleurian
26
! * Email: [email protected]; [email protected]
27
! * Web: http://elmerice.elmerfem.org
28
! *
29
! * Original Date: 02 Jully 2013
30
!------------------------------------------------------------------------------
31
! Transfer of the water between two drainage systems,transfer is computed to go
32
! from the EPL layer to the sediment one giving positive value of the transfer
33
! when water flows in this way and negative in the other;
34
! This function requires two hydrological solvers (inefficient and efficient)
35
!-----------------------------------------------------------------------------
36
37
FUNCTION EPLToIDS(Model,nodenumber,x) RESULT(Transfer)
38
USE DefUtils
39
USE types
40
USE CoordinateSystems
41
USE SolverUtils
42
USE ElementDescription
43
44
IMPLICIT NONE
45
!-----------------------------------------------
46
! External variables
47
!-----------------------------------------------
48
TYPE(Model_t) :: Model
49
INTEGER :: nodenumber
50
REAL(KIND=dp) :: Transfer, x
51
!-----------------------------------------------
52
! Local variables
53
!-----------------------------------------------
54
55
TYPE(Element_t),POINTER :: Element
56
TYPE(Variable_t), POINTER :: IDSHead, EPLHead, PipingMask
57
TYPE(ValueList_t), POINTER :: Constants, Material, BodyForce
58
59
REAL(KIND=dp), POINTER :: IDSValues(:), EPLValues(:), MaskValues(:)
60
REAL(KIND=dp), ALLOCATABLE :: g(:,:)
61
REAL(KIND=dp), ALLOCATABLE :: Density(:), Gravity(:), &
62
EPLComp(:), EPLPorosity(:), EPLThick(:), EPLStoring(:),&
63
IDSComp(:), IDSPorosity(:), IDSThick(:), IDSStoring(:),&
64
IDSTrans(:),UpperLimit(:), LeakFact(:)
65
REAL(KIND=dp)::WatComp
66
67
INTEGER, POINTER :: IDSPerm(:), EPLPerm(:), MaskPerm(:)
68
INTEGER :: material_id, bf_id
69
INTEGER :: N, istat, i, k
70
71
LOGICAL :: FirstTime=.TRUE., &
72
Found= .FALSE., &
73
AllocationsDone= .FALSE., &
74
UnFoundFatal=.TRUE.
75
76
SAVE g, &
77
Density, &
78
Gravity, &
79
EPLComp, &
80
EPLPorosity, &
81
EPLThick, &
82
EPLStoring, &
83
IDSComp, &
84
IDSPorosity, &
85
IDSThick, &
86
IDSStoring, &
87
IDSTrans, &
88
UpperLimit, &
89
LeakFact, &
90
FirstTime, &
91
Found, &
92
AllocationsDone
93
94
IF (FirstTime)THEN
95
FirstTime = .FALSE.
96
IF ( AllocationsDone ) THEN
97
DEALLOCATE(g, &
98
Density, &
99
Gravity, &
100
EPLComp, &
101
EPLPorosity, &
102
EPLThick, &
103
EPLStoring, &
104
IDSComp, &
105
IDSPorosity, &
106
IDSThick, &
107
IDSStoring, &
108
IDSTrans, &
109
UpperLimit, &
110
LeakFact)
111
112
END IF
113
114
N = Model % MaxElementNodes
115
ALLOCATE(g( 3,N ), &
116
Density( N ), &
117
Gravity( N ), &
118
EPLComp( N ), &
119
EPLPorosity( N ), &
120
EPLThick( N ), &
121
EPLStoring( N ), &
122
IDSComp( N ), &
123
IDSPorosity( N ), &
124
IDSThick( N ), &
125
IDSStoring( N ), &
126
IDSTrans( N ), &
127
UpperLimit( N ), &
128
LeakFact( N ), &
129
STAT=istat)
130
131
IF ( istat /= 0 ) THEN
132
CALL FATAL( 'USF_WaterTransfer', 'Memory allocation error' )
133
ELSE
134
WRITE(Message,'(a)') 'Memory allocation done'
135
CALL INFO("WaterTransfer",Message,Level=4)
136
END IF
137
AllocationsDone = .TRUE.
138
END IF
139
140
141
!Get the Mask
142
!------------
143
PipingMask => VariableGet( Model % Variables, 'Open EPL',UnFoundFatal=UnFoundFatal)
144
MaskPerm => PipingMask % Perm
145
MaskValues => PipingMask % Values
146
147
IF(MaskValues(MaskPerm(nodenumber)).GE.0.0)THEN
148
!EPL is not active, no transfer
149
Transfer = 0.0
150
ELSE
151
152
!Get the EPL and IDS water Heads
153
!-------------------------------------
154
EPLHead => VariableGet( Model % Variables, 'EPLHead',UnFoundFatal=UnFoundFatal)
155
EPLPerm => EPLHead % Perm
156
EPLValues => EPLHead % Values
157
158
IDSHead => VariableGet( Model % Variables, 'IDSHead',UnFoundFatal=UnFoundFatal)
159
IDSPerm => IDSHead % Perm
160
IDSValues => IDSHead % Values
161
162
!Get Parameters needed to compute the storing coefficient
163
!-------------------------------------------------------
164
Element => Model % CurrentElement
165
Material => GetMaterial(Element)
166
N = GetElementNOFNodes(Element)
167
Constants => GetConstants()
168
BodyForce => GetBodyForce()
169
170
IF (.NOT.ASSOCIATED(Material)) THEN
171
WRITE (Message,'(A)') 'No Material found for boundary element no. '
172
CALL FATAL("WaterTransfer",Message)
173
ELSE
174
material_id = GetMaterialId( Element, Found)
175
IF(.NOT.Found) THEN
176
WRITE (Message,'(A)') 'No Material ID found for boundary element no. '
177
CALL FATAL("WaterTransfer",Message)
178
END IF
179
END IF
180
181
!Generic parameters
182
!------------------
183
WatComp = GetConstReal( Constants, &
184
'Water Compressibility', Found)
185
IF ( .NOT.Found ) THEN
186
WatComp = 5.04e-4
187
END IF
188
189
Density(1:N) = ListGetReal( Material, 'Water Density', N, Element % NodeIndexes, Found,&
190
UnfoundFatal=UnFoundFatal)
191
!Previous default value: Density = 1.0055e-18
192
193
IF ( ASSOCIATED( BodyForce ) ) THEN
194
bf_id = GetBodyForceId()
195
g = 0.0_dp
196
g(1,1:N) = GetConstReal( Model % BodyForces(bf_id) % Values, 'Flow BodyForce 1',Found)
197
g(2,1:N) = GetConstReal( Model % BodyForces(bf_id) % Values, 'Flow BodyForce 2',Found)
198
g(3,1:N) = GetConstReal( Model % BodyForces(bf_id) % Values, 'Flow BodyForce 3',Found)
199
Gravity(1:N) = SQRT(SUM(g**2.0/N))
200
END IF
201
202
!EPL Parameters
203
!--------------
204
EPLComp(1:N) = listGetReal( Material,'EPL Compressibility', N, Element % NodeIndexes, Found,&
205
UnfoundFatal=UnFoundFatal)
206
!Previous default value: EPLComp(1:N) = 1.0D-2
207
208
EPLPorosity(1:N) = listGetReal( Material,'EPL Porosity', N, Element % NodeIndexes, Found,&
209
UnfoundFatal=UnFoundFatal)
210
!Previous default value: EPLPorosity(1:N) = 0.4D00
211
212
EPLThick(1:N) = listGetReal( Material,'EPL Thickness', N, Element % NodeIndexes, Found,&
213
UnfoundFatal=UnFoundFatal)
214
!Previous default value: EPLThick(1:N) = 10.0D00
215
216
!Inefficient Drainage System Parameters
217
!--------------------------------------
218
IDSComp(1:N) = listGetReal( Material,'IDS Compressibility', N, Element % NodeIndexes, Found,&
219
UnfoundFatal=UnFoundFatal)
220
!Previous default value: IDSComp(1:N) = 1.0D-2
221
222
IDSPorosity(1:N) = listGetReal( Material,'IDS Porosity', N, Element % NodeIndexes, Found,&
223
UnfoundFatal=UnFoundFatal)
224
!Previous default value: IDSPorosity(1:N) = 0.4D00
225
226
IDSThick(1:N) = listGetReal( Material,'IDS Thickness', N, Element % NodeIndexes, Found,&
227
UnfoundFatal=UnFoundFatal)
228
!Previous default value: IDSThick(1:N) = 10.0D00
229
230
!Computing the Storing coefficient of the EPL
231
!-------------------------------------------
232
EPLStoring(1:N) = EPLThick(1:N) * &
233
Gravity(1:N) * EPLPorosity(1:N) * Density(1:N) * &
234
(WatComp + EPLComp(1:N)/EPLPorosity(1:N))
235
236
!Computing the Storing coefficient of the Inefficient Drainage System
237
!-------------------------------------------------------------------
238
IDSStoring(1:N) = IDSThick(1:N) * &
239
Gravity(1:N) * IDSPorosity(1:N) * Density(1:N) * &
240
(WatComp + IDSComp(1:N)/IDSPorosity(1:N))
241
242
!Get Inefficient Drainage System Transmitivity
243
!---------------------------------------------
244
IDSTrans(1:N) = listGetReal( Material,'IDS Transmitivity', N, Element % NodeIndexes, Found,&
245
UnfoundFatal=UnFoundFatal)
246
!Previous default value: IDSTrans(1:N) = 1.5D04
247
248
!Get Inefficient Drainage System Upper Limit
249
!-------------------------------------------
250
UpperLimit(1:n) = ListGetReal(Material,'IDSHead Upper Limit',&
251
N, Element % NodeIndexes, Found)
252
IF (.NOT. Found) THEN
253
WRITE(Message,'(a)') 'No upper limit of solution for element no.'
254
CALL INFO("WaterTransfer", Message, level=10)
255
END IF
256
257
!Getting parameters needed by the Transfer Equation
258
!--------------------------------------------------
259
LeakFact(1:n) = ListGetReal( Material, 'Leakage Factor', N, Element % NodeIndexes, Found,&
260
UnfoundFatal=UnFoundFatal)
261
!Previous default value: LeakFact(1:N) = 50.0D00
262
263
!Computation of the Transfer
264
!---------------------------
265
DO i=1,N
266
k = Element % NodeIndexes(i)
267
IF(nodenumber.EQ. k)THEN
268
IF((IDSValues(IDSPerm(k)).GE.UpperLimit(i)).AND. &
269
(EPLValues(EPLPerm(k)).GT.IDSValues(IDSPerm(k))))THEN
270
!If Inefficient Drainage System Head is at upper limit and EPL Head greater than Inefficient Drainage System Head
271
! Then do nothing
272
Transfer = 0.0
273
ELSE
274
Transfer = IDSTrans(i) &
275
*(EPLValues(EPLPerm(k)) - IDSValues(IDSPerm(k))) &
276
/(IDSThick(i) * LeakFact(i))
277
IF(Transfer.GT.0.0)THEN !Positive Transfer is from EPL to IDS
278
Transfer = Transfer * EPLStoring(i)
279
ELSEIF(Transfer.LT.0.0)THEN !Negative Transfer from IDS to EPL
280
Transfer = Transfer * IDSStoring(i)
281
END IF
282
END IF
283
EXIT
284
END IF
285
END DO
286
END IF
287
288
END FUNCTION EPLToIDS
289
290