Merge branch 'master' of ssh://noisy/home/noisy3/OpenFOAM/OpenFOAM-dev

This commit is contained in:
Henry
2011-02-07 22:51:04 +00:00
14 changed files with 398 additions and 447 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2010-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -47,6 +47,8 @@ Description
int main(int argc, char *argv[])
{
argList::noParallel();
#include "setRootCase.H"
#include "createTime.H"
#include "createSingleCellMesh.H"

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -130,6 +130,7 @@ void testPackedList(const polyMesh& mesh, Random& rndGen)
{
FatalErrorIn("testPackedList()")
<< "point:" << i
<< " at:" << mesh.points()[i]
<< " minlabel:" << pointValues[i]
<< " minbits:" << bits.get(i)
<< " maxLabel:" << maxPointValues[i]
@ -186,6 +187,10 @@ void testSparseData(const polyMesh& mesh, Random& rndGen)
{
Info<< nl << "Testing Map synchronisation." << endl;
WarningIn("testSparseData()")
<< "Position test of sparse data only correct for cases without cyclics"
<< " with shared points." << endl;
primitivePatch allBoundary
(
SubList<face>
@ -204,7 +209,7 @@ void testSparseData(const polyMesh& mesh, Random& rndGen)
{
// Create some data. Use slightly perturbed positions.
Map<vector> sparseData;
Map<point> sparseData;
pointField fullData(mesh.nPoints(), point::max);
forAll(localPoints, i)
@ -223,14 +228,14 @@ void testSparseData(const polyMesh& mesh, Random& rndGen)
(
mesh,
sparseData,
minEqOp<vector>()
minMagSqrEqOp<point>()
// true // apply separation
);
syncTools::syncPointList
(
mesh,
fullData,
minEqOp<vector>(),
minMagSqrEqOp<point>(),
point::max
// true // apply separation
);
@ -257,7 +262,7 @@ void testSparseData(const polyMesh& mesh, Random& rndGen)
}
// 2. Does sparseData contain more?
forAllConstIter(Map<vector>, sparseData, iter)
forAllConstIter(Map<point>, sparseData, iter)
{
const point& sparsePt = iter();
label meshPointI = iter.key();
@ -374,16 +379,12 @@ void testPointSync(const polyMesh& mesh, Random& rndGen)
// Test position.
{
WarningIn("testPointSync()")
<< "Position test only correct for cases without cyclics"
<< " with shared points." << endl;
pointField syncedPoints(mesh.points());
syncTools::syncPointList
syncTools::syncPointPositions
(
mesh,
syncedPoints,
minEqOp<point>(),
minMagSqrEqOp<point>(),
point::max
);
@ -450,20 +451,16 @@ void testEdgeSync(const polyMesh& mesh, Random& rndGen)
// Test position.
{
WarningIn("testEdgeSync()")
<< "Position test only correct for cases without cyclics"
<< " with shared edges." << endl;
pointField syncedMids(edges.size());
forAll(syncedMids, edgeI)
{
syncedMids[edgeI] = edges[edgeI].centre(mesh.points());
}
syncTools::syncEdgeList
syncTools::syncEdgePositions
(
mesh,
syncedMids,
minEqOp<point>(),
minMagSqrEqOp<point>(),
point::max
);
@ -509,10 +506,11 @@ void testEdgeSync(const polyMesh& mesh, Random& rndGen)
{
if (nMasters[edgeI] != 1)
{
const edge& e = edges[edgeI];
//FatalErrorIn("testEdgeSync()")
WarningIn("testEdgeSync()")
<< "Edge " << edgeI
<< " midpoint " << edges[edgeI].centre(mesh.points())
<< " at:" << mesh.points()[e[0]] << mesh.points()[e[1]]
<< " has " << nMasters[edgeI]
<< " masters."
//<< exit(FatalError);
@ -532,11 +530,11 @@ void testFaceSync(const polyMesh& mesh, Random& rndGen)
{
pointField syncedFc(mesh.faceCentres());
syncTools::syncFaceList
syncTools::syncFacePositions
(
mesh,
syncedFc,
maxEqOp<point>()
maxMagSqrEqOp<point>()
);
forAll(syncedFc, faceI)

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -39,7 +39,8 @@ template<class Type>
void MapConsistentVolFields
(
const IOobjectList& objects,
const meshToMesh& meshToMeshInterp
const meshToMesh& meshToMeshInterp,
const meshToMesh::order& mapOrder
)
{
const fvMesh& meshSource = meshToMeshInterp.fromMesh();
@ -83,12 +84,7 @@ void MapConsistentVolFields
);
// Interpolate field
meshToMeshInterp.interpolate
(
fieldTarget,
fieldSource,
meshToMesh::INTERPOLATE
);
meshToMeshInterp.interpolate(fieldTarget, fieldSource, mapOrder);
// Write field
fieldTarget.write();
@ -101,11 +97,7 @@ void MapConsistentVolFields
GeometricField<Type, fvPatchField, volMesh> fieldTarget
(
fieldTargetIOobject,
meshToMeshInterp.interpolate
(
fieldSource,
meshToMesh::INTERPOLATE
)
meshToMeshInterp.interpolate(fieldSource, mapOrder)
);
// Write field

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -39,7 +39,8 @@ template<class Type>
void MapVolFields
(
const IOobjectList& objects,
const meshToMesh& meshToMeshInterp
const meshToMesh& meshToMeshInterp,
const meshToMesh::order& mapOrder
)
{
const fvMesh& meshSource = meshToMeshInterp.fromMesh();
@ -83,12 +84,7 @@ void MapVolFields
);
// Interpolate field
meshToMeshInterp.interpolate
(
fieldTarget,
fieldSource,
meshToMesh::INTERPOLATE
);
meshToMeshInterp.interpolate(fieldTarget, fieldSource, mapOrder);
// Write field
fieldTarget.write();

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -45,7 +45,8 @@ Description
void mapConsistentMesh
(
const fvMesh& meshSource,
const fvMesh& meshTarget
const fvMesh& meshTarget,
const meshToMesh::order& mapOrder
)
{
// Create the interpolation scheme
@ -61,11 +62,16 @@ void mapConsistentMesh
// Map volFields
// ~~~~~~~~~~~~~
MapConsistentVolFields<scalar>(objects, meshToMeshInterp);
MapConsistentVolFields<vector>(objects, meshToMeshInterp);
MapConsistentVolFields<sphericalTensor>(objects, meshToMeshInterp);
MapConsistentVolFields<symmTensor>(objects, meshToMeshInterp);
MapConsistentVolFields<tensor>(objects, meshToMeshInterp);
MapConsistentVolFields<scalar>(objects, meshToMeshInterp, mapOrder);
MapConsistentVolFields<vector>(objects, meshToMeshInterp, mapOrder);
MapConsistentVolFields<sphericalTensor>
(
objects,
meshToMeshInterp,
mapOrder
);
MapConsistentVolFields<symmTensor>(objects, meshToMeshInterp, mapOrder);
MapConsistentVolFields<tensor>(objects, meshToMeshInterp, mapOrder);
}
{
@ -98,7 +104,8 @@ void mapSubMesh
const fvMesh& meshSource,
const fvMesh& meshTarget,
const HashTable<word>& patchMap,
const wordList& cuttingPatches
const wordList& cuttingPatches,
const meshToMesh::order& mapOrder
)
{
// Create the interpolation scheme
@ -120,11 +127,11 @@ void mapSubMesh
// Map volFields
// ~~~~~~~~~~~~~
MapVolFields<scalar>(objects, meshToMeshInterp);
MapVolFields<vector>(objects, meshToMeshInterp);
MapVolFields<sphericalTensor>(objects, meshToMeshInterp);
MapVolFields<symmTensor>(objects, meshToMeshInterp);
MapVolFields<tensor>(objects, meshToMeshInterp);
MapVolFields<scalar>(objects, meshToMeshInterp, mapOrder);
MapVolFields<vector>(objects, meshToMeshInterp, mapOrder);
MapVolFields<sphericalTensor>(objects, meshToMeshInterp, mapOrder);
MapVolFields<symmTensor>(objects, meshToMeshInterp, mapOrder);
MapVolFields<tensor>(objects, meshToMeshInterp, mapOrder);
}
{
@ -155,7 +162,8 @@ void mapSubMesh
void mapConsistentSubMesh
(
const fvMesh& meshSource,
const fvMesh& meshTarget
const fvMesh& meshTarget,
const meshToMesh::order& mapOrder
)
{
HashTable<word> patchMap;
@ -181,7 +189,14 @@ void mapConsistentSubMesh
}
}
mapSubMesh(meshSource, meshTarget, patchMap, cuttingPatchTable.toc());
mapSubMesh
(
meshSource,
meshTarget,
patchMap,
cuttingPatchTable.toc(),
mapOrder
);
}
@ -240,6 +255,18 @@ int main(int argc, char *argv[])
"scalar",
"specify the source time"
);
argList::addOption
(
"sourceRegion",
"word",
"specify the source region"
);
argList::addOption
(
"targetRegion",
"word",
"specify the target region"
);
argList::addBoolOption
(
"parallelSource",
@ -255,12 +282,18 @@ int main(int argc, char *argv[])
"consistent",
"source and target geometry and boundary conditions identical"
);
argList::addOption
(
"mapMethod",
"word",
"specify the mapping method"
);
argList args(argc, argv);
if (!args.check())
{
FatalError.exit();
FatalError.exit();
}
fileName rootDirTarget(args.rootPath());
@ -270,12 +303,52 @@ int main(int argc, char *argv[])
const fileName rootDirSource = casePath.path();
const fileName caseDirSource = casePath.name();
Info<< "Source: " << rootDirSource << " " << caseDirSource << nl
<< "Target: " << rootDirTarget << " " << caseDirTarget << endl;
Info<< "Source: " << rootDirSource << " " << caseDirSource << endl;
word sourceRegion = fvMesh::defaultRegion;
if (args.optionFound("sourceRegion"))
{
sourceRegion = args["sourceRegion"];
Info<< "Source region: " << sourceRegion << endl;
}
Info<< "Target: " << rootDirTarget << " " << caseDirTarget << endl;
word targetRegion = fvMesh::defaultRegion;
if (args.optionFound("targetRegion"))
{
targetRegion = args["targetRegion"];
Info<< "Target region: " << targetRegion << endl;
}
const bool parallelSource = args.optionFound("parallelSource");
const bool parallelTarget = args.optionFound("parallelTarget");
const bool consistent = args.optionFound("consistent");
const bool consistent = args.optionFound("consistent");
meshToMesh::order mapOrder = meshToMesh::INTERPOLATE;
if (args.optionFound("mapMethod"))
{
const word mapMethod(args["mapMethod"]);
if (mapMethod == "mapNearest")
{
mapOrder = meshToMesh::MAP;
}
else if (mapMethod == "interpolate")
{
mapOrder = meshToMesh::INTERPOLATE;
}
else if (mapMethod == "cellPointInterpolate")
{
mapOrder = meshToMesh::CELL_POINT_INTERPOLATE;
}
else
{
FatalErrorIn(args.executable())
<< "Unknown mapMethod " << mapMethod << ". Valid options are: "
<< "mapNearest, interpolate and cellPointInterpolate"
<< exit(FatalError);
}
Info<< "Mapping method: " << mapMethod << endl;
}
#include "createTimes.H"
@ -323,7 +396,7 @@ int main(int argc, char *argv[])
(
IOobject
(
fvMesh::defaultRegion,
targetRegion,
runTimeTarget.timeName(),
runTimeTarget
)
@ -348,7 +421,7 @@ int main(int argc, char *argv[])
(
IOobject
(
fvMesh::defaultRegion,
sourceRegion,
runTimeSource.timeName(),
runTimeSource
)
@ -358,11 +431,18 @@ int main(int argc, char *argv[])
if (consistent)
{
mapConsistentSubMesh(meshSource, meshTarget);
mapConsistentSubMesh(meshSource, meshTarget, mapOrder);
}
else
{
mapSubMesh(meshSource, meshTarget, patchMap, cuttingPatches);
mapSubMesh
(
meshSource,
meshTarget,
patchMap,
cuttingPatches,
mapOrder
);
}
}
}
@ -390,7 +470,7 @@ int main(int argc, char *argv[])
(
IOobject
(
fvMesh::defaultRegion,
sourceRegion,
runTimeSource.timeName(),
runTimeSource
)
@ -413,7 +493,7 @@ int main(int argc, char *argv[])
(
IOobject
(
fvMesh::defaultRegion,
targetRegion,
runTimeTarget.timeName(),
runTimeTarget
)
@ -423,7 +503,7 @@ int main(int argc, char *argv[])
if (consistent)
{
mapConsistentSubMesh(meshSource, meshTarget);
mapConsistentSubMesh(meshSource, meshTarget, mapOrder);
}
else
{
@ -432,7 +512,8 @@ int main(int argc, char *argv[])
meshSource,
meshTarget,
patchMap,
addProcessorPatches(meshTarget, cuttingPatches)
addProcessorPatches(meshTarget, cuttingPatches),
mapOrder
);
}
}
@ -494,7 +575,7 @@ int main(int argc, char *argv[])
(
IOobject
(
fvMesh::defaultRegion,
sourceRegion,
runTimeSource.timeName(),
runTimeSource
)
@ -529,7 +610,7 @@ int main(int argc, char *argv[])
(
IOobject
(
fvMesh::defaultRegion,
targetRegion,
runTimeTarget.timeName(),
runTimeTarget
)
@ -544,7 +625,12 @@ int main(int argc, char *argv[])
{
if (consistent)
{
mapConsistentSubMesh(meshSource, meshTarget);
mapConsistentSubMesh
(
meshSource,
meshTarget,
mapOrder
);
}
else
{
@ -553,7 +639,8 @@ int main(int argc, char *argv[])
meshSource,
meshTarget,
patchMap,
addProcessorPatches(meshTarget, cuttingPatches)
addProcessorPatches(meshTarget, cuttingPatches),
mapOrder
);
}
}
@ -571,7 +658,7 @@ int main(int argc, char *argv[])
(
IOobject
(
fvMesh::defaultRegion,
sourceRegion,
runTimeSource.timeName(),
runTimeSource
)
@ -581,7 +668,7 @@ int main(int argc, char *argv[])
(
IOobject
(
fvMesh::defaultRegion,
targetRegion,
runTimeTarget.timeName(),
runTimeTarget
)
@ -592,11 +679,18 @@ int main(int argc, char *argv[])
if (consistent)
{
mapConsistentMesh(meshSource, meshTarget);
mapConsistentMesh(meshSource, meshTarget, mapOrder);
}
else
{
mapSubMesh(meshSource, meshTarget, patchMap, cuttingPatches);
mapSubMesh
(
meshSource,
meshTarget,
patchMap,
cuttingPatches,
mapOrder
);
}
}

View File

@ -149,7 +149,7 @@ pyr
(0 1)
(1 2)
(2 3)
(3 4)
(0 3)
(0 4)
(1 4)
(2 4)

View File

@ -841,7 +841,7 @@ Foam::label Foam::globalMeshData::findTransform
<< abort(FatalError);
}
return globalIndexAndTransform::subtractTransformIndex
return globalTransforms().subtractTransformIndex
(
remoteTransformI,
localTransformI
@ -859,7 +859,6 @@ void Foam::globalMeshData::calcGlobalEdgeSlaves() const
const edgeList& edges = coupledPatch().edges();
const globalIndex& globalEdgeNumbers = globalEdgeNumbering();
const pointField& localPoints = coupledPatch().localPoints();
// The whole problem with deducting edge-connectivity from
@ -920,7 +919,11 @@ void Foam::globalMeshData::calcGlobalEdgeSlaves() const
{
forAll(pEdges1, j)
{
if (pEdges0[i] == pEdges1[j] && pEdges0[i] != edgeI)
if
(
pEdges0[i] == pEdges1[j]
&& pEdges0[i] != globalEdgeNumbers.toGlobal(edgeI)
)
{
// Found a shared edge. Now check if the endpoints
// go through the same transformation.

View File

@ -470,6 +470,17 @@ public:
const bool isPosition
);
//- Helper: synchronise data without transforms
template<class Type, class CombineOp>
static void syncData
(
List<Type>& pointData,
const labelListList& slaves,
const labelListList& transformedSlaves,
const mapDistribute& slavesMap,
const CombineOp& cop
);
// Coupled point to coupled points. Coupled points are
// points on any coupled patch.

View File

@ -90,6 +90,59 @@ void Foam::globalMeshData::syncData
}
template<class Type, class CombineOp>
void Foam::globalMeshData::syncData
(
List<Type>& elems,
const labelListList& slaves,
const labelListList& transformedSlaves,
const mapDistribute& slavesMap,
const CombineOp& cop
)
{
// Pull slave data onto master
slavesMap.distribute(elems);
// Combine master data with slave data
forAll(slaves, i)
{
Type& elem = elems[i];
const labelList& slavePoints = slaves[i];
const labelList& transformSlavePoints = transformedSlaves[i];
if (slavePoints.size()+transformSlavePoints.size() > 0)
{
// Combine master with untransformed slave data
forAll(slavePoints, j)
{
cop(elem, elems[slavePoints[j]]);
}
// Combine master with transformed slave data
forAll(transformSlavePoints, j)
{
cop(elem, elems[transformSlavePoints[j]]);
}
// Copy result back to slave slots
forAll(slavePoints, j)
{
elems[slavePoints[j]] = elem;
}
forAll(transformSlavePoints, j)
{
elems[transformSlavePoints[j]] = elem;
}
}
}
// Push slave-slot data back to slaves
slavesMap.reverseDistribute(elems.size(), elems);
}
template<class Type, class CombineOp>
void Foam::globalMeshData::syncPointData
(

View File

@ -125,7 +125,7 @@ bool Foam::globalPoints::mergeInfo
const labelPairList& nbrInfo,
const label localPointI,
labelPairList& myInfo
)
) const
{
bool anyChanged = false;
@ -167,7 +167,7 @@ bool Foam::globalPoints::mergeInfo
);
// Combine mine and nbr transform
label t = globalIndexAndTransform::mergeTransformIndex
label t = globalTransforms_.mergeTransformIndex
(
nbrTransform,
myTransform
@ -315,27 +315,6 @@ bool Foam::globalPoints::storeInitialInfo
}
Foam::FixedList<Foam::label, 3> Foam::globalPoints::transformBits
(
const label transformIndex
) const
{
label t = transformIndex;
// Decode permutation as 3 integers
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Note: FixedList for speed reasons.
FixedList<label, 3> permutation;
permutation[0] = (t%3)-1;
t /= 3;
permutation[1] = (t%3)-1;
t /= 3;
permutation[2] = (t%3)-1;
return permutation;
}
void Foam::globalPoints::printProcPoints
(
const labelList& patchToMeshPoint,
@ -352,7 +331,8 @@ void Foam::globalPoints::printProcPoints
Pout<< " localpoint:";
Pout<< index;
Pout<< " through transform:"
<< trafoI << " bits:" << transformBits(trafoI);
<< trafoI << " bits:"
<< globalTransforms_.decodeTransformIndex(trafoI);
if (procI == Pstream::myProcNo())
{

View File

@ -162,12 +162,12 @@ class globalPoints
) const;
//- Merge info from neighbour into my data
static bool mergeInfo
bool mergeInfo
(
const labelPairList& nbrInfo,
const label localPointI,
labelPairList& myInfo
);
) const;
//- From mesh point to 'local point'. Is the mesh point itself
// if meshToPatchPoint is empty.
@ -198,9 +198,7 @@ class globalPoints
const label localPointI
);
//- Get the signs for the individual transforms
FixedList<label, 3> transformBits(const label transformIndex) const;
//- Debug printing
void printProcPoints
(
const labelList& patchToMeshPoint,

View File

@ -91,6 +91,43 @@ void Foam::syncTools::syncPointMap
{
const polyBoundaryMesh& patches = mesh.boundaryMesh();
// Synchronize multiple shared points.
const globalMeshData& pd = mesh.globalData();
// Values on shared points. Keyed on global shared index.
Map<T> sharedPointValues(0);
if (pd.nGlobalPoints() > 0)
{
// meshPoint per local index
const labelList& sharedPtLabels = pd.sharedPointLabels();
// global shared index per local index
const labelList& sharedPtAddr = pd.sharedPointAddr();
sharedPointValues.resize(sharedPtAddr.size());
// Fill my entries in the shared points
forAll(sharedPtLabels, i)
{
label meshPointI = sharedPtLabels[i];
typename Map<T>::const_iterator fnd =
pointValues.find(meshPointI);
if (fnd != pointValues.end())
{
combine
(
sharedPointValues,
cop,
sharedPtAddr[i], // index
fnd() // value
);
}
}
}
if (Pstream::parRun())
{
PstreamBuffers pBufs(Pstream::nonBlocking);
@ -254,8 +291,6 @@ void Foam::syncTools::syncPointMap
}
// Synchronize multiple shared points.
const globalMeshData& pd = mesh.globalData();
if (pd.nGlobalPoints() > 0)
{
// meshPoint per local index
@ -263,30 +298,6 @@ void Foam::syncTools::syncPointMap
// global shared index per local index
const labelList& sharedPtAddr = pd.sharedPointAddr();
// Values on shared points. Keyed on global shared index.
Map<T> sharedPointValues(sharedPtAddr.size());
// Fill my entries in the shared points
forAll(sharedPtLabels, i)
{
label meshPointI = sharedPtLabels[i];
typename Map<T>::const_iterator fnd =
pointValues.find(meshPointI);
if (fnd != pointValues.end())
{
combine
(
sharedPointValues,
cop,
sharedPtAddr[i], // index
fnd() // value
);
}
}
// Reduce on master.
if (Pstream::parRun())
@ -367,13 +378,7 @@ void Foam::syncTools::syncPointMap
if (sharedFnd != sharedPointValues.end())
{
combine
(
pointValues,
cop,
iter(), // index
sharedFnd() // value
);
pointValues.set(iter(), sharedFnd());
}
}
}
@ -779,6 +784,23 @@ void Foam::syncTools::syncEdgeMap
//
// const polyBoundaryMesh& patches = mesh.boundaryMesh();
//
// // Synchronize multiple shared points.
// const globalMeshData& pd = mesh.globalData();
//
// // Values on shared points.
// Field<T> sharedPts(0);
// if (pd.nGlobalPoints() > 0)
// {
// // Values on shared points.
// sharedPts.setSize(pd.nGlobalPoints(), nullValue);
//
// forAll(pd.sharedPointLabels(), i)
// {
// label meshPointI = pd.sharedPointLabels()[i];
// // Fill my entries in the shared points
// sharedPts[pd.sharedPointAddr()[i]] = pointValues[meshPointI];
// }
// }
//
// if (Pstream::parRun())
// {
@ -899,16 +921,6 @@ void Foam::syncTools::syncEdgeMap
//
// if (pd.nGlobalPoints() > 0)
// {
// // Values on shared points.
// Field<T> sharedPts(pd.nGlobalPoints(), nullValue);
//
// forAll(pd.sharedPointLabels(), i)
// {
// label meshPointI = pd.sharedPointLabels()[i];
// // Fill my entries in the shared points
// sharedPts[pd.sharedPointAddr()[i]] = pointValues[meshPointI];
// }
//
// // Combine on master.
// Pstream::listCombineGather(sharedPts, cop);
// Pstream::listCombineScatter(sharedPts);
@ -1208,6 +1220,8 @@ void Foam::syncTools::syncEdgePositions
const globalMeshData& gd = mesh.globalData();
const labelList& meshEdges = gd.coupledPatchMeshEdges();
const globalIndexAndTransform& git = gd.globalTransforms();
const mapDistribute& map = gd.globalEdgeSlavesMap();
List<point> cppFld(UIndirectList<point>(edgeValues, meshEdges));
@ -1216,8 +1230,8 @@ void Foam::syncTools::syncEdgePositions
cppFld,
gd.globalEdgeSlaves(),
gd.globalEdgeTransformedSlaves(),
gd.globalEdgeSlavesMap(),
gd.globalTransforms(),
map,
git,
cop,
true //position?
);
@ -1505,140 +1519,28 @@ void Foam::syncTools::syncPointList
<< mesh.nPoints() << abort(FatalError);
}
const polyBoundaryMesh& patches = mesh.boundaryMesh();
const globalMeshData& gd = mesh.globalData();
const labelList& meshPoints = gd.coupledPatch().meshPoints();
if (Pstream::parRun())
List<unsigned int> cppFld(gd.globalPointSlavesMap().constructSize());
forAll(meshPoints, i)
{
PstreamBuffers pBufs(Pstream::nonBlocking);
// Send
forAll(patches, patchI)
{
if
(
isA<processorPolyPatch>(patches[patchI])
&& patches[patchI].nPoints() > 0
)
{
const processorPolyPatch& procPatch =
refCast<const processorPolyPatch>(patches[patchI]);
List<unsigned int> patchInfo(procPatch.nPoints());
const labelList& meshPts = procPatch.meshPoints();
const labelList& nbrPts = procPatch.neighbPoints();
forAll(nbrPts, pointI)
{
label nbrPointI = nbrPts[pointI];
patchInfo[nbrPointI] = pointValues[meshPts[pointI]];
}
UOPstream toNbr(procPatch.neighbProcNo(), pBufs);
toNbr << patchInfo;
}
}
pBufs.finishedSends();
// Receive and combine.
forAll(patches, patchI)
{
if
(
isA<processorPolyPatch>(patches[patchI])
&& patches[patchI].nPoints() > 0
)
{
const processorPolyPatch& procPatch =
refCast<const processorPolyPatch>(patches[patchI]);
List<unsigned int> nbrPatchInfo(procPatch.nPoints());
{
// We do not know the number of points on the other side
// so cannot use Pstream::read.
UIPstream fromNbr(procPatch.neighbProcNo(), pBufs);
fromNbr >> nbrPatchInfo;
}
const labelList& meshPts = procPatch.meshPoints();
forAll(meshPts, pointI)
{
label meshPointI = meshPts[pointI];
unsigned int pointVal = pointValues[meshPointI];
cop(pointVal, nbrPatchInfo[pointI]);
pointValues[meshPointI] = pointVal;
}
}
}
cppFld[i] = pointValues[meshPoints[i]];
}
// Do the cyclics.
forAll(patches, patchI)
globalMeshData::syncData
(
cppFld,
gd.globalPointSlaves(),
gd.globalPointTransformedSlaves(),
gd.globalPointSlavesMap(),
cop
);
// Extract back to mesh
forAll(meshPoints, i)
{
if (isA<cyclicPolyPatch>(patches[patchI]))
{
const cyclicPolyPatch& cycPatch =
refCast<const cyclicPolyPatch>(patches[patchI]);
if (cycPatch.owner())
{
// Owner does all.
const edgeList& coupledPoints = cycPatch.coupledPoints();
const labelList& meshPts = cycPatch.meshPoints();
const cyclicPolyPatch& nbrPatch = cycPatch.neighbPatch();
const labelList& nbrMeshPts = nbrPatch.meshPoints();
forAll(coupledPoints, i)
{
const edge& e = coupledPoints[i];
label meshPoint0 = meshPts[e[0]];
label meshPoint1 = nbrMeshPts[e[1]];
unsigned int val0 = pointValues[meshPoint0];
unsigned int val1 = pointValues[meshPoint1];
unsigned int t = val0;
cop(val0, val1);
pointValues[meshPoint0] = val0;
cop(val1, t);
pointValues[meshPoint1] = val1;
}
}
}
}
// Synchronize multiple shared points.
const globalMeshData& pd = mesh.globalData();
if (pd.nGlobalPoints() > 0)
{
// Values on shared points. Use unpacked storage for ease!
List<unsigned int> sharedPts(pd.nGlobalPoints(), nullValue);
forAll(pd.sharedPointLabels(), i)
{
label meshPointI = pd.sharedPointLabels()[i];
// Fill my entries in the shared points
sharedPts[pd.sharedPointAddr()[i]] = pointValues[meshPointI];
}
// Combine on master.
Pstream::listCombineGather(sharedPts, cop);
Pstream::listCombineScatter(sharedPts);
// Now we will all have the same information. Merge it back with
// my local information.
forAll(pd.sharedPointLabels(), i)
{
label meshPointI = pd.sharedPointLabels()[i];
pointValues[meshPointI] = sharedPts[pd.sharedPointAddr()[i]];
}
pointValues[meshPoints[i]] = cppFld[i];
}
}
@ -1664,140 +1566,28 @@ void Foam::syncTools::syncEdgeList
<< mesh.nEdges() << abort(FatalError);
}
const polyBoundaryMesh& patches = mesh.boundaryMesh();
const globalMeshData& gd = mesh.globalData();
const labelList& meshEdges = gd.coupledPatchMeshEdges();
if (Pstream::parRun())
List<unsigned int> cppFld(gd.globalEdgeSlavesMap().constructSize());
forAll(meshEdges, i)
{
PstreamBuffers pBufs(Pstream::nonBlocking);
// Send
forAll(patches, patchI)
{
if
(
isA<processorPolyPatch>(patches[patchI])
&& patches[patchI].nEdges() > 0
)
{
const processorPolyPatch& procPatch =
refCast<const processorPolyPatch>(patches[patchI]);
List<unsigned int> patchInfo(procPatch.nEdges());
const labelList& meshEdges = procPatch.meshEdges();
const labelList& neighbEdges = procPatch.neighbEdges();
forAll(neighbEdges, edgeI)
{
label nbrEdgeI = neighbEdges[edgeI];
patchInfo[nbrEdgeI] = edgeValues[meshEdges[edgeI]];
}
UOPstream toNbr(procPatch.neighbProcNo(), pBufs);
toNbr << patchInfo;
}
}
pBufs.finishedSends();
// Receive and combine.
forAll(patches, patchI)
{
if
(
isA<processorPolyPatch>(patches[patchI])
&& patches[patchI].nEdges() > 0
)
{
const processorPolyPatch& procPatch =
refCast<const processorPolyPatch>(patches[patchI]);
// Receive from neighbour.
List<unsigned int> nbrPatchInfo(procPatch.nEdges());
{
UIPstream fromNeighb(procPatch.neighbProcNo(), pBufs);
fromNeighb >> nbrPatchInfo;
}
const labelList& meshEdges = procPatch.meshEdges();
forAll(meshEdges, edgeI)
{
unsigned int patchVal = nbrPatchInfo[edgeI];
label meshEdgeI = meshEdges[edgeI];
unsigned int edgeVal = edgeValues[meshEdgeI];
cop(edgeVal, patchVal);
edgeValues[meshEdgeI] = edgeVal;
}
}
}
cppFld[i] = edgeValues[meshEdges[i]];
}
// Do the cyclics.
forAll(patches, patchI)
globalMeshData::syncData
(
cppFld,
gd.globalEdgeSlaves(),
gd.globalEdgeTransformedSlaves(),
gd.globalEdgeSlavesMap(),
cop
);
// Extract back to mesh
forAll(meshEdges, i)
{
if (isA<cyclicPolyPatch>(patches[patchI]))
{
const cyclicPolyPatch& cycPatch =
refCast<const cyclicPolyPatch>(patches[patchI]);
if (cycPatch.owner())
{
// Owner does all.
const edgeList& coupledEdges = cycPatch.coupledEdges();
const labelList& meshEdges = cycPatch.meshEdges();
const cyclicPolyPatch& nbrPatch = cycPatch.neighbPatch();
const labelList& nbrMeshEdges = nbrPatch.meshEdges();
forAll(coupledEdges, i)
{
const edge& e = coupledEdges[i];
label edge0 = meshEdges[e[0]];
label edge1 = nbrMeshEdges[e[1]];
unsigned int val0 = edgeValues[edge0];
unsigned int t = val0;
unsigned int val1 = edgeValues[edge1];
cop(t, val1);
edgeValues[edge0] = t;
cop(val1, val0);
edgeValues[edge1] = val1;
}
}
}
}
// Synchronize multiple shared edges.
const globalMeshData& pd = mesh.globalData();
if (pd.nGlobalEdges() > 0)
{
// Values on shared edges. Use unpacked storage for ease!
List<unsigned int> sharedPts(pd.nGlobalEdges(), nullValue);
forAll(pd.sharedEdgeLabels(), i)
{
label meshEdgeI = pd.sharedEdgeLabels()[i];
// Fill my entries in the shared edges
sharedPts[pd.sharedEdgeAddr()[i]] = edgeValues[meshEdgeI];
}
// Combine on master.
Pstream::listCombineGather(sharedPts, cop);
Pstream::listCombineScatter(sharedPts);
// Now we will all have the same information. Merge it back with
// my local information.
forAll(pd.sharedEdgeLabels(), i)
{
label meshEdgeI = pd.sharedEdgeLabels()[i];
edgeValues[meshEdgeI] = sharedPts[pd.sharedEdgeAddr()[i]];
}
edgeValues[meshEdges[i]] = cppFld[i];
}
}

View File

@ -138,11 +138,17 @@ private:
bool checkBothSigns
) const;
//- Encode transform index. Hardcoded to 3 independent transforms max.
inline label encodeTransformIndex
(
const FixedList<Foam::label, 3>& permutationIndices
) const;
//- Decode transform index. Hardcoded to 3 independent transforms max.
inline static FixedList<label, 3> decodeTransformIndex
inline FixedList<label, 3> decodeTransformIndex
(
const label transformIndex
);
) const;
//- Disallow default bitwise copy construct
globalIndexAndTransform(const globalIndexAndTransform&);
@ -153,6 +159,10 @@ private:
public:
//- Declare friendship with the entry class for IO
friend class globalPoints;
// Constructors
//- Construct from components
@ -184,25 +194,25 @@ public:
) const;
//- Combine two transformIndices
static inline label mergeTransformIndex
inline label mergeTransformIndex
(
const label transformIndex0,
const label transformIndex1
);
) const;
//- Combine two transformIndices
static inline label minimumTransformIndex
inline label minimumTransformIndex
(
const label transformIndex0,
const label transformIndex1
);
) const;
//- Subtract two transformIndices
static inline label subtractTransformIndex
inline label subtractTransformIndex
(
const label transformIndex0,
const label transformIndex1
);
) const;
//- Encode index and bare index as components on own processor
inline static labelPair encode

View File

@ -118,20 +118,56 @@ Foam::label Foam::globalIndexAndTransform::encodeTransformIndex
}
Foam::label Foam::globalIndexAndTransform::encodeTransformIndex
(
const FixedList<Foam::label, 3>& permutation
) const
{
if (nIndependentTransforms() == 0)
{
return 0;
}
if (nIndependentTransforms() == 1)
{
return permutation[0]+1;
}
else if (nIndependentTransforms() == 2)
{
return (permutation[1]+1)*3 + (permutation[0]+1);
}
else
{
return
(permutation[2]+1)*9
+ (permutation[1]+1)*3
+ (permutation[0]+1);
}
}
Foam::FixedList<Foam::label, 3>
Foam::globalIndexAndTransform::decodeTransformIndex
(
const label transformIndex
)
) const
{
FixedList<label, 3> permutation;
FixedList<label, 3> permutation(0);
label t = transformIndex;
permutation[0] = (t%3)-1;
t /= 3;
permutation[1] = (t%3)-1;
t /= 3;
permutation[2] = (t%3)-1;
if (nIndependentTransforms() > 0)
{
permutation[0] = (t%3)-1;
if (nIndependentTransforms() > 1)
{
t /= 3;
permutation[1] = (t%3)-1;
if (nIndependentTransforms() > 2)
{
t /= 3;
permutation[2] = (t%3)-1;
}
}
}
# ifdef FULLDEBUG
t /= 3;
@ -222,10 +258,7 @@ Foam::label Foam::globalIndexAndTransform::addToTransformIndex
// Re-encode permutation
// ~~~~~~~~~~~~~~~~~~~~~
return
(permutation[2]+1)*9
+ (permutation[1]+1)*3
+ (permutation[0]+1);
return encodeTransformIndex(permutation);
}
else
{
@ -238,7 +271,7 @@ Foam::label Foam::globalIndexAndTransform::mergeTransformIndex
(
const label transformIndex0,
const label transformIndex1
)
) const
{
FixedList<label, 3> permutation0 = decodeTransformIndex(transformIndex0);
FixedList<label, 3> permutation1 = decodeTransformIndex(transformIndex1);
@ -269,10 +302,7 @@ Foam::label Foam::globalIndexAndTransform::mergeTransformIndex
<< exit(FatalError);
}
}
return
(permutation0[2]+1)*9
+ (permutation0[1]+1)*3
+ (permutation0[0]+1);
return encodeTransformIndex(permutation0);
}
@ -280,7 +310,7 @@ Foam::label Foam::globalIndexAndTransform::minimumTransformIndex
(
const label transformIndex0,
const label transformIndex1
)
) const
{
FixedList<label, 3> permutation0 = decodeTransformIndex(transformIndex0);
FixedList<label, 3> permutation1 = decodeTransformIndex(transformIndex1);
@ -315,10 +345,7 @@ Foam::label Foam::globalIndexAndTransform::minimumTransformIndex
<< exit(FatalError);
}
}
return
(permutation0[2]+1)*9
+ (permutation0[1]+1)*3
+ (permutation0[0]+1);
return encodeTransformIndex(permutation0);
}
@ -326,7 +353,7 @@ Foam::label Foam::globalIndexAndTransform::subtractTransformIndex
(
const label transformIndex0,
const label transformIndex1
)
) const
{
FixedList<label, 3> permutation0 = decodeTransformIndex(transformIndex0);
FixedList<label, 3> permutation1 = decodeTransformIndex(transformIndex1);
@ -336,10 +363,7 @@ Foam::label Foam::globalIndexAndTransform::subtractTransformIndex
permutation0[i] -= permutation1[i];
}
return
(permutation0[2]+1)*9
+ (permutation0[1]+1)*3
+ (permutation0[0]+1);
return encodeTransformIndex(permutation0);
}