Commit 23476071 authored by Mark Olesen's avatar Mark Olesen
Browse files

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).
parent 2a3bb0f5
......@@ -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();
......
......@@ -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,
......
......@@ -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"
......
......@@ -154,11 +154,4 @@ void Foam::polyMesh::initMesh(cellList& c)
neighbour_.note() = meshInfo;
}
void Foam::polyMesh::initMesh(const xfer<cellList>& clst)
{
initMesh(clst());
}
// ************************************************************************* //
......@@ -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
......
......@@ -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();
......
......@@ -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();
......
......@@ -228,38 +228,6 @@ Foam::fvMesh::fvMesh(const IOobject& io)
}
</