initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / postProcessing / functionObjects / utilities / dsmcFields / dsmcFields.C
blob8957dee17cda6ce696f191b04e79c4347f020994
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2009-2009 OpenCFD Ltd.
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 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
19     for more details.
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 * * * * * * * * * * * * * //
34 namespace Foam
36     defineTypeNameAndDebug(dsmcFields, 0);
40 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
42 Foam::dsmcFields::dsmcFields
44     const word& name,
45     const objectRegistry& obr,
46     const dictionary& dict,
47     const bool loadFromFiles
50     name_(name),
51     obr_(obr),
52     active_(true)
54     // Check if the available mesh is an fvMesh, otherwise deactivate
55     if (!isA<fvMesh>(obr_))
56     {
57         active_ = false;
58         WarningIn
59         (
60             "dsmcFields::dsmcFields"
61             "(const objectRegistry&, const dictionary&)"
62         )   << "No fvMesh available, deactivating." << nl
63             << endl;
64     }
66     read(dict);
70 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
72 Foam::dsmcFields::~dsmcFields()
76 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
78 void Foam::dsmcFields::read(const dictionary& dict)
80     if (active_)
81     {
83     }
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()
101     if (active_)
102     {
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>
111         (
112             rhoNMeanName
113         );
115         const volScalarField& rhoMMean = obr_.lookupObject<volScalarField>
116         (
117             rhoMMeanName
118         );
120         const volVectorField& momentumMean = obr_.lookupObject<volVectorField>
121         (
122             momentumMeanName
123         );
125         const volScalarField& linearKEMean = obr_.lookupObject<volScalarField>
126         (
127             linearKEMeanName
128         );
130         const volScalarField& internalEMean = obr_.lookupObject<volScalarField>
131         (
132             internalEMeanName
133         );
135         const volScalarField& iDofMean = obr_.lookupObject<volScalarField>
136         (
137             iDofMeanName
138         );
140         if (min(mag(rhoNMean)).value() > VSMALL)
141         {
142             Info<< "Calculating dsmcFields." << endl;
144             Info<< "    Calculating UMean field." << endl;
145             volVectorField UMean
146             (
147                 IOobject
148                 (
149                     "UMean",
150                     obr_.time().timeName(),
151                     obr_,
152                     IOobject::NO_READ
153                 ),
154                 momentumMean/rhoMMean
155             );
157             Info<< "    Calculating translationalT field." << endl;
158             volScalarField translationalT
159             (
160                 IOobject
161                 (
162                     "translationalT",
163                     obr_.time().timeName(),
164                     obr_,
165                     IOobject::NO_READ
166                 ),
167                 2.0/(3.0*dsmcCloud::kb*rhoNMean)
168                 *(linearKEMean - 0.5*rhoMMean*(UMean & UMean))
169             );
171             Info<< "    Calculating internalT field." << endl;
172             volScalarField internalT
173             (
174                 IOobject
175                 (
176                     "internalT",
177                     obr_.time().timeName(),
178                     obr_,
179                     IOobject::NO_READ
180                 ),
181                 2.0/(dsmcCloud::kb*iDofMean)*internalEMean
182             );
184             Info<< "    Calculating overallT field." << endl;
185             volScalarField overallT
186             (
187                 IOobject
188                 (
189                     "overallT",
190                     obr_.time().timeName(),
191                     obr_,
192                     IOobject::NO_READ
193                 ),
194                 2.0/(dsmcCloud::kb*(3.0*rhoNMean + iDofMean))
195                 *(linearKEMean - 0.5*rhoMMean*(UMean & UMean) + internalEMean)
196             );
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;
214             UMean.write();
216             translationalT.write();
218             internalT.write();
220             overallT.write();
222             Info<< "dsmcFields written." << nl << endl;
223         }
224         else
225         {
226             Info<< "Small value (" << min(mag(rhoNMean))
227                 << ") found in rhoNMean field. "
228                 << "Not calculating dsmcFields to avoid division by zero."
229                 << endl;
230         }
231     }
235 // ************************************************************************* //