polyMesh, fvMesh xfer constructors

- drop copy components constructors in favour of the xfer versions. Even if
  the caller sends through constant data, if will be automatically promoted
  to xfer (via a copy operation).
This commit is contained in:
Mark Olesen
2008-10-24 17:29:05 +02:00
parent 2a3bb0f5c4
commit 23476071dc
9 changed files with 42 additions and 517 deletions

View File

@ -230,7 +230,7 @@ Foam::polyMesh::polyMesh(const IOobject& io)
} }
else else
{ {
cellIOList c cellIOList cLst
( (
IOobject IOobject
( (
@ -243,9 +243,8 @@ Foam::polyMesh::polyMesh(const IOobject& io)
) )
); );
// Set the primitive mesh // Set the primitive mesh
initMesh(c); initMesh(cLst);
owner_.write(); owner_.write();
neighbour_.write(); neighbour_.write();
@ -271,162 +270,6 @@ Foam::polyMesh::polyMesh(const IOobject& io)
} }
Foam::polyMesh::polyMesh
(
const IOobject& io,
const pointField& points,
const faceList& faces,
const labelList& owner,
const labelList& neighbour,
const bool syncPar
)
:
objectRegistry(io),
primitiveMesh(),
points_
(
IOobject
(
"points",
instance(),
meshSubDir,
*this,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
points
),
faces_
(
IOobject
(
"faces",
instance(),
meshSubDir,
*this,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
faces
),
owner_
(
IOobject
(
"owner",
instance(),
meshSubDir,
*this,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
owner
),
neighbour_
(
IOobject
(
"neighbour",
instance(),
meshSubDir,
*this,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
neighbour
),
clearedPrimitives_(false),
boundary_
(
IOobject
(
"boundary",
instance(),
meshSubDir,
*this,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
*this,
0
),
bounds_(points_, syncPar),
directions_(Vector<label>::zero),
pointZones_
(
IOobject
(
"pointZones",
instance(),
meshSubDir,
*this,
IOobject::NO_READ,
IOobject::NO_WRITE
),
*this,
0
),
faceZones_
(
IOobject
(
"faceZones",
instance(),
meshSubDir,
*this,
IOobject::NO_READ,
IOobject::NO_WRITE
),
*this,
0
),
cellZones_
(
IOobject
(
"cellZones",
instance(),
meshSubDir,
*this,
IOobject::NO_READ,
IOobject::NO_WRITE
),
*this,
0
),
globalMeshDataPtr_(NULL),
moving_(false),
changing_(false),
curMotionTimeIndex_(time().timeIndex()),
oldPointsPtr_(NULL)
{
// Check if the faces and cells are valid
forAll (faces_, faceI)
{
const face& curFace = faces_[faceI];
if (min(curFace) < 0 || max(curFace) > points_.size())
{
FatalErrorIn
(
"polyMesh::polyMesh\n"
"(\n"
" const IOobject& io,\n"
" const pointField& points,\n"
" const faceList& faces,\n"
" const cellList& cells\n"
")\n"
) << "Face " << faceI << "contains vertex labels out of range: "
<< curFace << " Max point index = " << points_.size()
<< abort(FatalError);
}
}
// Set the primitive mesh
initMesh();
}
Foam::polyMesh::polyMesh Foam::polyMesh::polyMesh
( (
const IOobject& io, const IOobject& io,
@ -583,183 +426,6 @@ Foam::polyMesh::polyMesh
} }
Foam::polyMesh::polyMesh
(
const IOobject& io,
const pointField& points,
const faceList& faces,
const cellList& cells,
const bool syncPar
)
:
objectRegistry(io),
primitiveMesh(),
points_
(
IOobject
(
"points",
instance(),
meshSubDir,
*this,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
points
),
faces_
(
IOobject
(
"faces",
instance(),
meshSubDir,
*this,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
faces
),
owner_
(
IOobject
(
"owner",
instance(),
meshSubDir,
*this,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
0
),
neighbour_
(
IOobject
(
"neighbour",
instance(),
meshSubDir,
*this,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
0
),
clearedPrimitives_(false),
boundary_
(
IOobject
(
"boundary",
instance(),
meshSubDir,
*this,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
*this,
0
),
bounds_(points_, syncPar),
directions_(Vector<label>::zero),
pointZones_
(
IOobject
(
"pointZones",
instance(),
meshSubDir,
*this,
IOobject::NO_READ,
IOobject::NO_WRITE
),
*this,
0
),
faceZones_
(
IOobject
(
"faceZones",
instance(),
meshSubDir,
*this,
IOobject::NO_READ,
IOobject::NO_WRITE
),
*this,
0
),
cellZones_
(
IOobject
(
"cellZones",
instance(),
meshSubDir,
*this,
IOobject::NO_READ,
IOobject::NO_WRITE
),
*this,
0
),
globalMeshDataPtr_(NULL),
moving_(false),
changing_(false),
curMotionTimeIndex_(time().timeIndex()),
oldPointsPtr_(NULL)
{
// Check if the faces and cells are valid
forAll (faces_, faceI)
{
const face& curFace = faces_[faceI];
if (min(curFace) < 0 || max(curFace) > points_.size())
{
FatalErrorIn
(
"polyMesh::polyMesh\n"
"(\n"
" const IOobject& io,\n"
" const pointField& points,\n"
" const faceList& faces,\n"
" const cellList& cells\n"
")\n"
) << "Face " << faceI << "contains vertex labels out of range: "
<< curFace << " Max point index = " << points_.size()
<< abort(FatalError);
}
}
// Check if the faces and cells are valid
forAll (cells, cellI)
{
const cell& curCell = cells[cellI];
if (min(curCell) < 0 || max(curCell) > faces_.size())
{
FatalErrorIn
(
"polyMesh::polyMesh\n"
"(\n"
" const IOobject& io,\n"
" const pointField& points,\n"
" const faceList& faces,\n"
" const cellList& cells\n"
")\n"
) << "Cell " << cellI << "contains face labels out of range: "
<< curCell << " Max face index = " << faces_.size()
<< abort(FatalError);
}
}
// Set the primitive mesh
initMesh(const_cast<cellList&>(cells));
}
Foam::polyMesh::polyMesh Foam::polyMesh::polyMesh
( (
const IOobject& io, const IOobject& io,
@ -910,7 +576,8 @@ Foam::polyMesh::polyMesh
} }
} }
const cellList& cLst = cells(); // transfer in cell list
cellList cLst(cells);
// Check if cells are valid // Check if cells are valid
forAll (cLst, cellI) forAll (cLst, cellI)
@ -935,7 +602,7 @@ Foam::polyMesh::polyMesh
} }
// Set the primitive mesh // Set the primitive mesh
initMesh(cells); initMesh(cLst);
} }
@ -1019,8 +686,8 @@ void Foam::polyMesh::resetPrimitives
} }
// Set the primitive mesh from the owner_, neighbour_. Works // Set the primitive mesh from the owner_, neighbour_.
// out from patch end where the active faces stop. // Works out from patch end where the active faces stop.
initMesh(); initMesh();

View File

@ -116,8 +116,8 @@ private:
//- Boundary mesh //- Boundary mesh
mutable polyBoundaryMesh boundary_; mutable polyBoundaryMesh boundary_;
//- Mesh bounding-box. created from points on construction //- Mesh bounding-box.
// and updated when the mesh moves // Created from points on construction, updated when the mesh moves
boundBox bounds_; boundBox bounds_;
//- vector of valid directions in mesh //- vector of valid directions in mesh
@ -170,9 +170,6 @@ private:
//- Initialise the polyMesh from the given set of cells //- Initialise the polyMesh from the given set of cells
void initMesh(cellList& c); void initMesh(cellList& c);
//- Initialise the polyMesh from the given set of cells
void initMesh(const xfer<cellList>& c);
//- Calculate the valid directions in the mesh from the boundaries //- Calculate the valid directions in the mesh from the boundaries
void calcDirections() const; void calcDirections() const;
@ -217,18 +214,6 @@ public:
//- Construct from IOobject //- Construct from IOobject
explicit polyMesh(const IOobject& io); explicit polyMesh(const IOobject& io);
//- Construct without boundary from components.
// Boundary is added using addPatches() member function
polyMesh
(
const IOobject& io,
const pointField& points,
const faceList& faces,
const labelList& owner,
const labelList& neighbour,
const bool syncPar = true
);
//- Construct without boundary from components. //- Construct without boundary from components.
// Boundary is added using addPatches() member function // Boundary is added using addPatches() member function
polyMesh polyMesh
@ -241,17 +226,6 @@ public:
const bool syncPar = true const bool syncPar = true
); );
//- Construct without boundary with cells rather than owner/neighbour.
// Boundary is added using addPatches() member function
polyMesh
(
const IOobject& io,
const pointField& points,
const faceList& faces,
const cellList& cells,
const bool syncPar = true
);
//- Construct without boundary with cells rather than owner/neighbour. //- Construct without boundary with cells rather than owner/neighbour.
// Boundary is added using addPatches() member function // Boundary is added using addPatches() member function
polyMesh polyMesh
@ -267,7 +241,7 @@ public:
polyMesh polyMesh
( (
const IOobject& io, const IOobject& io,
const pointField& points, const xfer<pointField>& points,
const cellShapeList& shapes, const cellShapeList& shapes,
const faceListList& boundaryFaces, const faceListList& boundaryFaces,
const wordList& boundaryPatchNames, const wordList& boundaryPatchNames,

View File

@ -39,7 +39,7 @@ Foam::labelListList Foam::polyMesh::cellShapePointCells
const cellShapeList& c const cellShapeList& c
) const ) const
{ {
List<DynamicList<label, primitiveMesh::cellsPerPoint_> > List<DynamicList<label, primitiveMesh::cellsPerPoint_> >
pc(points().size()); pc(points().size());
// For each cell // For each cell
@ -136,7 +136,7 @@ Foam::labelList Foam::polyMesh::facePatchFaceCells
Foam::polyMesh::polyMesh Foam::polyMesh::polyMesh
( (
const IOobject& io, const IOobject& io,
const pointField& points, const xfer<pointField>& points,
const cellShapeList& cellsAsShapes, const cellShapeList& cellsAsShapes,
const faceListList& boundaryFaces, const faceListList& boundaryFaces,
const wordList& boundaryPatchNames, const wordList& boundaryPatchNames,
@ -311,7 +311,7 @@ Foam::polyMesh::polyMesh
// Insertion cannot be done in one go as the faces need to be // Insertion cannot be done in one go as the faces need to be
// added into the list in the increasing order of neighbour // added into the list in the increasing order of neighbour
// cells. Therefore, all neighbours will be detected first // cells. Therefore, all neighbours will be detected first
// and then added in the correct order. // and then added in the correct order.
const faceList& curFaces = cellsFaceShapes[cellI]; const faceList& curFaces = cellsFaceShapes[cellI];
@ -414,8 +414,8 @@ Foam::polyMesh::polyMesh
( (
"polyMesh::polyMesh\n" "polyMesh::polyMesh\n"
"(\n" "(\n"
" const IOobject& io,\n" " const IOobject&,\n"
" const pointField& points,\n" " const xfer<pointField>&,\n"
" const cellShapeList& cellsAsShapes,\n" " const cellShapeList& cellsAsShapes,\n"
" const faceListList& boundaryFaces,\n" " const faceListList& boundaryFaces,\n"
" const wordList& boundaryPatchTypes,\n" " const wordList& boundaryPatchTypes,\n"
@ -472,8 +472,8 @@ Foam::polyMesh::polyMesh
( (
"polyMesh::polyMesh\n" "polyMesh::polyMesh\n"
"(\n" "(\n"
" const IOobject& io,\n" " const IOobject&,\n"
" const pointField& points,\n" " const xfer<pointField>&,\n"
" const cellShapeList& cellsAsShapes,\n" " const cellShapeList& cellsAsShapes,\n"
" const faceListList& boundaryFaces,\n" " const faceListList& boundaryFaces,\n"
" const wordList& boundaryPatchTypes,\n" " const wordList& boundaryPatchTypes,\n"

View File

@ -154,11 +154,4 @@ void Foam::polyMesh::initMesh(cellList& c)
neighbour_.note() = meshInfo; neighbour_.note() = meshInfo;
} }
void Foam::polyMesh::initMesh(const xfer<cellList>& clst)
{
initMesh(clst());
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -142,9 +142,9 @@ Foam::autoPtr<Foam::polyMesh> Foam::meshReader::mesh
"constant", "constant",
registry registry
), ),
points_, xferMove(points_),
meshFaces_, xferMove(meshFaces_),
cellPolys_ xferMove(cellPolys_)
) )
); );
@ -166,14 +166,7 @@ void Foam::meshReader::writeMesh
IOstream::streamFormat fmt IOstream::streamFormat fmt
) const ) const
{ {
fileName meshDir = mesh.objectRegistry::path()/mesh.meshDir(); mesh.removeFiles();
// remove some directories and files - this should be easier
mesh.removeFiles(mesh.instance());
if (dir(meshDir/"sets"))
{
rmDir(meshDir/"sets");
}
Info<< "Writing polyMesh" << endl; Info<< "Writing polyMesh" << endl;
mesh.writeObject mesh.writeObject

View File

@ -1398,10 +1398,10 @@ Foam::autoPtr<Foam::polyMesh> Foam::polyMeshAdder::add
new polyMesh new polyMesh
( (
io, io,
allPoints, xferMove(allPoints),
allFaces, xferMove(allFaces),
allOwner, xferMove(allOwner),
allNeighbour xferMove(allNeighbour)
) )
); );
polyMesh& mesh = tmesh(); polyMesh& mesh = tmesh();

