ENH: improve controls for Time (issue #910)

- relocate some standard functionality to TimePaths to allow a lighter
  means of managing time directories without using the entire Time
  mechanism.

- optional enableLibs for Time construction (default is on)
  and a corresponding argList::noLibs() and "-no-libs" option

STYLE:

- mark Time::outputTime() as deprecated MAY-2016

- use pre-increment for runTime, although there is no difference in
  behaviour or performance.
This commit is contained in:
Mark Olesen 2018-07-02 10:20:01 +02:00
parent e8c1ae3c16
commit 2662042d49
120 changed files with 667 additions and 499 deletions

View File

@ -1,4 +1,4 @@
if (runTime.outputTime())
if (runTime.writeTime())
{
volVectorField gradT(fvc::grad(T));

View File

@ -115,7 +115,7 @@ int main(int argc, char *argv[])
#include "compressibleCourantNo.H"
#include "setDeltaT.H"
runTime++;
++runTime;
Info<< "\n\nTime = " << runTime.timeName() << endl;
#include "rhoEqn.H"

View File

@ -101,8 +101,8 @@ int main(int argc, char *argv[])
#include "compressibleCourantNo.H"
#include "setDeltaT.H"
// Indicators for refinement. Note: before runTime++
// only for post-processing reasons.
// Indicators for refinement.
// Note: before ++runTime only for post-processing reasons.
tmp<volScalarField> tmagGradP = mag(fvc::grad(p));
volScalarField normalisedGradP
(
@ -112,7 +112,7 @@ int main(int argc, char *argv[])
normalisedGradP.writeOpt() = IOobject::AUTO_WRITE;
tmagGradP.clear();
runTime++;
++runTime;
Info<< "\n\nTime = " << runTime.timeName() << endl;

View File

@ -107,7 +107,7 @@ int main(int argc, char *argv[])
#include "compressibleCourantNo.H"
#include "setDeltaT.H"
runTime++;
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;

View File

@ -95,7 +95,7 @@ int main(int argc, char *argv[])
#include "compressibleCourantNo.H"
#include "setDeltaT.H"
runTime++;
++runTime;
Info<< "Crank angle = " << runTime.theta() << " CA-deg" << endl;

View File

@ -92,7 +92,7 @@ int main(int argc, char *argv[])
#include "compressibleCourantNo.H"
#include "setDeltaT.H"
runTime++;
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;
#include "rhoEqn.H"

View File

@ -73,7 +73,7 @@ int main(int argc, char *argv[])
#include "setDeltaT.H"
runTime++;
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;
#include "solveChemistry.H"

View File

@ -74,7 +74,7 @@ int main(int argc, char *argv[])
#include "compressibleCourantNo.H"
#include "setDeltaT.H"
runTime++;
++runTime;
Info<< "Engine time = " << runTime.theta() << runTime.unit()
<< endl;

View File

@ -79,7 +79,7 @@ int main(int argc, char *argv[])
#include "setMultiRegionDeltaT.H"
#include "setDeltaT.H"
runTime++;
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;

View File

@ -85,7 +85,7 @@ int main(int argc, char *argv[])
#include "setDeltaT.H"
}
runTime++;
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;

View File

@ -85,7 +85,7 @@ int main(int argc, char *argv[])
#include "setDeltaT.H"
}
runTime++;
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;

View File

@ -87,7 +87,7 @@ int main(int argc, char *argv[])
#include "setDeltaT.H"
}
runTime++;
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;

View File

@ -76,7 +76,7 @@ int main(int argc, char *argv[])
#include "readTimeControls.H"
#include "setDeltaT.H"
runTime++;
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;

View File

@ -160,7 +160,7 @@ int main(int argc, char *argv[])
#include "setDeltaT.H"
}
runTime++;
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;

View File

@ -81,7 +81,7 @@ int main(int argc, char *argv[])
#include "compressibleCourantNo.H"
#include "setDeltaT.H"
runTime++;
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;

View File

@ -101,7 +101,7 @@ int main(int argc, char *argv[])
#include "setDeltaT.H"
}
runTime++;
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;

