ENH: cellShape::reset() - simplifies modification of existing shapes
This commit is contained in:
parent
5ec49a3898
commit
f2d634c49f
@ -401,7 +401,7 @@ int main(int argc, char *argv[])
|
||||
labelsTet[2] = pointMap[labels[2]];
|
||||
labelsTet[3] = pointMap[labels[4]];
|
||||
|
||||
cellShapes[nCells++] = cellShape(tet, labelsTet);
|
||||
cellShapes[nCells++].reset(tet, labelsTet);
|
||||
}
|
||||
|
||||
else if // Square-based pyramid
|
||||
@ -417,7 +417,7 @@ int main(int argc, char *argv[])
|
||||
labelsPyramid[3] = pointMap[labels[3]];
|
||||
labelsPyramid[4] = pointMap[labels[4]];
|
||||
|
||||
cellShapes[nCells++] = cellShape(pyr, labelsPyramid);
|
||||
cellShapes[nCells++].reset(pyr, labelsPyramid);
|
||||
}
|
||||
|
||||
else if // Triangular prism
|
||||
@ -433,7 +433,7 @@ int main(int argc, char *argv[])
|
||||
labelsPrism[4] = pointMap[labels[5]];
|
||||
labelsPrism[5] = pointMap[labels[6]];
|
||||
|
||||
cellShapes[nCells++] = cellShape(prism, labelsPrism);
|
||||
cellShapes[nCells++].reset(prism, labelsPrism);
|
||||
}
|
||||
|
||||
else // Hex
|
||||
@ -447,7 +447,7 @@ int main(int argc, char *argv[])
|
||||
labelsHex[6] = pointMap[labels[6]];
|
||||
labelsHex[7] = pointMap[labels[7]];
|
||||
|
||||
cellShapes[nCells++] = cellShape(hex, labelsHex);
|
||||
cellShapes[nCells++].reset(hex, labelsHex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -574,7 +574,7 @@ int main(int argc, char *argv[])
|
||||
];
|
||||
}
|
||||
|
||||
cellShapes[nCreatedCells] = cellShape(hex, cellPoints);
|
||||
cellShapes[nCreatedCells].reset(hex, cellPoints);
|
||||
|
||||
nCreatedCells++;
|
||||
}
|
||||
|
@ -238,15 +238,14 @@ cellShape extrudedQuadCellShape
|
||||
|
||||
return cellShape(hex, cellShapeLabels);
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Problem with edge matching. Edges: " << localFaces
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
|
||||
FatalErrorInFunction
|
||||
<< "Problem with edge matching. Edges: " << localFaces
|
||||
<< abort(FatalError);
|
||||
|
||||
// Return added to keep compiler happy
|
||||
return cellShape(hex, labelList(0));
|
||||
return cellShape(hex, labelList());
|
||||
}
|
||||
|
||||
|
||||
|
@ -178,15 +178,14 @@ cellShape extrudedTriangleCellShape
|
||||
|
||||
return cellShape(prism, cellShapeLabels);
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Problem with edge matching. Edges: " << localFaces
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
|
||||
FatalErrorInFunction
|
||||
<< "Problem with edge matching. Edges: " << localFaces
|
||||
<< abort(FatalError);
|
||||
|
||||
// Return added to keep compiler happy
|
||||
return cellShape(prism, labelList(0));
|
||||
return cellShape(prism, labelList());
|
||||
}
|
||||
|
||||
|
||||
|
@ -731,7 +731,7 @@ int main(int argc, char *argv[])
|
||||
labelsTet[2] = pointLookup[curCellLabels[3] ];
|
||||
labelsTet[3] = pointLookup[curCellLabels[1] ];
|
||||
|
||||
cells[celli] = cellShape(tet, labelsTet);
|
||||
cells[celli].reset(tet, labelsTet);
|
||||
}
|
||||
|
||||
// Square-based pyramid
|
||||
@ -743,7 +743,7 @@ int main(int argc, char *argv[])
|
||||
labelsPyramid[3] = pointLookup[curCellLabels[2] ];
|
||||
labelsPyramid[4] = pointLookup[curCellLabels[4] ];
|
||||
|
||||
cells[celli] = cellShape(pyr, labelsPyramid);
|
||||
cells[celli].reset(pyr, labelsPyramid);
|
||||
}
|
||||
|
||||
// Triangular prism
|
||||
@ -756,7 +756,7 @@ int main(int argc, char *argv[])
|
||||
labelsPrism[4] = pointLookup[curCellLabels[4] ];
|
||||
labelsPrism[5] = pointLookup[curCellLabels[5] ];
|
||||
|
||||
cells[celli] = cellShape(prism, labelsPrism);
|
||||
cells[celli].reset(prism, labelsPrism);
|
||||
}
|
||||
|
||||
// Hex
|
||||
@ -771,7 +771,7 @@ int main(int argc, char *argv[])
|
||||
labelsHex[6] = pointLookup[curCellLabels[7] ];
|
||||
labelsHex[7] = pointLookup[curCellLabels[6] ];
|
||||
|
||||
cells[celli] = cellShape(hex, labelsHex);
|
||||
cells[celli].reset(hex, labelsHex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -664,7 +664,7 @@ void readCellsLegacy
|
||||
|
||||
renumber(mshToFoam, tetPoints);
|
||||
|
||||
cells[celli++] = cellShape(tet, tetPoints);
|
||||
cells[celli++].reset(tet, tetPoints);
|
||||
|
||||
nTet++;
|
||||
}
|
||||
@ -685,7 +685,7 @@ void readCellsLegacy
|
||||
|
||||
renumber(mshToFoam, pyrPoints);
|
||||
|
||||
cells[celli++] = cellShape(pyr, pyrPoints);
|
||||
cells[celli++].reset(pyr, pyrPoints);
|
||||
|
||||
nPyr++;
|
||||
}
|
||||
@ -706,7 +706,7 @@ void readCellsLegacy
|
||||
|
||||
renumber(mshToFoam, prismPoints);
|
||||
|
||||
cells[celli] = cellShape(prism, prismPoints);
|
||||
cells[celli].reset(prism, prismPoints);
|
||||
|
||||
const cellShape& cell = cells[celli];
|
||||
|
||||
@ -721,7 +721,7 @@ void readCellsLegacy
|
||||
prismPoints[4] = cell[4];
|
||||
prismPoints[5] = cell[5];
|
||||
|
||||
cells[celli] = cellShape(prism, prismPoints);
|
||||
cells[celli].reset(prism, prismPoints);
|
||||
}
|
||||
|
||||
celli++;
|
||||
@ -747,7 +747,7 @@ void readCellsLegacy
|
||||
|
||||
renumber(mshToFoam, hexPoints);
|
||||
|
||||
cells[celli] = cellShape(hex, hexPoints);
|
||||
cells[celli].reset(hex, hexPoints);
|
||||
|
||||
const cellShape& cell = cells[celli];
|
||||
|
||||
@ -764,7 +764,7 @@ void readCellsLegacy
|
||||
hexPoints[6] = cell[2];
|
||||
hexPoints[7] = cell[3];
|
||||
|
||||
cells[celli] = cellShape(hex, hexPoints);
|
||||
cells[celli].reset(hex, hexPoints);
|
||||
}
|
||||
|
||||
celli++;
|
||||
@ -1019,7 +1019,7 @@ void readCells
|
||||
|
||||
renumber(mshToFoam, tetPoints);
|
||||
|
||||
cells[celli++] = cellShape(tet, tetPoints);
|
||||
cells[celli++].reset(tet, tetPoints);
|
||||
}
|
||||
}
|
||||
else if (elmType == MSHPYR)
|
||||
@ -1046,7 +1046,7 @@ void readCells
|
||||
|
||||
renumber(mshToFoam, pyrPoints);
|
||||
|
||||
cells[celli++] = cellShape(pyr, pyrPoints);
|
||||
cells[celli++].reset(pyr, pyrPoints);
|
||||
}
|
||||
}
|
||||
else if (elmType == MSHPRISM)
|
||||
@ -1073,7 +1073,7 @@ void readCells
|
||||
|
||||
renumber(mshToFoam, prismPoints);
|
||||
|
||||
cells[celli] = cellShape(prism, prismPoints);
|
||||
cells[celli].reset(prism, prismPoints);
|
||||
|
||||
const cellShape& cell = cells[celli];
|
||||
|
||||
@ -1088,7 +1088,7 @@ void readCells
|
||||
prismPoints[4] = cell[4];
|
||||
prismPoints[5] = cell[5];
|
||||
|
||||
cells[celli] = cellShape(prism, prismPoints);
|
||||
cells[celli].reset(prism, prismPoints);
|
||||
}
|
||||
|
||||
celli++;
|
||||
@ -1120,7 +1120,7 @@ void readCells
|
||||
|
||||
renumber(mshToFoam, hexPoints);
|
||||
|
||||
cells[celli] = cellShape(hex, hexPoints);
|
||||
cells[celli].reset(hex, hexPoints);
|
||||
|
||||
const cellShape& cell = cells[celli];
|
||||
|
||||
@ -1137,7 +1137,7 @@ void readCells
|
||||
hexPoints[6] = cell[2];
|
||||
hexPoints[7] = cell[3];
|
||||
|
||||
cells[celli] = cellShape(hex, hexPoints);
|
||||
cells[celli].reset(hex, hexPoints);
|
||||
}
|
||||
|
||||
celli++;
|
||||
|
@ -128,7 +128,7 @@ for (label i=0; i<nPoints; i++)
|
||||
hexLabels[6] = i3tab[i1tab[i8tab[i]]];
|
||||
hexLabels[7] = i3tab[i8tab[i]];
|
||||
|
||||
cellShapes[activeCells] = cellShape(hex, hexLabels);
|
||||
cellShapes[activeCells].reset(hex, hexLabels);
|
||||
|
||||
edgeList edges = cellShapes[activeCells].edges();
|
||||
|
||||
|
@ -108,7 +108,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
mshStream >> hexPoints[cp];
|
||||
}
|
||||
cells[celli] = cellShape(hex, hexPoints);
|
||||
cells[celli].reset(hex, hexPoints);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -119,7 +119,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
mshStream >> tetPoints[cp];
|
||||
}
|
||||
cells[celli] = cellShape(tet, tetPoints);
|
||||
cells[celli].reset(tet, tetPoints);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -154,7 +154,7 @@ int main(int argc, char *argv[])
|
||||
tetPoints[2] = readLabel(str) - 1;
|
||||
tetPoints[3] = readLabel(str) - 1;
|
||||
|
||||
cells[celli] = cellShape(tet, tetPoints);
|
||||
cells[celli].reset(tet, tetPoints);
|
||||
}
|
||||
|
||||
|
||||
|
@ -231,7 +231,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
// Do automatic collapse from hex.
|
||||
cellShapes[nCreatedCells] = cellShape(hex, cellPoints, true);
|
||||
cellShapes[nCreatedCells].reset(hex, cellPoints, true);
|
||||
|
||||
nCreatedCells++;
|
||||
}
|
||||
|
@ -309,7 +309,7 @@ int main(int argc, char *argv[])
|
||||
tetPoints[i] = nodeToPoint[nodeI];
|
||||
}
|
||||
|
||||
cells[celli++] = cellShape(tet, tetPoints);
|
||||
cells[celli++].reset(tet, tetPoints);
|
||||
|
||||
// Skip attributes
|
||||
for (label i = 0; i < nElemAttr; i++)
|
||||
|
@ -273,7 +273,7 @@ autoPtr<polyMesh> generateHexMesh
|
||||
hexPoints[5] = vtxLabel(nCells, i+1, j, k+1);
|
||||
hexPoints[6] = vtxLabel(nCells, i+1, j+1, k+1);
|
||||
hexPoints[7] = vtxLabel(nCells, i, j+1, k+1);
|
||||
cellShapes[celli++] = cellShape(hex, hexPoints);
|
||||
cellShapes[celli++].reset(hex, hexPoints);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,8 +34,7 @@ pointField points;
|
||||
cellShapes.setSize(bCells.size());
|
||||
forAll(cellShapes, celli)
|
||||
{
|
||||
cellShapes[celli] =
|
||||
cellShape(hex, labelList(bCells[celli]), false);
|
||||
cellShapes[celli].reset(hex, labelList(bCells[celli]), false);
|
||||
}
|
||||
|
||||
Info<< "Creating boundary faces" << endl;
|
||||
|
@ -334,8 +334,7 @@ bool Foam::hexMatcher::matches
|
||||
)
|
||||
)
|
||||
{
|
||||
shape = cellShape(model(), vertLabels());
|
||||
|
||||
shape.reset(model(), vertLabels());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -371,8 +371,7 @@ bool Foam::prismMatcher::matches
|
||||
)
|
||||
)
|
||||
{
|
||||
shape = cellShape(model(), vertLabels());
|
||||
|
||||
shape.reset(model(), vertLabels());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -329,8 +329,7 @@ bool Foam::pyrMatcher::matches
|
||||
)
|
||||
)
|
||||
{
|
||||
shape = cellShape(model(), vertLabels());
|
||||
|
||||
shape.reset(model(), vertLabels());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -274,8 +274,7 @@ bool Foam::tetMatcher::matches
|
||||
)
|
||||
)
|
||||
{
|
||||
shape = cellShape(model(), vertLabels());
|
||||
|
||||
shape.reset(model(), vertLabels());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -296,8 +296,7 @@ bool Foam::tetWedgeMatcher::matches
|
||||
)
|
||||
)
|
||||
{
|
||||
shape = cellShape(model(), vertLabels());
|
||||
|
||||
shape.reset(model(), vertLabels());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -396,8 +396,7 @@ bool Foam::wedgeMatcher::matches
|
||||
)
|
||||
)
|
||||
{
|
||||
shape = cellShape(model(), vertLabels());
|
||||
|
||||
shape.reset(model(), vertLabels());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -105,7 +105,7 @@ public:
|
||||
inline cellShape
|
||||
(
|
||||
const cellModel& model,
|
||||
labelUList&& labels,
|
||||
labelList&& labels,
|
||||
const bool doCollapse = false
|
||||
);
|
||||
|
||||
@ -173,18 +173,26 @@ public:
|
||||
//- Centroid of the cell
|
||||
inline point centre(const UList<point>& points) const;
|
||||
|
||||
//- Scalar magnitude
|
||||
inline scalar mag(const UList<point>& points) const;
|
||||
|
||||
//- Reset from components
|
||||
inline void reset
|
||||
(
|
||||
const cellModel& model,
|
||||
const labelUList& labels,
|
||||
const bool doCollapse = false
|
||||
);
|
||||
|
||||
//- Collapse shape to correct one after removing duplicate vertices
|
||||
void collapse();
|
||||
|
||||
//- Return info proxy, to print information to a stream
|
||||
Foam::InfoProxy<cellShape> info() const
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
//- Scalar magnitude
|
||||
inline scalar mag(const UList<point>& points) const;
|
||||
|
||||
//- Collapse shape to correct one after removing duplicate vertices
|
||||
void collapse();
|
||||
|
||||
|
||||
// Friend Operators
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
Copyright (C) 2020-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -78,7 +78,7 @@ inline Foam::cellShape::cellShape
|
||||
inline Foam::cellShape::cellShape
|
||||
(
|
||||
const cellModel& model,
|
||||
labelUList&& labels,
|
||||
labelList&& labels,
|
||||
const bool doCollapse
|
||||
)
|
||||
:
|
||||
@ -296,4 +296,21 @@ inline Foam::scalar Foam::cellShape::mag(const UList<point>& points) const
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::cellShape::reset
|
||||
(
|
||||
const cellModel& model,
|
||||
const labelUList& labels,
|
||||
const bool doCollapse
|
||||
)
|
||||
{
|
||||
static_cast<labelList&>(*this) = labels;
|
||||
m = &model;
|
||||
|
||||
if (doCollapse)
|
||||
{
|
||||
collapse();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
@ -6,7 +6,7 @@
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -130,8 +130,7 @@ void Foam::blockMesh::createCells() const
|
||||
}
|
||||
|
||||
// Construct collapsed cell and add to list
|
||||
cells_[celli] = cellShape(hex, cellPoints, true);
|
||||
|
||||
cells_[celli].reset(hex, cellPoints, true);
|
||||
++celli;
|
||||
}
|
||||
}
|
||||
|
@ -518,8 +518,7 @@ Foam::autoPtr<Foam::fvMesh> Foam::voxelMeshSearch::makeMesh
|
||||
cellShapes.setSize(bCells.size());
|
||||
forAll(cellShapes, celli)
|
||||
{
|
||||
cellShapes[celli] =
|
||||
cellShape(hex, labelList(bCells[celli]), false);
|
||||
cellShapes[celli].reset(hex, labelList(bCells[celli]), false);
|
||||
}
|
||||
|
||||
//Info<< "Creating boundary faces" << endl;
|
||||
|
Loading…
Reference in New Issue
Block a user