COMP: correct the internal reference types for surfMesh

- had a PrimitivePatch with SubField, but now use const pointField&.

  There is no derivation path from a pointIOField to SubField<point>,
  so a const reference makes more sense.
This commit is contained in:
Mark Olesen
2020-04-02 11:23:14 +02:00
parent d79954869d
commit ae14a1ef31
3 changed files with 37 additions and 72 deletions

View File

@ -146,14 +146,14 @@ public:
void clear(); void clear();
// Writing // Writing
//- Write using stream options //- Write using stream options
virtual bool writeObject virtual bool writeObject
( (
IOstreamOption streamOpt, IOstreamOption streamOpt,
const bool valid const bool valid
) const; ) const;
}; };

View File

@ -59,18 +59,24 @@ Foam::word Foam::surfMesh::meshSubDir = "surfMesh";
// zoneName = "zone0"; // zoneName = "zone0";
// } // }
// //
// // Set single default zone // // Set single default zone with nFaces
// surfZones_.resize(1); // surfZones_.resize(1);
// surfZones_[0] = surfZone // surfZones_[0] = surfZone(zoneName, nFaces());
// (
// zoneName,
// nFaces(), // zone size
// 0, // zone start
// 0 // zone index
// );
// } // }
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void Foam::surfMesh::updateRefs()
{
// Synchronize UList reference to the faces
static_cast<MeshReference&>(*this).shallowCopy
(
this->storedFaces()
);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::surfMesh::surfMesh(const IOobject& io) Foam::surfMesh::surfMesh(const IOobject& io)
@ -288,37 +294,6 @@ Foam::surfMesh::~surfMesh()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::surfMesh::updatePointsRef()
{
// Assign the reference to the points (quite ugly)
// points() are returned as Field but are actually stored as SubField
reinterpret_cast<typename MeshReference::PointFieldType&>
(
const_cast<Field<point>&>(MeshReference::points())
).shallowCopy
(
this->storedPoints()
);
}
void Foam::surfMesh::updateFacesRef()
{
// Assign the reference to the faces (UList)
static_cast<MeshReference&>(*this).shallowCopy
(
this->storedFaces()
);
}
void Foam::surfMesh::updateRefs()
{
this->updatePointsRef();
this->updateFacesRef();
}
void Foam::surfMesh::copySurface void Foam::surfMesh::copySurface
( (
const pointField& points, const pointField& points,
@ -431,6 +406,9 @@ void Foam::surfMesh::transfer
Foam::autoPtr<Foam::MeshedSurface<Foam::face>> Foam::autoPtr<Foam::MeshedSurface<Foam::face>>
Foam::surfMesh::releaseGeom() Foam::surfMesh::releaseGeom()
{ {
clearOut(); // Clear addressing
clearFields();
// Start with an empty geometry // Start with an empty geometry
auto aptr = autoPtr<MeshedSurface<face>>::New(); auto aptr = autoPtr<MeshedSurface<face>>::New();
@ -440,8 +418,6 @@ Foam::surfMesh::releaseGeom()
aptr->storedZones().transfer(this->storedZones()); aptr->storedZones().transfer(this->storedZones());
this->updateRefs(); // This may not be needed... this->updateRefs(); // This may not be needed...
clearOut(); // Clear addressing.
clearFields();
return aptr; return aptr;
} }
@ -577,7 +553,7 @@ void Foam::surfMesh::write
void Foam::surfMesh::write void Foam::surfMesh::write
( (
const fileName& name, const fileName& name,
const word& ext, const word& fileType,
IOstreamOption streamOpt, IOstreamOption streamOpt,
const dictionary& options const dictionary& options
) const ) const
@ -587,7 +563,7 @@ void Foam::surfMesh::write
this->points(), this->points(),
this->faces(), this->faces(),
this->surfZones() this->surfZones()
).write(name, ext, streamOpt, options); ).write(name, fileType, streamOpt, options);
} }

View File

@ -28,7 +28,8 @@ Class
Foam::surfMesh Foam::surfMesh
Description Description
A surface mesh consisting of general polygon faces. A surface mesh consisting of general polygon faces that has
IO capabilities and a registry for storing fields.
SourceFiles SourceFiles
surfMesh.C surfMesh.C
@ -43,9 +44,7 @@ SourceFiles
#include "surfaceRegistry.H" #include "surfaceRegistry.H"
#include "MeshedSurfaceIOAllocator.H" #include "MeshedSurfaceIOAllocator.H"
#include "PrimitivePatch.H" #include "PrimitivePatch.H"
#include "SubField.H"
#include "surfZoneIOList.H" #include "surfZoneIOList.H"
#include "surfFieldsFwd.H" #include "surfFieldsFwd.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -66,7 +65,7 @@ class surfMesh
: :
public surfaceRegistry, public surfaceRegistry,
private Detail::MeshedSurfaceIOAllocator, private Detail::MeshedSurfaceIOAllocator,
public PrimitivePatch<face, ::Foam::UList, ::Foam::SubField<point>, point> public PrimitivePatch<face, UList, const pointField&, point>
{ {
public: public:
@ -88,16 +87,12 @@ private:
// Private Typedefs // Private Typedefs
//- Memory and IO management
typedef Detail::MeshedSurfaceIOAllocator Allocator; typedef Detail::MeshedSurfaceIOAllocator Allocator;
typedef PrimitivePatch //- Internal mesh storage type
< typedef PrimitivePatch<face, UList, const pointField&, point>
face, MeshReference;
::Foam::UList,
::Foam::SubField<point>,
point
>
MeshReference;
// Private Data // Private Data
@ -137,14 +132,8 @@ protected:
return surfZones_; return surfZones_;
} }
//- Update references to storedFaces //- Update point/face references
virtual void updateFacesRef(); void updateRefs();
//- Update references to storedPoints
virtual void updatePointsRef();
//- Update references to storedPoints/storedFaces
virtual void updateRefs();
public: public:
@ -365,12 +354,12 @@ public:
const dictionary& options = dictionary::null const dictionary& options = dictionary::null
) const; ) const;
//- Write to file, choosing writer given extension. //- Write to file, choosing writer for given fileType.
// Uses MeshedSurfaceProxy for writing. // Uses MeshedSurfaceProxy for writing.
void write void write
( (
const fileName& name, const fileName& name,
const word& ext, const word& fileType,
IOstreamOption streamOpt = IOstreamOption(), IOstreamOption streamOpt = IOstreamOption(),
const dictionary& options = dictionary::null const dictionary& options = dictionary::null
) const; ) const;