/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2022-2026 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see .
\*---------------------------------------------------------------------------*/
#include "cutPolyIsoSurface.H"
#include "cellEdgeAddressing.H"
#include "cutPolyValue.H"
#include "EdgeMap.H"
#include "cpuTime.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(cutPolyIsoSurface, 0);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::cutPolyIsoSurface::cutPolyIsoSurface
(
const polyMesh& mesh,
const scalarField& pAlphas,
const scalar isoAlpha,
const labelUList& cells
)
:
points_(),
pointEdges_(),
pointEdgeLambdas_(),
faces_(),
faceCells_()
{
cpuTime cpuTime;
// Cut the faces
List> faceCuts(mesh.faces().size());
forAll(mesh.faces(), facei)
{
faceCuts[facei] =
cutPoly::faceCuts
(
mesh.faces()[facei],
pAlphas,
isoAlpha
);
}
// Request the cell-edge addressing engine
const cellEdgeAddressingList& cAddrs = cellEdgeAddressingList::New(mesh);
// Cut the cells
List cellCuts(mesh.cells().size());
label nCutCells = 0;
auto cutCell = [&](const label celli)
{
cellCuts[celli] =
cutPoly::cellCuts
(
mesh.cells()[celli],
cAddrs[celli],
mesh.faces(),
faceCuts,
pAlphas,
isoAlpha
);
nCutCells += !cellCuts[celli].empty();
};
if (notNull(cells))
{
forAll(cells, i)
{
cutCell(cells[i]);
}
}
else
{
forAll(mesh.cells(), celli)
{
cutCell(celli);
}
}
// Generate the cell cut polygons
const label nAllocate = nCutCells + nCutCells/10;
EdgeMap