📄 loadel.cpp
字号:
#include "loadel.h"#include "global.h"#include "globmat.h"#include "matrix.h"#include "intools.h"#include "elemhead.h"/** This constructor inializes attributes to zero values.*/loadel::loadel(){ eid = nlc = ndl = 0L; nodval = NULL;}/** This destructor deallocates used memory.*/loadel::~loadel(){ delete [] nodval;}/** This function reads element load from the opened text file given by the parameter in. @param in - pointer to the opened text file @retval 0 - on success*/long loadel::read (XFILE *in){ xfscanf(in,"%ld",&eid); if (eid<1) fprintf (stderr,"\n\n nonpositive number of loaded element in function loadel::read (file %s, line %d)",__FILE__,__LINE__); if (eid>Mt->ne){ fprintf (stderr,"\n\n number of loaded element in function loadel::read (file %s, line %d)",__FILE__,__LINE__); fprintf (stderr,"\n is greater than total number of elements.\n"); } eid--; xfscanf (in,"%d",(int*)&tel); switch (tel){ case volume:{ readvolumeload (in); break; } case edge:{ readedgeload (in); break; } case surface:{ readsurfaceload (in); break; } default:{ fprintf (stderr,"\n\n unknown type of element load is required in function loadel::read (file %s, line %d)",__FILE__,__LINE__); } } switch (tel){ case volume:{ volumeload (); break; } case surface:{ surfaceload (); break; } case edge:{ edgeload (); break; } default:{ fprintf (stderr,"\n\n unknown type of element load is required in function loadel::read (file %s, line %d)",__FILE__,__LINE__); } } return(0);}/** This function reads element volume load from the opned text file given by the parameter in. @param in - pointer to the opened text file*/void loadel::readvolumeload (XFILE *in){ long i; ndofe=Mt->give_ndofe (eid); nodval = new double [ndofe]; for (i=0;i<ndofe;i++){ xfscanf (in,"%lf",nodval+i); }}/** This function reads element edge load from the opned text file given by the parameter in. @param in - pointer to the opened text file*/void loadel::readedgeload (XFILE *in){ long i,j,k,l; ned=Mt->give_ned (eid); nned=Mt->give_nned (eid); napfun=Mt->give_napfun (eid); nodval = new double [ned*nned*napfun]; for (i=0;i<ned*nned*napfun;i++){ nodval[i]=0.0; } le = new long [ned]; l=0; for (i=0;i<ned;i++){ xfscanf (in,"%ld",le+i); if (le[i]==1){ for (j=0;j<nned;j++){ for (k=0;k<napfun;k++){ xfscanf (in,"%lf",nodval+l); l++; } } } else{ l+=nned*napfun; } }}/** This function reads element surface load from the opened text file given by the parameter in. @param in - pointer to the input file*/void loadel::readsurfaceload (XFILE *in){ long i,j,k,l; nsurf=Mt->give_nsurf (eid); nnsurf=Mt->give_nnsurf (eid); napfun=Mt->give_napfun (eid); nodvals = new double [nsurf*nnsurf*napfun]; for (i=0;i<nsurf*nnsurf*napfun;i++){ nodvals[i]=0.0; } ls = new long [nsurf]; l=0; for (i=0;i<nsurf;i++){ xfscanf (in,"%ld",ls+i); // ls=0 - surface is not loaded // ls=1 - surface is loaded by load defined in global system // ls=2 - surface is loaded by load defined in local system if (ls[i]==1 || ls[i]==2){ for (j=0;j<nnsurf;j++){ for (k=0;k<napfun;k++){ xfscanf (in,"%lf",nodvals+l); l++; } } } else{ l+=nnsurf*napfun; } }}/** This function computes volume load contribution to the element load vector or matrix respectively.*/void loadel::volumeload (){ long ndofe; matrix lm; ndofe = Mt->give_ndofe (eid); allocm (ndofe,ndofe,lm); allocv (ndofe,nf); switch (Mt->give_elem_type (eid)){ case bar2d:{ break; } case beam3d:{ Beam3d->load_matrix (eid,lm); break; } case planeelementlt:{ Pelt->res_load_matrix (eid,lm); break; } case planeelementqt:{ Peqt->load_matrix (eid,lm); break; } case planeelementlq:{ Pelq->res_load_matrix (eid,lm); break; } case planeelementqq:{ Peqq->res_load_matrix (eid,lm); break; } case planeelementrotlt:{ Perlt->load_matrix (eid,lm); break; } case cctel:{ Cct->load_matrix (eid,lm); break; } case q4plateel:{ Q4pl->load_matrix (eid,lm); break; } case axisymmlq:{ Asymlq->load_matrix (eid,lm); break; } case axisymmqq:{ Asymqq->load_matrix (eid,lm); break; } case lineartet:{ Ltet->load_matrix (eid,lm); break; } case linearhex:{ Lhex->load_matrix (eid,lm); break; } case quadrhex:{ Qhex->load_matrix (eid,lm); break; } default:{ fprintf (stderr,"\n\n unknown element type is required in function"); fprintf (stderr,"\n loadel::volumeload (file %s, line %d).\n",__FILE__,__LINE__); } } mxv (lm.a,nodval,nf.a,ndofe,ndofe); }/** This function computes edge load contribution to the element load vector or matrix respectively.*/void loadel::edgeload (){ ndofe=Mt->give_ndofe (eid); allocv (ndofe,nf); switch (Mt->give_elem_type (eid)){ case bar2d:{ break; } case planeelementlt:{ Pelt->nodeforces (eid,le,nodval,nf); break; } case planeelementqt:{ Peqt->nodeforces (eid,le,nodval,nf); break; } case planeelementsubqt:{ Pesqt->nodeforces (eid,le,nodval,nf); break; } case planeelementlq:{ Pelq->nodeforces (eid,le,nodval,nf); break; } case planeelementqq:{ Peqq->res_nodeforces (eid,le,nodval,nf); break; } case axisymmlq:{ Asymlq->nodeforces (eid,le,nodval,nf); break; } default:{ fprintf (stderr,"\n\n unknown element type is required in function"); fprintf (stderr,"\n loadel::edgeload (file %s, line %d)",__FILE__,__LINE__); } }}/** This function computes surface load contribution to the element load vector or matrix respectively.*/void loadel::surfaceload (){ ndofe=Mt->give_ndofe (eid); allocv (ndofe,nf); switch (Mt->give_elem_type (eid)){ case lineartet:{ Ltet->node_forces_surf (0,eid,ls,nodvals,nf); break; } case linearhex:{ Lhex->node_forces_surf (0,eid,ls,nodvals,nf); break; } case quadrhex:{ Qhex->node_forces_surf (0,eid,ls,nodvals,nf); break; } default:{ fprintf (stderr,"\n\n unknown element type is required in function"); fprintf (stderr,"\n loadel::surfaceload (file %s, line %d)",__FILE__,__LINE__); } }}/** This function reads element load data from the opened text file given by the parameter in. It is used in the mechprep preprocessor. @param in - pointer to the opened text file @param nne - number of element nodes @param lc - total number of load cases @retval 0 - on success @retval 2 - wrong load case id*/long loadel::read_prop(FILE *in, long nne, long lc){ getlong(in, nlc); getlong(in, ndl); if ((nlc < 1) || (nlc > lc)) return(2); if (nodval == NULL) nodval = new double [nne*ndl]; for (long i = 0; i < ndl*nne; i++) getdouble(in, nodval[i]); return(0);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -