From 0260643c67830c10c2c8ac1301a4938985907d5d Mon Sep 17 00:00:00 2001 From: Andrew Heather <> Date: Tue, 10 Aug 2021 09:29:59 +0100 Subject: [PATCH 1/4] ENH: PatchInjectionModel - added new parcel initial velocity options The parcel initial velocity can now be set using the new `velocityType` entry, taking one of the following options: - fixedValue : (default) same as earlier versions, requires U0 - patchValue : velocity set to seed patch face value - zeroGradient : velocity set to seed patch face adjacent cell value Example usage: model1 { type patchInjection; massTotal 1; SOI 0; parcelBasisType mass; patch cylinder; duration 10; parcelsPerSecond 100; velocityType patchValue; //velocityType zeroGradient; //U0 (-10 0 0); flowRateProfile constant 1; sizeDistribution { type normal; normalDistribution { expectation 1e-3; variance 1e-4; minValue 1e-5; maxValue 2e-3; } } } See the new $FOAM_TUTORIALS/lagrangian/kinematicParcelFoam/spinningDisk tutorial --- .../PatchInjection/PatchInjection.C | 123 +++++++++++++++--- .../PatchInjection/PatchInjection.H | 30 ++++- .../PatchInjection/patchInjectionBase.C | 12 +- .../PatchInjection/patchInjectionBase.H | 6 +- .../kinematicParcelFoam/spinningDisk/0/U | 56 ++++++++ .../kinematicParcelFoam/spinningDisk/0/p | 46 +++++++ .../spinningDisk/constant/g | 21 +++ .../constant/kinematicCloudProperties | 108 +++++++++++++++ .../spinningDisk/constant/transportProperties | 24 ++++ .../constant/turbulenceProperties | 20 +++ .../spinningDisk/system/blockMeshDict | 114 ++++++++++++++++ .../spinningDisk/system/controlDict | 54 ++++++++ .../spinningDisk/system/decomposeParDict | 27 ++++ .../spinningDisk/system/fvSchemes | 54 ++++++++ .../spinningDisk/system/fvSolution | 60 +++++++++ 15 files changed, 728 insertions(+), 27 deletions(-) create mode 100644 tutorials/lagrangian/kinematicParcelFoam/spinningDisk/0/U create mode 100644 tutorials/lagrangian/kinematicParcelFoam/spinningDisk/0/p create mode 100644 tutorials/lagrangian/kinematicParcelFoam/spinningDisk/constant/g create mode 100644 tutorials/lagrangian/kinematicParcelFoam/spinningDisk/constant/kinematicCloudProperties create mode 100644 tutorials/lagrangian/kinematicParcelFoam/spinningDisk/constant/transportProperties create mode 100644 tutorials/lagrangian/kinematicParcelFoam/spinningDisk/constant/turbulenceProperties create mode 100644 tutorials/lagrangian/kinematicParcelFoam/spinningDisk/system/blockMeshDict create mode 100644 tutorials/lagrangian/kinematicParcelFoam/spinningDisk/system/controlDict create mode 100644 tutorials/lagrangian/kinematicParcelFoam/spinningDisk/system/decomposeParDict create mode 100644 tutorials/lagrangian/kinematicParcelFoam/spinningDisk/system/fvSchemes create mode 100644 tutorials/lagrangian/kinematicParcelFoam/spinningDisk/system/fvSolution diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/PatchInjection/PatchInjection.C b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/PatchInjection/PatchInjection.C index 934f1343cf..6c1cc715ad 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/PatchInjection/PatchInjection.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/PatchInjection/PatchInjection.C @@ -29,6 +29,17 @@ License #include "PatchInjection.H" #include "distributionModel.H" +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +template +const Foam::Enum::velocityType> +Foam::PatchInjection::velocityTypeNames_ +({ + { vtFixedValue, "fixedValue" }, + { vtPatchValue, "patchValue" }, + { vtZeroGradient, "zeroGradient" }, +}); + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template @@ -46,7 +57,21 @@ Foam::PatchInjection::PatchInjection ( this->coeffDict().getScalar("parcelsPerSecond") ), - U0_(this->coeffDict().lookup("U0")), + velocityType_ + ( + velocityTypeNames_.getOrDefault + ( + "velocityType", + this->coeffDict(), + vtFixedValue + ) + ), + U0_ + ( + velocityType_ == vtFixedValue + ? this->coeffDict().template get("U0") + : Zero + ), flowRateProfile_ ( Function1::New @@ -63,7 +88,9 @@ Foam::PatchInjection::PatchInjection this->coeffDict().subDict("sizeDistribution"), owner.rndGen() ) - ) + ), + currentParceli_(-1), + currentFacei_(-1) { // Convert from user time to reduce the number of time conversion calls const Time& time = owner.db().time(); @@ -87,16 +114,12 @@ Foam::PatchInjection::PatchInjection patchInjectionBase(im), duration_(im.duration_), parcelsPerSecond_(im.parcelsPerSecond_), + velocityType_(im.velocityType_), U0_(im.U0_), flowRateProfile_(im.flowRateProfile_.clone()), - sizeDistribution_(im.sizeDistribution_.clone()) -{} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -template -Foam::PatchInjection::~PatchInjection() + sizeDistribution_(im.sizeDistribution_.clone()), + currentParceli_(im.currentParceli_), + currentFacei_(im.currentFacei_) {} @@ -167,16 +190,18 @@ Foam::scalar Foam::PatchInjection::volumeToInject template void Foam::PatchInjection::setPositionAndCell ( - const label, - const label, - const scalar, + const label parcelI, + const label nParcels, + const scalar time, vector& position, label& cellOwner, label& tetFacei, label& tetPti ) { - patchInjectionBase::setPositionAndCell + currentParceli_ = parcelI; + + currentFacei_ = patchInjectionBase::setPositionAndCell ( this->owner().mesh(), this->owner().rndGen(), @@ -191,16 +216,74 @@ void Foam::PatchInjection::setPositionAndCell template void Foam::PatchInjection::setProperties ( - const label, - const label, - const scalar, + const label parcelI, + const label nParcels, + const scalar time, typename CloudType::parcelType& parcel ) { - // set particle velocity - parcel.U() = U0_; + // Set particle velocity + switch (velocityType_) + { + case vtFixedValue: + { + parcel.U() = U0_; + break; + } + case vtPatchValue: + { + if (parcelI != currentParceli_) + { + WarningInFunction + << "Synchronisation problem: " + << "attempting to set injected parcel " << parcelI + << " properties using cached parcel " << currentParceli_ + << " properties" << endl; + } - // set particle diameter + const label patchFacei = currentFacei_; + + if (patchFacei < 0) + { + FatalErrorInFunction + << "Unable to set parcel velocity using patch value " + << "due to missing face index: patchFacei=" << patchFacei + << abort(FatalError); + } + + const volVectorField& U = this->owner().U(); + const label patchi = this->patchId_; + parcel.U() = U.boundaryField()[patchi][patchFacei]; + break; + } + case vtZeroGradient: + { + const label celli = parcel.cell(); + + if (celli < 0) + { + FatalErrorInFunction + << "Unable to set parcel velocity using zeroGradient " + << "due to missing cell index" + << abort(FatalError); + } + + const volVectorField& U = this->owner().U(); + parcel.U() = U[celli]; + break; + } + default: + { + FatalErrorInFunction + << "Unhandled velocityType " + << velocityTypeNames_[velocityType_] + << ". Available options are:" + << velocityTypeNames_.sortedToc() + << abort(FatalError); + } + } + + // Set particle diameter parcel.d() = sizeDistribution_->sample(); } diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/PatchInjection/PatchInjection.H b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/PatchInjection/PatchInjection.H index 25c1a007cf..517ebf7e02 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/PatchInjection/PatchInjection.H +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/PatchInjection/PatchInjection.H @@ -72,6 +72,24 @@ class PatchInjection public InjectionModel, public patchInjectionBase { +public: + + // Public Data Types + + //- Velocity type enumeration + enum velocityType + { + vtFixedValue, //!< User supplied fixed value + vtPatchValue, //!< Patch face values + vtZeroGradient //!< Patch internal cell values + }; + + //- Velocity type names + static const Enum velocityTypeNames_; + + +private: + // Private data //- Injection duration [s] @@ -80,7 +98,11 @@ class PatchInjection //- Number of parcels to introduce per second [] const label parcelsPerSecond_; + //- Velocity type + const velocityType velocityType_; + //- Initial parcel velocity [m/s] + // Note: Only used for vtFixedValue const vector U0_; //- Flow rate profile relative to SOI [] @@ -89,6 +111,12 @@ class PatchInjection //- Parcel size distribution model const autoPtr sizeDistribution_; + //- Current parcel being processed + label currentParceli_; + + //- Current face being processed + label currentFacei_; + public: @@ -120,7 +148,7 @@ public: //- Destructor - virtual ~PatchInjection(); + virtual ~PatchInjection() = default; // Member Functions diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/PatchInjection/patchInjectionBase.C b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/PatchInjection/patchInjectionBase.C index 9832c478e3..e3c495ec93 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/PatchInjection/patchInjectionBase.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/PatchInjection/patchInjectionBase.C @@ -144,7 +144,7 @@ void Foam::patchInjectionBase::updateMesh(const polyMesh& mesh) } -void Foam::patchInjectionBase::setPositionAndCell +Foam::label Foam::patchInjectionBase::setPositionAndCell ( const fvMesh& mesh, const scalar fraction01, @@ -155,6 +155,8 @@ void Foam::patchInjectionBase::setPositionAndCell label& tetPti ) { + label facei = -1; + if (cellOwners_.size() > 0) { // Determine which processor to inject from @@ -177,7 +179,7 @@ void Foam::patchInjectionBase::setPositionAndCell } // Set cellOwner - label facei = triToFace_[trii]; + facei = triToFace_[trii]; cellOwner = cellOwners_[facei]; // Find random point in triangle @@ -261,10 +263,12 @@ void Foam::patchInjectionBase::setPositionAndCell // Dummy position position = pTraits::max; } + + return facei; } -void Foam::patchInjectionBase::setPositionAndCell +Foam::label Foam::patchInjectionBase::setPositionAndCell ( const fvMesh& mesh, Random& rnd, @@ -276,7 +280,7 @@ void Foam::patchInjectionBase::setPositionAndCell { scalar fraction01 = rnd.globalSample01(); - setPositionAndCell + return setPositionAndCell ( mesh, fraction01, diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/PatchInjection/patchInjectionBase.H b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/PatchInjection/patchInjectionBase.H index aad5931ddf..6c2336670a 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/PatchInjection/patchInjectionBase.H +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/PatchInjection/patchInjectionBase.H @@ -118,7 +118,8 @@ public: //- Set the injection position and owner cell, tetFace and tetPt // Supply the fraction used to determine the location on the patch - void setPositionAndCell + // Returns the seed patch face index + label setPositionAndCell ( const fvMesh& mesh, const scalar fraction01, @@ -130,7 +131,8 @@ public: ); //- Set the injection position and owner cell, tetFace and tetPt - virtual void setPositionAndCell + // Returns the seed patch face index + virtual label setPositionAndCell ( const fvMesh& mesh, Random& rnd, diff --git a/tutorials/lagrangian/kinematicParcelFoam/spinningDisk/0/U b/tutorials/lagrangian/kinematicParcelFoam/spinningDisk/0/U new file mode 100644 index 0000000000..f03c35985d --- /dev/null +++ b/tutorials/lagrangian/kinematicParcelFoam/spinningDisk/0/U @@ -0,0 +1,56 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2106 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volVectorField; + object U; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 -1 0 0 0 0]; + +internalField uniform (0.1 0 0); + +boundaryField +{ + inlet + { + type fixedValue; + value $internalField; + } + + outlet + { + type inletOutlet; + inletValue uniform (0 0 0); + value uniform (0 0 0); + } + + cylinder + { + type rotatingWallVelocity; + origin (0 0 0); + axis (0 0 1); + omega 1; + } + + walls + { + type noSlip; + } + + frontAndBack + { + type empty; + } +} + + +// ************************************************************************* // diff --git a/tutorials/lagrangian/kinematicParcelFoam/spinningDisk/0/p b/tutorials/lagrangian/kinematicParcelFoam/spinningDisk/0/p new file mode 100644 index 0000000000..31a86b8b89 --- /dev/null +++ b/tutorials/lagrangian/kinematicParcelFoam/spinningDisk/0/p @@ -0,0 +1,46 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2106 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object p; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 2 -2 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + inlet + { + type zeroGradient; + } + + outlet + { + type fixedValue; + value uniform 0; + } + + "(walls|cylinder)" + { + type zeroGradient; + } + + frontAndBack + { + type empty; + } +} + + +// ************************************************************************* // diff --git a/tutorials/lagrangian/kinematicParcelFoam/spinningDisk/constant/g b/tutorials/lagrangian/kinematicParcelFoam/spinningDisk/constant/g new file mode 100644 index 0000000000..e340b6cb92 --- /dev/null +++ b/tutorials/lagrangian/kinematicParcelFoam/spinningDisk/constant/g @@ -0,0 +1,21 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2106 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class uniformDimensionedVectorField; + object g; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 -2 0 0 0 0]; +value (0 0 -9.8); + + +// ************************************************************************* // diff --git a/tutorials/lagrangian/kinematicParcelFoam/spinningDisk/constant/kinematicCloudProperties b/tutorials/lagrangian/kinematicParcelFoam/spinningDisk/constant/kinematicCloudProperties new file mode 100644 index 0000000000..aeae28fbb1 --- /dev/null +++ b/tutorials/lagrangian/kinematicParcelFoam/spinningDisk/constant/kinematicCloudProperties @@ -0,0 +1,108 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1912 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object kinematicCloudProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solution +{ + active true; + coupled yes; + transient yes; + cellValueSourceCorrection no; + maxCo 0.3; + + sourceTerms + { + schemes + { + U semiImplicit 1; + } + } + + interpolationSchemes + { + rho cell; + U cellPoint; + muc cell; + p cell; + } + + integrationSchemes + { + U Euler; + } +} + +constantProperties +{ + rho0 1000; +} + +subModels +{ + particleForces + { + sphereDrag; + gravity; + } + + injectionModels + { + model1 + { + type patchInjection; + massTotal 1; + SOI 0; + parcelBasisType mass; + patch cylinder; + duration 10; + parcelsPerSecond 100; + velocityType patchValue; + //velocityType zeroGradient; + //U0 (-10 0 0); + flowRateProfile constant 1; + sizeDistribution + { + type normal; + normalDistribution + { + expectation 1e-3; + variance 1e-4; + minValue 1e-5; + maxValue 2e-3; + } + } + } + } + + dispersionModel none; + + patchInteractionModel standardWallInteraction; + + stochasticCollisionModel none; + + surfaceFilmModel none; + + standardWallInteractionCoeffs + { + type rebound; + } +} + + +cloudFunctions +{} + + +// ************************************************************************* // diff --git a/tutorials/lagrangian/kinematicParcelFoam/spinningDisk/constant/transportProperties b/tutorials/lagrangian/kinematicParcelFoam/spinningDisk/constant/transportProperties new file mode 100644 index 0000000000..2f4edd39aa --- /dev/null +++ b/tutorials/lagrangian/kinematicParcelFoam/spinningDisk/constant/transportProperties @@ -0,0 +1,24 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2106 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object transportProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +transportModel Newtonian; + +nu 1e-05; + +rhoInf 1.2; + + +// ************************************************************************* // diff --git a/tutorials/lagrangian/kinematicParcelFoam/spinningDisk/constant/turbulenceProperties b/tutorials/lagrangian/kinematicParcelFoam/spinningDisk/constant/turbulenceProperties new file mode 100644 index 0000000000..15113f55f9 --- /dev/null +++ b/tutorials/lagrangian/kinematicParcelFoam/spinningDisk/constant/turbulenceProperties @@ -0,0 +1,20 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2106 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object turbulenceProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +simulationType laminar; + + +// ************************************************************************* // diff --git a/tutorials/lagrangian/kinematicParcelFoam/spinningDisk/system/blockMeshDict b/tutorials/lagrangian/kinematicParcelFoam/spinningDisk/system/blockMeshDict new file mode 100644 index 0000000000..a38ed26339 --- /dev/null +++ b/tutorials/lagrangian/kinematicParcelFoam/spinningDisk/system/blockMeshDict @@ -0,0 +1,114 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2106 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +scale 1; + +r 1; +a #eval{1./sqrt(2)*$r}; +b #eval{3*$r}; + +n 16; + +vertices +( + (-$b -$b 0) // 0 + ( $b -$b 0) // 1 + (-$a -$a 0) // 2 + ( $a -$a 0) // 3 + (-$a $a 0) // 4 + ( $a $a 0) // 5 + (-$b $b 0) // 6 + ( $b $b 0) // 7 + + (-$b -$b 1) // 8 + ( $b -$b 1) // 9 + (-$a -$a 1) // 10 + ( $a -$a 1) // 11 + (-$a $a 1) // 12 + ( $a $a 1) // 13 + (-$b $b 1) // 14 + ( $b $b 1) // 15 +); + +blocks +( + hex (0 1 3 2 8 9 11 10) ($n $n 1) simpleGrading (1 1 1) + hex (1 7 5 3 9 15 13 11) ($n $n 1) simpleGrading (1 1 1) + hex (7 6 4 5 15 14 12 13) ($n $n 1) simpleGrading (1 1 1) + hex (6 0 2 4 14 8 10 12) ($n $n 1) simpleGrading (1 1 1) +); + +edges +( + arc 2 3 origin (0 0 0) + arc 3 5 origin (0 0 0) + arc 5 4 origin (0 0 0) + arc 4 2 origin (0 0 0) + + arc 10 11 origin (0 0 1) + arc 11 13 origin (0 0 1) + arc 13 12 origin (0 0 1) + arc 12 10 origin (0 0 1) +); + +boundary +( + walls + { + type wall; + faces + ( + (0 2) + (2 2) + ); + } + cylinder + { + type wall; + faces + ( + (0 3) + (1 3) + (2 3) + (3 3) + ); + } + outlet + { + type patch; + faces + ( + (1 2) + ); + } + inlet + { + type patch; + faces + ( + (3 2) + ); + } +); + +defaultPatch +{ + type empty; + name frontAndBack; +} + + +// ************************************************************************* // diff --git a/tutorials/lagrangian/kinematicParcelFoam/spinningDisk/system/controlDict b/tutorials/lagrangian/kinematicParcelFoam/spinningDisk/system/controlDict new file mode 100644 index 0000000000..dbace75dfe --- /dev/null +++ b/tutorials/lagrangian/kinematicParcelFoam/spinningDisk/system/controlDict @@ -0,0 +1,54 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2106 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object controlDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +application kinematicParcelFoam; + +startFrom startTime; + +startTime 0; + +stopAt endTime; + +endTime 10; + +deltaT 0.005; + +writeControl adjustable; + +writeInterval 0.25; + +purgeWrite 0; + +writeFormat binary; + +writePrecision 6; + +writeCompression off; + +timeFormat general; + +timePrecision 6; + +runTimeModifiable yes; + +adjustTimeStep yes; + +maxCo 0.9; + +maxDeltaT 0.1; + + +// ************************************************************************* // diff --git a/tutorials/lagrangian/kinematicParcelFoam/spinningDisk/system/decomposeParDict b/tutorials/lagrangian/kinematicParcelFoam/spinningDisk/system/decomposeParDict new file mode 100644 index 0000000000..586c037a8a --- /dev/null +++ b/tutorials/lagrangian/kinematicParcelFoam/spinningDisk/system/decomposeParDict @@ -0,0 +1,27 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2106 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object decomposeParDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +numberOfSubdomains 4; + +method hierarchical; + +coeffs +{ + n ( 2 2 1 ); +} + + +// ************************************************************************* // \ No newline at end of file diff --git a/tutorials/lagrangian/kinematicParcelFoam/spinningDisk/system/fvSchemes b/tutorials/lagrangian/kinematicParcelFoam/spinningDisk/system/fvSchemes new file mode 100644 index 0000000000..6333789c9a --- /dev/null +++ b/tutorials/lagrangian/kinematicParcelFoam/spinningDisk/system/fvSchemes @@ -0,0 +1,54 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2106 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object fvSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +ddtSchemes +{ + default Euler; +} + +gradSchemes +{ + default Gauss linear; + grad(p) Gauss linear; + grad(U) Gauss linear; +} + +divSchemes +{ + default none; + + div(phi,U) Gauss upwind; + + div((nuEff*dev2(T(grad(U))))) Gauss linear; +} + +laplacianSchemes +{ + default Gauss linear corrected; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default corrected; +} + + +// ************************************************************************* // diff --git a/tutorials/lagrangian/kinematicParcelFoam/spinningDisk/system/fvSolution b/tutorials/lagrangian/kinematicParcelFoam/spinningDisk/system/fvSolution new file mode 100644 index 0000000000..a4b3321817 --- /dev/null +++ b/tutorials/lagrangian/kinematicParcelFoam/spinningDisk/system/fvSolution @@ -0,0 +1,60 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2106 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object fvSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solvers +{ + p + { + solver PBiCGStab; + tolerance 0; + relTol 0.1; + smoother GaussSeidel; + preconditioner DIC; + } + + pFinal + { + $p; + tolerance 1e-06; + relTol 0; + } + + U + { + solver smoothSolver; + smoother GaussSeidel; + tolerance 1e-05; + relTol 0.01; + } + + UFinal + { + $U; + tolerance 1e-06; + relTol 0; + } +} + +PIMPLE +{ + momentumPredictor yes; + nOuterCorrectors 1; + nCorrectors 2; + nNonOrthogonalCorrectors 0; +} + + +// ************************************************************************* // From c754c1ccbf4e869536ed99e4aa99da4a483d794c Mon Sep 17 00:00:00 2001 From: Andrew Heather <> Date: Tue, 14 Dec 2021 10:38:46 +0000 Subject: [PATCH 2/4] ENH: ConeNozzleInjection - enabled direction to change as f(time) - Now only has the options 'point' and 'disk' (deprecated movingPoint) - moving state is based on the type of Function1 - The position and direction entries are Function1-types, e.g. for the 'table' type the entries could be: position table ( ( 0 (0.1 0.5 0.5)) (0.2 (0.5 0.9 0.5)) (0.4 (0.9 0.5 0.5)) (0.6 (0.5 0.1 0.5)) (0.8 (0.5 0.5 0.9)) (1.0 (0.5 0.9 0.5)) (1.2 (0.5 0.5 0.1)) (1.4 (0.5 0.1 0.5)) (1.6 (0.1 0.5 0.5)) (1.8 (0.5 0.5 0.9)) (2.0 (0.9 0.5 0.5)) (2.2 (0.5 0.5 0.1)) ); direction table ( ( 0 ( 1 0 0)) (0.2 ( 0 -1 0)) (0.4 (-1 0 0)) (0.6 ( 0 1 0)) (0.8 ( 0 0 -1)) (1.0 ( 0 -1 0)) (1.2 ( 0 0 1)) (1.4 ( 0 1 0)) (1.6 ( 1 0 0)) (1.8 ( 0 0 -1)) (2.0 (-1 0 0)) (2.2 ( 0 0 1)) ); --- .../ConeNozzleInjection/ConeNozzleInjection.C | 189 +++++++++--------- .../ConeNozzleInjection/ConeNozzleInjection.H | 20 +- 2 files changed, 108 insertions(+), 101 deletions(-) diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeNozzleInjection/ConeNozzleInjection.C b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeNozzleInjection/ConeNozzleInjection.C index 53c93ebee0..3b468bbd06 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeNozzleInjection/ConeNozzleInjection.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeNozzleInjection/ConeNozzleInjection.C @@ -43,7 +43,6 @@ Foam::ConeNozzleInjection::injectionMethodNames ({ { injectionMethod::imPoint, "point" }, { injectionMethod::imDisc, "disc" }, - { injectionMethod::imMovingPoint, "movingPoint" }, }); template @@ -62,37 +61,52 @@ Foam::ConeNozzleInjection::flowTypeNames // * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * * // template -void Foam::ConeNozzleInjection::setInjectionMethod() +void Foam::ConeNozzleInjection::setInjectionGeometry() { - switch (injectionMethod_) + const auto& mesh = this->owner().mesh(); + + // Position + positionVsTime_.reset + ( + Function1::New("position", this->coeffDict(), &mesh) + ); + + positionVsTime_->userTimeToTime(this->owner().time()); + + if (positionVsTime_->constant()) { - case injectionMethod::imPoint: - case injectionMethod::imDisc: + position_ = positionVsTime_->value(0); + } + + // Direction + directionVsTime_.reset + ( + Function1::New("direction", this->coeffDict(), &mesh) + ); + + directionVsTime_->userTimeToTime(this->owner().time()); + + if (directionVsTime_->constant()) + { + direction_ = directionVsTime_->value(0); + direction_.normalise(); + + Random& rndGen = this->owner().rndGen(); + + // Determine direction vectors tangential to direction + vector tangent = Zero; + scalar magTangent = 0.0; + + while(magTangent < SMALL) { - this->coeffDict().readEntry("position", position_); - break; - } - case injectionMethod::imMovingPoint: - { - positionVsTime_.reset - ( - Function1::New - ( - "position", - this->coeffDict(), - &this->owner().mesh() - ) - ); - positionVsTime_->userTimeToTime(this->owner().time()); - break; - } - default: - { - FatalErrorInFunction - << "Unhandled injection method " - << injectionMethodNames[injectionMethod_] - << exit(FatalError); + vector v = rndGen.globalSample01(); + + tangent = v - (v & direction_)*direction_; + magTangent = mag(tangent); } + + tanVec1_ = tangent/magTangent; + tanVec2_ = direction_^tanVec1_; } } @@ -170,7 +184,8 @@ Foam::ConeNozzleInjection::ConeNozzleInjection injectorCell_(-1), tetFacei_(-1), tetPti_(-1), - direction_(this->coeffDict().lookup("direction")), + directionVsTime_(nullptr), + direction_(Zero), parcelsPerSecond_(this->coeffDict().getScalar("parcelsPerSecond")), flowRateProfile_ ( @@ -231,29 +246,10 @@ Foam::ConeNozzleInjection::ConeNozzleInjection thetaInner_->userTimeToTime(time); thetaOuter_->userTimeToTime(time); - setInjectionMethod(); + setInjectionGeometry(); setFlowType(); - Random& rndGen = this->owner().rndGen(); - - // Normalise direction vector - direction_.normalise(); - - // Determine direction vectors tangential to direction - vector tangent = Zero; - scalar magTangent = 0.0; - - while(magTangent < SMALL) - { - vector v = rndGen.globalSample01(); - - tangent = v - (v & direction_)*direction_; - magTangent = mag(tangent); - } - - tanVec1_ = tangent/magTangent; - tanVec2_ = direction_^tanVec1_; // Set total volume to inject this->volumeTotal_ = flowRateProfile_->integrate(0.0, duration_); @@ -279,6 +275,7 @@ Foam::ConeNozzleInjection::ConeNozzleInjection injectorCell_(im.injectorCell_), tetFacei_(im.tetFacei_), tetPti_(im.tetPti_), + directionVsTime_(im.directionVsTime_.clone()), direction_(im.direction_), parcelsPerSecond_(im.parcelsPerSecond_), flowRateProfile_(im.flowRateProfile_.clone()), @@ -294,37 +291,23 @@ Foam::ConeNozzleInjection::ConeNozzleInjection {} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -template -Foam::ConeNozzleInjection::~ConeNozzleInjection() -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template void Foam::ConeNozzleInjection::updateMesh() { // Set/cache the injector cell info for static methods - - switch (injectionMethod_) + if (positionVsTime_->constant()) { - case injectionMethod::imPoint: - { - this->findCellAtPosition - ( - injectorCell_, - tetFacei_, - tetPti_, - position_ - ); - break; - } - default: - { - // Do nothing for the other methods - } + position_ = positionVsTime_->value(0); + + this->findCellAtPosition + ( + injectorCell_, + tetFacei_, + tetPti_, + position_ + ); } } @@ -381,6 +364,28 @@ void Foam::ConeNozzleInjection::setPositionAndCell ) { Random& rndGen = this->owner().rndGen(); + const scalar t = time - this->SOI_; + + if (!directionVsTime_->constant()) + { + direction_ = directionVsTime_->value(t); + direction_.normalise(); + + // Determine direction vectors tangential to direction + vector tangent = Zero; + scalar magTangent = 0.0; + + while(magTangent < SMALL) + { + vector v = rndGen.globalSample01(); + + tangent = v - (v & direction_)*direction_; + magTangent = mag(tangent); + } + + tanVec1_ = tangent/magTangent; + tanVec2_ = direction_^tanVec1_; + } scalar beta = mathematical::twoPi*rndGen.globalSample01(); normal_ = tanVec1_*cos(beta) + tanVec2_*sin(beta); @@ -389,25 +394,25 @@ void Foam::ConeNozzleInjection::setPositionAndCell { case injectionMethod::imPoint: { - position = position_; - cellOwner = injectorCell_; - tetFacei = tetFacei_; - tetPti = tetPti_; - - break; - } - case injectionMethod::imMovingPoint: - { - position = positionVsTime_->value(time - this->SOI_); - - this->findCellAtPosition - ( - cellOwner, - tetFacei, - tetPti, - position - ); + if (positionVsTime_->constant()) + { + position = position_; + cellOwner = injectorCell_; + tetFacei = tetFacei_; + tetPti = tetPti_; + } + else + { + position = positionVsTime_->value(t); + this->findCellAtPosition + ( + cellOwner, + tetFacei, + tetPti, + position + ); + } break; } case injectionMethod::imDisc: @@ -416,7 +421,7 @@ void Foam::ConeNozzleInjection::setPositionAndCell scalar dr = outerDiameter_ - innerDiameter_; scalar r = 0.5*(innerDiameter_ + frac*dr); - position = position_ + r*normal_; + position = positionVsTime_->value(t) + r*normal_; this->findCellAtPosition ( diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeNozzleInjection/ConeNozzleInjection.H b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeNozzleInjection/ConeNozzleInjection.H index 0329d1e03a..606a9e5a6b 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeNozzleInjection/ConeNozzleInjection.H +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeNozzleInjection/ConeNozzleInjection.H @@ -97,8 +97,7 @@ public: enum class injectionMethod { imPoint, - imDisc, - imMovingPoint + imDisc }; static const Enum injectionMethodNames; @@ -136,19 +135,22 @@ private: //- Position relative to SOI [] autoPtr> positionVsTime_; - //- Injector position [m] + //- Static injector - position [m] vector position_; - //- Cell containing injector position [] + //- Static injector - cell containing injector position [] label injectorCell_; - //- Index of tet face for injector cell + //- Static injector - index of tet face for injector cell label tetFacei_; - //- Index of tet point for injector cell + //- Static injector - index of tet point for injector cell label tetPti_; //- Injector direction [] + autoPtr> directionVsTime_; + + //- Cached direction vector vector direction_; //- Number of parcels to introduce per second [] @@ -193,8 +195,8 @@ private: // Private Member Functions - //- Set the injection type - void setInjectionMethod(); + //- Set the injection position and direction + void setInjectionGeometry(); //- Set the injection flow type void setFlowType(); @@ -230,7 +232,7 @@ public: //- Destructor - virtual ~ConeNozzleInjection(); + virtual ~ConeNozzleInjection() = default; // Member Functions From f64e2864f7977c7c29fb705ce8806993b22a8601 Mon Sep 17 00:00:00 2001 From: Andrew Heather <> Date: Tue, 14 Dec 2021 10:55:45 +0000 Subject: [PATCH 3/4] TUT: Lagrangian - added example showing moving injector --- .../reactingParcelFoam/movingInjectorBox/0/G | 53 +++++ .../movingInjectorBox/0/H2O | 31 +++ .../reactingParcelFoam/movingInjectorBox/0/T | 31 +++ .../reactingParcelFoam/movingInjectorBox/0/U | 31 +++ .../movingInjectorBox/0/air | 31 +++ .../reactingParcelFoam/movingInjectorBox/0/p | 32 +++ .../movingInjectorBox/0/p_rgh | 31 +++ .../constant/chemistryProperties | 27 +++ .../constant/combustionProperties | 21 ++ .../movingInjectorBox/constant/g | 22 ++ .../constant/reactingCloud1Properties | 194 ++++++++++++++++++ .../movingInjectorBox/constant/reactions | 8 + .../constant/thermo.incompressiblePoly | 111 ++++++++++ .../constant/thermophysicalProperties | 48 +++++ .../constant/turbulenceProperties | 20 ++ .../movingInjectorBox/system/blockMeshDict | 61 ++++++ .../movingInjectorBox/system/controlDict | 55 +++++ .../movingInjectorBox/system/fvSchemes | 49 +++++ .../movingInjectorBox/system/fvSolution | 29 +++ 19 files changed, 885 insertions(+) create mode 100644 tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/0/G create mode 100644 tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/0/H2O create mode 100644 tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/0/T create mode 100644 tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/0/U create mode 100644 tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/0/air create mode 100644 tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/0/p create mode 100644 tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/0/p_rgh create mode 100644 tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/constant/chemistryProperties create mode 100644 tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/constant/combustionProperties create mode 100644 tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/constant/g create mode 100644 tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/constant/reactingCloud1Properties create mode 100644 tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/constant/reactions create mode 100644 tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/constant/thermo.incompressiblePoly create mode 100644 tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/constant/thermophysicalProperties create mode 100644 tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/constant/turbulenceProperties create mode 100644 tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/system/blockMeshDict create mode 100644 tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/system/controlDict create mode 100644 tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/system/fvSchemes create mode 100644 tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/system/fvSolution diff --git a/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/0/G b/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/0/G new file mode 100644 index 0000000000..a5d4726e0c --- /dev/null +++ b/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/0/G @@ -0,0 +1,53 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2106 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object G; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [1 0 -3 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + back + { + type symmetryPlane; + } + front + { + type symmetryPlane; + } + walls + { + type MarshakRadiation; + emissivityMode lookup; + emissivity uniform 1.0; + value uniform 0; + } + outlet + { + type zeroGradient; + } + inlet + { + type MarshakRadiation; + emissivityMode lookup; + emissivity uniform 1.0; + value uniform 0; + } +} + + +// ************************************************************************* // diff --git a/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/0/H2O b/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/0/H2O new file mode 100644 index 0000000000..3417452dad --- /dev/null +++ b/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/0/H2O @@ -0,0 +1,31 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2106 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object H2O; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 0 0 0 0]; + +internalField uniform 0.01; + +boundaryField +{ + walls + { + type zeroGradient; + } +} + + +// ************************************************************************* // diff --git a/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/0/T b/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/0/T new file mode 100644 index 0000000000..5f4690fedb --- /dev/null +++ b/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/0/T @@ -0,0 +1,31 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2106 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object T; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 1 0 0 0]; + +internalField uniform 293.0; + +boundaryField +{ + walls + { + type zeroGradient; + } +} + + +// ************************************************************************* // diff --git a/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/0/U b/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/0/U new file mode 100644 index 0000000000..e9257d5fea --- /dev/null +++ b/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/0/U @@ -0,0 +1,31 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2106 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volVectorField; + location "0"; + object U; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 -1 0 0 0 0]; + +internalField uniform (0 0 0); + +boundaryField +{ + walls + { + type noSlip; + } +} + + +// ************************************************************************* // diff --git a/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/0/air b/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/0/air new file mode 100644 index 0000000000..606aa0d6c1 --- /dev/null +++ b/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/0/air @@ -0,0 +1,31 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2106 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object air; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 0 0 0 0]; + +internalField uniform 0.99; + +boundaryField +{ + walls + { + type zeroGradient; + } +} + + +// ************************************************************************* // diff --git a/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/0/p b/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/0/p new file mode 100644 index 0000000000..fc36fdeaef --- /dev/null +++ b/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/0/p @@ -0,0 +1,32 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2106 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object p; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [1 -1 -2 0 0 0 0]; + +internalField uniform 100000; + +boundaryField +{ + walls + { + type calculated; + value $internalField; + } +} + + +// ************************************************************************* // diff --git a/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/0/p_rgh b/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/0/p_rgh new file mode 100644 index 0000000000..79a2cbea9f --- /dev/null +++ b/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/0/p_rgh @@ -0,0 +1,31 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2106 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object p_rgh; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [1 -1 -2 0 0 0 0]; + +internalField uniform 100000; + +boundaryField +{ + walls + { + type fixedFluxPressure; + } +} + + +// ************************************************************************* // diff --git a/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/constant/chemistryProperties b/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/constant/chemistryProperties new file mode 100644 index 0000000000..64efa4e4c7 --- /dev/null +++ b/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/constant/chemistryProperties @@ -0,0 +1,27 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2106 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object chemistryProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +chemistryType +{ + solver noChemistrySolver; +} + +chemistry off; + +initialChemicalTimeStep 1e-7; + +// ************************************************************************* // diff --git a/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/constant/combustionProperties b/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/constant/combustionProperties new file mode 100644 index 0000000000..3db193c82d --- /dev/null +++ b/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/constant/combustionProperties @@ -0,0 +1,21 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2106 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object combustionProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +combustionModel none; + + +// ************************************************************************* // diff --git a/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/constant/g b/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/constant/g new file mode 100644 index 0000000000..f1cda53f48 --- /dev/null +++ b/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/constant/g @@ -0,0 +1,22 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2106 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class uniformDimensionedVectorField; + location "constant"; + object g; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 -2 0 0 0 0]; +value (0 0 0); + + +// ************************************************************************* // diff --git a/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/constant/reactingCloud1Properties b/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/constant/reactingCloud1Properties new file mode 100644 index 0000000000..6e34ecf151 --- /dev/null +++ b/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/constant/reactingCloud1Properties @@ -0,0 +1,194 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2106 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object reactingCloud1Properties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solution +{ + active true; + coupled false; + transient yes; + cellValueSourceCorrection off; + maxCo 0.3; + + sourceTerms + { + schemes + { + rho explicit 1; + U explicit 1; + Yi explicit 1; + h explicit 1; + radiation explicit 1; + } + } + + interpolationSchemes + { + rho cell; + U cellPoint; + thermo:mu cell; + T cell; + Cp cell; + kappa cell; + p cell; + } + + integrationSchemes + { + U Euler; + T Euler; + } +} + + +constantProperties +{ + rho0 1000; + T0 293; + Cp0 4100; + + volumeUpdateMethod constantRho; +} + + +subModels +{ + particleForces + { + sphereDrag; + gravity; + } + + injectionModels + { + model1 + { + type coneNozzleInjection; + massTotal 0.0001; + parcelBasisType mass; + SOI 0; + + injectionMethod point; + flowType constantVelocity; + UMag 20; + outerDiameter 0.001; + innerDiameter 0; + duration 2; + parcelsPerSecond 2000; + flowRateProfile constant 1; + thetaInner constant 0; + thetaOuter constant 10; + + position table + ( + ( 0 (0.1 0.5 0.5)) + (0.2 (0.5 0.9 0.5)) + (0.4 (0.9 0.5 0.5)) + (0.6 (0.5 0.1 0.5)) + + (0.8 (0.5 0.5 0.9)) + (1.0 (0.5 0.9 0.5)) + (1.2 (0.5 0.5 0.1)) + (1.4 (0.5 0.1 0.5)) + + (1.6 (0.1 0.5 0.5)) + (1.8 (0.5 0.5 0.9)) + (2.0 (0.9 0.5 0.5)) + (2.2 (0.5 0.5 0.1)) + ); + + direction table + ( + ( 0 ( 1 0 0)) + (0.2 ( 0 -1 0)) + (0.4 (-1 0 0)) + (0.6 ( 0 1 0)) + + (0.8 ( 0 0 -1)) + (1.0 ( 0 -1 0)) + (1.2 ( 0 0 1)) + (1.4 ( 0 1 0)) + + (1.6 ( 1 0 0)) + (1.8 ( 0 0 -1)) + (2.0 (-1 0 0)) + (2.2 ( 0 0 1)) + ); + + sizeDistribution + { + type uniform; + uniformDistribution + { + minValue 100e-06; + maxValue 100e-06; + } + } + } + } + + dispersionModel none; + + patchInteractionModel standardWallInteraction; + + heatTransferModel none; + + compositionModel singleMixtureFraction; + + phaseChangeModel none; + + devolatilisationModel none; + + surfaceReactionModel none; + + stochasticCollisionModel none; + + surfaceFilmModel none; + + radiation off; + + standardWallInteractionCoeffs + { + type rebound; + } + + singleMixtureFractionCoeffs + { + phases + ( + gas + { + } + liquid + { + H2O 1; + } + solid + { + } + ); + YGasTot0 0; + YLiquidTot0 1; + YSolidTot0 0; + } +} + + +cloudFunctions +{} + + +// ************************************************************************* // diff --git a/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/constant/reactions b/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/constant/reactions new file mode 100644 index 0000000000..228f5f836b --- /dev/null +++ b/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/constant/reactions @@ -0,0 +1,8 @@ +species +( + air + H2O +); + +reactions +{} diff --git a/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/constant/thermo.incompressiblePoly b/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/constant/thermo.incompressiblePoly new file mode 100644 index 0000000000..a0b644ddea --- /dev/null +++ b/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/constant/thermo.incompressiblePoly @@ -0,0 +1,111 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2106 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object thermo.incompressiblePoly; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +N2 +{ + specie + { + molWeight 28.0134; + } + equationOfState + { + rhoCoeffs<8> ( 3.8936 -0.016463 3.2101e-05 -2.9174e-08 9.9889e-12 0 0 0 ); + } + thermodynamics + { + Hf 0; + Sf 0; + CpCoeffs<8> ( 979.08 0.41787 -0.0011761 1.6742e-06 -7.2559e-10 0 0 0 ); + } + transport + { + muCoeffs<8> ( 1.5068e-06 6.1598e-08 -1.8188e-11 0 0 0 0 0 ); + kappaCoeffs<8> ( 0.0031494 8.4997e-05 -1.2621e-08 0 0 0 0 0 ); + } +} + +O2 +{ + specie + { + molWeight 31.9988; + } + equationOfState + { + rhoCoeffs<8> ( 4.4475 -0.018805 3.6667e-05 -3.3323e-08 1.141e-11 0 0 0 ); + } + thermodynamics + { + Hf 0; + Sf 0; + CpCoeffs<8> ( 834.84 0.29297 -0.00014959 3.4143e-07 -2.2786e-10 0 0 0 ); + } + transport + { + muCoeffs<8> ( 1.5068e-06 6.1598e-08 -1.8188e-11 0 0 0 0 0 ); + kappaCoeffs<8> ( 0.00016082 8.5301e-05 -1.4998e-08 0 0 0 0 0 ); + } +} + +H2O +{ + specie + { + molWeight 18.0153; + } + equationOfState + { + rhoCoeffs<8> ( 2.5039 -0.010587 2.0643e-05 -1.8761e-08 6.4237e-12 0 0 0 ); + } + thermodynamics + { + Hf -13423000; + Sf 10482; + CpCoeffs<8> ( 1563.1 1.604 -0.0029334 3.2168e-06 -1.1571e-09 0 0 0 ); + } + transport + { + muCoeffs<8> ( 1.5068e-06 6.1598e-08 -1.8188e-11 0 0 0 0 0 ); + kappaCoeffs<8> ( 0.0037972 0.00015336 -1.1859e-08 0 0 0 0 0 ); + } +} + +air +{ + specie + { + molWeight 28.85; + } + equationOfState + { + rhoCoeffs<8> ( 4.0097 -0.016954 3.3057e-05 -3.0042e-08 1.0286e-11 0 0 0 ); + } + thermodynamics + { + Hf 0; + Sf 0; + CpCoeffs<8> ( 948.76 0.39171 -0.00095999 1.393e-06 -6.2029e-10 0 0 0 ); + } + transport + { + muCoeffs<8> ( 1.5061e-06 6.16e-08 -1.819e-11 0 0 0 0 0 ); + kappaCoeffs<8> ( 0.0025219 8.506e-05 -1.312e-08 0 0 0 0 0 ); + } +} + + +// ************************************************************************* // diff --git a/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/constant/thermophysicalProperties b/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/constant/thermophysicalProperties new file mode 100644 index 0000000000..da92d8cf7b --- /dev/null +++ b/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/constant/thermophysicalProperties @@ -0,0 +1,48 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2106 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object thermophysicalProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +thermoType +{ + type heRhoThermo; + mixture reactingMixture; + transport polynomial; + thermo hPolynomial; + energy sensibleEnthalpy; + equationOfState icoPolynomial; + specie specie; +} + +dpdt no; + +chemistryReader foamChemistryReader; + +foamChemistryFile "/reactions"; + +foamChemistryThermoFile "/thermo.incompressiblePoly"; + +inertSpecie air; + +liquids +{ + H2O; +} + +solids +{} + + +// ************************************************************************* // diff --git a/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/constant/turbulenceProperties b/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/constant/turbulenceProperties new file mode 100644 index 0000000000..66b3b930f9 --- /dev/null +++ b/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/constant/turbulenceProperties @@ -0,0 +1,20 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2106 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object turbulenceProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +simulationType laminar; + + +// ************************************************************************* // diff --git a/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/system/blockMeshDict b/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/system/blockMeshDict new file mode 100644 index 0000000000..d5b95ef9b8 --- /dev/null +++ b/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/system/blockMeshDict @@ -0,0 +1,61 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2106 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +scale 1; + +vertices +( + (0 0 0) + (1 0 0) + (1 1 0) + (0 1 0) + (0 0 1) + (1 0 1) + (1 1 1) + (0 1 1) +); + +blocks +( + hex (0 1 2 3 4 5 6 7) (10 10 10) simpleGrading (1 1 1) +); + +edges +( +); + +boundary +( + walls + { + type wall; + faces + ( + (3 7 6 2) + (1 5 4 0) + (0 4 7 3) + (2 6 5 1) + (0 3 2 1) + (4 5 6 7) + ); + } +); + +mergePatchPairs +( +); + +// ************************************************************************* // diff --git a/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/system/controlDict b/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/system/controlDict new file mode 100644 index 0000000000..a4d2217c42 --- /dev/null +++ b/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/system/controlDict @@ -0,0 +1,55 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2106 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object controlDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +application reactingParcelFoam; + +startFrom startTime; + +startTime 0; + +stopAt endTime; + +endTime 3; + +deltaT 1e-3; + +writeControl adjustable; + +writeInterval 0.05; + +purgeWrite 0; + +writeFormat ascii; + +writePrecision 10; + +writeCompression off; + +timeFormat general; + +timePrecision 6; + +runTimeModifiable true; + +adjustTimeStep yes; + +maxCo 5; + +maxDeltaT 1e-3; + + +// ************************************************************************* // diff --git a/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/system/fvSchemes b/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/system/fvSchemes new file mode 100644 index 0000000000..fed2404a96 --- /dev/null +++ b/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/system/fvSchemes @@ -0,0 +1,49 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2106 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object fvSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +ddtSchemes +{ + default Euler; +} + +gradSchemes +{ + default none; +} + +divSchemes +{ + default none; +} + +laplacianSchemes +{ + default none; +} + +interpolationSchemes +{ + default none; +} + +snGradSchemes +{ + default none; +} + + +// ************************************************************************* // diff --git a/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/system/fvSolution b/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/system/fvSolution new file mode 100644 index 0000000000..40a4b9fa9e --- /dev/null +++ b/tutorials/lagrangian/reactingParcelFoam/movingInjectorBox/system/fvSolution @@ -0,0 +1,29 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v2106 | +| \\ / A nd | Website: www.openfoam.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object fvSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solvers +{} + +PIMPLE +{ + solvePrimaryRegion no; +} + +relaxationFactors +{} + +// ************************************************************************* // From c4cc33b748bbf306f2e42f8eb0dcfe30c2ec9369 Mon Sep 17 00:00:00 2001 From: Andrew Heather <> Date: Tue, 14 Dec 2021 13:36:12 +0000 Subject: [PATCH 4/4] ENH: Added new FaceInteraction cloudFunctionObject Enables particles to interact with mesh faces (decsribed using faceZones). faceInteraction1 { type faceInteraction; faceZones ( (blockageFaces stick) // (blockageFaces escape) // (blockageFaces rebound) // not applicable for this test case (!) ); dMin 0; dMax 1; } The faceZones entry is a list of (faceZoneName interactionType), where interaction type is either stick, escape or rebound. --- .../include/makeParcelCloudFunctionObjects.H | 2 + .../makeReactingParcelCloudFunctionObjects.H | 2 + .../makeThermoParcelCloudFunctionObjects.H | 2 + .../FaceInteraction/FaceInteraction.C | 329 ++++++++++++++++++ .../FaceInteraction/FaceInteraction.H | 203 +++++++++++ 5 files changed, 538 insertions(+) create mode 100644 src/lagrangian/intermediate/submodels/CloudFunctionObjects/FaceInteraction/FaceInteraction.C create mode 100644 src/lagrangian/intermediate/submodels/CloudFunctionObjects/FaceInteraction/FaceInteraction.H diff --git a/src/lagrangian/intermediate/parcels/include/makeParcelCloudFunctionObjects.H b/src/lagrangian/intermediate/parcels/include/makeParcelCloudFunctionObjects.H index cc6d7b563e..45310e16d2 100644 --- a/src/lagrangian/intermediate/parcels/include/makeParcelCloudFunctionObjects.H +++ b/src/lagrangian/intermediate/parcels/include/makeParcelCloudFunctionObjects.H @@ -31,6 +31,7 @@ License // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +#include "FaceInteraction.H" #include "FacePostProcessing.H" #include "ParticleCollector.H" #include "ParticleErosion.H" @@ -50,6 +51,7 @@ License \ makeCloudFunctionObject(CloudType); \ \ + makeCloudFunctionObjectType(FaceInteraction, CloudType); \ makeCloudFunctionObjectType(FacePostProcessing, CloudType); \ makeCloudFunctionObjectType(ParticleCollector, CloudType); \ makeCloudFunctionObjectType(ParticleErosion, CloudType); \ diff --git a/src/lagrangian/intermediate/parcels/include/makeReactingParcelCloudFunctionObjects.H b/src/lagrangian/intermediate/parcels/include/makeReactingParcelCloudFunctionObjects.H index bc5bb9ec07..61e0e413cd 100644 --- a/src/lagrangian/intermediate/parcels/include/makeReactingParcelCloudFunctionObjects.H +++ b/src/lagrangian/intermediate/parcels/include/makeReactingParcelCloudFunctionObjects.H @@ -31,6 +31,7 @@ License // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +#include "FaceInteraction.H" #include "FacePostProcessing.H" #include "ParticleCollector.H" #include "ParticleErosion.H" @@ -53,6 +54,7 @@ License \ makeCloudFunctionObject(CloudType); \ \ + makeCloudFunctionObjectType(FaceInteraction, CloudType); \ makeCloudFunctionObjectType(FacePostProcessing, CloudType); \ makeCloudFunctionObjectType(ParticleCollector, CloudType); \ makeCloudFunctionObjectType(ParticleErosion, CloudType); \ diff --git a/src/lagrangian/intermediate/parcels/include/makeThermoParcelCloudFunctionObjects.H b/src/lagrangian/intermediate/parcels/include/makeThermoParcelCloudFunctionObjects.H index 635e809c8d..4b641e275b 100644 --- a/src/lagrangian/intermediate/parcels/include/makeThermoParcelCloudFunctionObjects.H +++ b/src/lagrangian/intermediate/parcels/include/makeThermoParcelCloudFunctionObjects.H @@ -30,6 +30,7 @@ License // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +#include "FaceInteraction.H" #include "FacePostProcessing.H" #include "ParticleCollector.H" #include "ParticleErosion.H" @@ -51,6 +52,7 @@ License \ makeCloudFunctionObject(CloudType); \ \ + makeCloudFunctionObjectType(FaceInteraction, CloudType); \ makeCloudFunctionObjectType(FacePostProcessing, CloudType); \ makeCloudFunctionObjectType(ParticleCollector, CloudType); \ makeCloudFunctionObjectType(ParticleErosion, CloudType); \ diff --git a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/FaceInteraction/FaceInteraction.C b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/FaceInteraction/FaceInteraction.C new file mode 100644 index 0000000000..1f246cbc10 --- /dev/null +++ b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/FaceInteraction/FaceInteraction.C @@ -0,0 +1,329 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2021 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 "FaceInteraction.H" +#include "faceZoneMesh.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +template +const Foam::Enum::interactionType> +Foam::FaceInteraction::interactionTypeNames_ +({ + { interactionType::STICK, "stick" }, + { interactionType::ESCAPE, "escape" }, + { interactionType::REBOUND, "rebound" }, +}); + + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +template +bool Foam::FaceInteraction::processParticle +( + const parcelType& p, + const label localZonei +) +{ + if (!faceZoneBBs_[localZonei].contains(p.position())) + { + // Quick reject if the particle is not in the face zone bound box + return false; + } + + if ((p.d() > dMax_) || (p.d() < dMin_)) + { + return false; + } + + return true; +} + + +template +void Foam::FaceInteraction::write() +{ + const fvMesh& mesh = this->owner().mesh(); + const faceZoneMesh& fzm = mesh.faceZones(); + + Info<< type() << " output:" << nl; + + // Retrieve any stored data + const label nZones = faceZoneIDs_.size(); + labelList npe0(nZones, Zero); + labelList nps0(nZones, Zero); + labelList npr0(nZones, Zero); + + this->getModelProperty("nEscape", npe0); + this->getModelProperty("nStick", nps0); + this->getModelProperty("nRebound", npr0); + + // Accumulate current data + labelList npe(returnReduce(nEscapeParticles_, sumOp())); + labelList nps(returnReduce(nStickParticles_, sumOp())); + labelList npr(returnReduce(nReboundParticles_, sumOp())); + forAll(npe, i) + { + npe[i] = npe[i] + npe0[i]; + nps[i] = nps[i] + nps0[i]; + npr[i] = npr[i] + npr0[i]; + } + + + // Write to log/file + forAll(faceZoneIDs_, i) + { + const label zonei = faceZoneIDs_[i]; + Info<< " Zone : " << fzm[zonei].name() << nl + << " Escape : " << npe[i] << nl + << " Stick : " << nps[i] << nl + << " Rebound : " << npr[i] << nl; + + if (this->writeToFile()) + { + auto& os = filePtrs_[i]; + + writeCurrentTime(os); + + // Note - writing as scalar for better formatting + os << tab << scalar(npe[i]) + << tab << scalar(nps[i]) + << tab << scalar(npr[i]) + << endl; + } + } + Info<< endl; + + // Set restart data + this->setModelProperty("nEscape", npe); + this->setModelProperty("nStick", nps); + this->setModelProperty("nRebound", npr); + + nEscapeParticles_ = Zero; + nStickParticles_ = Zero; + nReboundParticles_ = Zero; +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +Foam::FaceInteraction::FaceInteraction +( + const dictionary& dict, + CloudType& owner, + const word& modelName +) +: + CloudFunctionObject(dict, owner, modelName, typeName), + functionObjects::writeFile + ( + owner, + this->localPath(), + typeName, + this->coeffDict() + ), + faceZoneIDs_(), + faceZoneBBs_(), + faceZoneInteraction_(), + filePtrs_(), + nEscapeParticles_(), + nStickParticles_(), + nReboundParticles_(), + dMin_(this->coeffDict().getOrDefault("dMin", -GREAT)), + dMax_(this->coeffDict().getOrDefault("dMax", GREAT)) +{ + const List> nameAndInteraction + ( + this->coeffDict().lookup("faceZones") + ); + + filePtrs_.setSize(nameAndInteraction.size()); + + faceZoneBBs_.setSize(nameAndInteraction.size()); + faceZoneInteraction_.setSize(nameAndInteraction.size()); + + DynamicList