From b25c4611cb221a04440cbe1bc8fadbb7fd953189 Mon Sep 17 00:00:00 2001 From: Andrew Heather <> Date: Thu, 20 Aug 2020 12:32:08 +0100 Subject: [PATCH] ENH: Cloud patch interaction model updates - MultiInteraction: updated to call info() function of child models - PatchInteractionModel: added postEvolve hook - KinematicCloud: call patchInteraction() postEvolve hook --- .../Templates/KinematicCloud/KinematicCloud.C | 2 + .../PatchInjection/patchInjectionBase.C | 57 +++++++++++++++---- .../PatchInjection/patchInjectionBase.H | 16 ++++++ .../MultiInteraction/MultiInteraction.C | 21 +++++++ .../MultiInteraction/MultiInteraction.H | 6 ++ .../PatchInteractionModel.C | 5 ++ .../PatchInteractionModel.H | 4 +- 7 files changed, 99 insertions(+), 12 deletions(-) diff --git a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C index 1072ae273a..1c7e8a53c7 100644 --- a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C +++ b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C @@ -244,6 +244,8 @@ void Foam::KinematicCloud::postEvolve this->dispersion().cacheFields(false); + this->patchInteraction().postEvolve(); + forces_.cacheFields(false); functions_.postEvolve(td); diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/PatchInjection/patchInjectionBase.C b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/PatchInjection/patchInjectionBase.C index c26d74c55d..9832c478e3 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/PatchInjection/patchInjectionBase.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/PatchInjection/patchInjectionBase.C @@ -147,6 +147,7 @@ void Foam::patchInjectionBase::updateMesh(const polyMesh& mesh) void Foam::patchInjectionBase::setPositionAndCell ( const fvMesh& mesh, + const scalar fraction01, Random& rnd, vector& position, label& cellOwner, @@ -154,23 +155,15 @@ void Foam::patchInjectionBase::setPositionAndCell label& tetPti ) { - scalar areaFraction = rnd.globalPosition(scalar(0), patchArea_); - if (cellOwners_.size() > 0) { // Determine which processor to inject from - label proci = 0; - forAllReverse(sumTriMagSf_, i) - { - if (areaFraction >= sumTriMagSf_[i]) - { - proci = i; - break; - } - } + const label proci = whichProc(fraction01); if (Pstream::myProcNo() == proci) { + const scalar areaFraction = fraction01*patchArea_; + // Find corresponding decomposed face triangle label trii = 0; scalar offset = sumTriMagSf_[proci]; @@ -271,4 +264,46 @@ void Foam::patchInjectionBase::setPositionAndCell } +void Foam::patchInjectionBase::setPositionAndCell +( + const fvMesh& mesh, + Random& rnd, + vector& position, + label& cellOwner, + label& tetFacei, + label& tetPti +) +{ + scalar fraction01 = rnd.globalSample01(); + + setPositionAndCell + ( + mesh, + fraction01, + rnd, + position, + cellOwner, + tetFacei, + tetPti + ); +} + + +Foam::label Foam::patchInjectionBase::whichProc(const scalar fraction01) const +{ + const scalar areaFraction = fraction01*patchArea_; + + // Determine which processor to inject from + forAllReverse(sumTriMagSf_, i) + { + if (areaFraction >= sumTriMagSf_[i]) + { + return i; + } + } + + return 0; +} + + // ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/PatchInjection/patchInjectionBase.H b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/PatchInjection/patchInjectionBase.H index 806a8f5c7d..aad5931ddf 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/PatchInjection/patchInjectionBase.H +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/PatchInjection/patchInjectionBase.H @@ -116,6 +116,19 @@ public: //- Update patch geometry and derived info for injection locations virtual void updateMesh(const polyMesh& mesh); + //- Set the injection position and owner cell, tetFace and tetPt + // Supply the fraction used to determine the location on the patch + void setPositionAndCell + ( + const fvMesh& mesh, + const scalar fraction01, + Random& rnd, + vector& position, + label& cellOwner, + label& tetFacei, + label& tetPti + ); + //- Set the injection position and owner cell, tetFace and tetPt virtual void setPositionAndCell ( @@ -126,6 +139,9 @@ public: label& tetFacei, label& tetPti ); + + //- Return the processor that has the location specified by the fraction + label whichProc(const scalar fraction01) const; }; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/MultiInteraction/MultiInteraction.C b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/MultiInteraction/MultiInteraction.C index 65364a59bf..3bc8234bd4 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/MultiInteraction/MultiInteraction.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/MultiInteraction/MultiInteraction.C @@ -176,4 +176,25 @@ bool Foam::MultiInteraction::correct } +template +void Foam::MultiInteraction::postEvolve() +{ + for (auto& m : models_) + { + m.postEvolve(); + } +} + + +template +void Foam::MultiInteraction::info(Ostream& os) +{ + for (auto& m : models_) + { + Info<< "Patch interaction model " << m.type() << ':' << endl; + m.info(os); + } +} + + // ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/MultiInteraction/MultiInteraction.H b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/MultiInteraction/MultiInteraction.H index 60b417b4b1..18f82f38ec 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/MultiInteraction/MultiInteraction.H +++ b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/MultiInteraction/MultiInteraction.H @@ -148,6 +148,12 @@ public: const polyPatch& pp, bool& keepParticle ); + + //- Post-evolve hook + virtual void postEvolve(); + + //- Write patch interaction info to stream + virtual void info(Ostream& os); }; diff --git a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/PatchInteractionModel/PatchInteractionModel.C b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/PatchInteractionModel/PatchInteractionModel.C index 42774cfee1..8fe23c0229 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/PatchInteractionModel/PatchInteractionModel.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/PatchInteractionModel/PatchInteractionModel.C @@ -198,6 +198,11 @@ void Foam::PatchInteractionModel::addToEscapedParcels } +template +void Foam::PatchInteractionModel::postEvolve() +{} + + template void Foam::PatchInteractionModel::info(Ostream& os) { diff --git a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/PatchInteractionModel/PatchInteractionModel.H b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/PatchInteractionModel/PatchInteractionModel.H index 73d7bb6c20..d235330e2f 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/PatchInteractionModel/PatchInteractionModel.H +++ b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/PatchInteractionModel/PatchInteractionModel.H @@ -181,8 +181,10 @@ public: ) = 0; //- Add to escaped parcels - void addToEscapedParcels(const scalar mass); + virtual void addToEscapedParcels(const scalar mass); + //- Post-evolve hook + virtual void postEvolve(); //- Write patch interaction info to stream virtual void info(Ostream& os);