View File

@ -106,7 +106,7 @@ int main(int argc, char *argv[])
#include "setDeltaT.H"
}
runTime++;
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;

View File

@ -81,7 +81,7 @@ int main(int argc, char *argv[])
#include "compressibleCourantNo.H"
#include "setDeltaT.H"
runTime++;
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;

View File

@ -78,7 +78,7 @@ int main(int argc, char *argv[])
Info<< "Calculating the magnetic field potential" << endl;
runTime++;
++runTime;
while (simple.correctNonOrthogonal())
{

View File

@ -67,7 +67,7 @@ int main(int argc, char *argv[])
#include "capillaryCourantNo.H"
#include "setDeltaT.H"
runTime++;
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;
@ -138,7 +138,7 @@ int main(int argc, char *argv[])
Us.correctBoundaryConditions();
}
if (runTime.outputTime())
if (runTime.writeTime())
{
vsm.mapToVolume(h, H.boundaryFieldRef());
vsm.mapToVolume(Us, U.boundaryFieldRef());

View File

@ -84,7 +84,7 @@ int main(int argc, char *argv[])
#include "CourantNo.H"
#include "setDeltaT.H"
runTime++;
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;

View File

@ -73,7 +73,7 @@ int main(int argc, char *argv[])
#include "compressibleCourantNo.H"
#include "setDeltaT.H"
runTime++;
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;

View File

@ -79,7 +79,7 @@ int main(int argc, char *argv[])
#include "solidRegionDiffusionNo.H"
#include "setMultiRegionDeltaT.H"
runTime++;
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;

View File

@ -82,7 +82,7 @@ int main(int argc, char *argv[])
while (runTime.run())
{
runTime++;
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;

View File

@ -69,7 +69,7 @@ int main(int argc, char *argv[])
#include "CourantNo.H"
#include "setDeltaT.H"
runTime++;
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;

View File

@ -84,7 +84,7 @@ int main(int argc, char *argv[])
#include "setDeltaT.H"
runTime++;
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;

View File

@ -104,7 +104,7 @@ int main(int argc, char *argv[])
#include "CourantNo.H"
#include "setDeltaT.H"
runTime++;
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;

View File

@ -73,7 +73,7 @@ int main(int argc, char *argv[])
#include "CourantNo.H"
#include "setDeltaT.H"
runTime++;
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;

View File

@ -75,7 +75,7 @@ int main(int argc, char *argv[])
#include "CourantNo.H"
#include "setDeltaT.H"
runTime++;
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;

View File

@ -89,7 +89,7 @@ int main(int argc, char *argv[])
#include "setDeltaT.H"
}
runTime++;
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;

View File

@ -90,7 +90,7 @@ int main(int argc, char *argv[])
#include "setMultiRegionDeltaT.H"
}
runTime++;
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;

View File

@ -75,7 +75,7 @@ int main(int argc, char *argv[])
#include "compressibleCourantNo.H"
#include "setDeltaT.H"
runTime++;
++runTime;
Info<< "Engine time = " << runTime.theta() << runTime.unit() << endl;

View File

@ -83,7 +83,7 @@ int main(int argc, char *argv[])
#include "compressibleCourantNo.H"
#include "setDeltaT.H"
runTime++;
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;

View File

@ -73,7 +73,7 @@ int main(int argc, char *argv[])
#include "compressibleCourantNo.H"
#include "setDeltaT.H"
runTime++;
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;

View File

@ -98,7 +98,7 @@ int main(int argc, char *argv[])
#include "setDeltaT.H"
}
runTime++;
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;

View File

@ -74,7 +74,7 @@ int main(int argc, char *argv[])
#include "CourantNo.H"
#include "setDeltaT.H"
runTime++;
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;

View File

@ -69,7 +69,7 @@ int main(int argc, char *argv[])
#include "CourantNo.H"
#include "setDeltaT.H"
runTime++;
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;
// --- Pressure-velocity PIMPLE corrector loop

View File

