Commit 8b7f6666 authored by mattijs's avatar mattijs
Browse files

ENH: sets are now searched for.

Some tools now output sets at the pointsInstance (if relating to geometry),
some at the facesInstance (if relating to topology).
So when loading them we now search for them from current time down
to facesInstance. They cannot be beyond facesInstance.
Adapted Time::findInstance to take optional limiting instance. Adapted
topoSet to use this. Adapted all uses of IOobjectList on sets to do the
same.
parent e931525a
......@@ -304,7 +304,13 @@ void printAllSets(const polyMesh& mesh, Ostream& os)
IOobjectList objects
(
mesh,
mesh.pointsInstance(),
mesh.time().findInstance
(
polyMesh::meshSubDir/"sets",
word::null,
IOobject::READ_IF_PRESENT,
mesh.facesInstance()
),
polyMesh::meshSubDir/"sets"
);
IOobjectList cellSets(objects.lookupClass(cellSet::typeName));
......@@ -417,7 +423,13 @@ void removeSet
IOobjectList objects
(
mesh,
mesh.pointsInstance(),
mesh.time().findInstance
(
polyMesh::meshSubDir/"sets",
word::null,
IOobject::READ_IF_PRESENT,
mesh.facesInstance()
),
polyMesh::meshSubDir/"sets"
);
......
......@@ -81,14 +81,17 @@ int main(int argc, char *argv[])
# include "createNamedPolyMesh.H"
// Search for list of objects for the time of the mesh
IOobjectList objects
word setsInstance = runTime.findInstance
(
mesh,
mesh.pointsInstance(),
polyMesh::meshSubDir/"sets"
polyMesh::meshSubDir/"sets",
word::null,
IOobject::MUST_READ,
mesh.facesInstance()
);
Info<< "Searched : " << mesh.pointsInstance()/polyMesh::meshSubDir/"sets"
IOobjectList objects(mesh, setsInstance, polyMesh::meshSubDir/"sets");
Info<< "Searched : " << setsInstance/polyMesh::meshSubDir/"sets"
<< nl
<< "Found : " << objects.names() << nl
<< endl;
......
......@@ -400,25 +400,30 @@ void Foam::vtkPV3Foam::updateInfoSets
Info<< "<beg> Foam::vtkPV3Foam::updateInfoSets" << endl;
}
// Add names of sets
IOobjectList objects
// Add names of sets. Search for last time directory with a sets
// subdirectory. Take care not to search beyond the last mesh.
word facesInstance = dbPtr_().findInstance
(
dbPtr_(),
dbPtr_().findInstance(meshDir_, "faces", IOobject::READ_IF_PRESENT),
meshDir_/"sets"
meshDir_,
"faces",
IOobject::READ_IF_PRESENT
);
word setsInstance = dbPtr_().findInstance
(
meshDir_/"sets",
word::null,
IOobject::READ_IF_PRESENT,
facesInstance
);
IOobjectList objects(dbPtr_(), setsInstance, meshDir_/"sets");
if (debug)
{
Info<< " Foam::vtkPV3Foam::updateInfoSets read "
<< objects.names() << " from "
<< dbPtr_().findInstance
(
meshDir_,
"faces",
IOobject::READ_IF_PRESENT
)
<< endl;
<< objects.names() << " from " << setsInstance << endl;
}
......
......@@ -283,12 +283,14 @@ public:
//- Return the location of "dir" containing the file "name".
// (eg, used in reading mesh data)
// If name is null, search for the directory "dir" only
// If name is null, search for the directory "dir" only.
// Does not search beyond stopInstance (if set) or constant.
word findInstance
(
const fileName& dir,
const word& name = word::null,
const IOobject::readOption rOpt = IOobject::MUST_READ
const IOobject::readOption rOpt = IOobject::MUST_READ,
const word& stopInstance = word::null
) const;
//- Search the case for valid time directories
......
......@@ -39,19 +39,24 @@ Foam::word Foam::Time::findInstance
(
const fileName& dir,
const word& name,
const IOobject::readOption rOpt
const IOobject::readOption rOpt,
const word& stopInstance
) const
{
// Note: if name is empty, just check the directory itself
const fileName tPath(path());
const fileName dirPath(tPath/timeName()/dir);
// check the current time directory
if
(
name.empty()
? isDir(path()/timeName()/dir)
? isDir(dirPath)
:
(
isFile(path()/timeName()/dir/name)
isFile(dirPath/name)
&& IOobject(name, timeName(), dir, *this).headerOk()
)
)
......@@ -59,7 +64,8 @@ Foam::word Foam::Time::findInstance
if (debug)
{
Info<< "Time::findInstance"
"(const fileName&, const word&, const IOobject::readOption)"
"(const fileName&, const word&"
", const IOobject::readOption, const word&)"
<< " : found \"" << name
<< "\" in " << timeName()/dir
<< endl;
......@@ -88,10 +94,10 @@ Foam::word Foam::Time::findInstance
if
(
name.empty()
? isDir(path()/ts[instanceI].name()/dir)
? isDir(tPath/ts[instanceI].name()/dir)
:
(
isFile(path()/ts[instanceI].name()/dir/name)
isFile(tPath/ts[instanceI].name()/dir/name)
&& IOobject(name, ts[instanceI].name(), dir, *this).headerOk()
)
)
......@@ -99,7 +105,8 @@ Foam::word Foam::Time::findInstance
if (debug)
{
Info<< "Time::findInstance"
"(const fileName&, const word&, const IOobject::readOption)"
"(const fileName&, const word&"
", const IOobject::readOption, const word&)"
<< " : found \"" << name
<< "\" in " << ts[instanceI].name()/dir
<< endl;
......@@ -107,6 +114,34 @@ Foam::word Foam::Time::findInstance
return ts[instanceI].name();
}
// Check if hit minimum instance
if (ts[instanceI].name() == stopInstance)
{
if (debug)
{
Info<< "Time::findInstance"
"(const fileName&, const word&"
", const IOobject::readOption, const word&)"
<< " : hit stopInstance " << stopInstance
<< endl;
}
if (rOpt == IOobject::MUST_READ)
{
FatalErrorIn
(
"Time::findInstance"
"(const fileName&, const word&"
", const IOobject::readOption, const word&)"
) << "Cannot find file \"" << name << "\" in directory "
<< dir << " in times " << timeName()
<< " down to " << stopInstance
<< exit(FatalError);
}
return ts[instanceI].name();
}
}
......@@ -119,10 +154,10 @@ Foam::word Foam::Time::findInstance
if
(
name.empty()
? isDir(path()/constant()/dir)
? isDir(tPath/constant()/dir)
:
(
isFile(path()/constant()/dir/name)
isFile(tPath/constant()/dir/name)
&& IOobject(name, constant(), dir, *this).headerOk()
)
)
......@@ -130,7 +165,8 @@ Foam::word Foam::Time::findInstance
if (debug)
{
Info<< "Time::findInstance"
"(const fileName&, const word&, const IOobject::readOption)"
"(const fileName&, const word&"
", const IOobject::readOption, const word&)"
<< " : found \"" << name
<< "\" in " << constant()/dir
<< endl;
......@@ -144,9 +180,11 @@ Foam::word Foam::Time::findInstance
FatalErrorIn
(
"Time::findInstance"
"(const fileName&, const word&, const IOobject::readOption)"
"(const fileName&, const word&"
", const IOobject::readOption, const word&)"
) << "Cannot find file \"" << name << "\" in directory "
<< constant()/dir
<< dir << " in times " << timeName()
<< " down to " << constant()
<< exit(FatalError);
}
......
......@@ -77,11 +77,7 @@ void setUpdater::updateSets(const mapPolyMesh& morphMap) const
IOobjectList Objects
(
morphMap.mesh().time(),
morphMap.mesh().time().findInstance
(
morphMap.mesh().meshDir(),
"faces"
),
morphMap.mesh().facesInstance(),
"polyMesh/sets"
);
......
......@@ -124,6 +124,7 @@ Foam::label Foam::autoLayerDriver::mergePatchFacesUndo
}
Pout<< "Writing all faces to be merged to set "
<< allSets.objectPath() << endl;
allSets.instance() = mesh.time().timeName();
allSets.write();
}
......@@ -221,6 +222,7 @@ Foam::label Foam::autoLayerDriver::mergePatchFacesUndo
if (debug)
{
errorFaces.instance() = mesh.time().timeName();
Pout<< "Writing all faces in error to faceSet "
<< errorFaces.objectPath() << nl << endl;
errorFaces.write();
......@@ -266,6 +268,7 @@ Foam::label Foam::autoLayerDriver::mergePatchFacesUndo
if (debug)
{
faceSet restoreSet(mesh, "mastersToRestore", mastersToRestore);
restoreSet.instance() = mesh.time().timeName();
Pout<< "Writing all " << mastersToRestore.size()
<< " masterfaces to be restored to set "
<< restoreSet.objectPath() << endl;
......@@ -624,6 +627,7 @@ Foam::label Foam::autoLayerDriver::mergeEdgesUndo
if (debug)
{
errorFaces.instance() = mesh.time().timeName();
Pout<< "**Writing all faces in error to faceSet "
<< errorFaces.objectPath() << nl << endl;
errorFaces.write();
......@@ -806,6 +810,7 @@ void Foam::autoLayerDriver::checkMeshManifold() const
<< " points where this happens to pointSet "
<< nonManifoldPoints.name() << endl;
nonManifoldPoints.instance() = mesh.time().timeName();
nonManifoldPoints.write();
}
Info<< endl;
......@@ -945,6 +950,7 @@ void Foam::autoLayerDriver::handleNonManifolds
<< "and setting layer thickness to zero on these points."
<< endl;
nonManifoldPoints.instance() = mesh.time().timeName();
nonManifoldPoints.write();
forAll(meshPoints, patchPointI)
......@@ -1207,6 +1213,7 @@ void Foam::autoLayerDriver::handleWarpedFaces
//
// if (nMultiPatchCells > 0)
// {
// multiPatchCells.instance() = mesh.time().timeName();
// Info<< "Writing " << nMultiPatchCells
// << " cells with multiple (connected) patch faces to cellSet "
// << multiPatchCells.objectPath() << endl;
......
......@@ -415,7 +415,9 @@ Foam::label Foam::autoRefineDriver::shellRefine
Pout<< "Dumping " << candidateCells.size()
<< " cells to cellSet candidateCellsFromShells." << endl;
cellSet(mesh, "candidateCellsFromShells", candidateCells).write();
cellSet c(mesh, "candidateCellsFromShells", candidateCells);
c.instance() = mesh.time().timeName();
c.write();
}
// Problem choosing starting faces for bufferlayers (bFaces)
......
......@@ -598,6 +598,7 @@ Foam::List<Foam::labelPair> Foam::meshRefinement::getDuplicateFaces
}
Pout<< "Writing duplicate faces (baffles) to faceSet "
<< duplicateFaceSet.name() << nl << endl;
duplicateFaceSet.instance() = mesh_.time().timeName();
duplicateFaceSet.write();
}
......@@ -1559,6 +1560,7 @@ void Foam::meshRefinement::baffleAndSplitMesh
problemTopo.insert(faceI);
}
}
problemTopo.instance() = mesh_.time().timeName();
Pout<< "Dumping " << problemTopo.size()
<< " problem faces to " << problemTopo.objectPath() << endl;
problemTopo.write();
......
......@@ -203,6 +203,7 @@ Foam::Map<Foam::label> Foam::meshRefinement::findEdgeConnectedProblemCells
if (debug)
{
faceSet fSet(mesh_, "edgeConnectedFaces", candidateFaces);
fSet.instance() = mesh_.time().timeName();
Pout<< "Writing " << fSet.size()
<< " with problematic topology to faceSet "
<< fSet.objectPath() << endl;
......@@ -265,6 +266,7 @@ Foam::Map<Foam::label> Foam::meshRefinement::findEdgeConnectedProblemCells
if (debug)
{
perpFaces.instance() = mesh_.time().timeName();
Pout<< "Writing " << perpFaces.size()
<< " faces that are perpendicular to the surface to set "
<< perpFaces.objectPath() << endl;
......@@ -482,6 +484,7 @@ Foam::labelList Foam::meshRefinement::markFacesOnProblemCells
if (debug)
{
cellSet problemCellSet(mesh_, "problemCells", problemCells.toc());
problemCellSet.instance() = mesh_.time().timeName();
Pout<< "Writing " << problemCellSet.size()
<< " cells that are edge connected to coarser cell to set "
<< problemCellSet.objectPath() << endl;
......
......@@ -219,6 +219,7 @@ Foam::labelList Foam::meshRefinement::getChangedFaces
<< endl;
faceSet changedFacesSet(mesh, "changedFaces", changedFaces);
changedFacesSet.instance() = mesh.time().timeName();
Pout<< "getChangedFaces : Writing " << changedFaces.size()
<< " changed faces to faceSet " << changedFacesSet.name()
<< endl;
......
......@@ -117,7 +117,18 @@ cellSet::cellSet
IOobject
(
name,
runTime.findInstance(polyMesh::meshSubDir, "faces"),
runTime.findInstance
(
polyMesh::meshSubDir/"sets", //polyMesh::meshSubDir,
word::null, //"faces"
IOobject::MUST_READ,
runTime.findInstance
(
polyMesh::meshSubDir,
"faces",
IOobject::READ_IF_PRESENT
)
),
polyMesh::meshSubDir/"sets",
runTime,
r,
......@@ -141,10 +152,21 @@ cellSet::cellSet
IOobject
(
name,
runTime.findInstance(polyMesh::meshSubDir, "faces"),
runTime.findInstance
(
polyMesh::meshSubDir/"sets", //polyMesh::meshSubDir,
word::null, //"faces"
IOobject::NO_READ,
runTime.findInstance
(
polyMesh::meshSubDir,
"faces",
IOobject::READ_IF_PRESENT
)
),
polyMesh::meshSubDir/"sets",
runTime,
NO_READ,
IOobject::NO_READ,
w
),
size
......@@ -165,10 +187,21 @@ cellSet::cellSet
IOobject
(
name,
runTime.findInstance(polyMesh::meshSubDir, "faces"),
runTime.findInstance
(
polyMesh::meshSubDir/"sets", //polyMesh::meshSubDir,
word::null, //"faces"
IOobject::NO_READ,
runTime.findInstance
(
polyMesh::meshSubDir,
"faces",
IOobject::READ_IF_PRESENT
)
),
polyMesh::meshSubDir/"sets",
runTime,
NO_READ,
IOobject::NO_READ,
w
),
set
......
......@@ -28,6 +28,7 @@ License
#include "mapPolyMesh.H"
#include "polyMesh.H"
#include "boundBox.H"
#include "Time.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -362,7 +363,13 @@ topoSet::topoSet
IOobject
(
name,
mesh.facesInstance(),
mesh.time().findInstance
(
polyMesh::meshSubDir/"sets",
word::null,
IOobject::MUST_READ,
mesh.facesInstance()
),
polyMesh::meshSubDir/"sets",
mesh,
r,
......@@ -402,10 +409,16 @@ topoSet::topoSet
IOobject
(
name,
mesh.facesInstance(),
mesh.time().findInstance
(
polyMesh::meshSubDir/"sets",
word::null,
IOobject::NO_READ,
mesh.facesInstance()
),
polyMesh::meshSubDir/"sets",
mesh,
NO_READ,
IOobject::NO_READ,
w
)
),
......@@ -426,10 +439,16 @@ topoSet::topoSet
IOobject
(
name,
mesh.facesInstance(),
mesh.time().findInstance
(
polyMesh::meshSubDir/"sets",
word::null,
IOobject::NO_READ,
mesh.facesInstance()
),
polyMesh::meshSubDir/"sets",
mesh,
NO_READ,
IOobject::NO_READ,
w
)
),
......
......@@ -176,7 +176,8 @@ public:
// Can't use typeName info here since subclasses not yet instantiated
topoSet(const IOobject&, const word& wantedType);
//- Construct from polyMesh and name
//- Construct from polyMesh and name. Searches for a polyMesh/sets
// directory but not beyond mesh.facesInstance.
topoSet
(
const polyMesh& mesh,
......@@ -186,7 +187,9 @@ public:
writeOption w=NO_WRITE
);
//- Construct empty from additional size of labelHashSet
//- Construct empty from additional size of labelHashSet.
// Searches for a polyMesh/sets
// directory but not beyond mesh.facesInstance.
topoSet
(
const polyMesh& mesh,
......@@ -196,6 +199,8 @@ public:
);
//- Construct empty from additional labelHashSet
// Searches for a polyMesh/sets
// directory but not beyond mesh.facesInstance.
topoSet
(
const polyMesh& mesh,
......@@ -204,10 +209,10 @@ public:
writeOption w=NO_WRITE
);
//- Construct empty from IOobject and size
//- Construct empty from IOobject and size.
topoSet(const IOobject&, const label size);
//- Construct from IOobject and labelHashSet
//- Construct from IOobject and labelHashSet.
topoSet(const IOobject&, const labelHashSet&);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment