示例#1
0
void tiedcontact(ITG *ntie, char *tieset, ITG *nset, char *set,
               ITG *istartset, ITG *iendset, ITG *ialset,
               char *lakon, ITG *ipkon, ITG *kon,
	       double *tietol,
               ITG *nmpc, ITG *mpcfree, ITG *memmpc_,
               ITG **ipompcp, char **labmpcp, ITG **ikmpcp, ITG **ilmpcp,
               double **fmpcp, ITG **nodempcp, double **coefmpcp,
	       ITG *ithermal, double *co, double *vold, ITG *cfd,
	       ITG *nmpc_, ITG *mi, ITG *nk,ITG *istep,ITG *ikboun,
	       ITG *nboun,char *kind1,char *kind2){

  char *labmpc=NULL;

  ITG *itietri=NULL,*koncont=NULL,nconf,i,k,*nx=NULL,im,
      *ny=NULL,*nz=NULL,*ifaceslave=NULL,*istartfield=NULL,
      *iendfield=NULL,*ifield=NULL,ntrimax,index,
      ncont,ncone,*ipompc=NULL,*ikmpc=NULL,
      *ilmpc=NULL,*nodempc=NULL,ismallsliding=0,neq,neqterms,
      nmpctied,mortar=0,*ipe=NULL,*ime=NULL,*imastop=NULL,ifreeme;

  double *xo=NULL,*yo=NULL,*zo=NULL,*x=NULL,*y=NULL,*z=NULL,
    *cg=NULL,*straight=NULL,*fmpc=NULL,*coefmpc=NULL;

  ipompc=*ipompcp;labmpc=*labmpcp;ikmpc=*ikmpcp;ilmpc=*ilmpcp;
  fmpc=*fmpcp;nodempc=*nodempcp;coefmpc=*coefmpcp;

  /* identifying the slave surfaces as nodal or facial surfaces */

  NNEW(ifaceslave,ITG,*ntie);

  FORTRAN(identifytiedface,(tieset,ntie,set,nset,ifaceslave,kind1));

  /* determining the number of triangles of the triangulation
     of the master surface and the number of entities on the
     slave side */

  FORTRAN(allocont,(&ncont,ntie,tieset,nset,set,istartset,iendset,
	  ialset,lakon,&ncone,tietol,&ismallsliding,kind1,
	  kind2,&mortar,istep));

  if(ncont==0){
      SFREE(ifaceslave);return;
  }

  /* allocation of space for the triangulation; 
     koncont(1..3,i): nodes belonging to triangle i
     koncont(4,i): face label to which the triangle belongs =
     10*element+side number */

  NNEW(itietri,ITG,2**ntie);
  NNEW(koncont,ITG,4*ncont);

  /* triangulation of the master surface */

  FORTRAN(triangucont,(&ncont,ntie,tieset,nset,set,istartset,iendset,
	  ialset,itietri,lakon,ipkon,kon,koncont,kind1,kind2,co,nk));
  
  /* catalogueing the neighbors of the master triangles */
  
  RENEW(ipe,ITG,*nk);
  RENEW(ime,ITG,12*ncont);
  DMEMSET(ipe,0,*nk,0.);
  DMEMSET(ime,0,12*ncont,0.);
  NNEW(imastop,ITG,3*ncont);

  FORTRAN(trianeighbor,(ipe,ime,imastop,&ncont,koncont,
		        &ifreeme));

  SFREE(ipe);SFREE(ime);

  /* allocation of space for the center of gravity of the triangles
     and the 4 describing planes */

  NNEW(cg,double,3*ncont);
  NNEW(straight,double,16*ncont);
  
  FORTRAN(updatecont,(koncont,&ncont,co,vold,cg,straight,mi));
  
  /* determining the nodes belonging to the slave face surfaces */

  NNEW(istartfield,ITG,*ntie);
  NNEW(iendfield,ITG,*ntie);
  NNEW(ifield,ITG,8*ncone);

  FORTRAN(nodestiedface,(tieset,ntie,ipkon,kon,lakon,set,istartset,
       iendset,ialset,nset,ifaceslave,istartfield,iendfield,ifield,
       &nconf,&ncone,kind1));

  /* determining the maximum number of equations neq */

  if(*cfd==1){
    if(ithermal[1]<=1){
      neq=4;
    }else{
      neq=5;
    }
  }else{
    if(ithermal[1]<=1){
      neq=3;
    }else if(ithermal[1]==2){
      neq=1;
    }else{
      neq=4;
    }
  }
  neq*=(ncone+nconf);

  /* reallocating the MPC fields for the new MPC's
     ncone: number of MPC'S due to nodal slave surfaces
     nconf: number of MPC's due to facal slave surfaces */  

  RENEW(ipompc,ITG,*nmpc_+neq);
  RENEW(labmpc,char,20*(*nmpc_+neq)+1);
  RENEW(ikmpc,ITG,*nmpc_+neq);
  RENEW(ilmpc,ITG,*nmpc_+neq);
  RENEW(fmpc,double,*nmpc_+neq);

  /* determining the maximum number of terms;
     expanding nodempc and coefmpc to accommodate
     those terms */
  
  neqterms=9*neq;
  index=*memmpc_;
  (*memmpc_)+=neqterms;
  RENEW(nodempc,ITG,3**memmpc_);
  RENEW(coefmpc,double,*memmpc_);
  for(k=index;k<*memmpc_;k++){
      nodempc[3*k-1]=k+1;
  }
  nodempc[3**memmpc_-1]=0;

  /* determining the size of the auxiliary fields */
  
  ntrimax=0;
  for(i=0;i<*ntie;i++){
    if(itietri[2*i+1]-itietri[2*i]+1>ntrimax)
      ntrimax=itietri[2*i+1]-itietri[2*i]+1;
  }
  NNEW(xo,double,ntrimax);
  NNEW(yo,double,ntrimax);
  NNEW(zo,double,ntrimax);
  NNEW(x,double,ntrimax);
  NNEW(y,double,ntrimax);
  NNEW(z,double,ntrimax);
  NNEW(nx,ITG,ntrimax);
  NNEW(ny,ITG,ntrimax);
  NNEW(nz,ITG,ntrimax);
  
  /* generating the tie MPC's */

  FORTRAN(gentiedmpc,(tieset,ntie,itietri,ipkon,kon,
	  lakon,set,istartset,iendset,ialset,cg,straight,
	  koncont,co,xo,yo,zo,x,y,z,nx,ny,nz,nset,
	  ifaceslave,istartfield,iendfield,ifield,
	  ipompc,nodempc,coefmpc,nmpc,&nmpctied,mpcfree,ikmpc,ilmpc,
	  labmpc,ithermal,tietol,cfd,&ncont,imastop,ikboun,nboun,kind1));

  (*nmpc_)+=nmpctied;
  
  SFREE(xo);SFREE(yo);SFREE(zo);SFREE(x);SFREE(y);SFREE(z);SFREE(nx);
  SFREE(ny);SFREE(nz);SFREE(imastop);

  SFREE(ifaceslave);SFREE(istartfield);SFREE(iendfield);SFREE(ifield);
  SFREE(itietri);SFREE(koncont);SFREE(cg);SFREE(straight);

  /* reallocating the MPC fields */

  /*  RENEW(ipompc,ITG,nmpc_);
  RENEW(labmpc,char,20*nmpc_+1);
  RENEW(ikmpc,ITG,nmpc_);
  RENEW(ilmpc,ITG,nmpc_);
  RENEW(fmpc,double,nmpc_);*/

  *ipompcp=ipompc;*labmpcp=labmpc;*ikmpcp=ikmpc;*ilmpcp=ilmpc;
  *fmpcp=fmpc;*nodempcp=nodempc;*coefmpcp=coefmpc;

  /*  for(i=0;i<*nmpc;i++){
    j=i+1;
    FORTRAN(writempc,(ipompc,nodempc,coefmpc,labmpc,&j));
    }*/

  return;
}
void remeshcontactq(int *ntie, char *tieset, int *nset, char *set,
               int *istartset, int *iendset, int **ialsetp,
               char **lakonp, int **ipkonp, int **konp,
	       int *nalset,int *nmpc, int *mpcfree, int *memmpc_,
               int **ipompcp, char **labmpcp, int **ikmpcp, int **ilmpcp,
               double **fmpcp, int **nodempcp, double **coefmpcp,
	       double **cop,int *nmpc_, int *mi, int *nk, int *nkon, 
	       int *ne,int *nk_, int *ithermal, int **ielmatp, 
	       int **ielorienp,double **t0p,double **voldp,double **veoldp,
	       int *ncont,double **xstatep,int *nstate_,double **prestrp,
	       int *iprestr,int *nxstate,int **iamt1p){

  char *labmpc=NULL,*lakon=NULL;

  int k,index,*ipompc=NULL,*ikmpc=NULL,*nodface=NULL,im,
      *ilmpc=NULL,*nodempc=NULL,neqterms,*ipoface=NULL,nface,
      nquadface,ninterface,*ipkon=NULL,*ielmat=NULL,
      *kon=NULL,*ialset=NULL,nk0,*ielorien=NULL,mt=mi[1]+1,
      ntets2remesh,*iamt1=NULL;

  double *fmpc=NULL,*coefmpc=NULL,*co=NULL,*t0=NULL,
      *vold=NULL,*veold=NULL,*xstate=NULL,*prestr=NULL;

  ipompc=*ipompcp;labmpc=*labmpcp;ikmpc=*ikmpcp;ilmpc=*ilmpcp;
  fmpc=*fmpcp;nodempc=*nodempcp;coefmpc=*coefmpcp;ipkon=*ipkonp;
  kon=*konp;co=*cop;lakon=*lakonp;ialset=*ialsetp;ielmat=*ielmatp;
  ielorien=*ielorienp;t0=*t0p;vold=*voldp;veold=*veoldp;xstate=*xstatep;
  prestr=*prestrp;iamt1=*iamt1p;
      
  /* allocating the field to catalogue the faces external to the 
     set A of all C3D20(R) elements adjacent to contact surfaces
     for field nodface: 9 entries per face, 6 faces per element */
  
  nodface=NNEW(int,9*6**ne);
  ipoface=NNEW(int,*nk);

  /* allocating fields for listing all C3D10 elements belonging to
     one and the same end node */
  
  FORTRAN(remeshsurfq,(tieset,ntie,set,nset,istartset,
		      iendset,ialset,ipkon,kon,lakon,nodface,ipoface,&nface,
		      nk,ne));

  /* if no quadratic faces: return */

  if(nface==0){
      free(nodface);free(ipoface);
      *ncont=0;
      return;
  }
  
  RENEW(nodface,int,9*nface);
      
  /* one extra node per quadratic contact face
     (in the middle of the face) */
      
  RENEW(co,double,3*(*nk+nface));
  
  RENEW(t0,double,*nk+nface);
  RENEW(iamt1,int,*nk+nface);
  for(k=*nk_;k<*nk+nface;k++){iamt1[k]=0;}
  
  RENEW(vold,double,mt*(*nk+nface));
  DMEMSET(vold,mt**nk,mt*(*nk+nface),0.);
  
  RENEW(veold,double,mt*(*nk+nface));

  /* each element adjacent to a quadratic contact
     face gets more nodes:
     C3D20(R) -> C3D26(R)
     C3D10    -> C3D14
     C3D15    -> C3D19
     they are moved to a new location in field kon
     without freeing the previous space
 */

  RENEW(kon,int,*nkon+26*nface);
  
  nk0=*nk;

  FORTRAN(remeshcontactelq,(tieset,ntie,set,nset,istartset,
	  iendset,ialset,ipkon,kon,nkon,lakon,nodface,ipoface,
	  nk,ipompc,nodempc,ikmpc,ilmpc,nmpc,nmpc_,labmpc,coefmpc,
	  mpcfree,nalset,co,ithermal,&nk0,ne,ielmat,ielorien,mi,
	  t0,vold,veold,xstate,nstate_,prestr,iprestr));

  free(nodface);free(ipoface);
  
  if(nface>0){
      *nk_+=(*nk-nk0);
  }
  
  *ipompcp=ipompc;*labmpcp=labmpc;*ikmpcp=ikmpc;*ilmpcp=ilmpc;
  *fmpcp=fmpc;*nodempcp=nodempc;*coefmpcp=coefmpc;*ipkonp=ipkon;
  *konp=kon;*lakonp=lakon;*cop=co;*ialsetp=ialset;*ielmatp=ielmat;
  *ielorienp=ielorien;*t0p=t0;*voldp=vold;*veoldp=veold;*xstatep=xstate;
  *prestrp=prestr;*iamt1p=iamt1;
  
  return;
}
示例#3
0
void contact(ITG *ncont, ITG *ntie, char *tieset,ITG *nset,char *set,
	     ITG *istartset, ITG *iendset, ITG *ialset,ITG *itietri,
	     char *lakon, ITG *ipkon, ITG *kon, ITG *koncont, ITG *ne,
	     double *cg, double *straight, ITG *ifree, double *co,
	     double *vold, ITG *ielmat, double *cs, double *elcon,
             ITG *istep,ITG *iinc,ITG *iit,ITG *ncmat_,ITG *ntmat_,
             ITG *ne0, double *vini,
             ITG *nmethod, ITG *nmpc, ITG *mpcfree, ITG *memmpc_,
             ITG **ipompcp, char **labmpcp, ITG **ikmpcp, ITG **ilmpcp,
             double **fmpcp, ITG **nodempcp, double **coefmpcp,
             ITG *iperturb, ITG *ikboun, ITG *nboun, ITG *mi,
             ITG *imastop,ITG *nslavnode,ITG *islavnode,ITG *islavsurf,
             ITG *itiefac,double *areaslav,ITG *iponoels,ITG *inoels,
             double *springarea, double *tietol, double *reltime,
	     ITG *imastnode, ITG *nmastnode, double *xmastnor,
	     char *filab, ITG *mcs, ITG *ics,
             ITG *nasym,double *xnoels,ITG *mortar,double *pslavsurf,
             double *pmastsurf,double *clearini,double *theta){
    
    char *labmpc=NULL;

    ITG i,ntrimax,*nx=NULL,*ny=NULL,*nz=NULL,*ipompc=NULL,*ikmpc=NULL,
	*ilmpc=NULL,*nodempc=NULL,nmpc_,im;
    
    double *xo=NULL,*yo=NULL,*zo=NULL,*x=NULL,*y=NULL,*z=NULL,
        *fmpc=NULL, *coefmpc=NULL;

    ipompc=*ipompcp;labmpc=*labmpcp;ikmpc=*ikmpcp;ilmpc=*ilmpcp;
    fmpc=*fmpcp;nodempc=*nodempcp;coefmpc=*coefmpcp;
    nmpc_=*nmpc;

    /* next call is only for node-to-face penalty contact
       setting up bordering planes for the master triangles;
       these planes are common between neighboring traingles */

    if(*mortar==0){

	DMEMSET(xmastnor,0,3*nmastnode[*ntie],0.);
    
	FORTRAN(updatecontpen,(koncont,ncont,co,vold,
			cg,straight,mi,imastnode,nmastnode,xmastnor,
			ntie,tieset,nset,set,istartset,
			iendset,ialset,ipkon,lakon,kon,cs,mcs,ics));
    }
    
    /* determining the size of the auxiliary fields */
    
    ntrimax=0;
    for(i=0;i<*ntie;i++){
	if(itietri[2*i+1]-itietri[2*i]+1>ntrimax)
	    ntrimax=itietri[2*i+1]-itietri[2*i]+1;
    }
    xo=NNEW(double,ntrimax);
    yo=NNEW(double,ntrimax);
    zo=NNEW(double,ntrimax);
    x=NNEW(double,ntrimax);
    y=NNEW(double,ntrimax);
    z=NNEW(double,ntrimax);
    nx=NNEW(ITG,ntrimax);
    ny=NNEW(ITG,ntrimax);
    nz=NNEW(ITG,ntrimax);
    
    if(*mortar==0){
    
	FORTRAN(gencontelem_n2f,(tieset,ntie,itietri,ne,ipkon,kon,lakon,
	  cg,straight,ifree,koncont,
          co,vold,xo,yo,zo,x,y,z,nx,ny,nz,ielmat,elcon,istep,
          iinc,iit,ncmat_,ntmat_,nmethod,mi,
          imastop,nslavnode,islavnode,islavsurf,itiefac,areaslav,iponoels,
          inoels,springarea,
          set,nset,istartset,iendset,ialset,tietol,reltime,
          imastnode,nmastnode,filab,nasym,xnoels));

    }else if(*mortar==1){

	FORTRAN(gencontelem_f2f,(tieset,ntie,itietri,ne,ipkon,kon,
	  lakon,cg,straight,ifree,koncont,co,vold,xo,yo,zo,x,y,z,nx,ny,nz,
          ielmat,elcon,istep,iinc,iit,ncmat_,ntmat_,mi,imastop,islavsurf,
	  itiefac,springarea,tietol,reltime,filab,nasym,pslavsurf,pmastsurf,
	  clearini,theta));

    }

    free(xo);free(yo);free(zo);free(x);free(y);free(z);free(nx);
    free(ny);free(nz);

    *ipompcp=ipompc;*labmpcp=labmpc;*ikmpcp=ikmpc;*ilmpcp=ilmpc;
    *fmpcp=fmpc;*nodempcp=nodempc;*coefmpcp=coefmpc;
  
    return;
}
示例#4
0
void dynboun(double *amta,ITG *namta,ITG *nam,double *ampli, double *time,
             double *ttime,double *dtime,double *xbounold,double *xboun,
             double *xbounact,ITG *iamboun,ITG *nboun,ITG *nodeboun,
             ITG *ndirboun, double *ad, double *au, double *adb,
             double *aub, ITG *icol, ITG *irow, ITG *neq, ITG *nzs,
             double *sigma, double *b, ITG *isolver,
             double *alpham, double *betam, ITG *nzl,
             ITG *init,double *bact, double *bmin, ITG *jq, 
             char *amname,double *bv, double *bprev, double *bdiff,
             ITG *nactmech, ITG *icorrect, ITG *iprev){

    ITG idiff[3],i,j,ic,ir,im,symmetryflag=0;

    double *xbounmin=NULL,*xbounplus=NULL,*bplus=NULL,
	*ba=NULL,deltatime,deltatime2,deltatimesq,timemin,ttimemin,
        timeplus,ttimeplus,*aux=NULL,*b1=NULL,*b2=NULL,*bnew=NULL;

#ifdef SGI
  ITG token=1;
#endif
    
  NNEW(xbounmin,double,*nboun);
  NNEW(xbounplus,double,*nboun);

      /* time increment for the calculation of the change of the
         particular solution (needed to account for nonzero
         SPC's) */

  deltatime=*dtime;
  deltatime2=2.*deltatime;
  deltatimesq=deltatime*deltatime;

      /* the SPC value at timemin is stored in xbounmin */

  if(*init==1){

      /* at the start of a new step it is assumed that the previous step
	 has reached steady state (at least for the SPC conditions) */

      for(i=0;i<*nboun;i++){
	  xbounmin[i]=xbounold[i];
	  xbounact[i]=xbounold[i];
      }
  }
  else{
      timemin=*time-deltatime;
      ttimemin=*ttime-deltatime;
      FORTRAN(temploadmodal,(amta,namta,nam,ampli,&timemin,&ttimemin,dtime,
	   xbounold,xboun,xbounmin,iamboun,nboun,nodeboun,ndirboun,
           amname));
  }

      /* the SPC value at timeplus is stored in xbounplus */

  timeplus=*time+deltatime;
  ttimeplus=*ttime+deltatime;
  FORTRAN(temploadmodal,(amta,namta,nam,ampli,&timeplus,&ttimeplus,dtime,
	  xbounold,xboun,xbounplus,iamboun,nboun,nodeboun,ndirboun,
          amname));

  NNEW(bplus,double,neq[1]);
  NNEW(ba,double,neq[1]);
  NNEW(b1,double,neq[1]);
  NNEW(b2,double,neq[1]);

      /* check whether boundary conditions changed 
         comparision of min with prev */

  if(*init==1){
      for(i=0;i<*nboun;i++){
	  ic=neq[1]+i;
	  for(j=jq[ic]-1;j<jq[ic+1]-1;j++){
	      ir=irow[j]-1;
	      bmin[ir]=bmin[ir]-au[j]*xbounmin[i];
	  }
      }
      if(*isolver==0){
#ifdef SPOOLES
	  spooles_solve(bmin,&neq[1]);
#endif
      }
      else if(*isolver==4){
#ifdef SGI
	  sgi_solve(bmin,token);
#endif
      }
      else if(*isolver==5){
#ifdef TAUCS
	  tau_solve(bmin,&neq[1]);
#endif
      }
      if(*isolver==7){
#ifdef PARDISO
	  pardiso_solve(bmin,&neq[1],&symmetryflag);
#endif
      }
  }

  /* check whether boundary conditions changed 
     comparision of act with min */
  
  idiff[1]=0;
  for(i=0;i<*nboun;i++){
      if(fabs(xbounact[i]-xbounmin[i])>1.e-10){
	  idiff[1]=1;
	  break;
      }
  }
  if(*init==1){
      for(i=0;i<*nboun;i++){
	  ic=neq[1]+i;
	  for(j=jq[ic]-1;j<jq[ic+1]-1;j++){
	      ir=irow[j]-1;
	      bact[ir]=bact[ir]-au[j]*xbounact[i];
	  }
      }
      if(*isolver==0){
#ifdef SPOOLES
	  spooles_solve(bact,&neq[1]);
#endif
      }
      else if(*isolver==4){
#ifdef SGI
	  sgi_solve(bact,token);
#endif
      }
      else if(*isolver==5){
#ifdef TAUCS
	  tau_solve(bact,&neq[1]);
#endif
      }
      if(*isolver==7){
#ifdef PARDISO
	  pardiso_solve(bact,&neq[1],&symmetryflag);
#endif
      }
  }

      /* check whether boundary conditions changed 
         comparision of plus with act */
  
  idiff[2]=0;
  for(i=0;i<*nboun;i++){
      if(fabs(xbounplus[i]-xbounact[i])>1.e-10){
	  idiff[2]=1;
	  break;
      }
  }
  if(idiff[2]==1){
      for(i=0;i<*nboun;i++){
	  ic=neq[1]+i;
	  for(j=jq[ic]-1;j<jq[ic+1]-1;j++){
	      ir=irow[j]-1;
	      bplus[ir]=bplus[ir]-au[j]*xbounplus[i];
	  }
      }
      if(*isolver==0){
#ifdef SPOOLES
	  spooles_solve(bplus,&neq[1]);
#endif
      }
      else if(*isolver==4){
#ifdef SGI
	  sgi_solve(bplus,token);
#endif
      }
      else if(*isolver==5){
#ifdef TAUCS
	  tau_solve(bplus,&neq[1]);
#endif
      }
      if(*isolver==7){
#ifdef PARDISO
	  pardiso_solve(bplus,&neq[1],&symmetryflag);
#endif
      }
  }
  
  if((idiff[1]!=0)||(idiff[2]!=0)){

      /* present value is not zero */

      if(idiff[2]==0){
	  for(i=0;i<neq[1];i++){bplus[i]=bact[i];}
      }
      for(i=0;i<neq[1];i++){
	  
	  /* bv is the velocity */
	  
	  bv[i]=(bplus[i]-bmin[i])/deltatime2;
	  
	  /* ba is the acceleration */
	  
	  ba[i]=(bmin[i]-2.*bact[i]+bplus[i])/deltatimesq;
	  
	  b1[i]=ba[i]+*alpham*bv[i];
	  b2[i]=*betam*bv[i];

	  bmin[i]=bact[i];
	  bact[i]=bplus[i];
      }
      NNEW(bnew,double,neq[1]);
      FORTRAN(op,(&neq[1],b1,bplus,adb,aub,jq,irow));
      for(i=0;i<neq[1];i++){bnew[i]=-bplus[i];}
      FORTRAN(op,(&neq[1],b2,bplus,ad,au,jq,irow));
      if(*icorrect==2){
	  for(i=0;i<neq[1];i++){
	      bnew[i]-=bplus[i];
	      b[i]+=bnew[i];
	  }
      }else if(*icorrect==0){
	  for(i=0;i<neq[1];i++){
	      bnew[i]-=bplus[i];
	      bdiff[i]=bnew[i]-bprev[i];
	      b[i]+=bdiff[i];
//	      printf("dynboun %e,%e,%e,%e\n",bprev[i],bnew[i],bdiff[i],b[i]);
	  }
	  memcpy(&bprev[0],&bnew[0],sizeof(double)*neq[1]);
      }else{
	  for(i=0;i<neq[1];i++){
	      bnew[i]-=bplus[i];
	      bdiff[i]+=bnew[i]-bprev[i];
	      b[i]+=bdiff[i];
	  }
	  memcpy(&bprev[0],&bnew[0],sizeof(double)*neq[1]);
      }
      SFREE(bnew);
      *nactmech=neq[1];
      *iprev=1;
  }else if((*iprev!=0)&&(*icorrect!=2)){

      /* present value of b is zero, previous value was not zero */

      if(*icorrect==0){
	  for(i=0;i<neq[1];i++){
	      bdiff[i]=-bprev[i];
	      b[i]+=bdiff[i];
//	      printf("dynboun %e,%e,%e,%e\n",bprev[i],bdiff[i],b[i]);
	  }
//	  memset(&bprev[0],0.,sizeof(double)*neq[1]);
	  DMEMSET(bprev,0,neq[1],0.);
      }else{
	  for(i=0;i<neq[1];i++){
	      bdiff[i]+=-bprev[i];
	      b[i]+=bdiff[i];
	  }
//	  memset(&bprev[0],0.,sizeof(double)*neq[1]);
	  DMEMSET(bprev,0,neq[1],0.);
      }
      *nactmech=neq[1];
      *iprev=0;
  }
  
  SFREE(xbounmin);SFREE(xbounplus);
  SFREE(bplus);SFREE(ba);SFREE(b1);SFREE(b2);
  
  return;
}
示例#5
0
void precontact(ITG *ncont, ITG *ntie, char *tieset, ITG *nset, char *set,
        ITG *istartset, ITG *iendset, ITG *ialset, ITG *itietri,
        char *lakon, ITG *ipkon, ITG *kon, ITG *koncont, ITG *ne,
        double *cg, double *straight, double *co,double *vold,
        ITG *istep,ITG *iinc,ITG *iit,ITG *itiefac,
        ITG *islavsurf, ITG *islavnode, ITG *imastnode,
        ITG *nslavnode, ITG *nmastnode,ITG *imastop,ITG *mi,
	ITG *ipe, ITG *ime,double *tietol,ITG *iflagact,
	ITG *nintpoint,double **pslavsurfp,double *xmastnor,double *cs,
	ITG *mcs,ITG *ics,double *clearini,ITG *nslavs){

    /* authors: S. Rakotonanahary, S. Sitzmann and J. Hokkanen */

    ITG i,j,ntrimax,*nx=NULL,*ny=NULL,*nz=NULL,im,
        l,nstart,kflag,ntri,ii;
    
    double *xo=NULL,*yo=NULL,*zo=NULL,*x=NULL,*y=NULL,*z=NULL,
        *pslavsurf=NULL,*clearslavnode=NULL;
    
    pslavsurf=*pslavsurfp;
    
    /* update the location of the center of gravity of 
       the master triangles and the coefficients of their
       bounding planes */
    
    DMEMSET(xmastnor,0,3*nmastnode[*ntie],0.);
    
    FORTRAN(updatecontpen,(koncont,ncont,co,vold,
			   cg,straight,mi,imastnode,nmastnode,xmastnor,
			   ntie,tieset,nset,set,istartset,
			   iendset,ialset,ipkon,lakon,kon,cs,mcs,ics));
    
    /* determining the size of the auxiliary fields 
       (needed for the master triangle search for any
	   given location on the slave faces */	
    
    ntrimax=0;	
    for(i=0;i<*ntie;i++){	    
	if(itietri[2*i+1]-itietri[2*i]+1>ntrimax)		
	    ntrimax=itietri[2*i+1]-itietri[2*i]+1;  	
    }
    
    /* only at the start of a new step */
    
    if ((*istep==1)&&(*iinc==1)&&(*iit<=0)){	    
	NNEW(xo,double,ntrimax);	    
	NNEW(yo,double,ntrimax);	    
	NNEW(zo,double,ntrimax);	    
	NNEW(x,double,ntrimax);	    
	NNEW(y,double,ntrimax);	    
	NNEW(z,double,ntrimax);	   
	NNEW(nx,ITG,ntrimax);	   
	NNEW(ny,ITG,ntrimax);	    
	NNEW(nz,ITG,ntrimax);

	NNEW(clearslavnode,double,3**nslavs);
	    
	FORTRAN(adjustcontactnodes,(tieset,ntie,itietri,cg,straight,
		co,vold,xo,yo,zo,x,y,z,nx,ny,nz,istep,iinc,iit,
		mi,imastop,nslavnode,islavnode,set,nset,istartset,
		iendset,ialset,tietol,clearini,clearslavnode,itiefac,
                ipkon,kon,lakon,islavsurf));
	    
	SFREE(clearslavnode);
	SFREE(xo);SFREE(yo);SFREE(zo);SFREE(x);SFREE(y);SFREE(z);SFREE(nx);	    
	SFREE(ny);SFREE(nz);	    
    }
示例#6
0
void remastruct(ITG *ipompc, double **coefmpcp, ITG **nodempcp, ITG *nmpc,
              ITG *mpcfree, ITG *nodeboun, ITG *ndirboun, ITG *nboun,
              ITG *ikmpc, ITG *ilmpc, ITG *ikboun, ITG *ilboun,
              char *labmpc, ITG *nk,
              ITG *memmpc_, ITG *icascade, ITG *maxlenmpc,
              ITG *kon, ITG *ipkon, char *lakon, ITG *ne,
              ITG *nactdof, ITG *icol, ITG *jq, ITG **irowp, ITG *isolver,
              ITG *neq, ITG *nzs,ITG *nmethod, double **fp,
              double **fextp, double **bp, double **aux2p, double **finip,
              double **fextinip,double **adbp, double **aubp, ITG *ithermal,
	      ITG *iperturb, ITG *mass, ITG *mi,ITG *iexpl,ITG *mortar,
	      char *typeboun,double **cvp,double **cvinip,ITG *iit){

    /* reconstructs the nonzero locations in the stiffness and mass
       matrix after a change in MPC's */

    ITG *nodempc=NULL,*mast1=NULL,*ipointer=NULL,mpcend,mpcmult,
        callfrommain,i,*irow=NULL,mt,im;

    double *coefmpc=NULL,*f=NULL,*fext=NULL,*b=NULL,*aux2=NULL,
        *fini=NULL,*fextini=NULL,*adb=NULL,*aub=NULL,*cv=NULL,*cvini=NULL;
    
    nodempc=*nodempcp;coefmpc=*coefmpcp;irow=*irowp;
    f=*fp;fext=*fextp;b=*bp;aux2=*aux2p;fini=*finip;
    fextini=*fextinip;adb=*adbp;aub=*aubp;cv=*cvp;cvini=*cvinip;

    mt=mi[1]+1;

    /* decascading the MPC's */

    printf(" Decascading the MPC's\n\n");
   
    callfrommain=0;
    cascade(ipompc,&coefmpc,&nodempc,nmpc,
	    mpcfree,nodeboun,ndirboun,nboun,ikmpc,
	    ilmpc,ikboun,ilboun,&mpcend,&mpcmult,
	    labmpc,nk,memmpc_,icascade,maxlenmpc,
            &callfrommain,iperturb,ithermal);

    /* determining the matrix structure */
    
    printf(" Determining the structure of the matrix:\n");
 
    if(nzs[1]<10) nzs[1]=10;   
    NNEW(mast1,ITG,nzs[1]);
    NNEW(ipointer,ITG,mt**nk);
    RENEW(irow,ITG,nzs[1]);for(i=0;i<nzs[1];i++) irow[i]=0;
    
    mastruct(nk,kon,ipkon,lakon,ne,nodeboun,ndirboun,nboun,ipompc,
	     nodempc,nmpc,nactdof,icol,jq,&mast1,&irow,isolver,neq,
	     ikmpc,ilmpc,ipointer,nzs,nmethod,ithermal,
             ikboun,ilboun,iperturb,mi,mortar,typeboun,labmpc);

    SFREE(ipointer);SFREE(mast1);
    RENEW(irow,ITG,nzs[2]);
    
    *nodempcp=nodempc;*coefmpcp=coefmpc;*irowp=irow;

    /* reallocating fields the size of which depends on neq[1] or *nzs */

    RENEW(f,double,neq[1]);DMEMSET(f,0,neq[1],0.);
    RENEW(fext,double,neq[1]);DMEMSET(fext,0,neq[1],0.);
    RENEW(b,double,neq[1]);DMEMSET(b,0,neq[1],0.);
    RENEW(fini,double,neq[1]);

    /* for static calculations fini has to be set to f at the
       start of the calculation; in dynamic calculations this is
       not needed, since the initial accelerations has already
       been calculated */

    if((*nmethod!=4)&&(*iit==-1)) DMEMSET(fini,0,neq[1],0.);

    if(*nmethod==4){
	RENEW(aux2,double,neq[1]);DMEMSET(aux2,0,neq[1],0.);
	RENEW(cv,double,neq[1]);
	RENEW(cvini,double,neq[1]);
	RENEW(fextini,double,neq[1]);
//	for(i=0;i<neq[1];i++) fextini[i]=0.;

        /* the mass matrix is diagonal in an explicit dynamic
           calculation and is not changed by contact; this
           assumes that the number of degrees of freedom does
           not change  */

	if(*iexpl<=1){
	    RENEW(adb,double,neq[1]);for(i=0;i<neq[1];i++) adb[i]=0.;
	    RENEW(aub,double,nzs[1]);for(i=0;i<nzs[1];i++) aub[i]=0.;
	    mass[0]=1;
	}
    }

    *fp=f;*fextp=fext;*bp=b;*aux2p=aux2;*finip=fini;
    *fextinip=fextini;*adbp=adb;*aubp=aub;*cvp=cv;*cvinip=cvini;

    return;
}