void resultsinduction(double *co,ITG *nk,ITG *kon,ITG *ipkon,char *lakon, ITG *ne, double *v,double *stn,ITG *inum,double *elcon,ITG *nelcon, double *rhcon,ITG *nrhcon,double *alcon,ITG *nalcon,double *alzero, ITG *ielmat,ITG *ielorien,ITG *norien,double *orab,ITG *ntmat_, double *t0, double *t1,ITG *ithermal,double *prestr,ITG *iprestr,char *filab, double *eme,double *emn, double *een,ITG *iperturb,double *f,double *fn,ITG *nactdof,ITG *iout, double *qa,double *vold,double *b,ITG *nodeboun,ITG *ndirboun, double *xboun,ITG *nboun,ITG *ipompc,ITG *nodempc,double *coefmpc, char *labmpc,ITG *nmpc,ITG *nmethod,double *cam,ITG *neq,double *veold, double *accold,double *bet,double *gam,double *dtime,double *time, double *ttime,double *plicon,ITG *nplicon,double *plkcon, ITG *nplkcon,double *xstateini,double *xstiff,double *xstate,ITG *npmat_, double *epn,char *matname,ITG *mi,ITG *ielas,ITG *icmd,ITG *ncmat_, ITG *nstate_, double *sti,double *vini,ITG *ikboun,ITG *ilboun,double *ener, double *enern,double *emeini,double *xstaten,double *eei,double *enerini, double *cocon,ITG *ncocon,char *set,ITG *nset,ITG *istartset, ITG *iendset, ITG *ialset,ITG *nprint,char *prlab,char *prset,double *qfx,double *qfn, double *trab, ITG *inotr,ITG *ntrans,double *fmpc,ITG *nelemload,ITG *nload, ITG *ikmpc,ITG *ilmpc, ITG *istep,ITG *iinc,double *springarea,double *reltime, ITG *ne0, double *xforc, ITG *nforc, double *thicke, double *shcon,ITG *nshcon,char *sideload,double *xload, double *xloadold,ITG *icfd,ITG *inomat,double *h0,ITG *islavnode, ITG *nslavnode,ITG *ntie){ /* variables for multithreading procedure */ char *env,*envloc,*envsys; ITG intpointvarm,calcul_fn,calcul_f,calcul_qa,calcul_cauchy,iener,ikin, intpointvart,mt=mi[1]+1,i,j,*ithread=NULL,*islavsurf=NULL, sys_cpus,mortar=0,*islavact=NULL; double *pmastsurf=NULL,*clearini=NULL,*pslavsurf=NULL,*cdn=NULL; /* calculating integration point values (strains, stresses, heat fluxes, material tangent matrices and nodal forces) storing the nodal and integration point results in the .dat file iout=-2: v is assumed to be known and is used to calculate strains, stresses..., no result output corresponds to iout=-1 with in addition the calculation of the internal energy density iout=-1: v is assumed to be known and is used to calculate strains, stresses..., no result output; is used to take changes in SPC's and MPC's at the start of a new increment or iteration into account iout=0: v is calculated from the system solution and strains, stresses.. are calculated, no result output iout=1: v is calculated from the system solution and strains, stresses.. are calculated, requested results output iout=2: v is assumed to be known and is used to calculate strains, stresses..., requested results output */ num_cpus=0; sys_cpus=0; /* explicit user declaration prevails */ envsys=getenv("NUMBER_OF_CPUS"); if(envsys){ sys_cpus=atoi(envsys); if(sys_cpus<0) sys_cpus=0; } /* automatic detection of available number of processors */ if(sys_cpus==0){ sys_cpus = getSystemCPUs(); if(sys_cpus<1) sys_cpus=1; } /* local declaration prevails, if strictly positive */ envloc = getenv("CCX_NPROC_RESULTS"); if(envloc){ num_cpus=atoi(envloc); if(num_cpus<0){ num_cpus=0; }else if(num_cpus>sys_cpus){ num_cpus=sys_cpus; } } /* else global declaration, if any, applies */ env = getenv("OMP_NUM_THREADS"); if(num_cpus==0){ if (env) num_cpus = atoi(env); if (num_cpus < 1) { num_cpus=1; }else if(num_cpus>sys_cpus){ num_cpus=sys_cpus; } } // next line is to be inserted in a similar way for all other paralell parts if(*ne<num_cpus) num_cpus=*ne; pthread_t tid[num_cpus]; /* 1. nodewise storage of the primary variables 2. determination which derived variables have to be calculated */ FORTRAN(resultsini_em,(nk,v,ithermal,filab,iperturb,f,fn, nactdof,iout,qa,vold,b,nodeboun,ndirboun, xboun,nboun,ipompc,nodempc,coefmpc,labmpc,nmpc,nmethod,cam,neq, veold,dtime,mi,vini,nprint,prlab, &intpointvarm,&calcul_fn,&calcul_f,&calcul_qa,&calcul_cauchy,&iener, &ikin,&intpointvart,xforc,nforc)); /* electromagnetic calculation is linear: should not be taken into account in the convergence check (only thermal part is taken into account) */ cam[0]=0.; /* next statement allows for storing the displacements in each iteration: for debugging purposes */ if((strcmp1(&filab[3],"I")==0)&&(*iout==0)){ FORTRAN(frditeration,(co,nk,kon,ipkon,lakon,ne,v, ttime,ielmat,matname,mi,istep,iinc,ithermal)); } /* calculating the stresses and material tangent at the integration points; calculating the internal forces */ if(((ithermal[0]<=1)||(ithermal[0]>=3))&&(intpointvarm==1)){ co1=co;kon1=kon;ipkon1=ipkon;lakon1=lakon;v1=v;elcon1=elcon; nelcon1=nelcon;ielmat1=ielmat;ntmat1_=ntmat_;vold1=vold;dtime1=dtime; matname1=matname;mi1=mi;ncmat1_=ncmat_;sti1=sti;alcon1=alcon; nalcon1=nalcon;h01=h0;ne1=ne; /* calculating the magnetic field */ if(((*nmethod!=4)&&(*nmethod!=5))||(iperturb[0]>1)){ printf(" Using up to %" ITGFORMAT " cpu(s) for the magnetic field calculation.\n\n", num_cpus); } /* create threads and wait */ ithread=NNEW(ITG,num_cpus); for(i=0; i<num_cpus; i++) { ithread[i]=i; pthread_create(&tid[i], NULL, (void *)resultsemmt, (void *)&ithread[i]); } for(i=0; i<num_cpus; i++) pthread_join(tid[i], NULL); free(ithread); qa[0]=0.; } /* calculating the thermal flux and material tangent at the integration points; calculating the internal point flux */ if((ithermal[0]>=2)&&(intpointvart==1)){ fn1=NNEW(double,num_cpus*mt**nk); qa1=NNEW(double,num_cpus*3); nal=NNEW(ITG,num_cpus); co1=co;kon1=kon;ipkon1=ipkon;lakon1=lakon;v1=v; elcon1=elcon;nelcon1=nelcon;rhcon1=rhcon;nrhcon1=nrhcon; ielmat1=ielmat;ielorien1=ielorien;norien1=norien;orab1=orab; ntmat1_=ntmat_;t01=t0;iperturb1=iperturb;iout1=iout;vold1=vold; ipompc1=ipompc;nodempc1=nodempc;coefmpc1=coefmpc;nmpc1=nmpc; dtime1=dtime;time1=time;ttime1=ttime;plkcon1=plkcon; nplkcon1=nplkcon;xstateini1=xstateini;xstiff1=xstiff; xstate1=xstate;npmat1_=npmat_;matname1=matname;mi1=mi; ncmat1_=ncmat_;nstate1_=nstate_;cocon1=cocon;ncocon1=ncocon; qfx1=qfx;ikmpc1=ikmpc;ilmpc1=ilmpc;istep1=istep;iinc1=iinc; springarea1=springarea;calcul_fn1=calcul_fn;calcul_qa1=calcul_qa; mt1=mt;nk1=nk;shcon1=shcon;nshcon1=nshcon;ithermal1=ithermal; nelemload1=nelemload;nload1=nload;nmethod1=nmethod;reltime1=reltime; sideload1=sideload;xload1=xload;xloadold1=xloadold; pslavsurf1=pslavsurf;pmastsurf1=pmastsurf;mortar1=mortar; clearini1=clearini;plicon1=plicon;nplicon1=nplicon; /* calculating the heat flux */ printf(" Using up to %" ITGFORMAT " cpu(s) for the heat flux calculation.\n\n", num_cpus); /* create threads and wait */ ithread=NNEW(ITG,num_cpus); for(i=0; i<num_cpus; i++) { ithread[i]=i; pthread_create(&tid[i], NULL, (void *)resultsthermemmt, (void *)&ithread[i]); } for(i=0; i<num_cpus; i++) pthread_join(tid[i], NULL); for(i=0;i<*nk;i++){ fn[mt*i]=fn1[mt*i]; } for(i=0;i<*nk;i++){ for(j=1;j<num_cpus;j++){ fn[mt*i]+=fn1[mt*i+j*mt**nk]; } } free(fn1);free(ithread); /* determine the internal concentrated heat flux */ qa[1]=qa1[1]; for(j=1;j<num_cpus;j++){ qa[1]+=qa1[1+j*3]; } free(qa1); for(j=1;j<num_cpus;j++){ nal[0]+=nal[j]; } if(calcul_qa==1){ if(nal[0]>0){ qa[1]/=nal[0]; } } free(nal); }
void biosav(ITG *ipkon,ITG *kon,char *lakon,ITG *ne,double *co, double *qfx,double *h0,ITG *mi,ITG *inomat,ITG *nk){ ITG i,j,*ithread=NULL,nkphi,idelta,isum; /* calculates the magnetic intensity due to currents in the phi- domain of an electromagnetic calculation */ /* variables for multithreading procedure */ ITG sys_cpus; char *env,*envloc,*envsys; num_cpus = 0; sys_cpus=0; /* explicit user declaration prevails */ envsys=getenv("NUMBER_OF_CPUS"); if(envsys){ sys_cpus=atoi(envsys); if(sys_cpus<0) sys_cpus=0; } /* automatic detection of available number of processors */ if(sys_cpus==0){ sys_cpus = getSystemCPUs(); if(sys_cpus<1) sys_cpus=1; } /* local declaration prevails, if strictly positive */ envloc = getenv("CCX_NPROC_BIOTSAVART"); if(envloc){ num_cpus=atoi(envloc); if(num_cpus<0){ num_cpus=0; }else if(num_cpus>sys_cpus){ num_cpus=sys_cpus; } } /* else global declaration, if any, applies */ env = getenv("OMP_NUM_THREADS"); if(num_cpus==0){ if (env) num_cpus = atoi(env); if (num_cpus < 1) { num_cpus=1; }else if(num_cpus>sys_cpus){ num_cpus=sys_cpus; } } /* determining the nodal bounds in each thread */ NNEW(nkapar,ITG,num_cpus); NNEW(nkepar,ITG,num_cpus); /* n1 is the number of nodes in the phi(magnetostatic)-domain in an electromagnetic calculation */ nkphi=0; for(i=0;i<*nk;i++){ if(inomat[i]==1) nkphi++; } if(nkphi<num_cpus) num_cpus=nkphi; idelta=nkphi/num_cpus; /* dividing the range from 1 to the number of phi-nodes */ isum=0; for(i=0;i<num_cpus;i++){ nkapar[i]=isum; if(i!=num_cpus-1){ isum+=idelta; }else{ isum=nkphi; } nkepar[i]=isum-1; } /* translating the bounds of the ranges to real node numbers */ i=0; j=0; nkphi=-1; do{ if(j==num_cpus) break; do{ if(nkapar[j]==nkphi){ nkapar[j]=i; break; }else{ do{ i++; if(inomat[i]==1){ nkphi++; break; } }while(1); } }while(1); do{ if(nkepar[j]==nkphi){ nkepar[j]=i; j++; break; }else{ do{ i++; if(inomat[i]==1){ nkphi++; break; } }while(1); } }while(1); }while(1); ipkon1=ipkon;kon1=kon;lakon1=lakon;ne1=ne;co1=co;qfx1=qfx; h01=h0;mi1=mi; printf(" Using up to %" ITGFORMAT " cpu(s) for the Biot-Savart calculation.\n\n", num_cpus); /* create threads and wait */ pthread_t tid[num_cpus]; NNEW(ithread,ITG,num_cpus); for(i=0;i<num_cpus;i++){ ithread[i]=i; pthread_create(&tid[i],NULL,(void *)biotsavartmt,(void *)&ithread[i]); } for(i=0;i<num_cpus;i++)pthread_join(tid[i], NULL); SFREE(ithread);SFREE(nkapar);SFREE(nkepar); return; }
void compfluid(double **cop, ITG *nk, ITG **ipkonfp, ITG **konp, char **lakonfp, char **sidefacep, ITG *ifreestream, ITG *nfreestream, ITG *isolidsurf, ITG *neighsolidsurf, ITG *nsolidsurf, ITG **iponoelp, ITG **inoelp, ITG *nshcon, double *shcon, ITG *nrhcon, double *rhcon, double **voldp, ITG *ntmat_,ITG *nodeboun, ITG *ndirboun, ITG *nboun, ITG **ipompcp,ITG **nodempcp, ITG *nmpc, ITG **ikmpcp, ITG **ilmpcp, ITG *ithermal, ITG *ikboun, ITG *ilboun, ITG *iturbulent, ITG *isolver, ITG *iexpl, double *vcontu, double *ttime, double *time, double *dtime, ITG *nodeforc,ITG *ndirforc,double *xforc, ITG *nforc, ITG *nelemload, char *sideload, double *xload,ITG *nload, double *xbody,ITG *ipobody,ITG *nbody, ITG *ielmatf, char *matname, ITG *mi, ITG *ncmat_, double *physcon, ITG *istep, ITG *iinc, ITG *ibody, double *xloadold, double *xboun, double **coefmpcp, ITG *nmethod, double *xforcold, double *xforcact, ITG *iamforc,ITG *iamload, double *xbodyold, double *xbodyact, double *t1old, double *t1, double *t1act, ITG *iamt1, double *amta, ITG *namta, ITG *nam, double *ampli, double *xbounold, double *xbounact, ITG *iamboun, ITG *itg, ITG *ntg, char *amname, double *t0, ITG **nelemfacep, ITG *nface, double *cocon, ITG *ncocon, double *xloadact, double *tper, ITG *jmax, ITG *jout, char *set, ITG *nset, ITG *istartset, ITG *iendset, ITG *ialset, char *prset, char *prlab, ITG *nprint, double *trab, ITG *inotr, ITG *ntrans, char *filab, char **labmpcp, double *sti, ITG *norien, double *orab, char *jobnamef,char *tieset, ITG *ntie, ITG *mcs, ITG *ics, double *cs, ITG *nkon, ITG *mpcfree, ITG *memmpc_,double **fmpcp,ITG *nef,ITG **inomatp,double *qfx, ITG *neifa,ITG *neiel,ITG *ielfa,ITG *ifaext,double *vfa,double *vel, ITG *ipnei,ITG *nflnei,ITG *nfaext,char *typeboun,ITG *neij, double *tincf,ITG *nactdoh,ITG *nactdohinv,ITG *ielorienf){ /* main computational fluid dynamics routine */ char cflag[1],*labmpc=NULL,*lakonf=NULL,*sideface=NULL; char matvec[7]="MATVEC",msolve[7]="MSOLVE"; ITG *ipointer=NULL,*mast1=NULL,*irow=NULL,*icol=NULL,*jq=NULL, nzs=20000000,neq,kode,compressible,*ifabou=NULL,*ja=NULL, *nodempc=NULL,*ipompc=NULL,*ikmpc=NULL,*ilmpc=NULL,nfabou,im, *ipkonf=NULL,*kon=NULL,*nelemface=NULL,*inoel=NULL,last=0, *iponoel=NULL,*inomat=NULL,ithermalref,*integerglob=NULL,iit, iconvergence=0,symmetryflag,inputformat,i,*inum=NULL,iitf,ifreefa, *iponofa=NULL,*inofa=NULL,is,ie,*ia=NULL,nstate_,*ielpropf=NULL, icent=0,isti=0,iqfx=0,nfield,ndim,iorienglob,force=0,icfdout=1; ITG nelt,isym,itol,itmax,iunit,lrgw,*igwk=NULL,ligw,ierr,*iwork=NULL,iter, nsave,lenw,leniw; double *coefmpc=NULL,*fmpc=NULL,*umfa=NULL,reltime,*doubleglob=NULL, *co=NULL,*vold=NULL,*coel=NULL,*cosa=NULL,*gradvel=NULL,*gradvfa=NULL, *xxn=NULL,*xxi=NULL,*xle=NULL,*xlen=NULL,*xlet=NULL,timef,dtimef, *cofa=NULL,*area=NULL,*xrlfa=NULL,reltimef,ttimef,*hcfa=NULL,*cpel=NULL, *au=NULL,*ad=NULL,*b=NULL,*volume=NULL,*body=NULL,sigma=0.,betam, *adb=NULL,*aub=NULL,*advfa=NULL,*ap=NULL,*bp=NULL,*xxj=NULL, *v=NULL,*velo=NULL,*veloo=NULL,*gammat=NULL,*cosb=NULL,dmin,tincfguess, *hel=NULL,*hfa=NULL,*auv=NULL,*adv=NULL,*bv=NULL,*sel=NULL,*gamma=NULL, *gradtfa=NULL,*gradtel=NULL,*umel=NULL,*cpfa=NULL,*gradpel=NULL, *fn=NULL,*eei=NULL,*xstate=NULL,*ener=NULL,*thicke=NULL,*eme=NULL, ptimef,*stn=NULL,*qfn=NULL,*hcel=NULL,*aua=NULL,a1,a2,a3,beta, *prop=NULL; double tol,*rgwk=NULL,err,*sb=NULL,*sx=NULL,*rwork=NULL; nodempc=*nodempcp;ipompc=*ipompcp;ikmpc=*ikmpcp;ilmpc=*ilmpcp; coefmpc=*coefmpcp;labmpc=*labmpcp;fmpc=*fmpcp;co=*cop; ipkonf=*ipkonfp;lakonf=*lakonfp;kon=*konp; nelemface=*nelemfacep;sideface=*sidefacep;inoel=*inoelp; iponoel=*iponoelp;vold=*voldp;inomat=*inomatp; #ifdef SGI ITG token; #endif /* relative time at the end of the mechanical increment */ reltime=(*time)/(*tper); /* open frd-file for fluids */ FORTRAN(openfilefluid,(jobnamef)); /* variables for multithreading procedure */ ITG sys_cpus; char *env,*envloc,*envsys; num_cpus = 0; sys_cpus=0; /* explicit user declaration prevails */ envsys=getenv("NUMBER_OF_CPUS"); if(envsys){ sys_cpus=atoi(envsys); if(sys_cpus<0) sys_cpus=0; } /* automatic detection of available number of processors */ if(sys_cpus==0){ sys_cpus = getSystemCPUs(); if(sys_cpus<1) sys_cpus=1; } /* local declaration prevails, if strictly positive */ envloc = getenv("CCX_NPROC_CFD"); if(envloc){ num_cpus=atoi(envloc); if(num_cpus<0){ num_cpus=0; }else if(num_cpus>sys_cpus){ num_cpus=sys_cpus; } } /* else global declaration, if any, applies */ env = getenv("OMP_NUM_THREADS"); if(num_cpus==0){ if (env) num_cpus = atoi(env); if (num_cpus < 1) { num_cpus=1; }else if(num_cpus>sys_cpus){ num_cpus=sys_cpus; } } // next line is to be inserted in a similar way for all other paralell parts if(*nef<num_cpus) num_cpus=*nef; printf(" Using up to %" ITGFORMAT " cpu(s) for CFD.\n", num_cpus); pthread_t tid[num_cpus]; kode=0; /* *iexpl==0: structure:implicit, fluid:incompressible *iexpl==1: structure:implicit, fluid:compressible *iexpl==2: structure:explicit, fluid:incompressible *iexpl==3: structure:explicit, fluid:compressible */ if((*iexpl==1)||(*iexpl==3)){ compressible=1; }else{ compressible=0; } /* if initial conditions are specified for the temperature, it is assumed that the temperature is an unknown */ ithermalref=*ithermal; if(*ithermal==1){ *ithermal=2; } /* determining the matrix structure */ NNEW(ipointer,ITG,3**nk); NNEW(mast1,ITG,nzs); NNEW(irow,ITG,nzs); NNEW(ia,ITG,nzs); NNEW(icol,ITG,*nef); NNEW(jq,ITG,*nef+1); NNEW(ja,ITG,*nef+1); // NNEW(nactdoh,ITG,*nef); mastructf(nk,kon,ipkonf,lakonf,nef,icol,jq,&mast1,&irow, isolver,&neq,ipointer,&nzs,ipnei,neiel,mi); // printf("Unterschied start\n"); // for(i=0;i<*ne;i++){if(i+1!=nactdoh[i]){printf("Unterschied i=%d,nactdoh[i]=%d\n",i+1,nactdoh[i]);}} // printf("Unterschied end\n"); SFREE(ipointer);SFREE(mast1); /* calculation geometric data */ NNEW(coel,double,3**nef); NNEW(volume,double,*nef); NNEW(cosa,double,*nflnei); NNEW(cosb,double,*nflnei); NNEW(xxn,double,3**nflnei); NNEW(xxi,double,3**nflnei); NNEW(xxj,double,3**nflnei); NNEW(xle,double,*nflnei); NNEW(xlen,double,*nflnei); NNEW(xlet,double,*nflnei); NNEW(cofa,double,3**nface); NNEW(area,double,*nface); NNEW(xrlfa,double,3**nface); FORTRAN(initialcfd,(nef,ipkonf,kon,lakonf,co,coel,cofa,nface, ielfa,area,ipnei,neiel,xxn,xxi,xle,xlen,xlet,xrlfa,cosa, volume,neifa,xxj,cosb,vel,&dmin)); /* storing pointers to the boundary conditions in ielfa */ NNEW(ifabou,ITG,7**nfaext); FORTRAN(applyboun,(ifaext,nfaext,ielfa,ikboun,ilboun, nboun,typeboun,nelemload,nload,sideload,isolidsurf,nsolidsurf, ifabou,&nfabou,nface,nodeboun,ndirboun,ikmpc,ilmpc,labmpc,nmpc, nactdohinv)); RENEW(ifabou,ITG,nfabou); /* catalogueing the nodes for output purposes (interpolation at the nodes */ NNEW(iponofa,ITG,*nk); NNEW(inofa,ITG,2**nface*4); FORTRAN(cataloguenodes,(iponofa,inofa,&ifreefa,ielfa,ifabou,ipkonf, kon,lakonf,nface,nk)); RENEW(inofa,ITG,2*ifreefa); /* material properties for athermal calculations = calculation for which no initial thermal conditions were defined */ NNEW(umfa,double,*nface); NNEW(umel,double,*nef); /* calculating the density at the element centers */ FORTRAN(calcrhoel,(nef,vel,rhcon,nrhcon,ielmatf,ntmat_, ithermal,mi)); /* calculating the density at the face centers */ FORTRAN(calcrhofa,(nface,vfa,rhcon,nrhcon,ielmatf,ntmat_, ithermal,mi,ielfa)); /* calculating the dynamic viscosity at the face centers */ FORTRAN(calcumfa,(nface,vfa,shcon,nshcon,ielmatf,ntmat_, ithermal,mi,ielfa,umfa)); /* calculating the dynamic viscosity at the element centers */ FORTRAN(calcumel,(nef,vel,shcon,nshcon,ielmatf,ntmat_, ithermal,mi,umel)); if(*ithermal!=0){ NNEW(hcfa,double,*nface); NNEW(cpel,double,*nef); NNEW(cpfa,double,*nface); }