@@ -13,7 +13,7 @@ mutable struct CoreBuddFriction <: CoreFriction #{{{
1313 rho_water:: Float64
1414 g:: Float64
1515end # }}}
16- struct CoreWeertmanFriction <: CoreFriction # {{{
16+ mutable struct CoreWeertmanFriction <: CoreFriction # {{{
1717 c_input:: Input
1818 vx_input:: Input
1919 vy_input:: Input
@@ -31,18 +31,13 @@ mutable struct CoreSchoofFriction <: CoreFriction #{{{
3131 rho_water:: Float64
3232 g:: Float64
3333end # }}}
34- mutable struct CoreFluxDNNFriction <: CoreFriction # {{{
35- dnnChain :: Vector{Flux.Chain}
36- dtx :: Vector{StatsBase.ZScoreTransform}
37- dty :: Vector{StatsBase.ZScoreTransform}
38- xyz_list :: Matrix{Float64}
34+ mutable struct CoreDNNFriction <: CoreFriction # {{{
35+ model :: AbstractLuxLayer
36+ ps
37+ st
38+ c_input :: Input
3939 vx_input:: Input
4040 vy_input:: Input
41- b_input:: Input
42- H_input:: Input
43- rho_ice:: Float64
44- rho_water:: Float64
45- g:: Float64
4641end # }}}
4742
4843function CoreFriction (element:: Tria , :: Val{frictionlaw} ) where frictionlaw # {{{
@@ -79,23 +74,12 @@ function CoreFriction(element::Tria, ::Val{frictionlaw}) where frictionlaw #{{{
7974
8075 return CoreSchoofFriction (c_input, vx_input, vy_input, m_input, Cmax_input, H_input, b_input, rho_ice, rho_water, g)
8176 elseif frictionlaw== 20
82- dnnChain = FindParam (Vector{Flux. Chain{}}, element, FrictionDNNChainEnum)
83- dtx = FindParam (Vector{StatsBase. ZScoreTransform{Float64, Vector{Float64}} }, element, FrictionDNNdtxEnum)
84- dty = FindParam (Vector{StatsBase. ZScoreTransform{Float64, Vector{Float64}} }, element, FrictionDNNdtyEnum)
85- H_input = GetInput (element, ThicknessEnum)
86- b_input = GetInput (element, BaseEnum)
87- ssx_input = GetInput (element, SurfaceSlopeXEnum)
88- ssy_input = GetInput (element, SurfaceSlopeYEnum)
89- bsx_input = GetInput (element, BedSlopeXEnum)
90- bsy_input = GetInput (element, BedSlopeYEnum)
91-
92- xyz_list = GetVerticesCoordinates (element. vertices)
93-
94- rho_ice = FindParam (Float64, element, MaterialsRhoIceEnum)
95- rho_water = FindParam (Float64, element, MaterialsRhoSeawaterEnum)
96- g = FindParam (Float64, element, ConstantsGEnum)
77+ c_input = GetInput (element, FrictionCEnum)
78+ model = FindParam (AbstractLuxLayer, element, FrictionDNNEnum)
79+ ps = FindParam (NamedTuple, element, FrictionDNNpsEnum)
80+ st = FindParam (NamedTuple, element, FrictionDNNstEnum)
9781
98- return CoreFluxDNNFriction (dnnChain,dtx,dty,xyz_list ,vx_input,vy_input,b_input,H_input,rho_ice,rho_water,g )
82+ return CoreDNNFriction (model,ps,st,c_input ,vx_input,vy_input)
9983 else
10084 error (" Friction " ,typeof (md. friction)," not supported yet" )
10185 end
@@ -161,40 +145,18 @@ end#}}}
161145 end
162146 return alpha2
163147end # }}}
164- @inline function Alpha2 (friction:: CoreFluxDNNFriction , gauss:: GaussTria , i:: Int64 )# {{{
165- bed = GetInputValue (friction. b_input, gauss, i)
166- H = GetInputValue (friction. H_input, gauss, i)
148+ @inline function Alpha2 (friction:: CoreDNNFriction , gauss:: GaussTria , i:: Int64 )# {{{
167149 vx = GetInputValue (friction. vx_input, gauss, i)
168150 vy = GetInputValue (friction. vy_input, gauss, i)
169- h = bed + H
170151
152+ c = GetInputValue (friction. c_input, gauss, i)
171153 # Get the velocity
172154 vmag = VelMag (friction, gauss, i)
173155
174- # velocity gradients
175- dvx = GetInputDerivativeValue (friction. vx_input,friction. xyz_list,gauss,i)
176- dvy = GetInputDerivativeValue (friction. vy_input,friction. xyz_list,gauss,i)
177- vxdx = dvx[1 ]
178- vxdy = dvx[2 ]
179- vydx = dvy[1 ]
180- vydy = dvy[2 ]
181-
182- # Get effective pressure
183- Neff = EffectivePressure (friction, gauss, i)
184-
185- # need to change according to the construction of DNN
186- alpha2 = 0.0
187- for i in 1 : length (friction. dnnChain)
188- xin = StatsBase. transform (friction. dtx[i], (reshape (vcat (vx, vy, vxdx, vxdy, vydx, vydy, bed, h), 8 , :)))
189- pred = StatsBase. reconstruct (friction. dty[i], friction. dnnChain[i](xin))
190- alpha2 += first (pred)
191- end
192- # Average
193- alpha2 = alpha2 / length (friction. dnnChain)
194- if ( (vmag == 0.0 ) | (alpha2 < 0.0 ) )
156+ if (vmag == 0.0 )
195157 alpha2 = 0.0
196158 else
197- alpha2 = alpha2 ./ vmag
159+ alpha2 = c ^ 2 * vmag^ 2
198160 end
199161 return alpha2
200162end # }}}
0 commit comments