surfMesh, surfaceRegistry re-working

This commit is contained in:
Mark Olesen
2009-02-05 16:12:35 +01:00
parent a4d0094e48
commit 3aba0e28ff
16 changed files with 195 additions and 236 deletions

View File

@ -83,10 +83,24 @@ int main(int argc, char *argv[])
argList::validOptions.insert("from", "sourceCoordinateSystem"); argList::validOptions.insert("from", "sourceCoordinateSystem");
argList::validOptions.insert("to", "targetCoordinateSystem"); argList::validOptions.insert("to", "targetCoordinateSystem");
argList args(argc, argv); # include "setRootCase.H"
Time runTime(args.rootPath(), args.caseName()); # include "createTime.H"
const stringList& params = args.additionalArgs(); const stringList& params = args.additionalArgs();
// try for the latestTime, but create "constant" as needed
instantList Times = runTime.times();
if (Times.size())
{
label startTime = Times.size()-1;
runTime.setTime(Times[startTime], startTime);
}
else
{
runTime.setTime(instant(0, runTime.constant()), 0);
}
fileName importName(params[0]); fileName importName(params[0]);
word exportName("default"); word exportName("default");
@ -201,7 +215,6 @@ int main(int argc, char *argv[])
MeshedSurface<face> surf(importName); MeshedSurface<face> surf(importName);
if (args.options().found("clean")) if (args.options().found("clean"))

View File

@ -49,8 +49,8 @@ Foam::BasicMeshedSurface<Face>::BasicMeshedSurface()
template<class Face> template<class Face>
Foam::BasicMeshedSurface<Face>::BasicMeshedSurface Foam::BasicMeshedSurface<Face>::BasicMeshedSurface
( (
const Xfer<pointField>& pointLst, const Xfer< pointField >& pointLst,
const Xfer<List<Face> >& faceLst const Xfer< List<Face> >& faceLst
) )
: :
ParentType(List<Face>(), pointField()) ParentType(List<Face>(), pointField())
@ -112,8 +112,8 @@ void Foam::BasicMeshedSurface<Face>::scalePoints(const scalar& scaleFactor)
template<class Face> template<class Face>
void Foam::BasicMeshedSurface<Face>::reset void Foam::BasicMeshedSurface<Face>::reset
( (
const Xfer<pointField>& pointLst, const Xfer< pointField >& pointLst,
const Xfer<List<Face> >& faceLst const Xfer< List<Face> >& faceLst
) )
{ {
ParentType::clearOut(); ParentType::clearOut();
@ -135,8 +135,8 @@ void Foam::BasicMeshedSurface<Face>::reset
template<class Face> template<class Face>
void Foam::BasicMeshedSurface<Face>::reset void Foam::BasicMeshedSurface<Face>::reset
( (
const Xfer<List<point> >& pointLst, const Xfer< List<point> >& pointLst,
const Xfer<List<Face> >& faceLst const Xfer< List<Face> >& faceLst
) )
{ {
ParentType::clearOut(); ParentType::clearOut();

View File

@ -59,7 +59,8 @@ class BasicMeshedSurface
public PrimitivePatch<Face, ::Foam::List, pointField, point> public PrimitivePatch<Face, ::Foam::List, pointField, point>
{ {
//- Typedefs for convenience // Private typedefs
typedef PrimitivePatch typedef PrimitivePatch
< <
Face, Face,
@ -70,6 +71,7 @@ class BasicMeshedSurface
ParentType; ParentType;
protected: protected:
// Protected Member Functions // Protected Member Functions
//- Non-const access to global points //- Non-const access to global points
@ -103,8 +105,8 @@ public:
//- Construct by transferring components (points, faces). //- Construct by transferring components (points, faces).
BasicMeshedSurface BasicMeshedSurface
( (
const Xfer<pointField>&, const Xfer< pointField >&,
const Xfer<List<Face> >& const Xfer< List<Face> >&
); );
// Destructor // Destructor
@ -135,15 +137,15 @@ public:
//- Transfer components (points, faces). //- Transfer components (points, faces).
virtual void reset virtual void reset
( (
const Xfer<pointField>&, const Xfer< pointField >&,
const Xfer<List<Face> >& const Xfer< List<Face> >&
); );
//- Transfer components (points, faces). //- Transfer components (points, faces).
virtual void reset virtual void reset
( (
const Xfer<List<point> >&, const Xfer< List<point> >&,
const Xfer<List<Face> >& const Xfer< List<Face> >&
); );
//- Remove invalid faces //- Remove invalid faces
@ -160,14 +162,12 @@ public:
const bool verbose=false const bool verbose=false
); );
//- Triangulate in-place //- Triangulate in-place, returning the number of triangles added
// Returning the number of triangles added
// Optionally returning a map of original face Ids (zero-sized when
// no triangulation was done)
virtual label triangulate(); virtual label triangulate();
//- Triangulate in-place, setting a map of original face Ids //- Triangulate in-place, returning the number of triangles added
// faceMap is zero-sized when no triangulation was done // and setting a map of original face Ids.
// The faceMap is zero-sized when no triangulation was done.
virtual label triangulate(List<label>& faceMap); virtual label triangulate(List<label>& faceMap);

View File

@ -1,5 +0,0 @@
EXE_INC = \
-I$(LIB_SRC)/triSurface/lnInclude
LIB_LIBS = \
-ltriSurface

View File

@ -340,9 +340,9 @@ Foam::MeshedSurface<Face>::MeshedSurface(Istream& is)
template<class Face> template<class Face>
Foam::MeshedSurface<Face>::MeshedSurface(const Time& d) Foam::MeshedSurface<Face>::MeshedSurface(const Time& d, const word& surfName)
{ {
read(IFstream(findMeshName(d))()); read(IFstream(findMeshFile(d, surfName))());
} }
@ -822,9 +822,9 @@ bool Foam::MeshedSurface<Face>::read
template<class Face> template<class Face>
void Foam::MeshedSurface<Face>::write(const Time& d) const void Foam::MeshedSurface<Face>::write(const Time& d, const word& surfName) const
{ {
write(OFstream(findMeshName(d))()); write(OFstream(findMeshFile(d, surfName))());
} }
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //

View File

@ -204,7 +204,7 @@ public:
MeshedSurface(Istream&); MeshedSurface(Istream&);
//- Construct from objectRegistry //- Construct from objectRegistry
MeshedSurface(const Time&); MeshedSurface(const Time&, const word& surfName="");
//- Construct as copy //- Construct as copy
MeshedSurface(const MeshedSurface&); MeshedSurface(const MeshedSurface&);
@ -348,7 +348,7 @@ public:
} }
//- Write to database //- Write to database
void write(const Time&) const; void write(const Time&, const word& surfName="") const;
// Member operators // Member operators

View File

@ -25,17 +25,6 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "MeshedSurface.H" #include "MeshedSurface.H"
#include "UnsortedMeshedSurface.H"
#include "IFstream.H"
#include "OFstream.H"
#include "Time.H"
#include "ListOps.H"
#include "polyBoundaryMesh.H"
#include "polyMesh.H"
#include "surfMesh.H"
#include "primitivePatch.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //

View File

@ -253,9 +253,13 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface(Istream& is)
template<class Face> template<class Face>
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface(const Time& d) Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
(
const Time& d,
const word& surfName
)
{ {
read(IFstream(findMeshName(d))()); read(IFstream(findMeshFile(d, surfName))());
} }
@ -631,9 +635,13 @@ bool Foam::UnsortedMeshedSurface<Face>::read
template<class Face> template<class Face>
void Foam::UnsortedMeshedSurface<Face>::write(const Time& d) const void Foam::UnsortedMeshedSurface<Face>::write
(
const Time& d,
const word& surfName
) const
{ {
write(OFstream(findMeshName(d))()); write(OFstream(findMeshFile(d, surfName))());
} }

View File

@ -208,7 +208,7 @@ public:
UnsortedMeshedSurface(Istream&); UnsortedMeshedSurface(Istream&);
//- Construct from objectRegistry //- Construct from objectRegistry
UnsortedMeshedSurface(const Time&); UnsortedMeshedSurface(const Time&, const word& surfName="");
//- Construct as copy //- Construct as copy
UnsortedMeshedSurface(const UnsortedMeshedSurface<Face>&); UnsortedMeshedSurface(const UnsortedMeshedSurface<Face>&);
@ -364,7 +364,7 @@ public:
} }
//- Write to database //- Write to database
void write(const Time&) const; void write(const Time&, const word& surfName="") const;
// Member operators // Member operators

View File

@ -36,10 +36,8 @@ License
defineTypeNameAndDebug(Foam::surfMesh, 0); defineTypeNameAndDebug(Foam::surfMesh, 0);
Foam::word Foam::surfMesh::defaultName = "default";
Foam::word Foam::surfMesh::meshSubDir = "surfMesh"; Foam::word Foam::surfMesh::meshSubDir = "surfMesh";
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::surfMesh::oneZone() void Foam::surfMesh::oneZone()
@ -69,9 +67,10 @@ void Foam::surfMesh::oneZone()
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::surfMesh::surfMesh(const IOobject& io)
Foam::surfMesh::surfMesh(const IOobject& io, const word& surfName)
: :
surfaceRegistry(io.db(), io.name()), surfaceRegistry(io.db(), (surfName.size() ? surfName : io.name())),
surfMeshAllocator surfMeshAllocator
( (
IOobject IOobject
@ -93,7 +92,7 @@ Foam::surfMesh::surfMesh(const IOobject& io)
IOobject::NO_WRITE IOobject::NO_WRITE
) )
), ),
MeshReference(ioFaces_, ioPoints_), MeshReference(storedFaces_, storedPoints_),
surfZones_ surfZones_
( (
IOobject IOobject
@ -114,10 +113,10 @@ Foam::surfMesh::surfMesh
const IOobject& io, const IOobject& io,
const Xfer<pointField>& pointLst, const Xfer<pointField>& pointLst,
const Xfer<faceList>& faceLst, const Xfer<faceList>& faceLst,
const bool syncPar const word& surfName
) )
: :
surfaceRegistry(io, io.name()), surfaceRegistry(io.db(), (surfName.size() ? surfName : io.name())),
surfMeshAllocator surfMeshAllocator
( (
IOobject IOobject
@ -141,7 +140,7 @@ Foam::surfMesh::surfMesh
), ),
faceLst faceLst
), ),
MeshReference(ioFaces_, ioPoints_), MeshReference(storedFaces_, storedPoints_),
surfZones_ surfZones_
( (
IOobject IOobject
@ -157,62 +156,14 @@ Foam::surfMesh::surfMesh
{} {}
Foam::surfMesh::surfMesh
(
const IOobject& io,
const MeshedSurface<face>& surf,
const bool syncPar
)
:
surfaceRegistry(io, io.name()),
surfMeshAllocator
(
IOobject
(
"points",
instance(),
meshSubDir,
*this,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
surf.points(),
IOobject
(
"faces",
instance(),
meshSubDir,
*this,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
surf.faces()
),
MeshReference(ioFaces_, ioPoints_),
surfZones_
(
IOobject
(
"surfZones",
instance(),
meshSubDir,
*this,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
surf.zones()
)
{}
Foam::surfMesh::surfMesh Foam::surfMesh::surfMesh
( (
const IOobject& io, const IOobject& io,
const Xfer< MeshedSurface<face> >& surf, const Xfer< MeshedSurface<face> >& surf,
const bool syncPar const word& surfName
) )
: :
surfaceRegistry(io, io.name()), surfaceRegistry(io.db(), (surfName.size() ? surfName : io.name())),
surfMeshAllocator surfMeshAllocator
( (
IOobject IOobject
@ -236,7 +187,7 @@ Foam::surfMesh::surfMesh
), ),
faceList() faceList()
), ),
MeshReference(ioFaces_, ioPoints_), MeshReference(storedFaces_, storedPoints_),
surfZones_ surfZones_
( (
IOobject IOobject
@ -251,7 +202,11 @@ Foam::surfMesh::surfMesh
surfZoneList() surfZoneList()
) )
{ {
// We can also send Xfer<..>::null just to force initialization
if (&surf)
{
transfer(surf()); transfer(surf());
}
} }
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
@ -280,12 +235,12 @@ void Foam::surfMesh::resetPrimitives
// Optimized to avoid overwriting data at all // Optimized to avoid overwriting data at all
if (&points) if (&points)
{ {
ioPoints_.transfer(points()); storedPoints_.transfer(points());
} }
if (&faces) if (&faces)
{ {
ioFaces_.transfer(faces()); storedFaces_.transfer(faces());
} }
if (&zones) if (&zones)
@ -308,21 +263,19 @@ void Foam::surfMesh::transfer
// Clear addressing. // Clear addressing.
MeshReference::clearGeom(); MeshReference::clearGeom();
ioPoints_.transfer(surf.storedPoints()); storedPoints_.transfer(surf.storedPoints());
ioFaces_.transfer(surf.storedFaces()); storedFaces_.transfer(surf.storedFaces());
surfZones_.transfer(surf.storedZones()); surfZones_.transfer(surf.storedZones());
} }
void Foam::surfMesh::rename(const word& newName) void Foam::surfMesh::rename(const word& newName)
{ {
surfaceRegistry::rename(newName);
FatalErrorIn FatalErrorIn
( (
"surfMesh::rename(const word&)\n" "surfMesh::rename(const word&)\n"
) )
<< "rename does not work correctly\n" << "rename does not work correctly\n";
<< exit(FatalError);
} }
@ -335,34 +288,34 @@ Foam::fileName Foam::surfMesh::meshDir() const
const Foam::fileName& Foam::surfMesh::pointsInstance() const const Foam::fileName& Foam::surfMesh::pointsInstance() const
{ {
return ioPoints_.instance(); return storedPoints_.instance();
} }
const Foam::fileName& Foam::surfMesh::facesInstance() const const Foam::fileName& Foam::surfMesh::facesInstance() const
{ {
return ioFaces_.instance(); return storedFaces_.instance();
} }
Foam::label Foam::surfMesh::nPoints() const Foam::label Foam::surfMesh::nPoints() const
{ {
return ioPoints_.size(); return storedPoints_.size();
} }
Foam::label Foam::surfMesh::nFaces() const Foam::label Foam::surfMesh::nFaces() const
{ {
return ioFaces_.size(); return storedFaces_.size();
} }
const Foam::pointField& Foam::surfMesh::points() const const Foam::pointField& Foam::surfMesh::points() const
{ {
return ioPoints_; return storedPoints_;
} }
const Foam::faceList& Foam::surfMesh::faces() const const Foam::faceList& Foam::surfMesh::faces() const
{ {
return ioFaces_; return storedFaces_;
} }
void Foam::surfMesh::checkZones() void Foam::surfMesh::checkZones()

View File

@ -63,13 +63,13 @@ class MeshedSurface;
class surfMeshAllocator class surfMeshAllocator
{ {
protected: protected:
pointIOField ioPoints_; pointIOField storedPoints_;
faceIOList ioFaces_; faceIOList storedFaces_;
surfMeshAllocator(const IOobject& ioPoints, const IOobject& ioFaces) surfMeshAllocator(const IOobject& ioPoints, const IOobject& ioFaces)
: :
ioPoints_(ioPoints), storedPoints_(ioPoints),
ioFaces_(ioFaces) storedFaces_(ioFaces)
{} {}
surfMeshAllocator surfMeshAllocator
@ -80,8 +80,8 @@ protected:
const faceList& faces const faceList& faces
) )
: :
ioPoints_(ioPoints, points), storedPoints_(ioPoints, points),
ioFaces_(ioFaces, faces) storedFaces_(ioFaces, faces)
{} {}
surfMeshAllocator surfMeshAllocator
@ -92,8 +92,8 @@ protected:
const Xfer<faceList>& faces const Xfer<faceList>& faces
) )
: :
ioPoints_(ioPoints, points), storedPoints_(ioPoints, points),
ioFaces_(ioFaces, faces) storedFaces_(ioFaces, faces)
{} {}
}; };
@ -160,6 +160,28 @@ private:
//- Disallow default bitwise assignment //- Disallow default bitwise assignment
void operator=(const surfMesh&); void operator=(const surfMesh&);
protected:
// Protected Member Functions
//- Non-const access to global points
pointIOField& storedPoints()
{
return surfMeshAllocator::storedPoints_;
}
//- Non-const access to the faces
faceIOList& storedFaces()
{
return surfMeshAllocator::storedFaces_;
}
//- Non-const access to the zones
surfZoneIOList& storedZones()
{
return surfZones_;
}
public: public:
// Public typedefs // Public typedefs
@ -170,20 +192,13 @@ public:
//- Runtime type information //- Runtime type information
TypeName("surfMesh"); TypeName("surfMesh");
//- Return the default surface name //- Return the mesh sub-directory name (normally "surfMesh")
static word defaultName;
//- Return the mesh sub-directory name (usually "surfMesh")
static word meshSubDir; static word meshSubDir;
//- Return the default zone name
static word defaultZoneName;
// Constructors // Constructors
//- Construct from IOobject //- Construct from IOobject, with alternative surface name
explicit surfMesh(const IOobject& io); explicit surfMesh(const IOobject&, const word& surfName="");
//- Construct by transferring components (points, faces) without zones. //- Construct by transferring components (points, faces) without zones.
// surfZones are added using addZones() member function // surfZones are added using addZones() member function
@ -192,23 +207,15 @@ public:
const IOobject&, const IOobject&,
const Xfer<pointField>&, const Xfer<pointField>&,
const Xfer<faceList>&, const Xfer<faceList>&,
const bool syncPar=true const word& surfName=""
); );
//- Construct copy from MeshedSurface //- Construct copy/move from MeshedSurface
surfMesh
(
const IOobject&,
const MeshedSurface<face>& surf,
const bool syncPar=true
);
//- Construct copy from MeshedSurface
surfMesh surfMesh
( (
const IOobject&, const IOobject&,
const Xfer< MeshedSurface<face> >& surf, const Xfer< MeshedSurface<face> >& surf,
const bool syncPar=true const word& surfName=""
); );
// Destructor // Destructor
@ -224,7 +231,7 @@ public:
fileName meshDir() const; fileName meshDir() const;
//- Return the current instance directory for points //- Return the current instance directory for points
// Used in the consruction of gemometric mesh data dependent // Used in the consruction of geometric mesh data dependent
// on points // on points
const fileName& pointsInstance() const; const fileName& pointsInstance() const;
@ -300,6 +307,7 @@ public:
); );
//- Transfer the contents of the argument and annull the argument
void transfer(MeshedSurface<face>&); void transfer(MeshedSurface<face>&);
// Storage management // Storage management

View File

@ -37,11 +37,11 @@ void Foam::surfMesh::setInstance(const fileName& inst)
<< "Resetting file instance to " << inst << endl; << "Resetting file instance to " << inst << endl;
} }
ioPoints_.writeOpt() = IOobject::AUTO_WRITE; storedPoints_.writeOpt() = IOobject::AUTO_WRITE;
ioPoints_.instance() = inst; storedPoints_.instance() = inst;
ioFaces_.writeOpt() = IOobject::AUTO_WRITE; storedFaces_.writeOpt() = IOobject::AUTO_WRITE;
ioFaces_.instance() = inst; storedFaces_.instance() = inst;
surfZones_.writeOpt() = IOobject::AUTO_WRITE; surfZones_.writeOpt() = IOobject::AUTO_WRITE;
surfZones_.instance() = inst; surfZones_.instance() = inst;
@ -56,16 +56,16 @@ Foam::surfMesh::readUpdateState Foam::surfMesh::readUpdate()
<< "Updating mesh based on saved data." << endl; << "Updating mesh based on saved data." << endl;
} }
// Find the point and cell instance // Find point and face instances
fileName pointsInst(time().findInstance(meshDir(), "points")); fileName pointsInst(time().findInstance(meshDir(), "points"));
fileName facesInst(time().findInstance(meshDir(), "faces")); fileName facesInst(time().findInstance(meshDir(), "faces"));
if (debug) if (debug)
{ {
Info<< "Faces instance: old = " << facesInstance() Info<< "Points instance: old = " << pointsInstance()
<< " new = " << facesInst << nl << " new = " << pointsInst << nl
<< "Points instance: old = " << pointsInstance() << "Faces instance: old = " << facesInstance()
<< " new = " << pointsInst << endl; << " new = " << facesInst << endl;
} }
if (facesInst != facesInstance()) if (facesInst != facesInstance())
@ -78,12 +78,12 @@ Foam::surfMesh::readUpdateState Foam::surfMesh::readUpdate()
clearOut(); clearOut();
// Set instance to new instance. Note that points instance can differ // Set instance to new instance.
// from from faces instance. // Note points instance can differ from faces instance.
setInstance(facesInst); setInstance(facesInst);
ioPoints_.instance() = pointsInst; storedPoints_.instance() = pointsInst;
ioPoints_ = pointIOField storedPoints_ = pointIOField
( (
IOobject IOobject
( (
@ -97,7 +97,7 @@ Foam::surfMesh::readUpdateState Foam::surfMesh::readUpdate()
) )
); );
ioFaces_ = faceIOList storedFaces_ = faceIOList
( (
IOobject IOobject
( (
@ -111,10 +111,8 @@ Foam::surfMesh::readUpdateState Foam::surfMesh::readUpdate()
) )
); );
// synchronize the sizes // synchronize sizes and references?
MeshReference newMeshRef(ioFaces_, ioPoints_); // MeshReference::operator=(MeshReference(storedFaces_, storedPoints_));
MeshReference::operator=(newMeshRef);
// Reset the surface zones // Reset the surface zones
surfZoneIOList newZones surfZoneIOList newZones
@ -150,27 +148,21 @@ Foam::surfMesh::readUpdateState Foam::surfMesh::readUpdate()
} }
} }
surfZones_.transfer(newZones);
if (zonesChanged) if (zonesChanged)
{ {
WarningIn("surfMesh::readUpdateState surfMesh::readUpdate()") WarningIn("surfMesh::readUpdateState surfMesh::readUpdate()")
<< "Number of zones has changed. This may have " << "Number of zones has changed. This may have "
<< "unexpected consequences. Proceed with care." << endl; << "unexpected consequences. Proceed with care." << endl;
surfZones_.transfer(newZones);
}
else
{
surfZones_.transfer(newZones);
}
if (zonesChanged)
{
return surfMesh::TOPO_PATCH_CHANGE; return surfMesh::TOPO_PATCH_CHANGE;
} }
else else
{ {
return surfMesh::TOPO_CHANGE; return surfMesh::TOPO_CHANGE;
} }
} }
else if (pointsInst != pointsInstance()) else if (pointsInst != pointsInstance())
{ {
@ -182,9 +174,9 @@ Foam::surfMesh::readUpdateState Foam::surfMesh::readUpdate()
clearGeom(); clearGeom();
ioPoints_.instance() = pointsInst; storedPoints_.instance() = pointsInst;
ioPoints_ = pointIOField storedPoints_ = pointIOField
( (
IOobject IOobject
( (
@ -206,9 +198,9 @@ Foam::surfMesh::readUpdateState Foam::surfMesh::readUpdate()
{ {
Info << "No change" << endl; Info << "No change" << endl;
} }
}
return surfMesh::UNCHANGED; return surfMesh::UNCHANGED;
}
} }

View File

@ -29,10 +29,10 @@ License
#include "OFstream.H" #include "OFstream.H"
#include "Time.H" #include "Time.H"
#include "SortableList.H" #include "SortableList.H"
#include "surfMesh.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
Foam::word Foam::fileFormats::surfaceFormatsCore::meshSubDir("meshedSurface");
Foam::word Foam::fileFormats::surfaceFormatsCore::nativeExt("ofs"); Foam::word Foam::fileFormats::surfaceFormatsCore::nativeExt("ofs");
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
@ -61,14 +61,29 @@ Foam::fileFormats::surfaceFormatsCore::getLineNoComment
} }
Foam::fileName
Foam::fileFormats::surfaceFormatsCore::localMeshFileName(const word& surfName)
{
const word name(surfName.size() ? surfName : surfaceRegistry::defaultName);
return fileName
(
surfaceRegistry::subInstance
/ name
/ surfMesh::meshSubDir
/ name + "." + nativeExt
);
}
Foam::fileName Foam::fileName
Foam::fileFormats::surfaceFormatsCore::findMeshInstance Foam::fileFormats::surfaceFormatsCore::findMeshInstance
( (
const Time& d, const Time& d,
const word& subdirName const word& surfName
) )
{ {
fileName foamName(d.caseName() + "." + nativeExt); fileName localName = localMeshFileName(surfName);
// Search back through the time directories list to find the time // Search back through the time directories list to find the time
// closest to and lower than current time // closest to and lower than current time
@ -91,7 +106,7 @@ Foam::fileFormats::surfaceFormatsCore::findMeshInstance
{ {
for (label i = instanceI; i >= 0; --i) for (label i = instanceI; i >= 0; --i)
{ {
if (isFile(d.path()/ts[i].name()/subdirName/foamName)) if (isFile(d.path()/ts[i].name()/localName))
{ {
return ts[i].name(); return ts[i].name();
} }
@ -103,13 +118,13 @@ Foam::fileFormats::surfaceFormatsCore::findMeshInstance
Foam::fileName Foam::fileName
Foam::fileFormats::surfaceFormatsCore::findMeshName Foam::fileFormats::surfaceFormatsCore::findMeshFile
( (
const Time& d, const Time& d,
const word& subdirName const word& surfName
) )
{ {
fileName foamName(d.caseName() + "." + nativeExt); fileName localName = localMeshFileName(surfName);
// Search back through the time directories list to find the time // Search back through the time directories list to find the time
// closest to and lower than current time // closest to and lower than current time
@ -132,7 +147,7 @@ Foam::fileFormats::surfaceFormatsCore::findMeshName
{ {
for (label i = instanceI; i >= 0; --i) for (label i = instanceI; i >= 0; --i)
{ {
fileName testName(d.path()/ts[i].name()/subdirName/foamName); fileName testName(d.path()/ts[i].name()/localName);
if (isFile(testName)) if (isFile(testName))
{ {
@ -141,27 +156,8 @@ Foam::fileFormats::surfaceFormatsCore::findMeshName
} }
} }
return d.path()/"constant"/subdirName/foamName; // fallback to "constant"
} return d.path()/"constant"/localName;
Foam::fileName
Foam::fileFormats::surfaceFormatsCore::findMeshInstance
(
const Time& d
)
{
return findMeshInstance(d, meshSubDir);
}
Foam::fileName
Foam::fileFormats::surfaceFormatsCore::findMeshName
(
const Time& d
)
{
return findMeshName(d, meshSubDir);
} }

View File

@ -65,9 +65,6 @@ public:
// Static Data // Static Data
//- Return the mesh sub-directory name (usually "meshedSurface")
static word meshSubDir;
//- The file extension corresponding to 'native' surface format //- The file extension corresponding to 'native' surface format
// Normally "ofs" (mnemonic: OF = OpenFOAM, S = Surface) // Normally "ofs" (mnemonic: OF = OpenFOAM, S = Surface)
static word nativeExt; static word nativeExt;
@ -80,17 +77,14 @@ public:
//- Read non-comment line //- Read non-comment line
static string getLineNoComment(IFstream&); static string getLineNoComment(IFstream&);
//- Name of UnsortedMeshedSurface directory to use. //- Return the local file name (within time directory)
static fileName findMeshInstance(const Time&, const word& subdirName); static fileName localMeshFileName(const word& surfName="");
//- Name of UnsortedMeshedSurface directory to use. //- Find instance with surfName
static fileName findMeshName(const Time&, const word& subdirName); static fileName findMeshInstance(const Time&, const word& surfName="");
//- Name of UnsortedMeshedSurface directory to use. //- Find mesh file with surfName
static fileName findMeshInstance(const Time&); static fileName findMeshFile(const Time&, const word& surfName="");
//- Name of UnsortedMeshedSurface directory to use.
static fileName findMeshName(const Time&);
//- Determine the sort order from the zone ids. //- Determine the sort order from the zone ids.
// Returns zone list and sets faceMap to indices within faceLst // Returns zone list and sets faceMap to indices within faceLst

View File

@ -31,21 +31,27 @@ License
defineTypeNameAndDebug(Foam::surfaceRegistry, 0); defineTypeNameAndDebug(Foam::surfaceRegistry, 0);
const Foam::word Foam::surfaceRegistry::subInstance("surfaces");
Foam::word Foam::surfaceRegistry::defaultName("default");
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::surfaceRegistry::surfaceRegistry(const IOobject& io, const word& name) Foam::surfaceRegistry::surfaceRegistry
(
const objectRegistry& obr,
const word& surfName
)
: :
objectRegistry objectRegistry
( (
IOobject IOobject
( (
name, ( surfName.size() ? surfName : defaultName ),
( io.instance().size() ? io.instance() : "constant" ), obr.time().timeName(),
"surfaces", subInstance,
io.db(), obr,
io.readOpt(), IOobject::NO_READ,
io.writeOpt(), IOobject::NO_WRITE
io.registerObject()
) )
) )
{} {}

View File

@ -66,11 +66,16 @@ public:
//- Runtime type information //- Runtime type information
TypeName("surfaceRegistry"); TypeName("surfaceRegistry");
//- The subInstance (local) to prefix: %surfaces
static const word subInstance;
//- The default surface name: %default
static word defaultName;
// Constructors // Constructors
//- Construct for the given objectRegistry and named instance //- Construct for the given objectRegistry and named surface
explicit surfaceRegistry(const IOobject&, const word& name="default"); surfaceRegistry(const objectRegistry&, const word& surfName = "");
// Destructor // Destructor