COMP: patchDist: renamed to patchPatchDist

This commit is contained in:
mattijs
2013-01-07 16:25:18 +00:00
parent 572d7551b9
commit 685e885d81
6 changed files with 189 additions and 48 deletions

View File

@ -41,7 +41,7 @@ $(pWave)/pointEdgePoint.C
patchWave = $(algorithms)/PatchEdgeFaceWave patchWave = $(algorithms)/PatchEdgeFaceWave
$(patchWave)/PatchEdgeFaceWaveName.C $(patchWave)/PatchEdgeFaceWaveName.C
$(patchWave)/patchEdgeFaceInfo.C $(patchWave)/patchEdgeFaceInfo.C
$(patchWave)/patchDist.C $(patchWave)/patchPatchDist.C
meshWave = $(algorithms)/MeshWave meshWave = $(algorithms)/MeshWave
$(meshWave)/MeshWaveName.C $(meshWave)/MeshWaveName.C

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -23,7 +23,7 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "patchDist.H" #include "patchPatchDist.H"
#include "PatchEdgeFaceWave.H" #include "PatchEdgeFaceWave.H"
#include "syncTools.H" #include "syncTools.H"
#include "polyMesh.H" #include "polyMesh.H"
@ -31,7 +31,7 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::patchDist::patchDist Foam::patchPatchDist::patchPatchDist
( (
const polyPatch& patch, const polyPatch& patch,
const labelHashSet& nbrPatchIDs const labelHashSet& nbrPatchIDs
@ -41,19 +41,19 @@ Foam::patchDist::patchDist
nbrPatchIDs_(nbrPatchIDs), nbrPatchIDs_(nbrPatchIDs),
nUnset_(0) nUnset_(0)
{ {
patchDist::correct(); patchPatchDist::correct();
} }
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::patchDist::~patchDist() Foam::patchPatchDist::~patchPatchDist()
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::patchDist::correct() void Foam::patchPatchDist::correct()
{ {
// Mark all edge connected to a nbrPatch. // Mark all edge connected to a nbrPatch.
label nBnd = 0; label nBnd = 0;

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -22,19 +22,19 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class Class
Foam::patchDist Foam::patchPatchDist
Description Description
Like wallDist but calculates on patch distance to nearest neighbouring Like wallDist but calculates on a patch the distance to nearest neighbouring
patches. Uses PatchEdgeFaceWave to do actual calculation. patches. Uses PatchEdgeFaceWave to do actual calculation.
SourceFiles SourceFiles
patchDist.C patchPatchDist.C
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef patchDist_H #ifndef patchPatchDist_H
#define patchDist_H #define patchPatchDist_H
#include "scalarField.H" #include "scalarField.H"
#include "HashSet.H" #include "HashSet.H"
@ -48,10 +48,10 @@ namespace Foam
class polyPatch; class polyPatch;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class patchDist Declaration Class patchPatchDist Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class patchDist class patchPatchDist
: :
public scalarField public scalarField
{ {
@ -75,7 +75,7 @@ public:
// Constructors // Constructors
//- Construct from patch and neighbour patches. //- Construct from patch and neighbour patches.
patchDist patchPatchDist
( (
const polyPatch& pp, const polyPatch& pp,
const labelHashSet& nbrPatchIDs const labelHashSet& nbrPatchIDs
@ -83,7 +83,7 @@ public:
//- Destructor //- Destructor
virtual ~patchDist(); virtual ~patchPatchDist();
// Member Functions // Member Functions

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -523,6 +523,75 @@ void Foam::PointEdgeWave<Type, TrackingData>::handleCyclicPatches()
} }
// Propagate information from edge to point. Return number of points changed.
template <class Type, class TrackingData>
Foam::label Foam::PointEdgeWave<Type, TrackingData>::handleCollocatedPoints()
{
// Transfer onto coupled patch
const globalMeshData& gmd = mesh_.globalData();
const indirectPrimitivePatch& cpp = gmd.coupledPatch();
const labelList& meshPoints = cpp.meshPoints();
const mapDistribute& slavesMap = gmd.globalPointSlavesMap();
const labelListList& slaves = gmd.globalPointSlaves();
List<Type> elems(slavesMap.constructSize());
forAll(meshPoints, pointI)
{
elems[pointI] = allPointInfo_[meshPoints[pointI]];
}
// Reset changed points counter.
nChangedPoints_ = 0;
// Pull slave data onto master. No need to update transformed slots.
slavesMap.distribute(elems, false);
// Combine master data with slave data
forAll(slaves, pointI)
{
Type& elem = elems[pointI];
const labelList& slavePoints = slaves[pointI];
label meshPointI = meshPoints[pointI];
// Combine master with untransformed slave data
forAll(slavePoints, j)
{
updatePoint
(
meshPointI,
elems[slavePoints[j]],
elem
);
}
// Copy result back to slave slots
forAll(slavePoints, j)
{
elems[slavePoints[j]] = elem;
}
}
// Push slave-slot data back to slaves
slavesMap.reverseDistribute(elems.size(), elems, false);
// Extract back onto mesh
forAll(meshPoints, pointI)
{
allPointInfo_[meshPoints[pointI]] = elems[pointI];
}
// Sum nChangedPoints over all procs
label totNChanged = nChangedPoints_;
reduce(totNChanged, sumOp<label>());
return totNChanged;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Iterate, propagating changedPointsInfo across mesh, until no change (or // Iterate, propagating changedPointsInfo across mesh, until no change (or
@ -863,44 +932,58 @@ Foam::label Foam::PointEdgeWave<Type, TrackingData>::iterate
while (iter < maxIter) while (iter < maxIter)
{ {
if (debug) while (iter < maxIter)
{ {
Pout<< "Iteration " << iter << endl; if (debug)
{
Pout<< "Iteration " << iter << endl;
}
label nEdges = pointToEdge();
if (debug)
{
Pout<< "Total changed edges : " << nEdges << endl;
}
if (nEdges == 0)
{
break;
}
label nPoints = edgeToPoint();
if (debug)
{
Pout<< "Total changed points : " << nPoints << nl
<< "Total evaluations : " << nEvals_ << nl
<< "Remaining unvisited points: " << nUnvisitedPoints_ << nl
<< "Remaining unvisited edges : " << nUnvisitedEdges_ << nl
<< endl;
}
if (nPoints == 0)
{
break;
}
iter++;
} }
label nEdges = pointToEdge();
// Enforce collocated points are exactly equal. This might still mean
// non-collocated points are not equal though. WIP.
label nPoints = handleCollocatedPoints();
if (debug) if (debug)
{ {
Pout<< "Total changed edges : " << nEdges << endl; Pout<< "Collocated point sync : " << nPoints << nl
} << endl;
if (nEdges == 0)
{
break;
}
label nPoints = edgeToPoint();
if (debug)
{
Pout<< "Total changed points : " << nPoints << endl;
Pout<< "Total evaluations : " << nEvals_ << endl;
Pout<< "Remaining unvisited points: " << nUnvisitedPoints_ << endl;
Pout<< "Remaining unvisited edges : " << nUnvisitedEdges_ << endl;
Pout<< endl;
} }
if (nPoints == 0) if (nPoints == 0)
{ {
break; break;
} }
iter++;
} }
return iter; return iter;

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -205,6 +205,9 @@ class PointEdgeWave
//- Merge data from across cyclic boundaries //- Merge data from across cyclic boundaries
void handleCyclicPatches(); void handleCyclicPatches();
//- Explicitly sync all collocated points
label handleCollocatedPoints();
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
PointEdgeWave(const PointEdgeWave&); PointEdgeWave(const PointEdgeWave&);

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -59,8 +59,63 @@ inline bool Foam::pointEdgePoint::update
if ((diff < SMALL) || ((distSqr_ > SMALL) && (diff/distSqr_ < tol))) if ((diff < SMALL) || ((distSqr_ > SMALL) && (diff/distSqr_ < tol)))
{ {
// don't propagate small changes // don't propagate small changes unless origins differ
return false; scalar originDiff2 = magSqr(origin_-w2.origin());
if
(
originDiff2 < SMALL
|| ((distSqr_ > SMALL) && (originDiff2/distSqr_ < tol))
)
{
return false;
}
else
{
// Different origin. Choose lexical ordering.
bool w2less = false;
for (direction cmp = 0; cmp < vector::nComponents; cmp++)
{
scalar d = w2.origin()[cmp]-origin_[cmp];
scalar magD = mag(d);
if
(
magD < SMALL
|| ((distSqr_ > SMALL) && (magD/distSqr_ > tol))
)
{
// Small difference. Test next component.
}
else if (d < 0)
{
w2less = true;
break;
}
else if (d > 0)
{
break;
}
}
if (w2less)
{
// update with new values
distSqr_ = dist2;
origin_ = w2.origin();
return true;
}
else
{
Pout<< "** same distance. at:" << pt << nl
<< " old distance:" << Foam::sqr(distSqr_) << nl
<< " new distance:" << Foam::sqr(dist2) << nl
<< " old origin:" << origin_ << nl
<< " new origin:" << w2.origin() << nl
<< endl;
Pout<< "** w2 looses." << endl;
return false;
}
}
} }
else else
{ {