1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "ParamagneticForce.H"
27 #include "demandDrivenData.H"
28 #include "electromagneticConstants.H"
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 template<class CloudType>
33 Foam::ParamagneticForce<CloudType>::ParamagneticForce
37 const dictionary& dict
40 ParticleForce<CloudType>(owner, mesh, dict, typeName, true),
43 this->coeffs().template lookupOrDefault<word>("HdotGradH", "HdotGradH")
45 HdotGradHInterpPtr_(NULL),
46 magneticSusceptibility_
48 readScalar(this->coeffs().lookup("magneticSusceptibility"))
53 template<class CloudType>
54 Foam::ParamagneticForce<CloudType>::ParamagneticForce
56 const ParamagneticForce& pf
59 ParticleForce<CloudType>(pf),
60 HdotGradHName_(pf.HdotGradHName_),
61 HdotGradHInterpPtr_(pf.HdotGradHInterpPtr_),
62 magneticSusceptibility_(pf.magneticSusceptibility_)
66 // * * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * //
68 template<class CloudType>
69 Foam::ParamagneticForce<CloudType>::~ParamagneticForce()
73 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
75 template<class CloudType>
76 void Foam::ParamagneticForce<CloudType>::cacheFields(const bool store)
80 const volVectorField& HdotGradH =
81 this->mesh().template lookupObject<volVectorField>(HdotGradHName_);
83 HdotGradHInterpPtr_ = interpolation<vector>::New
85 this->owner().solution().interpolationSchemes(),
91 deleteDemandDrivenData(HdotGradHInterpPtr_);
96 template<class CloudType>
97 Foam::forceSuSp Foam::ParamagneticForce<CloudType>::calcNonCoupled
99 const typename CloudType::parcelType& p,
106 forceSuSp value(vector::zero, 0.0);
108 const interpolation<vector>& HdotGradHInterp = *HdotGradHInterpPtr_;
111 mass*3.0*constant::electromagnetic::mu0.value()/p.rho()
112 *magneticSusceptibility_/(magneticSusceptibility_ + 3)
113 *HdotGradHInterp.interpolate(p.position(), p.currentTetIndices());
119 // ************************************************************************* //