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 #include "partialWrite.H"
00027 #include <OpenFOAM/dictionary.H>
00028 #include <OpenFOAM/Time.H>
00029 #include <OpenFOAM/IOobjectList.H>
00030 #include <OpenFOAM/polyMesh.H>
00031 #include <OpenFOAM/cloud.H>
00032
00033
00034
00035 namespace Foam
00036 {
00037 defineTypeNameAndDebug(partialWrite, 0);
00038 }
00039
00040
00041
00042
00043 Foam::partialWrite::partialWrite
00044 (
00045 const word& name,
00046 const objectRegistry& obr,
00047 const dictionary& dict,
00048 const bool loadFromFiles
00049 )
00050 :
00051 name_(name),
00052 obr_(obr)
00053 {
00054 read(dict);
00055 }
00056
00057
00058
00059
00060 Foam::partialWrite::~partialWrite()
00061 {}
00062
00063
00064
00065
00066 void Foam::partialWrite::read(const dictionary& dict)
00067 {
00068 dict.lookup("objectNames") >> objectNames_;
00069 dict.lookup("writeInterval") >> writeInterval_;
00070 writeInstance_ = 0;
00071
00072 Info<< type() << " " << name() << ":" << nl
00073 << " dumping every outputTime :";
00074 forAllConstIter(HashSet<word>, objectNames_, iter)
00075 {
00076 Info<< ' ' << iter.key();
00077 }
00078 Info<< nl
00079 << " dumping all other fields every "
00080 << writeInterval_ << "th outputTime" << nl
00081 << endl;
00082
00083 if (writeInterval_ < 1)
00084 {
00085 FatalIOErrorIn("partialWrite::read(const dictionary&)", dict)
00086 << "Illegal value for writeInterval " << writeInterval_
00087 << ". It should be >= 1."
00088 << exit(FatalIOError);
00089 }
00090 }
00091
00092
00093 void Foam::partialWrite::execute()
00094 {
00095
00096
00097 }
00098
00099
00100 void Foam::partialWrite::end()
00101 {
00102
00103
00104 }
00105
00106
00107 void Foam::partialWrite::write()
00108 {
00109
00110 if (obr_.time().outputTime())
00111 {
00112
00113
00114
00115
00116
00117
00118 writeInstance_++;
00119
00120 if (writeInstance_ == writeInterval_)
00121 {
00122
00123 writeInstance_ = 0;
00124 }
00125 else
00126 {
00127
00128 fileName dbDir;
00129 if (isA<polyMesh>(obr_))
00130 {
00131 dbDir = dynamic_cast<const polyMesh&>(obr_).dbDir();
00132 }
00133
00134 IOobjectList objects(obr_, obr_.time().timeName());
00135
00136 if (debug)
00137 {
00138 Pout<< "For region:" << obr_.name() << endl;
00139 }
00140
00141 forAllConstIter(IOobjectList, objects, iter)
00142 {
00143 if (!objectNames_.found(iter()->name()))
00144 {
00145 const fileName f =
00146 obr_.time().timePath()
00147 /dbDir
00148 /iter()->name();
00149 if (debug)
00150 {
00151 Pout<< " rm " << f << endl;
00152 }
00153 rm(f);
00154 }
00155 }
00156
00157
00158 fileNameList cloudDirs
00159 (
00160 readDir
00161 (
00162 obr_.time().timePath()/dbDir/cloud::prefix,
00163 fileName::DIRECTORY
00164 )
00165 );
00166 forAll(cloudDirs, i)
00167 {
00168 if (debug)
00169 {
00170 Pout<< "For cloud:" << cloudDirs[i] << endl;
00171 }
00172
00173 IOobjectList sprayObjs
00174 (
00175 obr_,
00176 obr_.time().timeName(),
00177 cloud::prefix/cloudDirs[i]
00178 );
00179 forAllConstIter(IOobjectList, sprayObjs, iter)
00180 {
00181 if (!objectNames_.found(iter()->name()))
00182 {
00183 const fileName f =
00184 obr_.time().timePath()
00185 /dbDir
00186 /cloud::prefix
00187 /cloudDirs[i]
00188 /iter()->name();
00189 if (debug)
00190 {
00191 Pout<< " rm " << f << endl;
00192 }
00193 rm(f);
00194 }
00195 }
00196 }
00197 }
00198 }
00199 }
00200
00201
00202