📄 outdriverm.cpp
字号:
@param in - pointer to the opened text file @retval 0 - on success @retval 1 - error reading step or load case selection @retval 2 - error reading displacement selection @retval 3 - error reading strain selection @retval 4 - error reading stress selection @retval 5 - error reading other values selection @retval 6 - error reading reaction output flag */long nodeoutm::read(XFILE *in){ long i; // step and loadcases xfscanf(in, "%k", "sel_nodstep"); dstep.read(in); if (dstep.st == sel_no) return 0; xfscanf(in, "%k", "sel_nodlc"); sellc.read(in); // displacements xfscanf(in, "%k", "displ_nodes"); selndisp.read(in); switch (selndisp.st) { case sel_no: break; case sel_all: case sel_range: case sel_list: xfscanf(in, "%k", "displ_comp"); seldisp = new sel[selndisp.n]; for (i=0; i<selndisp.n; i++) seldisp[i].read(in); break; default: fprintf(stderr, "\n\nUnknown type of selection is required in function nodeoutm::read\n"); fprintf(stderr, " (file %s, line %d)", __FILE__, __LINE__); return 2; } // strains xfscanf(in, "%k", "strain_nodes"); selnstra.read(in); switch (selnstra.st) { case sel_no: break; case sel_all: case sel_range: case sel_list: xfscanf(in, "%k", "nodstrain_comp"); Mp->straincomp = 1; Mp->strainaver = 1; transtra = new long[selnstra.n]; memset(transtra, 0, sizeof(*transtra)*selnstra.n); selstra = new sel[selnstra.n]; for(i=0; i<selnstra.n; i++) selstra[i].read(in); xfscanf(in, "%k", "nodstra_transfid"); for(i=0; i<selnstra.n; i++) { if (xfscanf(in, "%ld", transtra+i) != 1) { fprintf(stderr, "\n\nError reading strain selection\n"); fprintf(stderr, " in function nodeoutm::read, (file %s, line %d)\n", __FILE__, __LINE__); return 3; } } break; default: fprintf(stderr, "\n\nUnknown type of selection is required in function nodeoutm::read\n"); fprintf(stderr, " (file %s, line %d)", __FILE__, __LINE__); return 3; } // stresses xfscanf(in, "%k", "stress_nodes"); selnstre.read(in); switch (selnstre.st) { case sel_no: break; case sel_all: case sel_range: case sel_list: xfscanf(in, "%k", "nodstress_comp"); Mp->straincomp = 1; Mp->strainaver = 1; Mp->stresscomp = 1; Mp->stressaver = 1; transtre = new long[selnstre.n]; memset(transtre, 0, sizeof(*transtre)*selnstre.n); selstre = new sel[selnstre.n]; for(i=0; i<selnstre.n; i++) selstre[i].read(in); xfscanf(in, "%k", "nodstre_transfid"); for(i=0; i<selnstre.n; i++) { if (xfscanf(in, "%ld", transtre+i) != 1) { fprintf(stderr, "\n\nError reading stress selection\n"); fprintf(stderr, " in function nodeoutm::read, (file %s, line %d)\n", __FILE__, __LINE__); return 3; } } break; default: fprintf(stderr, "\n\nUnknown type of selection is required in function nodeoutm::read\n"); fprintf(stderr, " (file %s, line %d)", __FILE__, __LINE__); return 4; } // other values xfscanf(in, "%k", "other_nodes"); selnoth.read(in); switch (selnoth.st) { case sel_no: break; case sel_all: case sel_range: case sel_list: xfscanf(in, "%k", "nodother_comp"); Mp->othercomp = 1; Mp->otheraver = 1; seloth = new sel[selnoth.n]; for (i=0; i < selnoth.n; i++) seloth[i].read(in); break; default: fprintf(stderr, "\n\nUnknown type of selection is required in function nodeoutm::read\n"); fprintf(stderr, " (file %s, line %d)", __FILE__, __LINE__); return 5; } // reactions if (xfscanf(in, "%k%ld", "reactions", &react) != 2) { fprintf(stderr, "\n\nError reading reactions selection\n"); fprintf(stderr, " in function nodeoutm::read, (file %s, line %d)\n", __FILE__, __LINE__); return 6; } if (react) Mp->reactcomp = 1; return 0;}/** Function prints data with description for output of nodal values to the text file. @param out - pointer to the opened text file*/void nodeoutm::print(FILE *out){ long i; // step and loadcases dstep.print(out); if (dstep.st == sel_no) return; sellc.print(out); fprintf(out, "\n"); // displacements selndisp.print(out); switch(selndisp.st) { case sel_no: break; case sel_all: case sel_range: case sel_list: for(i=0; i<selndisp.n; i++) seldisp[i].print(out); break; default: fprintf(stderr, "\n\nUnknown type of selection is required in function nodeoutm::print\n"); fprintf(stderr, " (file %s, line %d)", __FILE__, __LINE__); return; } // strains selnstra.print(out); switch (selnstra.st) { case sel_no: break; case sel_all: case sel_range: case sel_list: for(i=0; i<selnstra.n; i++) selstra[i].print(out); for(i=0; i<selnstra.n; i++) fprintf(out, "%ld ", transtra[i]); fprintf(out, "\n"); break; default: fprintf(stderr, "\n\nUnknown type of selection is required in function nodeoutm::print\n"); fprintf(stderr, " (file %s, line %d)", __FILE__, __LINE__); return; } // stresses selnstre.print(out); switch (selnstre.st) { case sel_no: break; case sel_all: case sel_range: case sel_list: for(i=0; i<selnstre.n; i++) selstre[i].print(out); for(i=0; i<selnstre.n; i++) fprintf(out, "%ld ", transtre[i]); fprintf(out, "\n"); break; default: fprintf(stderr, "\n\nUnknown type of selection is required in function nodeoutm::print\n"); fprintf(stderr, " (file %s, line %d)", __FILE__, __LINE__); return; } // other values selnoth.print(out); switch (selnoth.st) { case sel_no: break; case sel_all: case sel_range: case sel_list: for(i=0; i<selnoth.n; i++) seloth[i].print(out); break; default: fprintf(stderr, "\n\nUnknown type of selection is required in function nodeoutm::print\n"); fprintf(stderr, " (file %s, line %d)", __FILE__, __LINE__); return; } // reactions fprintf(out, "%ld\n", react);}/** Function prints required output values for selected nodes and for given load case to the output text file. @param out - pointer to the opened text file @param lcid - load case id */void nodeoutm::print_out(FILE *out, long lcid){ if (selndisp.st != sel_no) { fprintf(out, "** Nodal displacements :\n\n"); print_disp(out, lcid); } if (selnstra.st != sel_no) { fprintf(out, "** Nodal averaged strains :\n\n"); print_stra(out, lcid); } if (selnstre.st != sel_no) { fprintf(out, "** Nodal averaged stresses :\n\n"); print_stre(out, lcid); } if (selnoth.st != sel_no) { fprintf(out, "** Nodal averaged other values :\n\n"); print_other(out); } if (react) { fprintf(out, "** Reactions :\n\n"); print_react(out, lcid); }}/** Function prints required displacements for selected nodes and for given load case to the output text file. @param out - pointer to the opened text file @param lcid - load case id */void nodeoutm::print_disp(FILE *out, long lcid){ long i, j, ndofn; double *r; for (i=0; i<Mt->nn; i++) { if (selndisp.presence_id(i)) { fprintf(out, " Node %7ld", i+1); ndofn = Mt->give_ndofn(i); r = new double[ndofn]; noddispl(lcid, r, i); for (j=0; j<ndofn; j++) { if (selndisp.presence_id(seldisp,i,j)) fprintf(out, " r_%ld=% .*e", j+1, prdisp, r[j]); } delete [] r; fprintf(out, "\n"); } } fprintf(out, "\n");}/** Function prints required strains for selected nodes and for given load case to the output text file. @param out - pointer to the opened text file @param lcid - load case id */void nodeoutm::print_stra(FILE *out, long lcid){ long i, j, ncomp, id, ir; for (i=0; i<Mt->nn; i++) { if (selnstra.presence_id(i, ir)) { fprintf(out, " Node %7ld", i+1); ncomp = Mt->nodes[i].ncompstr; id = lcid*ncomp; for (j=0; j<ncomp; j++) { if (selnstra.presence_id(selstra,i,j)) fprintf(out, " eps_%ld=% .*e", j+1, prstra, Mt->nodes[i].strain[id+j]); } if (transtra[ir] < 0) { vector eps(4), peps(3); matrix epst(3,3), pvect(3,3); fillv(0.0, eps); for (j=0; j<ncomp; j++) eps[j] = Mt->nodes[i].strain[j]; if (ncomp == 4) vector_tensor (eps, epst, planestrain, strain); if (ncomp == 6) vector_tensor (eps, epst, spacestress, strain); princ_val (epst, peps, pvect, 20, 1.0e-4, Mp->zero, 3); if (Mt->nodes[i].pstra == NULL) Mt->nodes[i].pstra = new double [9]; for (j=0; j<3; j++) { Mt->nodes[i].pstra[j] = peps[j]; fprintf(out, " peps_%ld=% .*e", j+1, prstra, peps[j]); } for (j=0; j<3; j++) { Mt->nodes[i].pstra[3+j] = pvect[0][j]; fprintf(out, " a_1%ld=% .*e", j+1, prstra, pvect[0][j]); } for (j=0; j<3; j++) { Mt->nodes[i].pstra[6+j] = pvect[2][j]; fprintf(out, " a_3%ld=% .*e", j+1, prstra, pvect[2][j]); } } fprintf(out, "\n"); } } fprintf(out, "\n");}/** Function prints required stresses for selected nodes and for given load case to the output text file. @param out - pointer to the opened text file @param lcid - load case id */void nodeoutm::print_stre(FILE *out, long lcid){ long i, ir, j, ncomp, id; for (i=0; i<Mt->nn; i++) { if (selnstre.presence_id(i, ir)) { fprintf(out, " Node %7ld", i+1); ncomp = Mt->nodes[i].ncompstr; id = lcid*ncomp; for (j=0; j<ncomp; j++) { if (selnstre.presence_id(selstre, i, j)) fprintf(out, " sig_%ld=% .*e", j+1, prstre, Mt->nodes[i].stress[id+j]); } if (transtre[ir] < 0) { vector sig(ncomp), psig(3); matrix sigt(3,3), pvect(3,3); fillv(0.0, sig); for (j=0; j<ncomp; j++) sig[j] = Mt->nodes[i].stress[j]; if (ncomp == 4) vector_tensor (sig, sigt, planestrain, stress); if (ncomp == 6) vector_tensor (sig, sigt, spacestress, stress); princ_val (sigt, psig, pvect, 20, 1.0e-4, Mp->zero, 3); if (Mt->nodes[i].pstre == NULL) Mt->nodes[i].pstre = new double [9]; for (j=0; j<3; j++) { Mt->nodes[i].pstre[j] = psig[j]; fprintf(out, " psig_%ld=% .*e", j+1, prstre, psig[j]); } fprintf(out, " tau_max=% .*e", prstre, (psig[2]-psig[0])/2); for (j=0; j<3; j++) { Mt->nodes[i].pstre[3+j] = pvect[0][j]; fprintf(out, " a_1%ld=% .*e", j+1, prstre, pvect[0][j]); } for (j=0; j<3; j++) { Mt->nodes[i].pstre[6+j] = pvect[2][j]; fprintf(out, " a_3%ld=% .*e", j+1, prstre, pvect[2][j]); } } fprintf(out, "\n"); } } fprintf(out, "\n");}/** Function prints required other values for selected nodes and for given load case to the output text file. @param out - pointer to the opened text file @param lcid - load case id */void nodeoutm::print_other(FILE *out){ long i, j, ncomp; for (i=0; i<Mt->nn; i++) { ncomp = Mt->nodes[i].ncompother; if (selnoth.presence_id(i)) { fprintf(out, " Node %7ld", i+1); ncomp = Mt->nodes[i].ncompother; for (j=0; j<ncomp; j++) { if (selnoth.presence_id(seloth, i, j)) fprintf(out, " other_%ld=% .*e", j+1, proth, Mt->nodes[i].other[j]); } fprintf(out, "\n"); } } fprintf(out, "\n");}/** Function prints all reactions for for given load case to the output text file. @param out - pointer to the opened text file @param lcid - load case id */void nodeoutm::print_react(FILE *out, long lcid){ long i, j, ndofn; for (i=0; i<Mt->nn; i++) { if (Mt->nodes[i].react) { fprintf(out, " Node %7ld", i+1); ndofn = Mt->give_ndofn(i); for (j=0; j<ndofn; j++) fprintf(out, " R_%ld=% .*e", j+1, prreac, Mt->nodes[i].r[lcid*ndofn+j]); fprintf(out, "\n"); } } fprintf(out, "\n");}/** Constructor initializes data to zero values*/nodeoutgm::nodeoutgm(){ seldisp = selstra = selstre = seloth = NULL; transtra = transtre = NULL; }/** Destructor deallocates used memory*/nodeoutgm::~nodeoutgm(){ delete [] seldisp;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -