writeFluentScalarField.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 volScalarField and Fluent field identifier, write the field in
26  Fluent data format
27 
28 
29 \*---------------------------------------------------------------------------*/
30 
31 #include "writeFluentFields.H"
32 #include "emptyFvPatchFields.H"
33 
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38 
39 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 
42 (
43  const volScalarField& phi,
44  const label fluentFieldIdentifier,
45  Ostream& stream
46 )
47 {
48  const scalarField& phiInternal = phi;
49 
50  // Writing cells
51  stream
52  << "(300 ("
53  << fluentFieldIdentifier << " " // Field identifier
54  << "1 " // Zone ID: (cells=1, internal faces=2,
55  // patch faces=patchi+10)
56  << "1 " // Number of components (scalar=1, vector=3)
57  << "0 0 " // Unused
58  << "1 " << phiInternal.size() // Start and end of list
59  << ")(" << endl;
60 
61  forAll(phiInternal, celli)
62  {
63  stream << phiInternal[celli] << endl;
64  }
65 
66  stream
67  << "))" << endl;
68 
69  label nWrittenFaces = phiInternal.size();
70 
71  // Writing boundary faces
72  forAll(phi.boundaryField(), patchi)
73  {
74  if (isType<emptyFvPatchScalarField>(phi.boundaryField()[patchi]))
75  {
76  // Form empty patch field repeat the internal field to
77  // allow for the node interpolation in Fluent
78  const scalarField& phiInternal = phi;
79 
80  // Get reference to internal cells
81  const labelList emptyFaceCells =
82  phi.boundaryField()[patchi].patch().patch().faceCells();
83 
84  // Writing cells for empty patch
85  stream
86  << "(300 ("
87  << fluentFieldIdentifier << " " // Field identifier
88  << patchi + 10 << " " // Zone ID: patchi+10
89  << "1 " // Number of components (scalar=1, vector=3)
90  << "0 0 " // Unused
91  << nWrittenFaces + 1 << " "
92  << nWrittenFaces + emptyFaceCells.size()// Start and end of list
93  << ")(" << endl;
94 
95  nWrittenFaces += emptyFaceCells.size();
96 
97  forAll(emptyFaceCells, facei)
98  {
99  stream << phiInternal[emptyFaceCells[facei]] << endl;
100  }
101 
102  stream
103  << "))" << endl;
104  }
105  else
106  {
107  // Regular patch
108  label nWrittenFaces = phiInternal.size();
109 
110  const scalarField& patchPhi = phi.boundaryField()[patchi];
111 
112  // Write header
113  stream
114  << "(300 ("
115  << fluentFieldIdentifier << " " // Field identifier
116  << patchi + 10 << " " // Zone ID: patchi+10
117  << "1 " // Number of components (scalar=1, vector=3)
118  << "0 0 " // Unused
119  << nWrittenFaces + 1 << " " << nWrittenFaces + patchPhi.size()
120  // Start and end of list
121  << ")(" << endl;
122 
123  nWrittenFaces += patchPhi.size();
124 
125  forAll(patchPhi, facei)
126  {
127  stream << patchPhi[facei] << endl;
128  }
129 
130  stream
131  << "))" << endl;
132  }
133  }
134 }
135 
136 
137 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
138 
139 } // End namespace Foam
140 
141 // ************************************************************************* //
#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< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:57
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
void writeFluentField(const volScalarField &phi, const label fluentFieldIdentifier, Ostream &stream)
phi
Definition: correctPhi.H:3
List< label > labelList
A List of labels.
Definition: labelList.H:56
label patchi
Namespace for OpenFOAM.