ENH: cellShape::reset() - simplifies modification of existing shapes

This commit is contained in:
Mark Olesen
2021-05-28 20:18:04 +02:00
parent 5ec49a3898
commit f2d634c49f
23 changed files with 85 additions and 71 deletions

View File

@ -334,8 +334,7 @@ bool Foam::hexMatcher::matches
)
)
{
shape = cellShape(model(), vertLabels());
shape.reset(model(), vertLabels());
return true;
}

View File

@ -371,8 +371,7 @@ bool Foam::prismMatcher::matches
)
)
{
shape = cellShape(model(), vertLabels());
shape.reset(model(), vertLabels());
return true;
}

View File

@ -329,8 +329,7 @@ bool Foam::pyrMatcher::matches
)
)
{
shape = cellShape(model(), vertLabels());
shape.reset(model(), vertLabels());
return true;
}

View File

@ -274,8 +274,7 @@ bool Foam::tetMatcher::matches
)
)
{
shape = cellShape(model(), vertLabels());
shape.reset(model(), vertLabels());
return true;
}

View File

@ -296,8 +296,7 @@ bool Foam::tetWedgeMatcher::matches
)
)
{
shape = cellShape(model(), vertLabels());
shape.reset(model(), vertLabels());
return true;
}

View File

@ -396,8 +396,7 @@ bool Foam::wedgeMatcher::matches
)
)
{
shape = cellShape(model(), vertLabels());
shape.reset(model(), vertLabels());
return true;
}

View File

@ -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

View File

@ -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();
}
}
// ************************************************************************* //

View File

@ -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;
}
}

View File

@ -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;