1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 Translates FOAM data to Fluent format.
28 \*---------------------------------------------------------------------------*/
31 #include "writeFluentFields.H"
33 #include "IOobjectList.H"
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 int main(int argc, char *argv[])
40 argList::noParallel();
41 timeSelector::addOptions(false); // no constant
43 # include "setRootCase.H"
44 # include "createTime.H"
46 instantList timeDirs = timeSelector::select0(runTime, args);
48 # include "createMesh.H"
50 // make a directory called proInterface in the case
51 mkDir(runTime.rootPath()/runTime.caseName()/"fluentInterface");
53 forAll(timeDirs, timeI)
55 runTime.setTime(timeDirs[timeI], timeI);
57 Info<< "Time = " << runTime.timeName() << endl;
59 if (mesh.readUpdate())
61 Info<< " Read new mesh" << endl;
64 // make a directory called proInterface in the case
65 mkDir(runTime.rootPath()/runTime.caseName()/"fluentInterface");
67 // open a file for the mesh
68 OFstream fluentDataFile
73 runTime.caseName() + runTime.timeName() + ".dat"
77 << "(0 \"FOAM to Fluent data File\")" << endl << endl;
79 // Writing number of faces
80 label nFaces = mesh.nFaces();
82 forAll (mesh.boundary(), patchI)
84 nFaces += mesh.boundary()[patchI].size();
88 << "(33 (" << mesh.nCells() << " " << nFaces << " "
89 << mesh.nPoints() << "))" << endl;
91 IOdictionary foamDataToFluentDict
95 "foamDataToFluentDict",
104 // Search for list of objects for this time
105 IOobjectList objects(mesh, runTime.timeName());
108 // Converting volScalarField
109 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
111 // Search list of objects for volScalarFields
112 IOobjectList scalarFields(objects.lookupClass("volScalarField"));
116 IOobjectList::iterator scalarFieldIter = scalarFields.begin();
117 scalarFieldIter != scalarFields.end();
128 // lookup field from dictionary
129 if (foamDataToFluentDict.found(field.name()))
133 readLabel(foamDataToFluentDict.lookup(field.name()))
139 Info<< " Converting field " << field.name() << endl;
140 writeFluentField(field, unitNumber, fluentDataFile);
146 // Converting volVectorField
147 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
149 // Search list of objects for volVectorFields
150 IOobjectList vectorFields(objects.lookupClass("volVectorField"));
154 IOobjectList::iterator vectorFieldIter = vectorFields.begin();
155 vectorFieldIter != vectorFields.end();
166 // lookup field from dictionary
167 if (foamDataToFluentDict.found(field.name()))
171 readLabel(foamDataToFluentDict.lookup(field.name()))
177 Info<< " Converting field " << field.name() << endl;
178 writeFluentField(field, unitNumber, fluentDataFile);
186 Info << "End\n" << endl;
192 // ************************************************************************* //