/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-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 "PointEdgeWave.H"
#include "polyMesh.H"
#include "processorPolyPatch.H"
#include "cyclicPolyPatch.H"
#include "OPstream.H"
#include "IPstream.H"
#include "PstreamCombineReduceOps.H"
#include "debug.H"
#include "typeInfo.H"
#include "globalMeshData.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
template
Foam::scalar Foam::PointEdgeWave::propagationTol_ = 0.01;
template
int Foam::PointEdgeWave::defaultTrackingData_ = -1;
namespace Foam
{
//- Reduction class. If x and y are not equal assign value.
template
class combineEqOp
{
TrackingData& td_;
public:
combineEqOp(TrackingData& td)
:
td_(td)
{}
void operator()(Type& x, const Type& y) const
{
if (!x.valid(td_) && y.valid(td_))
{
x = y;
}
}
};
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template
void Foam::PointEdgeWave::transform
(
const polyPatch& patch,
const labelList& patchPointLabels,
const transformer& transform,
List& pointInfo
) const
{
forAll(pointInfo, i)
{
pointInfo[i].transform(patch, patchPointLabels[i], transform, td_);
}
}
template
bool Foam::PointEdgeWave::updatePoint
(
const label pointi,
const label neighbourEdgeI,
const Type& neighbourInfo,
Type& pointInfo
)
{
// Update info for pointi, at position pt, with information from
// neighbouring edge.
// Updates:
// - changedPoint_, changedPoints_, nChangedPoints_,
// - statistics: nEvals_, nUnvisitedPoints_
nEvals_++;
bool wasValid = pointInfo.valid(td_);
bool propagate =
pointInfo.updatePoint
(
mesh_,
pointi,
neighbourEdgeI,
neighbourInfo,
propagationTol_,
td_
);
if (propagate)
{
if (!changedPoint_[pointi])
{
changedPoint_[pointi] = true;
changedPoints_[nChangedPoints_++] = pointi;
}
}
if (!wasValid && pointInfo.valid(td_))
{
--nUnvisitedPoints_;
}
return propagate;
}
template
bool Foam::PointEdgeWave::updatePoint
(
const label pointi,
const Type& neighbourInfo,
Type& pointInfo
)
{
// Update info for pointi, at position pt, with information from
// same point.
// Updates:
// - changedPoint_, changedPoints_, nChangedPoints_,
// - statistics: nEvals_, nUnvisitedPoints_
nEvals_++;
bool wasValid = pointInfo.valid(td_);
bool propagate =
pointInfo.updatePoint
(
mesh_,
pointi,
neighbourInfo,
propagationTol_,
td_
);
if (propagate)
{
if (!changedPoint_[pointi])
{
changedPoint_[pointi] = true;
changedPoints_[nChangedPoints_++] = pointi;
}
}
if (!wasValid && pointInfo.valid(td_))
{
--nUnvisitedPoints_;
}
return propagate;
}
template
bool Foam::PointEdgeWave::updateEdge
(
const label edgeI,
const label neighbourPointi,
const Type& neighbourInfo,
Type& edgeInfo
)
{
// Update info for edgeI, at position pt, with information from
// neighbouring point.
// Updates:
// - changedEdge_, changedEdges_, nChangedEdges_,
// - statistics: nEvals_, nUnvisitedEdge_
nEvals_++;
bool wasValid = edgeInfo.valid(td_);
bool propagate =
edgeInfo.updateEdge
(
mesh_,
edgeI,
neighbourPointi,
neighbourInfo,
propagationTol_,
td_
);
if (propagate)
{
if (!changedEdge_[edgeI])
{
changedEdge_[edgeI] = true;
changedEdges_[nChangedEdges_++] = edgeI;
}
}
if (!wasValid && edgeInfo.valid(td_))
{
--nUnvisitedEdges_;
}
return propagate;
}
template
template
Foam::label Foam::PointEdgeWave::countPatchType() const
{
label nPatches = 0;
forAll(mesh_.boundary(), patchi)
{
if (isA(mesh_.boundary()[patchi]))
{
nPatches++;
}
}
return nPatches;
}
template
void Foam::PointEdgeWave::handleProcPatches()
{
// 1. Send all point info on processor patches.
PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking);
DynamicList patchInfo;
DynamicList