From 2fee35e7fe69650b95694ee3aefe366d9e7c078e Mon Sep 17 00:00:00 2001
From: sergio <sergio>
Date: Thu, 10 Dec 2015 13:11:48 -0800
Subject: [PATCH] ENH: Adding temporary fix for patchInjectionBase to find
 cellId where parcel is injected. In ReactingMultiphaseParcel.C changing in
 calc function the  mass update due to phase change.

---
 .../ReactingMultiphaseParcel.C                | 29 +++++++++----------
 .../PatchInjection/patchInjectionBase.C       | 16 ++++++++--
 2 files changed, 27 insertions(+), 18 deletions(-)

diff --git a/src/lagrangian/intermediate/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcel.C b/src/lagrangian/intermediate/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcel.C
index 2f050e26ae5..5516e7c9476 100644
--- a/src/lagrangian/intermediate/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcel.C
+++ b/src/lagrangian/intermediate/parcels/Templates/ReactingMultiphaseParcel/ReactingMultiphaseParcel.C
@@ -175,7 +175,6 @@ void Foam::ReactingMultiphaseParcel<ParcelType>::calc
     const CompositionModel<reactingCloudType>& composition =
         td.cloud().composition();
 
-
     // Define local properties at beginning of timestep
     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
@@ -291,7 +290,6 @@ void Foam::ReactingMultiphaseParcel<ParcelType>::calc
         Cs
     );
 
-
     // Surface reactions
     // ~~~~~~~~~~~~~~~~~
 
@@ -324,27 +322,14 @@ void Foam::ReactingMultiphaseParcel<ParcelType>::calc
         dhsTrans
     );
 
-
     // 2. Update the parcel properties due to change in mass
     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
     scalarField dMassGas(dMassDV + dMassSRGas);
     scalarField dMassLiquid(dMassPC + dMassSRLiquid);
     scalarField dMassSolid(dMassSRSolid);
-    scalar mass1 =
-        updateMassFractions(mass0, dMassGas, dMassLiquid, dMassSolid);
 
-    this->Cp_ = CpEff(td, pc, T0, idG, idL, idS);
-
-    // Update particle density or diameter
-    if (td.cloud().constProps().constantVolume())
-    {
-        this->rho_ = mass1/this->volume();
-    }
-    else
-    {
-        this->d_ = cbrt(mass1/this->rho_*6.0/pi);
-    }
+    scalar mass1 = mass0 - sum(dMassGas) - sum(dMassLiquid) - sum(dMassSolid);
 
     // Remove the particle when mass falls below minimum threshold
     if (np0*mass1 < td.cloud().constProps().minParcelMass())
@@ -386,6 +371,18 @@ void Foam::ReactingMultiphaseParcel<ParcelType>::calc
         return;
     }
 
+    (void)updateMassFractions(mass0, dMassGas, dMassLiquid, dMassSolid);
+
+     // Update particle density or diameter
+    if (td.cloud().constProps().constantVolume())
+    {
+        this->rho_ = mass1/this->volume();
+    }
+    else
+    {
+        this->d_ = cbrt(mass1/this->rho_*6.0/pi);
+    }
+
     // Correct surface values due to emitted species
     this->correctSurfaceValues(td, cellI, Ts, Cs, rhos, mus, Prs, kappas);
     Res = this->Re(U0, this->d_, rhos, mus);
diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/PatchInjection/patchInjectionBase.C b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/PatchInjection/patchInjectionBase.C
index 0d070691f01..6e52a06dba2 100644
--- a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/PatchInjection/patchInjectionBase.C
+++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/PatchInjection/patchInjectionBase.C
@@ -215,8 +215,20 @@ void Foam::patchInjectionBase::setPositionAndCell
             // first face of the cell as the tetFace and the first point after
             // the base point on the face as the tetPt.  The tracking will pick
             // the cell consistent with the motion in the first tracking step
-            tetFaceI = mesh.cells()[cellOwner][0];
-            tetPtI = 1;
+            //tetFaceI = mesh.cells()[cellOwner][0];
+            //tetPtI = 1;
+
+            //SAF: temporary fix for patchInjection.
+            // This function finds both cellOwner and tetFaceI. The particle
+            // was injected in a non-boundary cell and the tracking function
+            // could not find the cellOwner
+            mesh.findCellFacePt
+            (
+                position,
+                cellOwner,
+                tetFaceI,
+                tetPtI
+            );
         }
         else
         {
-- 
GitLab