@ -94,7 +94,7 @@ int main(int argc, char *argv[])
#include "setDeltaT.H"
}
runTime++;
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;

View File

@ -97,7 +97,7 @@ int main(int argc, char *argv[])
#include "setDeltaT.H"
}
runTime++;
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;

View File

@ -97,7 +97,7 @@ int main(int argc, char *argv[])
#include "setDeltaT.H"
}
runTime++;
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;

View File

@ -75,7 +75,7 @@ int main(int argc, char *argv[])
#include "alphaCourantNo.H"
#include "setDeltaT.H"
runTime++;
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;

View File

@ -80,7 +80,7 @@ int main(int argc, char *argv[])
#include "CourantNo.H"
#include "setDeltaT.H"
runTime++;
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;

View File

@ -83,7 +83,7 @@ int main(int argc, char *argv[])
#include "alphaCourantNo.H"
#include "setDeltaT.H"
runTime++;
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;

View File

@ -85,7 +85,7 @@ int main(int argc, char *argv[])
#include "CourantNo.H"
#include "setDeltaT.H"
runTime++;
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;

View File

@ -92,7 +92,7 @@ int main(int argc, char *argv[])
#include "setDeltaT.H"
}
runTime++;
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;

View File

@ -90,7 +90,7 @@ int main(int argc, char *argv[])
#include "setDeltaT.H"
}
runTime++;
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;

View File

@ -133,7 +133,7 @@
}
}
//if (runTime.outputTime())
//if (runTime.writeTime())
//{
// volScalarField("contPhiPcorr", fvc::div(phi)).write();
// pcorr.write();

View File

@ -118,7 +118,7 @@ int main(int argc, char *argv[])
#include "setDeltaT.H"
}
runTime++;
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;

View File

@ -93,7 +93,7 @@ int main(int argc, char *argv[])
#include "alphaCourantNo.H"
#include "setDeltaT.H"
runTime++;
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;

View File

@ -104,7 +104,7 @@ int main(int argc, char *argv[])
#include "CourantNo.H"
#include "setDeltaT.H"
runTime++;
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;

View File

@ -80,7 +80,7 @@ int main(int argc, char *argv[])
#include "CourantNo.H"
#include "setDeltaT.H"
runTime++;
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;

View File

@ -86,7 +86,7 @@ int main(int argc, char *argv[])
#include "CourantNo.H"
#include "setDeltaT.H"
runTime++;
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;
// --- Pressure-velocity PIMPLE corrector loop

View File

@ -78,7 +78,7 @@ int main(int argc, char *argv[])
#include "alphaCourantNo.H"
#include "setDeltaT.H"
runTime++;
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;

View File

@ -91,7 +91,7 @@ int main(int argc, char *argv[])
#include "CourantNo.H"
#include "setDeltaT.H"
runTime++;
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;

View File

@ -70,7 +70,7 @@ int main(int argc, char *argv[])
#include "CourantNo.H"
#include "setDeltaT.H"
runTime++;
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;

View File

@ -101,7 +101,7 @@ int main(int argc, char *argv[])
#include "setDeltaT.H"
}
runTime++;
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;
// --- Pressure-velocity PIMPLE corrector loop

View File

@ -135,7 +135,7 @@ int main(int argc, char *argv[])
#include "setDeltaT.H"
}
runTime++;
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;
// --- Pressure-velocity PIMPLE corrector loop

View File

@ -71,7 +71,7 @@ int main(int argc, char *argv[])
#include "alphaCourantNo.H"
#include "setDeltaT.H"
runTime++;
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;

View File

@ -83,7 +83,7 @@ int main(int argc, char *argv[])
#include "CourantNos.H"
#include "setDeltaT.H"
runTime++;
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;
// --- Pressure-velocity PIMPLE corrector loop

View File

