Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060 #include <finiteVolume/fvCFD.H>
00061 #include "writeFluentFields.H"
00062 #include <OpenFOAM/OFstream.H>
00063 #include <OpenFOAM/IOobjectList.H>
00064
00065
00066
00067
00068 int main(int argc, char *argv[])
00069 {
00070 argList::noParallel();
00071 timeSelector::addOptions(false);
00072
00073 # include <OpenFOAM/setRootCase.H>
00074 # include <OpenFOAM/createTime.H>
00075
00076 instantList timeDirs = timeSelector::select0(runTime, args);
00077
00078 # include <OpenFOAM/createMesh.H>
00079
00080
00081 mkDir(runTime.rootPath()/runTime.caseName()/"fluentInterface");
00082
00083 forAll(timeDirs, timeI)
00084 {
00085 runTime.setTime(timeDirs[timeI], timeI);
00086
00087 Info<< "Time = " << runTime.timeName() << endl;
00088
00089 if (mesh.readUpdate())
00090 {
00091 Info<< " Read new mesh" << endl;
00092 }
00093
00094
00095 mkDir(runTime.rootPath()/runTime.caseName()/"fluentInterface");
00096
00097
00098 OFstream fluentDataFile
00099 (
00100 runTime.rootPath()/
00101 runTime.caseName()/
00102 "fluentInterface"/
00103 runTime.caseName() + runTime.timeName() + ".dat"
00104 );
00105
00106 fluentDataFile
00107 << "(0 \"FOAM to Fluent data File\")" << endl << endl;
00108
00109
00110 label nFaces = mesh.nFaces();
00111
00112 forAll (mesh.boundary(), patchI)
00113 {
00114 nFaces += mesh.boundary()[patchI].size();
00115 }
00116
00117 fluentDataFile
00118 << "(33 (" << mesh.nCells() << " " << nFaces << " "
00119 << mesh.nPoints() << "))" << endl;
00120
00121 IOdictionary foamDataToFluentDict
00122 (
00123 IOobject
00124 (
00125 "foamDataToFluentDict",
00126 runTime.system(),
00127 mesh,
00128 IOobject::MUST_READ,
00129 IOobject::NO_WRITE
00130 )
00131 );
00132
00133
00134
00135 IOobjectList objects(mesh, runTime.timeName());
00136
00137
00138
00139
00140
00141
00142 IOobjectList scalarFields(objects.lookupClass("volScalarField"));
00143
00144 for
00145 (
00146 IOobjectList::iterator scalarFieldIter = scalarFields.begin();
00147 scalarFieldIter != scalarFields.end();
00148 ++scalarFieldIter
00149 )
00150 {
00151
00152 volScalarField field
00153 (
00154 *scalarFieldIter(),
00155 mesh
00156 );
00157
00158
00159 if (foamDataToFluentDict.found(field.name()))
00160 {
00161 label unitNumber
00162 (
00163 readLabel(foamDataToFluentDict.lookup(field.name()))
00164 );
00165
00166
00167 if (unitNumber > 0)
00168 {
00169 Info<< " Converting field " << field.name() << endl;
00170 writeFluentField(field, unitNumber, fluentDataFile);
00171 }
00172 }
00173 }
00174
00175
00176
00177
00178
00179
00180 IOobjectList vectorFields(objects.lookupClass("volVectorField"));
00181
00182 for
00183 (
00184 IOobjectList::iterator vectorFieldIter = vectorFields.begin();
00185 vectorFieldIter != vectorFields.end();
00186 ++vectorFieldIter
00187 )
00188 {
00189
00190 volVectorField field
00191 (
00192 *vectorFieldIter(),
00193 mesh
00194 );
00195
00196
00197 if (foamDataToFluentDict.found(field.name()))
00198 {
00199 label unitNumber
00200 (
00201 readLabel(foamDataToFluentDict.lookup(field.name()))
00202 );
00203
00204
00205 if (unitNumber > 0)
00206 {
00207 Info<< " Converting field " << field.name() << endl;
00208 writeFluentField(field, unitNumber, fluentDataFile);
00209 }
00210 }
00211 }
00212
00213 Info<< endl;
00214 }
00215
00216 Info << "End\n" << endl;
00217
00218 return 0;
00219 }
00220
00221
00222