double JTKernel(double t1,double t2,double beta,double SR,double Q){ double Kernel=0.; double H = 1./(3.358*Q); Kernel = 2.*pi*H*fabs(beta)*(Cc(SR,t1)*Cd(SR,t2)-Cd(SR,t1)*Cc(SR,t2))/pow(1.+S(SR)*S(SR)*t1*t1,.5); Kernel *= exp(-.5*beta*beta*(pow(Cc(SR,t1)-Cc(SR,t2),2.) + pow(Cd(SR,t1)-Cd(SR,t2),2.))); return Kernel; }
CFileAccess *FileAccessNew(U8 *_mask,Bool make_mask=FALSE,Bool make_dirs=FALSE) { Bool valid=TRUE,old_silent; U8 *buf,*mask,*temp_mask; CFileAccess *fa=CAlloc(sizeof(CFileAccess)); mask=MStrUtil(_mask, SUF_REM_LEADING|SUF_REM_TRAILING|SUF_REM_CTRL_CHARS); temp_mask=mask; fa->old_dir=StrNew(Fs->cur_dir); fa->old_prt=Fs->cur_prt; if (*mask && mask[1]==':') { if (Fs->cur_prt!=Drv2Prt(*mask)) if (!Drv(*mask)) valid=FALSE; mask+=2; } if (StrStr(mask,"HOME") && Fs->cur_prt!=Drv2Prt(*sys_acct)) Drv(*sys_acct); fa->p=Fs->cur_prt; PrtChk(fa->p); buf=MAlloc(StrLen(mask)+2); StrCpy(buf,mask); fa->mask=MAlloc(StrLen(mask)+2); StrLastRem(buf,"/",fa->mask); if (*mask=='/' && !*buf) StrCpy(buf,"/"); //If began with Dir, change to Dir. if (*buf && !Cd(buf,make_dirs)) valid=FALSE; if (valid && make_mask) { if (!*fa->mask) { Free(fa->mask); fa->mask=StrNew("*"); } else { if (!make_dirs || FileNameChk(fa->mask)) { old_silent=Silent(ON); //Try mask to see if Dir. If Dir, change to dir and set to "*". if (Cd(fa->mask,make_dirs)) { Free(fa->mask); fa->mask=StrNew("*"); } Silent(old_silent); } } } Free(buf); Free(temp_mask); if (!valid) { FileAccessDel(fa); fa=NULL; // throw(EXCEPT_FILE); } return fa; }
DirectoryOperations::DirectoryOperations( void ) { mode = 0; items = 0; dirs = NULL; Cd(); }
Foam::scalar Foam::standardDragModel::relaxationTime ( const vector& URel, const scalar diameter, const scalar rho, const scalar liquidDensity, const scalar nu, const scalar dev ) const { scalar time = GREAT; scalar Re = mag(URel)*diameter/nu; if (Re > 0.1) { time = 4.0*liquidDensity*diameter/(3.0*rho*Cd(Re, dev)*mag(URel)); } else { // for small Re number, the relative velocity is both in // the nominator and denominator // use Cd = 24/Re and remove the SMALL/SMALL // expression for the velocities time = liquidDensity*diameter*diameter/(18*rho*nu*(1.0 + Cdistort_*dev)); } return time; }
DirectoryOperations::DirectoryOperations( char *path ) { mode = 0; items = 0; dirs = NULL; Cd( path ); }
void CPMPChan::Run() { /// fetch data objects gsl_vector_complex invec = vin1.GetDataObj(); gsl_matrix_complex cmat = min2.GetDataObj(); // // gsl_vector_complex *tmp = gsl_vector_complex_alloc(N()); // // // extract the user channel matrix // // for (int i=0; i<N(); i++) { gsl_complex h = gsl_matrix_complex_get(&cmat,Cd(),(N()-i)%N()); for (int j=0; j<N(); j++) { gsl_matrix_complex_set(user_chan,j,(j+i) % N(),h); } } // cout << "User " << Cd() << " channel:" << endl; // gsl_matrix_complex_show(user_chan); // // // compute the output vector // // gsl_blas_zgemv(CblasNoTrans, gsl_complex_rect(1.0,0), user_chan, &invec, gsl_complex_rect(0,0), tmp); // cout << "User " << Cd() << " trasmitted vector:" << endl; // gsl_vector_complex_fprintf(stdout,&invec,"%f"); // cout << "User " << Cd() << " received vector:" << endl; // gsl_vector_complex_fprintf(stdout,tmp,"%f"); //////// production of data vout1.DeliverDataObj( *tmp ); }
int main(int argc,char* argv[]) { SP<Amplifier> Amp(new Amplifier() ); SP<CdPlayer> Cd( new CdPlayer()); SP<DVDPlayer> Dvd( new DVDPlayer()); SP<PopcornPopper> PopCorn( new PopcornPopper()); SP<Projector> Pro(new Projector()); SP<Screen> Scr(new Screen()); SP<TheaterLights> Light(new TheaterLights()); SP<Tuner> Tun(new Tuner()); SP<HomeTheaterFacade> Home(new HomeTheaterFacade(Amp,Cd,Dvd,PopCorn,Pro,Scr,Light,Tun)); Home->watchMovie("The Lord of the Rings.3"); Home->endMovie(); return 0; }
STDMETHODIMP VFSExplorer::CdUp(IProgress **aProgress) { AutoCaller autoCaller(this); if (FAILED(autoCaller.rc())) return autoCaller.rc(); Utf8Str strUpPath; { AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); /* Remove lowest dir entry in a platform neutral way. */ char *pszNewPath = RTStrDup(m->strPath.c_str()); RTPathStripTrailingSlash(pszNewPath); RTPathStripFilename(pszNewPath); strUpPath = pszNewPath; RTStrFree(pszNewPath); } return Cd(Bstr(strUpPath).raw(), aProgress); }
U0 FileAccessDel(CFileAccess *fa) { CBlkDev *bdev; if (!fa) return; bdev=fa->old_prt->bdev; if (!(bdev->flags & BDF_INIT_IN_PROGRESS)) { if (fa->old_dir) { Drv(Prt2Drv(fa->old_prt)); Cd(fa->old_dir); } } else { Fs->cur_prt=fa->old_prt; Free(Fs->cur_dir); Fs->cur_dir=StrNew("/"); } Free(fa->old_dir); Free(fa->mask); Free(fa); }
Bool FileFind(U8 *filename,CDirEntry *rde=NULL,I64 fuf_flags=0) { //$LK,"FUF_JUST_DIRS","MN:FUF_JUST_DIRS"$, $LK,"FUF_JUST_FILES","MN:FUF_JUST_FILES"$, $LK,"FUF_Z_OR_NOT_Z","MN:FUF_Z_OR_NOT_Z"$, $LK,"FUF_SCAN_PARENTS","MN:FUF_SCAN_PARENTS"$ //If you pass rde, you must Free(rde->full_name); I64 i,j,cur_dir_cluster; U8 *altname,*curname,*full_name=NULL; CDirEntry de; CFileAccess *fa; Bool result=FALSE; if (fuf_flags&~FUG_FILE_FIND) throw(EXCEPT_FUF,5); if (!filename) return FALSE; altname=ToggleZorNotZ(filename); if (fuf_flags&FUF_Z_OR_NOT_Z) j=2; else j=1; for (i=0;i<j && !result;i++) { if (!i) curname=filename; else curname=altname; if (fa=FileAccessNew(curname)) { cur_dir_cluster=Name2DirCluster(fa->p,Fs->cur_dir); switch (fa->p->type) { case PT_REDSEA: result=RedSeaFSFileFind(fa->p,cur_dir_cluster,fa->mask,&de,fuf_flags); break; case PT_FAT32: result=FAT32FileFind(fa->p,cur_dir_cluster,fa->mask,&de,fuf_flags); break; case PT_ISO9660: result=ISO1FileFind(fa->p,cur_dir_cluster,fa->mask,&de,fuf_flags); break; default: PutDefineErr("ST_UNSUPPORTED_FILE_SYSTEM"); } if (result && rde) full_name=MSPrintF("%C:%s/%s",Fs->cur_prt->drv_let,Fs->cur_dir,de.name); FileAccessDel(fa); } } for (i=0;i<j && !result && fuf_flags&FUF_SCAN_PARENTS;i++) { if (!i) curname=filename; else curname=altname; if (fa=FileAccessNew(curname)) { cur_dir_cluster=Name2DirCluster(fa->p,Fs->cur_dir); while (!result && StrCmp(Fs->cur_dir,"/")) { Cd(".."); cur_dir_cluster=Name2DirCluster(fa->p,Fs->cur_dir); switch (fa->p->type) { case PT_REDSEA: result=RedSeaFSFileFind(fa->p,cur_dir_cluster,fa->mask,&de,fuf_flags); break; case PT_FAT32: result=FAT32FileFind(fa->p,cur_dir_cluster,fa->mask,&de,fuf_flags); break; case PT_ISO9660: result=ISO1FileFind(fa->p,cur_dir_cluster,fa->mask,&de,fuf_flags); break; default: PutDefineErr("ST_UNSUPPORTED_FILE_SYSTEM"); } } if (result && rde) full_name=MSPrintF("%C:%s/%s",Fs->cur_prt->drv_let,Fs->cur_dir,de.name); FileAccessDel(fa); } } if (rde) { if (result) { MemCpy(rde,&de,sizeof(CDirEntry)); rde->full_name=full_name; } else MemSet(rde,0,sizeof(CDirEntry)); } Free(altname); return result; }
U8 *FileRead(U8 *filename,I64 *_size=NULL,I64 *_attr=NULL,Bool raw=FALSE) { CHashGeneric *temph; U8 *absname,*altname,*curname,*result=NULL; I64 i,size=0,attr=0; CFileAccess *fa; CArcCompress *ac=NULL; if (_attr) *_attr=0; absname=FileNameAbs(filename); altname=ToggleZorNotZ(absname); if (!raw && ((temph=HashFind(absname,adam_task->hash_table,HTT_FILE))|| (temph=HashFind(altname,adam_task->hash_table,HTT_FILE)))) { if (FileAttr(absname) & _ATTR_COMPRESSED) { ac=temph->user_data0; if (_size) *_size=ac->expanded_size; if (_attr) *_attr=FileAttr(absname,*_attr); result=ExpandBuf(ac); } else { result=MAlloc(temph->user_data1+1); MemCpy(result,temph->user_data0,temph->user_data1); result[temph->user_data1]=0; //Terminate if (_size) *_size=temph->user_data1; } } else { for (i=0;i<2 && !result;i++) {//Try name, then altname if (!i) curname=absname; else curname=altname; if (fa=FileAccessNew(curname)) { switch (fa->p->type) { case PT_REDSEA: result=RedSeaFSFileRead(fa->p,Fs->cur_dir,fa->mask,&size,&attr,raw,&ac); break; case PT_FAT32: result=FAT32FileRead(fa->p,Fs->cur_dir,fa->mask,&size,&attr,raw,&ac); break; case PT_ISO9660: result=ISO1FileRead(fa->p,Fs->cur_dir,fa->mask,&size,&attr,raw,&ac); break; default: PutDefineErr("ST_UNSUPPORTED_FILE_SYSTEM"); } FileAccessDel(fa); } } //Search parent directories. for (i=0;i<2 && !result;i++) {//Try name, then altname if (!i) curname=absname; else curname=altname; if (fa=FileAccessNew(curname)) { while (!result && StrCmp(Fs->cur_dir,"/")) { Cd(".."); switch (Fs->cur_prt->type) { case PT_REDSEA: result=RedSeaFSFileRead(fa->p,Fs->cur_dir,fa->mask,&size,&attr,raw,&ac); break; case PT_FAT32: result=FAT32FileRead(fa->p,Fs->cur_dir,fa->mask,&size,&attr,raw,&ac); break; case PT_ISO9660: result=ISO1FileRead(fa->p,Fs->cur_dir,fa->mask,&size,&attr,raw,&ac); break; default: PutDefineErr("ST_UNSUPPORTED_FILE_SYSTEM"); } } FileAccessDel(fa); } } if (!result) { "%s ",filename; PutDefineErr("ST_FILE_NOT_FOUND"); } if (_size) *_size=size; if (_attr) *_attr=attr; if (result && !raw && attr & _ATTR_RESIDENT) HashGenericAdd(curname,HTT_FILE,AMAllocIdentical(ac),size,0,adam_task); Free(ac); } Free(absname); Free(altname); return result; }
void Correlator::Setup() { //////// initialization of dynamic data structures M=(2*D()+1); symbol_time = 0; Ns=(1 << Nb()); symbol_arg = complex<double>(0,1)*2.0*PI/Ns; gray_decoding=Vector <unsigned int>(Ns); indim = G()*S()*M; wvec = Matrix < complex <double> > (indim,1); //////// rate declaration for ports out1.SetRate( Nb() ); //////// sequences loading ifstream ifs; ifs.open( seqfname() ); if (! ifs ) { cerr << BlockName << ": error opening " << seqfname() << endl; exit(_ERROR_OPEN_FILE_); } Matrix < double > gm; ifs >> gm; ifs.close(); code = Vector< double >(G()); for (int i=1; i<G()+1; i++) code(i)=gm(Cd(),i); /////////// Gray Demapping for (unsigned int i=0; i<Ns; i++) { unsigned int tmp=0; for (unsigned int k=0; k<Nb(); k++) { unsigned int t=(1<<k), tt=2*t; tmp += t * (((t+i)/tt) % 2); } gray_decoding[tmp]=i; } ////////// Pulse initialization pulse1=TxPulse(S()); ////////// correlator initialization for (register int i=0; i< G()*S(); i++){ unsigned int isymb, tsymb, tchip, ichip, tsample, currsample; currsample = i+D()*G()*S(); // position in samples from the start of the chip tsample = currsample % S(); // position in chips ichip = currsample / S(); // position in chips from the start of the symbol tchip = ichip % G(); wvec[currsample][0] = code[tchip] * pulse1(tsample) / sqrt(G()); } }
void DiFeliceDrag::setForce() const { // get viscosity field #ifdef comp const volScalarField nufField = particleCloud_.turbulence().mu() / rho_; #else const volScalarField& nufField = particleCloud_.turbulence().nu(); #endif vector position(0,0,0); scalar voidfraction(1); vector Ufluid(0,0,0); vector drag(0,0,0); label cellI=0; vector Us(0,0,0); vector Ur(0,0,0); scalar ds(0); scalar nuf(0); scalar rho(0); scalar magUr(0); scalar Rep(0); scalar Cd(0); interpolationCellPoint<scalar> voidfractionInterpolator_(voidfraction_); interpolationCellPoint<vector> UInterpolator_(U_); #include "setupProbeModel.H" for(int index = 0;index < particleCloud_.numberOfParticles(); index++) { //if(mask[index][0]) //{ cellI = particleCloud_.cellIDs()[index][0]; drag = vector(0,0,0); if (cellI > -1) // particle Found { if(interpolation_) { position = particleCloud_.position(index); voidfraction = voidfractionInterpolator_.interpolate(position,cellI); Ufluid = UInterpolator_.interpolate(position,cellI); }else { voidfraction = voidfraction_[cellI]; Ufluid = U_[cellI]; } Us = particleCloud_.velocity(index); Ur = Ufluid-Us; ds = 2*particleCloud_.radius(index); nuf = nufField[cellI]; rho = rho_[cellI]; magUr = mag(Ur); Rep = 0; Cd = 0; if (magUr > 0) { // calc particle Re Nr Rep = ds*voidfraction*magUr/(nuf+SMALL); // calc fluid drag Coeff Cd = sqr(0.63 + 4.8/sqrt(Rep)); // calc model coefficient Xi scalar Xi = 3.7 - 0.65 * exp(-sqr(1.5-log10(Rep))/2); // calc particle's drag drag = 0.125*Cd*rho*M_PI*ds*ds*pow(voidfraction,(2-Xi))*magUr*Ur; if (modelType_=="B") drag /= voidfraction; } if(verbose_ && index >100 && index <102) { Pout << "index = " << index << endl; Pout << "Us = " << Us << endl; Pout << "Ur = " << Ur << endl; Pout << "ds = " << ds << endl; Pout << "rho = " << rho << endl; Pout << "nuf = " << nuf << endl; Pout << "voidfraction = " << voidfraction << endl; Pout << "Rep = " << Rep << endl; Pout << "Cd = " << Cd << endl; Pout << "drag = " << drag << endl; } //Set value fields and write the probe if(probeIt_) { #include "setupProbeModelfields.H" vValues.append(drag); //first entry must the be the force vValues.append(Ur); sValues.append(Rep); sValues.append(Cd); sValues.append(voidfraction); particleCloud_.probeM().writeProbe(index, sValues, vValues); } } // set force on particle if(treatExplicit_) for(int j=0;j<3;j++) expForces()[index][j] += drag[j]; else for(int j=0;j<3;j++) impForces()[index][j] += drag[j]; for(int j=0;j<3;j++) DEMForces()[index][j] += drag[j]; } //} }
int DirectoryOperations::Cd( char *path ) { int n; HANDLE hdir; WIN32_FIND_DATA status; if ( path == NULL || path[ 0 ] == '\0' ) { //コンピュータ Free(); items = GetDrive(); dirs = (char **)calloc( items, sizeof( char * ) ); for ( n = 0; n < items; ++n ) { dirs[ n ] = (char *)calloc( 4, sizeof( char ) ); dirs[ n ][ 0 ] = drive[ n ]; dirs[ n ][ 1 ] = ':'; dirs[ n ][ 2 ] = '\\'; } strcpy_s( current, MAX_PATH, "COMPUTER" );// strcpy( current, "COMPUTER" ); return 0; } else if ( strcmp( path, ".." ) == 0 ) { //1つ上に移動。 if ( strcmp( current + 1, ":\\" ) == 0 ) { return Cd( NULL ); } else { n = strlen( current ) - 1; for ( --n; n >= 0; --n ) { if ( current[ n ] == '\\' ) { current[ n + 1 ] = '*'; current[ n + 2 ] = '\0'; break; } } } } else if ( strcmp( path, "." ) == 0 ) { //同じ場所なので移動しない。 } else { if ( path[ 1 ] == ':' && path[ 2 ] == '\\' ) { //絶対パス。 strcpy_s( current, MAX_PATH, path );//// strcpy( current, path ); } else { //相対パスなので単純コピー。 strcat_s( current, MAX_PATH, path );// strcat( current, path ); } n = strlen( current ); if ( current[ n - 1 ] != '\\' ) { current[ n++ ] = '\\'; } current[ n ] = '*'; current[ n + 1 ] = '\0'; } if ( ( hdir = FindFirstFile( current, &status ) ) != INVALID_HANDLE_VALUE ) { current[ strlen( current ) - 1 ] = '\0'; Makelist( hdir, &status, 0 ); FindClose( hdir ); } else { current[ strlen( current ) - 1 ] = '\0'; //ディレクトリ一覧の解放。 Free(); //新しく領域を作る。 // dirs = (char **)calloc( (items = count + (filepath[ 0 ] != '\0') + 2 ), sizeof( char * ) ); dirs = (char **)calloc( ( items = 1 ), sizeof( char * ) ); //1つ上に行くためのパスは用意しておく。 dirs[ 0 ] = (char *)calloc( 3, sizeof( char ) ); strcpy_s( dirs[ 0 ], 3, ".." ); } return 0; }
int main(int argc, char *argv[]) { char command[20]; // the command either internal or external. parameters_t parameters; // all other parameters. char outpath[1024]; // the path of output redirection. char inpath[1024]; // the path of input redirection. int flags[2]; // mark if there is any I/O redirection. // Check if there is a batch file. if (argc == 2) { commands = fopen(argv[1], "r"); if (commands == NULL) { printf("Can't open the file \"%s\"!\n", argv[1]); commands = stdin; } } else commands = stdin; // Set the environment variable SHELL. SetMyshell(); for (Prompt(); fscanf(commands, "%s", command) != EOF; Prompt()) // Initially get the command. { // Get all other parameters. GetParameters(command, ¶meters, flags, inpath, outpath); // Check if there is a stdout redirection. switch (flags[0]) { case 1: freopen(outpath, "w", stdout); break; case 2: freopen(outpath, "a", stdout); break; } // Check if there is a stdin redirection. if (flags[1]) freopen(inpath, "r", stdin); // Run different command correspondingly. if (!strcmp(command, "cd")) Cd(¶meters); else if (!strcmp(command, "clr")) Clr(); else if (!strcmp(command, "cmp")) Cmp(¶meters); else if (!strcmp(command, "dir")) Dir(¶meters); else if (!strcmp(command, "echo")) Echo(¶meters); else if (!strcmp(command, "environ")) Environ(); else if (!strcmp(command, "fgrep")) Fgrep(¶meters); else if (!strcmp(command, "help")) Help(); else if (!strcmp(command, "pause")) Pause(); else if (!strcmp(command, "pwd")) Pwd(); else if (!strcmp(command, "quit")) Quit(); else if (!strcmp(command, "wc")) Wc(¶meters); else RunExternal(command, ¶meters, flags, inpath, outpath); // If there was an I/O redirection, restore the stdin/stdout. if (flags[0]) freopen("/dev/tty", "w", stdout); if (flags[1]) freopen("/dev/tty", "r", stdin); } return 0; }
Bool Cd(U8 *dirname,Bool make_dirs=FALSE) {//Optionally, will create the directories if they don't exist. I64 maxlen,cur_dir_cluster=0; U8 *chg_to_buf,*new_cur_dir,*buf; CPrt *p; Bool result=TRUE; if (!*dirname) return TRUE; if (dirname[1]==':') { if (*dirname==':') { if (Fs->cur_prt->drv_let!=*sys_acct) if (!Drv(*dirname)) return FALSE; } else { if (Fs->cur_prt!= Drv2Prt(*dirname)) if (!Drv(*dirname)) return FALSE; } dirname+=2; } if (*dirname=='/' || !*dirname || !Fs->cur_dir) { Free(Fs->cur_dir); Fs->cur_dir=StrNew("/"); if (*dirname=='/') dirname++; } chg_to_buf=MStrUtil(dirname, SUF_REM_LEADING|SUF_REM_TRAILING|SUF_REM_CTRL_CHARS); maxlen=StrLen(Fs->cur_dir)+1+StrLen(chg_to_buf)+1; new_cur_dir=MAlloc(maxlen); buf=MAlloc(maxlen); StrCpy(new_cur_dir,Fs->cur_dir); while (*chg_to_buf && result) { StrFirstRem(chg_to_buf,"/",buf); if (!*buf) StrCpy(new_cur_dir,"/"); else if (!StrCmp(buf,"..")) { StrLastRem(new_cur_dir,"/"); if (!*new_cur_dir) StrCpy(new_cur_dir,"/"); } else if (!StrCmp(buf,".")) { ; } else if (*buf) { if (!StrCmp(buf,"HOME")) { result=Cd(sys_acct); Free(new_cur_dir); new_cur_dir=MAlloc(maxlen+StrLen(sys_acct)); StrCpy(new_cur_dir,sys_acct+2); } else { p=Fs->cur_prt; cur_dir_cluster=Name2DirCluster(p,new_cur_dir); switch (p->type) { case PT_REDSEA: result=RedSeaFSCd(buf,cur_dir_cluster); break; case PT_FAT32: result=FAT32Cd(buf,cur_dir_cluster); break; case PT_ISO9660: result=ISO1Cd(buf,cur_dir_cluster); break; default: PutDefineErr("ST_UNSUPPORTED_FILE_SYSTEM"); result=FALSE; } if (!result && make_dirs) { Free(Fs->cur_dir); Fs->cur_dir=StrNew(new_cur_dir); result=MkDir(buf); } if (result) { if (StrCmp(new_cur_dir,"/")) StrCat(new_cur_dir,"/"); StrCat(new_cur_dir,buf); } } } } Free(Fs->cur_dir); Fs->cur_dir=StrNew(new_cur_dir); Free(buf); Free(chg_to_buf); Free(new_cur_dir); return result; }
Classic::Classic() { Cd:Cd(); primarywork = new char[1]; primarywork[0] = '\0'; }
void DiFeliceDrag::setForce() const { if (scaleDia_ > 1) Info << "DiFeliceDrag using scale = " << scaleDia_ << endl; else if (particleCloud_.cg() > 1){ scaleDia_=particleCloud_.cg(); Info << "DiFeliceDrag using scale from liggghts cg = " << scaleDia_ << endl; } // get viscosity field #ifdef comp const volScalarField nufField = particleCloud_.turbulence().mu() / rho_; #else const volScalarField& nufField = particleCloud_.turbulence().nu(); #endif vector position(0,0,0); scalar voidfraction(1); vector Ufluid(0,0,0); vector drag(0,0,0); label cellI=0; vector Us(0,0,0); vector Ur(0,0,0); scalar ds(0); scalar nuf(0); scalar rho(0); scalar magUr(0); scalar Rep(0); scalar Cd(0); vector UfluidFluct(0,0,0); vector UsFluct(0,0,0); vector dragExplicit(0,0,0); scalar dragCoefficient(0); interpolationCellPoint<scalar> voidfractionInterpolator_(voidfraction_); interpolationCellPoint<vector> UInterpolator_(U_); #include "setupProbeModel.H" for(int index = 0;index < particleCloud_.numberOfParticles(); index++) { //if(mask[index][0]) //{ cellI = particleCloud_.cellIDs()[index][0]; drag = vector(0,0,0); if (cellI > -1) // particle Found { if(interpolation_) { position = particleCloud_.position(index); voidfraction = voidfractionInterpolator_.interpolate(position,cellI); Ufluid = UInterpolator_.interpolate(position,cellI); }else { voidfraction = voidfraction_[cellI]; Ufluid = U_[cellI]; } Us = particleCloud_.velocity(index); Ur = Ufluid-Us; ds = 2*particleCloud_.radius(index); nuf = nufField[cellI]; rho = rho_[cellI]; magUr = mag(Ur); Rep = 0; Cd = 0; dragCoefficient = 0; if (magUr > 0) { // calc particle Re Nr Rep = ds/scaleDia_*voidfraction*magUr/(nuf+SMALL); // calc fluid drag Coeff Cd = sqr(0.63 + 4.8/sqrt(Rep)); // calc model coefficient Xi scalar Xi = 3.7 - 0.65 * exp(-sqr(1.5-log10(Rep))/2); // calc particle's drag dragCoefficient = 0.125*Cd*rho *M_PI *ds*ds *scaleDia_ *pow(voidfraction,(2-Xi))*magUr *scaleDrag_; if (modelType_=="B") dragCoefficient /= voidfraction; drag = dragCoefficient*Ur; //total drag force! //Split forces if(splitImplicitExplicit_) { UfluidFluct = Ufluid - U_[cellI]; UsFluct = Us - UsField_[cellI]; dragExplicit = dragCoefficient*(UfluidFluct - UsFluct); //explicit part of force } } if(verbose_ && index >-1 && index <102) { Pout << "index = " << index << endl; Pout << "Us = " << Us << endl; Pout << "Ur = " << Ur << endl; Pout << "ds/scale = " << ds/scaleDia_ << endl; Pout << "rho = " << rho << endl; Pout << "nuf = " << nuf << endl; Pout << "voidfraction = " << voidfraction << endl; Pout << "Rep = " << Rep << endl; Pout << "Cd = " << Cd << endl; Pout << "drag (total) = " << drag << endl; if(splitImplicitExplicit_) { Pout << "UfluidFluct = " << UfluidFluct << endl; Pout << "UsFluct = " << UsFluct << endl; Pout << "dragExplicit = " << dragExplicit << endl; } } //Set value fields and write the probe if(probeIt_) { #include "setupProbeModelfields.H" vValues.append(drag); //first entry must the be the force vValues.append(Ur); sValues.append(Rep); sValues.append(Cd); sValues.append(voidfraction); particleCloud_.probeM().writeProbe(index, sValues, vValues); } } // set force on particle if(treatExplicit_) for(int j=0;j<3;j++) expForces()[index][j] += drag[j]; else //implicit treatment, taking explicit force contribution into account { for(int j=0;j<3;j++) { impForces()[index][j] += drag[j] - dragExplicit[j]; //only consider implicit part! expForces()[index][j] += dragExplicit[j]; } } for(int j=0;j<3;j++) DEMForces()[index][j] += drag[j]; } //} }
void disassembler::Cq(const x86_insn *insn) { Cd(insn); }
Vector<String> CppBuilder::CustomStep(const String& pf, const String& package_, bool& error) { String package = Nvl(package_, mainpackage); String path = (*pf == '.' && pf[1] != '.') ? target : SourcePath(package, pf); String file = GetHostPath(path); String ext = ToLower(GetFileExt(pf)); if(ext == ".ext") { Vector<String> files; Vector<String> dirs; sGatherAllExt(files, dirs, GetFileFolder(path), ""); Index<String> pkg_files; Package pkg; pkg.Load(PackagePath(package)); for(int i = 0; i < pkg.GetCount(); i++) pkg_files.Add(pkg[i]); Index<String> out; Index<String> include_path; String f = LoadFile(path); try { CParser p(f); while(!p.IsEof()) { if(p.Id("files")) { Vector<String> e = ReadPatterns(p); for(int i = 0; i < files.GetCount(); i++) for(int j = 0; j < e.GetCount(); j++) { String f = files[i]; if(PatternMatch(e[j], f) && pkg_files.Find(f) < 0) out.FindAdd(f); } } if(p.Id("exclude")) { ExtExclude(p, out); } if(p.Id("include_path")) { Vector<String> e = ReadPatterns(p); for(int j = 0; j < e.GetCount(); j++) { String ee = e[j]; if(ee.Find('*') >= 0) for(int i = 0; i < dirs.GetCount(); i++) { String d = dirs[i]; if(PatternMatch(e[j], d)) { include_path.FindAdd(d); } } else include_path.Add(ee); } } if(p.Id("exclude_path")) { ExtExclude(p, include_path); } if(p.Id("includes")) { Vector<String> e = ReadPatterns(p); for(int i = 0; i < files.GetCount(); i++) for(int j = 0; j < e.GetCount(); j++) { String f = files[i]; if(PatternMatch(e[j], f) && pkg_files.Find(f) < 0) include_path.FindAdd(GetFileFolder(f)); } } } } catch(CParser::Error) { PutConsole("Invalid .ext file"); error = true; return Vector<String>(); } for(int i = 0; i < include_path.GetCount(); i++) include.Add(NormalizePath(include_path[i], GetFileFolder(path))); Vector<String> o; for(int i = 0; i < out.GetCount(); i++) o.Add(SourcePath(package, out[i])); return o; } for(int i = 0; i < wspc.GetCount(); i++) { const Array< ::CustomStep >& mv = wspc.GetPackage(i).custom; for(int j = 0; j < mv.GetCount(); j++) { const ::CustomStep& m = mv[j]; if(MatchWhen(m.when, config.GetKeys()) && m.MatchExt(ext)) { VectorMap<String, String> mac; AddPath(mac, "PATH", file); AddPath(mac, "RELPATH", pf); AddPath(mac, "DIR", GetFileFolder(PackagePath(package))); AddPath(mac, "FILEDIR", GetFileFolder(file)); AddPath(mac, "PACKAGE", package); mac.Add("FILE", GetFileName(file)); mac.Add("TITLE", GetFileTitle(file)); AddPath(mac, "EXEPATH", GetHostPath(target)); AddPath(mac, "EXEDIR", GetHostPath(GetFileFolder(target))); mac.Add("EXEFILE", GetFileName(target)); mac.Add("EXETITLE", GetFileTitle(target)); AddPath(mac, "OUTDIR", GetHostPath(outdir)); //BW AddPath(mac, "OUTDIR", GetHostPath(GetFileFolder(target))); AddPath(mac, "OUTFILE", GetHostPath(GetFileName(target))); AddPath(mac, "OUTTITLE", GetHostPath(GetFileTitle(target))); mac.Add("INCLUDE", Join(include, ";")); Vector<String> out = Cuprep(m.output, mac, include); bool dirty = out.IsEmpty(); for(int i = 0; !dirty && i < out.GetCount(); i++) dirty = (GetFileTime(file) > GetFileTime(out[i])); if(dirty) { HdependTimeDirty(); PutConsole(GetFileName(file)); Vector<String> cmd = Cuprep(m.command, mac, include); String cmdtext; for(int c = 0; c < cmd.GetCount(); c++) { PutVerbose(cmd[c]); if(!Cd(cmd[c]) && !Cp(cmd[c], package, error)) { String ctext = cmd[c]; const char *cm = ctext; if(*cm == '?') cm++; if(*ctext != '?' && Execute(cm)) { for(int t = 0; t < out.GetCount(); t++) DeleteFile(out[t]); PutConsole("FAILED: " + ctext); error = true; return Vector<String>(); } } } } return out; } } } Vector<String> out; out.Add(path); return out; }
void DiFeliceDrag::setForce() const { if (scaleDia_ > 1) Info << typeName << " using scale = " << scaleDia_ << endl; else if (particleCloud_.cg() > 1){ scaleDia_=particleCloud_.cg(); Info << typeName << " using scale from liggghts cg = " << scaleDia_ << endl; } const volScalarField& nufField = forceSubM(0).nuField(); const volScalarField& rhoField = forceSubM(0).rhoField(); vector position(0,0,0); scalar voidfraction(1); vector Ufluid(0,0,0); vector drag(0,0,0); vector dragExplicit(0,0,0); scalar dragCoefficient(0); label cellI=0; vector Us(0,0,0); vector Ur(0,0,0); scalar ds(0); scalar nuf(0); scalar rho(0); scalar magUr(0); scalar Rep(0); scalar Cd(0); interpolationCellPoint<scalar> voidfractionInterpolator_(voidfraction_); interpolationCellPoint<vector> UInterpolator_(U_); #include "setupProbeModel.H" for(int index = 0;index < particleCloud_.numberOfParticles(); index++) { cellI = particleCloud_.cellIDs()[index][0]; drag = vector(0,0,0); dragExplicit = vector(0,0,0); Ufluid =vector(0,0,0); if (cellI > -1) // particle Found { if(forceSubM(0).interpolation()) { position = particleCloud_.position(index); voidfraction = voidfractionInterpolator_.interpolate(position,cellI); Ufluid = UInterpolator_.interpolate(position,cellI); }else { voidfraction = voidfraction_[cellI]; Ufluid = U_[cellI]; } Us = particleCloud_.velocity(index); Ur = Ufluid-Us; ds = 2*particleCloud_.radius(index); nuf = nufField[cellI]; rho = rhoField[cellI]; magUr = mag(Ur); Rep = 0; Cd = 0; dragCoefficient = 0; if (magUr > 0) { // calc particle Re Nr Rep = ds/scaleDia_*voidfraction*magUr/(nuf+SMALL); // calc fluid drag Coeff Cd = sqr(0.63 + 4.8/sqrt(Rep)); // calc model coefficient Xi scalar Xi = 3.7 - 0.65 * exp(-sqr(1.5-log10(Rep))/2); // calc particle's drag dragCoefficient = 0.125*Cd*rho *M_PI *ds*ds *scaleDia_ *pow(voidfraction,(2-Xi))*magUr *scaleDrag_; if (modelType_=="B") dragCoefficient /= voidfraction; drag = dragCoefficient*Ur; //total drag force! forceSubM(0).explicitCorr(drag,dragExplicit,dragCoefficient,Ufluid,U_[cellI],Us,UsField_[cellI],forceSubM(0).verbose(),index); } if(forceSubM(0).verbose() && index >-1 && index <102) { Pout << "index = " << index << endl; Pout << "scaleDrag_ = " << scaleDrag_ << endl; Pout << "Us = " << Us << endl; Pout << "Ur = " << Ur << endl; Pout << "ds/scale = " << ds/scaleDia_ << endl; Pout << "rho = " << rho << endl; Pout << "nuf = " << nuf << endl; Pout << "voidfraction = " << voidfraction << endl; Pout << "Rep = " << Rep << endl; Pout << "Cd = " << Cd << endl; Pout << "drag (total) = " << drag << endl; } //Set value fields and write the probe if(probeIt_) { #include "setupProbeModelfields.H" vValues.append(drag); //first entry must the be the force vValues.append(Ur); sValues.append(Rep); sValues.append(Cd); sValues.append(voidfraction); particleCloud_.probeM().writeProbe(index, sValues, vValues); } } // write particle based data to global array forceSubM(0).partToArray(index,drag,dragExplicit,Ufluid,dragCoefficient); } }
CC_FILE_ERROR MascaretFilter::saveToFile(ccHObject* entity, QString filename, SaveParameters& parameters) { if (!entity || filename.isEmpty()) return CC_FERR_BAD_ARGUMENT; //look for valid profiles std::vector<ccPolyline*> profiles; try { //get all polylines std::vector<ccPolyline*> candidates; if (entity->isA(CC_TYPES::POLY_LINE)) { candidates.push_back(static_cast<ccPolyline*>(entity)); } else if (entity->isA(CC_TYPES::HIERARCHY_OBJECT)) { for (unsigned i=0; i<entity->getChildrenNumber(); ++i) if (entity->getChild(i) && entity->getChild(i)->isA(CC_TYPES::POLY_LINE)) candidates.push_back(static_cast<ccPolyline*>(entity->getChild(i))); } //then keep the valid profiles only for (size_t i=0; i<candidates.size(); ++i) { ccPolyline* poly = candidates[i]; if ( !poly->hasMetaData(ccPolyline::MetaKeyUpDir()) || !poly->hasMetaData(ccPolyline::MetaKeyAbscissa()) || !poly->hasMetaData(ccPolyline::MetaKeyPrefixCenter()+".x") || !poly->hasMetaData(ccPolyline::MetaKeyPrefixCenter()+".y") || !poly->hasMetaData(ccPolyline::MetaKeyPrefixCenter()+".z") || !poly->hasMetaData(ccPolyline::MetaKeyPrefixDirection()+".x") || !poly->hasMetaData(ccPolyline::MetaKeyPrefixDirection()+".y") || !poly->hasMetaData(ccPolyline::MetaKeyPrefixDirection()+".z") ) { ccLog::Warning(QString("[Mascaret] Polyline '%1' is not a valid profile (missing meta-data)").arg(poly->getName())); break; } else { profiles.push_back(poly); } } } catch (const std::bad_alloc&) { return CC_FERR_NOT_ENOUGH_MEMORY; } if (profiles.empty()) return CC_FERR_NO_SAVE; //open ASCII file for writing QFile file(filename); if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) return CC_FERR_WRITING; QTextStream outFile(&file); outFile.setRealNumberPrecision(12); //ask some parameters SaveMascaretFileDlg smfDlg; if (!smfDlg.exec()) return CC_FERR_CANCELED_BY_USER; QString biefName = smfDlg.biefNameLineEdit->text(); QString type("T"); //B or T --> ask the user switch(smfDlg.typeComboBox->currentIndex()) { case 0: type = "B"; //bathy break; case 1: type = "T"; //topo break; default: assert(false); } //sanitize the 'bief' (reach) name biefName = MakeMascaretName(biefName); //sort the sections by their abscissa if (profiles.size() > 1) { for (size_t i=0; i<profiles.size()-1; ++i) { size_t smallestIndex = i; double smallestAbscissa = profiles[i]->getMetaData(ccPolyline::MetaKeyAbscissa()).toDouble(); for (size_t j=i+1; j<profiles.size(); ++j) { double a = profiles[j]->getMetaData(ccPolyline::MetaKeyAbscissa()).toDouble(); if (a < smallestAbscissa) { smallestAbscissa = a; smallestIndex = j; } } if (i != smallestIndex) { std::swap(profiles[i],profiles[smallestIndex]); } } } CC_FILE_ERROR result = CC_FERR_NO_SAVE; //for each profile for (size_t i=0; i<profiles.size(); ++i) { ccPolyline* poly = profiles[i]; unsigned vertCount = poly ? poly->size() : 0; if (vertCount < 2) { //invalid size ccLog::Warning(QString("[Mascaret] Polyline '%1' does not have enough vertices").arg(poly->getName())); continue; } //decode meta-data bool ok = true; int upDir = 2; double absc = 0.0; CCVector3d Cd(0,0,0); CCVector3d Ud(0,0,0); while (true) //fake loop for easy break { upDir = poly->getMetaData(ccPolyline::MetaKeyUpDir()).toInt(&ok); if (!ok) break; absc = poly->getMetaData(ccPolyline::MetaKeyAbscissa()).toDouble(&ok); if (!ok) break; Cd.x = poly->getMetaData(ccPolyline::MetaKeyPrefixCenter()+".x").toDouble(&ok); if (!ok) break; Cd.y = poly->getMetaData(ccPolyline::MetaKeyPrefixCenter()+".y").toDouble(&ok); if (!ok) break; Cd.z = poly->getMetaData(ccPolyline::MetaKeyPrefixCenter()+".z").toDouble(&ok); if (!ok) break; Ud.x = poly->getMetaData(ccPolyline::MetaKeyPrefixDirection()+".x").toDouble(&ok); if (!ok) break; Ud.y = poly->getMetaData(ccPolyline::MetaKeyPrefixDirection()+".y").toDouble(&ok); if (!ok) break; Ud.z = poly->getMetaData(ccPolyline::MetaKeyPrefixDirection()+".z").toDouble(&ok); break; } if (!ok) { ccLog::Warning(QString("[Mascaret] At least one of the meta-data entry of polyline '%1' is invalid?!").arg(poly->getName())); continue; } QString profileName = poly->getName(); profileName = MakeMascaretName(profileName); CCVector3 C = CCVector3::fromArray(Cd.u); CCVector3 U = CCVector3::fromArray(Ud.u); U.normalize(); //write header outFile << "PROFIL " << biefName << " " << profileName << " " << absc; #define SAVE_AS_GEO_MASCARET #ifdef SAVE_AS_GEO_MASCARET int xDir = upDir == 2 ? 0 : upDir+1; int yDir = xDir == 2 ? 0 : xDir+1; //for "geo"-mascaret, we add some more information: // - first point { const CCVector3* firstP = poly->getPoint(0); CCVector3d firstPg = poly->toGlobal3d(*firstP); outFile << " "; outFile << firstPg.u[xDir] << " " << firstPg.u[yDir]; } // - last point { const CCVector3* lastP = poly->getPoint(vertCount-1); CCVector3d lastPg = poly->toGlobal3d(*lastP); outFile << " "; outFile << lastPg.u[xDir] << " " << lastPg.u[yDir]; } // - profile/path intersection point { outFile << " AXE "; CCVector3d Cdg = poly->toGlobal3d(Cd); outFile << Cdg.u[xDir] << " " << Cdg.u[yDir]; } #endif outFile << endl; //check the abscissa values order (must be increasing!) bool inverted = false; { const CCVector3* P0 = poly->getPoint(0); //convert to 'local' coordinate system CCVector2 Q0; ToLocalAbscissa(*P0, C, U, upDir, Q0); const CCVector3* P1 = poly->getPoint(vertCount-1); //convert to 'local' coordinate system CCVector2 Q1; ToLocalAbscissa(*P1, C, U, upDir, Q1); inverted = (Q1.x < Q0.x); } for (unsigned j=0; j<vertCount; ++j) { const CCVector3* P = poly->getPoint(inverted ? vertCount-1-j : j); //convert to 'local' coordinate system CCVector2 Q; ToLocalAbscissa(*P, C, U, upDir, Q); outFile << Q.x << " " << Q.y << " " << type; #ifdef SAVE_AS_GEO_MASCARET { //for "geo"-mascaret, we add some more information: // - real coordinates of the point outFile << " "; CCVector3d Pg = poly->toGlobal3d(*P); outFile << Pg.u[xDir] << " " << Pg.u[yDir]; } #endif outFile << endl; } result = CC_FERR_NO_ERROR; } file.close(); return result; }