/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Copyright (C) 2019-2026 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 "volumeBlockage.H" #include "fvmDiv.H" #include "fvmLaplacian.H" #include "fviDiv.H" #include "surfaceInterpolate.H" #include "fluidThermophysicalTransportModel.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { namespace fv { defineTypeNameAndDebug(volumeBlockage, 0); addToRunTimeSelectionTable(fvModel, volumeBlockage, dictionary); addBackwardCompatibleToRunTimeSelectionTable ( fvModel, volumeBlockage, dictionary, volumeFractionSource, "volumeFractionSource" ); } } // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // void Foam::fv::volumeBlockage::readCoeffs(const dictionary& dict) { phiName_ = dict.lookupOrDefault("phi", "phi"); rhoName_ = dict.lookupOrDefault("rho", "rho"); UName_ = dict.lookupOrDefault("U", "U"); volumePhaseName_ = dict.lookup("volumePhase"); } const Foam::volScalarField& Foam::fv::volumeBlockage::volumeAlpha() const { const word alphaName = IOobject::groupName("alpha", volumePhaseName_); if (!mesh().foundObject(alphaName)) { volScalarField* alphaPtr = new volScalarField ( IOobject ( alphaName, mesh().time().constant(), mesh(), IOobject::MUST_READ, IOobject::NO_WRITE ), mesh(), dimless ); alphaPtr->store(); } return mesh().lookupObject(alphaName); } Foam::tmp Foam::fv::volumeBlockage::D ( const word& fieldName ) const { const word phiName = IOobject::groupName(phiName_, IOobject::group(fieldName)); const surfaceScalarField& phi = mesh().lookupObject(phiName); if (phi.dimensions() == dimensions::volumetricFlux) { const momentumTransportModel& turbulence = mesh().lookupType(); return turbulence.nuEff(); } else if (phi.dimensions() == dimensions::massFlux) { const fluidThermophysicalTransportModel& ttm = mesh().lookupType(); if (fieldName == ttm.thermo().T().name()) { return ttm.kappaEff(); } else { if (fieldName == ttm.thermo().he().name()) { return ttm.kappaEff()/ttm.thermo().Cpv(); } else { return ttm.momentumTransport().rho() *ttm.momentumTransport().nuEff(); } } } else { FatalErrorInFunction << "Dimensions of " << phi.name() << " not recognised" << exit(FatalError); return tmp(nullptr); } } template void Foam::fv::volumeBlockage::addGeneralSupType ( const AlphaFieldType& alpha, fvMatrix& eqn ) const { const word phiName = IOobject::groupName(phiName_, IOobject::group(eqn.psi().name())); const surfaceScalarField& phi = mesh().lookupObject(phiName); const volScalarField B(1 - volumeAlpha()); const volInternalScalarField AByB(volumeAlpha()()/B()); const volScalarField D(this->D(eqn.psi().name())); // Divergence term const word divScheme("div(", phiName, ',', eqn.psi().name(), ')'); eqn -= AByB*fvm::div(phi, eqn.psi(), divScheme); // Laplacian term const word laplacianScheme ( "laplacian(", D.name(), ',', eqn.psi().name(), ')' ); eqn += fvm::laplacian(D, eqn.psi()) - 1/B()*fvm::laplacian(B*D, eqn.psi(), laplacianScheme); } template void Foam::fv::volumeBlockage::addAlphaSupType ( const AlphaFieldType& alpha, const VolField& field, fvMatrix& eqn ) const { addGeneralSupType(alpha, eqn); } template void Foam::fv::volumeBlockage::addAlphaSupType ( const AlphaFieldType& alpha, const volScalarField& field, fvMatrix& eqn ) const { if (IOobject::member(field.name()) == rhoName_) { const word phiName = IOobject::groupName(phiName_, IOobject::group(field.name())); const surfaceScalarField& phi = mesh().lookupObject(phiName); const volScalarField AByB(volumeAlpha()/(1 - volumeAlpha())); eqn -= AByB()*fvi::div(phi); } else { addGeneralSupType(alpha, eqn); } } template void Foam::fv::volumeBlockage::addAlphaSupType ( const AlphaFieldType& alpha, const volVectorField& field, fvMatrix& eqn ) const { if (IOobject::member(field.name()) == UName_) { const word phiName = IOobject::groupName(phiName_, IOobject::group(field.name())); const surfaceScalarField& phi = mesh().lookupObject(phiName); const volScalarField AByB(volumeAlpha()/(1 - volumeAlpha())); const word scheme("div(", phiName, ',', eqn.psi().name(), ')'); eqn -= fvi::div(fvc::interpolate(AByB)*phi, eqn.psi(), scheme); } else { addGeneralSupType(alpha, eqn); } } template void Foam::fv::volumeBlockage::addSupType ( const VolField& field, fvMatrix& eqn ) const { addAlphaSupType(geometricOneField(), field, eqn); } template void Foam::fv::volumeBlockage::addSupType ( const volScalarField& rho, const VolField& field, fvMatrix& eqn ) const { addAlphaSupType(geometricOneField(), field, eqn); } template void Foam::fv::volumeBlockage::addSupType ( const volScalarField& alpha, const volScalarField& rho, const VolField& field, fvMatrix& eqn ) const { addAlphaSupType(alpha, field, eqn); } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::fv::volumeBlockage::volumeBlockage ( const word& name, const word& modelType, const fvMesh& mesh, const dictionary& dict ) : fvModel(name, modelType, mesh, dict), phiName_(word::null), rhoName_(word::null), UName_(word::null), volumePhaseName_(word::null) { readCoeffs(coeffs(dict)); volumeAlpha(); } // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // Foam::fv::volumeBlockage::~volumeBlockage() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // bool Foam::fv::volumeBlockage::addsSupToField(const word& fieldName) const { return true; } Foam::wordList Foam::fv::volumeBlockage::addSupFields() const { return wordList(); } FOR_ALL_FIELD_TYPES(IMPLEMENT_FV_MODEL_ADD_FIELD_SUP, fv::volumeBlockage) FOR_ALL_FIELD_TYPES(IMPLEMENT_FV_MODEL_ADD_RHO_FIELD_SUP, fv::volumeBlockage) FOR_ALL_FIELD_TYPES ( IMPLEMENT_FV_MODEL_ADD_ALPHA_RHO_FIELD_SUP, fv::volumeBlockage ) bool Foam::fv::volumeBlockage::movePoints() { return true; } void Foam::fv::volumeBlockage::topoChange(const polyTopoChangeMap&) {} void Foam::fv::volumeBlockage::mapMesh(const polyMeshMap& map) {} void Foam::fv::volumeBlockage::distribute(const polyDistributionMap&) {} bool Foam::fv::volumeBlockage::read(const dictionary& dict) { if (fvModel::read(dict)) { readCoeffs(coeffs(dict)); return true; } else { return false; } } // ************************************************************************* //