| 1 | #Node class definition
|
|---|
| 2 | mutable struct Node #{{{
|
|---|
| 3 | id::Int64
|
|---|
| 4 | sid::Int64
|
|---|
| 5 | indexingupdate::Bool
|
|---|
| 6 | gsize::Int64
|
|---|
| 7 | gdoflist::Vector{Int64}
|
|---|
| 8 | fdoflist::Vector{Int64}
|
|---|
| 9 | sdoflist::Vector{Int64}
|
|---|
| 10 | svalues::Vector{Float64}
|
|---|
| 11 | end# }}}
|
|---|
| 12 |
|
|---|
| 13 | #Node functions
|
|---|
| 14 | function Base.show(io::IO, this::Node)# {{{
|
|---|
| 15 |
|
|---|
| 16 | println(io,"Node:")
|
|---|
| 17 | println(io," id: ",this.id)
|
|---|
| 18 | println(io," sid: ",this.sid)
|
|---|
| 19 | println(io," indexingupdate: ",this.indexingupdate)
|
|---|
| 20 | println(io," gsize: ",this.gsize)
|
|---|
| 21 | println(io," gdoflist: ",this.gdoflist)
|
|---|
| 22 | println(io," fdoflist: ",this.fdoflist)
|
|---|
| 23 | println(io," sdoflist: ",this.sdoflist)
|
|---|
| 24 | println(io," svalues: ",this.svalues)
|
|---|
| 25 | end# }}}
|
|---|
| 26 | function ApplyConstraint(node::Node,dof::Int8,value::Float64) #{{{
|
|---|
| 27 |
|
|---|
| 28 | node.indexingupdate = true
|
|---|
| 29 | node.fdoflist[dof] = -1
|
|---|
| 30 | node.sdoflist[dof] = +1
|
|---|
| 31 | node.svalues[dof] = value
|
|---|
| 32 |
|
|---|
| 33 | end# }}}
|
|---|
| 34 | function CreateNodalConstraints(node::Node,ys::IssmVector) #{{{
|
|---|
| 35 |
|
|---|
| 36 | if(SSize(node)>0)
|
|---|
| 37 | SetValues!(ys,node.gsize,node.sdoflist,node.svalues)
|
|---|
| 38 | end
|
|---|
| 39 |
|
|---|
| 40 | end# }}}
|
|---|
| 41 | function DistributeDofs(node::Node,setenum::IssmEnum,dofcount::Int64) #{{{
|
|---|
| 42 |
|
|---|
| 43 | if setenum==GsetEnum
|
|---|
| 44 | for i=1:node.gsize
|
|---|
| 45 | node.gdoflist[i] = dofcount
|
|---|
| 46 | dofcount += 1
|
|---|
| 47 | end
|
|---|
| 48 | elseif setenum==FsetEnum
|
|---|
| 49 | for i=1:node.gsize
|
|---|
| 50 | if node.fdoflist[i]!=-1
|
|---|
| 51 | @assert node.sdoflist[i]==-1
|
|---|
| 52 | node.fdoflist[i] = dofcount
|
|---|
| 53 | dofcount += 1
|
|---|
| 54 | end
|
|---|
| 55 | end
|
|---|
| 56 | elseif setenum==SsetEnum
|
|---|
| 57 | for i=1:node.gsize
|
|---|
| 58 | if node.sdoflist[i]!=-1
|
|---|
| 59 | @assert node.fdoflist[i]==-1
|
|---|
| 60 | node.sdoflist[i] = dofcount
|
|---|
| 61 | dofcount += 1
|
|---|
| 62 | end
|
|---|
| 63 | end
|
|---|
| 64 | else
|
|---|
| 65 | error("not supported")
|
|---|
| 66 | end
|
|---|
| 67 |
|
|---|
| 68 | return dofcount
|
|---|
| 69 | end# }}}
|
|---|
| 70 | function GetNumberOfDofs(node::Node,setenum::IssmEnum) #{{{
|
|---|
| 71 |
|
|---|
| 72 | if setenum==GsetEnum
|
|---|
| 73 | dofcount = node.gsize
|
|---|
| 74 | elseif setenum==FsetEnum
|
|---|
| 75 | dofcount = 0
|
|---|
| 76 | for i=1:node.gsize
|
|---|
| 77 | if node.fdoflist[i]!=-1
|
|---|
| 78 | dofcount += 1
|
|---|
| 79 | end
|
|---|
| 80 | end
|
|---|
| 81 | elseif setenum==SsetEnum
|
|---|
| 82 | dofcount = 0
|
|---|
| 83 | for i=1:node.gsize
|
|---|
| 84 | if node.sdoflist[i]!=-1
|
|---|
| 85 | dofcount += 1
|
|---|
| 86 | end
|
|---|
| 87 | end
|
|---|
| 88 | else
|
|---|
| 89 | error("not supported")
|
|---|
| 90 | end
|
|---|
| 91 |
|
|---|
| 92 | return dofcount
|
|---|
| 93 |
|
|---|
| 94 | end# }}}
|
|---|
| 95 | function GetDofList(node::Node,doflist::Vector{Int64},count::Int64,setenum::IssmEnum) #{{{
|
|---|
| 96 |
|
|---|
| 97 | if setenum==GsetEnum
|
|---|
| 98 | for i in 1:node.gsize
|
|---|
| 99 | count += 1
|
|---|
| 100 | doflist[count] = node.gdoflist[i]
|
|---|
| 101 | end
|
|---|
| 102 | elseif setenum==FsetEnum
|
|---|
| 103 | for i=1:node.gsize
|
|---|
| 104 | #if node.fdoflist[i]!=-1
|
|---|
| 105 | count += 1
|
|---|
| 106 | doflist[count] = node.fdoflist[i]
|
|---|
| 107 | #end
|
|---|
| 108 | end
|
|---|
| 109 | elseif setenum==SsetEnum
|
|---|
| 110 | for i=1:node.gsize
|
|---|
| 111 | #if node.sdoflist[i]!=-1
|
|---|
| 112 | count += 1
|
|---|
| 113 | doflist[count] = node.sdoflist[i]
|
|---|
| 114 | #end
|
|---|
| 115 | end
|
|---|
| 116 | else
|
|---|
| 117 | error("not supported")
|
|---|
| 118 | end
|
|---|
| 119 |
|
|---|
| 120 | return count
|
|---|
| 121 |
|
|---|
| 122 | end# }}}
|
|---|
| 123 | function GetGlobalDofList(nodes::Vector{Node},ndofs::Int64,setenum::IssmEnum) #{{{
|
|---|
| 124 |
|
|---|
| 125 | #Allocate list
|
|---|
| 126 | doflist = Vector{Int64}(undef,ndofs)
|
|---|
| 127 |
|
|---|
| 128 | #Assign values
|
|---|
| 129 | count = 0
|
|---|
| 130 | for i in 1:length(nodes)
|
|---|
| 131 | count = GetDofList(nodes[i],doflist,count,setenum)
|
|---|
| 132 | end
|
|---|
| 133 | @assert count==ndofs
|
|---|
| 134 |
|
|---|
| 135 | return doflist
|
|---|
| 136 |
|
|---|
| 137 | end# }}}
|
|---|
| 138 | function VecReduce(node::Node,ug::Vector{Float64},uf::IssmVector) #{{{
|
|---|
| 139 |
|
|---|
| 140 | for i=1:node.gsize
|
|---|
| 141 | if node.fdoflist[i]!=-1
|
|---|
| 142 | uf.vector[node.fdoflist[i]] = ug[node.gdoflist[i]]
|
|---|
| 143 | end
|
|---|
| 144 | end
|
|---|
| 145 |
|
|---|
| 146 | end# }}}
|
|---|
| 147 | function SSize(node::Node) #{{{
|
|---|
| 148 |
|
|---|
| 149 | ssize = 0
|
|---|
| 150 |
|
|---|
| 151 | for i=1:node.gsize
|
|---|
| 152 | if node.fdoflist[i]!=-1
|
|---|
| 153 | ssize+=1
|
|---|
| 154 | end
|
|---|
| 155 | end
|
|---|
| 156 |
|
|---|
| 157 | return ssize
|
|---|
| 158 |
|
|---|
| 159 | end# }}}
|
|---|
| 160 |
|
|---|
| 161 | #Nodes functions
|
|---|
| 162 | function RequiresDofReindexing(nodes::Vector{Node}) #{{{
|
|---|
| 163 |
|
|---|
| 164 | for i in 1:length(nodes)
|
|---|
| 165 | if nodes[i].indexingupdate
|
|---|
| 166 | return true
|
|---|
| 167 | end
|
|---|
| 168 | end
|
|---|
| 169 |
|
|---|
| 170 | return false
|
|---|
| 171 |
|
|---|
| 172 | end# }}}
|
|---|
| 173 | function DistributeDofs(nodes::Vector{Node},setenum::IssmEnum) #{{{
|
|---|
| 174 |
|
|---|
| 175 | dofcount = 1
|
|---|
| 176 |
|
|---|
| 177 | for i in 1:length(nodes)
|
|---|
| 178 | dofcount = DistributeDofs(nodes[i],setenum,dofcount)
|
|---|
| 179 | end
|
|---|
| 180 |
|
|---|
| 181 |
|
|---|
| 182 | end# }}}
|
|---|
| 183 | function NumberOfDofs(nodes::Vector{Node},setenum::IssmEnum) #{{{
|
|---|
| 184 |
|
|---|
| 185 | numdofs = 0
|
|---|
| 186 | for i in 1:length(nodes)
|
|---|
| 187 | numdofs += GetNumberOfDofs(nodes[i],setenum)
|
|---|
| 188 | end
|
|---|
| 189 | return numdofs
|
|---|
| 190 |
|
|---|
| 191 | end# }}}
|
|---|