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

📄 plelemlt.cpp

📁 Finite element program for mechanical problem. It can solve various problem in solid problem
💻 CPP
📖 第 1 页 / 共 3 页
字号:
}void planeelemlt::appstrain (long lcid,long eid,double xi,double eta,long fi,long ncomp,vector &eps){  long i,j,k;  ivector nodes;  vector nodval(nne);    if (ncomp != eps.n){    fprintf (stderr,"\n\n wrong interval of indices in function strain (%s, line %d).\n",__FILE__,__LINE__);    abort ();  }    allocv (nne,nodes);  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]].strain[lcid*tncomp+i];    }    eps[k]=approx_nat (xi,eta,nodval);    k++;  }    destrv (nodes);}void planeelemlt::strains (long lcid,long eid,long ri,long ci){  long i,naep,ncp,sid;  double **stra;  vector coord,eps;    if (Mp->strainaver==0){    stra = new double* [nne];    for (i=0;i<nne;i++){      stra[i] = new double [tncomp];    }    elem_strains (stra,lcid,eid,ri,ci);  }  switch (Mm->stra.tape[eid]){  case nowhere:{    break;  }  case intpts:{    //allip_strains (stra,lcid,eid,ri,ci);    break;  }  case enodes:{    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 (2,coord);    for (i=0;i<naep;i++){      Mm->stra.give_aepcoord (sid,i,coord);            if (Mp->strainaver==0)	appval (coord[0],coord[1],0,ncp,eps,stra);      if (Mp->strainaver==1)	appstrain (lcid,eid,coord[0],coord[1],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 planeelemlt::strains (%s, line %d).\n",__FILE__,__LINE__);  }  }  if (Mp->strainaver==0){    for (i=0;i<nne;i++){      delete [] stra[i];    }    delete [] stra;  }}/**   function computes strains in arbitrary point on element      @param xi, eta - natural coordinates of the point   @param eps - array containing strains   @param val - array containing values on element      11.5.2002*/void planeelemlt::appval (double xi,double eta,long fi,long nc,vector &eps,double **val){  long i,j,k;  vector nodval;    k=0;  allocv (nne,nodval);  for (i=fi;i<fi+nc;i++){    for (j=0;j<nne;j++){      nodval[j]=val[j][i];    }    eps[k]=approx_nat (xi,eta,nodval);    k++;  }    destrv (nodval);}/**   function computes stresses at integration points of element   stresses are computed by material models      @param lcid - load case id   @param eid - element id   @param ri - row index   @param ci - column index      JK, 10.5.2002*/void planeelemlt::ip_stresses (long lcid,long eid,long ri,long ci){  long ipp;  ipp=Mt->elements[eid].ipp[ri][ci];  //  computation of correct stresses  if (Mp->strcomp==1)    Mm->computenlstresses (ipp);}/**   function computes stresses at integration points of element   stresses are computed from strains with the help of elastic stiffness      @param lcid - load case id   @param eid - element id   @param ri - row index   @param ci - column index      JK, 27.11.2006*/void planeelemlt::ip_elast_stresses (long lcid,long eid,long ri,long ci){  long ipp;  vector eps(tncomp),sig(tncomp);  matrix d(tncomp,tncomp);    //  stiffness matrix of the material  Mm->matstiff (d,ipp);    //  strains  Mm->givestrain (lcid,ipp,eps);    //  elastic stresses  mxv (d,eps,sig);    Mm->storestress (lcid,ipp,sig);}void planeelemlt::nod_stresses (long lcid,long eid,long ri,long ci){  long ipp;  double xi,eta,*lsm,*lhs,*rhs;  vector nxi(nne),neta(nne),eps,epst,epstt,sig,natcoord(2);  ivector nodes(nne);  matrix d(tncomp,tncomp);    lsm = new double [9];    //  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],sig);  lhs = new double [ncomp[0]*3];  rhs = new double [ncomp[0]*3];    nullv (lsm,9);  nullv (rhs,ncomp[0]*3);    ipp=Mt->elements[eid].ipp[ri][ci];    Mm->matstiff (d,ipp);    fillv (0.0,sig);  allocv (ncomp[0],eps);    xi=1.0/3.0;  eta=1.0/3.0;    if (Mp->strainaver==0)    Mm->givestrain (lcid,ipp,cncomp[0],ncomp[0],eps);  if (Mp->strainaver==1)    appstrain (lcid,eid,xi,eta,cncomp[0],ncomp[0],eps);    /*  if (Mt->elements[eid].presctemp==1){    allocv (tncomp,epstt);    tempstrains (lcid,eid,ipp,xi,eta,epstt);    allocv (ncomp[0],epst);    extract (epst,epstt,cncomp[0],ncomp[0]);    subv (eps,epst,eps);    destrv (epst);  destrv (epstt);  }  */    mxv (d,eps,sig);    natcoord[0]=xi;  natcoord[1]=eta;  matassem_lsm (lsm,natcoord);  rhsassem_lsm (rhs,natcoord,sig);    solve_lsm (lsm,lhs,rhs,Mp->zero,3,ncomp[0]);    Mt->stress_nodal_values (nodes,nxi,neta,nxi,lhs,2,cncomp[0],ncomp[0],lcid);  delete [] lhs;  delete [] rhs;  destrv (sig);  destrv (eps);  delete [] lsm;}void planeelemlt::elem_stresses (double **stra,double **stre,long lcid,long eid,long ri,long ci){  long ipp;  double xi,eta,*lsm,*lhs,*rhs;  vector nxi(nne),neta(nne),eps,epst,epstt,sig,natcoord(2);  ivector nodes(nne);  matrix d(tncomp,tncomp);    lsm = new double [9];    //  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],sig);  lhs = new double [ncomp[0]*3];  rhs = new double [ncomp[0]*3];    nullv (lsm,9);  nullv (rhs,ncomp[0]*3);    ipp=Mt->elements[eid].ipp[ri][ci];    xi=1.0/3.0;  eta=1.0/3.0;    Mm->matstiff (d,ipp);    allocv (tncomp,eps);    if (Mp->strainaver==0)    appval (xi,eta,0,tncomp,eps,stra);  if (Mp->strainaver==1)    appstrain (lcid,eid,xi,eta,cncomp[0],ncomp[0],eps);    /*  if (Mt->elements[eid].presctemp==1){    allocv (tncomp,epstt);    tempstrains (lcid,eid,ipp,xi,eta,epstt);    allocv (ncomp[0],epst);    extract (epst,epstt,cncomp[0],ncomp[0]);    subv (eps,epst,eps);    destrv (epst);  destrv (epstt);  }  */    mxv (d,eps,sig);    natcoord[0]=xi;  natcoord[1]=eta;  matassem_lsm (lsm,natcoord);  rhsassem_lsm (rhs,natcoord,sig);    solve_lsm (lsm,lhs,rhs,Mp->zero,3,ncomp[0]);  nodal_values (stre,nxi,neta,nxi,lhs,2,cncomp[0],ncomp[0]);      delete [] lhs;  delete [] rhs;  destrv (sig);  destrv (eps);    delete [] lsm;}/**   function computes stresses in arbitrary point on element      @param eid - element id   @param xi, eta - natural coordinates of the point   @param fi,li - first and last indices   @param sig - array containing stresses      11.5.2002*/void planeelemlt::appstress (long lcid,long eid,double xi,double eta,long fi,long ncomp,vector &sig){  long i,j,k;  ivector nodes;  vector nodval;    if (ncomp != sig.n){    fprintf (stderr,"\n\n wrong interval of indices in function stress (%s, line %d).\n",__FILE__,__LINE__);    abort ();  }  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_nat (xi,eta,nodval);    k++;  }    destrv (nodes);  destrv (nodval);}void planeelemlt::stresses (long lcid,long eid,long ri,long ci){  long i,naep,ncp,sid;  double **stra,**stre;  vector coord,sig;    if (Mp->stressaver==0){    stra = new double* [nne];    stre = new double* [nne];    for (i=0;i<nne;i++){      stra[i] = new double [tncomp];      stre[i] = new double [tncomp];    }    elem_strains (stra,lcid,eid,ri,ci);    elem_stresses (stra,stre,lcid,eid,ri,ci);  }  switch (Mm->stre.tape[eid]){  case nowhere:{    break;  }  case intpts:{    //allip_stresses (stre,lcid,eid,ri,ci);    break;  }  case enodes:{    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__);  }  }  if (Mp->stressaver==0){    for (i=0;i<nne;i++){      delete [] stra[i];      delete [] stre[i];    }    delete [] stra;    delete [] stre;  }}void planeelemlt::nod_others (long lcid,long eid,long ri,long ci){  long ipp, i, ncomp;  double *lsm,*lhs,*rhs;  vector nxi(nne),neta(nne),other,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);  ipp=Mt->elements[eid].ipp[ri][ci];  ncomp = Mm->ip[ipp].ncompother;  allocv (ncomp,other);  lhs = new double [ncomp*3];  rhs = new double [ncomp*3];  lsm = new double [9];    nullv (lsm,9);  nullv (rhs,ncomp*3);    for (i = 0;i < ncomp; i++)    other[i] = Mm->ip[ipp].eqother[i];  natcoord[0]=1.0/3.0;  natcoord[1]=1.0/3.0;  matassem_lsm (lsm,natcoord);  rhsassem_lsm (rhs,natcoord,other);    solve_lsm (lsm,lhs,rhs,Mp->zero,3,ncomp);  Mt->other_nodal_values (nodes,nxi,neta,nxi,lhs,2,0,ncomp,lcid);    delete [] lsm;  delete [] lhs;  delete [] rhs;  destrv (other);  destrv (nodes);}/**   function computes correct stresses at integration points on element   @param lcid - number of load case   @param eid - element id   @param ri,ci - row and column indices      JK, 27.11.2006*/void planeelemlt::compute_nlstress (long lcid,long eid,long ri,long ci){  long ipp;    ipp=Mt->elements[eid].ipp[ri][ci];    //  computation of correct stresses  if (Mp->strcomp==1)    Mm->computenlstresses (ipp);  }/**   function computes nonlocal correct stresses at integration points on element      @param lcid - number of load case   @param eid - element id   @param ri,ci - row and column indices      JK, 27.11.2006*/void planeelemlt::compute_nonloc_nlstress (long lcid,long eid,long ri,long ci){  long ipp;    ipp=Mt->elements[eid].ipp[ri][ci];    //  computation of correct stresses  if (Mp->strcomp==1)    Mm->compnonloc_nlstresses (ipp);  }/**   function computes nonlocal correct stresses at integration points on element      @param lcid - number of load case   @param eid - element id   @param ri,ci - row and column indices      JK, 27.11.2006*/void planeelemlt::compute_eigstress (long lcid,long eid,long ri,long ci){  long ipp;  vector eigstr(tncomp),sig(tncomp);  matrix d(tncomp,tncomp);    ipp=Mt->elements[eid].ipp[ri][ci];    Mm->giveeigstrain (ipp,eigstr);    //  matrix of stiffness of the material  Mm->matstiff (d,ipp);    mxv (d,eigstr,sig);    Mm->storeeigstress (ipp,sig);}/**   function integrates selected quantity over the finite element   it results in nodal values      @param iq - type of integrated quantity (see alias.h)   @param lcid - number of load case   @param eid - element id   @param ri,ci - row and column indices   @param nv - nodal values   @param x,y - node coordinates      JK, 27.11.2006*/void planeelemlt::elem_integration (integratedquant iq,long lcid,long eid,long ri,long ci,vector &nv,vector &x,vector &y){  long ipp;  double xi,eta,det,thick;  ivector nodes(nne);  vector t(nne),ipv(tncomp),contr(ndofe);  matrix gm(tncomp,ndofe);    Mc->give_thickness (eid,nodes,t);    fillv (0.0,nv);    ipp=Mt->elements[eid].ipp[ri][ci];    xi=1.0/3.0;  eta=1.0/3.0;  thick = approx_nat (xi,eta,t);      switch (iq){  case locstress:{    //  stress reading from integration point    Mm->givestress (lcid,ipp,ipv);    break;  }  case nonlocstress:{    //  stress reading from integration point    Mm->givestress (lcid,ipp,ipv);    break;  }  case eigstress:{    //  eigenstress reading from integration point    Mm->giveeigstress (ipp,ipv);    break;  }  default:{    fprintf (stderr,"\n\n unknown type of quantity is required in function plelemlt::elem_integration (file %s, line %d).\n",__FILE__,__LINE__);  }  }      //  strain-displacement (geometric) matrix  geom_matrix (gm,x,y);    //  contribution to the nodal values  mtxv (gm,ipv,contr);    //  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]);  cmulv (det*thick/2.0,contr);    //  summation  addv(contr,nv,nv);}/**   function computes nodal forces caused by eigenstrains   eigenstrain expresses e.g. temperature strains      @param lcid - load case id   @param eid - element id   @param nfor - array containing nodal forces      JK, 27.11.2006*/void planeelemlt::res_eigstrain_forces (long lcid,long eid,vector &nfor){  long transf;  ivector nodes (nne);  vector v(ndofe),x(nne),y(nne);  Mt->give_node_coord2d (x,y,eid);  eigstrain_forces (lcid,eid,0,0,nfor,x,y);

⌨️ 快捷键说明

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