1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
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 a STAR-CD SMAP data file into FOAM field format.
28 \*---------------------------------------------------------------------------*/
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 int main(int argc, char *argv[])
38 argList::noParallel();
39 argList::validArgs.append("SMAP fileName");
41 argList args(argc, argv);
48 # include "createTime.H"
50 fileNameList fieldNames = readDir(runTime.timePath(), fileName::FILE);
51 dictionary fieldNameDict;
52 forAll (fieldNames, i)
54 fieldNameDict.add(fieldNames[i], word(fieldNames[i]));
58 if (fieldNameDict.found("U")) nameMap.add("SU", word("U"));
59 if (fieldNameDict.found("p")) nameMap.add("P", word("p"));
60 if (fieldNameDict.found("T")) nameMap.add("T", word("T"));
61 if (fieldNameDict.found("rho")) nameMap.add("DENS", word("rho"));
62 if (fieldNameDict.found("k")) nameMap.add("TE", word("k"));
63 if (fieldNameDict.found("epsilon")) nameMap.add("ED", word("epsilon"));
64 if (fieldNameDict.found("nuEff")) nameMap.add("VIS", word("nuEff"));
66 # include "createMesh.H"
68 IFstream smapFile(args.additionalArgs()[0]);
72 FatalErrorIn(args.executable())
73 << "Cannot open SMAP file " << smapFile.name()
77 while (!smapFile.eof())
79 wordList starFieldNames(10);
81 token fieldName(smapFile);
90 fieldName.type() != token::WORD
91 && fieldName.wordToken() != "CELL"
94 FatalErrorIn(args.executable())
95 << "Expected first CELL, found "
101 smapFile >> fieldName;
102 while (fieldName.type() == token::WORD)
104 starFieldNames[nCols++] = fieldName.wordToken();
105 smapFile >> fieldName;
108 List<volScalarField*> sFields
111 reinterpret_cast<volScalarField*>(0)
114 List<volVectorField*> vFields
117 reinterpret_cast<volVectorField*>(0)
123 if (nameMap.found(starFieldNames[i]))
125 if (starFieldNames[i] == "SU")
132 nameMap.lookup(starFieldNames[i]),
150 nameMap.lookup(starFieldNames[i]),
171 forAll (mesh.cells(), celli)
183 smapFile >> (*sFields[i])[celli];
188 smapFile >> (*vFields[i])[celli].x();
189 smapFile >> (*vFields[i])[celli].y();
190 smapFile >> (*vFields[i])[celli].z();
201 for (label i=0; i<nCols; i++)
205 sFields[i]->correctBoundaryConditions();
212 vFields[i]->correctBoundaryConditions();
219 // Read dummy entry and check the cell index
224 FatalErrorIn(args.executable())
225 << "Expected first SMAP dummy entry to be cell 0, found "
230 for (label i=0; i<nCols; i++)
236 Info << "End\n" << endl;
242 // ************************************************************************* //