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
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076 #include <OpenFOAM/argList.H>
00077 #include <OpenFOAM/timeSelector.H>
00078 #include <OpenFOAM/Time.H>
00079 #include <finiteVolume/volFields.H>
00080 #include <finiteVolume/surfaceFields.H>
00081 #include <OpenFOAM/pointFields.H>
00082 #include <OpenFOAM/cellIOList.H>
00083 #include <OpenFOAM/IOobjectList.H>
00084 #include <OpenFOAM/IOPtrList.H>
00085
00086 #include "writeMeshObject.H"
00087 #include "fieldDictionary.H"
00088
00089 using namespace Foam;
00090
00091
00092
00093 namespace Foam
00094 {
00095 defineTemplateTypeNameAndDebug(IOPtrList<entry>, 0);
00096 }
00097
00098
00099
00100 bool writeZones(const word& name, const fileName& meshDir, Time& runTime)
00101 {
00102 IOobject io
00103 (
00104 name,
00105 runTime.timeName(),
00106 meshDir,
00107 runTime,
00108 IOobject::MUST_READ,
00109 IOobject::NO_WRITE,
00110 false
00111 );
00112
00113 bool writeOk = false;
00114
00115 if (io.headerOk())
00116 {
00117 Info<< " Reading " << io.headerClassName()
00118 << " : " << name << endl;
00119
00120
00121
00122 const word oldTypeName = IOPtrList<entry>::typeName;
00123 const_cast<word&>(IOPtrList<entry>::typeName) = word::null;
00124
00125 IOPtrList<entry> meshObject(io);
00126
00127 forAll(meshObject, i)
00128 {
00129 if (meshObject[i].isDict())
00130 {
00131 dictionary& d = meshObject[i].dict();
00132
00133 if (d.found("faceLabels"))
00134 {
00135 d.set("faceLabels", labelList(d.lookup("faceLabels")));
00136 }
00137
00138 if (d.found("flipMap"))
00139 {
00140 d.set("flipMap", boolList(d.lookup("flipMap")));
00141 }
00142
00143 if (d.found("cellLabels"))
00144 {
00145 d.set("cellLabels", labelList(d.lookup("cellLabels")));
00146 }
00147
00148 if (d.found("pointLabels"))
00149 {
00150 d.set("pointLabels", labelList(d.lookup("pointLabels")));
00151 }
00152 }
00153 }
00154
00155 const_cast<word&>(IOPtrList<entry>::typeName) = oldTypeName;
00156
00157 const_cast<word&>(meshObject.type()) = io.headerClassName();
00158
00159 Info<< " Writing " << name << endl;
00160
00161
00162 writeOk = meshObject.regIOobject::writeObject
00163 (
00164 IOstream::ASCII,
00165 IOstream::currentVersion,
00166 runTime.writeCompression()
00167 );
00168 }
00169
00170 return writeOk;
00171 }
00172
00173
00174
00175
00176
00177 int main(int argc, char *argv[])
00178 {
00179 timeSelector::addOptions();
00180 #include <OpenFOAM/addRegionOption.H>
00181 #include <OpenFOAM/setRootCase.H>
00182 #include <OpenFOAM/createTime.H>
00183
00184 fileName meshDir = polyMesh::meshSubDir;
00185 fileName regionPrefix = "";
00186 word regionName = polyMesh::defaultRegion;
00187 if (args.optionReadIfPresent("region", regionName))
00188 {
00189 Info<< "Using region " << regionName << nl << endl;
00190 regionPrefix = regionName;
00191 meshDir = regionName/polyMesh::meshSubDir;
00192 }
00193
00194 Foam::instantList timeDirs = Foam::timeSelector::select0(runTime, args);
00195
00196 forAll(timeDirs, timeI)
00197 {
00198 runTime.setTime(timeDirs[timeI], timeI);
00199 Info<< "Time = " << runTime.timeName() << endl;
00200
00201
00202 writeMeshObject<cellIOList>("cells", meshDir, runTime);
00203 writeMeshObject<labelIOList>("owner", meshDir, runTime);
00204 writeMeshObject<labelIOList>("neighbour", meshDir, runTime);
00205 writeMeshObject<faceIOList>("faces", meshDir, runTime);
00206 writeMeshObject<pointIOField>("points", meshDir, runTime);
00207 writeMeshObject<labelIOList>("pointProcAddressing", meshDir, runTime);
00208 writeMeshObject<labelIOList>("faceProcAddressing", meshDir, runTime);
00209 writeMeshObject<labelIOList>("cellProcAddressing", meshDir, runTime);
00210 writeMeshObject<labelIOList>
00211 (
00212 "boundaryProcAddressing",
00213 meshDir,
00214 runTime
00215 );
00216
00217 if (runTime.writeFormat() == IOstream::ASCII)
00218 {
00219
00220
00221 writeZones("cellZones", meshDir, runTime);
00222 writeZones("faceZones", meshDir, runTime);
00223 writeZones("pointZones", meshDir, runTime);
00224 }
00225
00226
00227 IOobjectList objects(runTime, runTime.timeName(), regionPrefix);
00228
00229 forAllConstIter(IOobjectList, objects, iter)
00230 {
00231 const word& headerClassName = iter()->headerClassName();
00232
00233 if
00234 (
00235 headerClassName == volScalarField::typeName
00236 || headerClassName == volVectorField::typeName
00237 || headerClassName == volSphericalTensorField::typeName
00238 || headerClassName == volSymmTensorField::typeName
00239 || headerClassName == volTensorField::typeName
00240
00241 || headerClassName == surfaceScalarField::typeName
00242 || headerClassName == surfaceVectorField::typeName
00243 || headerClassName == surfaceSphericalTensorField::typeName
00244 || headerClassName == surfaceSymmTensorField::typeName
00245 || headerClassName == surfaceTensorField::typeName
00246
00247 || headerClassName == pointScalarField::typeName
00248 || headerClassName == pointVectorField::typeName
00249 || headerClassName == pointSphericalTensorField::typeName
00250 || headerClassName == pointSymmTensorField::typeName
00251 || headerClassName == pointTensorField::typeName
00252 )
00253 {
00254 Info<< " Reading " << headerClassName
00255 << " : " << iter()->name() << endl;
00256
00257 fieldDictionary fDict
00258 (
00259 *iter(),
00260 headerClassName
00261 );
00262
00263 Info<< " Writing " << iter()->name() << endl;
00264 fDict.regIOobject::write();
00265 }
00266 }
00267
00268 Info<< endl;
00269 }
00270
00271 Info<< "End\n" << endl;
00272
00273 return 0;
00274 }
00275
00276
00277