source: issm/trunk-jpl/src/jl/solve/nodes.jl@ 26634

Last change on this file since 26634 was 26634, checked in by Mathieu Morlighem, 3 years ago

CHG: updated degrees of freedom

File size: 2.3 KB
Line 
1#Node class definition
2mutable 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}
11end# }}}
12
13#Node functions
14function 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)
25end# }}}
26function 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
33end# }}}
34function 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
62end# }}}
63function 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
87end# }}}
88
89#Nodes functions
90function RequiresDofReindexing(nodes::Vector{Node}) #{{{
91
92 for i in 1:length(nodes)
93 if nodes[i].indexingupdate
94 return true
95 end
96 end
97
98 return false
99
100end# }}}
101function DistributeDofs(nodes::Vector{Node},setenum::IssmEnum) #{{{
102
103 dofcount = 1
104
105 for i in 1:length(nodes)
106 dofcount = DistributeDofs(nodes[i],setenum,dofcount)
107 end
108
109
110end# }}}
111function NumberOfDofs(nodes::Vector{Node},setenum::IssmEnum) #{{{
112
113 numdofs = 0
114 for i in 1:length(nodes)
115 numdofs += GetNumberOfDofs(nodes[i],setenum)
116 end
117 return numdofs
118
119end# }}}
Note: See TracBrowser for help on using the repository browser.