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

📄 linhex.cpp

📁 Finite element program for mechanical problem. It can solve various problem in solid problem
💻 CPP
📖 第 1 页 / 共 5 页
字号:
void linhex::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 (3,coord);    for (i=0;i<naep;i++){      Mm->stra.give_aepcoord (sid,i,coord);      if (Mp->strainaver==0)	//appval (coord[0],coord[1],coord[2],0,ncp,eps,stra);      if (Mp->strainaver==1)	appstrain (lcid,eid,coord[0],coord[1],coord[2],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 planeelemlq::strains (%s, line %d).\n",__FILE__,__LINE__);  }  }    if (Mp->strainaver==0){    for (i=0;i<nne;i++){      delete [] stra[i];    }    delete [] stra;  }}/**   function computes stresses at integration points of element      @param lcid - load case id   @param eid - element id      10.5.2002, JK*/void linhex::res_ip_stresses (long lcid,long eid){  ip_stresses (lcid,eid,0,0);}/**   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      10.5.2002, JK*/void linhex::ip_stresses (long lcid,long eid,long ri,long ci){  long i,j,k,ipp;    ipp=Mt->elements[eid].ipp[ri][ci];    for (i=0;i<intordsm[0][0];i++){    for (j=0;j<intordsm[0][0];j++){      for (k=0;k<intordsm[0][0];k++){		//  computation of correct stresses	if (Mp->strcomp==1)	  Mm->computenlstresses (ipp);		ipp++;      }    }  }}/**   function computes elastic 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      10.5.2002, JK*/void linhex::ip_elast_stresses (long lcid,long eid,long ri,long ci){  long i,j,k,ipp;  vector gp,w,eps(tncomp),sig(tncomp);  matrix d(tncomp,tncomp);  allocv (intordsm[0][0],gp);  allocv (intordsm[0][0],w);    gauss_points (gp.a,w.a,intordsm[0][0]);  ipp=Mt->elements[eid].ipp[ri][ci];    for (i=0;i<intordsm[0][0];i++){    for (j=0;j<intordsm[0][0];j++){      for (k=0;k<intordsm[0][0];k++){		Mm->matstiff (d,ipp);		Mm->givestrain (lcid,ipp,eps);		mxv (d,eps,sig);		Mm->storestress (lcid,ipp,sig);		ipp++;      }    }  }    destrv (w);  destrv (gp);}/**   function computes stresses at nodes      @param lcid - load case id   @param eid - element id   @param ri,ci - row and column indices      10.5.2002, JK*/void linhex::nod_stresses_ip (long lcid,long eid,long ri,long ci){  long i,j,ipp;  ivector ipnum(nne),nod(nne);  vector sig(tncomp);    //  numbers of integration points closest to nodes  //  (function is from the file GEFEL/ordering.cpp)  ipp=Mt->elements[eid].ipp[ri][ci];  nodip_linhex (ipp,intordsm[0][0],ipnum);    //  node numbers of the element  Mt->give_elemnodes (eid,nod);    for (i=0;i<nne;i++){    //  stresses at the closest integration point    Mm->givestress (lcid,ipnum[i],sig);        //  storage of stresses to the node    j=nod[i];    Mt->nodes[j].storestress (lcid,0,sig);  }}/**   function computes stresses in arbitrary point on element      @param lcid - load case id   @param eid - element id   @param xi, eta, zeta - natural coordinates of the point   @param fi,li - first and last indices   @param sig - array containing stresses      11.5.2002*/void linhex::appstress (long lcid,long eid,double xi,double eta,double zeta,long fi,long ncomp,vector &sig){  long i,j,k;  ivector nodes(nne);  vector nodval(nne);    if (ncomp != sig.n){    fprintf (stderr,"\n\n wrong interval of indices in function stress (%s, line %d).\n",__FILE__,__LINE__);    abort ();  }  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 (xi,eta,zeta,nodval);    k++;  }}void linhex::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 (3,coord);    for (i=0;i<naep;i++){      Mm->stre.give_aepcoord (sid,i,coord);      if (Mp->stressaver==0)	//appval (coord[0],coord[1],coord[2],0,ncp,sig,stre);      if (Mp->stressaver==1)	appstress (lcid,eid,coord[0],coord[1],coord[2],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;  }    //mainip_stresses (0,eid,0,0);    }/**   function computes other values in nodes of element   @param lcid - load case id   @param eid - element id   @param ri,ci - row and column indices      JK, 24.10.2005*/void linhex::nod_eqother_ip (long lcid,long eid,long ri,long ci){  long i,j,ipp,ncompo;  ivector ipnum(nne),nod(nne);  vector eqother;    //  numbers of integration points closest to nodes  //  (function is from the file GEFEL/ordering.cpp)  ipp=Mt->elements[eid].ipp[ri][ci];  nodip_linhex (ipp,intordsm[0][0],ipnum);    //  node numbers of the element  Mt->give_elemnodes (eid,nod);    for (i=0;i<nne;i++){    //  number of components of array other    ncompo = Mm->givencompeqother (ipnum[i],0);    allocv (ncompo,eqother);    //  components of array other at integration points    Mm->giveeqother (ipnum[i],0,ncompo,eqother.a);        //  storage of components to the node    j=nod[i];    Mt->nodes[j].storeother (lcid,0,ncompo,eqother);        destrv (eqother);  }}/**   function computes internal forces in the case of geometrical linear computation      @param lcid - number of load case   @param eid - element id   @param ri,ci - row and column indices   @param ifor - vector of internal forces      JK, 28.7.2001*/void linhex::gl_internal_forces (long lcid,long eid,long ri,long ci,vector &ifor){  integratedquant iq;  iq=locstress;    //  computation of stresses  compute_nlstress (lcid,eid,ri,ci);    //  integration of stresses over the element  elem_integration (iq,lcid,eid,ri,ci,ifor);}/**   function computes internal forces (from correct stresses)      @param lcid - number of load case   @param eid - element id   @param ri,ci - row and column indices   @param ifor - %vector of internal forces      JK, 24.9.2005*/void linhex::gnl_internal_forces (long lcid,long eid,long ri,long ci,vector &ifor){  long i,j,k,ipp;  double xi,eta,zeta,jac;  ivector cn(ndofe);  vector w,gp,x(nne),y(nne),z(nne),sig(tncomp),contr(ndofe),r(ndofe);  matrix gm(tncomp,ndofe);    //  node coordinates  Mt->give_node_coord3d (x,y,z,eid);  //  code numbers of element  Mt->give_code_numbers (eid,cn.a);  //  nodal displacements  eldispl (lcid,eid,r.a,cn.a,ndofe);      fillv (0.0,ifor);    //  array for coordinates of integration points  allocv (intordsm[0][0],gp);  //  array for weights of integration points  allocv (intordsm[0][0],w);    //  coordinates and weights of integration points  gauss_points (gp.a,w.a,intordsm[0][0]);    //  number of the first integration point on element  ipp=Mt->elements[eid].ipp[ri][ci];      for (i=0;i<intordsm[0][0];i++){    xi=gp[i];    for (j=0;j<intordsm[0][0];j++){      eta=gp[j];      for (k=0;k<intordsm[0][0];k++){	zeta=gp[k];		//  computation of stress	if (Mp->strcomp==1)	  Mm->computenlstresses (ipp);		if (Mp->nodeintfor==1){	  Mm->givestress (lcid,ipp,sig);	  	  //  strain-displacement (geometric) matrix	  gngeom_matrix (gm,r,x,y,z,xi,eta,zeta,jac);	  	  mtxv (gm,sig,contr);	  	  cmulv (jac*w[i]*w[j]*w[k],contr);	  	  addv (contr,ifor,ifor);	}	ipp++;      }    }  }  destrv (w);  destrv (gp);}/**   function computes internal forces (from correct stresses)      @param lcid - number of load case   @param eid - element id   @param ifor - %vector of internal forces      JK, 24.9.2005*/void linhex::res_internal_forces (long lcid,long eid,vector &ifor){  long transf;  ivector nodes (nne);  vector v(ndofe);    gl_internal_forces (lcid,eid,0,0,ifor);  //gnl_internal_forces (lcid,eid,0,0,ifor);      //  transformation of nodal forces  //  (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);    //globloctransf (ifor,v,tmat);    glvectortransf (ifor,v,tmat);    copyv (v,ifor);  }}/**   function computes nonlocal 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      JK, 28.7.2001*/void linhex::nonloc_internal_forces (long lcid,long eid,long ri,long ci,vector &ifor){  integratedquant iq;  iq=nonlocstress;    //  computation of nonlocal stresses  compute_nonloc_nlstress (lcid,eid,ri,ci);    //  integration of stresses over the element  elem_integration (iq,lcid,eid,ri,ci,ifor);}/**   function computes contributions from eigenstrains to the right hand side      @param eid - element id   @param ifor - %vector of internal forces   JK, 17.8.2004*/void linhex::res_eigstrain_forces (long lcid,long eid,vector &nfor){  long transf;  ivector nodes (nne);  vector v(ndofe);  eigstrain_forces (lcid,eid,0,0,nfor);  //  transformation of nodal forces  //  (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);    //globloctransf (nfor,v,tmat);    glvectortransf (nfor,v,tmat);    copyv (v,nfor);  }}/**   function computes contributions from eigenstrains to the right hand side      @param eid - element id   @param ifor - vector of internal forces   JK, 17.8.2004*/void linhex::eigstrain_forces (long lcid,long eid,long ri,long ci,vector &nfor){  integratedquant iq;  iq=eigstress;    //  computation of eigenstresses  compute_eigstress (lcid,eid,ri,ci);    //  integration of stresses over the element  elem_integration (iq,lcid,eid,ri,ci,nfor);  }/**   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 linhex::compute_nlstress (long lcid,long eid,long ri,long ci){  long i,j,k,ipp;    ipp=Mt->elements[eid].ipp[ri][ci];    for (i=0;i<intordsm[0][0];i++){    for (j=0;j<intordsm[0][0];j++){      for (k=0;k<intordsm[0][0];k++){		//  computation of correct stresses	if (Mp->strcomp==1)	  Mm->computenlstresses (ipp);		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 linhex::compute_nonloc_nlstress (long lcid,long eid,long ri,long ci){  long i,j,k,ipp;    ipp=Mt->elements[eid].ipp[ri][ci];    for (i=0;i<intordsm[0][0];i++){    for (j=0;j<intordsm[0][0];j++){      for (k=0;k<intordsm[0][0];k++){		//  computation of correct stresses	if (Mp->strcomp==1)	  Mm->compnonloc_nlstresses (ipp);		ipp++;      }    }  }}/**   function computes nonlocal correct stresses at integration points on element   

⌨️ 快捷键说明

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