Loading...
Searching...
No Matches
foamDataToFluent.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
27Application
28 foamDataToFluent
29
30Group
31 grpPostProcessingUtilities
32
33Description
34 Translate OpenFOAM data to Fluent format.
35
36\*---------------------------------------------------------------------------*/
37
38#include "fvCFD.H"
39#include "writeFluentFields.H"
40#include "OFstream.H"
41#include "IOobjectList.H"
42
43// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44
45int main(int argc, char *argv[])
46{
47 argList::addNote
48 (
49 "Translate OpenFOAM data to Fluent format"
50 );
51 argList::noParallel();
52 timeSelector::addOptions(false); // constant(false), zero(false)
53
54 #include "setRootCase.H"
55 #include "createTime.H"
56
57 instantList timeDirs = timeSelector::select0(runTime, args);
58
59 #include "createNamedMesh.H"
60
61 // make a directory called proInterface in the case
62 mkDir(runTime.rootPath()/runTime.caseName()/"fluentInterface");
63
64 forAll(timeDirs, timeI)
65 {
66 runTime.setTime(timeDirs[timeI], timeI);
67
68 Info<< "Time = " << runTime.timeName() << endl;
69
70 if (mesh.readUpdate())
71 {
72 Info<< " Read new mesh" << endl;
73 }
74
75 // make a directory called proInterface in the case
76 mkDir(runTime.rootPath()/runTime.caseName()/"fluentInterface");
77
78 // open a file for the mesh
79 OFstream fluentDataFile
80 (
81 runTime.rootPath()/
82 runTime.caseName()/
83 "fluentInterface"/
84 runTime.caseName() + runTime.timeName() + ".dat"
85 );
86
87 fluentDataFile
88 << "(0 \"FOAM to Fluent data File\")" << endl << endl;
89
90 // Writing number of faces
91 label nFaces = mesh.nFaces();
92
93 forAll(mesh.boundary(), patchi)
94 {
95 nFaces += mesh.boundary()[patchi].size();
96 }
97
98 fluentDataFile
99 << "(33 (" << mesh.nCells() << " " << nFaces << " "
100 << mesh.nPoints() << "))" << endl;
101
102 IOdictionary foamDataToFluentDict
103 (
104 IOobject
105 (
106 "foamDataToFluentDict",
107 runTime.system(),
108 mesh,
109 IOobjectOption::MUST_READ,
110 IOobjectOption::NO_WRITE,
111 IOobjectOption::NO_REGISTER
112 )
113 );
114
115
116 // Search for list of objects for this time
117 IOobjectList objects(mesh, runTime.timeName());
118
119
120 readFieldsAndWriteFluent<volScalarField>
121 (
122 foamDataToFluentDict,
123 objects,
124 mesh,
125 fluentDataFile
126 );
127
128 readFieldsAndWriteFluent<volVectorField>
129 (
130 foamDataToFluentDict,
131 objects,
132 mesh,
133 fluentDataFile
134 );
135
136 Info<< endl;
137 }
138
139 Info<< "End\n" << endl;
140
141 return 0;
142}
143
144
145// ************************************************************************* //
dynamicFvMesh & mesh
engineTime & runTime
Required Classes.
messageStream Info
Information stream (stdout output on master, null elsewhere).
List< instant > instantList
List of instants.
Definition instantList.H:41
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
Foam::argList args(argc, argv)
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299
mkDir(pdfPath)