mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
surfMesh changes
- can read MeshedSurface, UnsortedMeshedSurface from surfMesh/ - can write surfMesh in any third-party format
This commit is contained in:
@ -278,6 +278,14 @@ int main(int argc, char *argv[])
|
||||
Info<< "runTime.timeName() = " << runTime.timeName() << endl;
|
||||
|
||||
|
||||
Info<< "write MeshedSurface 'yetAnother' via proxy as surfMesh"
|
||||
<< endl;
|
||||
surf.write
|
||||
(
|
||||
runTime,
|
||||
"yetAnother"
|
||||
);
|
||||
|
||||
surfMesh surfIn
|
||||
(
|
||||
IOobject
|
||||
@ -291,7 +299,16 @@ int main(int argc, char *argv[])
|
||||
);
|
||||
|
||||
|
||||
Info<< "surfIn = " << surfIn.nFaces() << endl;
|
||||
MeshedSurface<face> surfIn2(runTime, "foobar");
|
||||
|
||||
Info<<"surfIn2 = " << surfIn2.size() << endl;
|
||||
|
||||
Info<< "surfIn = " << surfIn.size() << endl;
|
||||
|
||||
|
||||
Info<< "writing surfMesh as obj = oldSurfIn.obj" << endl;
|
||||
surfIn.write("oldSurfIn.obj");
|
||||
|
||||
|
||||
Info<< "runTime.instance() = " << runTime.instance() << endl;
|
||||
|
||||
|
||||
@ -28,8 +28,6 @@ License
|
||||
#include "UnsortedMeshedSurface.H"
|
||||
#include "MeshedSurfaceProxy.H"
|
||||
#include "mergePoints.H"
|
||||
#include "IFstream.H"
|
||||
#include "OFstream.H"
|
||||
#include "Time.H"
|
||||
#include "ListOps.H"
|
||||
#include "polyBoundaryMesh.H"
|
||||
@ -140,12 +138,7 @@ void Foam::MeshedSurface<Face>::write
|
||||
|
||||
if (supported.found(ext))
|
||||
{
|
||||
MeshedSurfaceProxy<Face>
|
||||
(
|
||||
surf.points(),
|
||||
surf.faces(),
|
||||
surf.surfZones()
|
||||
).write(name);
|
||||
MeshedSurfaceProxy<Face>(surf).write(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -367,11 +360,37 @@ Foam::MeshedSurface<Face>::MeshedSurface(const fileName& name)
|
||||
|
||||
|
||||
template<class Face>
|
||||
Foam::MeshedSurface<Face>::MeshedSurface(const Time& d, const word& surfName)
|
||||
Foam::MeshedSurface<Face>::MeshedSurface
|
||||
(
|
||||
const Time& t,
|
||||
const word& surfName
|
||||
)
|
||||
:
|
||||
ParentType(List<Face>(), pointField())
|
||||
{
|
||||
read(this->findMeshFile(d, surfName));
|
||||
surfMesh mesh
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"dummyName",
|
||||
t.timeName(),
|
||||
t,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
),
|
||||
surfName
|
||||
);
|
||||
|
||||
// same face type as surfMesh
|
||||
MeshedSurface<face> surf
|
||||
(
|
||||
xferMove(mesh.storedPoints()),
|
||||
xferMove(mesh.storedFaces()),
|
||||
xferMove(mesh.storedZones())
|
||||
);
|
||||
|
||||
this->transcribe(surf);
|
||||
}
|
||||
|
||||
|
||||
@ -1133,11 +1152,11 @@ bool Foam::MeshedSurface<Face>::read
|
||||
template<class Face>
|
||||
void Foam::MeshedSurface<Face>::write
|
||||
(
|
||||
const Time& d,
|
||||
const Time& t,
|
||||
const word& surfName
|
||||
) const
|
||||
{
|
||||
write(findMeshFile(d, surfName));
|
||||
MeshedSurfaceProxy<Face>(*this).write(t, surfName);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
@ -1153,6 +1172,18 @@ void Foam::MeshedSurface<Face>::operator=(const MeshedSurface& surf)
|
||||
}
|
||||
|
||||
|
||||
template<class Face>
|
||||
Foam::MeshedSurface<Face>::operator
|
||||
Foam::MeshedSurfaceProxy<Face>() const
|
||||
{
|
||||
return MeshedSurfaceProxy<Face>
|
||||
(
|
||||
this->points(),
|
||||
this->faces(),
|
||||
this->surfZones()
|
||||
);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
@ -85,14 +85,9 @@ class MeshedSurface
|
||||
public PrimitivePatch<Face, ::Foam::List, pointField, point>,
|
||||
public fileFormats::surfaceFormatsCore
|
||||
{
|
||||
// friends despite different faces
|
||||
template<class Face2>
|
||||
friend class MeshedSurface;
|
||||
|
||||
// friends despite different faces
|
||||
template<class Face2>
|
||||
friend class UnsortedMeshedSurface;
|
||||
|
||||
// friends - despite different face representationsx
|
||||
template<class Face2> friend class MeshedSurface;
|
||||
template<class Face2> friend class UnsortedMeshedSurface;
|
||||
friend class surfMesh;
|
||||
|
||||
private:
|
||||
@ -232,7 +227,7 @@ public:
|
||||
//- Construct from file name (uses extension to determine type)
|
||||
MeshedSurface(const fileName&, const word& ext);
|
||||
|
||||
//- Construct from objectRegistry
|
||||
//- Construct from database
|
||||
MeshedSurface(const Time&, const word& surfName="");
|
||||
|
||||
// Declare run-time constructor selection table
|
||||
@ -437,6 +432,9 @@ public:
|
||||
|
||||
void operator=(const MeshedSurface<Face>&);
|
||||
|
||||
//- Conversion operator to MeshedSurfaceProxy
|
||||
operator MeshedSurfaceProxy<Face>() const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -34,7 +34,7 @@ template<class Face>
|
||||
void Foam::MeshedSurface<Face>::writeStats(Ostream& os) const
|
||||
{
|
||||
os << "points : " << this->points().size() << nl;
|
||||
if (this->isTri())
|
||||
if (MeshedSurface<Face>::isTri())
|
||||
{
|
||||
os << "triangles : " << this->size() << nl;
|
||||
}
|
||||
|
||||
@ -26,11 +26,6 @@ License
|
||||
|
||||
#include "MeshedSurface.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class Face>
|
||||
@ -38,7 +33,7 @@ void Foam::MeshedSurface<Face>::checkZones()
|
||||
{
|
||||
// extra safety, ensure we have at some zones
|
||||
// and they cover all the faces - fix start silently
|
||||
surfZoneList& zones = storedZones();
|
||||
surfZoneList& zones = this->storedZones();
|
||||
if (zones.size())
|
||||
{
|
||||
label count = 0;
|
||||
@ -48,25 +43,25 @@ void Foam::MeshedSurface<Face>::checkZones()
|
||||
count += zones[zoneI].size();
|
||||
}
|
||||
|
||||
if (count < size())
|
||||
if (count < this->size())
|
||||
{
|
||||
WarningIn
|
||||
(
|
||||
"MeshedSurface::checkZones()\n"
|
||||
)
|
||||
<< "more faces " << size() << " than zones " << count
|
||||
<< "more faces " << this->size() << " than zones " << count
|
||||
<< " ... extending final zone"
|
||||
<< endl;
|
||||
|
||||
zones[zones.size()-1].size() += count - size();
|
||||
zones[zones.size()-1].size() += count - this->size();
|
||||
}
|
||||
else if (count > size())
|
||||
else if (count > this->size())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"MeshedSurface::checkZones()\n"
|
||||
)
|
||||
<< "more zones " << count << " than faces " << size()
|
||||
<< "more zones " << count << " than faces " << this->size()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
@ -101,7 +96,7 @@ void Foam::MeshedSurface<Face>::sortFacesAndStore
|
||||
List<Face> newFaces(faceMap.size());
|
||||
forAll(faceMap, faceI)
|
||||
{
|
||||
// use transfer to recover memory if possible
|
||||
// use transfer to recover memory where possible
|
||||
newFaces[faceI].transfer(oldFaces[faceMap[faceI]]);
|
||||
}
|
||||
this->storedFaces().transfer(newFaces);
|
||||
@ -205,10 +200,4 @@ void Foam::MeshedSurface<Face>::removeZones()
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -25,9 +25,11 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "MeshedSurfaceProxy.H"
|
||||
#include "MeshedSurface.H"
|
||||
#include "Time.H"
|
||||
#include "surfMesh.H"
|
||||
#include "MeshedSurface.H"
|
||||
#include "OFstream.H"
|
||||
#include "ListOps.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
@ -86,6 +88,127 @@ void Foam::MeshedSurfaceProxy<Face>::write
|
||||
}
|
||||
|
||||
|
||||
template<class Face>
|
||||
void Foam::MeshedSurfaceProxy<Face>::write
|
||||
(
|
||||
const Time& t,
|
||||
const word& surfName
|
||||
) const
|
||||
{
|
||||
// the surface name to be used
|
||||
word name(surfName.size() ? surfName : surfaceRegistry::defaultName);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Info<< "MeshedSurfaceProxy::write"
|
||||
"(const Time&, const word&) : "
|
||||
"writing to " << name
|
||||
<< endl;
|
||||
}
|
||||
|
||||
|
||||
// the local location
|
||||
const fileName objectDir
|
||||
(
|
||||
t.timePath()/surfaceRegistry::subInstance/name/surfMesh::meshSubDir
|
||||
);
|
||||
|
||||
if (!isDir(objectDir))
|
||||
{
|
||||
mkDir(objectDir);
|
||||
}
|
||||
|
||||
|
||||
// write surfMesh/points
|
||||
{
|
||||
pointIOField io
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"points",
|
||||
t.timeName(),
|
||||
surfMesh::meshSubDir,
|
||||
t,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
)
|
||||
);
|
||||
|
||||
OFstream os(objectDir/io.name());
|
||||
io.writeHeader(os);
|
||||
|
||||
os << this->points();
|
||||
|
||||
os << "\n\n"
|
||||
"// ************************************************************************* //\n";
|
||||
}
|
||||
|
||||
|
||||
// write surfMesh/faces
|
||||
{
|
||||
faceIOList io
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"faces",
|
||||
t.timeName(),
|
||||
surfMesh::meshSubDir,
|
||||
t,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
)
|
||||
);
|
||||
|
||||
OFstream os(objectDir/io.name());
|
||||
io.writeHeader(os);
|
||||
|
||||
if (this->useFaceMap())
|
||||
{
|
||||
// this is really a bit annoying (and wasteful) but no other way
|
||||
os << reorder(this->faceMap(), this->faces());
|
||||
}
|
||||
else
|
||||
{
|
||||
os << this->faces();
|
||||
}
|
||||
|
||||
os << "\n\n"
|
||||
"// ************************************************************************* //\n";
|
||||
}
|
||||
|
||||
|
||||
// write surfMesh/surfZones
|
||||
{
|
||||
surfZoneIOList io
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"surfZones",
|
||||
t.timeName(),
|
||||
surfMesh::meshSubDir,
|
||||
t,
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
)
|
||||
);
|
||||
|
||||
OFstream os(objectDir/io.name());
|
||||
io.writeHeader(os);
|
||||
|
||||
os << this->surfZones();
|
||||
|
||||
os << "\n\n"
|
||||
"// ************************************************************************* //"
|
||||
<< endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Face>
|
||||
@ -104,19 +227,6 @@ Foam::MeshedSurfaceProxy<Face>::MeshedSurfaceProxy
|
||||
{}
|
||||
|
||||
|
||||
template<class Face>
|
||||
Foam::MeshedSurfaceProxy<Face>::MeshedSurfaceProxy
|
||||
(
|
||||
const MeshedSurface<Face>& surf
|
||||
)
|
||||
:
|
||||
points_(surf.points()),
|
||||
faces_(surf.faces()),
|
||||
zones_(surf.surfZones()),
|
||||
faceMap_(List<label>())
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Face>
|
||||
@ -131,16 +241,6 @@ Foam::MeshedSurfaceProxy<Face>::~MeshedSurfaceProxy()
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
// template<class Face>
|
||||
// void Foam::MeshedSurfaceProxy<Face>::write
|
||||
// (
|
||||
// const Time& d,
|
||||
// const word& surfName
|
||||
// ) const
|
||||
// {
|
||||
// write(findMeshFile(d, surfName)());
|
||||
// }
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
|
||||
@ -76,15 +76,6 @@ class MeshedSurfaceProxy
|
||||
|
||||
const List<label>& faceMap_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
MeshedSurfaceProxy(const MeshedSurfaceProxy&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const MeshedSurfaceProxy&);
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
@ -108,12 +99,6 @@ public:
|
||||
const List<label>& faceMap = List<label>()
|
||||
);
|
||||
|
||||
//- Construct from MeshedSurface
|
||||
explicit MeshedSurfaceProxy
|
||||
(
|
||||
const MeshedSurface<Face>&
|
||||
);
|
||||
|
||||
// Destructor
|
||||
|
||||
virtual ~MeshedSurfaceProxy();
|
||||
@ -176,8 +161,6 @@ public:
|
||||
|
||||
// Write
|
||||
|
||||
//?? void writeStats(Ostream& os) const;
|
||||
|
||||
//- Generic write routine. Chooses writer based on extension.
|
||||
virtual void write(const fileName& name) const
|
||||
{
|
||||
@ -185,7 +168,9 @@ public:
|
||||
}
|
||||
|
||||
//- Write to database
|
||||
//?? void write(const Time&, const word& surfName="") const;
|
||||
virtual void write(const Time&, const word& surfName = "") const;
|
||||
|
||||
//?? void writeStats(Ostream& os) const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -26,6 +26,7 @@ License
|
||||
|
||||
#include "MeshedSurface.H"
|
||||
#include "UnsortedMeshedSurface.H"
|
||||
#include "MeshedSurfaceProxy.H"
|
||||
#include "IFstream.H"
|
||||
#include "OFstream.H"
|
||||
#include "Time.H"
|
||||
@ -127,16 +128,7 @@ void Foam::UnsortedMeshedSurface<Face>::write
|
||||
|
||||
if (supported.found(ext))
|
||||
{
|
||||
labelList faceMap;
|
||||
List<surfZone> zoneLst = surf.sortedZones(faceMap);
|
||||
|
||||
MeshedSurfaceProxy<Face>
|
||||
(
|
||||
surf.points(),
|
||||
surf.faces(),
|
||||
zoneLst,
|
||||
faceMap
|
||||
).write(name);
|
||||
MeshedSurfaceProxy<Face>(surf).write(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -291,13 +283,14 @@ Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface(const fileName& name)
|
||||
template<class Face>
|
||||
Foam::UnsortedMeshedSurface<Face>::UnsortedMeshedSurface
|
||||
(
|
||||
const Time& d,
|
||||
const Time& t,
|
||||
const word& surfName
|
||||
)
|
||||
:
|
||||
ParentType()
|
||||
{
|
||||
read(this->findMeshFile(d, surfName));
|
||||
MeshedSurface<Face> surf(t, surfName);
|
||||
transfer(surf);
|
||||
}
|
||||
|
||||
|
||||
@ -473,7 +466,75 @@ Foam::surfZoneList Foam::UnsortedMeshedSurface<Face>::sortedZones
|
||||
zoneNames.insert(zoneI, zoneToc_[zoneI].name());
|
||||
}
|
||||
|
||||
return this->sortedZonesById(zoneIds_, zoneNames, faceMap);
|
||||
// std::sort() really seems to mix up the order.
|
||||
// and std::stable_sort() might take too long / too much memory
|
||||
|
||||
// Assuming that we have relatively fewer zones compared to the
|
||||
// number of items, just do it ourselves
|
||||
|
||||
// step 1: get zone sizes and store (origId => zoneI)
|
||||
Map<label> lookup;
|
||||
forAll(zoneIds_, faceI)
|
||||
{
|
||||
const label origId = zoneIds_[faceI];
|
||||
|
||||
Map<label>::iterator fnd = lookup.find(origId);
|
||||
if (fnd != lookup.end())
|
||||
{
|
||||
fnd()++;
|
||||
}
|
||||
else
|
||||
{
|
||||
lookup.insert(origId, 1);
|
||||
}
|
||||
}
|
||||
|
||||
// step 2: assign start/size (and name) to the newZones
|
||||
// re-use the lookup to map (zoneId => zoneI)
|
||||
surfZoneList zoneLst(lookup.size());
|
||||
label start = 0;
|
||||
label zoneI = 0;
|
||||
forAllIter(Map<label>, lookup, iter)
|
||||
{
|
||||
label origId = iter.key();
|
||||
|
||||
word name;
|
||||
Map<word>::const_iterator fnd = zoneNames.find(origId);
|
||||
if (fnd != zoneNames.end())
|
||||
{
|
||||
name = fnd();
|
||||
}
|
||||
else
|
||||
{
|
||||
name = word("zone") + ::Foam::name(zoneI);
|
||||
}
|
||||
|
||||
zoneLst[zoneI] = surfZone
|
||||
(
|
||||
name,
|
||||
0, // initialize with zero size
|
||||
start,
|
||||
zoneI
|
||||
);
|
||||
|
||||
// increment the start for the next zone
|
||||
// and save the (zoneId => zoneI) mapping
|
||||
start += iter();
|
||||
iter() = zoneI++;
|
||||
}
|
||||
|
||||
|
||||
// step 3: build the re-ordering
|
||||
faceMap.setSize(zoneIds_.size());
|
||||
|
||||
forAll(zoneIds_, faceI)
|
||||
{
|
||||
label zoneI = lookup[zoneIds_[faceI]];
|
||||
faceMap[faceI] = zoneLst[zoneI].start() + zoneLst[zoneI].size()++;
|
||||
}
|
||||
|
||||
// with reordered faces registered in faceMap
|
||||
return zoneLst;
|
||||
}
|
||||
|
||||
|
||||
@ -670,11 +731,11 @@ bool Foam::UnsortedMeshedSurface<Face>::read
|
||||
template<class Face>
|
||||
void Foam::UnsortedMeshedSurface<Face>::write
|
||||
(
|
||||
const Time& d,
|
||||
const Time& t,
|
||||
const word& surfName
|
||||
) const
|
||||
{
|
||||
write(OFstream(this->findMeshFile(d, surfName))());
|
||||
MeshedSurfaceProxy<Face>(*this).write(t, surfName);
|
||||
}
|
||||
|
||||
|
||||
@ -695,6 +756,24 @@ void Foam::UnsortedMeshedSurface<Face>::operator=
|
||||
}
|
||||
|
||||
|
||||
template<class Face>
|
||||
Foam::UnsortedMeshedSurface<Face>::operator
|
||||
Foam::MeshedSurfaceProxy<Face>() const
|
||||
{
|
||||
labelList faceMap;
|
||||
List<surfZone> zoneLst = this->sortedZones(faceMap);
|
||||
|
||||
return MeshedSurfaceProxy<Face>
|
||||
(
|
||||
this->points(),
|
||||
this->faces(),
|
||||
zoneLst,
|
||||
faceMap
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
@ -78,15 +78,10 @@ class UnsortedMeshedSurface
|
||||
:
|
||||
public MeshedSurface<Face>
|
||||
{
|
||||
// friends despite different faces
|
||||
template<class Face2>
|
||||
friend class MeshedSurface;
|
||||
|
||||
// friends despite different faces
|
||||
template<class Face2>
|
||||
friend class UnsortedMeshedSurface;
|
||||
|
||||
friend class MeshedSurface<Face>;
|
||||
// friends - despite different face representationsx
|
||||
template<class Face2> friend class MeshedSurface;
|
||||
template<class Face2> friend class UnsortedMeshedSurface;
|
||||
friend class surfMesh;
|
||||
|
||||
private:
|
||||
|
||||
@ -200,7 +195,7 @@ public:
|
||||
//- Construct from Istream
|
||||
UnsortedMeshedSurface(Istream&);
|
||||
|
||||
//- Construct from objectRegistry
|
||||
//- Construct from objectRegistry and a named surface
|
||||
UnsortedMeshedSurface(const Time&, const word& surfName="");
|
||||
|
||||
// Declare run-time constructor selection table
|
||||
@ -277,7 +272,7 @@ public:
|
||||
return zoneToc_;
|
||||
}
|
||||
|
||||
//- Sort faces according to zone.
|
||||
//- Sort faces according to zoneIds
|
||||
// Returns a surfZoneList and sets faceMap to index within faces()
|
||||
surfZoneList sortedZones(labelList& faceMap) const;
|
||||
|
||||
@ -365,6 +360,8 @@ public:
|
||||
|
||||
void operator=(const UnsortedMeshedSurface<Face>&);
|
||||
|
||||
//- Conversion operator to MeshedSurfaceProxy
|
||||
operator MeshedSurfaceProxy<Face>() const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -60,6 +60,9 @@ class surfMesh
|
||||
private MeshedSurfaceIOAllocator,
|
||||
public PrimitivePatch<face, ::Foam::UList, ::Foam::SubField<point>, point>
|
||||
{
|
||||
// friends
|
||||
template<class Face> friend class MeshedSurface;
|
||||
template<class Face> friend class UnsortedMeshedSurface;
|
||||
|
||||
public:
|
||||
|
||||
@ -259,17 +262,15 @@ public:
|
||||
void transfer(MeshedSurface<face>&);
|
||||
|
||||
|
||||
|
||||
//- Avoid masking the normal objectRegistry write
|
||||
using surfaceRegistry::write;
|
||||
|
||||
|
||||
//- Write to file
|
||||
static void write(const fileName&, const surfMesh&);
|
||||
|
||||
//- Write to file
|
||||
void write(const fileName&);
|
||||
|
||||
|
||||
// Storage management
|
||||
|
||||
//- Transfer contents to the Xfer container as a MeshedSurface
|
||||
|
||||
@ -25,9 +25,10 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "surfaceFormatsCore.H"
|
||||
|
||||
#include "Time.H"
|
||||
#include "IFstream.H"
|
||||
#include "OFstream.H"
|
||||
#include "Time.H"
|
||||
#include "SortableList.H"
|
||||
#include "surfMesh.H"
|
||||
|
||||
@ -37,13 +38,6 @@ Foam::word Foam::fileFormats::surfaceFormatsCore::nativeExt("ofs");
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
bool
|
||||
Foam::fileFormats::surfaceFormatsCore::isNative(const word& ext)
|
||||
{
|
||||
return (ext == nativeExt);
|
||||
}
|
||||
|
||||
|
||||
Foam::string
|
||||
Foam::fileFormats::surfaceFormatsCore::getLineNoComment
|
||||
(
|
||||
@ -60,7 +54,7 @@ Foam::fileFormats::surfaceFormatsCore::getLineNoComment
|
||||
return line;
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
Foam::fileName
|
||||
Foam::fileFormats::surfaceFormatsCore::localMeshFileName(const word& surfName)
|
||||
{
|
||||
@ -79,7 +73,7 @@ Foam::fileFormats::surfaceFormatsCore::localMeshFileName(const word& surfName)
|
||||
Foam::fileName
|
||||
Foam::fileFormats::surfaceFormatsCore::findMeshInstance
|
||||
(
|
||||
const Time& d,
|
||||
const Time& t,
|
||||
const word& surfName
|
||||
)
|
||||
{
|
||||
@ -88,12 +82,12 @@ Foam::fileFormats::surfaceFormatsCore::findMeshInstance
|
||||
// Search back through the time directories list to find the time
|
||||
// closest to and lower than current time
|
||||
|
||||
instantList ts = d.times();
|
||||
instantList ts = t.times();
|
||||
label instanceI;
|
||||
|
||||
for (instanceI = ts.size()-1; instanceI >= 0; --instanceI)
|
||||
{
|
||||
if (ts[instanceI].value() <= d.timeOutputValue())
|
||||
if (ts[instanceI].value() <= t.timeOutputValue())
|
||||
{
|
||||
break;
|
||||
}
|
||||
@ -106,7 +100,7 @@ Foam::fileFormats::surfaceFormatsCore::findMeshInstance
|
||||
{
|
||||
for (label i = instanceI; i >= 0; --i)
|
||||
{
|
||||
if (isFile(d.path()/ts[i].name()/localName))
|
||||
if (isFile(t.path()/ts[i].name()/localName))
|
||||
{
|
||||
return ts[i].name();
|
||||
}
|
||||
@ -120,7 +114,7 @@ Foam::fileFormats::surfaceFormatsCore::findMeshInstance
|
||||
Foam::fileName
|
||||
Foam::fileFormats::surfaceFormatsCore::findMeshFile
|
||||
(
|
||||
const Time& d,
|
||||
const Time& t,
|
||||
const word& surfName
|
||||
)
|
||||
{
|
||||
@ -129,12 +123,12 @@ Foam::fileFormats::surfaceFormatsCore::findMeshFile
|
||||
// Search back through the time directories list to find the time
|
||||
// closest to and lower than current time
|
||||
|
||||
instantList ts = d.times();
|
||||
instantList ts = t.times();
|
||||
label instanceI;
|
||||
|
||||
for (instanceI = ts.size()-1; instanceI >= 0; --instanceI)
|
||||
{
|
||||
if (ts[instanceI].value() <= d.timeOutputValue())
|
||||
if (ts[instanceI].value() <= t.timeOutputValue())
|
||||
{
|
||||
break;
|
||||
}
|
||||
@ -147,7 +141,7 @@ Foam::fileFormats::surfaceFormatsCore::findMeshFile
|
||||
{
|
||||
for (label i = instanceI; i >= 0; --i)
|
||||
{
|
||||
fileName testName(d.path()/ts[i].name()/localName);
|
||||
fileName testName(t.path()/ts[i].name()/localName);
|
||||
|
||||
if (isFile(testName))
|
||||
{
|
||||
@ -157,94 +151,9 @@ Foam::fileFormats::surfaceFormatsCore::findMeshFile
|
||||
}
|
||||
|
||||
// fallback to "constant"
|
||||
return d.path()/"constant"/localName;
|
||||
}
|
||||
|
||||
|
||||
// Returns zone info.
|
||||
// Sets faceMap to the indexing according to zone numbers.
|
||||
// Zone numbers start at 0.
|
||||
Foam::surfZoneList
|
||||
Foam::fileFormats::surfaceFormatsCore::sortedZonesById
|
||||
(
|
||||
const UList<label>& zoneIds,
|
||||
const Map<word>& zoneNames,
|
||||
labelList& faceMap
|
||||
)
|
||||
{
|
||||
// determine sort order according to zone numbers
|
||||
|
||||
// std::sort() really seems to mix up the order.
|
||||
// and std::stable_sort() might take too long / too much memory
|
||||
|
||||
// Assuming that we have relatively fewer zones compared to the
|
||||
// number of items, just do it ourselves
|
||||
|
||||
// step 1: get zone sizes and store (origId => zoneI)
|
||||
Map<label> lookup;
|
||||
forAll(zoneIds, faceI)
|
||||
{
|
||||
const label origId = zoneIds[faceI];
|
||||
|
||||
Map<label>::iterator fnd = lookup.find(origId);
|
||||
if (fnd != lookup.end())
|
||||
{
|
||||
fnd()++;
|
||||
}
|
||||
else
|
||||
{
|
||||
lookup.insert(origId, 1);
|
||||
}
|
||||
}
|
||||
|
||||
// step 2: assign start/size (and name) to the newZones
|
||||
// re-use the lookup to map (zoneId => zoneI)
|
||||
surfZoneList zoneLst(lookup.size());
|
||||
label start = 0;
|
||||
label zoneI = 0;
|
||||
forAllIter(Map<label>, lookup, iter)
|
||||
{
|
||||
label origId = iter.key();
|
||||
|
||||
word name;
|
||||
Map<word>::const_iterator fnd = zoneNames.find(origId);
|
||||
if (fnd != zoneNames.end())
|
||||
{
|
||||
name = fnd();
|
||||
}
|
||||
else
|
||||
{
|
||||
name = word("zone") + ::Foam::name(zoneI);
|
||||
}
|
||||
|
||||
zoneLst[zoneI] = surfZone
|
||||
(
|
||||
name,
|
||||
0, // initialize with zero size
|
||||
start,
|
||||
zoneI
|
||||
);
|
||||
|
||||
// increment the start for the next zone
|
||||
// and save the (zoneId => zoneI) mapping
|
||||
start += iter();
|
||||
iter() = zoneI++;
|
||||
}
|
||||
|
||||
|
||||
// step 3: build the re-ordering
|
||||
faceMap.setSize(zoneIds.size());
|
||||
|
||||
forAll(zoneIds, faceI)
|
||||
{
|
||||
label zoneI = lookup[zoneIds[faceI]];
|
||||
faceMap[faceI] =
|
||||
zoneLst[zoneI].start() + zoneLst[zoneI].size()++;
|
||||
}
|
||||
|
||||
// with reordered faces registered in faceMap
|
||||
return zoneLst;
|
||||
return t.path()/"constant"/localName;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
bool
|
||||
@ -291,6 +200,7 @@ Foam::fileFormats::surfaceFormatsCore::surfaceFormatsCore()
|
||||
Foam::fileFormats::surfaceFormatsCore::~surfaceFormatsCore()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
@ -75,15 +75,6 @@ protected:
|
||||
return List<surfZone>(1, surfZone(name, container.size(), 0, 0));
|
||||
}
|
||||
|
||||
//- Determine the sort order from the zone ids.
|
||||
// Returns zone list and sets faceMap to indices within faceLst
|
||||
static surfZoneList sortedZonesById
|
||||
(
|
||||
const UList<label>& zoneIds,
|
||||
const Map<word>& zoneNames,
|
||||
labelList& faceMap
|
||||
);
|
||||
|
||||
//- Read non-comment line
|
||||
static string getLineNoComment(IFstream&);
|
||||
|
||||
@ -97,18 +88,6 @@ public:
|
||||
|
||||
// Static Member Functions
|
||||
|
||||
//- Check if file extension corresponds to 'native' surface format
|
||||
static bool isNative(const word&);
|
||||
|
||||
//- Return the local file name (within time directory)
|
||||
static fileName localMeshFileName(const word& surfName="");
|
||||
|
||||
//- Find instance with surfName
|
||||
static fileName findMeshInstance(const Time&, const word& surfName="");
|
||||
|
||||
//- Find mesh file with surfName
|
||||
static fileName findMeshFile(const Time&, const word& surfName="");
|
||||
|
||||
static bool checkSupport
|
||||
(
|
||||
const wordHashSet& available,
|
||||
@ -118,6 +97,18 @@ public:
|
||||
);
|
||||
|
||||
|
||||
//- Return the local file name (within time directory)
|
||||
// NEEDS FIXING
|
||||
static fileName localMeshFileName(const word& surfName="");
|
||||
|
||||
//- Find instance with surfName
|
||||
// NEEDS FIXING
|
||||
static fileName findMeshInstance(const Time&, const word& surfName="");
|
||||
|
||||
//- Find mesh file with surfName
|
||||
// NEEDS FIXING
|
||||
static fileName findMeshFile(const Time&, const word& surfName="");
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
|
||||
Reference in New Issue
Block a user