From 6f4e9ec164d99fe827da87d0d90f92d507760782 Mon Sep 17 00:00:00 2001 From: Will Bainbridge Date: Wed, 11 Apr 2018 11:30:45 +0100 Subject: [PATCH] reactingEulerFoam: Order-independent lookup of unordered pair models Lookup of models associated with unordered phase pairs now searches for both possible pair names; e.g. gasAndLiquid and liquidAndGas. Patch contributed by Institute of Fluid Dynamics, Helmholtz-Zentrum Dresden - Rossendorf (HZDR) --- .../orderedPhasePair/orderedPhasePair.C | 12 ++++- .../orderedPhasePair/orderedPhasePair.H | 5 +- .../phasePair/phasePair/phasePair.C | 10 +++- .../phasePair/phasePair/phasePair.H | 3 ++ .../phaseSystems/phaseSystem/phaseSystem.H | 8 ++-- .../phaseSystem/phaseSystemTemplates.C | 47 +++++++++++++++---- 6 files changed, 69 insertions(+), 16 deletions(-) diff --git a/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/phasePair/orderedPhasePair/orderedPhasePair.C b/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/phasePair/orderedPhasePair/orderedPhasePair.C index d6ea3da0b..8abbfa87d 100644 --- a/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/phasePair/orderedPhasePair/orderedPhasePair.C +++ b/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/phasePair/orderedPhasePair/orderedPhasePair.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2014-2015 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2014-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -71,6 +71,16 @@ Foam::word Foam::orderedPhasePair::name() const } +Foam::word Foam::orderedPhasePair::otherName() const +{ + FatalErrorInFunction + << "Requested other name phase from an ordered pair." + << exit(FatalError); + + return word::null; +} + + Foam::tmp Foam::orderedPhasePair::E() const { return phase1().fluid().E(*this); diff --git a/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/phasePair/orderedPhasePair/orderedPhasePair.H b/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/phasePair/orderedPhasePair/orderedPhasePair.H index be4e23261..9cba70b71 100644 --- a/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/phasePair/orderedPhasePair/orderedPhasePair.H +++ b/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/phasePair/orderedPhasePair/orderedPhasePair.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2014-2015 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2014-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -77,6 +77,9 @@ public: //- Pair name virtual word name() const; + //- Other pair name + virtual word otherName() const; + //- Aspect ratio virtual tmp E() const; }; diff --git a/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/phasePair/phasePair/phasePair.C b/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/phasePair/phasePair/phasePair.C index 70ddd0427..1cff0aa63 100644 --- a/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/phasePair/phasePair/phasePair.C +++ b/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/phasePair/phasePair/phasePair.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2014-2015 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2014-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -93,6 +93,14 @@ Foam::word Foam::phasePair::name() const } +Foam::word Foam::phasePair::otherName() const +{ + word name1(first()); + name1[0] = toupper(name1[0]); + return second() + "And" + name1; +} + + Foam::tmp Foam::phasePair::rho() const { return phase1()*phase1().rho() + phase2()*phase2().rho(); diff --git a/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/phasePair/phasePair/phasePair.H b/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/phasePair/phasePair/phasePair.H index 06f0328f0..de3d40ead 100644 --- a/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/phasePair/phasePair/phasePair.H +++ b/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/phasePair/phasePair/phasePair.H @@ -112,6 +112,9 @@ public: //- Pair name virtual word name() const; + //- Other pair name + virtual word otherName() const; + //- Average density tmp rho() const; diff --git a/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/phaseSystem/phaseSystem.H b/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/phaseSystem/phaseSystem.H index 680008464..914eb848f 100644 --- a/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/phaseSystem/phaseSystem.H +++ b/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/phaseSystem/phaseSystem.H @@ -83,6 +83,10 @@ public: typedef UPtrList phaseModelPartialList; + typedef + HashTable, phasePairKey, phasePairKey::hash> + phasePairTable; + protected: @@ -92,10 +96,6 @@ protected: HashTable dictTable; - typedef - HashTable, phasePairKey, phasePairKey::hash> - phasePairTable; - typedef HashTable, word, word::hash> blendingMethodTable; diff --git a/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/phaseSystem/phaseSystemTemplates.C b/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/phaseSystem/phaseSystemTemplates.C index 16d352b8e..d3cd79cb0 100644 --- a/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/phaseSystem/phaseSystemTemplates.C +++ b/applications/solvers/multiphase/reactingEulerFoam/phaseSystems/phaseSystem/phaseSystemTemplates.C @@ -371,11 +371,20 @@ void Foam::phaseSystem::fillFields template const modelType& Foam::phaseSystem::lookupSubModel(const phasePair& key) const { - return - mesh().lookupObject - ( - IOobject::groupName(modelType::typeName, key.name()) - ); + const word name(IOobject::groupName(modelType::typeName, key.name())); + + if (key.ordered() || mesh().foundObject(name)) + { + return mesh().lookupObject(name); + } + else + { + return + mesh().lookupObject + ( + IOobject::groupName(modelType::typeName, key.otherName()) + ); + } } @@ -394,11 +403,31 @@ template const Foam::BlendedInterfacialModel& Foam::phaseSystem::lookupBlendedSubModel(const phasePair& key) const { - return - mesh().lookupObject> + const word name + ( + IOobject::groupName ( - IOobject::groupName(modelType::typeName, key.name()) - ); + BlendedInterfacialModel::typeName, + key.name() + ) + ); + + if (mesh().foundObject>(name)) + { + return mesh().lookupObject>(name); + } + else + { + return + mesh().lookupObject> + ( + IOobject::groupName + ( + BlendedInterfacialModel::typeName, + key.otherName() + ) + ); + } }