-
Notifications
You must be signed in to change notification settings - Fork 58
/
Copy pathParametricSpring.cs
204 lines (159 loc) · 5.62 KB
/
ParametricSpring.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
using BriefFiniteElementNet.ElementHelpers;
using BriefFiniteElementNet.Elements.ElementHelpers;
namespace BriefFiniteElementNet.Elements.Elements
{
/// <summary>
/// represents a two noded parametric spring, parameters are copied to global stiffness matrix exactly without any modification or transform
/// </summary>
public class ParametricSpring : Element,ISerializable
{
#region proerties
/// <summary>
/// stiffness in global dof DX
/// </summary>
public double KDx { get; set; }
/// <summary>
/// stiffness in global dof DY
/// </summary>
public double KDy { get; set; }
/// <summary>
/// stiffness in global dof DZ
/// </summary>
public double KDz { get; set; }
/// <summary>
/// stiffness in global dof RX
/// </summary>
public double KRx { get; set; }
/// <summary>
/// stiffness in global dof RY
/// </summary>
public double KRy { get; set; }
/// <summary>
/// stiffness in global dof RZ
/// </summary>
public double KRz { get; set; }
/// <summary>
/// Gets or sets the start node.
/// </summary>
/// <value>
/// The start node of <see cref="BarElement"/>.
/// </value>
public Node StartNode
{
get { return nodes[0]; }
set { nodes[0] = value; }
}
/// <summary>
/// Gets or sets the end node.
/// </summary>
/// <value>
/// The end node of <see cref="BarElement"/>.
/// </value>
public Node EndNode
{
get { return nodes[1]; }
set { nodes[1] = value; }
}
#endregion
/// <summary>
/// Initializes a new instance of the <see cref="BarElement"/> class.
/// </summary>
/// <param name="n1">The n1.</param>
/// <param name="n2">The n2.</param>
public ParametricSpring(Node n1, Node n2) : base(2)
{
StartNode = n1;
EndNode = n2;
}
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
info.AddValue(nameof(KDx), KDx);
info.AddValue(nameof(KDy), KDy);
info.AddValue(nameof(KDz), KDz);
info.AddValue(nameof(KRx), KRx);
info.AddValue(nameof(KRy), KRy);
info.AddValue(nameof(KRz), KRz);
base.GetObjectData(info, context);
}
protected ParametricSpring(SerializationInfo info, StreamingContext context) : base(info, context)
{
KDx = info.GetDouble(nameof(KDx));
KDy = info.GetDouble(nameof(KDy));
KDz = info.GetDouble(nameof(KDz));
KRx = info.GetDouble(nameof(KRx));
KRy = info.GetDouble(nameof(KRy));
KRz = info.GetDouble(nameof(KRz));
}
#region Element methods
public Matrix GetGlobalStifnessMatrix()
{
var helpers = GetHelpers();
var buf = MatrixPool.Allocate(12, 12); // 2 node
for (var i = 0; i < helpers.Length; i++)
{
var helper = helpers[i];
var ki = helper.CalcLocalStiffnessMatrix(this);
var dofs = helper.GetDofOrder(this);
for (var ii = 0; ii < dofs.Length; ii++)
{
var bi = dofs[ii].NodeIndex * 6 + (int)dofs[ii].Dof;
for (var jj = 0; jj < dofs.Length; jj++)
{
var bj = dofs[jj].NodeIndex * 6 + (int)dofs[jj].Dof;
buf[bi, bj] += ki[ii, jj];
}
}
}
return buf;
}
public override Matrix GetGlobalMassMatrix()
{
var buf = new Matrix(6, 6);
return buf;
}
public override Matrix GetGlobalDampingMatrix()
{
var buf = new Matrix(6, 6);
return buf;
}
public override Force[] GetGlobalEquivalentNodalLoads(ElementalLoad load)
{
throw new BriefFiniteElementNetException(string.Format("{0} element cannot have internal loads",
nameof(ParametricSpring)));
}
public override Matrix GetLambdaMatrix()
{
return Matrix.Eye(3);
}
public override double[] IsoCoordsToLocalCoords(params double[] isoCoords)
{
throw new NotImplementedException();
}
public override IElementHelper[] GetHelpers()
{
var helpers = new List<IElementHelper>();
{
helpers.Add(new ParametricSpringHelper() { SpringType = DoF.Dx });
helpers.Add(new ParametricSpringHelper() { SpringType = DoF.Dy });
helpers.Add(new ParametricSpringHelper() { SpringType = DoF.Dz });
helpers.Add(new ParametricSpringHelper() { SpringType = DoF.Rx });
helpers.Add(new ParametricSpringHelper() { SpringType = DoF.Ry });
helpers.Add(new ParametricSpringHelper() { SpringType = DoF.Rz });
}
return helpers.ToArray();
}
public override void GetGlobalStiffnessMatrix(Matrix stiffness)
{
var buf = this.GetGlobalMassMatrix();
buf.CopyTo(stiffness);
buf.ReturnToPool();
}
#endregion
}
}