📄 plelemlt.cpp
字号:
#include "plelemlt.h"#include "global.h"#include "globmat.h"#include "genfile.h"#include "adaptivity.h"#include "node.h"#include "element.h"#include "loadcase.h"#include "gadaptivity.h"#include "intpoints.h"#include <stdlib.h>#include <math.h>planeelemlt::planeelemlt (void){ long i,j; // number nodes on element nne=3; // number of DOFs on element ndofe=6; // number of strain/stress components tncomp=3; // number of functions approximated napfun=2; // order of numerical integration of mass matrix intordmm=3; // number of edges on element ned=3; // number of nodes on one edge nned=2; // order of numerical integration on element edges (boundaries) intordb=2; // number of blocks (parts of geometric matrix) nb=1; // number of strain/stress components ncomp = new long [nb]; ncomp[0]=3; // 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++){ for (j=0;j<nb;j++){ tnip+=nip[i][j]; } } intordsm[0][0]=1;}planeelemlt::~planeelemlt (void){ long i; for (i=0;i<nb;i++){ delete [] nip[i]; delete [] intordsm[i]; } delete [] nip; delete [] intordsm; delete [] ncomp; delete [] cncomp;}void planeelemlt::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 approximates function defined by nodal values area coordinates are used @param areacoord - vector containing area coordinates @param nodval - nodal values JK*/double planeelemlt::approx (vector &areacoord,vector &nodval){ double f; scprd (areacoord,nodval,f); return f;}/** function approximates function defined by nodal values natural coordinates are used @param xi,eta - natural coordinates @param nodval - nodal values JK*/double planeelemlt::approx_nat (double xi,double eta,vector &nodval){ double f; vector areacoord(3); // conversion of natural coordinates to area coordinates areacoord[0]=xi; areacoord[1]=eta; areacoord[2]=1.0-areacoord[0]-areacoord[1]; scprd (areacoord,nodval,f); return f;}/** function returns %matrix of base function @param n - %matrix of approximation functions @param xi,eta - natural coordinates JK, 17.8.2001*/void planeelemlt::bf_matrix (matrix &n,double xi,double eta){ vector bf(nne); bf_lin_3_2d (bf.a,xi,eta); fillm (0.0,n); n[0][0]=bf[0]; n[0][2]=bf[1]; n[0][4]=bf[2]; n[1][1]=bf[0]; n[1][3]=bf[1]; n[1][5]=bf[2];}/** function assembles strain-displacement (geometric) %matrix @param gm - geometric %matrix @param x,y - node coordinates JK, 17.8.2001*/void planeelemlt::geom_matrix (matrix &gm,vector &x,vector &y){ double det; vector b(3),c(3); // det is equal to double area of the element det = (x[1]-x[0])*(y[2]-y[0])-(x[2]-x[0])*(y[1]-y[0]); plsb (b.a,y.a,det); plsc (c.a,x.a,det); fillm (0.0,gm); gm[0][0]=b[0]; gm[0][2]=b[1]; gm[0][4]=b[2]; gm[1][1]=c[0]; gm[1][3]=c[1]; gm[1][5]=c[2]; gm[2][0]=c[0]; gm[2][1]=b[0]; gm[2][2]=c[1]; gm[2][3]=b[1]; gm[2][4]=c[2]; gm[2][5]=b[2];}/** function assembles transformation %matrix from local nodal coordinate system to the global coordinate system x_g = T x_l @param inodes - array containing node numbers @param tmat - transfomation %matrix JK, 17.8.2001*/void planeelemlt::transf_matrix (ivector &nodes,matrix &tmat){ long i,n,m; fillm (0.0,tmat); n=nodes.n; m=tmat.m; for (i=0;i<m;i++){ tmat[i][i]=1.0; } for (i=0;i<n;i++){ if (Mt->nodes[nodes[i]].transf>0){ tmat[i*2][i*2] = Mt->nodes[nodes[i]].e1[0]; tmat[i*2][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]; } }}/** function computes stiffness %matrix of plane stress triangular finite element with linear approximation functions @param eid - element id @param ri,ci - row and column indices @param sm - stiffness %matrix @param x,y - node coordinates JK, 17.8.2001*/void planeelemlt::stiffness_matrix (long eid,long ri,long ci,matrix &sm,vector &x,vector &y){ long ipp; double xi,eta,jac,det,thick; ivector nodes(nne); vector t(nne); matrix gm(tncomp,ndofe),d(tncomp,tncomp); // element nodes Mt->give_elemnodes (eid,nodes); // thickness of the element Mc->give_thickness (eid,nodes,t); // det is equal to double area of the element det = (x[1]-x[0])*(y[2]-y[0])-(x[2]-x[0])*(y[1]-y[0]); xi=1.0/3.0; eta=1.0/3.0; fillm (0.0,sm); ipp=Mt->elements[eid].ipp[ri][ci]; // geometric matrix geom_matrix (gm,x,y); // stiffness matrix of material Mm->matstiff (d,ipp); thick = approx_nat (xi,eta,t); // det is equal to double area of the element jac=thick*det/2.0; // contribution to the stiffness matrix of the element bdbj (sm.a,gm.a,d.a,jac,gm.m,gm.n);}/** function computes stiffness %matrix of plane stress triangular finite element with linear approximation functions @param eid - element id @param sm - stiffness %matrix JK, 17.8.2001*/void planeelemlt::res_stiffness_matrix (long eid,matrix &sm){ long transf; ivector nodes(nne); vector x(nne),y(nne); Mt->give_node_coord2d (x,y,eid); stiffness_matrix (eid,0,0,sm,x,y); // transformation of stiffness matrix // (in the case of nodal coordinate systems) Mt->give_elemnodes (eid,nodes); transf = Mt->locsystems (nodes); if (transf>0){ matrix tmat (ndofe,ndofe); transf_matrix (nodes,tmat); glmatrixtransf (sm,tmat); }}/** function computes mass %matrix of the plane stress triangular finite element with linear approximation functions @param eid - number of element @param mm - mass %matrix @param x,y - node coordinates JK, 17.6.2001*/void planeelemlt::mass_matrix (long eid,matrix &mm,vector &x,vector &y){ long i; double jac,det,thick,rho; ivector nodes(nne); vector w(intordmm),gp1(intordmm),gp2(intordmm),t(nne),dens(nne); matrix n(napfun,ndofe); // element nodes Mt->give_elemnodes (eid,nodes); // thickness of the element Mc->give_thickness (eid,nodes,t); // density of the material Mc->give_density (eid,nodes,dens); // det is equal to double area of the element det = (x[1]-x[0])*(y[2]-y[0])-(x[2]-x[0])*(y[1]-y[0]); gauss_points_tr (gp1.a,gp2.a,w.a,intordmm); fillm (0.0,mm); for (i=0;i<intordmm;i++){ bf_matrix (n,gp1[i],gp2[i]); thick = approx_nat (gp1[i],gp2[i],t); rho = approx_nat (gp1[i],gp2[i],dens); jac=w[i]*thick*rho*det; nnj (mm.a,n.a,jac,n.m,n.n); } }/** function computes mass %matrix of the plane stress triangular finite element with linear approximation functions @param eid - number of element @param mm - mass %matrix JK, 17.6.2001*/void planeelemlt::res_mass_matrix (long eid,matrix &mm){ long transf; ivector nodes(nne); vector x(nne),y(nne); Mt->give_node_coord2d (x,y,eid); mass_matrix (eid,mm,x,y); // transformation of mass matrix // (in the case of nodal coordinate systems) Mt->give_elemnodes (eid,nodes); transf = Mt->locsystems (nodes); if (transf>0){ matrix tmat (ndofe,ndofe); transf_matrix (nodes,tmat); glmatrixtransf (mm,tmat); }}/** function computes load %matrix of the plane stress triangular finite element with linear approximation functions load vector is obtained after premultiplying load %matrix by nodal load values @param eid - number of element @param lm - load %matrix @param x,y - node coordinates JK, 25.7.2001*/void planeelemlt::load_matrix (long eid,matrix &lm,vector &x,vector &y){ long i; double jac,det,thick; ivector nodes(nne); vector w(intordmm),gp1(intordmm),gp2(intordmm),b(3),c(3),t(nne); matrix n(napfun,ndofe); Mt->give_elemnodes (eid,nodes); Mc->give_thickness (eid,nodes,t); gauss_points_tr (gp1.a,gp2.a,w.a,intordmm); // det is equal to double area of the element det = (x[1]-x[0])*(y[2]-y[0])-(x[2]-x[0])*(y[1]-y[0]); fillm (0.0,lm); for (i=0;i<intordmm;i++){ bf_matrix (n,gp1[i],gp2[i]); thick = approx_nat (gp1[i],gp2[i],t); // zkontrolovat deleni dvema jac=w[i]*thick*det; nnj (lm.a,n.a,jac,n.m,n.n); } }/** function computes load %matrix of the plane stress triangular finite element with linear approximation functions load vector is obtained after premultiplying load %matrix by nodal load values @param eid - number of element @param lm - load %matrix JK, 25.7.2001*/void planeelemlt::res_load_matrix (long eid,matrix &lm){ long transf; ivector nodes(nne); vector x(nne),y(nne); Mt->give_node_coord2d (x,y,eid); load_matrix (eid,lm,x,y); // transformation of load matrix // (in the case of nodal coordinate systems) Mt->give_elemnodes (eid,nodes); transf = Mt->locsystems (nodes); if (transf>0){ matrix tmat (ndofe,ndofe); transf_matrix (nodes,tmat); glmatrixtransf (lm,tmat); }}/** function computes strains at integration points @param lcid - load case id @param eid - element id JK*/void planeelemlt::res_ip_strains (long lcid,long eid){ vector aux,x(nne),y(nne),r(ndofe); ivector cn(ndofe),nodes(nne); matrix tmat; Mt->give_node_coord2d (x,y,eid); Mt->give_elemnodes (eid,nodes); Mt->give_code_numbers (eid,cn.a); eldispl (lcid,eid,r.a,cn.a,ndofe); // transformation of displacement vector // (in the case of nodal coordinate systems) long transf = Mt->locsystems (nodes); if (transf>0){ allocv (ndofe,aux); allocm (ndofe,ndofe,tmat); transf_matrix (nodes,tmat); //locglobtransf (aux,r,tmat); lgvectortransf (aux,r,tmat); copyv (aux,r); destrv (aux); destrm (tmat); } ip_strains (lcid,eid,0,0,x,y,r);}/** 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 x,y - node coordinates @param r - nodal displacements JK, 10.5.2002*/void planeelemlt::ip_strains (long lcid,long eid,long ri,long ci,vector &x,vector &y,vector &r){ long ipp; vector eps(tncomp); matrix gm(tncomp,ndofe); geom_matrix (gm,x,y); mxv (gm,r,eps); ipp=Mt->elements[eid].ipp[ri][ci]; Mm->storestrain (lcid,ipp,cncomp[0],ncomp[0],eps);}/** function computes strains at nodes of element @param lcid - load case id @param eid - element id @param ri - row index @param ci - column index JK, 10.5.2002*/void planeelemlt::nod_strains (long lcid,long eid,long ri,long ci){ long ipp; double *lsm,*lhs,*rhs; vector nxi(nne),neta(nne),eps,aux,natcoord(2); ivector nodes(nne); // natural coordinates of element nodes // (function is from the file GEFEL/ordering.cpp) nodcoord_planelt (nxi,neta); Mt->give_elemnodes (eid,nodes); allocv (ncomp[0],eps); lhs = new double [ncomp[0]*3]; rhs = new double [ncomp[0]*3]; lsm = new double [9]; nullv (lsm,9); nullv (rhs,ncomp[0]*3); ipp=Mt->elements[eid].ipp[ri][ci]; Mm->givestrain (lcid,ipp,cncomp[0],ncomp[0],eps); natcoord[0]=1.0/3.0; natcoord[1]=1.0/3.0; matassem_lsm (lsm,natcoord); rhsassem_lsm (rhs,natcoord,eps); solve_lsm (lsm,lhs,rhs,Mp->zero,3,ncomp[0]); Mt->strain_nodal_values (nodes,nxi,neta,nxi,lhs,2,cncomp[0],ncomp[0],lcid); delete [] lsm; delete [] lhs; delete [] rhs; destrv (eps); destrv (nodes);}/** function computes strains on element @param val - array containing strains on element @param lcid - load case id @param eid - element id 15.7.2002*/void planeelemlt::elem_strains (double **stra,long lcid,long eid,long ri,long ci){ long i,ii,ipp; double xi,eta,*lsm,*lhs,*rhs; vector nxi(nne),neta(nne),gp1,gp2,w,eps,aux,natcoord(2); lsm = new double [9]; // natural coordinates of element nodes // (function is from the file GEFEL/ordering.cpp) nodcoord_planelt (nxi,neta); for (ii=0;ii<nb;ii++){ allocv (intordsm[ii][ii],gp1); allocv (intordsm[ii][ii],gp2); allocv (intordsm[ii][ii],w); allocv (ncomp[ii],eps); lhs = new double [ncomp[ii]*3]; rhs = new double [ncomp[ii]*3]; gauss_points_tr (gp1.a,gp2.a,w.a,intordsm[ii][ii]); nullv (lsm,9); nullv (rhs,ncomp[ii]*3); ipp=Mt->elements[eid].ipp[ri+ii][ci+ii]; for (i=0;i<intordsm[ii][ii];i++){ xi=gp1[i]; eta=gp2[i]; Mm->givestrain (lcid,ipp,cncomp[ii],ncomp[ii],eps); natcoord[0]=xi; natcoord[1]=eta; matassem_lsm (lsm,natcoord); rhsassem_lsm (rhs,natcoord,eps); ipp++; } solve_lsm (lsm,lhs,rhs,Mp->zero,3,ncomp[ii]); nodal_values (stra,nxi,neta,nxi,lhs,2,cncomp[ii],ncomp[ii]); delete [] lhs; delete [] rhs; destrv (eps); destrv (w); destrv (gp1); destrv (gp2); } delete [] lsm;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -