Commit 3aba0e28 authored by Mark Olesen's avatar Mark Olesen
Browse files

surfMesh, surfaceRegistry re-working

parent a4d0094e
......@@ -83,10 +83,24 @@ int main(int argc, char *argv[])
argList::validOptions.insert("from", "sourceCoordinateSystem");
argList::validOptions.insert("to", "targetCoordinateSystem");
argList args(argc, argv);
Time runTime(args.rootPath(), args.caseName());
# include "setRootCase.H"
# include "createTime.H"
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]);
word exportName("default");
......@@ -201,7 +215,6 @@ int main(int argc, char *argv[])
MeshedSurface<face> surf(importName);
if (args.options().found("clean"))
......
......@@ -49,8 +49,8 @@ Foam::BasicMeshedSurface<Face>::BasicMeshedSurface()
template<class Face>
Foam::BasicMeshedSurface<Face>::BasicMeshedSurface
(
const Xfer<pointField>& pointLst,
const Xfer<List<Face> >& faceLst
const Xfer< pointField >& pointLst,
const Xfer< List<Face> >& faceLst
)
:
ParentType(List<Face>(), pointField())
......@@ -112,8 +112,8 @@ void Foam::BasicMeshedSurface<Face>::scalePoints(const scalar& scaleFactor)
template<class Face>
void Foam::BasicMeshedSurface<Face>::reset
(
const Xfer<pointField>& pointLst,
const Xfer<List<Face> >& faceLst
const Xfer< pointField >& pointLst,
const Xfer< List<Face> >& faceLst
)
{
ParentType::clearOut();
......@@ -135,8 +135,8 @@ void Foam::BasicMeshedSurface<Face>::reset
template<class Face>
void Foam::BasicMeshedSurface<Face>::reset
(
const Xfer<List<point> >& pointLst,
const Xfer<List<Face> >& faceLst
const Xfer< List<point> >& pointLst,
const Xfer< List<Face> >& faceLst
)
{
ParentType::clearOut();
......@@ -556,7 +556,7 @@ void Foam::BasicMeshedSurface<Face>::writeStats(Ostream& os) const
}
os << "faces : " << this->size()
<< " (tri:" << nTri << " quad:" << nQuad
<< " (tri:" << nTri << " quad:" << nQuad
<< " poly:" << (this->size() - nTri - nQuad ) << ")" << nl;
}
......
......@@ -59,7 +59,8 @@ class BasicMeshedSurface
public PrimitivePatch<Face, ::Foam::List, pointField, point>
{
//- Typedefs for convenience
// Private typedefs
typedef PrimitivePatch
<
Face,
......@@ -70,6 +71,7 @@ class BasicMeshedSurface
ParentType;
protected:
// Protected Member Functions
//- Non-const access to global points
......@@ -103,8 +105,8 @@ public:
//- Construct by transferring components (points, faces).
BasicMeshedSurface
(
const Xfer<pointField>&,
const Xfer<List<Face> >&
const Xfer< pointField >&,
const Xfer< List<Face> >&
);
// Destructor
......@@ -135,15 +137,15 @@ public:
//- Transfer components (points, faces).
virtual void reset
(
const Xfer<pointField>&,
const Xfer<List<Face> >&
const Xfer< pointField >&,
const Xfer< List<Face> >&
);
//- Transfer components (points, faces).
virtual void reset
(
const Xfer<List<point> >&,
const Xfer<List<Face> >&
const Xfer< List<point> >&,
const Xfer< List<Face> >&
);
//- Remove invalid faces
......@@ -160,14 +162,12 @@ public:
const bool verbose=false
);
//- Triangulate in-place
// Returning the number of triangles added
// Optionally returning a map of original face Ids (zero-sized when
// no triangulation was done)
//- Triangulate in-place, returning the number of triangles added
virtual label triangulate();
//- Triangulate in-place, setting a map of original face Ids
// faceMap is zero-sized when no triangulation was done
//- Triangulate in-place, returning the number of triangles added
// and setting a map of original face Ids.
// The faceMap is zero-sized when no triangulation was done.
virtual label triangulate(List<label>& faceMap);
......
EXE_INC = \
-I$(LIB_SRC)/triSurface/lnInclude
LIB_LIBS = \
-ltriSurface
......@@ -340,9 +340,9 @@ Foam::MeshedSurface<Face>::MeshedSurface(Istream& is)
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>
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 * * * * * * * * * * * * * //
......
......@@ -204,7 +204,7 @@ public:
MeshedSurface(Istream&);
//- Construct from objectRegistry
MeshedSurface(const Time&);
MeshedSurface(const Time&, const word& surfName="");
//- Construct as copy
MeshedSurface(const MeshedSurface&);
......@@ -348,7 +348,7 @@ public:
}
//- Write to database
void write(const Time&) const;
void write(const Time&, const word& surfName="") const;
// Member operators
......
......@@ -25,17 +25,6 @@ License
\*---------------------------------------------------------------------------*/
#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 * * * * * * * * * * * //
......
......@@ -253,9 +253,13 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface(Istream& is)
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>
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))());
}
......
......@@ -208,7 +208,7 @@ public:
UnsortedMeshedSurface(Istream&);
//- Construct from objectRegistry
UnsortedMeshedSurface(const Time&);
UnsortedMeshedSurface(const Time&, const word& surfName="");
//- Construct as copy
UnsortedMeshedSurface(const UnsortedMeshedSurface<Face>&);
......@@ -364,7 +364,7 @@ public:
}
//- Write to database
void write(const Time&) const;
void write(const Time&, const word& surfName="") const;
// Member operators
......
......@@ -36,10 +36,8 @@ License
defineTypeNameAndDebug(Foam::surfMesh, 0);
Foam::word Foam::surfMesh::defaultName = "default";
Foam::word Foam::surfMesh::meshSubDir = "surfMesh";
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::surfMesh::oneZone()
......@@ -69,9 +67,10 @@ void Foam::surfMesh::oneZone()
// * * * * * * * * * * * * * * * * 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
(
IOobject
......@@ -93,7 +92,7 @@ Foam::surfMesh::surfMesh(const IOobject& io)
IOobject::NO_WRITE
)
),
MeshReference(ioFaces_, ioPoints_),
MeshReference(storedFaces_, storedPoints_),
surfZones_
(
IOobject
......@@ -114,10 +113,10 @@ Foam::surfMesh::surfMesh
const IOobject& io,
const Xfer<pointField>& pointLst,
const Xfer<faceList>& faceLst,
const bool syncPar
const word& surfName
)
:
surfaceRegistry(io, io.name()),
surfaceRegistry(io.db(), (surfName.size() ? surfName : io.name())),
surfMeshAllocator
(
IOobject
......@@ -141,7 +140,7 @@ Foam::surfMesh::surfMesh
),
faceLst
),
MeshReference(ioFaces_, ioPoints_),
MeshReference(storedFaces_, storedPoints_),
surfZones_
(
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
(
const IOobject& io,
const Xfer< MeshedSurface<face> >& surf,
const bool syncPar
const word& surfName
)
:
surfaceRegistry(io, io.name()),
surfaceRegistry(io.db(), (surfName.size() ? surfName : io.name())),
surfMeshAllocator
(
IOobject
......@@ -236,7 +187,7 @@ Foam::surfMesh::surfMesh
),
faceList()
),
MeshReference(ioFaces_, ioPoints_),
MeshReference(storedFaces_, storedPoints_),
surfZones_
(
IOobject
......@@ -251,7 +202,11 @@ Foam::surfMesh::surfMesh
surfZoneList()
)
{
transfer(surf());
// We can also send Xfer<..>::null just to force initialization
if (&surf)
{
transfer(surf());
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
......@@ -280,12 +235,12 @@ void Foam::surfMesh::resetPrimitives
// Optimized to avoid overwriting data at all
if (&points)
{
ioPoints_.transfer(points());
storedPoints_.transfer(points());
}
if (&faces)
{
ioFaces_.transfer(faces());
storedFaces_.transfer(faces());
}
if (&zones)
......@@ -308,21 +263,19 @@ void Foam::surfMesh::transfer
// Clear addressing.
MeshReference::clearGeom();
ioPoints_.transfer(surf.storedPoints());
ioFaces_.transfer(surf.storedFaces());
storedPoints_.transfer(surf.storedPoints());
storedFaces_.transfer(surf.storedFaces());
surfZones_.transfer(surf.storedZones());
}
void Foam::surfMesh::rename(const word& newName)
{
surfaceRegistry::rename(newName);
FatalErrorIn
(
"surfMesh::rename(const word&)\n"
)
<< "rename does not work correctly\n"
<< exit(FatalError);
<< "rename does not work correctly\n";
}
......@@ -335,34 +288,34 @@ Foam::fileName Foam::surfMesh::meshDir() const
const Foam::fileName& Foam::surfMesh::pointsInstance() const
{
return ioPoints_.instance();
return storedPoints_.instance();
}
const Foam::fileName& Foam::surfMesh::facesInstance() const
{
return ioFaces_.instance();
return storedFaces_.instance();
}
Foam::label Foam::surfMesh::nPoints() const
{
return ioPoints_.size();
return storedPoints_.size();
}
Foam::label Foam::surfMesh::nFaces() const
{
return ioFaces_.size();
return storedFaces_.size();
}
const Foam::pointField& Foam::surfMesh::points() const
{
return ioPoints_;
return storedPoints_;
}
const Foam::faceList& Foam::surfMesh::faces() const
{
return ioFaces_;
return storedFaces_;
}
void Foam::surfMesh::checkZones()
......
......@@ -63,13 +63,13 @@ class MeshedSurface;
class surfMeshAllocator
{
protected:
pointIOField ioPoints_;
faceIOList ioFaces_;
pointIOField storedPoints_;
faceIOList storedFaces_;
surfMeshAllocator(const IOobject& ioPoints, const IOobject& ioFaces)
:
ioPoints_(ioPoints),
ioFaces_(ioFaces)
storedPoints_(ioPoints),
storedFaces_(ioFaces)
{}
surfMeshAllocator
......@@ -80,8 +80,8 @@ protected:
const faceList& faces
)
:
ioPoints_(ioPoints, points),
ioFaces_(ioFaces, faces)
storedPoints_(ioPoints, points),
storedFaces_(ioFaces, faces)
{}
surfMeshAllocator
......@@ -92,8 +92,8 @@ protected:
const Xfer<faceList>& faces
)
:
ioPoints_(ioPoints, points),
ioFaces_(ioFaces, faces)
storedPoints_(ioPoints, points),
storedFaces_(ioFaces, faces)
{}
};
......@@ -160,6 +160,28 @@ private:
//- Disallow default bitwise assignment
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 typedefs
......@@ -170,20 +192,13 @@ public:
//- Runtime type information
TypeName("surfMesh");
//- Return the default surface name
static word defaultName;
//- Return the mesh sub-directory name (usually "surfMesh")
//- Return the mesh sub-directory name (normally "surfMesh")
static word meshSubDir;
//- Return the default zone name
static word defaultZoneName;
// Constructors
//- Construct from IOobject
explicit surfMesh(const IOobject& io);
//- Construct from IOobject, with alternative surface name
explicit surfMesh(const IOobject&, const word& surfName="");
//- Construct by transferring components (points, faces) without zones.
// surfZones are added using addZones() member function
......@@ -192,23 +207,15 @@ public:
const IOobject&,
const Xfer<pointField>&,
const Xfer<faceList>&,
const bool syncPar=true
);
//- Construct copy from MeshedSurface
surfMesh
(
const IOobject&,
const MeshedSurface<face>& surf,
const bool syncPar=true
const word& surfName=""
);
//- Construct copy from MeshedSurface
//- Construct copy/move from MeshedSurface
surfMesh
(
const IOobject&,
const Xfer< MeshedSurface<face> >& surf,
const bool syncPar=true
const word& surfName=""
);
// Destructor
......@@ -224,7 +231,7 @@ public:
fileName meshDir() const;
//- 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
const fileName& pointsInstance() const;
......@@ -300,6 +307,7 @@ public:
);
//- Transfer the contents of the argument and annull the argument