void virtualMassForce::setForce() const { reAllocArrays(); scalar dt = U_.mesh().time().deltaT().value(); for(int index = 0;index < particleCloud_.numberOfParticles(); index++) { //if(mask[index][0]) //{ vector virtualMassForce(0,0,0); label cellI = particleCloud_.cellIDs()[index][0]; if (cellI > -1) // particle Found { vector Us = particleCloud_.velocity(index); vector Ur = U_[cellI]-Us; vector UrelOld; for(int j=0;j<3;j++) { UrelOld[j] = UrelOld_[index][j]; UrelOld_[index][j] = Ur[j]; } vector ddtUrel = (Ur-UrelOld)/dt; scalar ds = 2*particleCloud_.radius(index); scalar Vs = ds*ds*ds*M_PI/6; scalar rho = rho_[cellI]; virtualMassForce = 0.5 * rho * Vs * ddtUrel; } // set force on particle if(treatExplicit_) for(int j=0;j<3;j++) expForces()[index][j] += virtualMassForce[j]; else for(int j=0;j<3;j++) impForces()[index][j] += virtualMassForce[j]; for(int j=0;j<3;j++) DEMForces()[index][j] += virtualMassForce[j]; //} } }
void Foam::cfdemCloud::CheckExistanceAndReadDEMData() { int nmr_of_part=IOM().LookForDEMdata(); //IOM().getNumberOfParticles("positions_nh"); //if these files are not empty if(nmr_of_part>0) { Pout <<"Found "<< nmr_of_part<<" particles."<< endl; if(nmr_of_part>numberOfParticles()) { FatalError<< "Amount of memory for "<<nmr_of_part<<" particles from prev. simulation exceeds already allocated memory for "<<numberOfParticles()<<" particle. \nIncrease maxNumberOfParticles in coupllingProperties file." << abort(FatalError); } reAllocArrays(); setNumberOfParticles(nmr_of_part); Info << "- Starting to upload it."<< endl; //fetching data from files into DEM arrays IOM().getExistingDEMData("positions_nh","vector-atom",positions_); IOM().getExistingDEMData("r_nh","scalar-atom",radii_); IOM().getExistingDEMData("m_nh","scalar-atom",mass_); IOM().getExistingDEMData("v_nh","vector-atom",velocities_); IOM().getExistingDEMData("DEMForces_nh","vector-atom",DEMForces_); IOM().getExistingDEMData("tTurbs_nh","scalar-atom",tTurb_); IOM().getExistingDEMData("tTurbInts_nh","scalar-atom",tTurbInt_); IOM().getExistingDEMData("fluidTurbVels_nh","vector-atom",fluidTurbVel_); //pushing data to DEM code dataExchangeM().giveDataFromPreviosSimulation(nmr_of_part, positions_, velocities_, radii_, mass_,DEMForces_,tTurb_,tTurbInt_,fluidTurbVel_); //Info << "All data is loaded."<< endl<< endl; } else { //Info << "************** FILES PRESENT BUT EMPTY. ************************************"<< endl<< endl; } }
void virtualMassForce::setForce() const { reAllocArrays(); scalar dt = U_.mesh().time().deltaT().value(); vector position(0,0,0); vector Ufluid(0,0,0); vector Ur(0,0,0); vector DDtU(0,0,0); //Compute extra vfields in case it is needed volVectorField DDtU_(0.0*U_/U_.mesh().time().deltaT()); if(splitUrelCalculation_) DDtU_ = fvc::ddt(U_) + fvc::div(phi_, U_); //Total Derivative of fluid velocity interpolationCellPoint<vector> UInterpolator_( U_); interpolationCellPoint<vector> DDtUInterpolator_(DDtU_); #include "setupProbeModel.H" bool haveUrelOld_(false); for(int index = 0; index < particleCloud_.numberOfParticles(); index++) { vector virtualMassForce(0,0,0); label cellI = particleCloud_.cellIDs()[index][0]; if (cellI > -1) // particle Found { if(forceSubM(0).interpolation()) { position = particleCloud_.position(index); Ufluid = UInterpolator_.interpolate(position,cellI); } else { Ufluid = U_[cellI]; } if(splitUrelCalculation_) //if split, just use total derivative of fluid velocity if(forceSubM(0).interpolation()) { DDtU = DDtUInterpolator_.interpolate(position,cellI); } else { DDtU = DDtU_[cellI]; } else { vector Us = particleCloud_.velocity(index); Ur = Ufluid - Us; } //Check of particle was on this CPU the last step if(UrelOld_[index][0]==NOTONCPU) //use 1. element to indicate that particle was on this CPU the last time step haveUrelOld_ = false; else haveUrelOld_ = true; vector UrelOld(0.,0.,0.); vector ddtUrel(0.,0.,0.); for(int j=0; j<3; j++) { UrelOld[j] = UrelOld_[index][j]; UrelOld_[index][j] = Ur[j]; } if(haveUrelOld_ ) //only compute force if we have old (relative) velocity ddtUrel = (Ur-UrelOld)/dt; if(splitUrelCalculation_) //we can always compute the total derivative in case we split ddtUrel = DDtU; scalar ds = 2*particleCloud_.radius(index); scalar Vs = ds*ds*ds*M_PI/6; scalar rho = forceSubM(0).rhoField()[cellI]; virtualMassForce = Cadd_ * rho * Vs * ddtUrel; if( forceSubM(0).verbose() ) //&& index>100 && index < 105) { Pout << "index / cellI = " << index << tab << cellI << endl; Pout << "position = " << particleCloud_.position(index) << endl; } //Set value fields and write the probe if(probeIt_) { #include "setupProbeModelfields.H" vValues.append(virtualMassForce); //first entry must the be the force vValues.append(Ur); vValues.append(UrelOld); vValues.append(ddtUrel); sValues.append(Vs); sValues.append(rho); particleCloud_.probeM().writeProbe(index, sValues, vValues); } } else //particle not on this CPU UrelOld_[index][0]=NOTONCPU; // write particle based data to global array forceSubM(0).partToArray(index,virtualMassForce,vector::zero); } }
void centreVoidFraction::setvoidFraction(double** const& mask,double**& voidfractions,double**& particleWeights,double**& particleVolumes) const { reAllocArrays(); scalar radius(-1); scalar volume(0); scalar cellVol(0); scalar scaleVol= weight(); for(int index=0; index< particleCloud_.numberOfParticles(); index++) { //if(mask[index][0]) //{ // reset particleWeights[index][0]=0; cellsPerParticle_[index][0]=1; label cellI = particleCloud_.cellIDs()[index][0]; if (cellI >= 0) // particel centre is in domain { cellVol = voidfractionNext_.mesh().V()[cellI]; radius = particleCloud_.radius(index); volume = 4.188790205*radius*radius*radius*scaleVol; // store volume for each particle particleVolumes[index][0] = volume; voidfractionNext_[cellI] -= volume/cellVol; if(voidfractionNext_[cellI] < alphaMin_ ) { voidfractionNext_[cellI] = alphaMin_; alphaLimited_ = 1; } if(index==0 && alphaLimited_) Info<<"alpha limited to" <<alphaMin_<<endl; // store voidFraction for each particle voidfractions[index][0] = voidfractionNext_[cellI]; // store cellweight for each particle - this should not live here particleWeights[index][0] = 1; /*//OUTPUT if (index==0) { Info << "centre cellI = " << cellI << endl; Info << "cellsPerParticle_=" << cellsPerParticle_[index][0] << endl; for(int i=0;i<cellsPerParticle_[index][0];i++) { if(i==0)Info << "cellids, voidfractions, particleWeights, : \n"; Info << particleCloud_.cellIDs()[index][i] << " ," << endl; Info << voidfractions[index][i] << " ," << endl; Info << particleWeights[index][i] << " ," << endl; } }*/ } //} } // bring voidfraction from Eulerian Field to particle array for(int index=0; index< particleCloud_.numberOfParticles(); index++) { label cellID = particleCloud_.cellIDs()[index][0]; if(cellID >= 0) { voidfractions[index][0] = voidfractionNext_[cellID]; } else { voidfractions[index][0] = -1.; } } }