FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 Description
00025     Given a volScalarField and Fluent field identifier, write the field in
00026     Fluent data format
00027 
00028 
00029 \*---------------------------------------------------------------------------*/
00030 
00031 #include "writeFluentFields.H"
00032 #include <finiteVolume/emptyFvPatchFields.H>
00033 
00034 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00035 
00036 namespace Foam
00037 {
00038 
00039 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00040 
00041 void writeFluentField
00042 (
00043     const volScalarField& phi,
00044     const label fluentFieldIdentifier,
00045     Ostream& stream
00046 )
00047 {
00048     const scalarField& phiInternal = phi.internalField();
00049 
00050     // Writing cells
00051     stream
00052         << "(300 ("
00053         << fluentFieldIdentifier << " "  // Field identifier
00054         << "1 "                  // Zone ID: (cells=1, internal faces=2,
00055                                  // patch faces=patchI+10)
00056         << "1 "                  // Number of components (scalar=1, vector=3)
00057         << "0 0 "                // Unused
00058         << "1 " << phiInternal.size() // Start and end of list
00059         << ")(" << endl;
00060 
00061     forAll (phiInternal, cellI)
00062     {
00063         stream << phiInternal[cellI] << endl;
00064     }
00065 
00066     stream
00067         << "))" << endl;
00068 
00069     label nWrittenFaces = phiInternal.size();
00070 
00071     // Writing boundary faces
00072     forAll (phi.boundaryField(), patchI)
00073     {
00074         if (isType<emptyFvPatchScalarField>(phi.boundaryField()[patchI]))
00075         {
00076             // Form empty patch field repeat the internal field to
00077             // allow for the node interpolation in Fluent
00078             const scalarField& phiInternal = phi.internalField();
00079 
00080             // Get reference to internal cells
00081             const labelList emptyFaceCells =
00082                 phi.boundaryField()[patchI].patch().patch().faceCells();
00083 
00084             // Writing cells for empty patch
00085             stream
00086                 << "(300 ("
00087                 << fluentFieldIdentifier << " "  // Field identifier
00088                 << patchI + 10 << " "            // Zone ID: patchI+10
00089                 << "1 "             // Number of components (scalar=1, vector=3)
00090                 << "0 0 "                // Unused
00091                 << nWrittenFaces + 1 << " "
00092                 << nWrittenFaces + emptyFaceCells.size()// Start and end of list
00093                 << ")(" << endl;
00094 
00095             nWrittenFaces += emptyFaceCells.size();
00096 
00097             forAll (emptyFaceCells, faceI)
00098             {
00099                 stream << phiInternal[emptyFaceCells[faceI]] << endl;
00100             }
00101 
00102             stream
00103                 << "))" << endl;
00104         }
00105         else
00106         {
00107             // Regular patch
00108             label nWrittenFaces = phiInternal.size();
00109 
00110             const scalarField& patchPhi = phi.boundaryField()[patchI];
00111 
00112             // Write header
00113             stream
00114                 << "(300 ("
00115                 << fluentFieldIdentifier << " "  // Field identifier
00116                 << patchI + 10 << " "            // Zone ID: patchI+10
00117                 << "1 "          // Number of components (scalar=1, vector=3)
00118                 << "0 0 "            // Unused
00119                 << nWrittenFaces + 1 << " " << nWrittenFaces + patchPhi.size()
00120                                  // Start and end of list
00121                 << ")(" << endl;
00122 
00123             nWrittenFaces += patchPhi.size();
00124 
00125             forAll (patchPhi, faceI)
00126             {
00127                 stream << patchPhi[faceI] << endl;
00128             }
00129 
00130             stream
00131                 << "))" << endl;
00132         }
00133     }
00134 }
00135 
00136 
00137 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00138 
00139 } // End namespace Foam
00140 
00141 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines