📄 outdriverm.cpp
字号:
delete [] selstra; delete [] selstre; delete [] seloth; delete [] transtra; delete [] transtre;}long nodeoutgm::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 nodeoutgm::read\n"); fprintf(stderr, " (file %s, line %d)", __FILE__, __LINE__); return 5; } 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 nodeoutgm::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; }}/** Function prints required output values for selected nodes and for given load case and step to the output grahics file. @param out - pointer to the opened grahics file @param lcid - load case id @param desclcid - load case description @param gf - graphics format */void nodeoutgm::print_graphics(FILE *out, long lcid, char *desclcid, graphfmt gf){ long i, j, k; if (gf == grfmt_open_dx) return; if (selndisp.st != sel_no) { if (gf == grfmt_gid) write_gid_displ(out, lcid, desclcid); else write_displ(out, lcid, desclcid); } if (selnstra.st != sel_no) { for(i=0; i<Mm->max_ncompstrn; i++) { for (j=0; j<selnstra.n; j++) { if (selstra[j].presence_id(i)) { if (gf == grfmt_gid) write_gid_nodscalar(out, strain, lcid, i, desclcid); else write_nodscalar(out, strain, lcid, i, desclcid); break; } } } for (j=0; j<selnstra.n; j++) { if (transtra[j] < 0) { for(k=0; k<3; k++) { if (gf == grfmt_gid) write_gid_nodscalar(out, pstrain, lcid, k, desclcid); else write_nodscalar(out, -k-1, desclcid); } break; } } } if (selnstre.st != sel_no) { for(i=0; i<Mm->max_ncompstrn; i++) { for (j=0; j<selnstre.n; j++) { if (selstre[j].presence_id(i)) { if (gf == grfmt_gid) write_gid_nodscalar(out, stress, lcid, i, desclcid); else write_nodscalar(out, stress, lcid, i, desclcid); break; } } } for (j=0; j<selnstre.n; j++) { if (transtre[j] < 0) { for(k=0; k<4; k++) { if (gf == grfmt_gid) write_gid_nodscalar(out, pstress, lcid, k, desclcid); else write_nodscalar(out, k, desclcid); } break; } } } if (selnoth.st != sel_no) { for(i=0; i<Mm->max_nncompo; i++) { for (j=0; j<selnoth.n; j++) { if (seloth[j].presence_id(i)) { if (gf == grfmt_gid) write_gid_nodscalar(out, other, lcid, i, desclcid); else write_nodscalar(out, other, lcid, i, desclcid); break; } } } }}/** Function prints required output values for selected nodes and for given load case and step to the several output grahics files named by printed quantity component. @param outfn - string with file name part @param mode - opening mode for graphics files @param lcid - load case id @param desclcid - load case description @param gf - graphics format */void nodeoutgm::print_graphics(char *outfn, char *mode, long lcid, char *desclcid, graphfmt gf){ long i, j, k, sl; char fname[FNAMELEN+70]; FILE *out; sl = strlen(outfn); if (gf != grfmt_gid_sep) { fprintf(stderr, "\nInvalid graphics format is required in function nodeoutm::print_graphics\n"); fprintf(stderr, "(file %s, line %d)", __FILE__, __LINE__); return; } if (selndisp.st != sel_no) { sprintf(fname, "%s.displ.flavia.res", outfn); out = fopen(fname, mode); if (out == NULL) { fprintf(stderr, "\n\nUnable to open graphics file '%s' in function nodeoutm::print_graphics\n", fname); fprintf(stderr, " (file %s, line %d)\n", __FILE__, __LINE__); abort(); } if (ftell(out) == 0) fprintf(out, "GiD Post Results File 1.0\n"); else write_gid_displ(out, lcid, desclcid); fclose(out); } if (selnstra.st != sel_no) { for(i=0; i<Mm->max_ncompstrn; i++) { for (j=0; j<selnstra.n; j++) { if (selstra[j].presence_id(i)) { sprintf(fname, "%s.nodal_eps%ld.flavia.res", outfn, i+1); out = fopen(fname, mode); if (out == NULL) { fprintf(stderr, "\n\nUnable to open graphics file '%s' in function nodeoutm::print_graphics\n", fname); fprintf(stderr, " (file %s, line %d)\n", __FILE__, __LINE__); abort(); } if (ftell(out) == 0) fprintf(out, "GiD Post Results File 1.0\n"); else write_gid_nodscalar(out, strain, lcid, i, desclcid); fclose(out); break; } } } for (j=0; j<selnstra.n; j++) { if (transtra[j] < 0) { for(k=0; k<3; k++) { sprintf(fname, "%s.nodal_peps%ld.flavia.res", outfn, k+1); out = fopen(fname, mode); if (out == NULL) { fprintf(stderr, "\n\nUnable to open graphics file '%s' in function nodeoutm::print_graphics\n", fname); fprintf(stderr, " (file %s, line %d)\n", __FILE__, __LINE__); abort(); } if (ftell(out) == 0) fprintf(out, "GiD Post Results File 1.0\n"); else write_gid_nodscalar(out, pstrain, lcid, k, desclcid); fclose(out); } break; } } } if (selnstre.st != sel_no) { for(i=0; i<Mm->max_ncompstrn; i++) { for (j=0; j<selnstre.n; j++) { if (selstre[j].presence_id(i)) { sprintf(fname, "%s.nodal_sig%ld.flavia.res", outfn, i+1); out = fopen(fname, mode); if (out == NULL) { fprintf(stderr, "\n\nUnable to open graphics file '%s' in function nodeoutm::print_graphics\n", fname); fprintf(stderr, " (file %s, line %d)\n", __FILE__, __LINE__); abort(); } if (ftell(out) == 0) fprintf(out, "GiD Post Results File 1.0\n"); else write_gid_nodscalar(out, stress, lcid, i, desclcid); fclose(out); break; } } } for (j=0; j<selnstre.n; j++) { if (transtre[j] < 0) { for(k=0; k<4; k++) { sprintf(fname, "%s.nodal_psig%ld.flavia.res", outfn, k+1); out = fopen(fname, mode); if (out == NULL) { fprintf(stderr, "\n\nUnable to open graphics file '%s' in function nodeoutm::print_graphics\n", fname); fprintf(stderr, " (file %s, line %d)\n", __FILE__, __LINE__); abort(); } if (ftell(out) == 0) fprintf(out, "GiD Post Results File 1.0\n"); else write_gid_nodscalar(out, pstress, lcid, k, desclcid); fclose(out); } break; } } } if (selnoth.st != sel_no) { for(i=0; i<Mm->max_nncompo; i++) { for (j=0; j<selnoth.n; j++) { if (seloth[j].presence_id(i)) { sprintf(fname, "%s.nodal_other%ld.flavia.res", outfn, i+1); out = fopen(fname, mode); if (out == NULL) { fprintf(stderr, "\n\nUnable to open graphics file '%s' in function nodeoutm::print_graphics\n", fname); fprintf(stderr, " (file %s, line %d)\n", __FILE__, __LINE__); abort(); } if (ftell(out) == 0) fprintf(out, "GiD Post Results File 1.0\n"); else write_gid_nodscalar(out, other, lcid, i, desclcid); fclose(out); break; } } } }}/** Constructor initializes data to zero values*/elemoutm::elemoutm(){ selstra = selstre = seloth = NULL; transtra = transtre = NULL; }/** Destructor deallocates used memory*/elemoutm::~elemoutm(){ delete [] selstra; delete [] selstre; delete [] seloth; delete [] transtra; delete [] transtre;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -