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)/PatchEdgeFaceWaveName.C
$(patchWave)/patchEdgeFaceInfo.C
$(patchWave)/patchDist.C
$(patchWave)/patchPatchDist.C
meshWave = $(algorithms)/MeshWave
$(meshWave)/MeshWaveName.C

View File

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

View File

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

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
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 * * * * * * * * * * * * * * //
// Iterate, propagating changedPointsInfo across mesh, until no change (or
@ -861,6 +930,8 @@ Foam::label Foam::PointEdgeWave<Type, TrackingData>::iterate
label iter = 0;
while (iter < maxIter)
{
while (iter < maxIter)
{
if (debug)
@ -884,15 +955,11 @@ Foam::label Foam::PointEdgeWave<Type, TrackingData>::iterate
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;
Pout<< "Total changed points : " << nPoints << nl
<< "Total evaluations : " << nEvals_ << nl
<< "Remaining unvisited points: " << nUnvisitedPoints_ << nl
<< "Remaining unvisited edges : " << nUnvisitedEdges_ << nl
<< endl;
}
if (nPoints == 0)
@ -903,6 +970,22 @@ Foam::label Foam::PointEdgeWave<Type, TrackingData>::iterate
iter++;
}
// Enforce collocated points are exactly equal. This might still mean
// non-collocated points are not equal though. WIP.
label nPoints = handleCollocatedPoints();
if (debug)
{
Pout<< "Collocated point sync : " << nPoints << nl
<< endl;
}
if (nPoints == 0)
{
break;
}
}
return iter;
}

View File

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

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -59,10 +59,65 @@ inline bool Foam::pointEdgePoint::update
if ((diff < SMALL) || ((distSqr_ > SMALL) && (diff/distSqr_ < tol)))
{
// don't propagate small changes
// don't propagate small changes unless origins differ
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
{
// update with new values
distSqr_ = dist2;