Changeset 26705


Ignore:
Timestamp:
12/03/21 11:18:50 (3 years ago)
Author:
Mathieu Morlighem
Message:

CHG: added subelement GL calculation

Location:
issm/trunk-jpl/src/jl/solve
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified issm/trunk-jpl/src/jl/solve/analyses/stressbalanceanalysis.jl

    r26704 r26705  
    4444        FetchDataToInput(md,inputs,elements,md.initialization.vx./md.constants.yts,VxEnum)
    4545        FetchDataToInput(md,inputs,elements,md.initialization.vy./md.constants.yts,VyEnum)
    46 
    47         FetchDataToInput(md,inputs,elements,md.friction.coefficient,FrictionCoefficientEnum)
     46        FetchDataToInput(md,inputs,elements,md.mask.ice_levelset, MaskIceLevelsetEnum)
     47        FetchDataToInput(md,inputs,elements,md.mask.ocean_levelset, MaskOceanLevelsetEnum)
     48
     49        #Deal with friction
     50        if typeof(md.friction)==BuddFriction
     51                FetchDataToInput(md,inputs,elements,md.friction.coefficient,FrictionCoefficientEnum)
     52        else
     53                error("Friction ", typeof(md.friction), " not supported yet")
     54        end
    4855
    4956end#}}}
     
    5360        AddParam(parameters,md.stressbalance.abstol,StressbalanceAbstolEnum)
    5461        AddParam(parameters,md.stressbalance.maxiter,StressbalanceMaxiterEnum)
     62
     63        #Deal with friction
     64        if typeof(md.friction)==BuddFriction
     65                AddParam(parameters, 1, FrictionLawEnum)
     66        else
     67                error("Friction ", typeof(md.friction), " not supported yet")
     68        end
    5569end#}}}
    5670
     
    104118
    105119        #Add basal friction
    106         basis = Vector{Float64}(undef,numnodes)
    107         friction = Friction(element)
    108 
    109         #Start integrating
    110         gauss = GaussTria(2)
    111         for ig in 1:gauss.numgauss
    112 
    113                 Jdet = JacobianDeterminant(xyz_list, gauss)
    114                 NodalFunctions(element, basis, gauss, ig, P1Enum)
    115 
    116                 alpha2 = Alpha2(friction, gauss, ig)
    117 
    118                 for i in 1:numnodes
    119                         for j in 1:numnodes
    120                                 Ke.values[2*i-1,2*j-1] += gauss.weights[ig]*Jdet*alpha2*basis[i]*basis[j]
    121                                 Ke.values[2*i  ,2*j  ] += gauss.weights[ig]*Jdet*alpha2*basis[i]*basis[j]
     120        phi=GetGroundedPortion(element, xyz_list)
     121
     122        if(phi>0)
     123                basis = Vector{Float64}(undef,numnodes)
     124                friction = CoreFriction(element)
     125
     126                #Start integrating
     127                gauss = GaussTria(2)
     128                for ig in 1:gauss.numgauss
     129
     130                        Jdet = JacobianDeterminant(xyz_list, gauss)
     131                        NodalFunctions(element, basis, gauss, ig, P1Enum)
     132
     133                        alpha2 = Alpha2(friction, gauss, ig)
     134
     135                        for i in 1:numnodes
     136                                for j in 1:numnodes
     137                                        Ke.values[2*i-1,2*j-1] += gauss.weights[ig]*Jdet*phi*alpha2*basis[i]*basis[j]
     138                                        Ke.values[2*i  ,2*j  ] += gauss.weights[ig]*Jdet*phi*alpha2*basis[i]*basis[j]
     139                                end
    122140                        end
    123141                end
    124142        end
    125        
    126143
    127144        return Ke
  • TabularUnified issm/trunk-jpl/src/jl/solve/elements.jl

    r26681 r26705  
    8989
    9090end # }}}
     91function GetInputListOnVertices!(element::Tria, vector::Vector{Float64}, enum::IssmEnum) # {{{
     92
     93        #Get Input first
     94        input = GetInput(element, enum)
     95
     96        #Get value at each vertex (i.e. P1 Nodes)
     97        gauss=GaussTria(P1Enum)
     98        for i in 1:gauss.numgauss
     99                vector[i] = GetInputValue(input, gauss, i)
     100        end
     101
     102end # }}}
    91103function FindParam(element::Tria,enum::IssmEnum) # {{{
    92104
     
    107119
    108120end # }}}
     121function GetGroundedPortion(element::Tria, xyz_list::Matrix{Float64}) #{{{
     122
     123        level = Vector{Float64}(undef,3)
     124        GetInputListOnVertices!(element, level, MaskOceanLevelsetEnum)
     125
     126        #Be sure that values are not zero
     127        epsilon = 1.e-15
     128        for i in 1:3
     129                if(level[i]==0.) level[i]=level[i]+epsilon end
     130        end
     131
     132        if level[1]>0 && level[2]>0 && level[3]>0
     133      #Completely grounded
     134                phi = 1.0
     135   elseif level[1]<0 && level[2]<0 && level[3]<0
     136      #Completely floating
     137      phi = 0.0
     138   else
     139                #Partially floating,
     140                if(level[1]*level[2]>0) #Nodes 0 and 1 are similar, so points must be found on segment 0-2 and 1-2
     141                        s1=level[3]/(level[3]-level[2]);
     142                        s2=level[3]/(level[3]-level[1]);
     143                elseif(level[2]*level[3]>0) #Nodes 1 and 2 are similar, so points must be found on segment 0-1 and 0-2
     144                        s1=level[1]/(level[1]-level[2]);
     145                        s2=level[1]/(level[1]-level[3]);
     146                elseif(level[1]*level[3]>0) #Nodes 0 and 2 are similar, so points must be found on segment 1-0 and 1-2
     147                        s1=level[2]/(level[2]-level[1]);
     148                        s2=level[2]/(level[2]-level[3]);
     149                else
     150                        error("not supposed to be here...")
     151                end
     152
     153                if(level[1]*level[2]*level[3]>0)
     154                        phi = s1*s2
     155                else
     156                        phi = (1-s1*s2)
     157                end
     158        end
     159
     160        return phi
     161end#}}}
    109162
    110163#Finite Element stuff
  • TabularUnified issm/trunk-jpl/src/jl/solve/friction.jl

    r26704 r26705  
    11#Friction class definition
    2 struct Friction#{{{
     2
     3abstract type CoreFriction end
     4struct CoreBuddFriction#{{{
    35        H_input::ElementInput
    46        b_input::ElementInput
     
    810        g::Float64
    911end# }}}
    10 function Friction(element::Tria) #{{{
     12function CoreFriction(element::Tria) #{{{
    1113
    12         H_input  = GetInput(element, ThicknessEnum)
    13         b_input  = GetInput(element, BaseEnum)
    14         c_input  = GetInput(element, FrictionCoefficientEnum)
     14        frictionlaw = FindParam(element, FrictionLawEnum)
    1515
    16         rho_ice   = FindParam(element, MaterialsRhoIceEnum)
    17         rho_water = FindParam(element, MaterialsRhoSeawaterEnum)
    18         g         = FindParam(element, ConstantsGEnum)
     16        if frictionlaw==1
     17                H_input  = GetInput(element, ThicknessEnum)
     18                b_input  = GetInput(element, BaseEnum)
     19                c_input  = GetInput(element, FrictionCoefficientEnum)
    1920
    20         return Friction(H_input, b_input, c_input, rho_ice, rho_water, g)
     21                rho_ice   = FindParam(element, MaterialsRhoIceEnum)
     22                rho_water = FindParam(element, MaterialsRhoSeawaterEnum)
     23                g         = FindParam(element, ConstantsGEnum)
     24
     25                return CoreBuddFriction(H_input, b_input, c_input, rho_ice, rho_water, g)
     26        else
     27                error("Friction ",typeof(md.friction)," not supported yet")
     28        end
    2129end#}}}
    2230
    2331#vertices functions
    24 function Alpha2(friction::Friction, gauss::GaussTria, i::Int64) #{{{
     32function Alpha2(friction::CoreBuddFriction, gauss::GaussTria, i::Int64) #{{{
    2533
    2634        #Get effective pressure
Note: See TracChangeset for help on using the changeset viewer.