Changeset 26658


Ignore:
Timestamp:
11/23/21 07:13:52 (3 years ago)
Author:
Mathieu Morlighem
Message:

CHG: started working on element matrices

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

Legend:

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

    r26655 r26658  
    6666
    6767end #}}}
     68function CreateKMatrix(analysis::StressbalanceAnalysis,element::Tria)# {{{
     69
     70        #Initialize Element matrix
     71        Ke = ElementMatrix(element.nodes)
     72
     73        return Ke
     74end #}}}
    6875function GetSolutionFromInputs(analysis::StressbalanceAnalysis,ug::Vector{Float64},element::Tria) #{{{
    6976
  • issm/trunk-jpl/src/jl/solve/elementmatrix.jl

    r26655 r26658  
    77end #}}}
    88function ElementMatrix(nodes::Vector{Node})#{{{
    9         error("not implemented yet")
     9
     10        #Get matrix size
     11        nrows = NumberOfDofs(nodes,GsetEnum)
     12
     13        #Initialize element matrix with zeros
     14        values = zeros(nrows,nrows)
     15
     16        #Get dof lists
     17        gglobaldoflist=GetGlobalDofList(nodes,nrows,GsetEnum)
     18        fglobaldoflist=GetGlobalDofList(nodes,nrows,FsetEnum)
     19        sglobaldoflist=GetGlobalDofList(nodes,nrows,SsetEnum)
     20
     21        return ElementMatrix(nrows,gglobaldoflist,fglobaldoflist,sglobaldoflist,values)
    1022end#}}}
     23function Base.show(io::IO, this::ElementMatrix)# {{{
     24
     25        println(io,"ElementMatrix:")
     26        println(io,"   nrows: ",this.nrows)
     27        println(io,"   gglobaldoflist: ",this.gglobaldoflist)
     28        println(io,"   fglobaldoflist: ",this.fglobaldoflist)
     29        println(io,"   sglobaldoflist: ",this.sglobaldoflist)
     30        print(io,"   values: ")
     31        display(this.values)
     32end# }}}
     33
     34mutable struct ElementVector#{{{
     35        nrows::Int64
     36        fglobaldoflist::Vector{Int64}
     37        values::Vector{Float64}
     38end #}}}
     39function ElementVector(nodes::Vector{Node})#{{{
     40
     41        #Get matrix size
     42        nrows = NumberOfDofs(nodes,GsetEnum)
     43
     44        #Initialize element matrix with zeros
     45        values = zeros(nrows,nrows)
     46
     47        #Get dof list
     48        fglobaldoflist=GetGlobalDofList(nodes,nrows,FsetEnum)
     49
     50        return ElementVector(nrows,fglobaldoflist,values)
     51end#}}}
     52function Base.show(io::IO, this::ElementVector)# {{{
     53
     54        println(io,"ElementVector:")
     55        println(io,"   nrows: ",this.nrows)
     56        println(io,"   gglobaldoflist: ",this.gglobaldoflist)
     57        println(io,"   fglobaldoflist: ",this.fglobaldoflist)
     58        println(io,"   sglobaldoflist: ",this.sglobaldoflist)
     59        print(io,"   values: ")
     60        display(this.values)
     61end# }}}
  • issm/trunk-jpl/src/jl/solve/nodes.jl

    r26652 r26658  
    9595        elseif setenum==FsetEnum
    9696                for i=1:node.gsize
    97                         if  node.fdoflist[i]!=-1
     97                        #if  node.fdoflist[i]!=-1
    9898                                count += 1
    9999                                doflist[count] = node.fdoflist[i]
    100                         end
     100                        #end
    101101                end
    102102        elseif setenum==SsetEnum
    103103                for i=1:node.gsize
    104                         if  node.sdoflist[i]!=-1
     104                        #if  node.sdoflist[i]!=-1
    105105                                count += 1
    106106                                doflist[count] = node.sdoflist[i]
    107                         end
     107                        #end
    108108                end
    109109        else
     
    112112
    113113        return count
     114
     115end# }}}
     116function GetGlobalDofList(nodes::Vector{Node},ndofs::Int64,setenum::IssmEnum) #{{{
     117
     118        #Allocate list
     119        doflist = Vector{Int64}(undef,ndofs)
     120
     121        #Assign values
     122        count = 0
     123        for i in 1:length(nodes)
     124                count = GetDofList(nodes[i],doflist,count,setenum)
     125        end
     126        println(count," ",ndofs)
     127        @assert count==ndofs
     128
     129        return doflist
    114130
    115131end# }}}
Note: See TracChangeset for help on using the changeset viewer.