24 bool terminal_output,
bool file_output
81 for (
int i = 0; i < Nd; i++)
90 double t0,
t1, t2, t3, t4, t5, t6, t7, t8;
92 t0, t1, t2, t3, t4, t5, t6, t7, t8, 0.0);
98 Fei[0] = Fei[6] =
density_ * Ax * L * gx / 2.0;
99 Fei[1] = Fei[7] =
density_ * Ax * L * gy / 2.0;
100 Fei[2] = Fei[8] =
density_ * Ax * L * gz / 2.0;
102 Fei[3] =
density_ * Ax * L * L / 12.0 * ((-t3*t7 + t4*t6)*gy + (-t3*t8 + t5*t6)*gz);
103 Fei[4] =
density_ * Ax * L * L / 12.0 * ((-t4*t6 + t3*t7)*gx + (-t4*t8 + t5*t7)*gz);
104 Fei[5] =
density_ * Ax * L * L / 12.0 * ((-t5*t6 + t3*t8)*gx + (-t5*t7 + t4*t8)*gy);
106 Fei[9] =
density_ * Ax * L * L / 12.0 * ((t3*t7 - t4*t6)*gy + (t3*t8 - t5*t6)*gz);
107 Fei[10] =
density_ * Ax * L * L / 12.0 * ((t4*t6 - t3*t7)*gx + (t4*t8 - t5*t7)*gz);
108 Fei[11] =
density_ * Ax * L * L / 12.0 * ((t5*t6 - t3*t8)*gx + (t5*t7 - t4*t8)*gy);
143 for (
int i = 0; i < Nd; i++)
150 for (
int j = 0; j < 6; j++)
155 F_[dual_u * 6 + j] += (*ptr_x)[i] *
Fe_[i][j];
159 F_[dual_v * 6 + j] += (*ptr_x)[i] *
Fe_[i][j + 6];
179 vector<WF_edge *> wf_edge_list = *ptr_frame->
GetEdgeList();
180 vector<WF_vert *> wf_vert_list = *ptr_frame->
GetVertList();
187 double Asy = Ax * (6 + 12 *
v_ + 6 *
v_*
v_) / (7 + 12 *
v_ + 4 *
v_*
v_);
191 double Jxx = 0.5 *
F_PI * r_ * r_ * r_ *
r_;
202 double Iyy =
F_PI * r_ * r_ * r_ * r_ / 4;
205 double t0,
t1, t2, t3, t4, t5, t6, t7, t8;
208 for (
int i = 0; i < Nd; i++)
218 double Le = L - 2 *
nr_;
220 MatrixXd eKuv(12, 12);
223 point node_u = wf_vert_list[u]->Position();
224 point node_v = wf_vert_list[v]->Position();
226 transf_.
CreateTransMatrix(node_u, node_v, t0, t1, t2, t3, t4, t5, t6, t7, t8, 0);
232 Ksy = 12. *
E_ * Izz * fs / (
G_ * Asy * Le * Le);
233 Ksz = 12. *
E_ * Iyy * fs / (
G_ * Asz * Le * Le);
244 eKuv(0,0) = eKuv(6,6) =
E_ * Ax / Le;
245 eKuv(1,1) = eKuv(7,7) = 12. *
E_ * Izz / (Le * Le * Le * (1. + Ksy));
246 eKuv(2,2) = eKuv(8,8) = 12. *
E_ * Iyy / (Le * Le * Le * (1. + Ksz));
247 eKuv(3,3) = eKuv(9,9) =
G_ * Jxx / Le;
248 eKuv(4,4) = eKuv(10,10) = (4. + Ksz) *
E_ * Iyy / (Le * (1. + Ksz));
249 eKuv(5,5) = eKuv(11,11) = (4. + Ksy) *
E_ * Izz / (Le * (1. + Ksy));
251 eKuv(4,2) = eKuv(2,4) = -6. *
E_ * Iyy / (Le * Le * (1. + Ksz));
252 eKuv(5,1) = eKuv(1,5) = 6. *
E_ * Izz / (Le * Le * (1. + Ksy));
253 eKuv(6,0) = eKuv(0,6) = - eKuv(0,0);
255 eKuv(11,7) = eKuv(7,11) = eKuv(7,5) = eKuv(5,7) = -eKuv(5,1);
256 eKuv(10,8) = eKuv(8,10) = eKuv(8,4) = eKuv(4,8) = -eKuv(4,2);
257 eKuv(9,3) = eKuv(3,9) = - eKuv(3,3);
258 eKuv(10, 2) = eKuv(2, 10) = eKuv(4, 2);
259 eKuv(11, 1) = eKuv(1, 11) = eKuv(5, 1);
261 eKuv(7,1) = eKuv(1,7) = -eKuv(1,1);
262 eKuv(8,2) = eKuv(2,8) = -eKuv(2,2);
263 eKuv(10,4) = eKuv(4,10) = (2. - Ksz) *
E_ * Iyy / (Le * (1. + Ksz));
264 eKuv(11,5) = eKuv(5,11) = (2. - Ksy) *
E_ * Izz / (Le * (1. + Ksy));
266 transf_.
TransLocToGlob(t0, t1, t2, t3, t4, t5, t6, t7, t8, eKuv, 0, 0);
268 for (
int k = 0; k < 12; k++)
270 for (
int l = k + 1; l < 12; l++)
272 if (eKuv(k, l) != eKuv(l, k))
274 if (fabs(eKuv(k,l) / eKuv(l,k) - 1.0) >
SPT_EPS 276 (fabs(eKuv(k, l) / eKuv(k, k)) >
SPT_EPS || fabs(eKuv(l, k) / eKuv(k, k)) >
SPT_EPS)
279 fprintf(stderr,
"elastic_K: element stiffness matrix not symetric ...\n");
280 fprintf(stderr,
" ... k[%d][%d] = %15.6e \n", k, l, eKuv(k,l));
281 fprintf(stderr,
" ... k[%d][%d] = %15.6e ", l, k, eKuv(l,k));
282 fprintf(stderr,
" ... relative error = %e \n", fabs(eKuv(k,l) / eKuv(l,k) - 1.0));
285 eKuv(k, l) = eKuv(l, k) = (eKuv(k, l) + eKuv(l, k)) / 2;
319 vector<Triplet<double>> K_list;
322 for (
int i = 0; i < Nd; i++)
331 if (dual_u <
Ns_ && dual_v <
Ns_)
334 for (
int k = 0; k < 6; k++)
336 for (
int l = 0; l < 6; l++)
340 tmp = (*ptr_x)[i] *
eK_[i](k, l);
343 K_list.push_back(Triplet<double>(dual_u * 6 + k, dual_u * 6 + l, tmp));
346 tmp = (*ptr_x)[i] *
eK_[i](k + 6, l + 6);
349 K_list.push_back(Triplet<double>(dual_v * 6 + k, dual_v * 6 + l, tmp));
352 tmp = (*ptr_x)[i] *
eK_[i](k, l + 6);
355 K_list.push_back(Triplet<double>(dual_u * 6 + k, dual_v * 6 + l, tmp));
358 tmp = (*ptr_x)[i] *
eK_[i](k + 6, l);
361 K_list.push_back(Triplet<double>(dual_v * 6 + k, dual_u * 6 + l, tmp));
370 for (
int k = 0; k < 6; k++)
372 for (
int l = 0; l < 6; l++)
374 double tmp = (*ptr_x)[i] *
eK_[i](k, l);
377 K_list.push_back(Triplet<double>(dual_u * 6 + k, dual_u * 6 + l, tmp));
385 for (
int k = 0; k < 6; k++)
387 for (
int l = 0; l < 6; l++)
389 double tmp = (*ptr_x)[i] *
eK_[i](k + 6, l + 6);
392 K_list.push_back(Triplet<double>(dual_v * 6 + k, dual_v * 6 + l, tmp));
398 K_.setFromTriplets(K_list.begin(), K_list.end());
409 bool cond_num,
int file_id,
string file_name
434 fprintf(stdout,
"Stiffness : Linear Elastic Analysis ... Element Gravity Loads\n");
439 cout <<
"Stiffness Solver fail!\n" << endl;
462 int file_id,
string file_name
484 fprintf(stdout,
"Stiffness : Linear Elastic Analysis ... Element Gravity Loads\n");
490 cout <<
"Stiffness Solver fail!\n" << endl;
517 bool bSuccess =
true;
520 printf(
"Condition Number = %9.3e\n", cond_num);
526 printf(
" * Acceptable Matrix! *\n");
532 printf(
" * Ill Conditioned Stiffness Matrix! *\n");
533 printf(
"Press any key to exit...\n");
553 bool bSuccess =
true;
557 printf(
"Root Mean Square (RMS) equilibrium error = %9.3e\n", error);
564 printf(
" * Converged *\n");
570 printf(
" !! Not Converged !!\n");
571 printf(
"Press any key to exit...\n");
594 for (
int i = 0; i <
Ns_ * 6; i++)
602 sprintf(iname,
"%d",
id);
605 string fpath = path +
'/' + fname + iname +
".3dd";
606 string meshpath = path +
'/' + fname + iname +
"-msh";
607 string plotpath = path +
'/' + fname + iname +
".plt";
609 double exagg_static = 5;
626 for (
int i = 0; i < 6; i++)
628 for (
int j = 0; j < 6; j++)
630 tmpK(i, j) =
eK_[dual_id](i, j + 6);
636 for (
int i = 0; i < 6; i++)
638 for (
int j = 0; j < 6; j++)
640 tmpK(i, j) =
eK_[dual_id](i + 6, j);
657 for (
int i = 0; i < 6; i++)
659 for (
int j = 0; j < 6; j++)
661 tmpK(i, j) =
eK_[dual_id](i, j);
667 for (
int i = 0; i < 6; i++)
669 for (
int j = 0; j < 6; j++)
671 tmpK(i, j) =
eK_[dual_id](i + 6, j + 6);
688 for (
int j = 0; j < 6; j++)
690 tmpF[j] =
Fe_[dual_id][j];
695 for (
int j = 0; j < 6; j++)
697 tmpF[j] =
Fe_[dual_id][j + 6];
708 printf(
"***Stiffness timer result:\n");
720 printf(
"***Stiffness detailed timing turned off.\n");
bool CheckError(IllCondDetector &stiff_inspector, VX &D)
bool CalculateD(VX &D, VX *ptr_x=NULL, bool cond_num=false, int file_id=0, string file_name="")
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t0
GLenum GLenum GLenum GLenum GLenum scale
GLsizei const GLchar *const * path
void WriteData(VectorXd &D, int id=0, string fname="stiff_data")
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t1
void GnuPltStaticMesh(const char *fpath, const char *meshpath, const char *plotpath, VX &D, double exagg_static, float scale, DualGraph *ptr_dualgraph, WireFrame *ptr_frame)
StiffnessSolver stiff_solver_
vector< WF_edge * > * GetEdgeList()
double EquilibriumError(EigenSp const &K, VX const &D, VX const &F)
void TransLocToGlob(double t0, double t1, double t2, double t3, double t4, double t5, double t6, double t7, double t8, MX &m, float r1, float r2)
DualGraph * ptr_dualgraph_
void WriteInputData(const char *fpath, DualGraph *ptr_dualgraph, FiberPrintPARM *ptr_parm, int verbose)
bool SolveSystem(SpMat &K, VX &D, VX &F, int verbose, int &info)
void CreateGlobalK(VX *ptr_x=NULL)
void CreateF(VX *ptr_x=NULL)
vector< WF_vert * > * GetVertList()
FiberPrintPARM * ptr_parm_
void CreateTransMatrix(std::vector< V3 > xyz, double L, int n1, int n2, double &t0, double &t1, double &t2, double &t3, double &t4, double &t5, double &t6, double &t7, double &t8, float p)
bool CheckIllCondition(IllCondDetector &stiff_inspector)