10 assert(fname != NULL);
13 outdir = getenv(
"FRAMEFAB_OUTDIR");
16 if (default_outdir == NULL)
19 outdir = default_outdir;
22 res = sprintf(fullpath,
"%s%c%s", outdir,
'\\', fname);
26 printf(
"ERROR: unable to construct output filename: overflow.\n");
32 printf(
"StiffnessIO->OuputPath: Output file path generated: %s\n", fullpath);
48 const char *meshpath,
const char *plotpath,
50 double exagg_static,
float scale,
57 std::vector<WF_edge*> wf_edge_list = *ptr_wf->
GetEdgeList();
58 std::vector<DualFace*> dual_face_list = *ptr_dualgraph->
GetFaceList();
62 FILE *fpif = NULL, *fpm = NULL;
73 int j = 0,
m = 0,
n = 0,
80 string title =
"Fiber Deform Test";
100 if ((fpm = fopen(plotpath,
"w")) == NULL)
102 sprintf(errMsg,
"\n error: cannot open gnuplot script file: %s \n", plotpath);
108 sprintf(meshfl,
"%sf.%03d", meshpath, 0);
114 fprintf(fpm,
"# FIBERPRINT FRAME STRUCTUAL ANALYSIS RESULTS GCL@USTC");
115 fprintf(fpm,
" VERSION %s \n", std::string(
VERSION).c_str());
116 fprintf(fpm,
"# %s\n", title.c_str());
117 fprintf(fpm,
"# %s", ctime(&now));
118 fprintf(fpm,
"# G N U P L O T S C R I P T F I L E \n");
121 fprintf(fpm,
"set autoscale\n");
122 fprintf(fpm,
"unset border\n");
123 fprintf(fpm,
"set pointsize 1.0\n");
124 fprintf(fpm,
"set xtics; set ytics; set ztics; \n");
125 fprintf(fpm,
"unset zeroaxis\n");
126 fprintf(fpm,
"unset key\n");
127 fprintf(fpm,
"unset label\n");
128 fprintf(fpm,
"set size ratio -1 # 1:1 2D axis scaling \n");
129 fprintf(fpm,
"# set view equal xyz # 1:1 3D axis scaling \n");
131 fprintf(fpm,
"# NODE NUMBER LABELS\n");
132 for (j = 0; j < nN; j++)
136 fprintf(fpm,
"set label ' %d' at %12.4e, %12.4e, %12.4e\n",
140 fprintf(fpm,
"# ELEMENT NUMBER LABELS\n");
141 for (
m = 0;
m < nE;
m++)
144 WF_edge *ei = wf_edge_list[e_id];
149 int dual_u = ptr_dualgraph->
v_dual_id(u);
150 int dual_v = ptr_dualgraph->
v_dual_id(v);
155 fprintf(fpm,
"set label ' %d' at %12.4e, %12.4e, %12.4e\n",
161 fprintf(fpm,
"%c set parametric\n", D3);
162 fprintf(fpm,
"%c set view 60, 70, %5.2f \n", D3, scale);
163 fprintf(fpm,
"%c set view equal xyz # 1:1 3D axis scaling \n", D3);
164 fprintf(fpm,
"%c unset key\n", D3);
165 fprintf(fpm,
"%c set xlabel 'x'\n", D3);
166 fprintf(fpm,
"%c set ylabel 'y'\n", D3);
167 fprintf(fpm,
"%c set zlabel 'z'\n", D3);
172 fprintf(fpm,
"set title \"%s\\n", title.c_str());
177 fprintf(fpm,
" deflection exaggeration: %.1f ", exagg_static);
180 fprintf(fpm,
"unset clip; \nset clip one; set clip two\n");
181 fprintf(fpm,
"set xyplane 0 \n");
192 fprintf(fpm,
"%c splot '%s' u 2:3:4 t 'load case %d of %d' w lp ",
194 if (!anlyz) fprintf(fpm,
" lw %d lt 1 pt 6 \n", lw);
195 else fprintf(fpm,
" lw 1 lt 5 pt 6, '%s' u 1:2:3 t 'load case %d of %d' w l lw %d lt 3\n", meshfl, 1, 1, lw);
197 if (anlyz) fprintf(fpm,
"pause -1\n");
204 if ((fpm = fopen(meshpath,
"w")) == NULL)
206 sprintf(errMsg,
"\n error: cannot open gnuplot undeformed mesh data file: %s\n", meshpath);
211 fprintf(fpm,
"# FIBERPRINT FRAME STRUCTURAL ANALYSIS RESULTS GCL@USTC");
212 fprintf(fpm,
" VERSION %s \n", std::string(
VERSION).c_str());
213 fprintf(fpm,
"# %s\n", title.c_str());
214 fprintf(fpm,
"# %s", ctime(&now));
215 fprintf(fpm,
"# U N D E F O R M E D M E S H D A T A (global coordinates)\n");
216 fprintf(fpm,
"# Node X Y Z \n");
218 for (
m = 0;
m < nE;
m++)
221 WF_edge *ei = wf_edge_list[e_id];
226 int dual_u = ptr_dualgraph->
v_dual_id(u);
227 int dual_v = ptr_dualgraph->
v_dual_id(v);
233 fprintf(fpm,
"%5d %12.4e %12.4e %12.4e \n",
235 fprintf(fpm,
"%5d %12.4e %12.4e %12.4e",
237 fprintf(fpm,
"\n\n\n");
246 if ((fpm = fopen(meshfl,
"w")) == NULL)
248 sprintf(errMsg,
"\n error: cannot open gnuplot deformed mesh data file %s \n", meshfl);
253 fprintf(fpm,
"# FIBERPRINT FRAME STRUCTURAL ANALYSIS RESULTS GCL@USTC");
254 fprintf(fpm,
" VERSION %s \n", std::string(
VERSION).c_str());
255 fprintf(fpm,
"# %s\n", title.c_str());
256 fprintf(fpm,
"# %s", ctime(&now));
257 fprintf(fpm,
"# D E F O R M E D M E S H D A T A ");
258 fprintf(fpm,
" deflection exaggeration: %.1f\n", exagg_static);
259 fprintf(fpm,
"# X-dsp Y-dsp Z-dsp\n");
262 FILE *fpv = fopen(
"C:/Users/DELL/Desktop/result/vert.txt",
"w");
263 FILE *fpl = fopen(
"C:/Users/DELL/Desktop/result/line.txt",
"w");
265 for (
m = 0;
m < nE;
m++)
272 WF_edge *ei = wf_edge_list[e_id];
277 int dual_u = ptr_dualgraph->
v_dual_id(u);
278 int dual_v = ptr_dualgraph->
v_dual_id(v);
280 fprintf(fpm,
"\n# element %5d \n",
m);
285 D,
m, ptr_dualgraph, ptr_wf, exagg_static);
287 int nB = beam.size();
288 for (
int i = 0; i < nB; ++i)
290 fprintf(fpm,
" %12.4e %12.4e %12.4e\n\n", beam[i].
x(), beam[i].
y(), beam[i].
z());
295 fprintf(fpl,
"%lf %lf %lf %lf %lf %lf\n",
296 beam[0].
x(), beam[0].
y(), beam[0].
z(),
297 beam[nB - 1].
x(), beam[nB - 1].
y(), beam[nB - 1].
z());
298 fprintf(fpv,
"%lf %lf %lf\n", beam[0].
x(), beam[0].
y(), beam[0].
z());
299 fprintf(fpv,
"%lf %lf %lf\n", beam[nB - 1].
x(), beam[nB - 1].
y(), beam[nB - 1].
z());
323 double t0,
t1, t2, t3, t4, t5, t6, t7, t8,
324 u1,
u2, u3, u4, u5, u6, u7, u8, u9, u10, u11, u12,
343 t0, t1, t2, t3, t4, t5, t6, t7, t8, 0.0);
345 i1 = 6 * dual_u; i2 = 6 * dual_v;
349 u1 = exagg*(t0*D[i1 + 0] + t1*D[i1 + 1] + t2*D[i1 + 2]);
350 u2 = exagg*(t3*D[i1 + 0] + t4*D[i1 + 1] + t5*D[i1 + 2]);
351 u3 = exagg*(t6*D[i1 + 0] + t7*D[i1 + 1] + t8*D[i1 + 2]);
353 u4 = exagg*(t0*D[i1 + 3] + t1*D[i1 + 4] + t2*D[i1 + 5]);
354 u5 = exagg*(t3*D[i1 + 3] + t4*D[i1 + 4] + t5*D[i1 + 5]);
355 u6 = exagg*(t6*D[i1 + 3] + t7*D[i1 + 4] + t8*D[i1 + 5]);
357 u7 = exagg*(t0*D[i2 + 0] + t1*D[i2 + 1] + t2*D[i2 + 2]);
358 u8 = exagg*(t3*D[i2 + 0] + t4*D[i2 + 1] + t5*D[i2 + 2]);
359 u9 = exagg*(t6*D[i2 + 0] + t7*D[i2 + 1] + t8*D[i2 + 2]);
361 u10 = exagg*(t0*D[i2 + 3] + t1*D[i2 + 4] + t2*D[i2 + 5]);
362 u11 = exagg*(t3*D[i2 + 3] + t4*D[i2 + 4] + t5*D[i2 + 5]);
363 u12 = exagg*(t6*D[i2 + 3] + t7*D[i2 + 4] + t8*D[i2 + 5]);
367 a[0] = u2; b[0] = u3;
368 a[1] = u8; b[1] = u9;
369 a[2] = u6; b[2] = -u5;
370 a[3] = u12; b[3] = -u11;
373 A(0,0) = 1.0; A(0,1) = u1; A(0,2) = u1*u1; A(0,3) = u1*u1*u1;
374 A(1,0) = 1.0; A(1,1) = u7; A(1,2) = u7*u7; A(1,3) = u7*u7*u7;
375 A(2,0)= 0.0; A(2,1) = 1.; A(2,2) = 2.*u1; A(2,3) = 3.*u1*u1;
376 A(3,0) = 0.0; A(3,1) = 1.; A(3,2) = 2.*u7; A(3,3) = 3.*u7*u7;
384 sprintf(errMsg,
" n1 = %d n2 = %d L = %e u7 = %e \n", dual_u+1, dual_v+1, L, u7);
394 sprintf(errMsg,
" n1 = %d n2 = %d L = %e u7 = %e \n", dual_u + 1, dual_v + 1, L, u7);
403 for (s = u1; fabs(s) <= 1.01*fabs(L + u7); s += fabs(L + u7 - u1) / 10.0)
407 v = xa[0] + xa[1] * s + xa[2] * s*s + xa[3] * s*s*s;
408 w = xb[0] + xb[1] * s + xb[2] * s*s + xb[3] * s*s*s;
411 dX = t0*s + t3*v + t6*w;
412 dY = t1*s + t4*v + t7*w;
413 dZ = t2*s + t5*v + t8*w;
432 string title_s =
"FiberPrint Test File -- static analysis (N,mm,Ton)\n";
435 if ((fp = fopen(fpath,
"w")) == NULL)
437 sprintf(errMsg,
"\n ERROR: cannot open .3dd transfer data file '%s'", fpath);
442 fprintf(fp, title_s.c_str());
448 std::vector<WF_edge*> wf_edge_list = *ptr_wf->
GetEdgeList();
449 std::vector<DualFace*> dual_face_list = *ptr_dualgraph->
GetFaceList();
453 double density = ptr_parm->
density_;
454 double g = ptr_parm->
g_;
460 fprintf(fp,
"%d # number of nodes\n", nN);
461 fprintf(fp,
"#.node x y z r\n");
462 fprintf(fp,
"# mm mm mm m\n\n");
463 for (
int i = 0; i < nN; i++)
467 fprintf(fp,
"%d %f %f %f %f\n", i + 1,
473 std::vector<int> res_index;
474 for (
int i = 0; i < nN; i++)
476 int id = dual_face_list[i]->orig_id();
481 res_index.push_back(i+1);
485 fprintf(fp,
"%d # number of nodes with reaction\n", nR);
486 fprintf(fp,
"#.node x y z xx yy zz 1=b_fixed, 0=free\n");
487 for (
int i = 0; i < nR; i++)
489 fprintf(fp,
"%d 1 1 1 1 1 1\n", res_index[i]);
493 double Ax =
F_PI * r * r;
494 double Asy = Ax * (6 + 12 * v + 6 * v*v) / (7 + 12 * v + 4 * v*v);
496 double Jxx = 0.5 *
M_PI * r * r * r * r;
501 fprintf(fp,
"%d # number of frame element\n", nE);
502 fprintf(fp,
"#.e n1 n2 Ax Asy Asz Jxx Iyy Izz E G roll density\n");
503 fprintf(fp,
"# . . mm^2 mm^2 mm^2 mm^4 mm^4 mm^4 MPa MPa deg T/mm^3\n");
504 for (
int i = 0; i < nE; i++)
507 WF_edge *ei = wf_edge_list[e_id];
512 int dual_u = ptr_dualgraph->
v_dual_id(u);
513 int dual_v = ptr_dualgraph->
v_dual_id(v);
515 double Iyy =
F_PI * r * r * r * r / 4;
518 fprintf(fp,
"%d %d %d %f %f %f %f %f %f %f %f %f %.14f\n",
519 i + 1, dual_u + 1, dual_v + 1,
520 Ax, Asy, Asz, Jxx, Iyy, Izz, E, G, 0.0, density);
526 fprintf(fp,
"%d # 1: include shear deformation\n", 0);
527 fprintf(fp,
"%d # 1: include geometric stiffness\n", 0);
528 fprintf(fp,
"%.1f # exaggerate static mesh deformation\n", 10.0);
529 fprintf(fp,
"%.1f # zoom scale for 3D plotting\n", 2.5);
530 fprintf(fp,
"%d # x-axis increment for internal forces, mm\n", -1);
531 fprintf(fp,
" # if dx is -1 then internal force calculation are skipped\n");
535 fprintf(fp,
"%d # number of static load cases\n", 1);
536 fprintf(fp,
" # Begin static Load Case 1 of 1\n");
539 fprintf(fp,
"# gravitational acceleration for self-weight loading (global)\n");
540 fprintf(fp,
"#.gX gY gZ\n");
541 fprintf(fp,
"#.mm/s^2 mm/s^2 mm/s^2\n");
542 fprintf(fp,
" 0 0 %.6f\n", g);
545 fprintf(fp,
"%d # number of loaded nodes\n", 0);
546 fprintf(fp,
"%d # number of uniform loads\n", 0);
547 fprintf(fp,
"%d # number of trapezoidal loads\n", 0);
548 fprintf(fp,
"%d # number of internal concentrated loads\n", 0);
549 fprintf(fp,
"%d # number of temperature loads\n", 0);
551 fprintf(fp,
"%d # number of nodes with prescribed displacement\n", nR);
552 fprintf(fp,
"#.node X-disp1 Y-disp1 Z-disp1 X-rot'n Y-rot'n Z-rot'n\n");
553 fprintf(fp,
"# mm mm mm radian radian radian\n");
554 for (
int i = 0; i < nR; i++)
556 fprintf(fp,
"%d 0 0 0 0 0 0\n", res_index[i]);
559 fprintf(fp,
" # End static Load Case 1 of 1\n");
562 fprintf(fp,
"%d #number of dynamic modes\n",0);
563 fprintf(fp,
"# End of transfer data file for fiber test");
578 if ((fp_m = fopen(filename,
"w")) == NULL)
580 printf(
" error: cannot open file: %s \n", filename);
585 fprintf(fp_m,
"%% filename: %s - %s\n", filename, ctime(&now));
586 fprintf(fp_m,
"%% type: matrix \n");
587 fprintf(fp_m,
"%% rows: %d\n", n);
588 fprintf(fp_m,
"%% columns: %d\n", n);
589 for (i = 0; i < n; i++)
591 for (j = 0; j < n; j++)
595 if (fabs(A(j,i)) > 1.e-99)
597 fprintf(fp_m,
"%21.12e", A(j,i));
601 fprintf(fp_m,
" 0 ");
606 if (fabs(A(i, j)) > 1.e-99)
608 fprintf(fp_m,
"%21.12e", A(i,j));
612 fprintf(fp_m,
" 0 ");
629 vector<DualFace*> dual_face_list = *ptr_dual_graph->
GetFaceList();
632 if ((fp = fopen(filename,
"w")) == NULL)
634 printf(
" error: cannot open file: %s \n", filename);
639 fprintf(fp,
"%% filename: %s - %s\n", filename, ctime(&now));
640 fprintf(fp,
"%% type: vector \n");
641 fprintf(fp,
"%% rows: %d\n", n);
644 fprintf(fp,
"NODE DISPLACEMENTS (global)\n");
645 fprintf(fp,
"#.node X-dsp Y-dsp Z-dsp X-rot Y-rot Z-rot\n");
646 for (i = 0; i < nN; i++)
649 int v_id = dual_face_list[i]->orig_id();
650 int v_dual_id = ptr_dual_graph->
v_dual_id(v_id);
651 for (j = 0; j < 6; j++)
653 tmp_D[6 * v_dual_id + j] = D[6 * i + j];
657 for (i = 0; i < nN; i++)
659 fprintf(fp,
"%d %.6f %.6f %.6f %.6f %.6f %.6f\n",
660 i+1, tmp_D[6 * i], tmp_D[6 * i + 1], tmp_D[6 * i + 2], tmp_D[6 * i + 3], tmp_D[6 * i + 4], tmp_D[6 * i + 5]);
vector< DualFace * > * GetFaceList()
void GnuPltCubicBentBeam(vector< point > &beam, VX &D, int dual_i, DualGraph *ptr_dualgraph, WireFrame *ptr_frame, double exagg)
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t0
GLenum GLenum GLenum GLenum GLenum scale
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
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)
GLfixed GLfixed GLfixed y2
vector< WF_edge * > * GetEdgeList()
GLubyte GLubyte GLubyte GLubyte w
GLboolean GLboolean GLboolean GLboolean a
void WriteInputData(const char *fpath, DualGraph *ptr_dualgraph, FiberPrintPARM *ptr_parm, int verbose)
void SaveUpperMatrix(char filename[], const MX &A, int n)
GLboolean GLboolean GLboolean b
GLdouble GLdouble GLdouble z
GLuint GLfloat GLfloat GLfloat x1
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 isFixed(int u) const
void SaveDisplaceVector(char filename[], const VX &D, int n, DualGraph *ptr_dual_graph)
void OutputPath(const char *fname, char fullpath[], const int len, char *default_outdir, int verbose)
point GetPosition(int u) const
bool LUDecomp(MX &A, VX &x, VX &b)