-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathNLHingeNonLin.cpp
executable file
·95 lines (69 loc) · 2.01 KB
/
NLHingeNonLin.cpp
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
#include <math.h>
#include "NLHingeNonLin.hpp"
NLHingeNonLin::NLHingeNonLin(Node **nodes, int nNodes,
double K1, double K2, double My) : Element(nodes, nNodes) {
if(nNodes != 2) {
// BORK!!
cerr << "Non-linear hinge objects can only be associated w/ two nodes"
<< endl;
exit(1);
}
for(int i = 0; i < nNodes; i++) {
if(nodes[i]->nDoF != 3) {
// BORK!!
cerr << "Non-linear hinges must connect nodes w/ 3 DoFs!" << endl;
exit(2);
}
}
this->K1 = K1;
this->K2 = K2;
this->dP = (My/K1);
// sanity check
if(nDoF != 6) {
// BORK !!!
cerr << "NLHingeNonLin really ought to have 6 DoFs" << endl;
exit(1);
}
double dx = nodes[1]->Xo[0] - nodes[0]->Xo[0];
cerr << "dx = " << dx << endl;
double dy = nodes[1]->Xo[1] - nodes[0]->Xo[1];
cerr << "dy = " << dy << endl;
double L = sqrt(dx*dx + dy*dy);
cerr << "length of element is " << L << endl;
K[0][0] = K[1][1] = K[3][3] = K[4][4] = 1000000000000.0;
K[0][3] = K[3][0] = K[1][4] = K[4][1] = 1000000000000.0;
K[2][2] = K[5][5] = K1;
K[2][5] = K[5][2] = -K1;
cerr << K[0][0] << endl;
for(int i = 0; i < nDoF; i++)
for(int j = 0; j < nDoF; j++)
Ko[i][j] = K[i][j];
for(int i = 0; i < nDoF; i++) {
for(int j = 0; j < nDoF; j++)
cerr << Ko[i][j] << ", ";
cerr << endl;
}
}
int NLHingeNonLin::getElementK(double** K) {
P = nodes[1]->X[2] - nodes[0]->X[2];
if (P > (Po + dP)){
Po = P - dP;
this->K[2][2] = this->K[5][5] = K2;
this->K[2][5] = this->K[5][2] = -K2;
}else if(P < (Po - dP)){
Po = P + dP;
this->K[2][2] = this->K[5][5] = K2;
this->K[2][5] = this->K[5][2] = -K2;
}else{
this->K[2][2] = this->K[5][5] = K1;
this->K[2][5] = this->K[5][2] = -K1;
}
cout << ".";
for(int i = 0; i < nDoF; i++)
for(int j = 0; j < nDoF; j++)
K[i][j] = this->K[i][j];
return 0;
}
bool NLHingeNonLin::isLinear() {
return false;
}