View Issue Details

IDProjectCategoryView StatusLast Update
0003459OpenFOAMPatchpublic2020-02-24 17:51
ReportertniemiAssigned Tohenry 
PrioritynormalSeverityminorReproducibilityN/A
Status resolvedResolutionfixed 
Product Versiondev 
Fixed in Versiondev 
Summary0003459: Patch for adding phase support for moleFractions function object
DescriptionI have attached a simple patch which adds the option to specify a phase name to rho/psiReactionThermoMoleFractions function objects. This allows the function object to work in multiphase cases.
TagsNo tags attached.

Activities

tniemi

2020-02-23 14:09

reporter  

patch.diff (4,112 bytes)
diff --git a/src/thermophysicalModels/reactionThermo/functionObjects/moleFractions/moleFractions.C b/src/thermophysicalModels/reactionThermo/functionObjects/moleFractions/moleFractions.C
index ed1a47c0a..2e0b8b44d 100644
--- a/src/thermophysicalModels/reactionThermo/functionObjects/moleFractions/moleFractions.C
+++ b/src/thermophysicalModels/reactionThermo/functionObjects/moleFractions/moleFractions.C
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     | Website:  https://openfoam.org
-    \\  /    A nd           | Copyright (C) 2016-2018 OpenFOAM Foundation
+    \\  /    A nd           | Copyright (C) 2016-2020 OpenFOAM Foundation
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -32,7 +32,10 @@ template<class ThermoType>
 void Foam::moleFractions<ThermoType>::calculateMoleFractions()
 {
     const ThermoType& thermo =
-        mesh_.lookupObject<ThermoType>(basicThermo::dictName);
+        mesh_.lookupObject<ThermoType>
+        (
+            IOobject::groupName(basicThermo::dictName, phaseName_)
+        );
 
     const PtrList<volScalarField>& Y = thermo.composition().Y();
 
@@ -62,12 +65,17 @@ Foam::moleFractions<ThermoType>::moleFractions
     const dictionary& dict
 )
 :
-    fvMeshFunctionObject(name, runTime, dict)
+    fvMeshFunctionObject(name, runTime, dict),
+    phaseName_(dict.lookupOrDefault<word>("phase", word::null))
 {
-    if (mesh_.foundObject<ThermoType>(basicThermo::dictName))
+    const word dictName
+    (
+        IOobject::groupName(basicThermo::dictName, phaseName_)
+    );
+
+    if (mesh_.foundObject<ThermoType>(dictName))
     {
-        const ThermoType& thermo =
-            mesh_.lookupObject<ThermoType>(basicThermo::dictName);
+        const ThermoType& thermo = mesh_.lookupObject<ThermoType>(dictName);
 
         const PtrList<volScalarField>& Y = thermo.composition().Y();
 
@@ -96,10 +104,22 @@ Foam::moleFractions<ThermoType>::moleFractions
     }
     else
     {
-        FatalErrorInFunction
-            << "Cannot find thermodynamics model of type "
-            << ThermoType::typeName
-            << exit(FatalError);
+        if (phaseName_ != word::null)
+        {
+            FatalErrorInFunction
+                << "Cannot find thermodynamics model of type "
+                << ThermoType::typeName
+                << " for phase "
+                << phaseName_
+                << exit(FatalError);
+        }
+        else
+        {
+            FatalErrorInFunction
+                << "Cannot find thermodynamics model of type "
+                << ThermoType::typeName
+                << exit(FatalError);
+        }
     }
 }
 
diff --git a/src/thermophysicalModels/reactionThermo/functionObjects/moleFractions/moleFractions.H b/src/thermophysicalModels/reactionThermo/functionObjects/moleFractions/moleFractions.H
index 36b57b090..a78708964 100644
--- a/src/thermophysicalModels/reactionThermo/functionObjects/moleFractions/moleFractions.H
+++ b/src/thermophysicalModels/reactionThermo/functionObjects/moleFractions/moleFractions.H
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     | Website:  https://openfoam.org
-    \\  /    A nd           | Copyright (C) 2016-2019 OpenFOAM Foundation
+    \\  /    A nd           | Copyright (C) 2016-2020 OpenFOAM Foundation
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -48,6 +48,8 @@ Description
     \endverbatim
     depending on the thermodynamics package used in the solver.
 
+    Optionally, the name of the phase can be specified for multiphase cases.
+
 See also
     Foam::functionObjects::fvMeshFunctionObject
 
@@ -81,6 +83,9 @@ class moleFractions
         //- Species mole fractions
         PtrList<volScalarField> X_;
 
+        //- Optional phase name
+        word phaseName_;
+
 
     // Private Member Functions
 
patch.diff (4,112 bytes)

henry

2020-02-24 17:51

manager   ~0011210

Resolved by commit b559ef28ef527389de95f099a76622a86c2f22d7

Issue History

Date Modified Username Field Change
2020-02-23 14:09 tniemi New Issue
2020-02-23 14:09 tniemi File Added: patch.diff
2020-02-24 17:51 henry Assigned To => henry
2020-02-24 17:51 henry Status new => resolved
2020-02-24 17:51 henry Resolution open => fixed
2020-02-24 17:51 henry Fixed in Version => dev
2020-02-24 17:51 henry Note Added: 0011210