From d1b9dab50af3186236848783cc650e518f370ff1 Mon Sep 17 00:00:00 2001 From: graham Date: Mon, 20 Sep 2010 12:45:57 +0100 Subject: [PATCH 1/9] ENH: Moving cellOccupancy into KinematicCloud. --- .../Templates/KinematicCloud/KinematicCloud.C | 72 +++++++++++++++++++ .../Templates/KinematicCloud/KinematicCloud.H | 20 +++++- .../KinematicCloud/KinematicCloudI.H | 13 ++++ .../Templates/ReactingCloud/ReactingCloud.C | 25 ++++++- .../Templates/ReactingCloud/ReactingCloud.H | 3 + .../ReactingMultiphaseCloud.C | 25 ++++++- .../ReactingMultiphaseCloud.H | 3 + .../Templates/ThermoCloud/ThermoCloud.C | 25 ++++++- .../Templates/ThermoCloud/ThermoCloud.H | 3 + .../PairCollision/PairCollision.C | 45 +++++------- .../PairCollision/PairCollision.H | 6 -- 11 files changed, 203 insertions(+), 37 deletions(-) diff --git a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C index 10fccde371..9666d61719 100644 --- a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C +++ b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C @@ -43,6 +43,52 @@ void Foam::KinematicCloud::preEvolve() { this->dispersion().cacheFields(true); forces_.cacheFields(true, interpolationSchemes_); + updateCellOccupancy(); +} + + +template +void Foam::KinematicCloud::buildCellOccupancy() +{ + if (cellOccupancyPtr_.empty()) + { + cellOccupancyPtr_.reset + ( + new List >(mesh_.nCells()) + ); + } + else if (cellOccupancyPtr_().size() != mesh_.nCells()) + { + // If the size of the mesh has changed, reset the + // cellOccupancy size + + cellOccupancyPtr_().setSize(mesh_.nCells()); + } + + List >& cellOccupancy = cellOccupancyPtr_(); + + forAll(cellOccupancy, cO) + { + cellOccupancy[cO].clear(); + } + + forAllIter(typename KinematicCloud, *this, iter) + { + cellOccupancy[iter().cell()].append(&iter()); + } +} + + +template +void Foam::KinematicCloud::updateCellOccupancy() +{ + // Only build the cellOccupancy if the pointer is set, i.e. it has + // been requested before. + + if (cellOccupancyPtr_.valid()) + { + buildCellOccupancy(); + } } @@ -80,8 +126,19 @@ void Foam::KinematicCloud::evolveCloud() g_.value() ); + label preInjectionSize = this->size(); + this->surfaceFilm().inject(td); + // Update the cellOccupancy if the size of the cloud has changed + // during the injection. + if (preInjectionSize != this->size()) + { + updateCellOccupancy(); + + preInjectionSize = this->size(); + } + this->injection().inject(td); if (coupled_) @@ -89,6 +146,18 @@ void Foam::KinematicCloud::evolveCloud() resetSourceTerms(); } + // Assume that motion will update the cellOccupancy as necessary + // before it is required. + motion(td); +} + + +template +void Foam::KinematicCloud::motion +( + typename ParcelType::trackData& td +) +{ // Sympletic leapfrog integration of particle forces: // + apply half deltaV with stored force // + move positions with new velocity @@ -136,6 +205,8 @@ void Foam::KinematicCloud::moveCollide // td.part() = ParcelType::trackData::tpRotationalTrack; // Cloud::move(td); + updateCellOccupancy(); + this->collision().collide(); td.part() = ParcelType::trackData::tpVelocityHalfStep; @@ -194,6 +265,7 @@ Foam::KinematicCloud::KinematicCloud particleProperties_.lookup("cellValueSourceCorrection") ), rndGen_(label(0)), + cellOccupancyPtr_(), rho_(rho), U_(U), mu_(mu), diff --git a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.H b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.H index 5d36cb575e..ed5b5ae539 100644 --- a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.H +++ b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.H @@ -136,6 +136,9 @@ protected: //- Random number generator - used by some injection routines Random rndGen_; + //- Cell occupancy information for each parcel, (demand driven) + autoPtr > > cellOccupancyPtr_; + // References to the carrier gas fields @@ -209,10 +212,20 @@ protected: //- Pre-evolve void preEvolve(); + //- Build the cellOccupancy + void buildCellOccupancy(); + + //- Update (i.e. build) the cellOccupancy if it has + // already been used + void updateCellOccupancy(); + //- Evolve the cloud void evolveCloud(); - //- Move-collide + //- Particle motion + void motion(typename ParcelType::trackData& td); + + //- Move-collide particles void moveCollide(typename ParcelType::trackData& td); //- Post-evolve @@ -284,6 +297,11 @@ public: //- Return refernce to the random object inline Random& rndGen(); + //- Return the cell occupancy information for each parcel, + // non-const access, the caller is responsible for updating + // it if particles are removed or created. + inline List >& cellOccupancy(); + // References to the carrier gas fields diff --git a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloudI.H b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloudI.H index 9f9b441f43..536e4e6773 100644 --- a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloudI.H +++ b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloudI.H @@ -302,6 +302,19 @@ inline Foam::Random& Foam::KinematicCloud::rndGen() } +template +inline Foam::List >& +Foam::KinematicCloud::cellOccupancy() +{ + if (cellOccupancyPtr_.empty()) + { + buildCellOccupancy(); + } + + return cellOccupancyPtr_(); +} + + template inline Foam::DimensionedField& Foam::KinematicCloud::UTrans() diff --git a/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.C b/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.C index fec5e02ea3..f3fb165b0e 100644 --- a/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.C +++ b/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.C @@ -120,8 +120,19 @@ void Foam::ReactingCloud::evolveCloud() this->g().value() ); + label preInjectionSize = this->size(); + this->surfaceFilm().inject(td); + // Update the cellOccupancy if the size of the cloud has changed + // during the injection. + if (preInjectionSize != this->size()) + { + this->updateCellOccupancy(); + + preInjectionSize = this->size(); + } + this->injection().inject(td); if (this->coupled()) @@ -129,7 +140,19 @@ void Foam::ReactingCloud::evolveCloud() resetSourceTerms(); } - Cloud::move(td); + // Assume that motion will update the cellOccupancy as necessary + // before it is required. + motion(td); +} + + +template +void Foam::ReactingCloud::motion +( + typename ParcelType::trackData& td +) +{ + ThermoCloud::motion(td); } diff --git a/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.H b/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.H index 38b33eab48..def51f8955 100644 --- a/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.H +++ b/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloud.H @@ -130,6 +130,9 @@ protected: //- Evolve the cloud void evolveCloud(); + //- Particle motion + void motion(typename ParcelType::trackData& td); + //- Post-evolve void postEvolve(); diff --git a/src/lagrangian/intermediate/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloud.C b/src/lagrangian/intermediate/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloud.C index 954f048634..451e3716d4 100644 --- a/src/lagrangian/intermediate/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloud.C +++ b/src/lagrangian/intermediate/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloud.C @@ -93,8 +93,19 @@ void Foam::ReactingMultiphaseCloud::evolveCloud() this->g().value() ); + label preInjectionSize = this->size(); + this->surfaceFilm().inject(td); + // Update the cellOccupancy if the size of the cloud has changed + // during the injection. + if (preInjectionSize != this->size()) + { + this->updateCellOccupancy(); + + preInjectionSize = this->size(); + } + this->injection().inject(td); if (this->coupled()) @@ -102,7 +113,19 @@ void Foam::ReactingMultiphaseCloud::evolveCloud() resetSourceTerms(); } - Cloud::move(td); + // Assume that motion will update the cellOccupancy as necessary + // before it is required. + motion(td); +} + + +template +void Foam::ReactingMultiphaseCloud::motion +( + typename ParcelType::trackData& td +) +{ + ReactingCloud::motion(td); } diff --git a/src/lagrangian/intermediate/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloud.H b/src/lagrangian/intermediate/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloud.H index efd1eaab8e..af2199261e 100644 --- a/src/lagrangian/intermediate/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloud.H +++ b/src/lagrangian/intermediate/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloud.H @@ -121,6 +121,9 @@ protected: //- Evolve the cloud void evolveCloud(); + //- Particle motion + void motion(typename ParcelType::trackData& td); + //- Post-evolve void postEvolve(); diff --git a/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.C b/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.C index 96d6d59b8a..26cbeedcc6 100644 --- a/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.C +++ b/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.C @@ -86,8 +86,19 @@ void Foam::ThermoCloud::evolveCloud() this->g().value() ); + label preInjectionSize = this->size(); + + // Update the cellOccupancy if the size of the cloud has changed + // during the injection. this->surfaceFilm().inject(td); + if (preInjectionSize != this->size()) + { + this->updateCellOccupancy(); + + preInjectionSize = this->size(); + } + this->injection().inject(td); if (this->coupled()) @@ -95,7 +106,19 @@ void Foam::ThermoCloud::evolveCloud() resetSourceTerms(); } - Cloud::move(td); + // Assume that motion will update the cellOccupancy as necessary + // before it is required. + motion(td); +} + + +template +void Foam::ThermoCloud::motion +( + typename ParcelType::trackData& td +) +{ + KinematicCloud::motion(td); } diff --git a/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.H b/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.H index 0f7c8afb23..a476dcb6f7 100644 --- a/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.H +++ b/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.H @@ -121,6 +121,9 @@ protected: //- Evolve the cloud void evolveCloud(); + //- Particle motion + void motion(typename ParcelType::trackData& td); + //- Post-evolve void postEvolve(); diff --git a/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairCollision.C b/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairCollision.C index e1e1587c95..0afeb97578 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairCollision.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairCollision.C @@ -51,8 +51,6 @@ void Foam::PairCollision::preInteraction() p.torque() = vector::zero; } - - buildCellOccupancy(); } @@ -61,7 +59,7 @@ void Foam::PairCollision::parcelInteraction() { PstreamBuffers pBufs(Pstream::nonBlocking); - il_.sendReferredData(cellOccupancy_, pBufs); + il_.sendReferredData(this->owner().cellOccupancy(), pBufs); realRealInteraction(); @@ -80,17 +78,20 @@ void Foam::PairCollision::realRealInteraction() typename CloudType::parcelType* pA_ptr = NULL; typename CloudType::parcelType* pB_ptr = NULL; + List >& cellOccupancy = + this->owner().cellOccupancy(); + forAll(dil, realCellI) { // Loop over all Parcels in cell A (a) - forAll(cellOccupancy_[realCellI], a) + forAll(cellOccupancy[realCellI], a) { - pA_ptr = cellOccupancy_[realCellI][a]; + pA_ptr = cellOccupancy[realCellI][a]; forAll(dil[realCellI], interactingCells) { List cellBParcels = - cellOccupancy_[dil[realCellI][interactingCells]]; + cellOccupancy[dil[realCellI][interactingCells]]; // Loop over all Parcels in cell B (b) forAll(cellBParcels, b) @@ -102,9 +103,9 @@ void Foam::PairCollision::realRealInteraction() } // Loop over the other Parcels in cell A (aO) - forAll(cellOccupancy_[realCellI], aO) + forAll(cellOccupancy[realCellI], aO) { - pB_ptr = cellOccupancy_[realCellI][aO]; + pB_ptr = cellOccupancy[realCellI][aO]; // Do not double-evaluate, compare pointers, arbitrary // order @@ -127,6 +128,9 @@ void Foam::PairCollision::realReferredInteraction() List >& referredParticles = il_.referredParticles(); + List >& cellOccupancy = + this->owner().cellOccupancy(); + // Loop over all referred cells forAll(ril, refCellI) { @@ -150,7 +154,7 @@ void Foam::PairCollision::realReferredInteraction() forAll(realCells, realCellI) { List realCellParcels = - cellOccupancy_[realCells[realCellI]]; + cellOccupancy[realCells[realCellI]]; forAll(realCellParcels, realParcelI) { @@ -179,6 +183,9 @@ void Foam::PairCollision::wallInteraction() const volVectorField& U = mesh.lookupObject(il_.UName()); + List >& cellOccupancy = + this->owner().cellOccupancy(); + // Storage for the wall interaction sites DynamicList flatSitePoints; DynamicList flatSiteExclusionDistancesSqr; @@ -196,7 +203,7 @@ void Foam::PairCollision::wallInteraction() const labelList& realWallFaces = directWallFaces[realCellI]; // Loop over all Parcels in cell - forAll(cellOccupancy_[realCellI], cellParticleI) + forAll(cellOccupancy[realCellI], cellParticleI) { flatSitePoints.clear(); flatSiteExclusionDistancesSqr.clear(); @@ -209,7 +216,7 @@ void Foam::PairCollision::wallInteraction() sharpSiteData.clear(); typename CloudType::parcelType& p = - *cellOccupancy_[realCellI][cellParticleI]; + *cellOccupancy[realCellI][cellParticleI]; const point& pos = p.position(); @@ -482,21 +489,6 @@ void Foam::PairCollision::postInteraction() } -template -void Foam::PairCollision::buildCellOccupancy() -{ - forAll(cellOccupancy_, cO) - { - cellOccupancy_[cO].clear(); - } - - forAllIter(typename CloudType, this->owner(), iter) - { - cellOccupancy_[iter().cell()].append(&iter()); - } -} - - template void Foam::PairCollision::evaluatePair ( @@ -539,7 +531,6 @@ Foam::PairCollision::PairCollision ) : CollisionModel(dict, owner, typeName), - cellOccupancy_(owner.mesh().nCells()), pairModel_ ( PairModel::New diff --git a/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairCollision.H b/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairCollision.H index 8699d477cd..6ad4130e1c 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairCollision.H +++ b/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairCollision.H @@ -76,9 +76,6 @@ class PairCollision // Private data - //- Cell occupancy information for each parcel - List > cellOccupancy_; - //- PairModel to calculate the interaction between two parcels autoPtr > pairModel_; @@ -124,9 +121,6 @@ class PairCollision //- Post collision tasks void postInteraction(); - //- Build the cell occupancy information for each parcel - void buildCellOccupancy(); - //- Calculate the pair force between parcels void evaluatePair ( From ed314b62bc578b2a4e75492a72801260f10bbcf2 Mon Sep 17 00:00:00 2001 From: graham Date: Mon, 20 Sep 2010 17:36:41 +0100 Subject: [PATCH 2/9] STYLE: Removed unused dynamicMeshDicts. --- .../mixerVessel2D/constant/dynamicMeshDict | 42 ------------------- .../mixerVessel2D/constant/dynamicMeshDict | 42 ------------------- 2 files changed, 84 deletions(-) delete mode 100644 tutorials/compressible/rhoPorousMRFPimpleFoam/mixerVessel2D/constant/dynamicMeshDict delete mode 100644 tutorials/incompressible/MRFSimpleFoam/mixerVessel2D/constant/dynamicMeshDict diff --git a/tutorials/compressible/rhoPorousMRFPimpleFoam/mixerVessel2D/constant/dynamicMeshDict b/tutorials/compressible/rhoPorousMRFPimpleFoam/mixerVessel2D/constant/dynamicMeshDict deleted file mode 100644 index 36f5458ddf..0000000000 --- a/tutorials/compressible/rhoPorousMRFPimpleFoam/mixerVessel2D/constant/dynamicMeshDict +++ /dev/null @@ -1,42 +0,0 @@ -/*--------------------------------*- C++ -*----------------------------------*\ -| ========= | | -| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.com | -| \\/ M anipulation | | -\*---------------------------------------------------------------------------*/ -FoamFile -{ - version 2.0; - format ascii; - class dictionary; - location "constant"; - object dynamicMeshDict; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -dynamicFvMeshLib "libtopoChangerFvMesh.so"; - -dynamicFvMesh mixerFvMesh; - -mixerFvMeshCoeffs -{ - coordinateSystem - { - type cylindrical; - origin ( 0 0 0 ); - axis ( 0 0 1 ); - direction ( 1 0 0 ); - } - - rpm 10; - - slider - { - inside insideSlider; - outside outsideSlider; - } -} - - -// ************************************************************************* // diff --git a/tutorials/incompressible/MRFSimpleFoam/mixerVessel2D/constant/dynamicMeshDict b/tutorials/incompressible/MRFSimpleFoam/mixerVessel2D/constant/dynamicMeshDict deleted file mode 100644 index 36f5458ddf..0000000000 --- a/tutorials/incompressible/MRFSimpleFoam/mixerVessel2D/constant/dynamicMeshDict +++ /dev/null @@ -1,42 +0,0 @@ -/*--------------------------------*- C++ -*----------------------------------*\ -| ========= | | -| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.com | -| \\/ M anipulation | | -\*---------------------------------------------------------------------------*/ -FoamFile -{ - version 2.0; - format ascii; - class dictionary; - location "constant"; - object dynamicMeshDict; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -dynamicFvMeshLib "libtopoChangerFvMesh.so"; - -dynamicFvMesh mixerFvMesh; - -mixerFvMeshCoeffs -{ - coordinateSystem - { - type cylindrical; - origin ( 0 0 0 ); - axis ( 0 0 1 ); - direction ( 1 0 0 ); - } - - rpm 10; - - slider - { - inside insideSlider; - outside outsideSlider; - } -} - - -// ************************************************************************* // From 27dc56ed0d3d7aa6f12903c5103aade6d8d64855 Mon Sep 17 00:00:00 2001 From: graham Date: Wed, 22 Sep 2010 12:27:42 +0100 Subject: [PATCH 3/9] BUG: fixedValue pdf returning +-VGREAT for min/maxValue() -should be value_ surely? --- src/thermophysicalModels/pdfs/fixedValue/fixedValue.C | 4 ++-- src/thermophysicalModels/pdfs/pdf/pdf.H | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/thermophysicalModels/pdfs/fixedValue/fixedValue.C b/src/thermophysicalModels/pdfs/fixedValue/fixedValue.C index 98634af06f..b8afd67303 100644 --- a/src/thermophysicalModels/pdfs/fixedValue/fixedValue.C +++ b/src/thermophysicalModels/pdfs/fixedValue/fixedValue.C @@ -62,13 +62,13 @@ Foam::scalar Foam::pdfs::fixedValue::fixedValue::sample() const Foam::scalar Foam::pdfs::fixedValue::fixedValue::minValue() const { - return -VGREAT; + return value_; } Foam::scalar Foam::pdfs::fixedValue::fixedValue::maxValue() const { - return VGREAT; + return value_; } diff --git a/src/thermophysicalModels/pdfs/pdf/pdf.H b/src/thermophysicalModels/pdfs/pdf/pdf.H index b0c5ea671d..d6dbf8fb90 100644 --- a/src/thermophysicalModels/pdfs/pdf/pdf.H +++ b/src/thermophysicalModels/pdfs/pdf/pdf.H @@ -77,7 +77,7 @@ protected: //- Coefficients dictionary const dictionary pdfDict_; - //- Reference to the randmo number generator + //- Reference to the random number generator Random& rndGen_; From bd91a2d5c366281a2b789b0c76c288382639ae8d Mon Sep 17 00:00:00 2001 From: graham Date: Wed, 22 Sep 2010 16:20:54 +0100 Subject: [PATCH 4/9] ENH: Adding bools to turn off initCellFacePt() for reconstruction, post-processing etc. --- .../decomposePar/lagrangianFieldDecomposer.C | 3 ++- src/lagrangian/basic/Particle/Particle.C | 8 ++++++-- src/lagrangian/basic/Particle/Particle.H | 3 ++- src/lagrangian/basic/passiveParticle/passiveParticle.H | 8 +++++--- .../reconstruct/reconstructLagrangianPositions.C | 3 ++- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/applications/utilities/parallelProcessing/decomposePar/lagrangianFieldDecomposer.C b/applications/utilities/parallelProcessing/decomposePar/lagrangianFieldDecomposer.C index efe0c37ff6..a6b0c9594d 100644 --- a/applications/utilities/parallelProcessing/decomposePar/lagrangianFieldDecomposer.C +++ b/applications/utilities/parallelProcessing/decomposePar/lagrangianFieldDecomposer.C @@ -102,7 +102,8 @@ Foam::lagrangianFieldDecomposer::lagrangianFieldDecomposer ( positions_, ppi.position(), - procCelli + procCelli, + false ) ); } diff --git a/src/lagrangian/basic/Particle/Particle.C b/src/lagrangian/basic/Particle/Particle.C index 9ad51cdeaf..704c9ebc1a 100644 --- a/src/lagrangian/basic/Particle/Particle.C +++ b/src/lagrangian/basic/Particle/Particle.C @@ -162,7 +162,8 @@ Foam::Particle::Particle ( const Cloud& cloud, const vector& position, - const label cellI + const label cellI, + bool doCellFacePt ) : cloud_(cloud), @@ -175,7 +176,10 @@ Foam::Particle::Particle origProc_(Pstream::myProcNo()), origId_(cloud_.getNewParticleID()) { - initCellFacePt(); + if (doCellFacePt) + { + initCellFacePt(); + } } diff --git a/src/lagrangian/basic/Particle/Particle.H b/src/lagrangian/basic/Particle/Particle.H index 8dbdebd4e1..b28221a205 100644 --- a/src/lagrangian/basic/Particle/Particle.H +++ b/src/lagrangian/basic/Particle/Particle.H @@ -346,7 +346,8 @@ public: ( const Cloud&, const vector& position, - const label cellI + const label cellI, + bool doCellFacePt = true ); //- Construct from Istream diff --git a/src/lagrangian/basic/passiveParticle/passiveParticle.H b/src/lagrangian/basic/passiveParticle/passiveParticle.H index 49de4eba66..50697e3a69 100644 --- a/src/lagrangian/basic/passiveParticle/passiveParticle.H +++ b/src/lagrangian/basic/passiveParticle/passiveParticle.H @@ -68,15 +68,17 @@ public: Particle(c, position, cellI, tetFaceI, tetPtI) {} - //- Construct from components, with searching for tetFace and tetPt + //- Construct from components, with searching for tetFace and + // tetPt unless disabled by doCellFacePt = false. passiveParticle ( const Cloud& c, const vector& position, - const label cellI + const label cellI, + bool doCellFacePt = true ) : - Particle(c, position, cellI) + Particle(c, position, cellI, doCellFacePt) {} //- Construct from Istream diff --git a/src/parallel/reconstruct/reconstruct/reconstructLagrangianPositions.C b/src/parallel/reconstruct/reconstruct/reconstructLagrangianPositions.C index bab5aa0df0..2e001de610 100644 --- a/src/parallel/reconstruct/reconstruct/reconstructLagrangianPositions.C +++ b/src/parallel/reconstruct/reconstruct/reconstructLagrangianPositions.C @@ -69,7 +69,8 @@ void Foam::reconstructLagrangianPositions ( lagrangianPositions, ppi.position(), - cellMap[ppi.cell()] + cellMap[ppi.cell()], + false ) ); } From 3f637b2fcfa7d70f89fab1e285df80545bd765c2 Mon Sep 17 00:00:00 2001 From: graham Date: Wed, 22 Sep 2010 16:28:47 +0100 Subject: [PATCH 5/9] ENH: InflationInjection. Needs dTarget data member in KinematicParcel. Some functions in InjectionModel no longer const. --- .../coalCombustion/coalParcel/coalParcel.C | 2 + .../coalCombustion/coalParcel/coalParcel.H | 1 + .../Templates/KinematicCloud/KinematicCloud.H | 7 +- .../CollisionRecordList/CollisionRecordList.C | 41 ++ .../CollisionRecordList/CollisionRecordList.H | 8 + .../KinematicParcel/KinematicParcel.C | 1 + .../KinematicParcel/KinematicParcel.H | 16 +- .../KinematicParcel/KinematicParcelI.H | 23 +- .../KinematicParcel/KinematicParcelIO.C | 13 + .../ReactingMultiphaseParcel.H | 1 + .../ReactingMultiphaseParcelI.H | 2 + .../Templates/ReactingParcel/ReactingParcel.H | 1 + .../ReactingParcel/ReactingParcelI.H | 2 + .../Templates/ThermoParcel/ThermoParcel.H | 1 + .../Templates/ThermoParcel/ThermoParcelI.H | 2 + .../basicKinematicParcel.C | 2 + .../basicKinematicParcel.H | 1 + .../basicReactingMultiphaseParcel.C | 2 + .../basicReactingMultiphaseParcel.H | 1 + .../basicReactingParcel/basicReactingParcel.C | 2 + .../basicReactingParcel/basicReactingParcel.H | 1 + .../basicThermoParcel/basicThermoParcel.C | 2 + .../basicThermoParcel/basicThermoParcel.H | 1 + .../include/makeParcelInjectionModels.H | 8 + .../ConeInjection/ConeInjection.C | 4 +- .../ConeInjection/ConeInjection.H | 4 +- .../ConeInjectionMP/ConeInjectionMP.C | 4 +- .../ConeInjectionMP/ConeInjectionMP.H | 4 +- .../FieldActivatedInjection.C | 4 +- .../FieldActivatedInjection.H | 4 +- .../InflationInjection/InflationInjection.C | 466 ++++++++++++++++++ .../InflationInjection/InflationInjection.H | 200 ++++++++ .../InjectionModel/InjectionModel.C | 12 +- .../InjectionModel/InjectionModel.H | 4 +- .../KinematicLookupTableInjection.C | 4 +- .../KinematicLookupTableInjection.H | 4 +- .../ManualInjection/ManualInjection.C | 4 +- .../ManualInjection/ManualInjection.H | 4 +- .../InjectionModel/NoInjection/NoInjection.C | 4 +- .../InjectionModel/NoInjection/NoInjection.H | 4 +- .../PatchInjection/PatchInjection.C | 4 +- .../PatchInjection/PatchInjection.H | 4 +- .../ReactingLookupTableInjection.C | 4 +- .../ReactingLookupTableInjection.H | 4 +- .../ReactingMultiphaseLookupTableInjection.C | 4 +- .../ReactingMultiphaseLookupTableInjection.H | 4 +- .../ThermoLookupTableInjection.C | 4 +- .../ThermoLookupTableInjection.H | 4 +- 48 files changed, 848 insertions(+), 55 deletions(-) create mode 100644 src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InflationInjection/InflationInjection.C create mode 100644 src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InflationInjection/InflationInjection.H diff --git a/src/lagrangian/coalCombustion/coalParcel/coalParcel.C b/src/lagrangian/coalCombustion/coalParcel/coalParcel.C index a6500c8388..3445afe14e 100644 --- a/src/lagrangian/coalCombustion/coalParcel/coalParcel.C +++ b/src/lagrangian/coalCombustion/coalParcel/coalParcel.C @@ -57,6 +57,7 @@ Foam::coalParcel::coalParcel const label typeId, const scalar nParticle0, const scalar d0, + const scalar dTarget0, const vector& U0, const vector& f0, const vector& pi0, @@ -78,6 +79,7 @@ Foam::coalParcel::coalParcel typeId, nParticle0, d0, + dTarget0, U0, f0, pi0, diff --git a/src/lagrangian/coalCombustion/coalParcel/coalParcel.H b/src/lagrangian/coalCombustion/coalParcel/coalParcel.H index 81f6447320..6195de8439 100644 --- a/src/lagrangian/coalCombustion/coalParcel/coalParcel.H +++ b/src/lagrangian/coalCombustion/coalParcel/coalParcel.H @@ -79,6 +79,7 @@ public: const label typeId, const scalar nParticle0, const scalar d0, + const scalar dTarget0, const vector& U0, const vector& f0, const vector& pi0, diff --git a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.H b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.H index ed5b5ae539..1d0a903810 100644 --- a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.H +++ b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.H @@ -297,9 +297,10 @@ public: //- Return refernce to the random object inline Random& rndGen(); - //- Return the cell occupancy information for each parcel, - // non-const access, the caller is responsible for updating - // it if particles are removed or created. + //- Return the cell occupancy information for each + // parcel, non-const access, the caller is + // responsible for updating it for its own purposes + // if particles are removed or created. inline List >& cellOccupancy(); diff --git a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/CollisionRecordList/CollisionRecordList.C b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/CollisionRecordList/CollisionRecordList.C index aa2db0b4de..4e80d16d6f 100644 --- a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/CollisionRecordList/CollisionRecordList.C +++ b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/CollisionRecordList/CollisionRecordList.C @@ -300,6 +300,27 @@ Foam::CollisionRecordList::matchPairRecord } +template +bool Foam::CollisionRecordList::checkPairRecord +( + label origProcOfOther, + label origIdOfOther +) +{ + forAll(pairRecords_, i) + { + PairCollisionRecord& pCR = pairRecords_[i]; + + if (pCR.match(origProcOfOther, origIdOfOther)) + { + return true; + } + } + + return false; +} + + template Foam::WallCollisionRecord& Foam::CollisionRecordList::matchWallRecord @@ -333,6 +354,26 @@ Foam::CollisionRecordList::matchWallRecord } +template +bool Foam::CollisionRecordList::checkWallRecord +( + const vector& pRel, + scalar radius +) +{ + forAll(wallRecords_, i) + { + WallCollisionRecord& wCR = wallRecords_[i]; + + if (wCR.match(pRel, radius)) + { + return true; + } + } + + return false; +} + template void Foam::CollisionRecordList::update() diff --git a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/CollisionRecordList/CollisionRecordList.H b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/CollisionRecordList/CollisionRecordList.H index 51aa29849f..a933b35ca0 100644 --- a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/CollisionRecordList/CollisionRecordList.H +++ b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/CollisionRecordList/CollisionRecordList.H @@ -168,6 +168,10 @@ public: label origIdOfOther ); + //- Enquire if the specified record exists without modifying + // its accessed status + bool checkPairRecord(label origProcOfOther, label origIdOfOther); + //- Enquires if the position of wall impact relative to the // particle centre is present in the records. If so, return // access to the WallCollisionRecord (hence the data) and @@ -179,6 +183,10 @@ public: scalar radius ); + //- Enquire if the specified record exists without modifying + // its accessed status + bool checkWallRecord(const vector& pRel, scalar radius); + //- Update the collision records, deleting any records not // marked as having been accessed, then mark all records as // not accessed ready for the next evaluation diff --git a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.C b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.C index 26acc7d9e6..f6ba6aeed3 100644 --- a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.C +++ b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.C @@ -225,6 +225,7 @@ Foam::KinematicParcel::KinematicParcel typeId_(p.typeId_), nParticle_(p.nParticle_), d_(p.d_), + dTarget_(p.dTarget_), U_(p.U_), f_(p.f_), angularMomentum_(p.angularMomentum_), diff --git a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.H b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.H index b87a1390df..4a76cb0173 100644 --- a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.H +++ b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.H @@ -250,6 +250,9 @@ protected: //- Diameter [m] scalar d_; + //- Target diameter [m] + scalar dTarget_; + //- Velocity of Parcel [m/s] vector U_; @@ -347,6 +350,7 @@ public: const label typeId, const scalar nParticle0, const scalar d0, + const scalar dTarget0, const vector& U0, const vector& f0, const vector& angularMomentum0, @@ -388,6 +392,9 @@ public: //- Return const access to diameter inline scalar d() const; + //- Return const access to target diameter + inline scalar dTarget() const; + //- Return const access to velocity inline const vector& U() const; @@ -427,6 +434,9 @@ public: //- Return access to diameter inline scalar& d(); + //- Return access to target diameter + inline scalar& dTarget(); + //- Return access to velocity inline vector& U(); @@ -478,19 +488,19 @@ public: inline scalar volume() const; //- Particle volume for a given diameter - inline scalar volume(const scalar d) const; + inline static scalar volume(const scalar d); //- Particle projected area inline scalar areaP() const; //- Projected area for given diameter - inline scalar areaP(const scalar d) const; + inline static scalar areaP(const scalar d); //- Particle surface area inline scalar areaS() const; //- Surface area for given diameter - inline scalar areaS(const scalar d) const; + inline static scalar areaS(const scalar d); //- Reynolds number inline scalar Re diff --git a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcelI.H b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcelI.H index a6f41647c7..e39a9f43af 100644 --- a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcelI.H +++ b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcelI.H @@ -91,6 +91,7 @@ inline Foam::KinematicParcel::KinematicParcel typeId_(owner.parcelTypeId()), nParticle_(0), d_(0.0), + dTarget_(0.0), U_(vector::zero), f_(vector::zero), angularMomentum_(vector::zero), @@ -116,6 +117,7 @@ inline Foam::KinematicParcel::KinematicParcel const label typeId, const scalar nParticle0, const scalar d0, + const scalar dTarget0, const vector& U0, const vector& f0, const vector& angularMomentum0, @@ -128,6 +130,7 @@ inline Foam::KinematicParcel::KinematicParcel typeId_(typeId), nParticle_(nParticle0), d_(d0), + dTarget_(dTarget0), U_(U0), f_(f0), angularMomentum_(angularMomentum0), @@ -292,6 +295,13 @@ inline Foam::scalar Foam::KinematicParcel::d() const } +template +inline Foam::scalar Foam::KinematicParcel::dTarget() const +{ + return dTarget_; +} + + template inline const Foam::vector& Foam::KinematicParcel::U() const { @@ -380,6 +390,13 @@ inline Foam::scalar& Foam::KinematicParcel::d() } +template +inline Foam::scalar& Foam::KinematicParcel::dTarget() +{ + return dTarget_; +} + + template inline Foam::vector& Foam::KinematicParcel::U() { @@ -504,7 +521,7 @@ inline Foam::scalar Foam::KinematicParcel::volume() const template inline Foam::scalar -Foam::KinematicParcel::volume(const scalar d) const +Foam::KinematicParcel::volume(const scalar d) { return pi/6.0*pow3(d); } @@ -519,7 +536,7 @@ inline Foam::scalar Foam::KinematicParcel::areaP() const template inline Foam::scalar -Foam::KinematicParcel::areaP(const scalar d) const +Foam::KinematicParcel::areaP(const scalar d) { return 0.25*areaS(d); } @@ -534,7 +551,7 @@ inline Foam::scalar Foam::KinematicParcel::areaS() const template inline Foam::scalar -Foam::KinematicParcel::areaS(const scalar d) const +Foam::KinematicParcel::areaS(const scalar d) { return pi*d*d; } diff --git a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcelIO.C b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcelIO.C index 7660070383..8f1645db60 100644 --- a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcelIO.C +++ b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcelIO.C @@ -37,6 +37,7 @@ Foam::string Foam::KinematicParcel::propHeader = + " typeId" + " nParticle" + " d" + + " dTarget " + " (Ux Uy Uz)" + " (fx fy fz)" + " (angularMomentumx angularMomentumy angularMomentumz)" @@ -68,6 +69,7 @@ Foam::KinematicParcel::KinematicParcel typeId_(0), nParticle_(0.0), d_(0.0), + dTarget_(0.0), U_(vector::zero), f_(vector::zero), angularMomentum_(vector::zero), @@ -88,6 +90,7 @@ Foam::KinematicParcel::KinematicParcel typeId_ = readLabel(is); nParticle_ = readScalar(is); d_ = readScalar(is); + dTarget_ = readScalar(is); is >> U_; is >> f_; is >> angularMomentum_; @@ -106,6 +109,7 @@ Foam::KinematicParcel::KinematicParcel + sizeof(typeId_) + sizeof(nParticle_) + sizeof(d_) + + sizeof(dTarget_) + sizeof(U_) + sizeof(f_) + sizeof(angularMomentum_) @@ -150,6 +154,9 @@ void Foam::KinematicParcel::readFields(Cloud& c) IOField d(c.fieldIOobject("d", IOobject::MUST_READ)); c.checkFieldIOobject(c, d); + IOField dTarget(c.fieldIOobject("dTarget", IOobject::MUST_READ)); + c.checkFieldIOobject(c, dTarget); + IOField U(c.fieldIOobject("U", IOobject::MUST_READ)); c.checkFieldIOobject(c, U); @@ -234,6 +241,7 @@ void Foam::KinematicParcel::readFields(Cloud& c) p.typeId_ = typeId[i]; p.nParticle_ = nParticle[i]; p.d_ = d[i]; + p.dTarget_ = dTarget[i]; p.U_ = U[i]; p.f_ = f[i]; p.angularMomentum_ = angularMomentum[i]; @@ -271,6 +279,7 @@ void Foam::KinematicParcel::writeFields(const Cloud& c) np ); IOField d(c.fieldIOobject("d", IOobject::NO_READ), np); + IOField dTarget(c.fieldIOobject("dTarget", IOobject::NO_READ), np); IOField U(c.fieldIOobject("U", IOobject::NO_READ), np); IOField f(c.fieldIOobject("f", IOobject::NO_READ), np); IOField angularMomentum @@ -333,6 +342,7 @@ void Foam::KinematicParcel::writeFields(const Cloud& c) typeId[i] = p.typeId(); nParticle[i] = p.nParticle(); d[i] = p.d(); + dTarget[i] = p.dTarget(); U[i] = p.U(); f[i] = p.f(); angularMomentum[i] = p.angularMomentum(); @@ -357,6 +367,7 @@ void Foam::KinematicParcel::writeFields(const Cloud& c) typeId.write(); nParticle.write(); d.write(); + dTarget.write(); U.write(); f.write(); angularMomentum.write(); @@ -390,6 +401,7 @@ Foam::Ostream& Foam::operator<< << token::SPACE << p.typeId() << token::SPACE << p.nParticle() << token::SPACE << p.d() + << token::SPACE << p.dTarget() << token::SPACE << p.U() << token::SPACE << p.f() << token::SPACE << p.angularMomentum() @@ -409,6 +421,7 @@ Foam::Ostream& Foam::operator<< + sizeof(p.typeId()) + sizeof(p.nParticle()) + sizeof(p.d()) + + sizeof(p.dTarget()) + sizeof(p.U()) + sizeof(p.f()) + sizeof(p.angularMomentum()) diff --git a/src/lagrangian/intermediate/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcel.H b/src/lagrangian/intermediate/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcel.H index 3fb4ef2421..ed0b11e88e 100644 --- a/src/lagrangian/intermediate/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcel.H +++ b/src/lagrangian/intermediate/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcel.H @@ -306,6 +306,7 @@ public: const label typeId, const scalar nParticle0, const scalar d0, + const scalar dTarget0, const vector& U0, const vector& f0, const vector& angularMomentum0, diff --git a/src/lagrangian/intermediate/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcelI.H b/src/lagrangian/intermediate/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcelI.H index 5899d2a666..960a298ad7 100644 --- a/src/lagrangian/intermediate/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcelI.H +++ b/src/lagrangian/intermediate/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcelI.H @@ -113,6 +113,7 @@ inline Foam::ReactingMultiphaseParcel::ReactingMultiphaseParcel const label typeId, const scalar nParticle0, const scalar d0, + const scalar dTarget0, const vector& U0, const vector& f0, const vector& angularMomentum0, @@ -134,6 +135,7 @@ inline Foam::ReactingMultiphaseParcel::ReactingMultiphaseParcel typeId, nParticle0, d0, + dTarget0, U0, f0, angularMomentum0, diff --git a/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcel.H b/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcel.H index 415967c7c5..6ae15d5098 100644 --- a/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcel.H +++ b/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcel.H @@ -255,6 +255,7 @@ public: const label typeId, const scalar nParticle0, const scalar d0, + const scalar dTarget0, const vector& U0, const vector& f0, const vector& angularMomentum0, diff --git a/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcelI.H b/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcelI.H index 39beae61cf..60c1556b8f 100644 --- a/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcelI.H +++ b/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcelI.H @@ -98,6 +98,7 @@ inline Foam::ReactingParcel::ReactingParcel const label typeId, const scalar nParticle0, const scalar d0, + const scalar dTarget0, const vector& U0, const vector& f0, const vector& angularMomentum0, @@ -116,6 +117,7 @@ inline Foam::ReactingParcel::ReactingParcel typeId, nParticle0, d0, + dTarget0, U0, f0, angularMomentum0, diff --git a/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcel.H b/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcel.H index 5632d76592..dc97dcba6c 100644 --- a/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcel.H +++ b/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcel.H @@ -268,6 +268,7 @@ public: const label typeId, const scalar nParticle0, const scalar d0, + const scalar dTarget0, const vector& U0, const vector& f0, const vector& angularMomentum0, diff --git a/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcelI.H b/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcelI.H index b046f142dd..b728ce65cb 100644 --- a/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcelI.H +++ b/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcelI.H @@ -99,6 +99,7 @@ inline Foam::ThermoParcel::ThermoParcel const label typeId, const scalar nParticle0, const scalar d0, + const scalar dTarget0, const vector& U0, const vector& f0, const vector& angularMomentum0, @@ -116,6 +117,7 @@ inline Foam::ThermoParcel::ThermoParcel typeId, nParticle0, d0, + dTarget0, U0, f0, angularMomentum0, diff --git a/src/lagrangian/intermediate/parcels/derived/basicKinematicParcel/basicKinematicParcel.C b/src/lagrangian/intermediate/parcels/derived/basicKinematicParcel/basicKinematicParcel.C index 4ec2941bf7..adc4fc409b 100644 --- a/src/lagrangian/intermediate/parcels/derived/basicKinematicParcel/basicKinematicParcel.C +++ b/src/lagrangian/intermediate/parcels/derived/basicKinematicParcel/basicKinematicParcel.C @@ -67,6 +67,7 @@ Foam::basicKinematicParcel::basicKinematicParcel const label typeId, const scalar nParticle0, const scalar d0, + const scalar dTarget0, const vector& U0, const vector& f0, const vector& angularMomentum0, @@ -84,6 +85,7 @@ Foam::basicKinematicParcel::basicKinematicParcel typeId, nParticle0, d0, + dTarget0, U0, f0, angularMomentum0, diff --git a/src/lagrangian/intermediate/parcels/derived/basicKinematicParcel/basicKinematicParcel.H b/src/lagrangian/intermediate/parcels/derived/basicKinematicParcel/basicKinematicParcel.H index 56d9cad296..5fdb8777a5 100644 --- a/src/lagrangian/intermediate/parcels/derived/basicKinematicParcel/basicKinematicParcel.H +++ b/src/lagrangian/intermediate/parcels/derived/basicKinematicParcel/basicKinematicParcel.H @@ -81,6 +81,7 @@ public: const label typeId, const scalar nParticle0, const scalar d0, + const scalar dTarget0, const vector& U0, const vector& f0, const vector& angularMomentum0, diff --git a/src/lagrangian/intermediate/parcels/derived/basicReactingMultiphaseParcel/basicReactingMultiphaseParcel.C b/src/lagrangian/intermediate/parcels/derived/basicReactingMultiphaseParcel/basicReactingMultiphaseParcel.C index 49e4e06ef4..748122567e 100644 --- a/src/lagrangian/intermediate/parcels/derived/basicReactingMultiphaseParcel/basicReactingMultiphaseParcel.C +++ b/src/lagrangian/intermediate/parcels/derived/basicReactingMultiphaseParcel/basicReactingMultiphaseParcel.C @@ -57,6 +57,7 @@ Foam::basicReactingMultiphaseParcel::basicReactingMultiphaseParcel const label typeId, const scalar nParticle0, const scalar d0, + const scalar dTarget0, const vector& U0, const vector& f0, const vector& angularMomentum0, @@ -79,6 +80,7 @@ Foam::basicReactingMultiphaseParcel::basicReactingMultiphaseParcel typeId, nParticle0, d0, + dTarget0, U0, f0, angularMomentum0, diff --git a/src/lagrangian/intermediate/parcels/derived/basicReactingMultiphaseParcel/basicReactingMultiphaseParcel.H b/src/lagrangian/intermediate/parcels/derived/basicReactingMultiphaseParcel/basicReactingMultiphaseParcel.H index 1c9d2db2d7..2fa913c229 100644 --- a/src/lagrangian/intermediate/parcels/derived/basicReactingMultiphaseParcel/basicReactingMultiphaseParcel.H +++ b/src/lagrangian/intermediate/parcels/derived/basicReactingMultiphaseParcel/basicReactingMultiphaseParcel.H @@ -82,6 +82,7 @@ public: const label typeId, const scalar nParticle0, const scalar d0, + const scalar dTarget0, const vector& U0, const vector& f0, const vector& angularMomentum0, diff --git a/src/lagrangian/intermediate/parcels/derived/basicReactingParcel/basicReactingParcel.C b/src/lagrangian/intermediate/parcels/derived/basicReactingParcel/basicReactingParcel.C index f60f30b552..25b0c4c26a 100644 --- a/src/lagrangian/intermediate/parcels/derived/basicReactingParcel/basicReactingParcel.C +++ b/src/lagrangian/intermediate/parcels/derived/basicReactingParcel/basicReactingParcel.C @@ -57,6 +57,7 @@ Foam::basicReactingParcel::basicReactingParcel const label typeId, const scalar nParticle0, const scalar d0, + const scalar dTarget0, const vector& U0, const vector& f0, const vector& angularMomentum0, @@ -75,6 +76,7 @@ Foam::basicReactingParcel::basicReactingParcel typeId, nParticle0, d0, + dTarget0, U0, f0, angularMomentum0, diff --git a/src/lagrangian/intermediate/parcels/derived/basicReactingParcel/basicReactingParcel.H b/src/lagrangian/intermediate/parcels/derived/basicReactingParcel/basicReactingParcel.H index 4329c61d9c..49e26aadb7 100644 --- a/src/lagrangian/intermediate/parcels/derived/basicReactingParcel/basicReactingParcel.H +++ b/src/lagrangian/intermediate/parcels/derived/basicReactingParcel/basicReactingParcel.H @@ -80,6 +80,7 @@ public: const label typeId, const scalar nParticle0, const scalar d0, + const scalar dTarget0, const vector& U0, const vector& f0, const vector& angularMomentum0, diff --git a/src/lagrangian/intermediate/parcels/derived/basicThermoParcel/basicThermoParcel.C b/src/lagrangian/intermediate/parcels/derived/basicThermoParcel/basicThermoParcel.C index b77bf79b93..5b5fddb1bb 100644 --- a/src/lagrangian/intermediate/parcels/derived/basicThermoParcel/basicThermoParcel.C +++ b/src/lagrangian/intermediate/parcels/derived/basicThermoParcel/basicThermoParcel.C @@ -60,6 +60,7 @@ Foam::basicThermoParcel::basicThermoParcel const label typeId, const scalar nParticle0, const scalar d0, + const scalar dTarget0, const vector U0, const vector& f0, const vector& angularMomentum0, @@ -77,6 +78,7 @@ Foam::basicThermoParcel::basicThermoParcel typeId, nParticle0, d0, + dTarget0, U0, f0, angularMomentum0, diff --git a/src/lagrangian/intermediate/parcels/derived/basicThermoParcel/basicThermoParcel.H b/src/lagrangian/intermediate/parcels/derived/basicThermoParcel/basicThermoParcel.H index 71614c7d9d..8f3720b365 100644 --- a/src/lagrangian/intermediate/parcels/derived/basicThermoParcel/basicThermoParcel.H +++ b/src/lagrangian/intermediate/parcels/derived/basicThermoParcel/basicThermoParcel.H @@ -80,6 +80,7 @@ public: const label typeId, const scalar nParticle0, const scalar d0, + const scalar dTarget0, const vector U0, const vector& f0, const vector& angularMomentum0, diff --git a/src/lagrangian/intermediate/parcels/include/makeParcelInjectionModels.H b/src/lagrangian/intermediate/parcels/include/makeParcelInjectionModels.H index ea8dcd57f4..b673d3d84c 100644 --- a/src/lagrangian/intermediate/parcels/include/makeParcelInjectionModels.H +++ b/src/lagrangian/intermediate/parcels/include/makeParcelInjectionModels.H @@ -33,11 +33,13 @@ License #include "ConeInjection.H" #include "ConeInjectionMP.H" #include "FieldActivatedInjection.H" +#include "InflationInjection.H" #include "KinematicLookupTableInjection.H" #include "ManualInjection.H" #include "NoInjection.H" #include "PatchInjection.H" + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #define makeParcelInjectionModels(ParcelType) \ @@ -63,6 +65,12 @@ License ParcelType \ ); \ makeInjectionModelType \ + ( \ + InflationInjection, \ + KinematicCloud, \ + ParcelType \ + ); \ + makeInjectionModelType \ ( \ KinematicLookupTableInjection, \ KinematicCloud, \ diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeInjection/ConeInjection.C b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeInjection/ConeInjection.C index 3047f909af..438b32b225 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeInjection/ConeInjection.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeInjection/ConeInjection.C @@ -36,7 +36,7 @@ Foam::label Foam::ConeInjection::parcelsToInject ( const scalar time0, const scalar time1 -) const +) { if ((time0 >= 0.0) && (time0 < duration_)) { @@ -54,7 +54,7 @@ Foam::scalar Foam::ConeInjection::volumeToInject ( const scalar time0, const scalar time1 -) const +) { if ((time0 >= 0.0) && (time0 < duration_)) { diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeInjection/ConeInjection.H b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeInjection/ConeInjection.H index 58309fa865..a9c289d6d4 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeInjection/ConeInjection.H +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeInjection/ConeInjection.H @@ -123,14 +123,14 @@ protected: ( const scalar time0, const scalar time1 - ) const; + ); //- Number of parcels to introduce over the time step relative to SOI scalar volumeToInject ( const scalar time0, const scalar time1 - ) const; + ); public: diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeInjectionMP/ConeInjectionMP.C b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeInjectionMP/ConeInjectionMP.C index 05cfb680a4..6639c43587 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeInjectionMP/ConeInjectionMP.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeInjectionMP/ConeInjectionMP.C @@ -36,7 +36,7 @@ Foam::label Foam::ConeInjectionMP::parcelsToInject ( const scalar time0, const scalar time1 -) const +) { if ((time0 >= 0.0) && (time0 < duration_)) { @@ -63,7 +63,7 @@ Foam::scalar Foam::ConeInjectionMP::volumeToInject ( const scalar time0, const scalar time1 -) const +) { if ((time0 >= 0.0) && (time0 < duration_)) { diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeInjectionMP/ConeInjectionMP.H b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeInjectionMP/ConeInjectionMP.H index 1033defe8b..2b0d4e8c31 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeInjectionMP/ConeInjectionMP.H +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeInjectionMP/ConeInjectionMP.H @@ -133,14 +133,14 @@ protected: ( const scalar time0, const scalar time1 - ) const; + ); //- Number of parcels to introduce over the time step scalar volumeToInject ( const scalar time0, const scalar time1 - ) const; + ); public: diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/FieldActivatedInjection/FieldActivatedInjection.C b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/FieldActivatedInjection/FieldActivatedInjection.C index a0dae5cb34..44cebec903 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/FieldActivatedInjection/FieldActivatedInjection.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/FieldActivatedInjection/FieldActivatedInjection.C @@ -36,7 +36,7 @@ Foam::label Foam::FieldActivatedInjection::parcelsToInject ( const scalar time0, const scalar time1 -) const +) { if (sum(nParcelsInjected_) < nParcelsPerInjector_*positions_.size()) { @@ -54,7 +54,7 @@ Foam::scalar Foam::FieldActivatedInjection::volumeToInject ( const scalar time0, const scalar time1 -) const +) { if (sum(nParcelsInjected_) < nParcelsPerInjector_*positions_.size()) { diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/FieldActivatedInjection/FieldActivatedInjection.H b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/FieldActivatedInjection/FieldActivatedInjection.H index 282e876cc6..9acf379154 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/FieldActivatedInjection/FieldActivatedInjection.H +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/FieldActivatedInjection/FieldActivatedInjection.H @@ -123,14 +123,14 @@ protected: ( const scalar time0, const scalar time1 - ) const; + ); //- Volume of parcels to introduce over the time step relative to SOI scalar volumeToInject ( const scalar time0, const scalar time1 - ) const; + ); public: diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InflationInjection/InflationInjection.C b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InflationInjection/InflationInjection.C new file mode 100644 index 0000000000..e1d3bd6d3d --- /dev/null +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InflationInjection/InflationInjection.C @@ -0,0 +1,466 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "InflationInjection.H" +#include "mathematicalConstants.H" +#include "PackedBoolList.H" +#include "Switch.H" +#include "cellSet.H" +#include "ListListOps.H" + +using namespace Foam::constant::mathematical; + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +template +Foam::label Foam::InflationInjection::parcelsToInject +( + const scalar time0, + const scalar time1 +) +{ + const polyMesh& mesh = this->owner().mesh(); + + List >& cellOccupancy = + this->owner().cellOccupancy(); + + scalar gR = growthRate_().value(time1); + + scalar dT = time1 - time0; + + // Inflate existing particles + + forAll(inflationCells_, iCI) + { + label cI = inflationCells_[iCI]; + + typename CloudType::parcelType* pPtr = NULL; + + forAll(cellOccupancy[cI], cPI) + { + pPtr = cellOccupancy[cI][cPI]; + + scalar dTarget = pPtr->dTarget(); + + pPtr->d() = min(dTarget, pPtr->d() + gR*dT); + } + } + + // Generate new particles + + newParticles_.clear(); + + Random& rnd = this->owner().rndGen(); + + // Diameter factor, when splitting particles into 4, this is the + // factor that modifies the diameter. + scalar dFact = sqrt(2.0)/(sqrt(3.0) + sqrt(2.0)); + + if ((time0 >= 0.0) && (time0 < duration_)) + { + volumeAccumulator_ += + fraction_*flowRateProfile_().integrate(time0, time1); + } + + labelHashSet cellCentresUsed; + + // Loop escape counter + label maxIterations = max + ( + 1, + (10*volumeAccumulator_) + /CloudType::parcelType::volume(parcelPDF_().minValue()) + ); + + label iterationNo = 0; + + // Info<< "Accumulated volume to inject: " + // << returnReduce(volumeAccumulator_, sumOp()) << endl; + + while (!generationCells_.empty() && volumeAccumulator_ > 0) + { + if (iterationNo > maxIterations) + { + WarningIn + ( + "Foam::label " + "Foam::InflationInjection::parcelsToInject" + "(" + "const scalar time0, " + "const scalar time1" + ")" + ) + << "Maximum particle split iterations (" + << maxIterations << ") exceeded" << endl; + + break; + } + + label cI = + generationCells_[rnd.integer(0, generationCells_.size() - 1)]; + + // Pick a particle at random from the cell - if there are + // none, insert one at the cell centre. Otherwise, split an + // existing particle into four new ones. + + if (cellOccupancy[cI].empty()) + { + if (!cellCentresUsed.found(cI)) + { + scalar dNew = parcelPDF_().sample(); + + newParticles_.append + ( + vectorPairScalarPair + ( + Pair(mesh.cellCentres()[cI], vector::zero), + Pair(dNew, dNew) + ) + ); + + volumeAccumulator_ -= CloudType::parcelType::volume(dNew); + + cellCentresUsed.insert(cI); + } + } + else + { + label cPI = rnd.integer(0, cellOccupancy[cI].size() - 1); + + // This has to be a reference to the pointer so that it + // can be set to NULL when the particle is deleted. + typename CloudType::parcelType*& pPtr = cellOccupancy[cI][cPI]; + + if (pPtr != NULL) + { + scalar pD = pPtr->d(); + + // Select bigger particles by preference + if ((pD/pPtr->dTarget()) < rnd.scalar01()) + { + continue; + } + + const point& pP = pPtr->position(); + const vector& pU = pPtr->U(); + + // Generate a tetrahedron of new positions with the + // four new spheres fitting inside the old one, where + // a is the diameter of the new spheres, and is + // related to the diameter of the enclosing sphere, A, + // by a = sqrt(2)*A/(sqrt(3) + sqrt(2)); + + // Positions around the origin, which is the + // tetrahedron centroid (centre of old sphere). + + // x = a/sqrt(3) + // r = a/(2*sqrt(6)) + // R = sqrt(3)*a/(2*sqrt(2)) + // d = a/(2*sqrt(3)) + + // p0(x, 0, -r) + // p1(-d, a/2, -r) + // p2(-d, -a/2, -r) + // p3(0, 0, R) + + scalar a = pD*dFact; + + scalar x = a/sqrt(3.0); + scalar r = a/(2.0*sqrt(6.0)); + scalar R = sqrt(3.0)*a/(2.0*sqrt(2.0)); + scalar d = a/(2.0*sqrt(3.0)); + + scalar dNew = parcelPDF_().sample(); + scalar volNew = CloudType::parcelType::volume(dNew); + + newParticles_.append + ( + vectorPairScalarPair + ( + Pair(vector(x, 0, -r) + pP, pU), + Pair(a, dNew) + ) + ); + volumeAccumulator_ -= volNew; + + dNew = parcelPDF_().sample(); + newParticles_.append + ( + vectorPairScalarPair + ( + Pair(vector(-d, a/2, -r) + pP, pU), + Pair(a, dNew) + ) + ); + volumeAccumulator_ -= volNew; + + dNew = parcelPDF_().sample(); + newParticles_.append + ( + vectorPairScalarPair + ( + Pair(vector(-d, -a/2, -r) + pP, pU), + Pair(a, dNew) + ) + ); + volumeAccumulator_ -= volNew; + + dNew = parcelPDF_().sample(); + newParticles_.append + ( + vectorPairScalarPair + ( + Pair(vector(0, 0, R) + pP, pU), + Pair(a, dNew) + ) + ); + volumeAccumulator_ -= volNew; + + // Account for the lost volume of the particle which + // is to be deleted + volumeAccumulator_ += CloudType::parcelType::volume + ( + pPtr->dTarget() + ); + + this->owner().deleteParticle(*pPtr); + + pPtr = NULL; + } + } + + iterationNo++; + } + + if (Pstream::parRun()) + { + List > gatheredNewParticles + ( + Pstream::nProcs() + ); + + gatheredNewParticles[Pstream::myProcNo()] = newParticles_; + + // Gather data onto master + Pstream::gatherList(gatheredNewParticles); + + // Combine + List combinedNewParticles + ( + ListListOps::combine > + ( + gatheredNewParticles, + accessOp >() + ) + ); + + if (Pstream::master()) + { + newParticles_ = combinedNewParticles; + } + + Pstream::scatter(newParticles_); + } + + return newParticles_.size(); +} + + +template +Foam::scalar Foam::InflationInjection::volumeToInject +( + const scalar time0, + const scalar time1 +) +{ + if ((time0 >= 0.0) && (time0 < duration_)) + { + return fraction_*flowRateProfile_().integrate(time0, time1); + } + else + { + return 0.0; + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +Foam::InflationInjection::InflationInjection +( + const dictionary& dict, + CloudType& owner +) +: + InjectionModel(dict, owner, typeName), + generationSetName_(this->coeffDict().lookup("generationCellSet")), + inflationSetName_(this->coeffDict().lookup("inflationCellSet")), + generationCells_(), + inflationCells_(), + duration_(readScalar(this->coeffDict().lookup("duration"))), + flowRateProfile_ + ( + DataEntry::New + ( + "flowRateProfile", + this->coeffDict() + ) + ), + growthRate_ + ( + DataEntry::New + ( + "growthRate", + this->coeffDict() + ) + ), + newParticles_(), + volumeAccumulator_(0.0), + fraction_(1.0), + parcelPDF_ + ( + pdfs::pdf::New + ( + this->coeffDict().subDict("parcelPDF"), + owner.rndGen() + ) + ) +{ + cellSet generationCells(this->owner().mesh(), generationSetName_); + + generationCells_ = generationCells.toc(); + + cellSet inflationCells(this->owner().mesh(), inflationSetName_); + + // Union of cellSets + inflationCells |= generationCells; + + inflationCells_ = inflationCells.toc(); + + if (Pstream::parRun()) + { + scalar generationVolume = 0.0; + + forAll(generationCells_, gCI) + { + label cI = generationCells_[gCI]; + + generationVolume += this->owner().mesh().cellVolumes()[cI]; + } + + scalar totalGenerationVolume = generationVolume; + + reduce(totalGenerationVolume, sumOp()); + + fraction_ = generationVolume/totalGenerationVolume; + } + + // Set total volume/mass to inject + this->volumeTotal_ = fraction_*flowRateProfile_().integrate(0.0, duration_); + this->massTotal_ *= fraction_; +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +template +Foam::InflationInjection::~InflationInjection() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +bool Foam::InflationInjection::active() const +{ + return true; +} + + +template +Foam::scalar Foam::InflationInjection::timeEnd() const +{ + return this->SOI_ + duration_; +} + + +template +void Foam::InflationInjection::setPositionAndCell +( + const label parcelI, + const label, + const scalar, + vector& position, + label& cellOwner, + label& tetFaceI, + label& tetPtI +) +{ + position = newParticles_[parcelI].first().first(); + + this->findCellAtPosition + ( + cellOwner, + tetFaceI, + tetPtI, + position, + false + ); +} + + +template +void Foam::InflationInjection::setProperties +( + const label parcelI, + const label, + const scalar, + typename CloudType::parcelType& parcel +) +{ + parcel.U() = newParticles_[parcelI].first().second(); + + parcel.d() = newParticles_[parcelI].second().first(); + + parcel.dTarget() = newParticles_[parcelI].second().second(); +} + + +template +bool Foam::InflationInjection::fullyDescribed() const +{ + return false; +} + + +template +bool Foam::InflationInjection::validInjection(const label) +{ + return true; +} + + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InflationInjection/InflationInjection.H b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InflationInjection/InflationInjection.H new file mode 100644 index 0000000000..7072412430 --- /dev/null +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InflationInjection/InflationInjection.H @@ -0,0 +1,200 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::InflationInjection + +Description + Inflation injection - creates new particles by splitting existing + particles within in a set of generation cells, then inflating them + to a target diameter within the generation cells and an additional + set of inflation cells. + +SourceFiles + InflationInjection.C + +\*---------------------------------------------------------------------------*/ + +#ifndef InflationInjection_H +#define InflationInjection_H + +#include "InjectionModel.H" +#include "pdf.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Structure to hold: +// + position = vectorPairScalarPair::first().first() +// + velocity = vectorPairScalarPair::first().second() +// + diameter = vectorPairScalarPair::second().first() +// + target diameter = vectorPairScalarPair::second().second() +// One structure to allow single operation parallel comms +typedef Tuple2, Pair > vectorPairScalarPair; + + +/*---------------------------------------------------------------------------*\ + Class InflationInjection Declaration +\*---------------------------------------------------------------------------*/ + +template +class InflationInjection +: + public InjectionModel +{ + // Private data + + //- Name of cellSet for generating new particles + word generationSetName_; + + //- Name of cellSet for inflating new particles + word inflationSetName_; + + //- Set of cells to generate particles in + labelList generationCells_; + + //- Set of cells to inflate particles in, includes all + // generation cells + labelList inflationCells_; + + //- Injection duration [s] + const scalar duration_; + + //- Flow rate profile relative to SOI [m3/s] + const autoPtr > flowRateProfile_; + + //- Growth rate of particle diameters towards target [m/s] + const autoPtr > growthRate_; + + //- Positions, velocities, diameters and target diameters of + // new particles after splitting + DynamicList newParticles_; + + //- Accumulation variable to carry over volume from one injection + // to the next + scalar volumeAccumulator_; + + //- Fraction of injection controlled by this processor + scalar fraction_; + + //- Parcel size PDF model + const autoPtr parcelPDF_; + + +protected: + + // Protected Member Functions + + //- Number of parcels to introduce over the time step relative to SOI + label parcelsToInject + ( + const scalar time0, + const scalar time1 + ); + + //- Volume of parcels to introduce over the time step relative to SOI + scalar volumeToInject + ( + const scalar time0, + const scalar time1 + ); + + +public: + + //- Runtime type information + TypeName("InflationInjection"); + + + // Constructors + + //- Construct from dictionary + InflationInjection + ( + const dictionary& dict, + CloudType& owner + ); + + + //- Destructor + virtual ~InflationInjection(); + + + // Member Functions + + //- Flag to indicate whether model activates injection model + bool active() const; + + //- Return the end-of-injection time + scalar timeEnd() const; + + + // Injection geometry + + //- Set the injection position and owner cell, tetFace and tetPt + virtual void setPositionAndCell + ( + const label parcelI, + const label nParcels, + const scalar time, + vector& position, + label& cellOwner, + label& tetFaceI, + label& tetPtI + ); + + //- Set the parcel properties + virtual void setProperties + ( + const label parcelI, + const label nParcels, + const scalar time, + typename CloudType::parcelType& parcel + ); + + //- Flag to identify whether model fully describes the parcel + virtual bool fullyDescribed() const; + + //- Return flag to identify whether or not injection of parcelI is + // permitted + virtual bool validInjection(const label parcelI); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "InflationInjection.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InjectionModel/InjectionModel.C b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InjectionModel/InjectionModel.C index 9136baa607..5a386e4397 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InjectionModel/InjectionModel.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InjectionModel/InjectionModel.C @@ -159,6 +159,8 @@ bool Foam::InjectionModel::findCellAtPosition reduce(procI, maxOp