/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2023-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- 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 "CoulombForce.H" #include "demandDrivenData.H" // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // template Foam::volVectorField& Foam::CoulombForce::getOrReadField ( const word& fieldName ) const { auto* ptr = this->mesh().template getObjectPtr(fieldName); if (!ptr) { ptr = new volVectorField ( IOobject ( fieldName, this->mesh().time().timeName(), this->mesh().thisDb(), IOobject::MUST_READ, IOobject::AUTO_WRITE, IOobject::REGISTER ), this->mesh() ); regIOobject::store(ptr); } return *ptr; } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template Foam::CoulombForce::CoulombForce ( CloudType& owner, const fvMesh& mesh, const dictionary& dict ) : ParticleForce(owner, mesh, dict, typeName, true), qPtr_ ( Function1::New("q", this->coeffs(), &mesh) ), Ename_(this->coeffs().template getOrDefault("E", "E")), EInterpPtr_(nullptr) {} template Foam::CoulombForce::CoulombForce ( const CoulombForce& pf ) : ParticleForce(pf), qPtr_(pf.qPtr_.clone()), Ename_(pf.Ename_), EInterpPtr_(nullptr) {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template void Foam::CoulombForce::cacheFields(const bool store) { if (store) { const volVectorField& E = getOrReadField(Ename_); EInterpPtr_.reset ( interpolation::New ( this->owner().solution().interpolationSchemes(), E ).ptr() ); } else { EInterpPtr_.reset(nullptr); } } template Foam::forceSuSp Foam::CoulombForce::calcNonCoupled ( const typename CloudType::parcelType& p, const typename CloudType::parcelType::trackingData& td, const scalar dt, const scalar mass, const scalar Re, const scalar muc ) const { const interpolation& EInterp = *EInterpPtr_; const scalar q = qPtr_->value(p.d()); // (YSSD:Eq. 6 - left term) return forceSuSp ( q*EInterp.interpolate(p.coordinates(), p.currentTetIndices()), Zero ); } // ************************************************************************* //