Added measurement of surface values of velocity and temperature to allow slip
[OpenFOAM-1.6.x.git] / src / postProcessing / functionObjects / utilities / dsmcFields / dsmcFields.C
blobcbc00df7717586b712996cb42295260233e4fbac
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";
109         word fDMeanName = "fDMean";
111         const volScalarField& rhoNMean = obr_.lookupObject<volScalarField>
112         (
113             rhoNMeanName
114         );
116         const volScalarField& rhoMMean = obr_.lookupObject<volScalarField>
117         (
118             rhoMMeanName
119         );
121         const volVectorField& momentumMean = obr_.lookupObject<volVectorField>
122         (
123             momentumMeanName
124         );
126         const volScalarField& linearKEMean = obr_.lookupObject<volScalarField>
127         (
128             linearKEMeanName
129         );
131         const volScalarField& internalEMean = obr_.lookupObject<volScalarField>
132         (
133             internalEMeanName
134         );
136         const volScalarField& iDofMean = obr_.lookupObject<volScalarField>
137         (
138             iDofMeanName
139         );
141         volVectorField fDMean =  obr_.lookupObject<volVectorField>
142         (
143             fDMeanName
144         );
146         if (min(mag(rhoNMean)).value() > VSMALL)
147         {
148             Info<< "Calculating dsmcFields." << endl;
150             Info<< "    Calculating UMean field." << endl;
151             volVectorField UMean
152             (
153                 IOobject
154                 (
155                     "UMean",
156                     obr_.time().timeName(),
157                     obr_,
158                     IOobject::NO_READ
159                 ),
160                 momentumMean/rhoMMean
161             );
163             Info<< "    Calculating translationalT field." << endl;
164             volScalarField translationalT
165             (
166                 IOobject
167                 (
168                     "translationalT",
169                     obr_.time().timeName(),
170                     obr_,
171                     IOobject::NO_READ
172                 ),
173                 2.0/(3.0*dsmcCloud::kb*rhoNMean)
174                 *(linearKEMean - 0.5*rhoMMean*(UMean & UMean))
175             );
177             Info<< "    Calculating internalT field." << endl;
178             volScalarField internalT
179             (
180                 IOobject
181                 (
182                     "internalT",
183                     obr_.time().timeName(),
184                     obr_,
185                     IOobject::NO_READ
186                 ),
187                 (2.0/dsmcCloud::kb)*(internalEMean/iDofMean)
188             );
190             Info<< "    Calculating overallT field." << endl;
191             volScalarField overallT
192             (
193                 IOobject
194                 (
195                     "overallT",
196                     obr_.time().timeName(),
197                     obr_,
198                     IOobject::NO_READ
199                 ),
200                 2.0/(dsmcCloud::kb*(3.0*rhoNMean + iDofMean))
201                *(linearKEMean - 0.5*rhoMMean*(UMean & UMean) + internalEMean)
202             );
204             Info<< "    Calculating pressure field." << endl;
205             volScalarField p
206             (
207                 IOobject
208                 (
209                     "p",
210                     obr_.time().timeName(),
211                     obr_,
212                     IOobject::NO_READ
213                 ),
214                 dsmcCloud::kb*rhoNMean*translationalT
215             );
217             const fvMesh& mesh = fDMean.mesh();
219             forAll(mesh.boundaryMesh(), i)
220             {
221                 const polyPatch& patch = mesh.boundaryMesh()[i];
223                 if (isA<wallPolyPatch>(patch))
224                 {
225                     p.boundaryField()[i] =
226                         fDMean.boundaryField()[i]
227                       & (patch.faceAreas()/mag(patch.faceAreas()));
228                 }
229             }
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;
251             UMean.write();
253             translationalT.write();
255             internalT.write();
257             overallT.write();
259             p.write();
261             Info<< "dsmcFields written." << nl << endl;
262         }
263         else
264         {
265             Info<< "Small value (" << min(mag(rhoNMean))
266                 << ") found in rhoNMean field. "
267                 << "Not calculating dsmcFields to avoid division by zero."
268                 << endl;
269         }
270     }
274 // ************************************************************************* //