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

writeFluentVectorField.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 volVectorField and Fluent field identifier, write the field in
00026     Fluent data format
00027 
00028 
00029 \*---------------------------------------------------------------------------*/
00030 
00031 #include "writeFluentFields.H"
00032 
00033 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00034 
00035 namespace Foam
00036 {
00037 
00038 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00039 
00040 void writeFluentField
00041 (
00042     const volVectorField& phi,
00043     const label fluentFieldIdentifier,
00044     Ostream& stream
00045 )
00046 {
00047     const vectorField& phiInternal = phi.internalField();
00048 
00049     // Writing cells
00050     stream
00051         << "(300 ("
00052         << fluentFieldIdentifier << " "  // Field identifier
00053         << "1 "                  // Zone ID: (cells=1, internal faces=2,
00054                                  // patch faces=patchI+10)
00055         << "3 "                  // Number of components (scalar=1, vector=3)
00056         << "0 0 "                // Unused
00057         << "1 " << phiInternal.size() // Start and end of list
00058         << ")(" << endl;
00059 
00060     forAll (phiInternal, cellI)
00061     {
00062         stream
00063             << phiInternal[cellI].x() << " "
00064             << phiInternal[cellI].y() << " "
00065             << phiInternal[cellI].z() << " "
00066             << endl;
00067     }
00068 
00069     stream
00070         << "))" << endl;
00071 
00072     label nWrittenFaces = phiInternal.size();
00073 
00074     // Writing boundary faces
00075     forAll (phi.boundaryField(), patchI)
00076     {
00077         const vectorField& patchPhi = phi.boundaryField()[patchI];
00078 
00079         // Write header
00080         stream
00081             << "(300 ("
00082             << fluentFieldIdentifier << " "  // Field identifier
00083             << patchI + 10 << " "            // Zone ID: patchI+10
00084             << "3 "              // Number of components (scalar=1, vector=3)
00085             << "0 0 "            // Unused
00086             << nWrittenFaces + 1 << " " << nWrittenFaces + patchPhi.size()
00087                                  // Start and end of list
00088             << ")(" << endl;
00089 
00090         nWrittenFaces += patchPhi.size();
00091 
00092         forAll (patchPhi, faceI)
00093         {
00094             stream
00095                 << patchPhi[faceI].x() << " "
00096                 << patchPhi[faceI].y() << " "
00097                 << patchPhi[faceI].z() << " "
00098                 << endl;
00099         }
00100 
00101         stream
00102             << "))" << endl;
00103     }
00104 }
00105 
00106 
00107 } // End namespace Foam
00108 
00109 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines