⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 axisymlt.cpp

📁 Finite element program for mechanical problem. It can solve various problem in solid problem
💻 CPP
📖 第 1 页 / 共 3 页
字号:
/**   function computes stresses in arbitrary point on element      @param lcid - load case id   @param eid - element id   @param areacoord - area coordinates of the point   @param fi,li - first and last indices   @param sig - array containing stresses      11.5.2002*/void axisymlt::appstress (long lcid,long eid,double xi,double eta,long fi,long ncomp,vector &sig){  long i,j,k;  ivector nodes;  vector areacoord(3),nodval;    if (ncomp != sig.n){    fprintf (stderr,"\n\n wrong interval of indices in function stress (%s, line %d).\n",__FILE__,__LINE__);    abort ();  }  areacoord[0]=xi;  areacoord[1]=eta;  areacoord[2]=1.0-areacoord[0]-areacoord[1];    allocv (nne,nodes);  allocv (nne,nodval);    Mt->give_elemnodes (eid,nodes);  k=0;  for (i=fi;i<fi+ncomp;i++){    for (j=0;j<nne;j++){      nodval[j]=Mt->nodes[nodes[j]].stress[lcid*tncomp+i];    }    sig[k]=approx (areacoord,nodval);    k++;  }    destrv (nodes);  destrv (nodval);}void axisymlt::stresses (long lcid,long eid,long ri,long ci){  vector coord,sig;    switch (Mm->stre.tape[eid]){  case nowhere:{    break;  }  case intpts:{    //allip_stresses (stre,lcid,eid,ri,ci);    break;  }  case enodes:{    nod_stresses_ip (lcid,eid);    break;  }  case userdefined:{    /*    //  number of auxiliary element points    naep = Mm->stre.give_naep (eid);    ncp = Mm->stre.give_ncomp (eid);    sid = Mm->stre.give_sid (eid);    allocv (ncp,sig);    allocv (2,coord);    for (i=0;i<naep;i++){      Mm->stre.give_aepcoord (sid,i,coord);      if (Mp->stressaver==0)	appval (coord[0],coord[1],0,ncp,sig,stre);      if (Mp->stressaver==1)	appstress (lcid,eid,coord[0],coord[1],0,ncp,sig);            Mm->stre.storevalues(lcid,eid,i,sig);    }    destrv (sig);    destrv (coord);    */    break;  }  default:{    fprintf (stderr,"\n\n unknown stress point is required in function planeelemlq::stresses (%s, line %d).\n",__FILE__,__LINE__);  }  }}/**   function computes eqother components at nodes of element      @param lcid - load case id   @param eid - element id      10.5.2002*/void axisymlt::nod_eqother_ip (long lcid,long eid){  long i,j,ncompo;  ivector ipnum(nne),nod(nne);  vector eqother;    //  numbers of integration points closest to nodes  nodipnum (eid,ipnum);    //  node numbers of the element  Mt->give_elemnodes (eid,nod);    for (i=0;i<nne;i++){    ncompo = Mm->givencompeqother (ipnum[i],0);    allocv (ncompo,eqother);    Mm->giveeqother (ipnum[i],0,ncompo,eqother.a);    //  storage of eqother to the node    j=nod[i];    Mt->nodes[j].storeother (lcid,0,ncompo,eqother);    destrv (eqother);  }}/**   function computes load matrix of the triangular axisymmetric   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      25.7.2001*/void axisymlt::load_matrix (long eid,matrix &lm){  long i;  double jac,det;  ivector nodes(nne);  vector x(nne),y(nne),w(intordmm),gp1(intordmm),gp2(intordmm);  matrix n(napfun,ndofe);    Mt->give_elemnodes (eid,nodes);  Mt->give_node_coord2d (x,y,eid);  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]);        //  zkontrolovat deleni dvema    jac=w[i]*det;        nnj (lm.a,n.a,jac,n.m,n.n);  }  }void axisymlt::res_eigstrain_forces (long lcid,long eid,vector &nfor){  vector x(nne),y(nne);  Mt->give_node_coord2d (x,y,eid);  eigstrain_forces (lcid,eid,0,0,nfor,x,y);}/**   function computes nodal forces caused by temperature changes      @param eid - element id   @param ri,ci - row and column indices   @param nfor - array containing nodal forces   @param x,y - nodal coordinates      22.12.2002, JK*/void axisymlt::eigstrain_forces (long lcid,long eid,long ri,long ci,vector &nfor,vector &x,vector &y){  long k,ipp;  double xi,eta,det;  vector eigstr(tncomp),sig(tncomp),contr(ndofe),areacoord(3);  matrix d(tncomp,tncomp),gm(tncomp,ndofe);    //  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]);    fillv (0.0,nfor);    ipp=Mt->elements[eid].ipp[ri][ci];    xi=1.0/3.0;  eta=1.0/3.0;  areacoord[0]=1.0/3.0;  areacoord[1]=1.0/3.0;  areacoord[2]=1.0/3.0;  Mm->giveeigstrain (ipp,cncomp[0],ncomp[0],eigstr);    Mm->matstiff (d,ipp);  mxv (d,eigstr,sig);  geom_matrix (gm,areacoord,x,y);  mtxv (gm,sig,contr);  cmulv (det/2.0,contr);    for (k=0;k<contr.n;k++){    nfor[k]+=contr[k];  }}/**   function computes internal forces      @param lcid - number of load case   @param eid - element id   @param ri,ci - row and column indices   @param ifor - vector of internal forces   17.8.2001*/void axisymlt::internal_forces (long lcid,long eid,long ri,long ci,vector &ifor){  long i,k,ii,ipp;  double rad,det;  ivector nodes(nne),cn(ndofe);  vector x(nne),y(nne),w,gp1,gp2,areacoord(3);  vector r(ndofe),eps(tncomp),sig(tncomp),contr(ndofe),auxcontr(ndofe);  matrix gm(tncomp,ndofe);    Mt->give_node_coord2d (x,y,eid);    fillv (0.0,ifor);    //  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]);    for (ii=0;ii<nb;ii++){    if (intordsm[ii][ii]==0)  continue;        allocv (intordsm[ii][ii],gp1);    allocv (intordsm[ii][ii],gp2);    allocv (intordsm[ii][ii],w);    //allocm (ncomp[ii],ndofe,gm);    //allocv (ncomp[ii],sig);        gauss_points_tr (gp1.a,gp2.a,w.a,intordsm[ii][ii]);    ipp=Mt->elements[eid].ipp[ii][ii];            for (i=0;i<intordsm[ii][ii];i++){      areacoord[0]=gp1[i];      areacoord[1]=gp2[i];      areacoord[2]=1.0-areacoord[0]-areacoord[1];                  Mm->computenlstresses (ipp);            Mm->givestress (lcid,ipp,sig);            geom_matrix (gm,areacoord,x,y);      mtxv (gm,sig,contr);            rad = approx (areacoord,x);      cmulv (rad*w[i]*det,contr);            for (k=0;k<contr.n;k++){	ifor[k]+=contr[k];      }            ipp++;          }    //destrv (sig);  destrm (gm);    destrv (w);  destrv (gp2);  destrv (gp1);  }}void axisymlt::res_internal_forces (long lcid,long eid,vector &ifor){  internal_forces (lcid,eid,0,0,ifor);}void axisymlt::ipcoord (long eid,long sip,long ipp,vector &coord)  //  function returns coordinates of integration points  //  eid - element id  //  ipp - integration point pointer  //  coord - vector of coordinates  //  19.1.2002{  /*  long i,ii;  vector x(nne),y(nne),areacoord(3),w(intordsm),gp1(intordsm),gp2(intordsm);    gauss_points_tr (gp1.a,gp2.a,w.a,intordsm);  Mt->give_node_coord2d (x,y,eid);  ii=Mt->elements[eid].ipp[sip];    for (i=0;i<intordsm;i++){    areacoord[0]=gp1[i];    areacoord[1]=gp2[i];    areacoord[2]=1.0-areacoord[0]-areacoord[1];        if (ii==ipp){      coord[0]=approx (areacoord,x);      coord[1]=approx (areacoord,y);      coord[2]=0.0;    }    ii++;  }  */}void axisymlt::nodeforces (long eid,long *le,double *nv,vector &nf){  /*  long i;  double ww,jac;  vector x(nne),y(nne),areacoord(3),gp(intordb),w(intordb),av(ndofe),v(ndofe);  matrix n(napfun,ndofe),am(ndofe,ndofe);    Mt->give_node_coord2d (x,y,eid);  gauss_points (gp.a,w.a,intordb);  if (le[0]==1){    fillm (0.0,am);    areacoord[0]=0.0;    for (i=0;i<intordb;i++){      areacoord[1]=(1.0+gp[i])/2.0;  areacoord[2]=1.0-areacoord[1];      ww=w[i];            bf_matrix (n,areacoord);            jac1d_2d (jac,x,y,areacoord[1],0);      jac*=ww;            nnj (am.a,n.a,jac,n.m,n.n);    }    fillv (0.0,av);    av[2]=nv[4];  av[3]=nv[5];  av[4]=nv[6];  av[5]=nv[7];    mxv (am,av,v);  addv (nf,v,nf);  }  if (le[1]==1){    fillm (0.0,am);    areacoord[1]=0.0;    for (i=0;i<intordb;i++){      areacoord[0]=(1.0+gp[i])/2.0;  areacoord[2]=1.0-areacoord[0];      ww=w[i];            bf_matrix (n,areacoord);            jac1d_2d (jac,x,y,areacoord[0],1);      jac*=ww;            nnj (am.a,n.a,jac,n.m,n.n);    }    fillv (0.0,av);    av[0]=nv[10];  av[1]=nv[11];  av[4]=nv[8];  av[5]=nv[9];    mxv (am,av,v);  addv (nf,v,nf);  }  if (le[2]==1){    fillm (0.0,am);    areacoord[2]=0.0;    for (i=0;i<intordb;i++){      areacoord[0]=(1.0+gp[i])/2.0;  areacoord[1]=1.0-areacoord[0];      ww=w[i];            bf_matrix (n,areacoord);            jac1d_2d (jac,x,y,areacoord[0],2);      jac*=ww;            nnj (am.a,n.a,jac,n.m,n.n);    }    fillv (0.0,av);    av[0]=nv[0];  av[1]=nv[1];  av[2]=nv[2];  av[3]=nv[3];    mxv (am,av,v);  addv (nf,v,nf);  }  */}void axisymlt::inicipval(long eid, long ri, long ci, matrix &nodval, inictype *ictn){  long i, j, k, ipp;  long ii, jj, nv = nodval.n;  long nstra, ncompstr, ncompeqother;  double xi, eta, ipval;  vector w, gp1, gp2, anv(nne);  long idstra, idstre, idoth, idic;  nstra = idstra = idstre = idoth = idic = 0;  for (j = 0; j < nv; j++) // for all initial values  {    for(i = 0; i < nne; i++)      anv[i] = nodval[i][j];    for (ii = 0; ii < nb; ii++)    {      for (jj = 0; jj < nb; jj++)      {        ipp=Mt->elements[eid].ipp[ri+ii][ci+jj];        if (intordsm[ii][jj] == 0)          continue;        allocv (intordsm[ii][jj],gp1);        allocv (intordsm[ii][jj],gp2);        allocv (intordsm[ii][jj],w);        gauss_points_tr (gp1.a, gp2.a, w.a, intordsm[ii][jj]);        for (k = 0; k < intordsm[ii][jj]; k++)        {          xi=gp1[k];          eta=gp2[k];          //  value in integration point          ipval = approx_nat(xi, eta, anv);          ncompstr =  Mm->ip[ipp].ncompstr;          ncompeqother = Mm->ip[ipp].ncompeqother;          if ((ictn[0] & inistrain) && (j < ncompstr))          {            Mm->ip[ipp].strain[j] += ipval;            ipp++;            continue;          }          if ((ictn[0] & inistress) && (j < nstra + ncompstr))          {            Mm->ip[ipp].stress[j] += ipval;            ipp++;            continue;          }          if ((ictn[0] & iniother) && (j < nstra+ncompeqother))          {            Mm->ip[ipp].eqother[idoth] += ipval;            ipp++;            continue;          }          if ((ictn[0] & inicond) && (j < nv))          {            if (Mm->ic[ipp] == NULL)            {              Mm->ic[ipp] = new double[nv-j];              memset(Mm->ic[ipp], 0, sizeof(*Mm->ic[ipp])*(nv-j)); 	    }            Mm->ic[ipp][idic] += ipval;            ipp++;            continue;          }          ipp++;        }        destrv(gp1);  destrv (gp2);  destrv (w);      }    }    ipp=Mt->elements[eid].ipp[ri][ci];    ncompstr =  Mm->ip[ipp].ncompstr;    ncompeqother = Mm->ip[ipp].ncompeqother;    if ((ictn[0] & inistrain) && (j < ncompstr))    {      nstra++;      idstra++;    }    if ((ictn[0] & inistress) && (j < nstra + ncompstr))    {            nstra++;      idstre++;    }      if ((ictn[0] & iniother)  && (j < nstra + ncompeqother))    {      nstra++;      idoth++;    }    if ((ictn[0] & inicond) && (j < nv))      idic++;  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -