OpenFOAM-dev / data /src /Lagrangian /cloudFunctionObjects /cloudBoundaryCollisionFlux /cloudBoundaryCollisionFlux.C
Download data/src/Lagrangian/cloudFunctionObjects/cloudBoundaryCollisionFlux/cloudBoundaryCollisionFlux.C from introvoyz042/OpenFOAM-dev: direct link, hf CLI and curl.
- Browser
- Download file 7.26 kB
-
https://huggingface.co/datasets/introvoyz042/OpenFOAM-dev/resolve/main/data/src/Lagrangian/cloudFunctionObjects/cloudBoundaryCollisionFlux/cloudBoundaryCollisionFlux.C
- Command line
-
hf download hf://datasets/introvoyz042/OpenFOAM-dev/data/src/Lagrangian/cloudFunctionObjects/cloudBoundaryCollisionFlux/cloudBoundaryCollisionFlux.C
-
curl -L -o cloudBoundaryCollisionFlux.C https://huggingface.co/datasets/introvoyz042/OpenFOAM-dev/resolve/main/data/src/Lagrangian/cloudFunctionObjects/cloudBoundaryCollisionFlux/cloudBoundaryCollisionFlux.C
7.26 kB
| /*---------------------------------------------------------------------------*\ | |
| ========= | | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | |
| \\ / O peration | Website: https://openfoam.org | |
| \\ / A nd | Copyright (C) 2025-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 <http://www.gnu.org/licenses/>. | |
| \*---------------------------------------------------------------------------*/ | |
| // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // | |
| namespace Foam | |
| { | |
| namespace functionObjects | |
| { | |
| defineTypeNameAndDebug(cloudBoundaryCollisionFlux, 0); | |
| } | |
| } | |
| // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // | |
| Foam::functionObjects::cloudBoundaryCollisionFlux::cloudBoundaryCollisionFlux | |
| ( | |
| const word& name, | |
| const Time& runTime, | |
| const dictionary& dict, | |
| const word& phiName, | |
| const dimensionSet& phiDims | |
| ) | |
| : | |
| cloudFvMeshFunctionObject(name, runTime, dict), | |
| prociPtr_(nullptr), | |
| faceiPtr_(nullptr), | |
| qPtr_(nullptr), | |
| phiName_(phiName), | |
| phiDims_(phiDims), | |
| phib_ | |
| ( | |
| mesh().boundary(), | |
| surfaceScalarField::Internal::null(), | |
| calculatedFvsPatchField<scalar>::typeName | |
| ) | |
| {} | |
| // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // | |
| Foam::functionObjects::cloudBoundaryCollisionFlux::~cloudBoundaryCollisionFlux() | |
| {} | |
| // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // | |
| Foam::wordList Foam::functionObjects::cloudBoundaryCollisionFlux::fields() const | |
| { | |
| return wordList::null(); | |
| } | |
| bool Foam::functionObjects::cloudBoundaryCollisionFlux::executeAtStart() const | |
| { | |
| return false; | |
| } | |
| bool Foam::functionObjects::cloudBoundaryCollisionFlux::execute() | |
| { | |
| return true; | |
| } | |
| void Foam::functionObjects::cloudBoundaryCollisionFlux::preSolve() | |
| { | |
| phib_ == Zero; | |
| } | |
| void Foam::functionObjects::cloudBoundaryCollisionFlux::preCrossFaces | |
| ( | |
| const LagrangianInternalScalarDynamicField& fraction | |
| ) | |
| { | |
| if (Pstream::parRun()) | |
| { | |
| prociPtr_.set | |
| ( | |
| new LagrangianLabelDynamicField | |
| ( | |
| IOobject | |
| ( | |
| name() + ":proci", | |
| time_.name(), | |
| cloud().mesh() | |
| ), | |
| cloud().mesh(), | |
| dimensioned<label>(dimless, -1) | |
| ) | |
| ); | |
| } | |
| faceiPtr_.set | |
| ( | |
| new LagrangianLabelDynamicField | |
| ( | |
| IOobject | |
| ( | |
| name() + ":facei", | |
| time_.name(), | |
| cloud().mesh() | |
| ), | |
| cloud().mesh(), | |
| dimensioned<label>(dimless, -1) | |
| ) | |
| ); | |
| qPtr_.set | |
| ( | |
| new LagrangianScalarDynamicField | |
| ( | |
| IOobject | |
| ( | |
| name() + ":q", | |
| time_.name(), | |
| cloud().mesh() | |
| ), | |
| cloud().mesh(), | |
| dimensionedScalar(phiDims_*dimensions::time, scalar(0)) | |
| ) | |
| ); | |
| } | |
| void Foam::functionObjects::cloudBoundaryCollisionFlux::preCrossFaces | |
| ( | |
| const LagrangianSubScalarSubField& fraction | |
| ) | |
| { | |
| const LagrangianSubMesh& subMesh = fraction.mesh(); | |
| if | |
| ( | |
| faceiPtr_.empty() | |
| || subMesh.group() == LagrangianGroup::none | |
| || subMesh.group() == LagrangianGroup::inInternalMesh | |
| ) return; | |
| const Foam::cloud& c = cloud(); | |
| if (Pstream::parRun()) | |
| { | |
| SubField<label> proci(subMesh.sub(prociPtr_->primitiveFieldRef())); | |
| proci = Pstream::myProcNo(); | |
| } | |
| SubField<label> facei(subMesh.sub(faceiPtr_->primitiveFieldRef())); | |
| facei = subMesh.sub(c.mesh().facei()); | |
| LagrangianSubScalarSubField q(subMesh.sub(qPtr_())); | |
| q += this->q(fraction, +1); | |
| } | |
| void Foam::functionObjects::cloudBoundaryCollisionFlux::postCrossFaces | |
| ( | |
| const LagrangianSubScalarSubField& fraction | |
| ) | |
| { | |
| const LagrangianSubMesh& subMesh = fraction.mesh(); | |
| if | |
| ( | |
| faceiPtr_.empty() | |
| || subMesh.group() == LagrangianGroup::none | |
| || subMesh.group() == LagrangianGroup::inInternalMesh | |
| ) return; | |
| const Foam::cloud& c = cloud(); | |
| auto proci0EqualsProci = [&](const label subi) | |
| { | |
| if (!Pstream::parRun()) return true; | |
| return | |
| prociPtr_->primitiveFieldRef()[subi + subMesh.start()] | |
| == Pstream::myProcNo(); | |
| }; | |
| const SubField<label> facei0 = subMesh.sub(faceiPtr_->primitiveFieldRef()); | |
| const SubField<label> facei = subMesh.sub(c.mesh().facei()); | |
| LagrangianSubScalarSubField q(subMesh.sub(qPtr_())); | |
| q += this->q(fraction, -1); | |
| const surfaceScalarField::BoundaryField& magSfb = | |
| mesh().magSf().boundaryField(); | |
| forAll(subMesh, subi) | |
| { | |
| // The particle must be on the same face to count as a collision | |
| if (!proci0EqualsProci(subi) || facei0[subi] != facei[subi]) continue; | |
| const label bFacei = facei[subi] - mesh().nInternalFaces(); | |
| const labelUList patchis = mesh().polyBFacePatches()[bFacei]; | |
| const labelUList patchFaceis = mesh().polyBFacePatchFaces()[bFacei]; | |
| forAll(patchis, i) | |
| { | |
| const scalar fraction = | |
| magSfb[patchis[i]][patchFaceis[i]] | |
| /mesh().magFaceAreas()[facei[subi]]; | |
| phib_[patchis[i]][patchFaceis[i]] += | |
| fraction*q[subi]/time_.deltaTValue(); | |
| } | |
| } | |
| } | |
| void Foam::functionObjects::cloudBoundaryCollisionFlux::postCrossFaces | |
| ( | |
| const LagrangianInternalScalarDynamicField& fraction | |
| ) | |
| { | |
| prociPtr_.clear(); | |
| faceiPtr_.clear(); | |
| qPtr_.clear(); | |
| } | |
| bool Foam::functionObjects::cloudBoundaryCollisionFlux::write() | |
| { | |
| return | |
| surfaceScalarField | |
| ( | |
| IOobject | |
| ( | |
| word(cloud().mesh().name(), ':', phiName_, "Coll"), | |
| time_.name(), | |
| mesh(), | |
| IOobject::NO_READ, | |
| IOobject::AUTO_WRITE | |
| ), | |
| mesh(), | |
| phiDims_, | |
| scalarField(mesh().nInternalFaces(), scalar(0)), | |
| phib_ | |
| ).write(); | |
| } | |
| bool Foam::functionObjects::cloudBoundaryCollisionFlux::clear() | |
| { | |
| return true; | |
| } | |
| // ************************************************************************* // | |