ENH: autoLayerDriver: better layering information message
[OpenFOAM-2.0.x.git] / src / lagrangian / intermediate / submodels / Kinematic / ParticleForces / Paramagnetic / ParamagneticForce.C
blob62628e61788fa33e00d33313960feb060ded9338
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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
35     CloudType& owner,
36     const fvMesh& mesh,
37     const dictionary& dict
40     ParticleForce<CloudType>(owner, mesh, dict, typeName, true),
41     HdotGradHName_
42     (
43         this->coeffs().template lookupOrDefault<word>("HdotGradH", "HdotGradH")
44     ),
45     HdotGradHInterpPtr_(NULL),
46     magneticSusceptibility_
47     (
48         readScalar(this->coeffs().lookup("magneticSusceptibility"))
49     )
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)
78     if (store)
79     {
80         const volVectorField& HdotGradH =
81             this->mesh().template lookupObject<volVectorField>(HdotGradHName_);
83         HdotGradHInterpPtr_ = interpolation<vector>::New
84         (
85             this->owner().solution().interpolationSchemes(),
86             HdotGradH
87         ).ptr();
88     }
89     else
90     {
91         deleteDemandDrivenData(HdotGradHInterpPtr_);
92     }
96 template<class CloudType>
97 Foam::forceSuSp Foam::ParamagneticForce<CloudType>::calcNonCoupled
99     const typename CloudType::parcelType& p,
100     const scalar dt,
101     const scalar mass,
102     const scalar Re,
103     const scalar muc
104 ) const
106     forceSuSp value(vector::zero, 0.0);
108     const interpolation<vector>& HdotGradHInterp = *HdotGradHInterpPtr_;
110     value.Su()=
111         mass*3.0*constant::electromagnetic::mu0.value()/p.rho()
112        *magneticSusceptibility_/(magneticSusceptibility_ + 3)
113        *HdotGradHInterp.interpolate(p.position(), p.currentTetIndices());
115     return value;
119 // ************************************************************************* //