OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

writeFluentScalarField.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Description
00026     Given a volScalarField and Fluent field identifier, write the field in
00027     Fluent data format
00028 
00029 
00030 \*---------------------------------------------------------------------------*/
00031 
00032 #include "writeFluentFields.H"
00033 #include "emptyFvPatchFields.H"
00034 
00035 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00036 
00037 namespace Foam
00038 {
00039 
00040 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00041 
00042 void writeFluentField
00043 (
00044     const volScalarField& phi,
00045     const label fluentFieldIdentifier,
00046     Ostream& stream
00047 )
00048 {
00049     const scalarField& phiInternal = phi.internalField();
00050 
00051     // Writing cells
00052     stream
00053         << "(300 ("
00054         << fluentFieldIdentifier << " "  // Field identifier
00055         << "1 "                  // Zone ID: (cells=1, internal faces=2,
00056                                  // patch faces=patchI+10)
00057         << "1 "                  // Number of components (scalar=1, vector=3)
00058         << "0 0 "                // Unused
00059         << "1 " << phiInternal.size() // Start and end of list
00060         << ")(" << endl;
00061 
00062     forAll (phiInternal, cellI)
00063     {
00064         stream << phiInternal[cellI] << endl;
00065     }
00066 
00067     stream
00068         << "))" << endl;
00069 
00070     label nWrittenFaces = phiInternal.size();
00071 
00072     // Writing boundary faces
00073     forAll (phi.boundaryField(), patchI)
00074     {
00075         if (isType<emptyFvPatchScalarField>(phi.boundaryField()[patchI]))
00076         {
00077             // Form empty patch field repeat the internal field to
00078             // allow for the node interpolation in Fluent
00079             const scalarField& phiInternal = phi.internalField();
00080 
00081             // Get reference to internal cells
00082             const labelList emptyFaceCells =
00083                 phi.boundaryField()[patchI].patch().patch().faceCells();
00084 
00085             // Writing cells for empty patch
00086             stream
00087                 << "(300 ("
00088                 << fluentFieldIdentifier << " "  // Field identifier
00089                 << patchI + 10 << " "            // Zone ID: patchI+10
00090                 << "1 "             // Number of components (scalar=1, vector=3)
00091                 << "0 0 "                // Unused
00092                 << nWrittenFaces + 1 << " "
00093                 << nWrittenFaces + emptyFaceCells.size()// Start and end of list
00094                 << ")(" << endl;
00095 
00096             nWrittenFaces += emptyFaceCells.size();
00097 
00098             forAll (emptyFaceCells, faceI)
00099             {
00100                 stream << phiInternal[emptyFaceCells[faceI]] << endl;
00101             }
00102 
00103             stream
00104                 << "))" << endl;
00105         }
00106         else
00107         {
00108             // Regular patch
00109             label nWrittenFaces = phiInternal.size();
00110 
00111             const scalarField& patchPhi = phi.boundaryField()[patchI];
00112 
00113             // Write header
00114             stream
00115                 << "(300 ("
00116                 << fluentFieldIdentifier << " "  // Field identifier
00117                 << patchI + 10 << " "            // Zone ID: patchI+10
00118                 << "1 "          // Number of components (scalar=1, vector=3)
00119                 << "0 0 "            // Unused
00120                 << nWrittenFaces + 1 << " " << nWrittenFaces + patchPhi.size()
00121                                  // Start and end of list
00122                 << ")(" << endl;
00123 
00124             nWrittenFaces += patchPhi.size();
00125 
00126             forAll (patchPhi, faceI)
00127             {
00128                 stream << patchPhi[faceI] << endl;
00129             }
00130 
00131             stream
00132                 << "))" << endl;
00133         }
00134     }
00135 }
00136 
00137 
00138 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00139 
00140 } // End namespace Foam
00141 
00142 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd