Changeset 26649


Ignore:
Timestamp:
11/19/21 11:13:48 (3 years ago)
Author:
Mathieu Morlighem
Message:

CHG: done with GetSolutionFromInputs

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

Legend:

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

    r26648 r26649  
    5757        #Get dofs for this finite element
    5858        doflist = GetDofList(element,GsetEnum)
    59         error("S")
     59        @assert length(doflist)==6
     60
     61        #Fetch inputs
     62        vx_input = GetInput(element, VxEnum)
     63        vy_input = GetInput(element, VyEnum)
     64
     65        #Loop over each node and enter solution in ug
     66        count = 0
     67        gauss=GaussTria(P1Enum)
     68        for i in 1:gauss.numgauss
     69                vx = GetInputValue(vx_input, gauss, i)
     70                vy = GetInputValue(vy_input, gauss, i)
     71
     72                count += 1
     73                ug[doflist[count]] = vx
     74                count += 1
     75                ug[doflist[count]] = vy
     76        end
     77
     78        #Make sure we reached all the values
     79        @assert count==length(doflist)
    6080
    6181end#}}}
     
    84104        ug = GetSolutionFromInputsx(analysis,femmodel)
    85105
     106        print(ug)
     107
    86108        #Loop until we reach convergence
    87109        while(~converged)
  • issm/trunk-jpl/src/jl/solve/elements.jl

    r26648 r26649  
    7272        end
    7373
    74         println(doflist)
    75         error("S")
     74        return doflist
     75end # }}}
     76function GetInput(element::Tria,enum::IssmEnum) # {{{
     77
     78        input = GetInput(element.inputs,enum)
     79        InputServe!(element,input)
     80        return input
    7681
    7782end # }}}
     83function InputServe!(element::Tria,input::ElementInput) # {{{
     84
     85        if input.interp==P0Enum
     86                input.element_values[1] = input.values[element.sid]
     87        elseif input.interp==P1Enum
     88                for i in 1:3
     89                        input.element_values[i] = input.values[element.vertices[i].sid]
     90                end
     91        else
     92                error("interpolation ",input.interp," not supported yet")
     93        end
     94
     95end # }}}
  • issm/trunk-jpl/src/jl/solve/gauss.jl

    r26629 r26649  
    2323                coords3 = [0.333333333333333]
    2424        elseif(order==2)
    25                 weights = [0.577350269189625, 0.577350269189625, 0.577350269189625]
    26                 coords1 = [0.666666666666667, 0.166666666666667, 0.166666666666667]
    27                 coords2 = [0.166666666666667, 0.666666666666667, 0.166666666666667]
    28                 coords3 = [0.166666666666667, 0.166666666666667, 0.666666666666667]
     25                weights = [0.577350269189625; 0.577350269189625; 0.577350269189625]
     26                coords1 = [0.666666666666667; 0.166666666666667; 0.166666666666667]
     27                coords2 = [0.166666666666667; 0.666666666666667; 0.166666666666667]
     28                coords3 = [0.166666666666667; 0.166666666666667; 0.666666666666667]
    2929        elseif(order==3)
    3030                npoints=4
    31                 weights = [-0.974278579257493, 0.902109795608790, 0.902109795608790, 0.902109795608790]
    32                 coords1 = [0.333333333333333, 0.600000000000000, 0.200000000000000, 0.200000000000000]
    33                 coords2 = [0.333333333333333, 0.200000000000000, 0.600000000000000, 0.200000000000000]
    34                 coords3 = [0.333333333333333, 0.200000000000000, 0.200000000000000, 0.600000000000000]
     31                weights = [-0.974278579257493; 0.902109795608790; 0.902109795608790; 0.902109795608790]
     32                coords1 = [ 0.333333333333333; 0.600000000000000; 0.200000000000000; 0.200000000000000]
     33                coords2 = [ 0.333333333333333; 0.200000000000000; 0.600000000000000; 0.200000000000000]
     34                coords3 = [ 0.333333333333333; 0.200000000000000; 0.200000000000000; 0.600000000000000]
    3535        else
    3636                error("order ",order," not supported yet");
     
    3939        return GaussTria(npoints,weights,coords1,coords2,coords3)
    4040end# }}}
     41function GaussTria(finiteelement::IssmEnum) #{{{
    4142
     43        if(finiteelement==P0Enum)
     44                npoints = 1
     45                weights = [1.]
     46                coords1 = [0.333333333333333]
     47                coords2 = [0.333333333333333]
     48                coords3 = [0.333333333333333]
     49        elseif(finiteelement==P1Enum)
     50                        npoints = 3
     51                        weights = 0.333333333333333*ones(3)
     52                        coords1 = [1.; 0.; 0.]
     53                        coords2 = [0.; 1.; 0.]
     54                        coords3 = [0.; 0.; 1.]
     55        else
     56                error("finite element ", finiteelement," not supported yet");
     57        end
     58
     59        return GaussTria(npoints,weights,coords1,coords2,coords3)
     60end# }}}
  • issm/trunk-jpl/src/jl/solve/inputs.jl

    r26629 r26649  
    1313        interp::IssmEnum
    1414        values::Vector{Float64}
     15        element_values::Vector{Float64}
    1516end# }}}
    1617
     
    2324
    2425#Inputs functions
     26function GetInput(inputs::Inputs,enum::IssmEnum) #{{{
     27
     28        #Does this input exist
     29        if !haskey(inputs.lookup,enum)
     30                error("Input ",enum," not found")
     31        end
     32
     33        #return input
     34        return inputs.lookup[enum]
     35
     36end#}}}
    2537function SetInput(inputs::Inputs,enum::IssmEnum,index::Int64,value::Bool) #{{{
    2638
     
    4860                @assert inputs.numberofelements > 0
    4961                if interp==P0Enum
    50                         inputs.lookup[enum] = ElementInput(enum,interp,zeros(inputs.numberofelements))
     62                        inputs.lookup[enum] = ElementInput(enum,interp,zeros(inputs.numberofelements),Vector{Float64}(undef,1))
    5163                elseif interp==P1Enum
    52                         inputs.lookup[enum] = ElementInput(enum,interp,zeros(inputs.numberofvertices))
     64                        inputs.lookup[enum] = ElementInput(enum,interp,zeros(inputs.numberofvertices),Vector{Float64}(undef,3))
    5365                else
    5466                        error("not supported yet")
     
    7183                @assert inputs.numberofvertices>0
    7284                if interp==P1Enum
    73                         inputs.lookup[enum] = ElementInput(enum,interp,zeros(inputs.numberofvertices))
     85                        inputs.lookup[enum] = ElementInput(enum,interp,zeros(inputs.numberofvertices),Vector{Float64}(undef,3))
    7486                else
    7587                        error("not supported yet")
     
    8597        input.values[indices] = values
    8698end#}}}
     99function GetInputValue(input::ElementInput,gauss::GaussTria,i::Int64)
     100
     101        if input.interp==P0Enum
     102                return input.element_value
     103        elseif input.interp==P1Enum
     104                value = input.element_values[1]*gauss.coords1[i] +  input.element_values[2]*gauss.coords2[i] +  input.element_values[3]*gauss.coords3[i]
     105        else
     106                error("not implemented yet")
     107        end
     108
     109        return value
     110
     111end#}}}
  • issm/trunk-jpl/src/jl/solve/solve.jl

    r26629 r26649  
    11include("../md/classes.jl")
    22include("./issmenums.jl")
     3include("./gauss.jl")
    34include("./parameters.jl")
    45include("./inputs.jl")
     
    910include("./femmodel.jl")
    1011include("./analyses.jl")
    11 include("./gauss.jl")
    1212include("./modules.jl")
    1313
Note: See TracChangeset for help on using the changeset viewer.