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

📄 node.cpp

📁 Finite element program for mechanical problem. It can solve various problem in solid problem
💻 CPP
字号:
#include <string.h>#include "node.h"#include "vector.h"#include "global.h"node::node (void){  crst = (crsectype) 0;  idcs=0;  transf=0;  e1=NULL;  e2=NULL;  e3=NULL;  react=0;  r=NULL;  ncompstr=0;  ncompother=0;  strain=NULL;  stress=NULL; other=NULL;  ncontr_strain=NULL;  ncontr_stress=NULL;  ncontr_other=NULL;  pstra = NULL;  pstre = NULL;  meaning = NULL;  nodval = NULL;  nvgraph = NULL;  nvforce = NULL;}node::~node (void){  delete [] e1;  delete [] e2;  delete [] e3;  delete [] strain;  delete [] stress;  delete [] other;  delete [] r;    delete [] pstra;  delete [] pstre;  delete [] ncontr_strain;  delete [] ncontr_stress;  delete [] ncontr_other;  delete [] meaning;  delete [] nodval;  delete [] nvgraph;  delete [] nvforce;}/**   function reads data from input file      @param in - pointer to input file      JK*/void node::read (XFILE *in,long ndofn){  //  type of cross section  xfscanf (in,"%d",(int*)&crst);  if (crst!=0){    xfscanf (in,"%ld",&idcs);    idcs--;  }    //  transformation to local system  xfscanf (in,"%ld",&transf);  if (transf!=0 && transf!=2 && transf!=3)    fprintf (stderr,"\n\n wrong identification of local system in function node::read (%s, line %d).\n",__FILE__,__LINE__);    if (transf==2){    e1 = new double [2];  e2 = new double [2];    xfscanf (in,"%lf %lf",e1+0,e1+1);    xfscanf (in,"%lf %lf",e2+0,e2+1);  }  if (transf==3){    e1 = new double [3];  e2 = new double [3];  e3 = new double [3];    xfscanf (in,"%lf %lf %lf",e1+0,e1+1,e1+2);    xfscanf (in,"%lf %lf %lf",e2+0,e2+1,e2+2);    xfscanf (in,"%lf %lf %lf",e3+0,e3+1,e3+2);  }}/**   function allocates arrays strain, stress and other on nodes      @param ncomp - number of strain/stress components   @param ncompo - number of components of array other   @param nlc - number of load cases      18.5.2002, JK, revised 29.11.2006*/void node::alloc (long ncomp,long ncompo,long nlc){  //  number of components of strain/stress  ncompstr=ncomp;  //  number of components of array other  ncompother=ncompo;    if (strain!=NULL)    delete [] strain;  if (stress!=NULL)    delete [] stress;  if (other!=NULL)    delete [] other;    strain = new double [nlc*ncompstr];  stress = new double [nlc*ncompstr];  other  = new double [nlc*ncompother];  memset(strain, 0, sizeof(*strain)*nlc*ncompstr);  memset(stress, 0, sizeof(*stress)*nlc*ncompstr);  memset(other, 0, sizeof(*other)*nlc*ncompother);    if (ncontr_strain!=NULL)    delete [] ncontr_strain;  if (ncontr_stress!=NULL)    delete [] ncontr_stress;  if (ncontr_other!=NULL)    delete [] ncontr_other;    ncontr_strain = new long [nlc];  ncontr_stress = new long [nlc];  ncontr_other  = new long [nlc];  memset(ncontr_strain, 0, sizeof(*ncontr_strain)*nlc);  memset(ncontr_stress, 0, sizeof(*ncontr_stress)*nlc);  memset(ncontr_other, 0, sizeof(*ncontr_other)*nlc);}/**   function reallocates other arrays on nodes      @param ncompo - number of components of array other   @param nlc - number of load cases      18.5.2002*/void node::realloc (long ncompo,long nlc){  //  number of components of array other  ncompother=ncompo;    if (other != NULL)    delete [] other;    other  = new double [nlc*ncompother];  memset(other, 0, sizeof(*other)*nlc*ncompother);}/**   function stores strain components      @param lcid - load case id   @param fi - first index   @param eps - array containing part of strain components      19.5.2002*/void node::storestrain (long lcid,long fi,vector &eps){  long i,j,m,n;  m=lcid*ncompstr;  n=eps.n;    if (fi==0)  ncontr_strain[lcid]++;    j=0;  for (i=m+fi;i<m+fi+n;i++){    strain[i]+=eps[j];    j++;  }}/**   function stores strain components      @param lcid - load case id   @param fi - first index   @param ncomp - number of components   @param eps - array containing part of strain components      19.5.2002*/void node::storestrain (long lcid,long fi,long ncomp,vector &eps){  long i,j,m;  m=lcid*ncompstr;  if (fi==0)  ncontr_strain[lcid]++;    j=fi;  for (i=m+fi;i<m+fi+ncomp;i++){    strain[i]+=eps[j];    j++;  }}/**   function stores stress components      @param lcid - load case id   @param fi - first index   @param sig - array containing part of stress components      JK, 25.9.2004*/void node::storestress (long lcid,long fi,vector &sig){  long i,j,m,n;  m=lcid*ncompstr;  n=sig.n;    if (fi==0)  ncontr_stress[lcid]++;    j=0;  for (i=m+fi;i<m+fi+n;i++){    stress[i]+=sig[j];    j++;  }}/**   function stores stress components      @param lcid - load case id   @param fi - first index   @param ncomp- number of components   @param sig - array containing part of stress components      19.5.2002*/void node::storestress (long lcid,long fi,long ncomp,vector &sig){  long i,j,m;  m=lcid*ncompstr;    if (fi==0)  ncontr_stress[lcid]++;    j=fi;  for (i=m+fi;i<m+fi+ncomp;i++){    stress[i]+=sig[j];    j++;  }}/**   function stores other components      @param lcid - load case id   @param fi - first index   @param ncomp- number of components   @param otherv - array containing part of other components      19.5.2002*/void node::storeother (long lcid,long fi,long ncomp,vector &otherv){  long i;    if (fi==0)  ncontr_other[lcid]++;    for (i=fi;i<fi+ncomp;i++){    other[i]+=otherv[i];  }}/**   function averages strain components      @param lcid - load case id      JK*/void node::strain_averageval (long lcid){  long i;  if (ncontr_strain[lcid]>0){    for (i=0;i<ncompstr;i++){      strain[lcid*ncompstr+i]/=ncontr_strain[lcid];    }  }}/**   function averages stress components      @param lcid - load case id      JK*/void node::stress_averageval (long lcid){  long i;  if (ncontr_stress[lcid]>0){    for (i=0;i<ncompstr;i++){      stress[lcid*ncompstr+i]/=ncontr_stress[lcid];    }  }}/**   function averages components of array other      @param lcid - load case id      JK*/void node::other_averageval (long lcid){  long i;  if (ncontr_other[lcid]>0){    for (i=0;i<ncompother;i++){      other[lcid*ncompother+i]/=ncontr_other[lcid];    }  }}/**   function sets strain components to zero      @param lcid - load case id      JK*/void node::nullstrain (long lcid){  long i;  for (i=0;i<ncompstr;i++){    strain[lcid*ncompstr+i]=0.0;  }}/**   function sets stress components to zero      @param lcid - load case id      JK*/void node::nullstress (long lcid){  long i;  for (i=0;i<ncompstr;i++){    stress[lcid*ncompstr+i]=0.0;  }}/**   function sets components of array other to zero      @param lcid - load case id      JK*/void node::nullother (long lcid){  long i;  for (i=0;i<ncompother;i++){    other[lcid*ncompother+i]=0.0;  }}void node::alloc_meaning (long nid){  long i,ndofn;    ndofn = Mt->give_ndofn (nid);  meaning = new long [ndofn];  for (i=0;i<ndofn;i++){    meaning[i]=-1;  }}/**   function cleans all arrays defined at node      @param nlc - number of load cases      JK, 23.8.2005*/void node::clean (long nlc){  long i;    for (i=0;i<nlc;i++){    nullstrain (i);    nullstress (i);    nullother (i);      }}/**   function allocates arrays used for problems with   changing nodes, elements and DOFs      @param nid - node id      7.11.2006, JK*/void node::alloc_growstr (long nid){  long i,ndofn;    ndofn = Mt->give_ndofn (nid);    nodval = new double [ndofn];  nvgraph = new double [ndofn];  nvforce = new double [ndofn];  for (i=0;i<ndofn;i++){    nodval[i]=0.0;    nvgraph[i]=0.0;    nvforce[i]=0.0;  }}

⌨️ 快捷键说明

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