/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Copyright (C) 2012-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 "ParticleTrap.H" #include "fvcGrad.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template Foam::ParticleTrap::ParticleTrap ( const dictionary& dict, CloudType& owner, const word& modelName ) : CloudFunctionObject(dict, owner, modelName, typeName), alphaName_ ( this->typeDict().template lookupOrDefault("alpha", "alpha") ), alphaPtr_(nullptr), gradAlphaPtr_(nullptr), threshold_(this->typeDict().template lookup("threshold")) {} template Foam::ParticleTrap::ParticleTrap ( const ParticleTrap& pt ) : CloudFunctionObject(pt), alphaName_(pt.alphaName_), alphaPtr_(pt.alphaPtr_), gradAlphaPtr_(nullptr), threshold_(pt.threshold_) {} // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // template Foam::ParticleTrap::~ParticleTrap() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template void Foam::ParticleTrap::preEvolve() { if (alphaPtr_ == nullptr) { const fvMesh& mesh = this->owner().mesh(); const volScalarField& alpha = mesh.lookupObject(alphaName_); alphaPtr_ = α } if (gradAlphaPtr_.valid()) { gradAlphaPtr_() == fvc::grad(*alphaPtr_); } else { gradAlphaPtr_.reset(new volVectorField(fvc::grad(*alphaPtr_))); } } template void Foam::ParticleTrap::postEvolve() { gradAlphaPtr_.clear(); } template void Foam::ParticleTrap::postMove ( parcelType& p, const scalar, const point&, bool& ) { if (alphaPtr_->primitiveField()[p.cell()] < threshold_) { const vector& gradAlpha = gradAlphaPtr_()[p.cell()]; vector nHat = gradAlpha/mag(gradAlpha); scalar nHatU = nHat & p.U(); if (nHatU < 0) { p.U() -= 2*nHat*nHatU; } } } // ************************************************************************* //