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";
110 const volScalarField& rhoNMean = obr_.lookupObject<volScalarField>
115 const volScalarField& rhoMMean = obr_.lookupObject<volScalarField>
120 const volVectorField& momentumMean = obr_.lookupObject<volVectorField>
125 const volScalarField& linearKEMean = obr_.lookupObject<volScalarField>
130 const volScalarField& internalEMean = obr_.lookupObject<volScalarField>
135 const volScalarField& iDofMean = obr_.lookupObject<volScalarField>
140 if (min(mag(rhoNMean)).value() > VSMALL)
142 Info<< "Calculating dsmcFields." << endl;
144 Info<< " Calculating UMean field." << endl;
150 obr_.time().timeName(),
154 momentumMean/rhoMMean
157 Info<< " Calculating translationalT field." << endl;
158 volScalarField translationalT
163 obr_.time().timeName(),
167 2.0/(3.0*dsmcCloud::kb*rhoNMean)
168 *(linearKEMean - 0.5*rhoMMean*(UMean & UMean))
171 Info<< " Calculating internalT field." << endl;
172 volScalarField internalT
177 obr_.time().timeName(),
181 2.0/(dsmcCloud::kb*iDofMean)*internalEMean
184 Info<< " Calculating overallT field." << endl;
185 volScalarField overallT
190 obr_.time().timeName(),
194 2.0/(dsmcCloud::kb*(3.0*rhoNMean + iDofMean))
195 *(linearKEMean - 0.5*rhoMMean*(UMean & UMean) + internalEMean)
198 Info<< " mag(UMean) max/min : "
199 << max(mag(UMean)).value() << " "
200 << min(mag(UMean)).value() << endl;
202 Info<< " translationalT max/min : "
203 << max(translationalT).value() << " "
204 << min(translationalT).value() << endl;
206 Info<< " internalT max/min : "
207 << max(internalT).value() << " "
208 << min(internalT).value() << endl;
210 Info<< " overallT max/min : "
211 << max(overallT).value() << " "
212 << min(overallT).value() << endl;
216 translationalT.write();
222 Info<< "dsmcFields written." << nl << endl;
226 Info<< "Small value (" << min(mag(rhoNMean))
227 << ") found in rhoNMean field. "
228 << "Not calculating dsmcFields to avoid division by zero."
235 // ************************************************************************* //