cleanup of time handling (cosmetic changes), used timeSelector in more places

This commit is contained in:
Mark Olesen
2009-05-20 15:40:30 +02:00
parent 7941b04785
commit 8edf105c45
43 changed files with 283 additions and 269 deletions

View File

@ -45,6 +45,7 @@ Description
#include "argList.H"
#include "Time.H"
#include "timeSelector.H"
#include "fvMesh.H"
#include "mathematicalConstants.H"
#include "polyTopoChange.H"
@ -340,7 +341,8 @@ void dumpFeatures
int main(int argc, char *argv[])
{
argList::noParallel();
# include "addTimeOptions.H"
timeSelector::addOptions(true, false);
argList::validArgs.append("feature angle[0-180]");
argList::validOptions.insert("splitAllFaces", "");
argList::validOptions.insert("doNotPreserveFaceZones", "");
@ -349,13 +351,10 @@ int main(int argc, char *argv[])
# include "setRootCase.H"
# include "createTime.H"
// Get times list
instantList Times = runTime.times();
# include "checkTimeOptions.H"
runTime.setTime(Times[startTime], startTime);
instantList timeDirs = timeSelector::select0(runTime, args);
# include "createMesh.H"
const word oldInstance = mesh.pointsInstance();
// Mark boundary edges and points.

View File

@ -59,11 +59,10 @@ int main(int argc, char *argv[])
pointField zeroPoints(mesh.points());
runTime.setTime(Times[0], 0);
for (int i = 1; i<Times.size(); i++)
// skip "constant" time
for (label timeI = 1; timeI < Times.size(); ++timeI)
{
runTime.setTime(Times[i], i);
runTime.setTime(Times[timeI], timeI);
Info<< "Time = " << runTime.timeName() << endl;

View File

@ -387,7 +387,6 @@ int main(int argc, char *argv[])
const word oldInstance = mesh.pointsInstance();
const bool blockOrder = args.optionFound("blockOrder");
if (blockOrder)
{
Info<< "Ordering cells into regions (using decomposition);"
@ -396,7 +395,6 @@ int main(int argc, char *argv[])
}
const bool orderPoints = args.optionFound("orderPoints");
if (orderPoints)
{
Info<< "Ordering points into internal and boundary points." << nl

View File

@ -591,24 +591,10 @@ commandStatus parseType
}
else if (setType == "time")
{
scalar time = readScalar(is);
scalar requestedTime = readScalar(is);
instantList Times = runTime.times();
int nearestIndex = -1;
scalar nearestDiff = Foam::GREAT;
forAll(Times, timeIndex)
{
if (Times[timeIndex].name() == "constant") continue;
scalar diff = fabs(Times[timeIndex].value() - time);
if (diff < nearestDiff)
{
nearestDiff = diff;
nearestIndex = timeIndex;
}
}
label nearestIndex = Time::findClosestTimeIndex(Times, requestedTime);
Pout<< "Changing time from " << runTime.timeName()
<< " to " << Times[nearestIndex].name()
@ -646,7 +632,8 @@ commandStatus parseType
}
default:
{
FatalErrorIn("parseType") << "Illegal mesh update state "
FatalErrorIn("parseType")
<< "Illegal mesh update state "
<< stat << abort(FatalError);
break;
}
@ -746,7 +733,7 @@ int main(int argc, char *argv[])
Pout<< "Reading commands from file " << batchFile << endl;
// we also cannot handle .gz files
// we cannot handle .gz files
if (!isFile(batchFile, false))
{
FatalErrorIn(args.executable())
@ -864,7 +851,7 @@ int main(int argc, char *argv[])
delete fileStreamPtr;
}
Pout << nl << "End" << endl;
Pout<< "\nEnd" << endl;
return 0;
}

View File

@ -64,7 +64,6 @@ int main(int argc, char *argv[])
# include "setRootCase.H"
# include "createTime.H"
bool noFlipMap = args.optionFound("noFlipMap");
// Get times list
@ -73,9 +72,8 @@ int main(int argc, char *argv[])
label startTime = Times.size()-1;
label endTime = Times.size();
// check -time and -latestTime options
# include "checkTimeOption.H"
# include "checkLatestTimeOption.H"
runTime.setTime(Times[startTime], startTime);

View File

@ -48,6 +48,7 @@ Note
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "timeSelector.H"
#include "IOobjectList.H"
#include "IOmanip.H"
#include "OFstream.H"

View File

@ -23,7 +23,8 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
Write out the FOAM mesh in Version 3.0 Fieldview-UNS format (binary).
Write out the OpenFOAM mesh in Version 3.0 Fieldview-UNS format (binary).
See Fieldview Release 9 Reference Manual - Appendix D
(Unstructured Data Format)
Borrows various from uns/write_binary_uns.c from FieldView dist.
@ -31,6 +32,7 @@ Description
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "timeSelector.H"
#include "volFields.H"
#include "surfaceFields.H"
#include "pointFields.H"
@ -176,20 +178,15 @@ int main(int argc, char *argv[])
{
argList::noParallel();
argList::validOptions.insert("noWall", "");
timeSelector::addOptions(true, false);
# include "addTimeOptions.H"
# include "setRootCase.H"
# include "createTime.H"
instantList Times = runTime.times();
# include "checkTimeOptions.H"
runTime.setTime(Times[startTime], startTime);
instantList timeDirs = timeSelector::select0(runTime, args);
# include "createMesh.H"
// Initialize name mapping table
FieldviewNames.insert("alpha", "aalpha");
FieldviewNames.insert("Alpha", "AAlpha");
@ -285,17 +282,16 @@ int main(int argc, char *argv[])
label fieldViewTime = 0;
for (label i=startTime; i<endTime; i++)
forAll(timeDirs, timeI)
{
runTime.setTime(Times[i], i);
Info<< "Time " << Times[i].name() << endl;
runTime.setTime(timeDirs[timeI], timeI);
Info<< "Time: " << runTime.timeName() << endl;
fvMesh::readUpdateState state = mesh.readUpdate();
if
(
i == startTime
timeI == 0
|| state == fvMesh::TOPO_CHANGE
|| state == fvMesh::TOPO_PATCH_CHANGE
)
@ -334,7 +330,7 @@ int main(int argc, char *argv[])
fileName fvFileName
(
fvPath/runTime.caseName() + "_" + Foam::name(i) + ".uns"
fvPath/runTime.caseName() + "_" + Foam::name(timeI) + ".uns"
);
Info<< " file:" << fvFileName.c_str() << endl;
@ -364,7 +360,7 @@ int main(int argc, char *argv[])
// Output constants for time, fsmach, alpha and re.
float fBuf[4];
fBuf[0] = Times[i].value();
fBuf[0] = runTime.value();
fBuf[1] = 0.0;
fBuf[2] = 0.0;
fBuf[3] = 1.0;
@ -892,7 +888,7 @@ int main(int argc, char *argv[])
writeInt(fvParticleFile, fieldViewTime + 1);
// Time value
writeFloat(fvParticleFile, Times[i].value());
writeFloat(fvParticleFile, runTime.value());
// Read particles
Cloud<passiveParticle> parcels(mesh);

View File

@ -5,9 +5,9 @@ HashSet<word> surfVectorHash;
HashSet<word> sprayScalarHash;
HashSet<word> sprayVectorHash;
forAll(Times, timeI)
forAll(timeDirs, timeI)
{
runTime.setTime(Times[timeI], timeI);
runTime.setTime(timeDirs[timeI], timeI);
// Add all fields to hashtable
IOobjectList objects(mesh, runTime.timeName());

View File

@ -113,11 +113,9 @@ int Foam::vtkPV3Foam::setTime(int nRequest, const double requestTimes[])
instantList Times = runTime.times();
int nearestIndex = timeIndex_;
for (int requestI = 0; requestI < nRequest; ++requestI)
{
int index = Time::findClosestTimeIndex(Times, requestTimes[requestI]);
if (index >= 0 && index != timeIndex_)
{
nearestIndex = index;
@ -125,7 +123,6 @@ int Foam::vtkPV3Foam::setTime(int nRequest, const double requestTimes[])
}
}
if (nearestIndex < 0)
{
nearestIndex = 0;

View File

@ -8,7 +8,7 @@ int USERD_get_maxsize_info
return Z_ERR;
#ifdef ENSIGHTDEBUG
Info << "Entering: USERD_get_maxsize_info" << endl << flush;
Info << "Entering: USERD_get_maxsize_info" << endl;
#endif
label maxNPoints = 0;
@ -21,7 +21,7 @@ int USERD_get_maxsize_info
Info<< "Checking all time steps for EnSight memory allocation purpose. This can take some time." << endl;
for (label t=1; t < TimeList.size(); t++)
for (label timeI=1; timeI < timeDirs.size(); ++timeI)
{
label nPen06 = 0;
@ -29,21 +29,21 @@ int USERD_get_maxsize_info
label nPyr05 = 0;
label nTet04 = 0;
runTimePtr->setTime(TimeList[t], t);
runTimePtr->setTime(timeDirs[timeI], timeI);
Info << "Checking time = " << TimeList[t].value() << endl << flush;
Info<< "Checking time = " << runTimePtr->timeName() << endl;
const cellShapeList& cells = meshPtr->cellShapes();
label nPoints = meshPtr->nPoints();
label nCells = cells.size();
const label nPoints = meshPtr->nPoints();
const label nCells = cells.size();
maxNPoints = max(maxNPoints, nPoints);
for (label n=0; n<nCells;n++)
{
label nFaces = cells[n].nFaces();
labelList points = cells[n];
const labelList& points = cells[n];
if ((nFaces == 6) && (points.size() == 8))
{
@ -70,7 +70,6 @@ int USERD_get_maxsize_info
if (Numparts_available > 1)
{
// Get the maximum number of spray parcels
// and store it
Cloud<passiveParticle> lagrangian(*meshPtr);
@ -79,9 +78,7 @@ int USERD_get_maxsize_info
{
nMaxParcels = lagrangian.size();
}
}
}
max_number_of_nodes[0] = maxNPoints;
@ -97,7 +94,7 @@ int USERD_get_maxsize_info
}
#ifdef ENSIGHTDEBUG
Info << "Leaving: USERD_get_maxsize_info" << endl << flush;
Info<< "Leaving: USERD_get_maxsize_info" << endl;
#endif
return Z_OK;

View File

@ -10,18 +10,18 @@ int USERD_get_sol_times
)
{
#ifdef ENSIGHTDEBUG
Info << "Entering: USERD_get_sol_times" << endl << flush;
Info << TimeList << endl;
Info<< "Entering: USERD_get_sol_times\n" << timeDirs << endl;
#endif
for (label n=0; n<Num_time_steps;n++)
{
solution_times[n] = TimeList[n+1].value();
solution_times[n] = timeDirs[n+1].value();
}
if (TimeList[1].value() < 0)
if (timeDirs[1].value() < 0)
{
scalar addCAD = 360.0;
while (TimeList[1].value() + addCAD < 0.0)
while (timeDirs[1].value() + addCAD < 0.0)
{
addCAD += 360.0;
}
@ -29,14 +29,14 @@ int USERD_get_sol_times
{
solution_times[n] += addCAD;
Info << "Time[" << n << "] = " << TimeList[n+1].value()
Info << "Time[" << n << "] = " << timeDirs[n+1].value()
<< " was corrected to " << solution_times[n] << endl;
}
}
#ifdef ENSIGHTDEBUG
Info << "Leaving: USERD_get_sol_times" << endl << flush;
Info<< "Leaving: USERD_get_sol_times" << endl;
#endif
return Z_OK;

View File

@ -6,11 +6,10 @@ int USERD_get_timeset_description
{
#ifdef ENSIGHTDEBUG
Info << "Entering: USERD_get_timeset_description" << endl
<< flush;
Info<< "Entering: USERD_get_timeset_description" << endl;
#endif
if (TimeList[1].value() < 0)
if (timeDirs[1].value() < 0)
{
strncpy(timeset_description, "CAD", Z_BUFL);
}
@ -20,8 +19,7 @@ int USERD_get_timeset_description
}
#ifdef ENSIGHTDEBUG
Info << "Leaving: USERD_get_timeset_description" << endl
<< flush;
Info<< "Leaving: USERD_get_timeset_description" << endl;
#endif
return Z_OK;

View File

@ -79,18 +79,18 @@ int USERD_set_filenames
);
// set the available number of time-steps
TimeList = (const instantList&)Foam::Time::findTimes(rootDir/caseDir);
timeDirs = Foam::Time::findTimes(rootDir/caseDir);
Num_time_steps = TimeList.size() - 1;
Num_time_steps = timeDirs.size() - 1;
nPatches = meshPtr->boundaryMesh().size();
// set the number of fields and store their names
// a valid field must exist for all time-steps
runTime.setTime(TimeList[TimeList.size()-1], TimeList.size()-1);
runTime.setTime(timeDirs[timeDirs.size()-1], timeDirs.size()-1);
IOobjectList objects(*meshPtr, runTime.timeName());
fieldNames = (const wordList&)objects.names();
fieldNames = objects.names();
// because of the spray being a 'field' ...
// get the availabe number of variables and
@ -149,7 +149,7 @@ int USERD_set_filenames
label n = 0;
while (!lagrangianNamesFound && n < Num_time_steps)
{
runTime.setTime(TimeList[n+1], n+1);
runTime.setTime(timeDirs[n+1], n+1);
Cloud<passiveParticle> lagrangian(*meshPtr);
@ -195,7 +195,7 @@ int USERD_set_filenames
}
Current_time_step = Num_time_steps;
runTime.setTime(TimeList[Current_time_step], Current_time_step);
runTime.setTime(timeDirs[Current_time_step], Current_time_step);
Num_variables = nVar + nSprayVariables;
Numparts_available = Num_unstructured_parts + Num_structured_parts + nPatches;

View File

@ -20,18 +20,30 @@ void USERD_set_time_set_and_step
if (time_step == 0)
{
runTime.setTime(TimeList[Current_time_step], Current_time_step);
runTime.setTime
(
timeDirs[Current_time_step],
Current_time_step
);
}
else
{
runTime.setTime(TimeList[Current_time_step + 1], Current_time_step + 1);
runTime.setTime
(
timeDirs[Current_time_step + 1],
Current_time_step + 1
);
}
meshPtr->readUpdate();
if (time_step == 0)
{
runTime.setTime(TimeList[Current_time_step + 1], Current_time_step + 1);
runTime.setTime
(
timeDirs[Current_time_step + 1],
Current_time_step + 1
);
}
if (Numparts_available > nPatches+1)

View File

@ -5,7 +5,6 @@ nVar -= Num_variables - nSprayVariables + lagrangianScalarNames.size();
if (nVar >= 0)
{
word name = lagrangianVectorNames[nVar];
IOField<vector> v

View File

@ -41,7 +41,7 @@ static word pointPrepend = "point_";
static fileName rootDir;
static fileName caseDir;
static instantList TimeList;
static instantList timeDirs;
static List<word> fieldNames;
static List<word> lagrangianScalarNames;

View File

@ -12,7 +12,7 @@
IOobject
(
"txx",
Times[i].name(),
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
@ -28,7 +28,7 @@
IOobject
(
"tyy",
Times[i].name(),
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
@ -44,7 +44,7 @@
IOobject
(
"tzz",
Times[i].name(),
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
@ -60,7 +60,7 @@
IOobject
(
"txy",
Times[i].name(),
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE

View File

@ -48,18 +48,13 @@ Description
int main(int argc, char *argv[])
{
argList::noParallel();
# include "addTimeOptions.H"
# include "setRootCase.H"
timeSelector::addOptions();
# include "setRootCase.H"
# include "createTime.H"
// Get times list
instantList Times = runTime.times();
// set startTime and endTime depending on -time and -latestTime options
# include "checkTimeOptions.H"
runTime.setTime(Times[startTime], startTime);
instantList timeDirs = timeSelector::select0(runTime, args);
# include "createMesh.H"
# include "readTransportProperties.H"
@ -83,10 +78,9 @@ int main(int argc, char *argv[])
// For each time step read all fields
for (label i=startTime; i<endTime; i++)
forAll(timeDirs, timeI)
{
runTime.setTime(Times[i], i);
runTime.setTime(timeDirs[timeI], timeI);
Info<< "Collapsing fields for time " << runTime.timeName() << endl;
# include "readFields.H"
@ -96,7 +90,7 @@ int main(int argc, char *argv[])
# include "collapse.H"
}
Info<< "end" << endl;
Info<< "\nEnd" << endl;
return 0;
}

View File

@ -1,7 +1,7 @@
IOobject UMeanHeader
(
"UMean",
runTime.times()[i].name(),
runTime.timeName(),
mesh,
IOobject::MUST_READ
);
@ -23,7 +23,7 @@
IOobject
(
"UPrime2Mean",
runTime.times()[i].name(),
runTime.timeName(),
mesh,
IOobject::MUST_READ
),
@ -39,7 +39,7 @@
IOobject
(
"pPrime2Mean",
runTime.times()[i].name(),
runTime.timeName(),
mesh,
IOobject::MUST_READ
),
@ -52,7 +52,7 @@
IOobject
(
"epsilonMean",
runTime.times()[i].name(),
runTime.timeName(),
mesh,
IOobject::MUST_READ
),
@ -64,7 +64,7 @@
IOobject
(
"nuMean",
runTime.times()[i].name(),
runTime.timeName(),
mesh,
IOobject::MUST_READ
),
@ -76,7 +76,7 @@
IOobject
(
"gammaDotMean",
runTime.times()[i].name(),
runTime.timeName(),
mesh,
IOobject::MUST_READ
),
@ -88,7 +88,7 @@
IOobject
(
"nuPrime",
runTime.times()[i].name(),
runTime.timeName(),
mesh,
IOobject::MUST_READ
),
@ -102,7 +102,7 @@
IOobject
(
"gammaDotPrime",
runTime.times()[i].name(),
runTime.timeName(),
mesh,
IOobject::MUST_READ
),

View File

@ -1,4 +1,4 @@
Info<< nl << "Create databases as time" << endl;
Info << "\nCreate databases as time" << endl;
Time runTimeSource
(

View File

@ -43,31 +43,6 @@ Description
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int getTimeIndex
(
const instantList& times,
const scalar t
)
{
int nearestIndex = -1;
scalar nearestDiff = Foam::GREAT;
forAll(times, timeIndex)
{
if (times[timeIndex].name() == "constant") continue;
scalar diff = fabs(times[timeIndex].value() - t);
if (diff < nearestDiff)
{
nearestDiff = diff;
nearestIndex = timeIndex;
}
}
return nearestIndex;
}
void mapConsistentMesh
(
const fvMesh& meshSource,
@ -254,9 +229,7 @@ wordList addProcessorPatches
int main(int argc, char *argv[])
{
# include "setRoots.H"
# include "createTimes.H"
# include "setTimeIndex.H"
runTimeSource.setTime(sourceTimes[sourceTimeIndex], sourceTimeIndex);

View File

@ -8,12 +8,18 @@
}
else
{
scalar sourceTime = args.optionRead<scalar>("sourceTime");
sourceTimeIndex = getTimeIndex(sourceTimes, sourceTime);
sourceTimeIndex = Time::findClosestTimeIndex
(
sourceTimes,
args.optionRead<scalar>("sourceTime")
);
}
}
else
{
scalar sourceTime = runTimeTarget.time().value();
sourceTimeIndex = getTimeIndex(sourceTimes, sourceTime);
sourceTimeIndex = Time::findClosestTimeIndex
(
sourceTimes,
runTimeTarget.time().value()
);
}

View File

@ -28,6 +28,7 @@ Description
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "timeSelector.H"
#include "Time.H"
#include "fvMesh.H"
#include "topoSetSource.H"
@ -174,19 +175,13 @@ public:
int main(int argc, char *argv[])
{
timeSelector::addOptions();
# include "addTimeOptions.H"
# include "setRootCase.H"
# include "createTime.H"
// Get times list
instantList Times = runTime.times();
// set startTime and endTime depending on -time and -latestTime options
# include "checkTimeOptions.H"
runTime.setTime(Times[startTime], startTime);
instantList timeDirs = timeSelector::select0(runTime, args);
# include "createMesh.H"
@ -220,9 +215,9 @@ int main(int argc, char *argv[])
PtrList<entry> regions(setFieldsDict.lookup("regions"));
forAll(regions, regioni)
forAll(regions, regionI)
{
const entry& region = regions[regioni];
const entry& region = regions[regionI];
autoPtr<topoSetSource> cellSelector =
topoSetSource::New(region.keyword(), mesh, region.dict());
@ -247,7 +242,7 @@ int main(int argc, char *argv[])
);
}
Info << nl << "End" << endl;
Info<< "\nEnd" << endl;
return 0;
}

View File

@ -109,20 +109,20 @@ void Foam::Time::setControls()
else
{
// Search directory for valid time directories
instantList Times = findTimes(path());
instantList timeDirs = findTimes(path());
if (startFrom == "firstTime")
{
if (Times.size())
if (timeDirs.size())
{
startTime_ = Times[0].value();
startTime_ = timeDirs[0].value();
}
}
else if (startFrom == "latestTime")
{
if (Times.size())
if (timeDirs.size())
{
startTime_ = Times[Times.size()-1].value();
startTime_ = timeDirs[timeDirs.size()-1].value();
}
}
else
@ -385,13 +385,13 @@ Foam::instantList Foam::Time::times() const
Foam::word Foam::Time::findInstancePath(const instant& t) const
{
instantList times = Time::findTimes(path());
instantList timeDirs = findTimes(path());
forAllReverse(times, i)
forAllReverse(timeDirs, timeI)
{
if (times[i] == t)
if (timeDirs[timeI] == t)
{
return times[i].name();
return timeDirs[timeI].name();
}
}
@ -401,37 +401,37 @@ Foam::word Foam::Time::findInstancePath(const instant& t) const
Foam::instant Foam::Time::findClosestTime(const scalar t) const
{
instantList times = Time::findTimes(path());
instantList timeDirs = findTimes(path());
// If there is only one time it is "constant" so return it
if (times.size() == 1)
// there is only one time (likely "constant") so return it
if (timeDirs.size() == 1)
{
return times[0];
return timeDirs[0];
}
if (t < times[1].value())
if (t < timeDirs[1].value())
{
return times[1];
return timeDirs[1];
}
else if (t > times[times.size() - 1].value())
else if (t > timeDirs[timeDirs.size()-1].value())
{
return times[times.size() - 1];
return timeDirs[timeDirs.size()-1];
}
label nearestIndex = -1;
scalar deltaT = GREAT;
for (label i=1; i < times.size(); i++)
for (label timeI=1; timeI < timeDirs.size(); ++timeI)
{
scalar diff = mag(times[i].value() - t);
scalar diff = mag(timeDirs[timeI].value() - t);
if (diff < deltaT)
{
deltaT = diff;
nearestIndex = i;
nearestIndex = timeI;
}
}
return times[nearestIndex];
return timeDirs[nearestIndex];
}
@ -440,29 +440,29 @@ Foam::instant Foam::Time::findClosestTime(const scalar t) const
//
// Foam::instant Foam::Time::findClosestTime(const scalar t) const
// {
// instantList times = Time::findTimes(path());
// label timeIndex = min(findClosestTimeIndex(times, t), 0);
// return times[timeIndex];
// instantList timeDirs = findTimes(path());
// label timeIndex = min(findClosestTimeIndex(timeDirs, t), 0);
// return timeDirs[timeIndex];
// }
Foam::label Foam::Time::findClosestTimeIndex
(
const instantList& times,
const instantList& timeDirs,
const scalar t
)
{
label nearestIndex = -1;
scalar deltaT = GREAT;
forAll (times, i)
forAll(timeDirs, timeI)
{
if (times[i].name() == "constant") continue;
if (timeDirs[timeI].name() == "constant") continue;
scalar diff = fabs(times[i].value() - t);
scalar diff = mag(timeDirs[timeI].value() - t);
if (diff < deltaT)
{
deltaT = diff;
nearestIndex = i;
nearestIndex = timeI;
}
}

View File

@ -170,7 +170,7 @@ Foam::List<Foam::instant> Foam::timeSelector::select
// determine latestTime selection (if any)
// this must appear before the -time option processing
label latestIdx = -1;
if (args.options().found("latestTime"))
if (args.optionFound("latestTime"))
{
selectTimes = false;
latestIdx = timeDirs.size() - 1;
@ -182,12 +182,12 @@ Foam::List<Foam::instant> Foam::timeSelector::select
}
}
if (args.options().found("time"))
if (args.optionFound("time"))
{
// can match 0/, but can never match constant/
selectTimes = timeSelector
(
IStringStream(args.options()["time"])()
args.optionLookup("time")()
).selected(timeDirs);
}
@ -201,13 +201,13 @@ Foam::List<Foam::instant> Foam::timeSelector::select
if (constantIdx >= 0)
{
// only add constant/ if specifically requested
selectTimes[constantIdx] = args.options().found("constant");
selectTimes[constantIdx] = args.optionFound("constant");
}
// special treatment for 0/
if (zeroIdx >= 0)
{
if (args.options().found("noZero"))
if (args.optionFound("noZero"))
{
// exclude 0/ if specifically requested
selectTimes[zeroIdx] = false;
@ -215,7 +215,7 @@ Foam::List<Foam::instant> Foam::timeSelector::select
else if (argList::validOptions.found("zeroTime"))
{
// with -zeroTime enabled, drop 0/ unless specifically requested
selectTimes[zeroIdx] = args.options().found("zeroTime");
selectTimes[zeroIdx] = args.optionFound("zeroTime");
}
}

View File

@ -136,7 +136,7 @@ public:
);
//- Return the set of times selected based on the argList options
static List<Foam::instant> select
static List<instant> select
(
const List<instant>&,
const argList& args
@ -144,7 +144,7 @@ public:
//- Return the set of times selected based on the argList options
// also set the runTime to the first instance
static List<Foam::instant> select0
static List<instant> select0
(
Time& runTime,
const argList& args

View File

@ -1 +1,5 @@
argList::validOptions.insert("region", "name");
//
// addRegionOption.H
// ~~~~~~~~~~~~~~~~~
Foam::argList::validOptions.insert("region", "name");

View File

@ -2,7 +2,7 @@
// addTimeOptions.H
// ~~~~~~~~~~~~~~~~
argList::validOptions.insert("constant", "");
argList::validOptions.insert("latestTime", "");
argList::validOptions.insert("noZero", "");
argList::validOptions.insert("time", "time");
Foam::argList::validOptions.insert("constant", "");
Foam::argList::validOptions.insert("latestTime", "");
Foam::argList::validOptions.insert("noZero", "");
Foam::argList::validOptions.insert("time", "time");

View File

@ -1,4 +1,14 @@
if (Times.size() > 1 && !args.optionFound("constant"))
//
// checkConstantOption.H
// ~~~~~~~~~~~~~~~~~~~~~
// unless -constant is present, skip startTime if it is "constant"
if
(
!args.optionFound("constant")
&& (startTime < Times.size()-1)
&& (Times[startTime].name() == "constant")
)
{
startTime = 1;
startTime++;
}

View File

@ -1,4 +0,0 @@
if (args.optionFound("latestTime"))
{
startTime = Times.size() - 1;
}

View File

@ -1,7 +1,17 @@
//
// checkTimeOption.H
// ~~~~~~~~~~~~~~~~~
// check -time and -latestTime options
if (args.optionFound("time"))
{
scalar timeValue = args.optionRead<scalar>("time");
Foam::scalar timeValue = args.optionRead<scalar>("time");
startTime = Time::findClosestTimeIndex(Times, timeValue);
startTime = Foam::Time::findClosestTimeIndex(Times, timeValue);
endTime = startTime + 1;
}
if (args.optionFound("latestTime"))
{
startTime = Times.size() - 1;
}

View File

@ -1,6 +1,12 @@
label startTime = 0;
label endTime = Times.size();
//
// checkTimeOptions.H
// ~~~~~~~~~~~~~~~~~~
Foam::label startTime = 0;
Foam::label endTime = Times.size();
// unless -constant is present, skip startTime if it is "constant"
# include "checkConstantOption.H"
// check -time and -latestTime options
# include "checkTimeOption.H"
# include "checkLatestTimeOption.H"

View File

@ -1,5 +1,9 @@
label startTime = 0;
label endTime = Times.size();
//
// checkTimeOptionsNoConstant.H
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Foam::label startTime = 0;
Foam::label endTime = Times.size();
// check -time and -latestTime options
# include "checkTimeOption.H"
# include "checkLatestTimeOption.H"

View File

@ -1,4 +1,9 @@
Foam::Info<< "Create mesh for time = "
//
// createMesh.H
// ~~~~~~~~~~~~
Foam::Info
<< "Create mesh for time = "
<< runTime.timeName() << Foam::nl << Foam::endl;
Foam::fvMesh mesh

View File

@ -1,13 +1,19 @@
Info<< "Create mesh, no clear-out for time = "
<< runTime.timeName() << nl << endl;
//
// createMeshNoClear.H
// ~~~~~~~~~~~~~~~~~~~
// currently identical to createMesh.H
fvMesh mesh
Foam::Info
<< "Create mesh, no clear-out for time = "
<< runTime.timeName() << Foam::nl << Foam::endl;
Foam::fvMesh mesh
(
IOobject
Foam::IOobject
(
fvMesh::defaultRegion,
Foam::fvMesh::defaultRegion,
runTime.timeName(),
runTime,
IOobject::MUST_READ
Foam::IOobject::MUST_READ
)
);

View File

@ -1,24 +1,30 @@
word regionName;
//
// createNamedMesh.H
// ~~~~~~~~~~~~~~~~~
Foam::word regionName;
if (args.optionReadIfPresent("region", regionName))
{
Info<< "Create mesh " << regionName << " for time = "
<< runTime.timeName() << nl << endl;
Foam::Info
<< "Create mesh " << regionName << " for time = "
<< runTime.timeName() << Foam::nl << Foam::endl;
}
else
{
regionName = fvMesh::defaultRegion;
Info<< "Create mesh for time = "
<< runTime.timeName() << nl << endl;
regionName = Foam::fvMesh::defaultRegion;
Foam::Info
<< "Create mesh for time = "
<< runTime.timeName() << Foam::nl << Foam::endl;
}
fvMesh mesh
Foam::fvMesh mesh
(
IOobject
Foam::IOobject
(
regionName,
runTime.timeName(),
runTime,
IOobject::MUST_READ
Foam::IOobject::MUST_READ
)
);

View File

@ -1,24 +1,30 @@
word regionName;
//
// createNamedPolyMesh.H
// ~~~~~~~~~~~~~~~~~~~~~
Foam::word regionName;
if (args.optionReadIfPresent("region", regionName))
{
Info<< "Create polyMesh " << regionName << " for time = "
<< runTime.timeName() << nl << endl;
Foam::Info
<< "Create polyMesh " << regionName << " for time = "
<< runTime.timeName() << Foam::nl << Foam::endl;
}
else
{
regionName = polyMesh::defaultRegion;
Info<< "Create polyMesh for time = "
<< runTime.timeName() << nl << endl;
regionName = Foam::polyMesh::defaultRegion;
Foam::Info
<< "Create polyMesh for time = "
<< runTime.timeName() << Foam::nl << Foam::endl;
}
polyMesh mesh
Foam::polyMesh mesh
(
IOobject
Foam::IOobject
(
regionName,
runTime.timeName(),
runTime,
IOobject::MUST_READ
Foam::IOobject::MUST_READ
)
);

View File

@ -1,13 +1,18 @@
Info<< "Create polyMesh for time = "
<< runTime.timeName() << nl << endl;
//
// createPolyMesh.H
// ~~~~~~~~~~~~~~~~
polyMesh mesh
Foam::Info
<< "Create polyMesh for time = "
<< runTime.timeName() << Foam::nl << Foam::endl;
Foam::polyMesh mesh
(
IOobject
Foam::IOobject
(
polyMesh::defaultRegion,
Foam::polyMesh::defaultRegion,
runTime.timeName(),
runTime,
IOobject::MUST_READ
Foam::IOobject::MUST_READ
)
);

View File

@ -1,3 +1,7 @@
//
// createTime.H
// ~~~~~~~~~~~~
Foam::Info<< "Create time\n" << Foam::endl;
Foam::Time runTime

View File

@ -1,5 +1,8 @@
Foam::argList args(argc, argv);
//
// setRootCase.H
// ~~~~~~~~~~~~~
Foam::argList args(argc, argv);
if (!args.checkRootCase())
{
Foam::FatalError.exit();

View File

@ -232,14 +232,14 @@ void Foam::calcTypes::addSubtract::preCalc
<< exit(FatalError);
}
if (args.options().found("field"))
if (args.optionFound("field"))
{
addSubtractFieldName_ = args.options()["field"];
addSubtractFieldName_ = args.option("field");
calcType_ = FIELD;
}
else if (args.options().found("value"))
else if (args.optionFound("value"))
{
addSubtractValueStr_ = args.options()["value"];
addSubtractValueStr_ = args.option("value");
calcType_ = VALUE;
}
else
@ -249,9 +249,9 @@ void Foam::calcTypes::addSubtract::preCalc
<< nl << exit(FatalError);
}
if (args.options().found("resultName"))
if (args.optionFound("resultName"))
{
resultName_ = args.options()["resultName"];
resultName_ = args.option("resultName");
}
}