Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/elmerice/UserFunctions/USF_LateralFriction.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: Olivier Gagliardini
26
! * Email:
27
! * Web: http://elmerice.elmerfem.org
28
! *
29
! * Original Date:
30
! * Date modifications:
31
! *
32
! *
33
! *****************************************************************************
34
!> Lateral Friction user functions
35
!>
36
!> return the gravity force -g + K * ||u||^(m-1) u
37
!> where K is the a lateral friction coefficient,
38
!> m the lateral friction exponent,
39
!> end u is the velocity vector
40
!> work only in 2D (no sense in 3D)
41
!> work for non-structured mesh
42
FUNCTION LateralFriction_x ( Model, nodenumber, x) RESULT(gx)
43
USE Types
44
USE DefUtils
45
IMPLICIT NONE
46
TYPE(Model_t) :: Model
47
INTEGER :: nodenumber
48
REAL(KIND=dp) :: x, gx, LateralFriction
49
50
gx = LateralFriction ( Model, nodenumber, x, 1 )
51
52
53
END FUNCTION LateralFriction_x
54
55
FUNCTION LateralFriction_y ( Model, nodenumber, x) RESULT(gy)
56
USE Types
57
USE DefUtils
58
IMPLICIT NONE
59
TYPE(Model_t) :: Model
60
INTEGER :: nodenumber
61
REAL(KIND=dp) :: x, gy, LateralFriction
62
63
gy = LateralFriction ( Model, nodenumber, x, 2 )
64
65
END FUNCTION LateralFriction_y
66
67
68
69
70
FUNCTION LateralFriction ( Model, nodenumber, x, axis ) RESULT(gi)
71
USE types
72
USE CoordinateSystems
73
USE SolverUtils
74
USE ElementDescription
75
USE DefUtils
76
IMPLICIT NONE
77
TYPE(Model_t) :: Model
78
INTEGER :: nodenumber, axis
79
REAL(KIND=dp) :: x, gi, Kspring, mm
80
81
TYPE(Nodes_t), SAVE :: Nodes
82
TYPE(Element_t), POINTER :: CurElement
83
TYPE(variable_t), POINTER :: FlowVariable
84
TYPE(ValueList_t), POINTER :: BodyForce, Material
85
86
REAL(KIND=dp), POINTER :: FlowValues(:)
87
INTEGER, POINTER :: FlowPerm(:)
88
89
REAL(KIND=dp), ALLOCATABLE :: auxReal(:)
90
91
REAL(KIND=dp) :: g(2), Velo(2), NVelo
92
INTEGER :: i, j, n
93
94
95
LOGICAL :: FirstTime = .TRUE., GotIt
96
97
CHARACTER(LEN=MAX_NAME_LEN) :: FlowSolverName
98
99
SAVE FirstTime, g, mm, FlowSolverName, auxReal
100
101
BodyForce => GetBodyForce()
102
material => GetMaterial()
103
104
IF (FirstTime) THEN
105
106
FirstTime = .FALSE.
107
108
n = Model % MaxElementNodes
109
ALLOCATE( auxReal(n) )
110
111
!---------------------
112
! Get the gravity vector g
113
!-------------------------
114
g(1) = GetConstReal( BodyForce, 'Lateral Friction Gravity 1', GotIt )
115
g(2) = GetConstReal( BodyForce, 'Lateral Friction Gravity 2', GotIt )
116
IF (.Not.GotIt ) CALL FATAL('LateralFriction', &
117
'Gravity vector must be specified')
118
119
120
mm = GetConstReal( BodyForce, 'Lateral Friction Exponent', GotIt )
121
IF (.Not.GotIt ) CALL FATAL('LateralFriction', &
122
'Lateral Friction Exponent must be defined')
123
124
FlowSolverName = GetString( BodyForce, 'Flow Solver Name', GotIt )
125
IF (.NOT.Gotit) FlowSolverName = 'Flow Solution'
126
127
ENDIF !FirstTime
128
129
130
FlowVariable => VariableGet( Model % Variables, FlowSolverName )
131
IF ( ASSOCIATED( FlowVariable ) ) THEN
132
FlowPerm => FlowVariable % Perm
133
FlowValues => FlowVariable % Values
134
ELSE
135
CALL Info('ShapeFactorGravity', &
136
& 'No variable for velocity associated.', Level=4)
137
END IF
138
NVelo = 0.0
139
DO i=1, 2
140
Velo(i) = FlowValues(3*(FlowPerm(nodenumber)-1) + i)
141
NVelo = NVelo + Velo(i)**2.0
142
END DO
143
NVelo = SQRT(NVelo)
144
145
!------------------------------------
146
! Get K coefficient for that nodes
147
!------------------------------------
148
CurElement => Model % CurrentElement
149
n = CurElement % Type % NumberOfNodes
150
auxReal(1:n) = GetReal( BodyForce, &
151
'Lateral Friction Coefficient', GotIt )
152
DO i=1, n
153
j = CurElement % NodeIndexes (i)
154
IF (nodenumber == j) EXIT
155
END DO
156
Kspring = auxReal(i)
157
IF ((NVelo > 1.0e-6).AND.(ABS(mm-1.0)>1.0e-6)) Kspring = Kspring * Nvelo**(mm-1.0)
158
159
gi = g(axis) - Kspring*velo(axis)
160
161
END FUNCTION LateralFriction
162
163
164
165
166