int main(int argc, char *argv[]) { #include "setRootCase.H" #include "createTime.H" #include "createMesh.H" #if defined(version30) pisoControl piso(mesh); #include "createTimeControls.H" #endif #include "createFields.H" #include "initContinuityErrs.H" // create cfdemCloud #include "readGravitationalAcceleration.H" #if defined(anisotropicRotation) cfdemCloudRotation particleCloud(mesh); #else cfdemCloud particleCloud(mesh); #endif #include "checkModelType.H" // create a scalarTransportModel autoPtr<scalarTransportModel> stm ( scalarTransportModel::New(particleCloud.couplingProperties(),particleCloud) ); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info<< "\nStarting time loop\n" << endl; while (runTime.loop()) { particleCloud.clockM().start(1,"Global"); Info<< "Time = " << runTime.timeName() << nl << endl; #if defined(version30) #include "readTimeControls.H" #include "CourantNo.H" #include "setDeltaT.H" #else #include "readPISOControls.H" #include "CourantNo.H" #endif // do particle stuff particleCloud.clockM().start(2,"Coupling"); bool hasEvolved = particleCloud.evolve(voidfraction,Us,U); if(hasEvolved) { particleCloud.smoothingM().smoothen(particleCloud.forceM(0).impParticleForces()); } Info << "update Ksl.internalField()" << endl; Ksl = particleCloud.momCoupleM(0).impMomSource(); Ksl.correctBoundaryConditions(); //Force Checks #include "forceCheckIm.H" #include "solverDebugInfo.H" particleCloud.clockM().stop("Coupling"); particleCloud.clockM().start(26,"Flow"); /*// get scalar source from DEM particleCloud.forceM(1).manipulateScalarField(Tsource); Tsource.correctBoundaryConditions();*/ stm().update(); /*// solve scalar transport equation fvScalarMatrix TEqn ( fvm::ddt(voidfraction,T) - fvm::Sp(fvc::ddt(voidfraction),T) + fvm::div(phi, T) - fvm::Sp(fvc::div(phi),T) - fvm::laplacian(DT*voidfraction, T) == Tsource ); TEqn.relax(); TEqn.solve();*/ particleCloud.clockM().start(26,"Flow"); if(particleCloud.solveFlow()) { // Pressure-velocity PISO corrector { // Momentum predictor fvVectorMatrix UEqn ( fvm::ddt(voidfraction,U) - fvm::Sp(fvc::ddt(voidfraction),U) + fvm::div(phi,U) - fvm::Sp(fvc::div(phi),U) // + turbulence->divDevReff(U) + particleCloud.divVoidfractionTau(U, voidfraction) == - fvm::Sp(Ksl/rho,U) ); UEqn.relax(); #if defined(version30) if (piso.momentumPredictor()) #else if (momentumPredictor) #endif { if (modelType=="B" || modelType=="Bfull") solve(UEqn == - fvc::grad(p) + Ksl/rho*Us); else solve(UEqn == - voidfraction*fvc::grad(p) + Ksl/rho*Us); } // --- PISO loop #if defined(version30) while (piso.correct()) #else int nCorrSoph = nCorr + 5 * pow((1-particleCloud.dataExchangeM().timeStepFraction()),1); for (int corr=0; corr<nCorrSoph; corr++) #endif { volScalarField rUA = 1.0/UEqn.A(); surfaceScalarField rUAf("(1|A(U))", fvc::interpolate(rUA)); volScalarField rUAvoidfraction("(voidfraction2|A(U))",rUA*voidfraction); surfaceScalarField rUAfvoidfraction("(voidfraction2|A(U)F)", fvc::interpolate(rUAvoidfraction)); U = rUA*UEqn.H(); #ifdef version23 phi = ( fvc::interpolate(U*voidfraction) & mesh.Sf() ) + rUAfvoidfraction*fvc::ddtCorr(U, phi); #else phi = ( fvc::interpolate(U*voidfraction) & mesh.Sf() ) + fvc::ddtPhiCorr(rUAvoidfraction, U, phi); #endif surfaceScalarField phiS(fvc::interpolate(Us*voidfraction) & mesh.Sf()); surfaceScalarField phiGes = phi + rUAf*(fvc::interpolate(Ksl/rho) * phiS); if (modelType=="A") rUAvoidfraction = volScalarField("(voidfraction2|A(U))",rUA*voidfraction*voidfraction); // Update the fixedFluxPressure BCs to ensure flux consistency #ifndef versionExt32 if (modelType=="A") { surfaceScalarField voidfractionf(fvc::interpolate(voidfraction)); setSnGrad<fixedFluxPressureFvPatchScalarField> ( p.boundaryField(), ( phi.boundaryField() - (mesh.Sf().boundaryField() & U.boundaryField()) )/(mesh.magSf().boundaryField()*rUAf.boundaryField()*voidfractionf.boundaryField()) ); }else { setSnGrad<fixedFluxPressureFvPatchScalarField> ( p.boundaryField(), ( phi.boundaryField() - (mesh.Sf().boundaryField() & U.boundaryField()) )/(mesh.magSf().boundaryField()*rUAf.boundaryField()) ); } #endif // Non-orthogonal pressure corrector loop #if defined(version30) while (piso.correctNonOrthogonal()) #else for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) #endif { // Pressure corrector fvScalarMatrix pEqn ( fvm::laplacian(rUAvoidfraction, p) == fvc::div(phiGes) + particleCloud.ddtVoidfraction() ); pEqn.setReference(pRefCell, pRefValue); #if defined(version30) pEqn.solve(mesh.solver(p.select(piso.finalInnerIter()))); if (piso.finalNonOrthogonalIter()) { phiGes -= pEqn.flux(); phi = phiGes; } #else if( corr == nCorr-1 && nonOrth == nNonOrthCorr ) #if defined(versionExt32) pEqn.solve(mesh.solutionDict().solver("pFinal")); #else pEqn.solve(mesh.solver("pFinal")); #endif else pEqn.solve(); if (nonOrth == nNonOrthCorr) { phiGes -= pEqn.flux(); phi = phiGes; } #endif } // end non-orthogonal corrector loop #include "continuityErrorPhiPU.H" if (modelType=="B" || modelType=="Bfull") U -= rUA*fvc::grad(p) - Ksl/rho*Us*rUA; else U -= voidfraction*rUA*fvc::grad(p) - Ksl/rho*Us*rUA; U.correctBoundaryConditions(); } // end piso loop }
int main(int argc, char *argv[]) { #include "setRootCase.H" #include "createTime.H" #include "createMesh.H" #if defined(version30) pisoControl piso(mesh); #include "createTimeControls.H" #endif #include "createFields.H" #include "createFvOptions.H" #include "initContinuityErrs.H" // create cfdemCloud #include "readGravitationalAcceleration.H" #include "checkImCoupleM.H" #if defined(anisotropicRotation) cfdemCloudRotation particleCloud(mesh); #elif defined(superquadrics_flag) cfdemCloudRotationSuperquadric particleCloud(mesh); #else cfdemCloud particleCloud(mesh); #endif #include "checkModelType.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info<< "\nStarting time loop\n" << endl; while (runTime.loop()) { Info<< "Time = " << runTime.timeName() << nl << endl; #if defined(version30) #include "readTimeControls.H" #include "CourantNo.H" #include "setDeltaT.H" #else #include "readPISOControls.H" #include "CourantNo.H" #endif // do particle stuff particleCloud.clockM().start(1,"Global"); particleCloud.clockM().start(2,"Coupling"); bool hasEvolved = particleCloud.evolve(voidfraction,Us,U); if(hasEvolved) { particleCloud.smoothingM().smoothenAbsolutField(particleCloud.forceM(0).impParticleForces()); } Ksl = particleCloud.momCoupleM(particleCloud.registryM().getProperty("implicitCouple_index")).impMomSource(); Ksl.correctBoundaryConditions(); surfaceScalarField voidfractionf = fvc::interpolate(voidfraction); phi = voidfractionf*phiByVoidfraction; //Force Checks #include "forceCheckIm.H" #include "solverDebugInfo.H" particleCloud.clockM().stop("Coupling"); particleCloud.clockM().start(26,"Flow"); if(particleCloud.solveFlow()) { // Pressure-velocity PISO corrector { // Momentum predictor fvVectorMatrix UEqn ( fvm::ddt(voidfraction,U) - fvm::Sp(fvc::ddt(voidfraction),U) + fvm::div(phi,U) - fvm::Sp(fvc::div(phi),U) // + turbulence->divDevReff(U) + particleCloud.divVoidfractionTau(U, voidfraction) == - fvm::Sp(Ksl/rho,U) + fvOptions(U) ); UEqn.relax(); fvOptions.constrain(UEqn); #if defined(version30) if (piso.momentumPredictor()) #else if (momentumPredictor) #endif { if (modelType=="B" || modelType=="Bfull") solve(UEqn == - fvc::grad(p) + Ksl/rho*Us); else solve(UEqn == - voidfraction*fvc::grad(p) + Ksl/rho*Us); fvOptions.correct(U); } // --- PISO loop #if defined(version30) while (piso.correct()) #else for (int corr=0; corr<nCorr; corr++) #endif { volScalarField rUA = 1.0/UEqn.A(); surfaceScalarField rUAf("(1|A(U))", fvc::interpolate(rUA)); volScalarField rUAvoidfraction("(voidfraction2|A(U))",rUA*voidfraction); surfaceScalarField rUAfvoidfraction("(voidfraction2|A(U)F)", fvc::interpolate(rUAvoidfraction)); U = rUA*UEqn.H(); #ifdef version23 phi = ( fvc::interpolate(U) & mesh.Sf() ) + rUAfvoidfraction*fvc::ddtCorr(U, phiByVoidfraction); #else phi = ( fvc::interpolate(U) & mesh.Sf() ) + fvc::ddtPhiCorr(rUAvoidfraction, U, phiByVoidfraction); #endif surfaceScalarField phiS(fvc::interpolate(Us) & mesh.Sf()); phi += rUAf*(fvc::interpolate(Ksl/rho) * phiS); if (modelType=="A") rUAvoidfraction = volScalarField("(voidfraction2|A(U))",rUA*voidfraction*voidfraction); // Update the fixedFluxPressure BCs to ensure flux consistency #include "fixedFluxPressureHandling.H" // Non-orthogonal pressure corrector loop #if defined(version30) while (piso.correctNonOrthogonal()) #else for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) #endif { // Pressure corrector fvScalarMatrix pEqn ( fvm::laplacian(rUAvoidfraction, p) == fvc::div(voidfractionf*phi) + particleCloud.ddtVoidfraction() ); pEqn.setReference(pRefCell, pRefValue); #if defined(version30) pEqn.solve(mesh.solver(p.select(piso.finalInnerIter()))); if (piso.finalNonOrthogonalIter()) { phiByVoidfraction = phi - pEqn.flux()/voidfractionf; } #else if( corr == nCorr-1 && nonOrth == nNonOrthCorr ) #if defined(versionExt32) pEqn.solve(mesh.solutionDict().solver("pFinal")); #else pEqn.solve(mesh.solver("pFinal")); #endif else pEqn.solve(); if (nonOrth == nNonOrthCorr) { phiByVoidfraction = phi - pEqn.flux()/voidfractionf; } #endif } // end non-orthogonal corrector loop phi = voidfractionf*phiByVoidfraction; #include "continuityErrorPhiPU.H" if (modelType=="B" || modelType=="Bfull") U -= rUA*fvc::grad(p) - Ksl/rho*Us*rUA; else U -= voidfraction*rUA*fvc::grad(p) - Ksl/rho*Us*rUA; U.correctBoundaryConditions(); fvOptions.correct(U); } // end piso loop }
bool Foam::faceOnlySet::trackToBoundary ( passiveParticle& singleParticle, DynamicList<point>& samplingPts, DynamicList<label>& samplingCells, DynamicList<label>& samplingFaces, DynamicList<scalar>& samplingCurveDist ) const { // distance vector between sampling points const vector offset = end_ - start_; const vector smallVec = tol*offset; const scalar smallDist = mag(smallVec); passiveParticleCloud particleCloud(mesh()); particle::TrackingData<passiveParticleCloud> trackData(particleCloud); // Alias const point& trackPt = singleParticle.position(); while(true) { point oldPoint = trackPt; singleParticle.trackToFace(end_, trackData); if (singleParticle.face() != -1 && mag(oldPoint - trackPt) > smallDist) { // Reached face. Sample. samplingPts.append(trackPt); samplingCells.append(singleParticle.cell()); samplingFaces.append(singleParticle.face()); samplingCurveDist.append(mag(trackPt - start_)); } if (mag(trackPt - end_) < smallDist) { // end reached return false; } else if (singleParticle.onBoundary()) { // Boundary reached. return true; } } }
int main(int argc, char *argv[]) { #include "setRootCase.H" #include "createTime.H" #include "createMesh.H" #include "createFields.H" #include "initContinuityErrs.H" // create cfdemCloud #include "readGravitationalAcceleration.H" cfdemCloud particleCloud(mesh); #include "checkModelType.H" // create a scalarTransportModel autoPtr<scalarTransportModel> stm ( scalarTransportModel::New(particleCloud.couplingProperties(),particleCloud) ); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info<< "\nStarting time loop\n" << endl; while (runTime.loop()) { Info<< "Time = " << runTime.timeName() << nl << endl; #include "readPISOControls.H" #include "CourantNo.H" // do particle stuff bool hasEvolved = particleCloud.evolve(voidfraction,Us,U); if(hasEvolved) { particleCloud.smoothingM().smoothen(particleCloud.forceM(0).impParticleForces()); } Info << "update Ksl.internalField()" << endl; Ksl = particleCloud.momCoupleM(0).impMomSource(); Ksl.correctBoundaryConditions(); #include "solverDebugInfo.H" /*// get scalar source from DEM particleCloud.forceM(1).manipulateScalarField(Tsource); Tsource.correctBoundaryConditions();*/ stm().update(); /*// solve scalar transport equation fvScalarMatrix TEqn ( fvm::ddt(voidfraction,T) - fvm::Sp(fvc::ddt(voidfraction),T) + fvm::div(phi, T) - fvm::Sp(fvc::div(phi),T) - fvm::laplacian(DT*voidfraction, T) == Tsource ); TEqn.relax(); TEqn.solve();*/ if(particleCloud.solveFlow()) { // Pressure-velocity PISO corrector { // Momentum predictor fvVectorMatrix UEqn ( fvm::ddt(voidfraction,U) - fvm::Sp(fvc::ddt(voidfraction),U) + fvm::div(phi,U) - fvm::Sp(fvc::div(phi),U) // + turbulence->divDevReff(U) + particleCloud.divVoidfractionTau(U, voidfraction) == - fvm::Sp(Ksl/rho,U) ); UEqn.relax(); if (momentumPredictor && (modelType=="B" || modelType=="Bfull")) solve(UEqn == - fvc::grad(p) + Ksl/rho*Us); else if (momentumPredictor) solve(UEqn == - voidfraction*fvc::grad(p) + Ksl/rho*Us); // --- PISO loop //for (int corr=0; corr<nCorr; corr++) int nCorrSoph = nCorr + 5 * pow((1-particleCloud.dataExchangeM().timeStepFraction()),1); for (int corr=0; corr<nCorrSoph; corr++) { volScalarField rUA = 1.0/UEqn.A(); surfaceScalarField rUAf("(1|A(U))", fvc::interpolate(rUA)); volScalarField rUAvoidfraction("(voidfraction2|A(U))",rUA*voidfraction); surfaceScalarField rUAfvoidfraction("(voidfraction2|A(U)F)", fvc::interpolate(rUAvoidfraction)); U = rUA*UEqn.H(); #ifdef version23 phi = ( fvc::interpolate(U*voidfraction) & mesh.Sf() ) + rUAfvoidfraction*fvc::ddtCorr(U, phi); #else phi = ( fvc::interpolate(U*voidfraction) & mesh.Sf() ) + fvc::ddtPhiCorr(rUAvoidfraction, U, phi); #endif surfaceScalarField phiS(fvc::interpolate(Us*voidfraction) & mesh.Sf()); surfaceScalarField phiGes = phi + rUAf*(fvc::interpolate(Ksl/rho) * phiS); if (modelType=="A") rUAvoidfraction = volScalarField("(voidfraction2|A(U))",rUA*voidfraction*voidfraction); // Non-orthogonal pressure corrector loop for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) { // Pressure corrector fvScalarMatrix pEqn ( fvm::laplacian(rUAvoidfraction, p) == fvc::div(phiGes) + particleCloud.ddtVoidfraction() ); pEqn.setReference(pRefCell, pRefValue); if ( corr == nCorr-1 && nonOrth == nNonOrthCorr ) { pEqn.solve(mesh.solver("pFinal")); } else { pEqn.solve(); } if (nonOrth == nNonOrthCorr) { phiGes -= pEqn.flux(); phi = phiGes; } } // end non-orthogonal corrector loop #include "continuityErrorPhiPU.H" if (modelType=="B" || modelType=="Bfull") U -= rUA*fvc::grad(p) - Ksl/rho*Us*rUA; else U -= voidfraction*rUA*fvc::grad(p) - Ksl/rho*Us*rUA; U.correctBoundaryConditions(); } // end piso loop } turbulence->correct(); }// end solveFlow else { Info << "skipping flow solution." << endl; } runTime.write(); Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" << nl << endl; } Info<< "End\n" << endl; return 0; }
void Foam::polyLineSet::calcSamples ( DynamicList<point>& samplingPts, DynamicList<label>& samplingCells, DynamicList<label>& samplingFaces, DynamicList<label>& samplingSegments, DynamicList<scalar>& samplingCurveDist ) const { // Check sampling points if (sampleCoords_.size() < 2) { FatalErrorInFunction << "Incorrect sample specification. Too few points:" << sampleCoords_ << exit(FatalError); } point oldPoint = sampleCoords_[0]; for (label sampleI = 1; sampleI < sampleCoords_.size(); sampleI++) { if (mag(sampleCoords_[sampleI] - oldPoint) < SMALL) { FatalErrorInFunction << "Incorrect sample specification." << " Point " << sampleCoords_[sampleI-1] << " at position " << sampleI-1 << " and point " << sampleCoords_[sampleI] << " at position " << sampleI << " are too close" << exit(FatalError); } oldPoint = sampleCoords_[sampleI]; } // Force calculation of cloud addressing on all processors const bool oldMoving = const_cast<polyMesh&>(mesh()).moving(false); passiveParticleCloud particleCloud(mesh()); // current segment number label segmentI = 0; // starting index of current segment in samplePts label startSegmentI = 0; label sampleI = 0; point lastSample(GREAT, GREAT, GREAT); while (true) { // Get boundary intersection point trackPt; label trackCelli = -1; label trackFacei = -1; do { const vector offset = sampleCoords_[sampleI+1] - sampleCoords_[sampleI]; const scalar smallDist = mag(tol*offset); // Get all boundary intersections List<pointIndexHit> bHits = searchEngine().intersections ( sampleCoords_[sampleI], sampleCoords_[sampleI+1] ); point bPoint(GREAT, GREAT, GREAT); label bFacei = -1; if (bHits.size()) { bPoint = bHits[0].hitPoint(); bFacei = bHits[0].index(); } // Get tracking point bool isSample = getTrackingPoint ( sampleCoords_[sampleI], bPoint, bFacei, smallDist, trackPt, trackCelli, trackFacei ); if (isSample && (mag(lastSample - trackPt) > smallDist)) { //Info<< "calcSamples : getTrackingPoint returned valid sample " // << " trackPt:" << trackPt // << " trackFacei:" << trackFacei // << " trackCelli:" << trackCelli // << " sampleI:" << sampleI // << " dist:" << dist // << endl; samplingPts.append(trackPt); samplingCells.append(trackCelli); samplingFaces.append(trackFacei); // Convert sampling position to unique curve parameter. Get // fraction of distance between sampleI and sampleI+1. scalar dist = mag(trackPt - sampleCoords_[sampleI]) / mag(sampleCoords_[sampleI+1] - sampleCoords_[sampleI]); samplingCurveDist.append(sampleI + dist); lastSample = trackPt; } if (trackCelli == -1) { // No intersection found. Go to next point sampleI++; } } while ((trackCelli == -1) && (sampleI < sampleCoords_.size() - 1)); if (sampleI == sampleCoords_.size() - 1) { //Info<< "calcSamples : Reached end of samples: " // << " sampleI now:" << sampleI // << endl; break; } // // Segment sampleI .. sampleI+1 intersected by domain // // Initialize tracking starting from sampleI passiveParticle singleParticle ( mesh(), trackPt, trackCelli ); bool bReached = trackToBoundary ( particleCloud, singleParticle, sampleI, samplingPts, samplingCells, samplingFaces, samplingCurveDist ); // fill sampleSegments for (label i = samplingPts.size() - 1; i >= startSegmentI; --i) { samplingSegments.append(segmentI); } if (!bReached) { //Info<< "calcSamples : Reached end of samples: " // << " sampleI now:" << sampleI // << endl; break; } lastSample = singleParticle.position(); // Find next boundary. sampleI++; if (sampleI == sampleCoords_.size() - 1) { //Info<< "calcSamples : Reached end of samples: " // << " sampleI now:" << sampleI // << endl; break; } segmentI++; startSegmentI = samplingPts.size(); } const_cast<polyMesh&>(mesh()).moving(oldMoving); }
void Foam::uniformSet::calcSamples ( DynamicList<point>& samplingPts, DynamicList<label>& samplingCells, DynamicList<label>& samplingFaces, DynamicList<label>& samplingSegments, DynamicList<scalar>& samplingCurveDist ) const { // distance vector between sampling points if ((nPoints_ < 2) || (mag(end_ - start_) < SMALL)) { FatalErrorInFunction << "Incorrect sample specification. Either too few points or" << " start equals end point." << endl << "nPoints:" << nPoints_ << " start:" << start_ << " end:" << end_ << exit(FatalError); } const vector offset = (end_ - start_)/(nPoints_ - 1); const vector normOffset = offset/mag(offset); const vector smallVec = tol*offset; const scalar smallDist = mag(smallVec); // Force calculation of cloud addressing on all processors const bool oldMoving = const_cast<polyMesh&>(mesh()).moving(false); passiveParticleCloud particleCloud(mesh()); // Get all boundary intersections List<pointIndexHit> bHits = searchEngine().intersections ( start_ - smallVec, end_ + smallVec ); point bPoint(GREAT, GREAT, GREAT); label bFacei = -1; if (bHits.size()) { bPoint = bHits[0].hitPoint(); bFacei = bHits[0].index(); } // Get first tracking point. Use bPoint, bFacei if provided. point trackPt; label trackCelli = -1; label trackFacei = -1; bool isSample = getTrackingPoint ( start_, bPoint, bFacei, smallDist, trackPt, trackCelli, trackFacei ); if (trackCelli == -1) { // Line start_ - end_ does not intersect domain at all. // (or is along edge) // Set points and cell/face labels to empty lists return; } if (isSample) { samplingPts.append(start_); samplingCells.append(trackCelli); samplingFaces.append(trackFacei); samplingCurveDist.append(0.0); } // // Track until hit end of all boundary intersections // // current segment number label segmentI = 0; // starting index of current segment in samplePts label startSegmentI = 0; label sampleI = 0; point samplePt = start_; // index in bHits; current boundary intersection label bHitI = 1; while(true) { // Initialize tracking starting from trackPt passiveParticle singleParticle(mesh(), trackPt, trackCelli); bool reachedBoundary = trackToBoundary ( particleCloud, singleParticle, samplePt, sampleI, samplingPts, samplingCells, samplingFaces, samplingCurveDist ); // fill sampleSegments for (label i = samplingPts.size() - 1; i >= startSegmentI; --i) { samplingSegments.append(segmentI); } if (!reachedBoundary) { if (debug) { Pout<< "calcSamples : Reached end of samples: " << " samplePt now:" << samplePt << " sampleI now:" << sampleI << endl; } break; } bool foundValidB = false; while (bHitI < bHits.size()) { scalar dist = (bHits[bHitI].hitPoint() - singleParticle.position()) & normOffset; if (debug) { Pout<< "Finding next boundary : " << "bPoint:" << bHits[bHitI].hitPoint() << " tracking:" << singleParticle.position() << " dist:" << dist << endl; } if (dist > smallDist) { // hitpoint is past tracking position foundValidB = true; break; } else { bHitI++; } } if (!foundValidB) { // No valid boundary intersection found beyond tracking position break; } // Update starting point for tracking trackFacei = bFacei; trackPt = pushIn(bPoint, trackFacei); trackCelli = getBoundaryCell(trackFacei); segmentI++; startSegmentI = samplingPts.size(); } const_cast<polyMesh&>(mesh()).moving(oldMoving); }
int main(int argc, char *argv[]) { #include "setRootCase.H" #include "createTime.H" #include "createMesh.H" #include "createFields.H" // create cfdemCloud cfdemCloud particleCloud(mesh); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info<< "\nStarting time loop\n" << endl; int count=0; int DEM_dump_Interval=1000; particleCloud.reAllocArrays(); double **positions_; double **velocities_; double **radii_; double **voidfractions_; double **particleWeights_; double **particleVolumes_; double **particleV_; double **cellIDs_; particleCloud.dataExchangeM().allocateArray(positions_,0.,3); particleCloud.dataExchangeM().allocateArray(velocities_,0.,3); particleCloud.get_radii(radii_); // get ref to radii //particleCloud.dataExchangeM().allocateArray(radii_,0.,1); particleCloud.dataExchangeM().allocateArray(voidfractions_,0.,1); particleCloud.dataExchangeM().allocateArray(particleWeights_,0.,1); particleCloud.dataExchangeM().allocateArray(particleVolumes_,0.,1); particleCloud.dataExchangeM().allocateArray(particleV_,0.,1); particleCloud.get_cellIDs(cellIDs_); // get ref to cellIDs //particleCloud.dataExchangeM().allocateArray(cellIDs_,0.,1); while (runTime.loop()) { Info<< "Time = " << runTime.timeName() << nl << endl; count+=DEM_dump_Interval;// proceed loading new data particleCloud.averagingM().resetVectorAverage(particleCloud.averagingM().UsPrev(),particleCloud.averagingM().UsNext()); particleCloud.voidFractionM().resetVoidFractions(); particleCloud.averagingM().resetVectorAverage(particleCloud.forceM(0).impParticleForces(),particleCloud.forceM(0).impParticleForces(),true); particleCloud.averagingM().resetVectorAverage(particleCloud.forceM(0).expParticleForces(),particleCloud.forceM(0).expParticleForces(),true); particleCloud.averagingM().resetWeightFields(); particleCloud.momCoupleM(0).resetMomSourceField(); particleCloud.dataExchangeM().couple(0); particleCloud.dataExchangeM().getData("x","vector-atom",positions_,count); particleCloud.dataExchangeM().getData("v","vector-atom",velocities_,count); particleCloud.dataExchangeM().getData("radius","scalar-atom",radii_,count); particleCloud.locateM().findCell(NULL,positions_,cellIDs_,particleCloud.numberOfParticles()); particleCloud.setPos(positions_); particleCloud.voidFractionM().setvoidFraction(NULL,voidfractions_,particleWeights_,particleVolumes_,particleV_); voidfraction.internalField() = particleCloud.voidFractionM().voidFractionInterp(); voidfraction.correctBoundaryConditions(); particleCloud.averagingM().setVectorAverage ( particleCloud.averagingM().UsNext(), velocities_, particleWeights_, particleCloud.averagingM().UsWeightField(), NULL, //mask NULL, false ); for (int i=0;i<particleCloud.nrForceModels();i++) particleCloud.forceM(i).setForce(); runTime.write(); particleCloud.IOM().dumpDEMdata(); Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" << nl << endl; } particleCloud.dataExchangeM().destroy(positions_,3); particleCloud.dataExchangeM().destroy(velocities_,3); //particleCloud.dataExchangeM().destroy(radii_); // destroyed in cloud particleCloud.dataExchangeM().destroy(voidfractions_,1); particleCloud.dataExchangeM().destroy(particleWeights_,1); particleCloud.dataExchangeM().destroy(particleVolumes_,1); particleCloud.dataExchangeM().destroy(particleV_,1); //particleCloud.dataExchangeM().destroy(cellIDs_); // destroyed in cloud Info<< "End\n" << endl; return 0; }
void Foam::faceOnlySet::calcSamples ( DynamicList<point>& samplingPts, DynamicList<label>& samplingCells, DynamicList<label>& samplingFaces, DynamicList<label>& samplingSegments, DynamicList<scalar>& samplingCurveDist ) const { // Distance vector between sampling points if (mag(end_ - start_) < SMALL) { FatalErrorInFunction << "Incorrect sample specification :" << " start equals end point." << endl << " start:" << start_ << " end:" << end_ << exit(FatalError); } const vector offset = (end_ - start_); const vector normOffset = offset/mag(offset); const vector smallVec = tol*offset; const scalar smallDist = mag(smallVec); // Force calculation of cloud addressing on all processors const bool oldMoving = const_cast<polyMesh&>(mesh()).moving(false); passiveParticleCloud particleCloud(mesh()); // Get all boundary intersections List<pointIndexHit> bHits = searchEngine().intersections ( start_ - smallVec, end_ + smallVec ); point bPoint(GREAT, GREAT, GREAT); label bFacei = -1; if (bHits.size()) { bPoint = bHits[0].hitPoint(); bFacei = bHits[0].index(); } // Get first tracking point. Use bPoint, bFacei if provided. point trackPt; label trackCelli = -1; label trackFacei = -1; // Pout<< "before getTrackingPoint : bPoint:" << bPoint // << " bFacei:" << bFacei << endl; getTrackingPoint ( start_, bPoint, bFacei, smallDist, trackPt, trackCelli, trackFacei ); // Pout<< "after getTrackingPoint : " // << " trackPt:" << trackPt // << " trackCelli:" << trackCelli // << " trackFacei:" << trackFacei // << endl; if (trackCelli == -1) { // Line start_ - end_ does not intersect domain at all. // (or is along edge) // Set points and cell/face labels to empty lists // Pout<< "calcSamples : Both start_ and end_ outside domain" // << endl; return; } if (trackFacei == -1) { // No boundary face. Check for nearish internal face trackFacei = findNearFace(trackCelli, trackPt, smallDist); } // Pout<< "calcSamples : got first point to track from :" // << " trackPt:" << trackPt // << " trackCell:" << trackCelli // << " trackFace:" << trackFacei // << endl; // // Track until hit end of all boundary intersections // // current segment number label segmentI = 0; // starting index of current segment in samplePts label startSegmentI = 0; // index in bHits; current boundary intersection label bHitI = 1; while (true) { if (trackFacei != -1) { // Pout<< "trackPt:" << trackPt << " on face so use." << endl; samplingPts.append(trackPt); samplingCells.append(trackCelli); samplingFaces.append(trackFacei); samplingCurveDist.append(mag(trackPt - start_)); } // Initialize tracking starting from trackPt passiveParticle singleParticle ( mesh(), trackPt, trackCelli ); bool reachedBoundary = trackToBoundary ( particleCloud, singleParticle, smallDist, samplingPts, samplingCells, samplingFaces, samplingCurveDist ); // Fill sampleSegments for (label i = samplingPts.size() - 1; i >= startSegmentI; --i) { samplingSegments.append(segmentI); } if (!reachedBoundary) { // Pout<< "calcSamples : Reached end of samples: " // << " samplePt now:" << singleParticle.position() // << endl; break; } bool foundValidB = false; while (bHitI < bHits.size()) { scalar dist = (bHits[bHitI].hitPoint() - singleParticle.position()) & normOffset; // Pout<< "Finding next boundary : " // << "bPoint:" << bHits[bHitI].hitPoint() // << " tracking:" << singleParticle.position() // << " dist:" << dist // << endl; if (dist > smallDist) { // Hit-point is past tracking position foundValidB = true; break; } else { bHitI++; } } if (!foundValidB || bHitI == bHits.size() - 1) { // No valid boundary intersection found beyond tracking position break; } // Update starting point for tracking trackFacei = bHits[bHitI].index(); trackPt = pushIn(bHits[bHitI].hitPoint(), trackFacei); trackCelli = getBoundaryCell(trackFacei); segmentI++; startSegmentI = samplingPts.size(); } const_cast<polyMesh&>(mesh()).moving(oldMoving); }
int main(int argc, char *argv[]) { #include "setRootCase.H" #include "createTime.H" #include "createMesh.H" #include "createFields.H" // create cfdemCloud cfdemCloud particleCloud(mesh); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info<< "\nStarting time loop\n" << endl; int count=0; int DEM_dump_Interval=1000; double **positions_; double **velocities_; double **radii_; double **voidfractions_; double **particleWeights_; double **particleVolumes_; double **cellIDs_; particleCloud.dataExchangeM().allocateArray(positions_,0.,3); particleCloud.dataExchangeM().allocateArray(velocities_,0.,3); particleCloud.dataExchangeM().allocateArray(radii_,0.,1); particleCloud.dataExchangeM().allocateArray(voidfractions_,0.,1); particleCloud.dataExchangeM().allocateArray(particleWeights_,0.,1); particleCloud.dataExchangeM().allocateArray(particleVolumes_,0.,1); particleCloud.dataExchangeM().allocateArray(cellIDs_,0.,1); while (runTime.loop()) { Info<< "Time = " << runTime.timeName() << nl << endl; count+=DEM_dump_Interval;// proceed loading new data particleCloud.regionM().resetVolFields(Us); particleCloud.dataExchangeM().couple(); particleCloud.dataExchangeM().getData("x","vector-atom",positions_,count); particleCloud.dataExchangeM().getData("v","vector-atom",velocities_,count); particleCloud.dataExchangeM().getData("radius","scalar-atom",radii_,count); particleCloud.set_radii(radii_); particleCloud.locateM().findCell(particleCloud.regionM().inRegion(),positions_,cellIDs_,particleCloud.numberOfParticles()); particleCloud.set_cellIDs(cellIDs_); particleCloud.voidFractionM().setvoidFraction ( particleCloud.regionM().inRegion(),voidfractions_,particleWeights_,particleVolumes_ ); voidfraction.internalField() = particleCloud.voidFractionM().voidFractionInterp(); voidfraction.correctBoundaryConditions(); particleCloud.averagingM().setVectorAverage ( particleCloud.averagingM().UsNext(), velocities_, particleWeights_, particleCloud.averagingM().UsWeightField(), particleCloud.regionM().inRegion() ); runTime.write(); Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" << nl << endl; } delete positions_; delete velocities_; delete radii_; delete voidfractions_; delete particleWeights_; delete particleVolumes_; delete cellIDs_; Info<< "End\n" << endl; return 0; }
int main(int argc, char *argv[]) { Foam::timeSelector::addOptions(); # include "addRegionOption.H" Foam::argList::addBoolOption ( "noWrite", "suppress writing results" ); #include "addDictOption.H" #include "setRootCase.H" #include "createTime.H" Foam::instantList timeDirs = Foam::timeSelector::select0(runTime, args); #include "createNamedMesh.H" #include "createFields.H" // Create particle cloud cfdemCloud particleCloud(mesh); particleCloud.reAllocArrays(); double **positions; double **velocities; double **radii; double **cellID; double **forces; particleCloud.dataExchangeM().allocateArray(positions,0.,3); particleCloud.dataExchangeM().allocateArray(velocities,0.,3); particleCloud.get_radii(radii); particleCloud.get_cellIDs(cellID); particleCloud.dataExchangeM().allocateArray(forces,0.,3); // Read dictionary + dictionaryProps const dictionary dict(particleCloud.couplingProperties()); const dictionary propsDict(dict.subDict("oneWayVTKProps")); bool verbose = false; labelList exIndex(1,0); // Particle ID for debuging if(propsDict.found("verbose")) { verbose = true; if(propsDict.found("exIndex")) exIndex = labelList(propsDict.lookup("exIndex")); } Info << " exIndex = " << exIndex << endl; // Read scalar from sub-dict scalar rhop(0); if(propsDict.found("rhoParticle")) rhop = readScalar(propsDict.lookup("rhoParticle")); Info << " Particle density = " << rhop << endl; forAll(timeDirs, timeI) { runTime.setTime(timeDirs[timeI], timeI); Foam::Info << " " << endl; Foam::Info << "Time = " << runTime.timeName() << Foam::endl; mesh.readUpdate(); // Read gas velocity IOobject Uheader ( "U", runTime.timeName(), mesh, IOobject::MUST_READ ); Info<< " Reading U" << endl; volVectorField U(Uheader,mesh); // Create gas velocity interpolation variable interpolationCellPoint<vector> Uf_xp(U); if ( runTime.timeName() != "0" ) { int count = runTime.value() / particleCloud.dataExchangeM().DEMts(); Info<< " " << endl; particleCloud.dataExchangeM().getData("v","vector-atom",velocities,count); Info<< " Reading particle velocities" << endl; Info<< " " << endl; particleCloud.dataExchangeM().getData("x","vector-atom",positions,count); Info<< " Reading particle positions" << endl; Info<< " " << endl; particleCloud.dataExchangeM().getData("radius","scalar-atom",radii,count); Info<< " Reading particle radius" << endl; Info<< " " << endl; particleCloud.dataExchangeM().getData("f","vector-atom",forces,count); Info<< " Reading forces on particles" << endl; Info<< " " << endl; // Locate particles in Eulerian grid particleCloud.locateM().findCell(NULL,positions,cellID,particleCloud.numberOfParticles()); particleCloud.setPos(positions); particleCloud.setVel(velocities); if(verbose) { //int index = 0; forAll(exIndex,ii) { int index = exIndex[ii]; Info << "" << endl; Info << " index = " << index << endl; Info << " rp = " << particleCloud.radius(index) << endl; Info << " Vp = " << particleCloud.velocity(index) << endl; Info << " Xp = " << particleCloud.position(index) << endl; Info << " CellID = " << particleCloud.particleCell(index) << endl; Info << " Fp = " << forces[index][0] << " " << forces[index][1] << " " << forces[index][2] << endl; int theCellIdOfTheParticle = particleCloud.particleCell(index); Info << " Uf = " << U[theCellIdOfTheParticle] << endl; Info << " Uf@Xp = " << Uf_xp.interpolate(particleCloud.position(index),theCellIdOfTheParticle); Info << "" << endl; } }
int main(int argc, char *argv[]) { #include "setRootCase.H" #include "createTime.H" #include "createDynamicFvMesh.H" #include "createFields.H" #include "initContinuityErrs.H" #if defined(version22) #include "createFvOptions.H" #endif // create cfdemCloud #include "readGravitationalAcceleration.H" cfdemCloudIB particleCloud(mesh); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info<< "\nStarting time loop\n" << endl; while (runTime.loop()) { Info<< "Time = " << runTime.timeName() << nl << endl; //=== dyM =================== interFace = mag(mesh.lookupObject<volScalarField>("voidfractionNext")); mesh.update(); //dyM #include "readPISOControls.H" #include "CourantNo.H" // do particle stuff Info << "- evolve()" << endl; particleCloud.evolve(); // Pressure-velocity PISO corrector { // Momentum predictor fvVectorMatrix UEqn ( fvm::ddt(voidfraction,U) + fvm::div(phi, U) + turbulence->divDevReff(U) #if defined(version22) == fvOptions(U) #endif ); UEqn.relax(); #if defined(version22) fvOptions.constrain(UEqn); #endif if (momentumPredictor) { solve(UEqn == -fvc::grad(p)); } // --- PISO loop for (int corr=0; corr<nCorr; corr++) { volScalarField rUA = 1.0/UEqn.A(); U = rUA*UEqn.H(); #ifdef version23 phi = (fvc::interpolate(U) & mesh.Sf()); // there is a new version in 23x #else phi = (fvc::interpolate(U) & mesh.Sf()) + fvc::ddtPhiCorr(rUA, U, phi); #endif adjustPhi(phi, U, p); #if defined(version22) fvOptions.relativeFlux(phi); #endif // Non-orthogonal pressure corrector loop for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) { // Pressure corrector fvScalarMatrix pEqn ( fvm::laplacian(rUA, p) == fvc::div(phi) + particleCloud.ddtVoidfraction() ); pEqn.setReference(pRefCell, pRefValue); if ( corr == nCorr-1 && nonOrth == nNonOrthCorr ) { pEqn.solve(mesh.solver("pFinal")); } else { pEqn.solve(); } if (nonOrth == nNonOrthCorr) { phi -= pEqn.flux(); } } #include "continuityErrs.H" U -= rUA*fvc::grad(p); U.correctBoundaryConditions(); } } turbulence->correct(); Info << "particleCloud.calcVelocityCorrection() " << endl; volScalarField voidfractionNext=mesh.lookupObject<volScalarField>("voidfractionNext"); particleCloud.calcVelocityCorrection(p,U,phiIB,voidfractionNext); #if defined(version22) fvOptions.correct(U); #endif runTime.write(); Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" << nl << endl; } Info<< "End\n" << endl; return 0; }
bool Foam::uniformSet::trackToBoundary ( passiveParticle& singleParticle, point& samplePt, label& sampleI, DynamicList<point>& samplingPts, DynamicList<label>& samplingCells, DynamicList<label>& samplingFaces, DynamicList<scalar>& samplingCurveDist ) const { // distance vector between sampling points const vector offset = (end_ - start_)/(nPoints_ - 1); const vector smallVec = tol*offset; const scalar smallDist = mag(smallVec); // Alias const point& trackPt = singleParticle.position(); passiveParticleCloud particleCloud(mesh()); particle::TrackingData<passiveParticleCloud> trackData(particleCloud); while(true) { // Find next samplePt on/after trackPt. Update samplePt, sampleI if (!nextSample(trackPt, offset, smallDist, samplePt, sampleI)) { // no more samples. if (debug) { Info<< "trackToBoundary : Reached end : samplePt now:" << samplePt << " sampleI now:" << sampleI << endl; } return false; } if (mag(samplePt - trackPt) < smallDist) { // trackPt corresponds with samplePt. Store and use next samplePt if (debug) { Info<< "trackToBoundary : samplePt corresponds to trackPt : " << " trackPt:" << trackPt << " samplePt:" << samplePt << endl; } samplingPts.append(trackPt); samplingCells.append(singleParticle.cell()); samplingFaces.append(-1); samplingCurveDist.append(mag(trackPt - start_)); // go to next samplePt if (!nextSample(trackPt, offset, smallDist, samplePt, sampleI)) { // no more samples. if (debug) { Info<< "trackToBoundary : Reached end : " << " samplePt now:" << samplePt << " sampleI now:" << sampleI << endl; } return false; } } if (debug) { Info<< "Searching along trajectory from " << " trackPt:" << trackPt << " trackCellI:" << singleParticle.cell() << " to:" << samplePt << endl; } point oldPos = trackPt; label facei = -1; do { singleParticle.stepFraction() = 0; singleParticle.track(samplePt, trackData); if (debug) { Info<< "Result of tracking " << " trackPt:" << trackPt << " trackCellI:" << singleParticle.cell() << " trackFaceI:" << singleParticle.face() << " onBoundary:" << singleParticle.onBoundary() << " samplePt:" << samplePt << " smallDist:" << smallDist << endl; } } while ( !singleParticle.onBoundary() && (mag(trackPt - oldPos) < smallDist) ); if (singleParticle.onBoundary()) { //Info<< "trackToBoundary : reached boundary" << endl; if (mag(trackPt - samplePt) < smallDist) { //Info<< "trackToBoundary : boundary is also sampling point" // << endl; // Reached samplePt on boundary samplingPts.append(trackPt); samplingCells.append(singleParticle.cell()); samplingFaces.append(facei); samplingCurveDist.append(mag(trackPt - start_)); } return true; } //Info<< "trackToBoundary : reached internal sampling point" << endl; // Reached samplePt in cell or on internal face samplingPts.append(trackPt); samplingCells.append(singleParticle.cell()); samplingFaces.append(-1); samplingCurveDist.append(mag(trackPt - start_)); // go to next samplePt } }
int main(int argc, char *argv[]) { Foam::timeSelector::addOptions(); # include "addRegionOption.H" Foam::argList::addBoolOption ( "noWrite", "suppress writing results" ); #include "addDictOption.H" #include "setRootCase.H" #include "createTime.H" Foam::instantList timeDirs = Foam::timeSelector::select0(runTime, args); #include "createNamedMesh.H" #include "createFields.H" // Create particle cloud cfdemCloud particleCloud(mesh); particleCloud.reAllocArrays(); double **positions; double **velocities; double **radii; particleCloud.dataExchangeM().allocateArray(positions,0.,3); particleCloud.dataExchangeM().allocateArray(velocities,0.,3); particleCloud.get_radii(radii); // Post-processing dictionary const dictionary dict(particleCloud.couplingProperties()); forAll(timeDirs, timeI) { runTime.setTime(timeDirs[timeI], timeI); Foam::Info << " " << endl; Foam::Info << "Time = " << runTime.timeName() << Foam::endl; int count = runTime.value() / particleCloud.dataExchangeM().DEMts(); if (count > 0) { Info<< " " << endl; particleCloud.dataExchangeM().getData("v","vector-atom",velocities,count); Info<< tab <<"Reading particle velocities" << endl; Info<< " " << endl; particleCloud.dataExchangeM().getData("x","vector-atom",positions,count); Info<< tab <<"Reading particle positions" << endl; Info<< " " << endl; particleCloud.dataExchangeM().getData("radius","scalar-atom",radii,count); Info<< tab <<"Reading particle radius" << endl; Info<< " " << endl; particleCloud.setPos(positions); particleCloud.setVel(velocities); int index = 0; Pout << tab << "index = " << index << endl; Pout << tab << "rp = " << particleCloud.radius(index) << endl; Pout << tab << "Vp = " << particleCloud.velocity(index) << endl; Pout << tab << "Xp = " << particleCloud.position(index) << endl; Pout << " " << endl; // Create agglomerate cloud bool locateAgglomerate(false); agglomerateCloud agglomerates(dict,mesh,particleCloud,count,locateAgglomerate); agglomerates.createAgglomerate(); Info << "\tNumber of agglomerates = " << agglomerates.numberOfAgglomerates() << endl; } }
int main(int argc, char *argv[]) { #include "setRootCase.H" #include "createTime.H" #include "createMesh.H" pimpleControl pimple(mesh); #include "initContinuityErrs.H" #include "createFields.H" #include "readTimeControls.H" #include "correctPhi.H" #include "CourantNo.H" #include "setInitialDeltaT.H" // create cfdemCloud cfdemCloud particleCloud(mesh); #include "checkModelType.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info<< "\nStarting time loop\n" << endl; while (runTime.run()) { particleCloud.clockM().start(1,"Global"); #include "readTimeControls.H" #include "CourantNo.H" #include "alphaCourantNo.H" #include "setDeltaT.H" runTime++; Info<< "Time = " << runTime.timeName() << nl << endl; // do particle stuff particleCloud.clockM().start(2,"Coupling"); particleCloud.evolve(voidfraction,Us,U); Info << "update Ksl.internalField()" << endl; Ksl.internalField() = particleCloud.momCoupleM(0).impMomSource(); Ksl.correctBoundaryConditions(); #include "solverDebugInfo.H" particleCloud.clockM().stop("Coupling"); particleCloud.clockM().start(26,"Flow"); twoPhaseProperties.correct(); #include "alphaEqnSubCycle.H" // --- Pressure-velocity PIMPLE corrector loop while (pimple.loop()) { #include "UEqn.H" // --- Pressure corrector loop while (pimple.correct()) { #include "pEqn.H" } if (pimple.turbCorr()) { turbulence->correct(); } } runTime.write(); Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" << nl << endl; particleCloud.clockM().stop("Flow"); particleCloud.clockM().stop("Global"); } Info<< "End\n" << endl; return 0; }
int main(int argc, char *argv[]) { timeSelector::addOptions(); # include "addRegionOption.H" argList::addBoolOption ( "noWrite", "suppress writing results" ); #include "addDictOption.H" #include "setRootCase.H" #include "createTime.H" instantList timeDirs = timeSelector::select0(runTime, args); #include "createNamedMesh.H" #include "createFields.H" // Create particle cloud cfdemCloud particleCloud(mesh); // Post-processing dictionary #include "postProcessingDict.H" // Create conditional averaging class conditionalAve condAve(postProcessingDict,conditionalAveragingDict, mesh,nVariable,nAveragingVariable,nTotalCase,conditionalAveraging); // Create multiple variable conditional averaging class multipleVarsConditionalAve multipleVarsCondAve(postProcessingDict,multConditionalAveragingDict, mesh,multNVariable,multNAveragingVariable,multNTotalCase,multConditionalAveraging); forAll(timeDirs, timeI) { runTime.setTime(timeDirs[timeI], timeI); Pout << " " << endl; Pout << "\nTime = " << runTime.timeName() << endl; mesh.readUpdate(); // Read gas volume fraction IOobject voidfractionheader ( "voidfraction", runTime.timeName(), mesh, IOobject::MUST_READ ); Info<< " Reading voidfraction" << endl; volScalarField voidfraction(voidfractionheader,mesh); // Read Eulerian particle velocity IOobject Usheader ( "Us", runTime.timeName(), mesh, IOobject::MUST_READ ); Info<< " Reading Us" << endl; volVectorField Us(Usheader,mesh); // Read particle kinetic stresses IOobject sigmaKinHeader ( "sigmaKin", runTime.timeName(), mesh, IOobject::MUST_READ ); Info<< " Reading sigmaKin" << endl; volSymmTensorField sigmaKin(sigmaKinHeader,mesh); // Read particle collisional stresses IOobject sigmaCollHeader ( "sigmaColl", runTime.timeName(), mesh, IOobject::MUST_READ ); Info<< " Reading sigmaColl" << endl; volSymmTensorField sigmaColl(sigmaCollHeader,mesh); // Particle pressure volScalarField Pp ( IOobject ( "Pp", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), mesh, dimensionedScalar( "zero", dimensionSet(1,-1,-2,0,0), scalar(0) ) ); Pp = 1./3. * tr( sigmaKin + sigmaColl ) ; // Write into the results folder Pp.write(); // Calculate the particulate pressure gradient volVectorField gradPp(fvc::grad(Pp)); // Particle shear stress volTensorField sigmap ( IOobject ( "sigmap", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), mesh, dimensionedTensor( "zero", dimensionSet(1,-1,-2,0,0), tensor(0,0,0,0,0,0,0,0,0) ) ); sigmap = ( sigmaKin + sigmaColl ) - tensor(I) * Pp; // Write into the results folder sigmap.write(); // Particle viscosity volScalarField mup ( IOobject ( "mup", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), mesh, dimensionedScalar( "zero", dimensionSet(1,-1,-1,0,0), scalar(0) ) ); // Particle shear stresses volTensorField S("S",fvc::grad(Us) + fvc::grad(Us)().T()); dimensionedScalar SSsmall("zero", dimensionSet(0,0,-2,0,0,0,0), SMALL); mup = ( sigmap && S ) / ( max ( S && S, SSsmall ) ); // Limit by zero mup.max(0.); // Write into the results folder mup.write(); // Particle viscosity/sqrt(p) dimensionedScalar PpSmall("zero", dimensionSet(1,-1,-2,0,0,0,0), 1.e-06); volScalarField mupSqrtPp ( IOobject ( "mupSqrtPp", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), mup/sqrt((mag(Pp)+PpSmall)*rhop)/dp ); //- Dummy word word varName(""); //- Conditional averaging condAve.calc(); condAve.write(varName); //- Multi-variable conditional averaging multipleVarsCondAve.calc(); multipleVarsCondAve.write(varName); }