43int main(
int argc,
char *argv[])
47 "Translate a STARCD SMAP data file into OpenFOAM field format"
50 argList::noParallel();
51 argList::addArgument(
"SMAP fileName");
53 argList
args(argc, argv);
66 fieldNameDict.add(fieldNames[i], word(fieldNames[i]));
70 if (fieldNameDict.found(
"U")) nameMap.add(
"SU", word(
"U"));
71 if (fieldNameDict.found(
"p")) nameMap.add(
"P", word(
"p"));
72 if (fieldNameDict.found(
"T")) nameMap.add(
"T", word(
"T"));
73 if (fieldNameDict.found(
"rho")) nameMap.add(
"DENS", word(
"rho"));
74 if (fieldNameDict.found(
"k")) nameMap.add(
"TE", word(
"k"));
75 if (fieldNameDict.found(
"epsilon")) nameMap.add(
"ED", word(
"epsilon"));
76 if (fieldNameDict.found(
"nuEff")) nameMap.add(
"VIS", word(
"nuEff"));
80 IFstream smapFile(
args.get<fileName>(1));
85 <<
"Cannot open SMAP file " << smapFile.name()
89 while (!smapFile.eof())
93 token fieldName(smapFile);
100 if (!fieldName.isWord(
"CELL"))
103 <<
"Expected first CELL, found "
109 smapFile >> fieldName;
110 while (fieldName.isWord())
112 starFieldNames[nCols++] = fieldName.wordToken();
113 smapFile >> fieldName;
116 List<volScalarField*> sFields
122 List<volVectorField*> vFields
131 if (nameMap.found(starFieldNames[i]))
135 nameMap.get<word>(starFieldNames[i]),
142 if (starFieldNames[i] ==
"SU")
174 smapFile >> (*sFields[i])[celli];
179 smapFile >> (*vFields[i])[celli].
x();
180 smapFile >> (*vFields[i])[celli].
y();
181 smapFile >> (*vFields[i])[celli].z();
192 for (label i=0; i<nCols; i++)
196 sFields[i]->correctBoundaryConditions();
199 sFields[i] =
nullptr;
203 vFields[i]->correctBoundaryConditions();
206 vFields[i] =
nullptr;
216 <<
"Expected first SMAP dummy entry to be cell 0, found "
221 for (label i=0; i<nCols; i++)
void exit(const int errNo=1)
Exit : can be called for any error to exit program.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
List< word > wordList
List of word.
GeometricField< vector, fvPatchField, volMesh > volVectorField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
List< fileName > fileNameList
List of fileName.
messageStream Info
Information stream (stdout output on master, null elsewhere).
Ostream & endl(Ostream &os)
Add newline and flush stream.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
errorManipArg< error, int > exit(error &err, const int errNo=1)
fileNameList readDir(const fileName &directory, const fileName::Type type=fileName::Type::FILE, const bool filtergz=true, const bool followLink=true)
Read a directory and return the entries as a fileName List.
Foam::argList args(argc, argv)
#define forAll(list, i)
Loop across all elements in list.