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