/* This library funtion writes the resulting data for a finite element program which does analysis on a truss Updated 5/19/99 SLFFEA source file Version: 1.0 Copyright (C) 1999 San Le The source code contained in this file is released under the terms of the GNU Library General Public License. */ #include #include #include #include #include "tsconst.h" #include "tsstruct.h" extern int dof, nmat, numel, numnp; int tswriter ( BOUND bc, int *connect, double *coord, int *el_matl, double *force, int *id, MATL *matl, char *name, STRAIN *strain, STRESS *stress, double *U) { int i,j,dum,check; char *ccheck; double fpointx, fpointy, fpointz; char out[20]; FILE *o3; /* Every output file is named after the input file with a ".ots" extension */ dum = strlen(name); if( dum > 15) dum = 15; bzero(out,20*sizeof(char)); ccheck = strncpy(out, name, dum); if(!ccheck) printf( " Problems with strncpy \n"); *(out+dum) = '.'; *(out+dum+1) = 'o'; *(out+dum+2) = 't'; *(out+dum+3) = 's'; o3 = fopen( out,"w" ); fprintf( o3, " numel numnp nmat (This is for a truss %15s) \n ", name); fprintf( o3, " %4d %4d %4d \n ", numel,numnp,nmat); fprintf( o3, "matl no., E modulus and Area \n"); for( i = 0; i < nmat; ++i ) { fprintf( o3, " %4d %9.4f %9.4f \n",i,matl[i].E, matl[i].area); } fprintf( o3, "el no., connectivity, matl no \n"); for( i = 0; i < numel; ++i ) { fprintf( o3, "%4d ",i); for( j = 0; j < npel; ++j ) { fprintf( o3, "%4d ",*(connect+npel*i+j)); } fprintf( o3, " %3d\n",*(el_matl+i)); } fprintf( o3, "node no., coordinates \n"); for( i = 0; i < numnp; ++i ) { fpointx = *(coord+nsd*i) + *(U+ndof*i); fpointy = *(coord+nsd*i+1) + *(U+ndof*i+1); fpointz = *(coord+nsd*i+2) + *(U+ndof*i+2); fprintf( o3, "%4d %14.6f %14.6f %14.6f\n", i, fpointx, fpointy, fpointz); } fprintf( o3, "prescribed displacement x: node disp value \n"); for( i = 0; i < numnp; ++i ) { fprintf( o3, "%4d %14.6e\n", i, *(U+ndof*i)); } fprintf( o3, " -10 \n"); fprintf( o3, "prescribed displacement y: node disp value \n"); for( i = 0; i < numnp; ++i ) { fprintf( o3, "%4d %14.6e\n", i, *(U+ndof*i+1)); } fprintf( o3, " -10 \n"); fprintf( o3, "prescribed displacement z: node disp value \n"); for( i = 0; i < numnp; ++i ) { fprintf( o3, "%4d %14.6e\n", i, *(U+ndof*i+2)); } fprintf( o3, " -10 \n"); fprintf( o3, "node with point load and load vector in x,y,z \n"); for( i = 0; i < bc.num_force[0] ; ++i ) { dum = bc.force[i]; if( *(id+ndof*dum) > -1 && *(id+ndof*dum+1) > -1 && *(id+ndof*dum+2) > -1 ) { fprintf( o3,"%4d",bc.force[i]); for( j = 0; j < ndof; ++j ) { fprintf( o3," %16.4f ",*(force+ndof*bc.force[i]+j)); } fprintf( o3, "\n"); } } for( i = 0; i < numnp; ++i ) { if( *(id+ndof*i) < 0 || *(id+ndof*i+1) < 0 || *(id+ndof*i+2) < 0 ) { fprintf( o3,"%4d",i); for( j = 0; j < ndof; ++j ) { fprintf( o3," %16.4f ",*(force+ndof*i+j)); } fprintf( o3, "\n"); } } fprintf( o3, " -10\n"); fprintf( o3, "element no. with stress and tensile stress vector \n"); for( i = 0; i < numel; ++i ) { fprintf( o3,"%4d ",i); fprintf( o3,"%14.6e ",stress[i].xx); fprintf( o3, "\n"); } fprintf( o3, " -10 \n"); fprintf( o3, "element no. with strain and tensile strain vector \n"); for( i = 0; i < numel; ++i ) { fprintf( o3,"%4d ",i); fprintf( o3,"%14.6e ",strain[i].xx); fprintf( o3, "\n"); } fprintf( o3, " -10 \n"); return 1; }