From ede5ec4830fbfb54877fdbc5b582c4c6db08ffcf Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Sat, 18 Mar 2023 14:50:19 +0000 Subject: [PATCH] multiphaseEuler: Create the drag and virtual mass tables on demand reduces storage and unnecessary evaluation of unused tables. --- .../multiphaseEuler/momentumPredictor.C | 6 +- .../MomentumTransferPhaseSystem.C | 249 ++++++++++++------ 2 files changed, 163 insertions(+), 92 deletions(-) diff --git a/applications/solvers/modules/multiphaseEuler/multiphaseEuler/momentumPredictor.C b/applications/solvers/modules/multiphaseEuler/multiphaseEuler/momentumPredictor.C index f9fe80bddd..97b1439212 100644 --- a/applications/solvers/modules/multiphaseEuler/multiphaseEuler/momentumPredictor.C +++ b/applications/solvers/modules/multiphaseEuler/multiphaseEuler/momentumPredictor.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2022 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2022-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -69,10 +69,6 @@ void Foam::solvers::multiphaseEuler::faceMomentumPredictor() { Info<< "Constructing face momentum equations" << endl; - // !!! Update coefficients shouldn't be necessary - // This should be done on demand - fluid.momentumTransfer(); - autoPtr momentumTransferPtr(fluid.momentumTransferf()); diff --git a/applications/solvers/modules/multiphaseEuler/phaseSystems/PhaseSystems/MomentumTransferPhaseSystem/MomentumTransferPhaseSystem.C b/applications/solvers/modules/multiphaseEuler/phaseSystems/PhaseSystems/MomentumTransferPhaseSystem/MomentumTransferPhaseSystem.C index baefa88dd5..6434229be9 100644 --- a/applications/solvers/modules/multiphaseEuler/phaseSystems/PhaseSystems/MomentumTransferPhaseSystem/MomentumTransferPhaseSystem.C +++ b/applications/solvers/modules/multiphaseEuler/phaseSystems/PhaseSystems/MomentumTransferPhaseSystem/MomentumTransferPhaseSystem.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2015-2022 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2015-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -120,90 +120,6 @@ MomentumTransferPhaseSystem this->generateInterfacialModels(liftModels_); this->generateInterfacialModels(wallLubricationModels_); this->generateInterfacialModels(turbulentDispersionModels_); - - forAllConstIter - ( - dragModelTable, - dragModels_, - dragModelIter - ) - { - const phaseInterface& interface = dragModelIter()->interface(); - - Kds_.insert - ( - dragModelIter.key(), - new volScalarField - ( - IOobject - ( - IOobject::groupName("Kd", interface.name()), - this->mesh().time().name(), - this->mesh() - ), - this->mesh(), - dimensionedScalar(dragModel::dimK, 0) - ) - ); - - Kdfs_.insert - ( - dragModelIter.key(), - new surfaceScalarField - ( - IOobject - ( - IOobject::groupName("Kdf", interface.name()), - this->mesh().time().name(), - this->mesh() - ), - this->mesh(), - dimensionedScalar(dragModel::dimK, 0) - ) - ); - } - - forAllConstIter - ( - virtualMassModelTable, - virtualMassModels_, - virtualMassModelIter - ) - { - const phaseInterface& interface = virtualMassModelIter()->interface(); - - Vms_.insert - ( - interface, - new volScalarField - ( - IOobject - ( - IOobject::groupName("Vm", interface.name()), - this->mesh().time().name(), - this->mesh() - ), - this->mesh(), - dimensionedScalar(virtualMassModel::dimK, 0) - ) - ); - - Vmfs_.insert - ( - interface, - new surfaceScalarField - ( - IOobject - ( - IOobject::groupName("Vmf", interface.name()), - this->mesh().time().name(), - this->mesh() - ), - this->mesh(), - dimensionedScalar(virtualMassModel::dimK, 0) - ) - ); - } } @@ -240,6 +156,36 @@ Foam::MomentumTransferPhaseSystem::momentumTransfer() ); } + // Initialise Kds table if required + if (!Kds_.size()) + { + forAllConstIter + ( + dragModelTable, + dragModels_, + dragModelIter + ) + { + const phaseInterface& interface = dragModelIter()->interface(); + + Kds_.insert + ( + dragModelIter.key(), + new volScalarField + ( + IOobject + ( + IOobject::groupName("Kd", interface.name()), + this->mesh().time().name(), + this->mesh() + ), + this->mesh(), + dimensionedScalar(dragModel::dimK, 0) + ) + ); + } + } + // Update the drag coefficients forAllConstIter ( @@ -249,7 +195,6 @@ Foam::MomentumTransferPhaseSystem::momentumTransfer() ) { *Kds_[dragModelIter.key()] = dragModelIter()->K(); - *Kdfs_[dragModelIter.key()] = dragModelIter()->Kf(); } // Add the implicit part of the drag force @@ -269,6 +214,37 @@ Foam::MomentumTransferPhaseSystem::momentumTransfer() } } + // Initialise Vms table if required + if (!Vms_.size()) + { + forAllConstIter + ( + virtualMassModelTable, + virtualMassModels_, + virtualMassModelIter + ) + { + const phaseInterface& interface = + virtualMassModelIter()->interface(); + + Vms_.insert + ( + interface, + new volScalarField + ( + IOobject + ( + IOobject::groupName("Vm", interface.name()), + this->mesh().time().name(), + this->mesh() + ), + this->mesh(), + dimensionedScalar(virtualMassModel::dimK, 0) + ) + ); + } + } + // Update the virtual mass coefficients forAllConstIter ( @@ -278,7 +254,6 @@ Foam::MomentumTransferPhaseSystem::momentumTransfer() ) { *Vms_[virtualMassModelIter.key()] = virtualMassModelIter()->K(); - *Vmfs_[virtualMassModelIter.key()] = virtualMassModelIter()->Kf(); } // Add the virtual mass force @@ -340,6 +315,106 @@ Foam::MomentumTransferPhaseSystem::momentumTransferf() ); } + // Initialise Kdfs table if required + if (!Kdfs_.size()) + { + forAllConstIter + ( + dragModelTable, + dragModels_, + dragModelIter + ) + { + const phaseInterface& interface = dragModelIter()->interface(); + + Kdfs_.insert + ( + dragModelIter.key(), + new surfaceScalarField + ( + IOobject + ( + IOobject::groupName("Kdf", interface.name()), + this->mesh().time().name(), + this->mesh() + ), + this->mesh(), + dimensionedScalar(dragModel::dimK, 0) + ) + ); + } + } + + // Update the drag coefficients + forAllConstIter + ( + dragModelTable, + dragModels_, + dragModelIter + ) + { + *Kdfs_[dragModelIter.key()] = dragModelIter()->Kf(); + } + + // Initialise Vms and Vmfs tables if required + if (!Vms_.size()) + { + forAllConstIter + ( + virtualMassModelTable, + virtualMassModels_, + virtualMassModelIter + ) + { + const phaseInterface& interface = + virtualMassModelIter()->interface(); + + Vms_.insert + ( + interface, + new volScalarField + ( + IOobject + ( + IOobject::groupName("Vm", interface.name()), + this->mesh().time().name(), + this->mesh() + ), + this->mesh(), + dimensionedScalar(virtualMassModel::dimK, 0) + ) + ); + + Vmfs_.insert + ( + interface, + new surfaceScalarField + ( + IOobject + ( + IOobject::groupName("Vmf", interface.name()), + this->mesh().time().name(), + this->mesh() + ), + this->mesh(), + dimensionedScalar(virtualMassModel::dimK, 0) + ) + ); + } + } + + // Update the virtual mass coefficients + forAllConstIter + ( + virtualMassModelTable, + virtualMassModels_, + virtualMassModelIter + ) + { + *Vms_[virtualMassModelIter.key()] = virtualMassModelIter()->K(); + *Vmfs_[virtualMassModelIter.key()] = virtualMassModelIter()->Kf(); + } + // Create U & grad(U) fields PtrList UgradUs(this->phaseModels_.size()); forAll(this->phaseModels_, phasei)