1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 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, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "dsmcFields.H"
28 #include "volFields.H"
29 #include "dictionary.H"
30 #include "dsmcCloud.H"
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36 defineTypeNameAndDebug(dsmcFields, 0);
40 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
42 Foam::dsmcFields::dsmcFields
45 const objectRegistry& obr,
46 const dictionary& dict,
47 const bool loadFromFiles
54 // Check if the available mesh is an fvMesh, otherwise deactivate
55 if (!isA<fvMesh>(obr_))
60 "dsmcFields::dsmcFields"
61 "(const objectRegistry&, const dictionary&)"
62 ) << "No fvMesh available, deactivating." << nl
70 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
72 Foam::dsmcFields::~dsmcFields()
76 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
78 void Foam::dsmcFields::read(const dictionary& dict)
87 void Foam::dsmcFields::execute()
89 // Do nothing - only valid on write
93 void Foam::dsmcFields::end()
95 // Do nothing - only valid on write
99 void Foam::dsmcFields::write()
103 word rhoNMeanName = "rhoNMean";
104 word rhoMMeanName = "rhoMMean";
105 word momentumMeanName = "momentumMean";
106 word linearKEMeanName = "linearKEMean";
107 word internalEMeanName = "internalEMean";
108 word iDofMeanName = "iDofMean";
109 word fDMeanName = "fDMean";
111 const volScalarField& rhoNMean = obr_.lookupObject<volScalarField>
116 const volScalarField& rhoMMean = obr_.lookupObject<volScalarField>
121 const volVectorField& momentumMean = obr_.lookupObject<volVectorField>
126 const volScalarField& linearKEMean = obr_.lookupObject<volScalarField>
131 const volScalarField& internalEMean = obr_.lookupObject<volScalarField>
136 const volScalarField& iDofMean = obr_.lookupObject<volScalarField>
141 volVectorField fDMean = obr_.lookupObject<volVectorField>
146 if (min(mag(rhoNMean)).value() > VSMALL)
148 Info<< "Calculating dsmcFields." << endl;
150 Info<< " Calculating UMean field." << endl;
156 obr_.time().timeName(),
160 momentumMean/rhoMMean
163 Info<< " Calculating translationalT field." << endl;
164 volScalarField translationalT
169 obr_.time().timeName(),
173 2.0/(3.0*dsmcCloud::kb*rhoNMean)
174 *(linearKEMean - 0.5*rhoMMean*(UMean & UMean))
177 Info<< " Calculating internalT field." << endl;
178 volScalarField internalT
183 obr_.time().timeName(),
187 (2.0/dsmcCloud::kb)*(internalEMean/iDofMean)
190 Info<< " Calculating overallT field." << endl;
191 volScalarField overallT
196 obr_.time().timeName(),
200 2.0/(dsmcCloud::kb*(3.0*rhoNMean + iDofMean))
201 *(linearKEMean - 0.5*rhoMMean*(UMean & UMean) + internalEMean)
204 Info<< " Calculating pressure field." << endl;
210 obr_.time().timeName(),
214 dsmcCloud::kb*rhoNMean*translationalT
217 const fvMesh& mesh = fDMean.mesh();
219 forAll(mesh.boundaryMesh(), i)
221 const polyPatch& patch = mesh.boundaryMesh()[i];
223 if (isA<wallPolyPatch>(patch))
225 p.boundaryField()[i] =
226 fDMean.boundaryField()[i]
227 & (patch.faceAreas()/mag(patch.faceAreas()));
231 Info<< " mag(UMean) max/min : "
232 << max(mag(UMean)).value() << " "
233 << min(mag(UMean)).value() << endl;
235 Info<< " translationalT max/min : "
236 << max(translationalT).value() << " "
237 << min(translationalT).value() << endl;
239 Info<< " internalT max/min : "
240 << max(internalT).value() << " "
241 << min(internalT).value() << endl;
243 Info<< " overallT max/min : "
244 << max(overallT).value() << " "
245 << min(overallT).value() << endl;
247 Info<< " p max/min : "
248 << max(p).value() << " "
249 << min(p).value() << endl;
253 translationalT.write();
261 Info<< "dsmcFields written." << nl << endl;
265 Info<< "Small value (" << min(mag(rhoNMean))
266 << ") found in rhoNMean field. "
267 << "Not calculating dsmcFields to avoid division by zero."
274 // ************************************************************************* //