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
{
cellIOList c
cellIOList cLst
(
IOobject
(
@ -243,9 +243,8 @@ Foam::polyMesh::polyMesh(const IOobject& io)
)
);
// Set the primitive mesh
initMesh(c);
initMesh(cLst);
owner_.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
(
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
(
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
forAll (cLst, cellI)
@ -935,7 +602,7 @@ Foam::polyMesh::polyMesh
}
// 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
// out from patch end where the active faces stop.
// Set the primitive mesh from the owner_, neighbour_.
// Works out from patch end where the active faces stop.
initMesh();

View File

@ -116,8 +116,8 @@ private:
//- Boundary mesh
mutable polyBoundaryMesh boundary_;
//- Mesh bounding-box. created from points on construction
// and updated when the mesh moves
//- Mesh bounding-box.
// Created from points on construction, updated when the mesh moves
boundBox bounds_;
//- vector of valid directions in mesh
@ -170,9 +170,6 @@ private:
//- Initialise the polyMesh from the given set of cells
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
void calcDirections() const;
@ -217,18 +214,6 @@ public:
//- Construct from IOobject
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.
// Boundary is added using addPatches() member function
polyMesh
@ -241,17 +226,6 @@ public:
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.
// Boundary is added using addPatches() member function
polyMesh
@ -267,7 +241,7 @@ public:
polyMesh
(
const IOobject& io,
const pointField& points,
const xfer<pointField>& points,
const cellShapeList& shapes,
const faceListList& boundaryFaces,
const wordList& boundaryPatchNames,

View File

@ -39,7 +39,7 @@ Foam::labelListList Foam::polyMesh::cellShapePointCells
const cellShapeList& c
) const
{
List<DynamicList<label, primitiveMesh::cellsPerPoint_> >
List<DynamicList<label, primitiveMesh::cellsPerPoint_> >
pc(points().size());
// For each cell
@ -136,7 +136,7 @@ Foam::labelList Foam::polyMesh::facePatchFaceCells
Foam::polyMesh::polyMesh
(
const IOobject& io,
const pointField& points,
const xfer<pointField>& points,
const cellShapeList& cellsAsShapes,
const faceListList& boundaryFaces,
const wordList& boundaryPatchNames,
@ -311,7 +311,7 @@ Foam::polyMesh::polyMesh
// Insertion cannot be done in one go as the faces need to be
// added into the list in the increasing order of neighbour
// 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];
@ -414,8 +414,8 @@ Foam::polyMesh::polyMesh
(
"polyMesh::polyMesh\n"
"(\n"
" const IOobject& io,\n"
" const pointField& points,\n"
" const IOobject&,\n"
" const xfer<pointField>&,\n"
" const cellShapeList& cellsAsShapes,\n"
" const faceListList& boundaryFaces,\n"
" const wordList& boundaryPatchTypes,\n"
@ -472,8 +472,8 @@ Foam::polyMesh::polyMesh
(
"polyMesh::polyMesh\n"
"(\n"
" const IOobject& io,\n"
" const pointField& points,\n"
" const IOobject&,\n"
" const xfer<pointField>&,\n"
" const cellShapeList& cellsAsShapes,\n"
" const faceListList& boundaryFaces,\n"
" const wordList& boundaryPatchTypes,\n"

View File

@ -154,11 +154,4 @@ void Foam::polyMesh::initMesh(cellList& c)
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",
registry
),
points_,
meshFaces_,
cellPolys_
xferMove(points_),
xferMove(meshFaces_),
xferMove(cellPolys_)
)
);
@ -166,14 +166,7 @@ void Foam::meshReader::writeMesh
IOstream::streamFormat fmt
) const
{
fileName meshDir = mesh.objectRegistry::path()/mesh.meshDir();
// remove some directories and files - this should be easier
mesh.removeFiles(mesh.instance());
if (dir(meshDir/"sets"))
{
rmDir(meshDir/"sets");
}
mesh.removeFiles();
Info<< "Writing polyMesh" << endl;
mesh.writeObject

View File

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

View File

@ -2097,29 +2097,20 @@ Foam::polyTopoChange::polyTopoChange
void Foam::polyTopoChange::clear()
{
points_.clear();
points_.setSize(0);
pointMap_.clear();
pointMap_.setSize(0);
reversePointMap_.clear();
reversePointMap_.setSize(0);
points_.clearStorage();
pointMap_.clearStorage();
reversePointMap_.clearStorage();
pointZone_.clear();
pointZone_.resize(0);
retiredPoints_.clear();
retiredPoints_.resize(0);
faces_.clear();
faces_.setSize(0);
region_.clear();
region_.setSize(0);
faceOwner_.clear();
faceOwner_.setSize(0);
faceNeighbour_.clear();
faceNeighbour_.setSize(0);
faceMap_.clear();
faceMap_.setSize(0);
reverseFaceMap_.clear();
reverseFaceMap_.setSize(0);
faces_.clearStorage();
region_.clearStorage();
faceOwner_.clearStorage();
faceNeighbour_.clearStorage();
faceMap_.clearStorage();
reverseFaceMap_.clearStorage();
faceFromPoint_.clear();
faceFromPoint_.resize(0);
faceFromEdge_.clear();
@ -2132,12 +2123,9 @@ void Foam::polyTopoChange::clear()
faceZoneFlip_.resize(0);
nActiveFaces_ = 0;
cellMap_.clear();
cellMap_.setSize(0);
reverseCellMap_.clear();
reverseCellMap_.setSize(0);
cellZone_.clear();
cellZone_.setSize(0);
cellMap_.clearStorage();
reverseCellMap_.clearStorage();
cellZone_.clearStorage();
cellFromPoint_.clear();
cellFromPoint_.resize(0);
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
(
const IOobject& io,
@ -286,39 +254,7 @@ Foam::fvMesh::fvMesh
{
if (debug)
{
Info<< "Constructing fvMesh from components"
<< 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;
Info<< "Constructing fvMesh from components" << endl;
}
}
@ -348,8 +284,7 @@ Foam::fvMesh::fvMesh
{
if (debug)
{
Info<< "Constructing fvMesh from components"
<< endl;
Info<< "Constructing fvMesh from components" << endl;
}
}

View File

@ -93,7 +93,7 @@ class fvMesh
//- Current time index for cell volumes
// Note. The whole mechanism will be replaced once the
// 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_;
//- Cell volumes old time level
@ -168,18 +168,6 @@ public:
//- Construct from IOobject
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.
// Boundary is added using addFvPatches() member function
fvMesh
@ -192,20 +180,7 @@ public:
const bool syncPar = true
);
//- Construct from components with cells rather than owner
// 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.
//- Construct without boundary from cells rather than owner/neighbour.
// Boundary is added using addPatches() member function
fvMesh
(
@ -252,7 +227,7 @@ public:
return *this;
}
//- Return reference to name
//- Return reference to name
// Note: name() is currently ambiguous due to derivation from
// surfaceInterpolation
const word& name() const