ENH: autoLayerDriver: better layering information message
[OpenFOAM-2.0.x.git] / src / lagrangian / intermediate / submodels / Kinematic / ParticleForces / PressureGradient / PressureGradientForce.C
bloba1d121ee2990e0bbd078f8f882f22de9e1d99dc8
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 "PressureGradientForce.H"
27 #include "fvcGrad.H"
29 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
31 template<class CloudType>
32 Foam::PressureGradientForce<CloudType>::PressureGradientForce
34     CloudType& owner,
35     const fvMesh& mesh,
36     const dictionary& dict
39     ParticleForce<CloudType>(owner, mesh, dict, typeName, true),
40     UName_(this->coeffs().lookup("U")),
41     gradUPtr_(NULL)
45 template<class CloudType>
46 Foam::PressureGradientForce<CloudType>::PressureGradientForce
48     const PressureGradientForce& pgf
51     ParticleForce<CloudType>(pgf),
52     UName_(pgf.UName_),
53     gradUPtr_(NULL)
57 // * * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * //
59 template<class CloudType>
60 Foam::PressureGradientForce<CloudType>::~PressureGradientForce()
64 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
66 template<class CloudType>
67 void Foam::PressureGradientForce<CloudType>::cacheFields(const bool store)
69     if (store)
70     {
71         const volVectorField& U = this->mesh().template
72             lookupObject<volVectorField>(UName_);
73         gradUPtr_ = fvc::grad(U).ptr();
74     }
75     else
76     {
77         if (gradUPtr_)
78         {
79             delete gradUPtr_;
80             gradUPtr_ = NULL;
81         }
82     }
86 template<class CloudType>
87 Foam::forceSuSp Foam::PressureGradientForce<CloudType>::calcCoupled
89     const typename CloudType::parcelType& p,
90     const scalar dt,
91     const scalar mass,
92     const scalar Re,
93     const scalar muc
94 ) const
96     forceSuSp value(vector::zero, 0.0);
98     const volTensorField& gradU = *gradUPtr_;
99     value.Su() = mass*p.rhoc()/p.rho()*(p.U() & gradU[p.cell()]);
101     return value;
105 // ************************************************************************* //