Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/elmerice/UserFunctions/USF_CouplingGlaDS_SSA.F90
3203 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: Olivier Gagliardini
26
! * Email:
27
! * Web: http://elmerice.elmerfem.org
28
! *
29
! * Original Date:
30
! * 2014/02/20 - Start wrinting User functions needed for the coupling between
31
! * the hydrology model (GlaDS) and the ice flow (SSA).
32
! *****************************************************************************
33
!> USF_CouplingGlaDS_SSA.F90
34
!>
35
!> HorizontalVelo returns the horizontal velocity (positive)
36
!>
37
FUNCTION HorizontalVelo (Model, nodenumber, x) RESULT(ub)
38
USE types
39
USE CoordinateSystems
40
USE SolverUtils
41
USE ElementDescription
42
USE DefUtils
43
IMPLICIT NONE
44
TYPE(Model_t) :: Model
45
REAL (KIND=dp) :: x, ub
46
INTEGER :: nodenumber
47
48
TYPE(ValueList_t), POINTER :: Constants
49
TYPE(Variable_t), POINTER :: FlowVariable, Gravity
50
REAL(KIND=dp), POINTER :: FlowValues(:)
51
INTEGER, POINTER :: FlowPerm(:)
52
INTEGER :: DIM, i
53
REAL (KIND=dp) :: velo(2)
54
LOGICAL :: GotIt
55
56
CHARACTER(LEN=MAX_NAME_LEN) :: USFName
57
58
USFName = 'HorizontalVelo'
59
DIM = CoordinateSystemDimension()
60
61
! Get the variables to compute ub : the fields velocity 1 and 2
62
FlowVariable => VariableGet( Model % Variables, 'ssavelocity' )
63
64
IF ( ASSOCIATED( FlowVariable ) ) THEN
65
FlowPerm => FlowVariable % Perm
66
FlowValues => FlowVariable % Values
67
ELSE
68
CALL FATAL(USFName, 'Need SSA Solver, variable >SSAVelocity< not associated !!!')
69
END IF
70
71
velo = 0.0_dp
72
DO i=1, DIM
73
velo(i) = FlowValues( (DIM)*(FlowPerm(Nodenumber)-1) + i )
74
END DO
75
ub = SQRT(velo(1)**2+velo(2)**2)
76
END FUNCTION HorizontalVelo
77
78
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
79
!> Function OverburdenPressure return the cryostatic pressure
80
!>
81
FUNCTION OverburdenPressure (Model, nodenumber, x) RESULT(IcePress)
82
USE types
83
USE CoordinateSystems
84
USE SolverUtils
85
USE ElementDescription
86
USE DefUtils
87
IMPLICIT NONE
88
TYPE(Model_t) :: Model
89
REAL (KIND=dp) :: x, IcePress
90
INTEGER :: nodenumber
91
TYPE(ValueList_t), POINTER :: Constants
92
TYPE(Variable_t), POINTER :: ZbVariable, ZsVariable
93
REAL(KIND=dp), POINTER :: ZbValues(:), ZsValues(:)
94
INTEGER, POINTER :: ZbPerm(:), ZsPerm(:)
95
INTEGER :: DIM, i
96
REAL (KIND=dp) :: zb, zs, gravity, rhoi
97
LOGICAL :: GotIt
98
99
CHARACTER(LEN=MAX_NAME_LEN) :: USFName
100
101
USFName = 'OverburdenPressure'
102
DIM = CoordinateSystemDimension()
103
104
! Get the constants needed to compute the overburden ice pressure
105
Constants => GetConstants()
106
gravity = GetConstReal( Constants, 'Gravity Norm', GotIt )
107
IF (.NOT.GotIt) THEN
108
WRITE(Message,'(a)')'Keyword >Gravity Norm< not found in Constant section'
109
CALL FATAL(USFName, Message)
110
END IF
111
rhoi = GetConstReal ( Constants, 'Ice Density', GotIt )
112
IF (.NOT.GotIt) THEN
113
WRITE(Message,'(a)')'Keyword >Ice Density< not found in Constant section'
114
CALL FATAL(USFName, Message)
115
END IF
116
117
! Get the variables to compute IcePress
118
ZbVariable => VariableGet( Model % Variables, 'zb' )
119
IF ( ASSOCIATED( ZbVariable ) ) THEN
120
ZbPerm => ZbVariable % Perm
121
ZbValues => ZbVariable % Values
122
ELSE
123
CALL FATAL(USFName, 'Variable >Zb< not associated !!!')
124
END IF
125
126
! Get the variables to compute IcePress
127
ZsVariable => VariableGet( Model % Variables, 'zs' )
128
IF ( ASSOCIATED( ZsVariable ) ) THEN
129
ZsPerm => ZsVariable % Perm
130
ZsValues => ZsVariable % Values
131
ELSE
132
CALL FATAL(USFName, 'Variable >Zs< not associated !!!')
133
END IF
134
zb = 0.0_dp
135
zs = 0.0_dp
136
137
zb = ZbValues( ZbPerm(Nodenumber))
138
zs = ZsValues( ZsPerm(Nodenumber))
139
IcePress = rhoi*gravity*(zs-zb)
140
IF (IcePress .LT. 0) THEN
141
print*, "Ice pressure value :", IcePress
142
END IF
143
END FUNCTION OverburdenPressure
144
145