From a9c7a176e351b863c5acd3b08ca914b5468c071a Mon Sep 17 00:00:00 2001 From: Henrik Rusche Date: Sun, 19 Aug 2018 16:49:25 +0200 Subject: [PATCH] BUGFIX: Mesh update in lagrangian --- .../KinematicCloud/KinematicCloudTemplate.C | 8 ++--- .../ReactingCloud/ReactingCloudTemplate.C | 9 +++++ .../ReactingCloud/ReactingCloudTemplate.H | 6 ++++ .../ReactingMultiphaseCloudTemplate.C | 12 +++++++ .../ReactingMultiphaseCloudTemplate.H | 7 +++- .../ThermoCloud/ThermoCloudTemplate.C | 9 +++++ .../ThermoCloud/ThermoCloudTemplate.H | 7 ++++ .../ConeInjectionMP/ConeInjectionMP.C | 21 +++++++----- .../ConeInjectionMP/ConeInjectionMP.H | 3 ++ .../FieldActivatedInjection.C | 21 +++++++----- .../FieldActivatedInjection.H | 3 ++ .../KinematicLookupTableInjection.C | 17 +++++++--- .../KinematicLookupTableInjection.H | 3 ++ .../PatchInjection/PatchInjection.C | 34 ++++++++++++------- .../PatchInjection/PatchInjection.H | 3 ++ .../ReactingLookupTableInjection.C | 17 +++++++--- .../ReactingLookupTableInjection.H | 3 ++ .../ReactingMultiphaseLookupTableInjection.C | 17 +++++++--- .../ReactingMultiphaseLookupTableInjection.H | 3 ++ .../ThermoLookupTableInjection.C | 17 +++++++--- .../ThermoLookupTableInjection.H | 3 ++ 21 files changed, 170 insertions(+), 53 deletions(-) diff --git a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloudTemplate.C b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloudTemplate.C index 306ac0dca..fcd6516c0 100644 --- a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloudTemplate.C +++ b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloudTemplate.C @@ -278,13 +278,9 @@ void Foam::KinematicCloud::updateMesh() template void Foam::KinematicCloud::autoMap(const mapPolyMesh& mapper) { - //typedef typename particle::TrackingData> tdType; + Cloud::autoMap(mapper); - //tdType td(*this); - - //Cloud::template autoMap(td, mapper); - - updateMesh(); + this->updateMesh(); } diff --git a/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloudTemplate.C b/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloudTemplate.C index d50514e72..a0e845013 100644 --- a/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloudTemplate.C +++ b/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloudTemplate.C @@ -278,6 +278,15 @@ void Foam::ReactingCloud::evolve() } +template +void Foam::ReactingCloud::autoMap(const mapPolyMesh& mapper) +{ + Cloud::autoMap(mapper); + + this->updateMesh(); +} + + template void Foam::ReactingCloud::info() const { diff --git a/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloudTemplate.H b/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloudTemplate.H index 3bfcb9206..970c861b0 100644 --- a/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloudTemplate.H +++ b/src/lagrangian/intermediate/clouds/Templates/ReactingCloud/ReactingCloudTemplate.H @@ -239,6 +239,12 @@ public: //- Evolve the spray (inject, move) void evolve(); + + // Mapping + + //- Remap the cells of particles corresponding to the + // mesh topology change with a default tracking data object + virtual void autoMap(const mapPolyMesh&); }; diff --git a/src/lagrangian/intermediate/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloudTemplate.C b/src/lagrangian/intermediate/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloudTemplate.C index eb6369e85..0111beac4 100644 --- a/src/lagrangian/intermediate/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloudTemplate.C +++ b/src/lagrangian/intermediate/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloudTemplate.C @@ -234,6 +234,18 @@ void Foam::ReactingMultiphaseCloud::evolve() } +template +void Foam::ReactingMultiphaseCloud::autoMap +( + const mapPolyMesh& mapper +) +{ + Cloud::autoMap(mapper); + + this->updateMesh(); +} + + template void Foam::ReactingMultiphaseCloud::info() const { diff --git a/src/lagrangian/intermediate/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloudTemplate.H b/src/lagrangian/intermediate/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloudTemplate.H index f204e8910..8f49593f8 100644 --- a/src/lagrangian/intermediate/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloudTemplate.H +++ b/src/lagrangian/intermediate/clouds/Templates/ReactingMultiphaseCloud/ReactingMultiphaseCloudTemplate.H @@ -202,7 +202,12 @@ public: //- Evolve the spray (inject, move) void evolve(); -}; + + // Mapping + + //- Remap the cells of particles corresponding to the + // mesh topology change with a default tracking data object + virtual void autoMap(const mapPolyMesh&);}; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloudTemplate.C b/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloudTemplate.C index 05bf1450a..c225285e5 100644 --- a/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloudTemplate.C +++ b/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloudTemplate.C @@ -225,6 +225,15 @@ void Foam::ThermoCloud::evolve() } +template +void Foam::ThermoCloud::autoMap(const mapPolyMesh& mapper) +{ + Cloud::autoMap(mapper); + + this->updateMesh(); +} + + template void Foam::ThermoCloud::info() const { diff --git a/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloudTemplate.H b/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloudTemplate.H index 72661d8da..30856de5f 100644 --- a/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloudTemplate.H +++ b/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloudTemplate.H @@ -227,6 +227,13 @@ public: //- Evolve the spray (inject, move) void evolve(); + + + // Mapping + + //- Remap the cells of particles corresponding to the + // mesh topology change with a default tracking data object + virtual void autoMap(const mapPolyMesh&); }; diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeInjectionMP/ConeInjectionMP.C b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeInjectionMP/ConeInjectionMP.C index 7dfdf695b..77fb5e865 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeInjectionMP/ConeInjectionMP.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeInjectionMP/ConeInjectionMP.C @@ -182,15 +182,7 @@ Foam::ConeInjectionMP::ConeInjectionMP // Set total volume to inject this->volumeTotal_ = volumeFlowRate_().integrate(0.0, duration_); - // Set/cache the injector cells - forAll(positions_, i) - { - this->findCellAtPosition - ( - injectorCells_[i], - positions_[i] - ); - } + this->updateMesh(); } @@ -210,6 +202,17 @@ bool Foam::ConeInjectionMP::active() const } +template +void Foam::ConeInjectionMP::updateMesh() +{ + // Set/cache the injector cell + forAll(positions_, i) + { + this->findCellAtPosition(injectorCells_[i], positions_[i]); + } +} + + template Foam::scalar Foam::ConeInjectionMP::timeEnd() const { diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeInjectionMP/ConeInjectionMP.H b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeInjectionMP/ConeInjectionMP.H index a3aa0b114..eca49874e 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeInjectionMP/ConeInjectionMP.H +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeInjectionMP/ConeInjectionMP.H @@ -162,6 +162,9 @@ public: //- Flag to indicate whether model activates injection model bool active() const; + //- Set injector locations when mesh is updated + virtual void updateMesh(); + //- Return the end-of-injection time scalar timeEnd() const; diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/FieldActivatedInjection/FieldActivatedInjection.C b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/FieldActivatedInjection/FieldActivatedInjection.C index a79838157..81dac427a 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/FieldActivatedInjection/FieldActivatedInjection.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/FieldActivatedInjection/FieldActivatedInjection.C @@ -131,15 +131,7 @@ Foam::FieldActivatedInjection::FieldActivatedInjection this->volumeTotal_ = nParcelsPerInjector_*sum(pow3(diameters_))*mathematicalConstant::pi/6.0; - // Set/cache the injector cells - forAll(positions_, i) - { - this->findCellAtPosition - ( - injectorCells_[i], - positions_[i] - ); - } + updateMesh(); } @@ -159,6 +151,17 @@ bool Foam::FieldActivatedInjection::active() const } +template +void Foam::FieldActivatedInjection::updateMesh() +{ + // Set/cache the injector cell + forAll(positions_, i) + { + this->findCellAtPosition(injectorCells_[i], positions_[i]); + } +} + + template Foam::scalar Foam::FieldActivatedInjection::timeEnd() const { diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/FieldActivatedInjection/FieldActivatedInjection.H b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/FieldActivatedInjection/FieldActivatedInjection.H index afc090b7d..b5e66f74e 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/FieldActivatedInjection/FieldActivatedInjection.H +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/FieldActivatedInjection/FieldActivatedInjection.H @@ -152,6 +152,9 @@ public: //- Flag to indicate whether model activates injection model bool active() const; + //- Set injector locations when mesh is updated + virtual void updateMesh(); + //- Return the end-of-injection time scalar timeEnd() const; diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/KinematicLookupTableInjection/KinematicLookupTableInjection.C b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/KinematicLookupTableInjection/KinematicLookupTableInjection.C index 636cb1df9..43ccc73c7 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/KinematicLookupTableInjection/KinematicLookupTableInjection.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/KinematicLookupTableInjection/KinematicLookupTableInjection.C @@ -97,10 +97,8 @@ Foam::KinematicLookupTableInjection::KinematicLookupTableInjection { // Set/cache the injector cells injectorCells_.setSize(injectors_.size()); - forAll(injectors_, i) - { - this->findCellAtPosition(injectorCells_[i], injectors_[i].x()); - } + + this->updateMesh(); // Determine volume of particles to inject this->volumeTotal_ = 0.0; @@ -128,6 +126,17 @@ bool Foam::KinematicLookupTableInjection::active() const } +template +void Foam::KinematicLookupTableInjection::updateMesh() +{ + // Set/cache the injector cell + forAll(injectors_, i) + { + this->findCellAtPosition(injectorCells_[i], injectors_[i].x()); + } +} + + template Foam::scalar Foam::KinematicLookupTableInjection::timeEnd() const { diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/KinematicLookupTableInjection/KinematicLookupTableInjection.H b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/KinematicLookupTableInjection/KinematicLookupTableInjection.H index 312c25e95..c28fd8e1b 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/KinematicLookupTableInjection/KinematicLookupTableInjection.H +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/KinematicLookupTableInjection/KinematicLookupTableInjection.H @@ -129,6 +129,9 @@ public: //- Flag to indicate whether model activates injection model bool active() const; + //- Set injector locations when mesh is updated + virtual void updateMesh(); + //- Return the end-of-injection time scalar timeEnd() const; diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/PatchInjection/PatchInjection.C b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/PatchInjection/PatchInjection.C index 556bdf9f4..d7f9045f8 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/PatchInjection/PatchInjection.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/PatchInjection/PatchInjection.C @@ -117,18 +117,7 @@ Foam::PatchInjection::PatchInjection << nl << exit(FatalError); } - const polyPatch& patch = owner.mesh().boundaryMesh()[patchId]; - - cellOwners_ = patch.faceCells(); - - label patchSize = cellOwners_.size(); - label totalPatchSize = patchSize; - reduce(totalPatchSize, sumOp