View File

@ -2097,29 +2097,20 @@ Foam::polyTopoChange::polyTopoChange
void Foam::polyTopoChange::clear() void Foam::polyTopoChange::clear()
{ {
points_.clear(); points_.clearStorage();
points_.setSize(0); pointMap_.clearStorage();
pointMap_.clear(); reversePointMap_.clearStorage();
pointMap_.setSize(0);
reversePointMap_.clear();
reversePointMap_.setSize(0);
pointZone_.clear(); pointZone_.clear();
pointZone_.resize(0); pointZone_.resize(0);
retiredPoints_.clear(); retiredPoints_.clear();
retiredPoints_.resize(0); retiredPoints_.resize(0);
faces_.clear(); faces_.clearStorage();
faces_.setSize(0); region_.clearStorage();
region_.clear(); faceOwner_.clearStorage();
region_.setSize(0); faceNeighbour_.clearStorage();
faceOwner_.clear(); faceMap_.clearStorage();
faceOwner_.setSize(0); reverseFaceMap_.clearStorage();
faceNeighbour_.clear();
faceNeighbour_.setSize(0);
faceMap_.clear();
faceMap_.setSize(0);
reverseFaceMap_.clear();
reverseFaceMap_.setSize(0);
faceFromPoint_.clear(); faceFromPoint_.clear();
faceFromPoint_.resize(0); faceFromPoint_.resize(0);
faceFromEdge_.clear(); faceFromEdge_.clear();
@ -2132,12 +2123,9 @@ void Foam::polyTopoChange::clear()
faceZoneFlip_.resize(0); faceZoneFlip_.resize(0);
nActiveFaces_ = 0; nActiveFaces_ = 0;
cellMap_.clear(); cellMap_.clearStorage();
cellMap_.setSize(0); reverseCellMap_.clearStorage();
reverseCellMap_.clear(); cellZone_.clearStorage();
reverseCellMap_.setSize(0);
cellZone_.clear();
cellZone_.setSize(0);
cellFromPoint_.clear(); cellFromPoint_.clear();
cellFromPoint_.resize(0); cellFromPoint_.resize(0);
cellFromEdge_.clear(); cellFromEdge_.clear();

View File

@ -228,38 +228,6 @@ Foam::fvMesh::fvMesh(const IOobject& io)
} }
Foam::fvMesh::fvMesh
(
const IOobject& io,
const pointField& points,
const faceList& faces,
const labelList& allOwner,
const labelList& allNeighbour,
const bool syncPar
)
:
polyMesh(io, points, faces, allOwner, allNeighbour, syncPar),
surfaceInterpolation(*this),
boundary_(*this),
lduPtr_(NULL),
curTimeIndex_(time().timeIndex()),
VPtr_(NULL),
V0Ptr_(NULL),
V00Ptr_(NULL),
SfPtr_(NULL),
magSfPtr_(NULL),
CPtr_(NULL),
CfPtr_(NULL),
phiPtr_(NULL)
{
if (debug)
{
Info<< "Constructing fvMesh from components"
<< endl;
}
}
Foam::fvMesh::fvMesh Foam::fvMesh::fvMesh
( (
const IOobject& io, const IOobject& io,
@ -286,39 +254,7 @@ Foam::fvMesh::fvMesh
{ {
if (debug) if (debug)
{ {
Info<< "Constructing fvMesh from components" Info<< "Constructing fvMesh from components" << endl;
<< endl;
}
}
Foam::fvMesh::fvMesh
(
const IOobject& io,
const pointField& points,
const faceList& faces,
const cellList& cells,
const bool syncPar
)
:
polyMesh(io, points, faces, cells, syncPar),
surfaceInterpolation(*this),
boundary_(*this),
lduPtr_(NULL),
curTimeIndex_(time().timeIndex()),
VPtr_(NULL),
V0Ptr_(NULL),
V00Ptr_(NULL),
SfPtr_(NULL),
magSfPtr_(NULL),
CPtr_(NULL),
CfPtr_(NULL),
phiPtr_(NULL)
{
if (debug)
{
Info<< "Constructing fvMesh from components"
<< endl;
} }
} }
@ -348,8 +284,7 @@ Foam::fvMesh::fvMesh
{ {
if (debug) if (debug)
{ {
Info<< "Constructing fvMesh from components" Info<< "Constructing fvMesh from components" << endl;
<< endl;
} }
} }

View File

@ -93,7 +93,7 @@ class fvMesh
//- Current time index for cell volumes //- Current time index for cell volumes
// Note. The whole mechanism will be replaced once the // Note. The whole mechanism will be replaced once the
// dimensionedField is created and the dimensionedField // dimensionedField is created and the dimensionedField
// will take care of the old-time levels. // will take care of the old-time levels.
mutable label curTimeIndex_; mutable label curTimeIndex_;
//- Cell volumes old time level //- Cell volumes old time level
@ -168,18 +168,6 @@ public:
//- Construct from IOobject //- Construct from IOobject
explicit fvMesh(const IOobject& io); explicit fvMesh(const IOobject& io);
//- Construct from components without boundary.
// Boundary is added using addFvPatches() member function
fvMesh
(
const IOobject& io,
const pointField& points,
const faceList& faces,
const labelList& allOwner,
const labelList& allNeighbour,
const bool syncPar = true
);
//- Construct from components without boundary. //- Construct from components without boundary.
// Boundary is added using addFvPatches() member function // Boundary is added using addFvPatches() member function
fvMesh fvMesh
@ -192,20 +180,7 @@ public:
const bool syncPar = true const bool syncPar = true
); );
//- Construct from components with cells rather than owner //- Construct without boundary from cells rather than owner/neighbour.
// and neighbourwithout boundary.
// Boundary is added using addPatches() member function
fvMesh
(
const IOobject& io,
const pointField& points,
const faceList& faces,
const cellList& cells,
const bool syncPar = true
);
//- Construct from components with cells rather than owner
// and neighbourwithout boundary.
// Boundary is added using addPatches() member function // Boundary is added using addPatches() member function
fvMesh fvMesh
( (
@ -252,7 +227,7 @@ public:
return *this; return *this;
} }
//- Return reference to name //- Return reference to name
// Note: name() is currently ambiguous due to derivation from // Note: name() is currently ambiguous due to derivation from
// surfaceInterpolation // surfaceInterpolation
const word& name() const const word& name() const