@ -70,7 +70,7 @@ int main(int argc, char *argv[])
labelList cellToCoarse(identity(mesh.nCells()));
labelListList coarseToCell(invertOneToMany(mesh.nCells(), cellToCoarse));
runTime++;
++runTime;
// Write initial agglomeration
{
@ -103,7 +103,7 @@ int main(int argc, char *argv[])
for (label level = 0; level < agglom.size(); level++)
{
runTime++;
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;

View File

@ -73,7 +73,7 @@ int main(int argc, char *argv[])
Info<< "\nCorrecting boundary conditions on " << T.name() << nl << endl;
runTime++;
++runTime;
Info<< "Time = " << runTime.timeName() << nl << endl;

View File

@ -1,4 +1,4 @@
if (runTime.outputTime())
if (runTime.writeTime())
{
volVectorField gradT(fvc::grad(T));

View File

@ -67,7 +67,7 @@ int main(int argc, char *argv[])
runTime.printExecutionTime(Info);
runTime++;
++runTime;
Pout<< "Writing particles to time " << runTime.timeName() << endl;
particles.write();
}

View File

@ -0,0 +1,3 @@
Test-timeSelector.C
EXE = $(FOAM_USER_APPBIN)/Test-timeSelector

View File

@ -0,0 +1 @@
/* EXE_INC = */

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -22,26 +22,65 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Description
Searches the current case directory for valid times
and sets the time list to these.
This is done if a times File does not exist.
Test TimePaths and timeSelectop
\*---------------------------------------------------------------------------*/
#include "Time.H"
#include "OSspecific.H"
#include "StringStream.H"
#include "argList.H"
#include "IOstreams.H"
#include "TimePaths.H"
#include "timeSelector.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
using namespace Foam;
Foam::instantList Foam::Time::findTimes
(
const fileName& directory,
const word& constantName
)
bool print(const instantList& instants)
{
return fileHandler().findTimes(directory, constantName);
if (instants.empty())
{
Info<<" none" << nl << nl;
return false;
}
Info <<"(" << nl;
for (const instant& t : instants)
{
Info<<" " << t << nl;
}
Info<<")" << nl << nl;
return true;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
argList::addNote("Test timeSelector");
timeSelector::addOptions(true, true);
argList::noLibs();
argList::noFunctionObjects();
#include "setRootCase.H"
autoPtr<TimePaths> timePaths;
instantList times(TimePaths(args).times());
Info<<"Available times" << nl;
if (print(times))
{
times = timeSelector::select(times, args);
Info<< "Selected times" << nl;
print(times);
}
return 0;
}
// ************************************************************************* //

View File

@ -57,7 +57,7 @@ int main(int argc, char *argv[])
const volScalarField& y = wallDist::New(mesh).y();
y.write();
runTime++;
++runTime;
Info<< "Time now = " << runTime.timeName() << endl;

View File

@ -1021,7 +1021,7 @@ int main(int argc, char *argv[])
if (!overwrite)
{
runTime++;
++runTime;
}
Info<< "Writing mesh without blockedCells to time " << runTime.value()
@ -1157,7 +1157,7 @@ int main(int argc, char *argv[])
if (!overwrite)
{
runTime++;
++runTime;
}
// Change the mesh. Change points directly (no inflation).

View File

@ -240,7 +240,7 @@ int main(int argc, char *argv[])
// Write resulting mesh
if (!overwrite)
{
runTime++;
++runTime;
}
else
{

View File

@ -409,7 +409,7 @@ int main(int argc, char *argv[])
if (!overwrite)
{
runTime++;
++runTime;
}

View File

@ -554,7 +554,7 @@ int main(int argc, char *argv[])
if (!overwrite)
{
runTime++;
++runTime;
}
else
{
@ -630,7 +630,7 @@ int main(int argc, char *argv[])
if (!overwrite)
{
runTime++;
++runTime;
}
else
{
@ -675,7 +675,7 @@ int main(int argc, char *argv[])
if (!overwrite)
{
runTime++;
++runTime;
}
else
{

View File

@ -167,7 +167,7 @@ int main(int argc, char *argv[])
if (!overwrite)
{
runTime++;
++runTime;
}
// Create mesh, return map from old to new mesh.

View File

@ -220,7 +220,7 @@ int main(int argc, char *argv[])
if (!overwrite)
{
runTime++;
++runTime;
}
autoPtr<mapPolyMesh> morphMap = meshMod.changeMesh(mesh, false);

View File

@ -170,7 +170,7 @@ int main(int argc, char *argv[])
if (!overwrite)
{
runTime++;
++runTime;
}
else
{

View File

@ -682,7 +682,7 @@ int main(int argc, char *argv[])
if (!overwrite)
{
runTime++;
++runTime;
}
autoPtr<mapPolyMesh> morphMap = meshMod.changeMesh(mesh, false);

View File

@ -1647,7 +1647,7 @@ int main(int argc, char *argv[])
word meshInstance;
if (!overwrite)
{
runTime++;
++runTime;
meshInstance = runTime.timeName();
}
else

View File

@ -128,7 +128,7 @@ int main(int argc, char *argv[])
{
mesh.initialiseForConformation();
runTime++;
++runTime;
mesh.writeMesh(runTime.timeName());
}
@ -138,7 +138,7 @@ int main(int argc, char *argv[])
while (runTime.run())
{
runTime++;
++runTime;
Info<< nl << "Time = " << runTime.timeName() << endl;

View File

@ -571,7 +571,7 @@ int main(int argc, char *argv[])
if (writeMesh)
{
runTime++;
++runTime;
Info<< "Writing mesh to " << runTime.timeName() << endl;
backgroundMesh.mesh().write();
}

View File

@ -206,7 +206,7 @@ int main(int argc, char *argv[])
if (!overwrite)
{
runTime++;
++runTime;
}
else
{

View File

@ -56,7 +56,7 @@ int main(int argc, char *argv[])
if (!overwrite)
{
runTime++;
++runTime;
}
Info<< "Time = " << runTime.timeName() << nl

View File

@ -222,7 +222,7 @@ int main(int argc, char *argv[])
if (!overwrite)
{
runTime++;
++runTime;
}

View File

@ -832,7 +832,7 @@ int main(int argc, char *argv[])
if (!overwrite)
{
runTime++;
++runTime;
}
// Change the mesh. Change points directly (no inflation).

View File

@ -895,7 +895,7 @@ int main(int argc, char *argv[])
if (!overwrite)
{
runTime++;
++runTime;
}
else
{

View File

@ -443,7 +443,7 @@ int main(int argc, char *argv[])
if (!overwrite)
{
runTime++;
++runTime;
}
// Change the mesh. No inflation.
@ -513,7 +513,7 @@ int main(int argc, char *argv[])
if (!overwrite)
{
runTime++;
++runTime;
}
// Change the mesh. No inflation.

View File

@ -76,7 +76,7 @@ int main(int argc, char *argv[])
if (!overwrite)
{
runTime++;
++runTime;
mesh.setInstance(runTime.timeName());
}

View File

@ -541,7 +541,7 @@ int main(int argc, char *argv[])
if (!overwrite)
{
runTime++;
++runTime;
}
else
{

View File

@ -322,7 +322,7 @@ int main(int argc, char *argv[])
if (!overwrite)
{
runTime++;
++runTime;
}

View File

@ -1050,7 +1050,7 @@ int main(int argc, char *argv[])
if (!overwrite)
{
runTime++;
++runTime;
}

View File

@ -267,7 +267,7 @@ int main(int argc, char *argv[])
if (!overwrite)
{
runTime++;
++runTime;
}
splitter.attach();

View File

@ -1944,7 +1944,7 @@ int main(int argc, char *argv[])
if (!overwrite)
{
runTime++;
++runTime;
mesh.setInstance(runTime.timeName());
}
else
@ -1992,7 +1992,7 @@ int main(int argc, char *argv[])
if (!overwrite)
{
runTime++;
++runTime;
}

View File

@ -603,7 +603,7 @@ int main(int argc, char *argv[])
// Advance time for intermediate results or only on final
if (!overwrite && (intermediate || actioni == nActions))
{
runTime++;
++runTime;
}
// Execute all polyMeshModifiers

View File

@ -591,7 +591,7 @@ int main(int argc, char *argv[])
}
else
{
runTime++;
++runTime;
subsetter.subMesh().setInstance(runTime.timeName());
}

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -29,25 +29,28 @@ Group
Description
List times using timeSelector.
To simplify parsing of the output, the normal banner information
is suppressed.
The normal banner information is suppressed.
Usage
\b foamListTimes [OPTION]
Options:
- \par -processor
List times from processor0/ directory
- \par -rm
Remove selected time directories
- \par -processor
List times from processor0/ directory
- \par -verbose
Report progress during removal
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "autoPtr.H"
#include "profiling.H"
#include "timeSelector.H"
#include "Time.H"
#include "TimePaths.H"
using namespace Foam;
@ -72,15 +75,24 @@ int main(int argc, char *argv[])
"rm",
"remove selected time directories"
);
argList::addBoolOption
(
"verbose",
"report progress of -rm option"
);
profiling::disable(); // Disable profiling (and its output)
#include "setRootCase.H"
const bool removeFiles(args.found("rm"));
const bool verbose(args.found("verbose"));
// Get times list from the master processor and subset based on
// command-line options
label nProcs = 0;
instantList timeDirs;
autoPtr<TimePaths> timePaths;
if (args.found("processor"))
{
@ -94,47 +106,48 @@ int main(int argc, char *argv[])
<< exit(FatalError);
}
timeDirs = timeSelector::select
timePaths = autoPtr<TimePaths>::New
(
Time
(
Time::controlDictName,
args.rootPath(),
args.caseName()/"processor0"
).times(),
args
args.rootPath(),
args.caseName()/"processor0"
);
}
else
{
timeDirs = timeSelector::select
timePaths = autoPtr<TimePaths>::New
(
Time
(
Time::controlDictName,
args.rootPath(),
args.caseName()
).times(),
args
args.rootPath(),
args.caseName()
);
}
if (args.found("rm"))
const instantList timeDirs(timeSelector::select(timePaths->times(), args));
const label nTimes = timeDirs.size();
if (removeFiles)
{
if (nProcs)
{
// Serr<< "Remove " << timeDirs.size()
// << " processor time directories" << nl;
if (verbose)
{
Info<< "Removing " << nTimes
<< " processor time directories" << endl;
}
forAllReverse(timeDirs, timei)
{
fileName path
(
args.path()
/ "processors"
/ timeDirs[timei].name()
);
const word& timeName = timeDirs[timei].name();
if (verbose)
{
Info<< " rm " << timeName
<< " [" << (nTimes - timei) << '/' << nTimes << ']'
<< endl;
}
fileName path(args.path()/"processors"/timeName);
rmDir(path, true);
@ -143,8 +156,8 @@ int main(int argc, char *argv[])
path =
(
args.path()
/ (word("processor") + name(proci))
/ timeDirs[timei].name()
/ ("processor" + Foam::name(proci))
/ timeName
);
rmDir(path, true);
@ -153,25 +166,36 @@ int main(int argc, char *argv[])
}
else
{
// Serr<< "Remove " << timeDirs.size()
// << " time directories" << nl;
if (verbose)
{
Info<< "Removing " << nTimes
<< " time directories" << endl;
}
forAllReverse(timeDirs, timei)
{
rmDir(args.path()/timeDirs[timei].name(), true);
const word& timeName = timeDirs[timei].name();
if (verbose)
{
Info<< " rm " << timeName
<< " [" << (nTimes - timei) << '/' << nTimes << ']'
<< endl;
}
rmDir(args.path()/timeName, true);
}
}
}
else
{
forAll(timeDirs, timei)
for (const instant& t : timeDirs)
{
Info<< timeDirs[timei].name() << nl;
Info<< t.name() << nl;
}
Info<< flush;
}
return 0;
}

View File

@ -56,10 +56,11 @@ Usage
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "autoPtr.H"
#include "profiling.H"
#include "timeSelector.H"
#include "Enum.H"
#include "Time.H"
#include "TimePaths.H"
using namespace Foam;
@ -292,7 +293,7 @@ int main(int argc, char *argv[])
// command-line options
label nProcs = 0;
wordList timeDirs;
autoPtr<TimePaths> timePaths;
if (args.found("processor") && !Pstream::parRun())
{
@ -308,45 +309,33 @@ int main(int argc, char *argv[])
// Obtain time directory names from "processor0/" only
timeDirs = ListOps::create<word>
timePaths = autoPtr<TimePaths>::New
(
timeSelector::select
(
Time
(
Time::controlDictName,
args.rootPath(),
args.caseName()/"processor0"
).times(),
args
),
[](const instant& t){ return t.name(); }
args.rootPath(),
args.caseName()/"processor0"
);
}
else
{
timeDirs = ListOps::create<word>
timePaths = autoPtr<TimePaths>::New
(
timeSelector::select
(
Time(Time::controlDictName, args).times(),
args
),
[](const instant& t){ return t.name(); }
args.rootPath(),
args.caseName()
);
Pstream::scatter(timeDirs);
}
const instantList timeDirs(timeSelector::select(timePaths->times(), args));
if (timeDirs.empty())
{
Info<< "no times selected" << nl;
}
for (const word& dirName : timeDirs)
for (const instant& t : timeDirs)
{
Info<< "\nTime = " << dirName << nl;
const word& timeName = t.name();
Info<< "\nTime = " << timeName << nl;
label count = 0;
@ -354,7 +343,7 @@ int main(int argc, char *argv[])
{
const wordHashSet files
(
getFiles(args.path()/"processor0", dirName)
getFiles(args.path()/"processor0", timeName)
);
for (label proci=0; proci < nProcs; ++proci)
@ -362,7 +351,7 @@ int main(int argc, char *argv[])
count += restoreFields
(
method,
args.path()/("processor" + Foam::name(proci))/dirName,
args.path()/("processor" + Foam::name(proci))/timeName,
files,
targetNames
);
@ -373,14 +362,14 @@ int main(int argc, char *argv[])
wordList files;
if (Pstream::master())
{
files = getFiles(args.path(), dirName);
files = getFiles(args.path(), timeName);
}
Pstream::scatter(files);
count += restoreFields
(
method,
args.path()/dirName,
args.path()/timeName,
wordHashSet(files),
targetNames
);

View File

@ -1156,7 +1156,7 @@ autoPtr<mapDistributePolyMesh> redistributeAndWrite
if (!overwrite)
{
runTime++;
++runTime;
mesh.setInstance(runTime.timeName());
}
else

View File

@ -65,7 +65,7 @@ int main(int argc, char *argv[])
{
scalar t0 = runTime.userTimeToTime(ca0 - runTime.theta());
runTime.setDeltaT(t0);
runTime++;
++runTime;
Info<< "CA = " << runTime.theta() << endl;
mesh.move();
}
@ -76,7 +76,7 @@ int main(int argc, char *argv[])
{
scalar t1 = runTime.userTimeToTime(ca1 - runTime.theta());
runTime.setDeltaT(t1);
runTime++;
++runTime;
Info<< "CA = " << runTime.theta() << endl;
mesh.move();
}

View File

@ -324,7 +324,7 @@ int main(int argc, char *argv[])
Info<< endl;
runTime++;
++runTime;
// Write resulting mesh
Info<< "Writing modified mesh to time " << runTime.value() << endl;

View File

@ -84,7 +84,7 @@ _of_complete_cache_[foamDataToFluent]="-case -fileHandler -listScalarBCs -listVe
_of_complete_cache_[foamDictionary]="-add -case -decomposeParDict -diff -diff-etc -entry -fileHandler -hostRoots -roots -set | -disableFunctionEntries -expand -includes -keywords -noFunctionObjects -parallel -remove -value -doc -doc-source -help -help-full"
_of_complete_cache_[foamFormatConvert]="-case -decomposeParDict -fileHandler -hostRoots -listScalarBCs -listVectorBCs -region -roots -time | -constant -enableFunctionEntries -latestTime -listFunctionObjects -listRegisteredSwitches -listSwitches -listUnsetSwitches -newTimes -noConstant -noFunctionObjects -noZero -parallel -doc -doc-source -help -help-full"
_of_complete_cache_[foamListRegions]="-case -fileHandler | -listFunctionObjects -listRegisteredSwitches -listSwitches -listUnsetSwitches -doc -doc-source -help -help-full"
_of_complete_cache_[foamListTimes]="-case -fileHandler -time | -constant -latestTime -listFunctionObjects -listRegisteredSwitches -listSwitches -listUnsetSwitches -newTimes -noZero -processor -rm -withZero -doc -doc-source -help -help-full"
_of_complete_cache_[foamListTimes]="-case -fileHandler -time | -constant -latestTime -listFunctionObjects -listRegisteredSwitches -listSwitches -listUnsetSwitches -newTimes -noZero -processor -rm -verbose -withZero -doc -doc-source -help -help-full"
_of_complete_cache_[foamMeshToFluent]="-case -fileHandler | -listFunctionObjects -listRegisteredSwitches -listSwitches -listUnsetSwitches -noFunctionObjects -doc -doc-source -help -help-full"
_of_complete_cache_[foamRestoreFields]="-case -decomposeParDict -fileHandler -hostRoots -method -roots -time | -constant -dry-run -latestTime -listFunctionObjects -listRegisteredSwitches -listSwitches -listUnsetSwitches -newTimes -noZero -parallel -processor -verbose -withZero -doc -doc-source -help -help-full"
_of_complete_cache_[foamToEnsight]="-case -cellZone -decomposeParDict -faceZones -fields -fileHandler -hostRoots -listScalarBCs -listVectorBCs -name -patches -region -roots -time -width | -ascii -constant -latestTime -listFunctionObjects -listRegisteredSwitches -listSwitches -listUnsetSwitches -newTimes -noFunctionObjects -noLagrangian -noPatches -noZero -nodeValues -parallel -doc -doc-source -help -help-full"

View File

@ -286,7 +286,6 @@ $(Time)/TimePaths.C
$(Time)/TimeState.C
$(Time)/Time.C
$(Time)/TimeIO.C
$(Time)/findTimes.C
$(Time)/subCycleTime.C
$(Time)/subLoopTime.C
$(Time)/timeSelector.C

View File

@ -244,21 +244,42 @@ void inplaceUniqueSort
);
//- Extract elements of List when select is true
// eg, to extract all selected elements:
//- Extract elements of the input List when select is true.
//
// \param select the bool-list selector, for which the operator[]
// returns true or false. A labelHashSet can also be used since
// it satisfies these requirements
// \param input the list input values. Cannot be a FixedList since
// it doesn't resize.
// \param invert set as true to invert the selection logic
//
// Eg, to extract all selected elements:
// \code
// subset<boolList, labelList>(selectedElems, list);
// Note a labelHashSet can also be used as the bool-list.
// Do not use FixedList for the input list, since it doesn't resize.
// \endcode
template<class BoolListType, class ListType>
ListType subset(const BoolListType& select, const ListType& input);
ListType subset
(
const BoolListType& select,
const ListType& input,
const bool invert=false
);
//- Inplace extract elements of List when select is true
// eg, to extract all selected elements:
// inplaceSubset<boolList, labelList>(selectedElems, list);
// Note a labelHashSet can also be used as the bool-list.
// Do not use FixedList for the input list, since it doesn't resize.
//- Inplace extract elements of the input List when select is true.
//
// \param select the bool-list selector, for which the operator[]
// returns true or false. A labelHashSet can also be used since
// it satisfies these requirements
// \param input the list input values. Cannot be a FixedList since
// it doesn't resize.
// \param invert set as true to invert the selection logic
template<class BoolListType, class ListType>
void inplaceSubset(const BoolListType& select, ListType& input);
void inplaceSubset
(
const BoolListType& select,
ListType& input,
const bool invert=false
);
//- Copy a subset of the input list when predicate is true.

Some files were not shown because too many files have changed in this diff Show More