-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReadHydroBoundaryCondition.f90
489 lines (442 loc) · 35.9 KB
/
ReadHydroBoundaryCondition.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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
!> This subroutine reads the simulation parameters.
Subroutine ReadHydroBoundaryCondition(HydroParam,hydroConfiguration,IniTime,FinalTime,MeshParam)
Use domain_types
Use Hydrodynamic
Use MeshVars
Implicit none
Integer i,j,k,iEdge,iNode1,iNode2,Face,iLayer,iRange,nWaterLvl
Integer:: idate(6)
character(len=20):: str
Integer NObjInflow, NObjWaterLevel, NObjRange
Integer(c_int):: numberOfBoundaryConditions
type(HydrodynamicConfiguration) :: hydroConfiguration
type(BoundaryCondition), dimension(:), pointer :: boundaryConditions
type(NonVerticallyIntegratedRange), pointer :: nonVerticallyIntegratedCell(:)
!integer, pointer :: objectIds(:)
type(HydrodynamicBoundaryConditionCell), pointer :: boundaryConditionCells(:)
type(TimeSeries), pointer :: hydrotimeSeries(:)
Integer:: IniTime !< Initial time of simulation (unix time)
Integer:: FinalTime !< Final time of simulation (unix time)
type(MeshGridParam) :: MeshParam
type(HydrodynamicParam) :: HydroParam
call c_f_pointer(hydroConfiguration%boundaryConditions, boundaryConditions, [hydroConfiguration%numberOfBoundaryConditions])
!Allocate(HydroParam%IndexInflow(HydroParam%NInflow,2))
Allocate(HydroParam%IndexInflow(MeshParam%nEdge,2))
HydroParam%IndexInflow = 0
HydroParam%IndexWaterLevel = 0.d0
HydroParam%NInflow = 0.d0
HydroParam%NWaterLevel = 0.d0
NObjWaterLevel = 0.d0
NObjInflow = 0.d0
NObjRange = 0.d0
! 1. Mapping cells (Water level) or faces (Inflow/outflow) with boundary condition
Do i = 1,hydroConfiguration%numberOfBoundaryConditions
call c_f_pointer(boundaryConditions(i)%cells, boundaryConditionCells, [boundaryConditions(i)%cellsLength])
If (trim(boundaryConditions(i)%conditionType) == "waterLevel") Then !Water level
Do j = 1,boundaryConditions(i)%cellsLength
HydroParam%NWaterLevel = HydroParam%NWaterLevel + 1
NObjWaterLevel = Max(NObjWaterLevel, boundaryConditions(i)%timeSeriesListSize)
EndDo
ElseIf (trim(boundaryConditions(i)%conditionType) == "waterFlow") Then !Inflow/Outflow
Do j = 1,boundaryConditions(i)%cellsLength
If (boundaryConditions(i)%verticallyIntegrated) Then
HydroParam%NInflow = HydroParam%NInflow + 1
NObjRange = Max(NObjRange,1)
NObjInflow = Max(NObjInflow, boundaryConditions(i)%timeSeriesListSize)
Else
NObjRange = Max(NObjRange,boundaryConditions(i)%rangesSize)
call c_f_pointer(boundaryConditions(i)%ranges, nonVerticallyIntegratedCell, [boundaryConditions(i)%rangesSize])
Do iRange = 1,boundaryConditions(i)%rangesSize
HydroParam%NInflow = HydroParam%NInflow + 1
If (nonVerticallyIntegratedCell(iRange)%function == 1) Then ! Constant
NObjInflow = Max(NObjInflow, 1)
ElseIf (nonVerticallyIntegratedCell(iRange)%function == 2) Then ! Time-series
NObjInflow = Max(NObjInflow, nonVerticallyIntegratedCell(iRange)%timeSeriesListSize)
EndIf
EndDo
EndIf
EndDo
ElseIf (trim(boundaryConditions(i)%conditionType) == "normalDepth") Then !Normal Depth
Do j = 1,boundaryConditions(i)%cellsLength
HydroParam%NInflow = HydroParam%NInflow + 1
!NObjInflow = Max(NObjInflow, boundaryConditions(i)%timeSeriesListSize)
Do iEdge = 1,4
Face = MeshParam%Edge(iEdge,boundaryConditionCells(j)%cellId + 1)
iNode1 = MeshParam%Quadri(MeshParam%EdgeDef(1,iEdge),boundaryConditionCells(j)%cellId + 1) ! Global Node Number of Node 1 of Edge "iEdge" of Element i
iNode2 = MeshParam%Quadri(MeshParam%EdgeDef(2,iEdge),boundaryConditionCells(j)%cellId + 1) ! Global Node Number of Node 2 of Edge "iEdge" of Element i
If (iNode1==boundaryConditionCells(j)%verticeIds(1).and.iNode2==boundaryConditionCells(j)%verticeIds(2)) Then
HydroParam%IndexInflow(Face,1) = HydroParam%NInflow
HydroParam%IndexInflow(Face,2) = boundaryConditionCells(j)%cellId + 1
Exit
EndIf
EndDo
EndDo
EndIf
EndDo
! 2. Reading Hydrodynamic Boundary conditions
If (NObjWaterLevel<2) NObjWaterLevel = 2
Allocate(HydroParam%WaterLevelValue(HydroParam%NWaterLevel,NObjWaterLevel))
Allocate (HydroParam%WaterLevelTime(HydroParam%NWaterLevel,NObjWaterLevel))
Allocate (HydroParam%WaterLevelnTime(HydroParam%NWaterLevel))
Allocate(HydroParam%IndexWaterLevel(HydroParam%NWaterLevel,2))
Allocate (HydroParam%WaterLevel(HydroParam%NWaterLevel))
If (NObjInflow<2) NObjInflow = 2
Allocate (HydroParam%InFlowValue(HydroParam%NInflow,NObjInflow))
Allocate (HydroParam%InFlowTime(HydroParam%NInflow,NObjInflow))
Allocate (HydroParam%InFlownTime(HydroParam%NInflow))
Allocate (HydroParam%InFlowSmallm(HydroParam%NInflow))
Allocate (HydroParam%InFlowCapitalM(HydroParam%NInflow))
Allocate (HydroParam%NRange(HydroParam%NInflow))
HydroParam%IndexWaterLevel = 0
HydroParam%IndexWaterLevelEdge = 0
HydroParam%IndexInflowEdge = 0
HydroParam%NInflow = 0
HydroParam%NWaterLevel = 0
!NObjRange = 0
nWaterLvl = 0
Do i = 1,hydroConfiguration%numberOfBoundaryConditions
call c_f_pointer(boundaryConditions(i)%cells, boundaryConditionCells, [boundaryConditions(i)%cellsLength])
If (trim(boundaryConditions(i)%conditionType) == "waterLevel") Then !Water level
If (boundaryConditions(i)%conditionFunction == 1) Then !Constant
Do k = 1,boundaryConditions(i)%cellsLength
HydroParam%NWaterLevel = HydroParam%NWaterLevel + 1
HydroParam%WaterLevelnTime(HydroParam%NWaterLevel) = 2
Do iEdge = 1,4
Face = MeshParam%Edge(iEdge,boundaryConditionCells(k)%cellId + 1)
iNode1 = MeshParam%Quadri(MeshParam%EdgeDef(1,iEdge),boundaryConditionCells(k)%cellId + 1) ! Global Node Number of Node 1 of Edge "iEdge" of Element i
iNode2 = MeshParam%Quadri(MeshParam%EdgeDef(2,iEdge),boundaryConditionCells(k)%cellId + 1) ! Global Node Number of Node 2 of Edge "iEdge" of Element i
If (iNode1==boundaryConditionCells(k)%verticeIds(1).and.iNode2==boundaryConditionCells(k)%verticeIds(2)) Then
HydroParam%IndexWaterLevel(HydroParam%NWaterLevel,1) = Face
HydroParam%IndexWaterLevel(HydroParam%NWaterLevel,2) = boundaryConditionCells(k)%cellId + 1
nWaterLvl = nWaterLvl + 1
HydroParam%IndexWaterLevelEdge(Face) = nWaterLvl
!HydroParam%IndexWaterLevelEdge(Face) = 1
EndIf
EndDo
HydroParam%WaterLevelTime(HydroParam%NWaterLevel,1) = IniTime
HydroParam%WaterLevelTime(HydroParam%NWaterLevel,2) = FinalTime
HydroParam%WaterLevelValue(HydroParam%NWaterLevel,:) = boundaryConditions(i)%constantValue
EndDo
ElseIf (boundaryConditions(i)%conditionFunction == 2) Then !Time-series
Do k = 1,boundaryConditions(i)%cellsLength
HydroParam%NWaterLevel = HydroParam%NWaterLevel + 1
If (boundaryConditions(i)%timeSeriesListSize<2) Then
HydroParam%WaterLevelnTime(HydroParam%NWaterLevel) = 2
Do iEdge = 1,4
Face = MeshParam%Edge(iEdge,boundaryConditionCells(k)%cellId + 1)
iNode1 = MeshParam%Quadri(MeshParam%EdgeDef(1,iEdge),boundaryConditionCells(k)%cellId + 1) ! Global Node Number of Node 1 of Edge "iEdge" of Element i
iNode2 = MeshParam%Quadri(MeshParam%EdgeDef(2,iEdge),boundaryConditionCells(k)%cellId + 1) ! Global Node Number of Node 2 of Edge "iEdge" of Element i
If (iNode1==boundaryConditionCells(k)%verticeIds(1).and.iNode2==boundaryConditionCells(k)%verticeIds(2)) Then
HydroParam%IndexWaterLevel(HydroParam%NWaterLevel,1) = Face
HydroParam%IndexWaterLevel(HydroParam%NWaterLevel,2) = boundaryConditionCells(k)%cellId + 1
nWaterLvl = nWaterLvl + 1
HydroParam%IndexWaterLevelEdge(Face) = nWaterLvl
!HydroParam%IndexWaterLevelEdge(Face) = 1
EndIf
EndDo
HydroParam%WaterLevelTime(HydroParam%NWaterLevel,1) = IniTime
HydroParam%WaterLevelTime(HydroParam%NWaterLevel,2) = FinalTime
call c_f_pointer(boundaryConditions(i)%timeSeriesList, hydrotimeSeries, [boundaryConditions(i)%timeSeriesListSize])
HydroParam%WaterLevelValue(HydroParam%NWaterLevel,:) = hydrotimeSeries(1)%value1
Else
HydroParam%WaterLevelnTime(HydroParam%NWaterLevel) = boundaryConditions(i)%timeSeriesListSize
Do iEdge = 1,4
Face = MeshParam%Edge(iEdge,boundaryConditionCells(k)%cellId + 1)
iNode1 = MeshParam%Quadri(MeshParam%EdgeDef(1,iEdge),boundaryConditionCells(k)%cellId + 1) ! Global Node Number of Node 1 of Edge "iEdge" of Element i
iNode2 = MeshParam%Quadri(MeshParam%EdgeDef(2,iEdge),boundaryConditionCells(k)%cellId + 1) ! Global Node Number of Node 2 of Edge "iEdge" of Element i
If (iNode1==boundaryConditionCells(k)%verticeIds(1).and.iNode2==boundaryConditionCells(k)%verticeIds(2)) Then
HydroParam%IndexWaterLevel(HydroParam%NWaterLevel,1) = Face
HydroParam%IndexWaterLevel(HydroParam%NWaterLevel,2) = boundaryConditionCells(k)%cellId + 1
nWaterLvl = nWaterLvl + 1
HydroParam%IndexWaterLevelEdge(Face) = nWaterLvl
!HydroParam%IndexWaterLevelEdge(Face) = 1
EndIf
EndDo
call c_f_pointer(boundaryConditions(i)%timeSeriesList, hydrotimeSeries, [boundaryConditions(i)%timeSeriesListSize])
Do j = 1, HydroParam%WaterLevelnTime(HydroParam%NWaterLevel)
! Verifing consistency of time series
!If (j == 1) Then !First date of time series
! If (IniTime<hydrotimeSeries(j)%timeStampSize) Then
! Call unix2c(hydrotimeSeries(j)%timeStampSize, idate)
! Print*, 'First date of time series ('//trim(str(idate(1)))//'/'//trim(str(idate(2)))//'/'//trim(str(idate(3)))//' '//trim(str(idate(4)))//':'//trim(str(idate(5)))//':'//trim(str(idate(6)))//')'
! Call unix2c(IniTime, idate)
! Print*, 'is greater than initial time of simulation ('//trim(str(idate(1)))//'/'//trim(str(idate(2)))//'/'//trim(str(idate(3)))//' '//trim(str(idate(4)))//':'//trim(str(idate(5)))//':'//trim(str(idate(6)))//').'
! Print*, 'Please check Boundary condition number ('//trim(str(i))//').'
! Pause
! Stop
! EndIf
!ElseIf (j == WaterLevelnTime(NWaterLevel)) Then
! If (FinalTime>hydrotimeSeries(j)%timeStampSize) Then
! Call unix2c(hydrotimeSeries(j)%timeStampSize, idate)
! Print*, 'Last date of time series ('//trim(str(idate(1)))//'/'//trim(str(idate(2)))//'/'//trim(str(idate(3)))//' '//trim(str(idate(4)))//':'//trim(str(idate(5)))//':'//trim(str(idate(6)))//')'
! Call unix2c(FinalTime, idate)
! Print*, 'is lesser than initial time of simulation ('//trim(str(idate(1)))//'/'//trim(str(idate(2)))//'/'//trim(str(idate(3)))//' '//trim(str(idate(4)))//':'//trim(str(idate(5)))//':'//trim(str(idate(6)))//').'
! Print*, 'Please check Boundary condition number ('//trim(str(i))//').'
! Pause
! Stop
! EndIf
!EndIf
! Storing stamp time and values of time series
HydroParam%WaterLevelTime(HydroParam%NWaterLevel,j) = hydrotimeSeries(j)%timeStamp
HydroParam%WaterLevelValue(HydroParam%NWaterLevel,j) = hydrotimeSeries(j)%value1
EndDo
EndIf
EndDo
EndIf
ElseIf (trim(boundaryConditions(i)%conditionType) == "waterFlow") Then !Inflow/Outflow
If (boundaryConditions(i)%verticallyIntegrated) Then ! Vertically Integrated
!HydroParam%NRange(i) = 1
!iRange = 1
If (boundaryConditions(i)%conditionFunction == 1) Then !Constant
Do k = 1,boundaryConditions(i)%cellsLength
HydroParam%NInflow = HydroParam%NInflow + 1
HydroParam%InFlownTime(HydroParam%NInflow) = 2
Do iEdge = 1,4
Face = MeshParam%Edge(iEdge,boundaryConditionCells(k)%cellId + 1)
iNode1 = MeshParam%Quadri(MeshParam%EdgeDef(1,iEdge),boundaryConditionCells(k)%cellId + 1) ! Global Node Number of Node 1 of Edge "iEdge" of Element i
iNode2 = MeshParam%Quadri(MeshParam%EdgeDef(2,iEdge),boundaryConditionCells(k)%cellId + 1) ! Global Node Number of Node 2 of Edge "iEdge" of Element i
If (iNode1==boundaryConditionCells(k)%verticeIds(1).and.iNode2==boundaryConditionCells(k)%verticeIds(2)) Then
HydroParam%InFlowSmallm(HydroParam%NInflow) = HydroParam%Smallm(Face)
HydroParam%InFlowCapitalM(HydroParam%NInflow) = HydroParam%CapitalM(Face)
HydroParam%IndexInflow(HydroParam%NInflow,1) = Face
HydroParam%IndexInflow(HydroParam%NInflow,2) = boundaryConditionCells(k)%cellId + 1
HydroParam%IndexInflowEdge(Face) = 1
EndIf
EndDo
HydroParam%InFlowTime(HydroParam%NInflow,1) = IniTime
HydroParam%InFlowTime(HydroParam%NInflow,2) = FinalTime
HydroParam%InFlowValue(HydroParam%NInflow,:) = boundaryConditions(i)%constantValue
EndDo
ElseIf (boundaryConditions(i)%conditionFunction == 2) Then !Time-series
Do k = 1,boundaryConditions(i)%cellsLength
HydroParam%NInflow = HydroParam%NInflow + 1
If (boundaryConditions(i)%timeSeriesListSize<2) Then
HydroParam%InFlownTime(HydroParam%NInflow) = 2
Do iEdge = 1,4
Face = MeshParam%Edge(iEdge,boundaryConditionCells(k)%cellId + 1)
iNode1 = MeshParam%Quadri(MeshParam%EdgeDef(1,iEdge),boundaryConditionCells(k)%cellId + 1) ! Global Node Number of Node 1 of Edge "iEdge" of Element i
iNode2 = MeshParam%Quadri(MeshParam%EdgeDef(2,iEdge),boundaryConditionCells(k)%cellId + 1) ! Global Node Number of Node 2 of Edge "iEdge" of Element i
If (iNode1==boundaryConditionCells(k)%verticeIds(1).and.iNode2==boundaryConditionCells(k)%verticeIds(2)) Then
HydroParam%InFlowSmallm(HydroParam%NInflow) = HydroParam%Smallm(Face)
HydroParam%InFlowCapitalM(HydroParam%NInflow) = HydroParam%CapitalM(Face)
HydroParam%IndexInflow(HydroParam%NInflow,1) = Face
HydroParam%IndexInflow(HydroParam%NInflow,2) = boundaryConditionCells(k)%cellId + 1
HydroParam%IndexInflowEdge(Face) = 1
EndIf
EndDo
HydroParam%InFlowTime(HydroParam%NInflow,1) = IniTime
HydroParam%InFlowTime(HydroParam%NInflow,2) = FinalTime
call c_f_pointer(boundaryConditions(i)%timeSeriesList, hydrotimeSeries, [boundaryConditions(i)%timeSeriesListSize])
HydroParam%InFlowValue(HydroParam%NInflow,:) = hydrotimeSeries(1)%value1
Else
HydroParam%InFlownTime(HydroParam%NInflow) = boundaryConditions(i)%timeSeriesListSize
Do iEdge = 1,4
Face = MeshParam%Edge(iEdge,boundaryConditionCells(k)%cellId + 1)
iNode1 = MeshParam%Quadri(MeshParam%EdgeDef(1,iEdge),boundaryConditionCells(k)%cellId + 1) ! Global Node Number of Node 1 of Edge "iEdge" of Element i
iNode2 = MeshParam%Quadri(MeshParam%EdgeDef(2,iEdge),boundaryConditionCells(k)%cellId + 1) ! Global Node Number of Node 2 of Edge "iEdge" of Element i
If (iNode1==boundaryConditionCells(k)%verticeIds(1).and.iNode2==boundaryConditionCells(k)%verticeIds(2)) Then
HydroParam%InFlowSmallm(HydroParam%NInflow) = HydroParam%Smallm(Face)
HydroParam%InFlowCapitalM(HydroParam%NInflow) = HydroParam%CapitalM(Face)
HydroParam%IndexInflow(HydroParam%NInflow,1) = Face
HydroParam%IndexInflow(HydroParam%NInflow,2) = boundaryConditionCells(k)%cellId + 1
HydroParam%IndexInflowEdge(Face) = 1
EndIf
EndDo
call c_f_pointer(boundaryConditions(i)%timeSeriesList, hydrotimeSeries, [boundaryConditions(i)%timeSeriesListSize])
Do j = 1, HydroParam%InFlownTime(HydroParam%NInflow)
! Verifing consistency of time series
!If (j == 1) Then !First date of time series
! If (IniTime<hydrotimeSeries(j)%timeStampSize) Then
! Call unix2c(hydrotimeSeries(j)%timeStampSize, idate)
! Print*, 'First date of time series ('//trim(str(idate(1)))//'/'//trim(str(idate(2)))//'/'//trim(str(idate(3)))//' '//trim(str(idate(4)))//':'//trim(str(idate(5)))//':'//trim(str(idate(6)))//')'
! Call unix2c(IniTime, idate)
! Print*, 'is greater than initial time of simulation ('//trim(str(idate(1)))//'/'//trim(str(idate(2)))//'/'//trim(str(idate(3)))//' '//trim(str(idate(4)))//':'//trim(str(idate(5)))//':'//trim(str(idate(6)))//').'
! Print*, 'Please check Boundary condition number ('//trim(str(i))//').'
! Pause
! Stop
! EndIf
!ElseIf (j == WaterLevelnTime(NWaterLevel)) Then
! If (FinalTime>hydrotimeSeries(j)%timeStampSize) Then
! Call unix2c(hydrotimeSeries(j)%timeStampSize, idate)
! Print*, 'Last date of time series ('//trim(str(idate(1)))//'/'//trim(str(idate(2)))//'/'//trim(str(idate(3)))//' '//trim(str(idate(4)))//':'//trim(str(idate(5)))//':'//trim(str(idate(6)))//')'
! Call unix2c(FinalTime, idate)
! Print*, 'is lesser than initial time of simulation ('//trim(str(idate(1)))//'/'//trim(str(idate(2)))//'/'//trim(str(idate(3)))//' '//trim(str(idate(4)))//':'//trim(str(idate(5)))//':'//trim(str(idate(6)))//').'
! Print*, 'Please check Boundary condition number ('//trim(str(i))//').'
! Pause
! Stop
! EndIf
!EndIf
! Storing stamp time and values of time series
HydroParam%InFlowTime(HydroParam%NInflow,j) = hydrotimeSeries(j)%timeStamp
HydroParam%InFlowValue(HydroParam%NInflow,j) = hydrotimeSeries(j)%value1
EndDo
EndIf
EndDo
EndIf
Else ! Non Vertically Integrated
call c_f_pointer(boundaryConditions(i)%ranges, nonVerticallyIntegratedCell, [boundaryConditions(i)%rangesSize])
!HydroParam%NRange(i) = boundaryConditions(i)%rangesSize
Do iRange = 1,boundaryConditions(i)%rangesSize
If (nonVerticallyIntegratedCell(iRange)%function == 1) Then !Constant
Do k = 1,boundaryConditions(i)%cellsLength
HydroParam%NInflow = HydroParam%NInflow + 1
HydroParam%InFlownTime(HydroParam%NInflow) = 2
Do iEdge = 1,4
Face = MeshParam%Edge(iEdge,boundaryConditionCells(k)%cellId + 1)
iNode1 = MeshParam%Quadri(MeshParam%EdgeDef(1,iEdge),boundaryConditionCells(k)%cellId + 1) ! Global Node Number of Node 1 of Edge "iEdge" of Element i
iNode2 = MeshParam%Quadri(MeshParam%EdgeDef(2,iEdge),boundaryConditionCells(k)%cellId + 1) ! Global Node Number of Node 2 of Edge "iEdge" of Element i
If (iNode1==boundaryConditionCells(k)%verticeIds(1).and.iNode2==boundaryConditionCells(k)%verticeIds(2)) Then
HydroParam%IndexInflow(HydroParam%NInflow,1) = Face
HydroParam%IndexInflow(HydroParam%NInflow,2) = boundaryConditionCells(k)%cellId + 1
HydroParam%IndexInflowEdge(Face) = 1
Do iLayer = HydroParam%Smallm(Face), HydroParam%CapitalM(Face)
If (HydroParam%Z(iLayer+1,Face)>nonVerticallyIntegratedCell(iRange)%minimumElevation) Then
HydroParam%InFlowSmallm(HydroParam%NInflow) = iLayer !Vertical Integrated (review)
Exit
Else
HydroParam%InFlowSmallm(HydroParam%NInflow) = HydroParam%Smallm(Face)
EndIf
EndDo
Do iLayer = HydroParam%Smallm(Face), HydroParam%CapitalM(Face)
If (HydroParam%Z(iLayer+1,Face)>=nonVerticallyIntegratedCell(iRange)%maximumElevation) Then
HydroParam%InFlowCapitalM(HydroParam%NInflow) = iLayer !Vertical Integrated (review)
Exit
Else
HydroParam%InFlowCapitalM(HydroParam%NInflow) = HydroParam%CapitalM(Face)
EndIf
EndDo
Exit
EndIf
EndDo
EndDo
HydroParam%InFlowTime(HydroParam%NInflow,1) = IniTime
HydroParam%InFlowTime(HydroParam%NInflow,2) = FinalTime
HydroParam%InFlowValue(HydroParam%NInflow,:) = nonVerticallyIntegratedCell(iRange)%value
ElseIf (nonVerticallyIntegratedCell(iRange)%function == 2) Then !Time-series
Do k = 1,boundaryConditions(i)%cellsLength
HydroParam%NInflow = HydroParam%NInflow + 1
If (nonVerticallyIntegratedCell(iRange)%timeSeriesListSize<2) Then
HydroParam%InFlownTime(HydroParam%NInflow) = 2
Do iEdge = 1,4
Face = MeshParam%Edge(iEdge,boundaryConditionCells(k)%cellId + 1)
iNode1 = MeshParam%Quadri(MeshParam%EdgeDef(1,iEdge),boundaryConditionCells(k)%cellId + 1) ! Global Node Number of Node 1 of Edge "iEdge" of Element i
iNode2 = MeshParam%Quadri(MeshParam%EdgeDef(2,iEdge),boundaryConditionCells(k)%cellId + 1) ! Global Node Number of Node 2 of Edge "iEdge" of Element i
If (iNode1==boundaryConditionCells(k)%verticeIds(1).and.iNode2==boundaryConditionCells(k)%verticeIds(2)) Then
HydroParam%IndexInflow(HydroParam%NInflow,1) = Face
HydroParam%IndexInflow(HydroParam%NInflow,2) = boundaryConditionCells(k)%cellId + 1
HydroParam%IndexInflowEdge(Face) = 1
Do iLayer = HydroParam%Smallm(Face), HydroParam%CapitalM(Face)
If (HydroParam%Z(iLayer+1,Face)>nonVerticallyIntegratedCell(iRange)%minimumElevation) Then
HydroParam%InFlowSmallm(HydroParam%NInflow) = iLayer !Vertical Integrated (review)
Exit
Else
HydroParam%InFlowSmallm(HydroParam%NInflow) = HydroParam%Smallm(Face)
EndIf
EndDo
Do iLayer = HydroParam%Smallm(Face), HydroParam%CapitalM(Face)
If (HydroParam%Z(iLayer+1,Face)>=nonVerticallyIntegratedCell(iRange)%maximumElevation) Then
HydroParam%InFlowCapitalM(HydroParam%NInflow) = iLayer !Vertical Integrated (review)
Exit
Else
HydroParam%InFlowCapitalM(HydroParam%NInflow) = HydroParam%CapitalM(Face)
EndIf
EndDo
Exit
EndIf
EndDo
HydroParam%InFlowTime(HydroParam%NInflow,1) = IniTime
HydroParam%InFlowTime(HydroParam%NInflow,2) = FinalTime
call c_f_pointer(nonVerticallyIntegratedCell(iRange)%timeSeriesList, hydrotimeSeries, [nonVerticallyIntegratedCell(iRange)%timeSeriesListSize])
HydroParam%InFlowValue(HydroParam%NInflow,:) = hydrotimeSeries(1)%value1
Else
HydroParam%InFlownTime(HydroParam%NInflow) = nonVerticallyIntegratedCell(iRange)%timeSeriesListSize
Do iEdge = 1,4
Face = MeshParam%Edge(iEdge,boundaryConditionCells(k)%cellId + 1)
iNode1 = MeshParam%Quadri(MeshParam%EdgeDef(1,iEdge),boundaryConditionCells(k)%cellId + 1) ! Global Node Number of Node 1 of Edge "iEdge" of Element i
iNode2 = MeshParam%Quadri(MeshParam%EdgeDef(2,iEdge),boundaryConditionCells(k)%cellId + 1) ! Global Node Number of Node 2 of Edge "iEdge" of Element i
If (iNode1==boundaryConditionCells(k)%verticeIds(1).and.iNode2==boundaryConditionCells(k)%verticeIds(2)) Then
HydroParam%IndexInflow(HydroParam%NInflow,1) = Face
HydroParam%IndexInflow(HydroParam%NInflow,2) = boundaryConditionCells(k)%cellId + 1
HydroParam%IndexInflowEdge(Face) = 1
Do iLayer = HydroParam%Smallm(Face), HydroParam%CapitalM(Face)
If (HydroParam%Z(iLayer+1,Face)>nonVerticallyIntegratedCell(iRange)%minimumElevation) Then
HydroParam%InFlowSmallm(HydroParam%NInflow) = iLayer !Vertical Integrated (review)
Exit
Else
HydroParam%InFlowSmallm(HydroParam%NInflow) = HydroParam%Smallm(Face)
EndIf
EndDo
Do iLayer = HydroParam%Smallm(Face), HydroParam%CapitalM(Face)
If (HydroParam%Z(iLayer+1,Face)>=nonVerticallyIntegratedCell(iRange)%maximumElevation) Then
HydroParam%InFlowCapitalM(HydroParam%NInflow) = iLayer !Vertical Integrated (review)
Exit
Else
HydroParam%InFlowCapitalM(HydroParam%NInflow) = HydroParam%CapitalM(Face)
EndIf
EndDo
Exit
EndIf
EndDo
call c_f_pointer(nonVerticallyIntegratedCell(iRange)%timeSeriesList, hydrotimeSeries, [nonVerticallyIntegratedCell(iRange)%timeSeriesListSize])
Do j = 1, HydroParam%InFlownTime(HydroParam%NInflow)
! Verifing consistency of time series
!If (j == 1) Then !First date of time series
! If (IniTime<hydrotimeSeries(j)%timeStampSize) Then
! Call unix2c(hydrotimeSeries(j)%timeStampSize, idate)
! Print*, 'First date of time series ('//trim(str(idate(1)))//'/'//trim(str(idate(2)))//'/'//trim(str(idate(3)))//' '//trim(str(idate(4)))//':'//trim(str(idate(5)))//':'//trim(str(idate(6)))//')'
! Call unix2c(IniTime, idate)
! Print*, 'is greater than initial time of simulation ('//trim(str(idate(1)))//'/'//trim(str(idate(2)))//'/'//trim(str(idate(3)))//' '//trim(str(idate(4)))//':'//trim(str(idate(5)))//':'//trim(str(idate(6)))//').'
! Print*, 'Please check Boundary condition number ('//trim(str(i))//').'
! Pause
! Stop
! EndIf
!ElseIf (j == WaterLevelnTime(NWaterLevel)) Then
! If (FinalTime>hydrotimeSeries(j)%timeStampSize) Then
! Call unix2c(hydrotimeSeries(j)%timeStampSize, idate)
! Print*, 'Last date of time series ('//trim(str(idate(1)))//'/'//trim(str(idate(2)))//'/'//trim(str(idate(3)))//' '//trim(str(idate(4)))//':'//trim(str(idate(5)))//':'//trim(str(idate(6)))//')'
! Call unix2c(FinalTime, idate)
! Print*, 'is lesser than initial time of simulation ('//trim(str(idate(1)))//'/'//trim(str(idate(2)))//'/'//trim(str(idate(3)))//' '//trim(str(idate(4)))//':'//trim(str(idate(5)))//':'//trim(str(idate(6)))//').'
! Print*, 'Please check Boundary condition number ('//trim(str(i))//').'
! Pause
! Stop
! EndIf
!EndIf
! Storing stamp time and values of time series
HydroParam%InFlowTime(HydroParam%NInflow,j) = hydrotimeSeries(j)%timeStamp
HydroParam%InFlowValue(HydroParam%NInflow,j) = hydrotimeSeries(j)%value1
EndDo
EndIf
EndDo
EndIf
EndDo
EndIf
ElseIf (trim(boundaryConditions(i)%conditionType) == "normalDepth") Then !Normal Depth
If (boundaryConditions(i)%conditionFunction == 1) Then !Constant
Do j = 1,boundaryConditions(i)%cellsLength
HydroParam%NInflow = HydroParam%NInflow + 1
HydroParam%InFlownTime(HydroParam%NInflow) = -999
Do iEdge = 1,4
Face = MeshParam%Edge(iEdge,boundaryConditionCells(j)%cellId + 1)
iNode1 = MeshParam%Quadri(MeshParam%EdgeDef(1,iEdge),boundaryConditionCells(j)%cellId + 1) ! Global Node Number of Node 1 of Edge "iEdge" of Element i
iNode2 = MeshParam%Quadri(MeshParam%EdgeDef(2,iEdge),boundaryConditionCells(j)%cellId + 1) ! Global Node Number of Node 2 of Edge "iEdge" of Element i
If (iNode1==boundaryConditionCells(j)%verticeIds(1).and.iNode2==boundaryConditionCells(j)%verticeIds(2)) Then
HydroParam%IndexInflow(HydroParam%NInflow,1) = Face
HydroParam%IndexInflow(HydroParam%NInflow,2) = boundaryConditionCells(j)%cellId + 1
HydroParam%IndexInflowEdge(Face) = 1
HydroParam%InFlowSmallm(HydroParam%NInflow) = 1 !Vertical Integrated (review)
HydroParam%InFlowCapitalM(HydroParam%NInflow) = MeshParam%KMax !Vertical Integrated (review)
Exit
EndIf
EndDo
HydroParam%InFlowTime(HydroParam%NInflow,1) = -999
HydroParam%InFlowTime(HydroParam%NInflow,2) = -999
HydroParam%InFlowValue(HydroParam%NInflow,:) = boundaryConditions(i)%constantValue
EndDo
EndIf
EndIf
EndDo
!Open(96,FILE=trim(simParam%OutputPath)//'/'//trim(Basename)//trim(FileName)//'.txt',STATUS='OLD',ACTION='READ')
!Do i=1,HydroParam%InflownTime(1)
! READ(96,*) HydroParam%irrgMirim(i), HydroParam%irrgMangueira(i)
!EndDo
End Subroutine ReadHydroBoundaryCondition