writeFluentVectorField.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Description
27  Given a volVectorField and Fluent field identifier, write the field in
28  Fluent data format
29 
30 
31 \*---------------------------------------------------------------------------*/
32 
33 #include "writeFluentFields.H"
34 
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 
37 namespace Foam
38 {
39 
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 
43 (
44  const volVectorField& phi,
45  const label fluentFieldIdentifier,
46  Ostream& stream
47 )
48 {
49  const vectorField& phiInternal = phi;
50 
51  // Writing cells
52  stream
53  << "(300 ("
54  << fluentFieldIdentifier << " " // Field identifier
55  << "1 " // Zone ID: (cells=1, internal faces=2,
56  // patch faces=patchi+10)
57  << "3 " // Number of components (scalar=1, vector=3)
58  << "0 0 " // Unused
59  << "1 " << phiInternal.size() // Start and end of list
60  << ")(" << endl;
61 
62  forAll(phiInternal, celli)
63  {
64  stream
65  << phiInternal[celli].x() << " "
66  << phiInternal[celli].y() << " "
67  << phiInternal[celli].z() << " "
68  << endl;
69  }
70 
71  stream
72  << "))" << endl;
73 
74  label nWrittenFaces = phiInternal.size();
75 
76  // Writing boundary faces
77  forAll(phi.boundaryField(), patchi)
78  {
79  const vectorField& patchPhi = phi.boundaryField()[patchi];
80 
81  // Write header
82  stream
83  << "(300 ("
84  << fluentFieldIdentifier << " " // Field identifier
85  << patchi + 10 << " " // Zone ID: patchi+10
86  << "3 " // Number of components (scalar=1, vector=3)
87  << "0 0 " // Unused
88  << nWrittenFaces + 1 << " " << nWrittenFaces + patchPhi.size()
89  // Start and end of list
90  << ")(" << endl;
91 
92  nWrittenFaces += patchPhi.size();
93 
94  forAll(patchPhi, facei)
95  {
96  stream
97  << patchPhi[facei].x() << " "
98  << patchPhi[facei].y() << " "
99  << patchPhi[facei].z() << " "
100  << endl;
101  }
102 
103  stream
104  << "))" << endl;
105  }
106 }
107 
108 
109 } // End namespace Foam
110 
111 // ************************************************************************* //
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:487
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:85
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:413
void writeFluentField(const volScalarField &phi, const label fluentFieldIdentifier, Ostream &stream)
Field< vector > vectorField
Specialisation of Field<T> for vector.
Namespace for OpenFOAM.