From 8f16204390537efec67e27d8032653ce08b034a4 Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Sun, 17 Jul 2016 22:59:25 +0100 Subject: [PATCH] basicMultiComponentMixture: Improved the handling of Ydefault --- .../basicMultiComponentMixture.C | 112 ++++++++++++------ .../0/{Ydefault => Ydefault.gas} | 2 +- 2 files changed, 78 insertions(+), 36 deletions(-) rename tutorials/multiphase/reactingTwoPhaseEulerFoam/RAS/bubbleColumnEvaporatingReacting/0/{Ydefault => Ydefault.gas} (97%) diff --git a/src/thermophysicalModels/reactionThermo/mixtures/basicMultiComponentMixture/basicMultiComponentMixture.C b/src/thermophysicalModels/reactionThermo/mixtures/basicMultiComponentMixture/basicMultiComponentMixture.C index 2bc7133c74..591d8283f7 100644 --- a/src/thermophysicalModels/reactionThermo/mixtures/basicMultiComponentMixture/basicMultiComponentMixture.C +++ b/src/thermophysicalModels/reactionThermo/mixtures/basicMultiComponentMixture/basicMultiComponentMixture.C @@ -46,48 +46,90 @@ Foam::basicMultiComponentMixture::basicMultiComponentMixture active_(species_.size(), true), Y_(species_.size()) { + tmp tYdefault; + forAll(species_, i) { - word YdefaultName(IOobject::groupName("Ydefault", phaseName)); - - volScalarField Ydefault + IOobject header ( - IOobject - ( - YdefaultName, - exists(mesh.time().path()/mesh.time().timeName()/YdefaultName) - ? mesh.time().timeName() - : ( - exists - ( - mesh.time().path()/mesh.time().constant()/YdefaultName - ) - ? mesh.time().constant() - : Time::timeName(0) - ), - mesh, - IOobject::MUST_READ, - IOobject::NO_WRITE - ), - mesh + IOobject::groupName(species_[i], phaseName), + mesh.time().timeName(), + mesh, + IOobject::NO_READ ); - Y_.set - ( - i, - new volScalarField + // Check if field exists and can be read + if (header.headerOk()) + { + Y_.set ( - IOobject + i, + new volScalarField ( - IOobject::groupName(species_[i], phaseName), - mesh.time().timeName(), - mesh, - IOobject::READ_IF_PRESENT, - IOobject::AUTO_WRITE - ), - Ydefault - ) - ); + IOobject + ( + IOobject::groupName(species_[i], phaseName), + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ) + ); + } + else + { + // Read Ydefault if not already read + if (!tYdefault.valid()) + { + word YdefaultName(IOobject::groupName("Ydefault", phaseName)); + + tYdefault = new volScalarField + ( + IOobject + ( + YdefaultName, + exists + ( + mesh.time().path()/mesh.time().timeName() + /YdefaultName + ) + ? mesh.time().timeName() + : ( + exists + ( + mesh.time().path()/mesh.time().constant() + /YdefaultName + ) + ? mesh.time().constant() + : Time::timeName(0) + ), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ), + mesh + ); + } + + Y_.set + ( + i, + new volScalarField + ( + IOobject + ( + IOobject::groupName(species_[i], phaseName), + mesh.time().timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + tYdefault() + ) + ); + } } // Do not enforce constraint of sum of mass fractions to equal 1 here diff --git a/tutorials/multiphase/reactingTwoPhaseEulerFoam/RAS/bubbleColumnEvaporatingReacting/0/Ydefault b/tutorials/multiphase/reactingTwoPhaseEulerFoam/RAS/bubbleColumnEvaporatingReacting/0/Ydefault.gas similarity index 97% rename from tutorials/multiphase/reactingTwoPhaseEulerFoam/RAS/bubbleColumnEvaporatingReacting/0/Ydefault rename to tutorials/multiphase/reactingTwoPhaseEulerFoam/RAS/bubbleColumnEvaporatingReacting/0/Ydefault.gas index cc22bdff91..3638838d63 100644 --- a/tutorials/multiphase/reactingTwoPhaseEulerFoam/RAS/bubbleColumnEvaporatingReacting/0/Ydefault +++ b/tutorials/multiphase/reactingTwoPhaseEulerFoam/RAS/bubbleColumnEvaporatingReacting/0/Ydefault.gas @@ -11,7 +11,7 @@ FoamFile format ascii; class volScalarField; location "0"; - object Ydefault; + object Ydefault.gas; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //