Commit 8edf105c authored by Mark Olesen's avatar Mark Olesen
Browse files

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

parent 7941b047
......@@ -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.
......
......@@ -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;
......
......@@ -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
......
......@@ -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;
}
......
......@@ -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);
......
......@@ -48,6 +48,7 @@ Note
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "timeSelector.H"
#include "IOobjectList.H"
#include "IOmanip.H"
#include "OFstream.H"
......
......@@ -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);
......
......@@ -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());
......
......@@ -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;
......
......@@ -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;
......@@ -19,9 +19,9 @@ int USERD_get_maxsize_info
label nPyr05Max = 0;
label nTet04Max = 0;
Info << "Checking all time steps for EnSight memory allocation purpose. This can take some time." << endl;
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;
......
......@@ -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;
......
......@@ -4,13 +4,12 @@ int USERD_get_timeset_description
char timeset_description[Z_BUFL]
)
{
#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;
......
......@@ -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;
......
......@@ -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)
......
......@@ -5,7 +5,6 @@ nVar -= Num_variables - nSprayVariables + lagrangianScalarNames.size();
if (nVar >= 0)
{
word name = lagrangianVectorNames[nVar];
IOField<vector> v
......@@ -42,7 +41,7 @@ if (nVar >= 0)
}
else
{
//Info << "getLagrangianVector: nVar = " << nVar << endl;
// Info<< "getLagrangianVector: nVar = " << nVar << endl;
return Z_UNDEF;
}
......@@ -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;
......
......@@ -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
......
......@@ -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"