📄 barel3d.cpp
字号:
#include <math.h>#include "barel3d.h"#include "global.h"#include "globmat.h"#include "genfile.h"#include "element.h"#include "node.h"#include "intpoints.h"#include "loadcase.h"/** JK, 27.9.2005*/barel3d::barel3d (void){ long i; // number nodes on element nne=2; // number of DOFs on element ndofe=6; // number of strain/stress components tncomp=1; // number of functions approximated napfun=3; ssst = bar; // number of blocks (parts of geometric matrix) nb=1; // number of strain/stress components ncomp = new long [nb]; ncomp[0]=1; // cumulative number of components approximated cncomp = new long [nb]; cncomp[0]=0; // number of integration points // order of numerical integration of stiffness matrix nip = new long* [nb]; intordsm = new long* [nb]; for (i=0;i<nb;i++){ nip[i] = new long [nb]; intordsm[i] = new long [nb]; } nip[0][0]=1; // total number of integration points tnip=0; for (i=0;i<nb;i++){ tnip+=nip[i][i]; } intordsm[0][0]=1;}barel3d::~barel3d (void){ long i; for (i=0;i<nb;i++){ delete [] nip[i]; delete [] intordsm[i]; } delete [] nip; delete [] intordsm; delete [] cncomp; delete [] ncomp; delete [] nip;}void barel3d::eleminit (long eid){ long ii,jj; Mt->elements[eid].nb=nb; Mt->elements[eid].intordsm = new long* [nb]; Mt->elements[eid].nip = new long* [nb]; for (ii=0;ii<nb;ii++){ Mt->elements[eid].intordsm[ii] = new long [nb]; Mt->elements[eid].nip[ii] = new long [nb]; for (jj=0;jj<nb;jj++){ Mt->elements[eid].intordsm[ii][jj]=intordsm[ii][jj]; Mt->elements[eid].nip[ii][jj]=nip[ii][jj]; } }}/** function computes direction %vector @param s - direction %vector @param x,y,z - vectors of nodal coordinates JK, 28.9.2005*/void barel3d::dirvect (vector &s,double &l,vector &x,vector &y,vector &z){ s[0]=x[1]-x[0]; s[1]=y[1]-y[0]; s[2]=z[1]-z[0]; l=sqrt(s[0]*s[0]+s[1]*s[1]+s[2]*s[2]); if (l<Mp->zero){ fprintf (stderr,"\n\n zero norm of direction vector in function dirvect (file %s, line %d).\n",__FILE__,__LINE__); } s[0]/=l; s[1]/=l; s[2]/=l;}/** function assembles strain-displacement (geometric) %matrix @param gm - strain-displacement (geometric) %matrix @param s - direction %vector JK, 27.9.2005*/void barel3d::geom_matrix (matrix &gm,vector &s,double l){ gm[0][0]=s[0]/l*(-1.0); gm[0][1]=s[1]/l*(-1.0); gm[0][2]=s[2]/l*(-1.0); gm[0][3]=s[0]/l; gm[0][4]=s[1]/l; gm[0][5]=s[2]/l;}/** function approximates function defined by nodal values @param xi - coordinate on element @param nodval - nodal values JK, 27.9.2005*/double barel3d::approx (double xi,vector &nodval){ double f; vector bf(nne); bf_lin_1d (bf.a,xi); scprd (bf,nodval,f); return f;}/** function assembles transformation %matrix from local nodal coordinate system to the global coordinate system x_g = T x_l @param nodes - array containing node numbers @param tmat - transformation %matrix JK, 3.2.2002*/void barel3d::transf_matrix (ivector &nodes,matrix &tmat){ long i; fillm (0.0,tmat); for (i=0;i<tmat.m;i++){ tmat[i][i]=1.0; } for (i=0;i<nodes.n;i++){ if (Mt->nodes[nodes[i]].transf>0){ tmat[i*2+0][i*2]=Mt->nodes[nodes[i]].e1[0]; tmat[i*2+0][i*2+1]=Mt->nodes[nodes[i]].e2[0]; tmat[i*2+1][i*2]=Mt->nodes[nodes[i]].e1[1]; tmat[i*2+1][i*2+1]=Mt->nodes[nodes[i]].e2[1]; } }}void barel3d::tran_mat (vector &x, matrix &tmat,vector &gx,vector &gy){ long i,j; vector gv(2*gx.n),lv(2*gx.n); j=0; for (i=0;i<gx.n;i++){ gv[j]=gx[i]; j++; gv[j]=gy[i]; j++; } //globloctransf (gv,lv,tmat); glvectortransf (gv,lv,tmat); for (i=0;i<gx.n;i++){ x[i]=lv[i*2]; }}/** function computes stiffness %matrix of threedimensonal element @param eid - element id @param ri,ci - row and column indices @param sm - stiffness %matrix JK, 27.9.2005*/void barel3d::stiffness_matrix (long eid,long ri,long ci,vector &s,matrix &sm){ long ipp; double l,a,jac; vector x(nne),y(nne),z(nne); matrix gm(tncomp,ndofe),d(tncomp,tncomp); fillm (0.0,sm); // node coordinates Mt->give_node_coord3d (x,y,z,eid); // length of the element l=sqrt ((x[1]-x[0])*(x[1]-x[0]) + (y[1]-y[0])*(y[1]-y[0]) + (z[1]-z[0])*(z[1]-z[0])); if (l<Mp->zero){ fprintf (stderr,"\n\n zero length of the %ld truss element",eid); fprintf (stderr,"\n in function barel3d::stiffness_matrix (barel3d.cpp).\n"); } // strain-displacement matrix geom_matrix (gm,s,l); // integration point id ipp=Mt->elements[eid].ipp[ri][ci]; // stiffness matrix of material Mm->matstiff (d,ipp); // are of cross section Mc->give_area (eid,a); jac=a*l; bdbj (sm.a,gm.a,d.a,jac,gm.m,gm.n); }/** function computes stiffness %matrix @param eid - element id @param sm - stiffness %matrix JK, 27.9.2005*/void barel3d::res_stiffness_matrix (long eid,matrix &sm){ long transf; double l; ivector nodes(nne); vector x(nne),y(nne),z(nne),s(3); matrix tmat (ndofe,ndofe); // node coordinates Mt->give_node_coord3d (x,y,z,eid); // direction vector dirvect (s,l,x,y,z); stiffness_matrix (eid,0,0,s,sm); // nodes on element Mt->give_elemnodes (eid,nodes); // transformation of stiffness matrix from global coordinate system // to the local nodal systems transf = Mt->locsystems (nodes); if (transf>0){ transf_matrix (nodes,tmat); glmatrixtransf (sm,tmat); }}/** function computes mass %matrix of threedimensional bar element @param eid - element id @param mm - mass %matrix JK, 27.9.2005*/void barel3d::mass_matrix (long eid,matrix &mm){ double l,a,rho; vector x(nne),y(nne),z(nne); fillm (0.0,mm); Mt->give_node_coord3d (x,y,z,eid); // length of the element l=sqrt ((x[1]-x[0])*(x[1]-x[0])+(y[1]-y[0])*(y[1]-y[0])); if (l<Mp->zero){ fprintf (stderr,"\n\n zero length of the %ld truss element",eid); fprintf (stderr,"\n in function barel3d::mass_matrix (%s, line %d).\n",__FILE__,__LINE__); } Mc->give_area (eid,a); Mc->give_densitye (eid,rho); mm[0][0]=a*rho*l*1.0/3.0; mm[0][1]=0.0; mm[0][2]=a*rho*l*1.0/6.0; mm[0][3]=0.0; mm[1][0]=0.0; mm[1][1]=a*rho*l*1.0/3.0; mm[1][2]=0.0; mm[1][3]=a*rho*l*1.0/6.0; mm[2][0]=a*rho*l*1.0/6.0; mm[2][1]=0.0; mm[2][2]=a*rho*l*1.0/3.0; mm[2][3]=0.0; mm[3][0]=0.0; mm[3][1]=a*rho*l*1.0/6.0; mm[3][2]=0.0; mm[3][3]=a*rho*l*1.0/3.0;}void barel3d::giveloccoord(vector &x, vector &y,vector &lx){ double l; lx[0] = 0.0; l = sqr(x[1] - x[0]) + sqr(y[1] - y[0]); l = sqrt(l); lx[1] = l;}/** function computes strains at integration points @param lcid - load case id @param eid - element id @param ri,ci - row and column indices JK, 4.10.2005*/void barel3d::res_ip_strains (long lcid,long eid){ long transf; double l; vector gx(nne),gy(nne),gz(nne),s(3),r(ndofe),aux(ndofe); ivector cn(ndofe),nodes(nne); matrix tmat(ndofe,ndofe); // node coordinates Mt->give_node_coord3d (gx,gy,gz,eid); // direction vector dirvect (s,l,gx,gy,gz); // code numbers Mt->give_code_numbers (eid,cn.a); // assembling of displacements defined on the element eldispl (lcid,eid,r.a,cn.a,ndofe); // transformation of displacement vector // (in the case of nodal coordinate systems) Mt->give_elemnodes (eid,nodes); transf = Mt->locsystems (nodes); if (transf>0){ // transformation matrix transf_matrix (nodes,tmat); lgvectortransf (aux,r,tmat); copyv (aux,r); } ip_strains (lcid,eid,0,0,s,r,l); }/** function computes strains at integration points of element @param lcid - load case id @param eid - element id @param ri - row index @param ci - column index @param s - direction %vector @param r - vector of nodal displacements JK, 3.10.2005*/void barel3d::ip_strains (long lcid,long eid,long ri,long ci,vector &s,vector &r,double l){ long i,ipid; vector eps(tncomp); matrix gm(tncomp,ndofe); ipid=Mt->elements[eid].ipp[ri][ci]; for (i=0;i<intordsm[0][0];i++){ // geometrix matrix geom_matrix (gm,s,l); // strain computation mxv (gm,r,eps); // strain storage Mm->storestrain (lcid,ipid,eps); ipid++; }}/** function computes strains in nodes of element @param lcid - load case id @param eid - element id @param ri,ci - row and column indices JK, 10.5.2002*/void barel3d::nod_strains_ip (long lcid,long eid,long ri,long ci){ long i,j,ipid; ivector ipnum(nne),nod(nne); vector eps(tncomp); // numbers of integration points closest to nodes // (function is from the file GEFEL/ordering.cpp) ipid=Mt->elements[eid].ipp[ri][ci]; nodip_bar (ipid,intordsm[0][0],ipnum); // node numbers of the element Mt->give_elemnodes (eid,nod); for (i=0;i<nne;i++){ // strains at the closest integration point Mm->givestrain (lcid,ipnum[i],eps); // storage of strains to the node j=nod[i]; Mt->nodes[j].storestrain (lcid,0,eps); }}/** function computes strains at strain points @param lcid - load case id @param eid - element id @param ri,ci - row and column indices JK*/void barel3d::strains (long lcid,long eid,long ri,long ci){ long i,naep,ncp,sid; vector coord,eps; switch (Mm->stra.tape[eid]){ case nowhere:{ break; } case intpts:{ //allip_strains (lcid,eid,ri,ci); break; } case enodes:{ nod_strains_ip (lcid,eid,ri,ci); break; } case userdefined:{ // number of auxiliary element points naep = Mm->stra.give_naep (eid); ncp = Mm->stra.give_ncomp (eid); sid = Mm->stra.give_sid (eid); allocv (ncp,eps); allocv (1,coord); for (i=0;i<naep;i++){ Mm->stra.give_aepcoord (sid,i,coord); if (Mp->strainaver==0) //appval (coord[0],0,ncp,eps,stra); if (Mp->strainaver==1) //appstrain (lcid,eid,coord[0],0,ncp,eps); Mm->stra.storevalues(lcid,eid,i,eps); } destrv (eps); destrv (coord); break; } default:{ fprintf (stderr,"\n\n unknown strain point is required in function barelq2d::strains (file %s, line %d).\n",__FILE__,__LINE__);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -