📄 input.cpp
字号:
@param d - structure with input data format description @retval 0 - on success In case of reading alternative file format : @retval 1 - if fails reading number of nodes @retval 2 - if fails reading nodal coordinates @retval 3 - if fails reading number of elements @retval 4 - if fails reading number of nodes on element @retval 5 - if fails reading nodal number on element @retval 6 - if fails reading property number on element @retval 7 - if file in alternative format couldn't be opened*/long input_siftop(descrip *d){ Top = new siftop; if (d->t3d == 1) { import_T3d_set_topology_pointer(*Top); if (d->seq) import_T3d(d->t3df, 0); else import_T3d(d->t3df, 1); } else { long ret; FILE *in = fopen(d->t3df, "rt"); if (in == NULL) return(7); if (d->seq) ret = Top->read(in, 0, d->redgn); else ret = Top->read(in, 1, d->redgn); fclose(in); return(ret); } return(0);}/** Function reads material database from file with name stored in the in @param in - string with database file name @retval 0 - on succes @retval 1 - if fails opening file @retval 2 - if fails reading number of material types @retval 3 - if fails reading material parameters*/long input_materials(char *in){ FILE *f = NULL; f = fopen(in, "rt"); if (f == NULL) { fprintf(stderr, "\nError - unable open material file :\n %s\n", in); return(1); } Dbmat = new dbmat; // allocating new dbmat class if (getlong(f, Dbmat->numt)) // reading number of material types { fprintf(stderr, "\nError reading number of material types\n"); fclose(f); return(2); } Dbmat->mat = new matr[Dbmat->numt]; // allocating memory for each material type Nmu = new long[Dbmat->numt]; // allocating array with number of used materials memset(Nmu, 0, sizeof(*Nmu)*Dbmat->numt); for (long i = 0; i < Dbmat->numt; i++) { // reading each index of material types if (Dbmat->mat[i].read(f)) { fclose(f); return(3); } } return(0);}/** Function reads cross-section database from file with name stored in the in @param in - string with database file name @retval 0 - on succes @retval 1 - if fails opening file @retval 2 - if fails reading number of cross-section types @retval 3 - if fails reading cross-section parameters*/long input_crs(char *in){ FILE *f = NULL; f = fopen(in, "rt"); if (f == NULL) { fprintf(stderr, "\nError - unable open cross-section file :\n %s\n", in); return(1); } Dbcrs = new dbcrs; // allocating new dbcrs class if (getlong(f, Dbcrs->numt)) // reading number of cross-section types { fprintf(stderr, "\nError reading number of cross-section types\n"); fclose(f); return(2); } Dbcrs->crs = new csec[Dbcrs->numt]; // allocating memory for each cross-section types Ncu = new long[Dbcrs->numt]; // allocating array with number used cross-sections memset(Ncu, 0, sizeof(*Ncu)*Dbcrs->numt); for (long i = 0; i < Dbcrs->numt; i++) { // reading cross-section properties for given cross-section type if (Dbcrs->crs[i].read(f)) { fclose(f); return(3); } } return(0);}/** Function reads property data of nodes and elements fro file in. @param in - poinetr to opened input file with property description @param npropn - number of property entries in section of nodal properties @param nprope - number of property entries in section of element properties @param nl - total number of lines scanned in nodal and element section @retval 0 : if succes @retval 1 : if fails reading property type of node @retval 2 : if fails reading property ndof of node @retval 3 : if ndof property of node hasn't been entered before node property, which needs ndof. @retval 4 : if fails reading boundary condition of nodes @retval 5 : if fails reading nodal load @retval 6 : if fails reading cross-section of node @retval 7 : if fails reading transformation vectors of local system in the node @retval 8 : if fails reading dynamic nodal load @retval 9 : if fails reading initial condition @retval 10 : if fails reading common code numbers in the nodes @retval 11 : if fails reading temperature load of node @retval 12 : if fails reading time function of node @retval 21 : if fails reading property type of element @retval 22 : if fails reading element type property of element @retval 23 : if fails reading material property of element @retval 24 : if fails reading cross-section property of element @retval 25 : if fails reading load property of element @retval 26 : if fails reading dynamic load property of element @retval 27 : if fails reading local coordinate system property of element @retval 28 : if fails reading edge load property of element @retval 29 : if fails reading surface load property of element @retval 31 : if fails reading number nodal property entries @retval 32 : if fails reading number element property entries*/long input_prop(XFILE *xin, long &npropn, long &nprope, long &nl){ long nprop, i, j, numl; long nv, nne, ret, ndofn, ccn = 1, ndir, dir; proptype tp; bocon *tbc; inicon *tic; loadel *tle;// dloadel *tdle; loadn *tln; dloadn *tdln; vector *tlsv; tempload *ttln; FILE *in = xin->file; getgkwid(xin, 0, numl); nl = numl; nprop = getnprop(xin, numl); nl += numl; if (nprop < 0) // reading number of lines with nodal propreties return(31); npropn = nprop; Nnp = new long[nprop]; // Array with property numbers Ndofn = new long[nprop]; // Array with ndof memset(Ndofn, 0, sizeof(*Ndofn)*nprop); // setting all ndof of each property to zero for (i = 0; i < nprop; Nnp[i] = -1, i++); Boc = new bocon*[nprop]; // Array with bounadry condition memset(Boc, 0, sizeof(*Boc)*nprop); // setting each bc pointer to NULL Ncs = new crsectype[nprop]; // Array of cross-section types in the nodes memset(Ncs, 0, sizeof(*Ncs)*nprop); // setting each cs type to zero Ncsi = new long[nprop]; // Array of cross-section indeces memset(Ncsi, 0, sizeof(*Ncsi)*nprop); // setting each cs to zero// Ncsn = 0; Nlsv = new vector*[nprop]; // Array with pointers to the // local coordinate system base vectors arrays memset(Nlsv, 0, sizeof(*Nlsv)*nprop); // setting each pointer lcs base vector array to NULL Lno = new loadn*[nprop]; // Array with pointers to the nodal load memset(Lno, 0, sizeof(*Lno)*nprop); // setting each pointer to NULL Dlno = new dloadn*[nprop]; // Array with pointers to the dynamic nodal load memset(Dlno, 0, sizeof(*Dlno)*nprop); // setting each pointer to NULL Nccn = new long*[nprop]; memset(Nccn, 0, sizeof(*Nccn)*nprop); Inic = new inicon*[nprop]; memset(Inic, 0, sizeof(*Inic)*nprop); Ntemp = new tempload*[nprop]; memset(Ntemp, 0, sizeof(*Ntemp)*nprop); Ntempl = 0; Ninic = 0; fprintf(stdout, "\nReading nodal properties (number of entries : %ld) . . .", nprop); // reading node properties for (i = 0; i < nprop; i++) { // reading property number and type of nodal property (tp) if (getlong(in, Nnp[i])) return(1); tp = proptype(getpkw(in)+1); switch(tp) { case ndofs : // reading number of degrees of freedom { fprintf(stdout, "\n reading ndofn"); if (getlong(in, Ndofn[i])) return(2); break; } case boundarycond : // reading boundary condition and prescribed displacements { fprintf(stdout, "\n reading boundary condition"); for (j = 0, ndofn = 0; j < i; j++) // searching read properties whether given nodal property has assigned ndof { if ((Nnp[j] == Nnp[i]) && (Ndofn[j] > 0)) { ndofn = Ndofn[j]; break; } } if (ndofn == 0) // cannot find property with description of ndof return(3); tbc = new bocon; // allocating temporary boundary condition class if ((ret = tbc->read_prop(in, ndofn))) // reading boundary condition return(4); Boc[i] = tbc; // storing pointer to the nodal bc break; } case loadnodes : // reading nodal load { fprintf(stdout, "\n reading nodal load"); for (j = 0, ndofn = 0; j < i; j++) // searching read properties whether given nodal property has assigned ndof { if ((Nnp[j] == Nnp[i]) && (Ndofn[j] > 0)) { ndofn = Ndofn[j]; break; } } if (ndofn == 0) // cannot find property with description of ndof return(3); tln = new loadn; // allocating temporary nodal load class if ((ret = tln->read_prop(in, ndofn, Nlc))) // reading nodal load return(5); Lno[i] = tln; // storing pointer to the nodal load break; } case crosssec : // reading cross-section in the node { fprintf(stdout, "\n reading cross-section"); if (getint(in, (int &)Ncs[i]) || getlong(in, Ncsi[i])) // reading cross-section type and index number return(6); if ((Ncs[i] == 0) || (Ncsi[i] == 0)) return(6); break; } case localsystem : // reading local coordinate system { fprintf(stdout, "\n reading nodal lcs"); getlong(in, nv); // reading number of lcs base vectors switch (nv) { case 2 : tlsv = new vector[nv]; // allocating temporary array of lcs base vectors for (j=0; j<nv; j++) allocv(2, tlsv[j]); if (readv(in, tlsv[0])) // reading the first base vector return(7); if (readv(in, tlsv[1])) // reading the second base vector return(7); Nlsv[i] = tlsv; // storing pointer to the array of lcs base vectors break; case 3 : tlsv = new vector[nv]; for (j=0; j<nv; j++) allocv(3, tlsv[j]); if (readv(in, tlsv[0])) // reading the first base vector return(7); if (readv(in, tlsv[1])) // reading the second base vector return(7); if (readv(in, tlsv[2])) // reading the third base vector return(7); Nlsv[i] = tlsv; // storing pointer to the array of lcs base vectors break; default : return(7); } // end of case number of lcs base vectors break; } // end of main case case dloadnodes : // reading nodal load { fprintf(stdout, "\n reading dynamic nodal load"); for (j = 0, ndofn = 0; j < i; j++) // searching read properties whether given nodal property has assigned ndof { if ((Nnp[j] == Nnp[i]) && (Ndofn[j] > 0)) { ndofn = Ndofn[j]; break; } } if (ndofn == 0) // cannot find property with description of ndof return(3); tdln = new dloadn; // allocating temporary nodal load class if (tdln->read_prop(in, ndofn, Nlc)) // reading nodal load return(8); Dlno[i] = tdln; // storing pointer to the nodal load break; } case initcond : // reading initial condition { Ninic = 1; fprintf(stdout, "\n reading initial condition"); for (j = 0, ndofn = 0; j < i; j++) // searching read properties whether given nodal property has assigned ndof { if ((Nnp[j] == Nnp[i]) && (Ndofn[j] > 0)) { ndofn = Ndofn[j]; break; } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -