Loading...
Searching...
No Matches
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 Copyright (C) 2023 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Description
28 Given a volVectorField and Fluent field identifier, write the field in
29 Fluent data format
30
31
32\*---------------------------------------------------------------------------*/
33
34#include "writeFluentFields.H"
35
36// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37
39(
40 const volVectorField& phi,
41 const label fluentFieldIdentifier,
42 Ostream& stream
43)
44{
45 const vectorField& phiInternal = phi;
46
47 // Writing cells
48 stream
49 << "(300 ("
50 << fluentFieldIdentifier << " " // Field identifier
51 << "1 " // Zone ID: (cells=1, internal faces=2,
52 // patch faces=patchi+10)
53 << "3 " // Number of components (scalar=1, vector=3)
54 << "0 0 " // Unused
55 << "1 " << phiInternal.size() // Start and end of list
56 << ")(" << nl;
57
58 for (const vector& val : phiInternal)
59 {
60 stream
61 << val.x() << ' ' << val.y() << ' ' << val.z() << nl;
62 }
63
64 stream
65 << "))" << nl;
66
67 label nWrittenFaces = phiInternal.size();
68
69 // Writing boundary faces
70 forAll(phi.boundaryField(), patchi)
71 {
72 const vectorField& patchPhi = phi.boundaryField()[patchi];
73
74 // Write header
75 stream
76 << "(300 ("
77 << fluentFieldIdentifier << " " // Field identifier
78 << patchi + 10 << " " // Zone ID: patchi+10
79 << "3 " // Number of components (scalar=1, vector=3)
80 << "0 0 " // Unused
81 << nWrittenFaces + 1 << " " << nWrittenFaces + patchPhi.size()
82 // Start and end of list
83 << ")(" << nl;
84
85 nWrittenFaces += patchPhi.size();
86
87 for (const vector& val : patchPhi)
88 {
89 stream
90 << val.x() << ' ' << val.y() << ' ' << val.z() << nl;
91 }
92
93 stream
94 << "))" << endl;
95 }
96}
97
98
99// ************************************************************************* //
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
Field< vector > vectorField
Specialisation of Field<T> for vector.
void writeFluentField(const volScalarField &phi, const label fluentFieldIdentifier, Ostream &os)
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299