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 DistributeDofs(node::Node,setenum::IssmEnum,dofcount::Int64) #{{{
|
---|
35 |
|
---|
36 | if setenum==GsetEnum
|
---|
37 | for i=1:node.gsize
|
---|
38 | node.gdoflist[i] = dofcount
|
---|
39 | dofcount += 1
|
---|
40 | end
|
---|
41 | elseif setenum==FsetEnum
|
---|
42 | for i=1:node.gsize
|
---|
43 | if node.fdoflist[i]!=-1
|
---|
44 | @assert node.sdoflist[i]==-1
|
---|
45 | node.fdoflist[i] = dofcount
|
---|
46 | dofcount += 1
|
---|
47 | end
|
---|
48 | end
|
---|
49 | elseif setenum==SsetEnum
|
---|
50 | for i=1:node.gsize
|
---|
51 | if node.sdoflist[i]!=-1
|
---|
52 | @assert node.fdoflist[i]==-1
|
---|
53 | node.sdoflist[i] = dofcount
|
---|
54 | dofcount += 1
|
---|
55 | end
|
---|
56 | end
|
---|
57 | else
|
---|
58 | error("not supported")
|
---|
59 | end
|
---|
60 |
|
---|
61 | return dofcount
|
---|
62 | end# }}}
|
---|
63 | function GetNumberOfDofs(node::Node,setenum::IssmEnum) #{{{
|
---|
64 |
|
---|
65 | if setenum==GsetEnum
|
---|
66 | dofcount = node.gsize
|
---|
67 | elseif setenum==FsetEnum
|
---|
68 | dofcount = 0
|
---|
69 | for i=1:node.gsize
|
---|
70 | if node.fdoflist[i]!=-1
|
---|
71 | dofcount += 1
|
---|
72 | end
|
---|
73 | end
|
---|
74 | elseif setenum==SsetEnum
|
---|
75 | dofcount = 0
|
---|
76 | for i=1:node.gsize
|
---|
77 | if node.sdoflist[i]!=-1
|
---|
78 | dofcount += 1
|
---|
79 | end
|
---|
80 | end
|
---|
81 | else
|
---|
82 | error("not supported")
|
---|
83 | end
|
---|
84 |
|
---|
85 | return dofcount
|
---|
86 |
|
---|
87 | end# }}}
|
---|
88 | function GetDofList(node::Node,doflist::Vector{Int64},count::Int64,setenum::IssmEnum) #{{{
|
---|
89 |
|
---|
90 | if setenum==GsetEnum
|
---|
91 | for i in 1:node.gsize
|
---|
92 | count += 1
|
---|
93 | doflist[count] = node.gdoflist[i]
|
---|
94 | end
|
---|
95 | elseif setenum==FsetEnum
|
---|
96 | for i=1:node.gsize
|
---|
97 | #if node.fdoflist[i]!=-1
|
---|
98 | count += 1
|
---|
99 | doflist[count] = node.fdoflist[i]
|
---|
100 | #end
|
---|
101 | end
|
---|
102 | elseif setenum==SsetEnum
|
---|
103 | for i=1:node.gsize
|
---|
104 | #if node.sdoflist[i]!=-1
|
---|
105 | count += 1
|
---|
106 | doflist[count] = node.sdoflist[i]
|
---|
107 | #end
|
---|
108 | end
|
---|
109 | else
|
---|
110 | error("not supported")
|
---|
111 | end
|
---|
112 |
|
---|
113 | return count
|
---|
114 |
|
---|
115 | end# }}}
|
---|
116 | function 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 | @assert count==ndofs
|
---|
127 |
|
---|
128 | return doflist
|
---|
129 |
|
---|
130 | end# }}}
|
---|
131 | function VecReduce(node::Node,ug::Vector{Float64},uf::Vector{Float64}) #{{{
|
---|
132 |
|
---|
133 | for i=1:node.gsize
|
---|
134 | if node.fdoflist[i]!=-1
|
---|
135 | uf[node.fdoflist[i]] = ug[node.gdoflist[i]]
|
---|
136 | end
|
---|
137 | end
|
---|
138 |
|
---|
139 | end# }}}
|
---|
140 |
|
---|
141 | #Nodes functions
|
---|
142 | function RequiresDofReindexing(nodes::Vector{Node}) #{{{
|
---|
143 |
|
---|
144 | for i in 1:length(nodes)
|
---|
145 | if nodes[i].indexingupdate
|
---|
146 | return true
|
---|
147 | end
|
---|
148 | end
|
---|
149 |
|
---|
150 | return false
|
---|
151 |
|
---|
152 | end# }}}
|
---|
153 | function DistributeDofs(nodes::Vector{Node},setenum::IssmEnum) #{{{
|
---|
154 |
|
---|
155 | dofcount = 1
|
---|
156 |
|
---|
157 | for i in 1:length(nodes)
|
---|
158 | dofcount = DistributeDofs(nodes[i],setenum,dofcount)
|
---|
159 | end
|
---|
160 |
|
---|
161 |
|
---|
162 | end# }}}
|
---|
163 | function NumberOfDofs(nodes::Vector{Node},setenum::IssmEnum) #{{{
|
---|
164 |
|
---|
165 | numdofs = 0
|
---|
166 | for i in 1:length(nodes)
|
---|
167 | numdofs += GetNumberOfDofs(nodes[i],setenum)
|
---|
168 | end
|
---|
169 | return numdofs
|
---|
170 |
|
---|
171 | end# }}}
|
---|