📄 output.cpp
字号:
#include "globprep.h"#include "output.h"#include "element.h"#include <string.h>/** This function writes read data from the preprocessor files to the file given by the out parameter in the MEFEL input format. Prameters @param out - pointer to the opened text file where the data will be written @param d - pointer to the description structure with preprocessor data*/long output(FILE *out, descrip *d){ // Output data in mechtop format long err; long npropn, nprope; npropn = Npropn; nprope = Nprope; fprintf(stdout, "\n\nOutput of MEFEL input file :"); fprintf(stdout, "\n writing nodes . . ."); if (Nlay == 0) err = wr_nodes(out, npropn); // writing nodes, crsecs in the nodes and local systems else err = wr_lay_nodes(out, npropn); // writing nodes, crsecs in the nodes and local systems for layered problems fflush(out); if (err) return(7); fprintf(stdout, " O.K."); fprintf(stdout, "\n writing boundary conditions . . ."); err = wr_bocon(out, npropn); // writing boundary conditions fflush(out); if (err) return(7); fprintf(stdout, " O.K."); fprintf(stdout, "\n writing elements . . ."); if (Nlay == 0) err = wr_elements(out, nprope, d); // writing elements and code numbers on elements else err = wr_lay_elements(out, nprope, d); // writing elements and code numbers on elements for layered problems fflush(out); if (err) return(7); fprintf(stdout, " O.K."); if (!(d->seq)) { fprintf(stdout, "\n writing global node numbers . . ."); err = wr_globnodnum(out); if (err) return(7); fprintf(stdout, " O.K."); }// err = wr_intpoints(out, nprope); // writing integration points of elements // with indeces of material parameters fflush(out); if (err) return(7); fprintf(stdout, "\n writing materials . . ."); err = wr_materials(out); // writing material parameters fflush(out); if (err) return(7); fprintf(stdout, " O.K.");/* if (Mp->stresscomp) { fprintf(stdout, "\n writing auxiliary points for stress computation . . ."); err = wr_auxpoint(out, nprope); // writing auxiliary points fflush(out); if (err) return(7); fprintf(stdout, " O.K."); fprintf(stdout, "\n writing local coordinate systems . . ."); err = wr_ellcsys(out, nprope); // writing local coordinate systems in the auxiliary points fprintf(out, "\n"); fflush(out); if (err) return(7); fprintf(stdout, " O.K."); } if (Mp->straincomp) { fprintf(stdout, "\n writing auxiliary points for strain computation . . ."); err = wr_auxpoint(out, nprope); // writing auxiliary points fflush(out); if (err) return(7); fprintf(stdout, " O.K."); fprintf(stdout, "\n writing local coordinate systems . . ."); err = wr_ellcsys(out, nprope); // writing local coordinate systems in the auxiliary points fprintf(out, "\n"); fflush(out); if (err) return(7); fprintf(stdout, " O.K."); }*/ fprintf(stdout, "\n writing cross-sections . . ."); err = wr_crsecs(out); // writing cross section parameters fflush(out); if (err) return(7); fprintf(stdout, " O.K."); fprintf(stdout, "\n writing loads . . ."); err = wr_load(out, npropn, nprope); // writing loads fflush(out); if (err) return(7); fprintf(stdout, " O.K."); // deallocating used memory long i; for (i = 0; i < npropn; i++) { delete Boc[i]; delete Boccn[i]; delete Lno[i]; delete Dlno[i]; delete [] Nlsv[i]; delete [] Nccn[i]; delete Inic[i]; } for (i = 0; i < nprope; i++) { delete Lel[i];// delete Dlel[i]; delete [] Mel[i]; delete [] Melid[i]; delete [] Elsv[i]; delete Edgl[i]; delete Eps[i]; } delete [] Nnp; delete [] Nep; delete [] Ndofn; delete [] Boc; delete [] Boccn; delete [] Lno; delete [] Dlno; delete [] Lel;// delete [] Dlel; delete [] Tel; delete [] Sel; delete [] Mel; delete [] Melid; delete [] Nmel; delete [] Ncs; delete [] Ncsi; delete [] Ecs; delete [] Ecsi; delete [] Nlsv; delete [] Elsv; delete [] Nccn; delete [] Edgl; delete Dbmat; delete Dbcrs; delete [] Tndofn; delete [] Tet; delete [] Nmu; delete [] Ncu; delete [] Inic; delete [] Enip; delete [] Surfl; delete [] Elsurfl; delete [] Eep; delete [] Eps; delete [] Tfel; // delete Top; return (0);}long wr_nodes(FILE *out, long nprop)/**< Function writes section with description of nodes to the text file given by out. @param out - pointer to the opened text file, where the data will be written @param nprop - number of entries in the input property file @retval 0 - if succes @retval 1 - if node hasn't assigned ndof @retval 2 - if node hasn't assigned cross-section*/{ long i, j, k, l, *ic, ndf, ncf, nlsf, rindex; Tndofn = new long[Top->nodes]; memset(Tndofn, 0, sizeof(*Tndofn)*Top->nodes); ic = new long[Top->nodes]; fprintf(out, "%ld\n", Top->nodes); for (i = 0; i < Top->nodes; i++) { for (j = 0; j < nprop; j++) // loop over all properties from input { if (Top->N[i].property == Nnp[j]) // test if number of property matchs number from input { if (Ncs[j]) // test if any cross-section is assigned { if ((ic[i] = Dbcrs->search_crs(Ncs[j], Ncsi[j]-1)) < 0) // searching cs in the cs database { fprintf(stderr, "\nError - cross-section with number %d and index %ld in node %ld not found\n", Ncs[j], Ncsi[j], i+1); delete [] ic; return(2); } else { if (Dbcrs->crs[ic[i]].propu[Ncsi[j]-1] == 0) Dbcrs->crs[ic[i]].npropu++; // indicator whether this cs type is used if (Ncu[ic[i]] == 0) Ncu[ic[i]]++; // indicator whether cs type from cs database is used in the given task Dbcrs->crs[ic[i]].propu[Ncsi[j]-1]++; // indicator whether this index of cs is used } break; } } }/* if (ncf == 0) { fprintf(stderr, "\nError - node number %ld hasn't assigned cross-section\n", i+1); delete [] ic; return (2); }*/ } Csrin = 0; for (j = 0; j < Dbcrs->numt; j++) { if (Dbcrs->crs[j].npropu) { rindex = 1; for (k = 0; k < Dbcrs->crs[j].nprop; k++) { if (Dbcrs->crs[j].propu[k]) { Dbcrs->crs[j].ridx[k] = rindex; rindex++; } } } } Csrin = rindex; for (i = 0; i < Top->nodes; i++) { // writing node number and coordinates fprintf(out, "%6ld % e % e % e", i+1, Top->N[i].x, Top->N[i].y, Top->N[i].z); for (j = 0, ndf = 0; j < nprop; j++) // loop over all properties from input { if (Top->N[i].property == Nnp[j]) // test if number of property matchs number from input { if (Ndofn[j]) // test if node has assigned ndofs { fprintf(out, " %ld", Ndofn[j]); Tndofn[i] = Ndofn[j]; ndf = 1; break; } } } if (ndf == 0) { fprintf(stderr, "\nError - node number %ld hasn't assigned ndofs\n", i+1); delete [] ic; return (1); } for (j = 0, ncf = 0; j < nprop; j++) // loop over all properties from input { if (Top->N[i].property == Nnp[j]) // test if number of property matchs number from input { if (Ncs[j]) // test if any cross-section is assigned { fprintf(out, " %d %ld", Ncs[j], Dbcrs->crs[ic[i]].ridx[Ncsi[j]-1]); ncf = 1; break; } } } if (ncf == 0) // no cross section assigned fprintf(out, " 0"); for (j = 0, nlsf = 0; j < nprop; j++) // loop over all properties from input { if (Top->N[i].property == Nnp[j]) // test if number of property matchs number from input { if (Nlsv[j]) // test if any local system is assigned { nlsf = 1; fprintf(out, " %ld", Nlsv[j][0].n); for (k = 0; k < Nlsv[j][0].n; k++) { for (l = 0; l < Nlsv[j][k].n; l++) fprintf(out, " % e", Nlsv[j][k](l)); } fprintf(out, "\n"); break; } } } if (nlsf == 0) fprintf(out, " 0\n"); } fprintf(out, "\n"); delete [] ic; return(0);}long wr_lay_nodes(FILE *out, long nprop)/**< Function writes section with description of nodes for layered problems to the text file given by out. @param out - pointer to the opened text file, where the data will be written @param nprop - number of entries in the input property file @retval 0 - if succes @retval 1 - if node hasn't assigned ndof @retval 2 - if node hasn't assigned cross-section*/{ long i, j, k, l, *ic, ndf, ncf, nlsf, rindex; Tndofn = new long[Top->nodes]; memset(Tndofn, 0, sizeof(*Tndofn)*Top->nodes); ic = new long[Top->nodes]; fprintf(out, "%ld\n", Top->nodes*Nlay); fprintf(out, "%ld\n", Top->nodes); for (i = 0; i < Top->nodes; i++) { for (j = 0; j < nprop; j++) // loop over all properties from input { if (Top->N[i].property == Nnp[j]) // test if number of property matchs number from input { if (Ncs[j]) // test if any cross-section is assigned { if ((ic[i] = Dbcrs->search_crs(Ncs[j], Ncsi[j]-1)) < 0) // searching cs in the cs database { fprintf(stderr, "\nError - cross-section with number %d and index %ld in node %ld not found\n", Ncs[j], Ncsi[j], i+1); delete [] ic; return(2); } else { if (Dbcrs->crs[ic[i]].propu[Ncsi[j]-1] == 0) Dbcrs->crs[ic[i]].npropu++; // indicator whether this cs type is used if (Ncu[ic[i]] == 0) Ncu[ic[i]]++; // indicator whether cs type from cs database is used in the given task Dbcrs->crs[ic[i]].propu[Ncsi[j]-1]++; // indicator whether this index of cs is used } break; } } }/* if (ncf == 0) { fprintf(stderr, "\nError - node number %ld hasn't assigned cross-section\n", i+1); delete [] ic; return (2); }*/ } Csrin = 0; for (j = 0; j < Dbcrs->numt; j++) { if (Dbcrs->crs[j].npropu) { rindex = 1; for (k = 0; k < Dbcrs->crs[j].nprop; k++) { if (Dbcrs->crs[j].propu[k]) { Dbcrs->crs[j].ridx[k] = rindex; rindex++; } } } } Csrin = rindex; for (i = 0; i < Top->nodes; i++) { fprintf (out, "%6ld\n%6ld\n", i+1, Nlay); for (l = 0; l < Nlay; l++) { // writing node number and coordinates fprintf(out, "%6ld % e % e % e", Nlay*i+l+1, Top->N[i].x, Top->N[i].y, Top->N[i].z); for (j = 0, ndf = 0; j < nprop; j++) // loop over all properties from input { if (Top->N[i].property == Nnp[j]) // test if number of property matchs number from input { if (Ndofn[j]) // test if node has assigned ndofs { fprintf(out, " %ld", Ndofn[j]); Tndofn[i] = Ndofn[j]; ndf = 1; break; } } } if (ndf == 0) { fprintf(stderr, "\nError - node number %ld hasn't assigned ndofs\n", i+1); delete [] ic; return (1); } for (j = 0, ncf = 0; j < nprop; j++) // loop over all properties from input { if (Top->N[i].property == Nnp[j]) // test if number of property matchs number from input { if (Ncs[j]) // test if any cross-section is assigned { fprintf(out, " %d %ld", Ncs[j], Dbcrs->crs[ic[i]].ridx[Ncsi[j]-1]); ncf = 1; break; } } } if (ncf == 0) // no cross section assigned fprintf(out, " 0"); for (j = 0, nlsf = 0; j < nprop; j++) // loop over all properties from input { if (Top->N[i].property == Nnp[j]) // test if number of property matchs number from input { if (Nlsv[j]) // test if any local system is assigned { nlsf = 1; fprintf(out, " %ld", Nlsv[j][0].n); for (k = 0; k < Nlsv[j][0].n; k++) { for (l = 0; l < Nlsv[j][k].n; l++) fprintf(out, " % e", Nlsv[j][k](l)); } fprintf(out, "\n"); break; } } } if (nlsf == 0) fprintf(out, " 0\n"); } } fprintf(out, "\n"); delete [] ic; return(0);}/** Function writes section with description of boundary conditions of nodes to the text file given by out. @param out - pointer to the opened text file, where the data will be written @param nprop - number of entries in the input property file
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -