/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2017-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License This file is part of OpenFOAM. OpenFOAM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . \*---------------------------------------------------------------------------*/ #include "PopulationBalancePhaseSystem.H" // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // template Foam::tmp Foam::PopulationBalancePhaseSystem::pDmdt ( const phasePairKey& key ) const { if (!pDmdt_.found(key)) { return phaseSystem::dmdt(key); } const scalar pDmdtSign(Pair::compare(pDmdt_.find(key).key(), key)); return pDmdtSign**pDmdt_[key]; } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template Foam::PopulationBalancePhaseSystem:: PopulationBalancePhaseSystem ( const fvMesh& mesh ) : BasePhaseSystem(mesh), populationBalances_ ( this->lookup("populationBalances"), diameterModels::populationBalanceModel::iNew(*this, pDmdt_) ) { forAll(populationBalances_, i) { const Foam::diameterModels::populationBalanceModel& popBal = populationBalances_[i]; forAllConstIter(phaseSystem::phasePairTable, popBal.phasePairs(), iter) { const phasePairKey& key = iter.key(); if (!this->phasePairs_.found(key)) { this->phasePairs_.insert ( key, autoPtr ( new phasePair ( this->phaseModels_[key.first()], this->phaseModels_[key.second()] ) ) ); } } } forAllConstIter ( phaseSystem::phasePairTable, this->phasePairs_, phasePairIter ) { const phasePair& pair(phasePairIter()); if (pair.ordered()) { continue; } // Initially assume no mass transfer pDmdt_.set ( pair, new volScalarField ( IOobject ( IOobject::groupName("pDmdt", pair.name()), this->mesh().time().timeName(), this->mesh(), IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE ), this->mesh(), dimensionedScalar(dimDensity/dimTime) ) ); } } // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // template Foam::PopulationBalancePhaseSystem:: ~PopulationBalancePhaseSystem() {} // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // template Foam::tmp Foam::PopulationBalancePhaseSystem::dmdt ( const phasePairKey& key ) const { return BasePhaseSystem::dmdt(key) + this->pDmdt(key); } template Foam::PtrList Foam::PopulationBalancePhaseSystem::dmdts() const { PtrList dmdts(BasePhaseSystem::dmdts()); forAllConstIter(pDmdtTable, pDmdt_, pDmdtIter) { const phasePair& pair = this->phasePairs_[pDmdtIter.key()]; const volScalarField& pDmdt = *pDmdtIter(); this->addField(pair.phase1(), "dmdt", pDmdt, dmdts); this->addField(pair.phase2(), "dmdt", - pDmdt, dmdts); } return dmdts; } template Foam::autoPtr Foam::PopulationBalancePhaseSystem::massTransfer() const { autoPtr eqnsPtr = BasePhaseSystem::massTransfer(); phaseSystem::massTransferTable& eqns = eqnsPtr(); forAllConstIter ( phaseSystem::phasePairTable, this->phasePairs_, phasePairIter ) { const phasePair& pair(phasePairIter()); if (pair.ordered()) { continue; } const phaseModel& phase = pair.phase1(); const phaseModel& otherPhase = pair.phase2(); // Note that the phase YiEqn does not contain a continuity error term, // so these additions represent the entire mass transfer const volScalarField dmdt(this->pDmdt(pair)); const volScalarField dmdt12(negPart(dmdt)); const volScalarField dmdt21(posPart(dmdt)); const PtrList& Yi = phase.Y(); forAll(Yi, i) { const word name ( IOobject::groupName(Yi[i].member(), phase.name()) ); const word otherName ( IOobject::groupName(Yi[i].member(), otherPhase.name()) ); *eqns[name] += dmdt21*eqns[otherName]->psi() + fvm::Sp(dmdt12, eqns[name]->psi()); *eqns[otherName] -= dmdt12*eqns[name]->psi() + fvm::Sp(dmdt21, eqns[otherName]->psi()); } } return eqnsPtr; } template bool Foam::PopulationBalancePhaseSystem::read() { if (BasePhaseSystem::read()) { bool readOK = true; // Models ... return readOK; } else { return false; } } template void Foam::PopulationBalancePhaseSystem::solve() { BasePhaseSystem::solve(); forAll(populationBalances_, i) { populationBalances_[i].solve(); } } // ************************************************************************* //