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

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

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

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

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

View File

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

View File

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

View File

@ -470,6 +470,17 @@ public:
const bool isPosition 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 // Coupled point to coupled points. Coupled points are
// points on any coupled patch. // 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> template<class Type, class CombineOp>
void Foam::globalMeshData::syncPointData void Foam::globalMeshData::syncPointData
( (

View File

@ -125,7 +125,7 @@ bool Foam::globalPoints::mergeInfo
const labelPairList& nbrInfo, const labelPairList& nbrInfo,
const label localPointI, const label localPointI,
labelPairList& myInfo labelPairList& myInfo
) ) const
{ {
bool anyChanged = false; bool anyChanged = false;
@ -167,7 +167,7 @@ bool Foam::globalPoints::mergeInfo
); );
// Combine mine and nbr transform // Combine mine and nbr transform
label t = globalIndexAndTransform::mergeTransformIndex label t = globalTransforms_.mergeTransformIndex
( (
nbrTransform, nbrTransform,
myTransform 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 void Foam::globalPoints::printProcPoints
( (
const labelList& patchToMeshPoint, const labelList& patchToMeshPoint,
@ -352,7 +331,8 @@ void Foam::globalPoints::printProcPoints
Pout<< " localpoint:"; Pout<< " localpoint:";
Pout<< index; Pout<< index;
Pout<< " through transform:" Pout<< " through transform:"
<< trafoI << " bits:" << transformBits(trafoI); << trafoI << " bits:"
<< globalTransforms_.decodeTransformIndex(trafoI);
if (procI == Pstream::myProcNo()) if (procI == Pstream::myProcNo())
{ {

View File

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

View File

@ -91,6 +91,43 @@ void Foam::syncTools::syncPointMap
{ {
const polyBoundaryMesh& patches = mesh.boundaryMesh(); 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()) if (Pstream::parRun())
{ {
PstreamBuffers pBufs(Pstream::nonBlocking); PstreamBuffers pBufs(Pstream::nonBlocking);
@ -254,8 +291,6 @@ void Foam::syncTools::syncPointMap
} }
// Synchronize multiple shared points. // Synchronize multiple shared points.
const globalMeshData& pd = mesh.globalData();
if (pd.nGlobalPoints() > 0) if (pd.nGlobalPoints() > 0)
{ {
// meshPoint per local index // meshPoint per local index
@ -263,30 +298,6 @@ void Foam::syncTools::syncPointMap
// global shared index per local index // global shared index per local index
const labelList& sharedPtAddr = pd.sharedPointAddr(); 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. // Reduce on master.
if (Pstream::parRun()) if (Pstream::parRun())
@ -367,13 +378,7 @@ void Foam::syncTools::syncPointMap
if (sharedFnd != sharedPointValues.end()) if (sharedFnd != sharedPointValues.end())
{ {
combine pointValues.set(iter(), sharedFnd());
(
pointValues,
cop,
iter(), // index
sharedFnd() // value
);
} }
} }
} }
@ -779,6 +784,23 @@ void Foam::syncTools::syncEdgeMap
// //
// const polyBoundaryMesh& patches = mesh.boundaryMesh(); // 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()) // if (Pstream::parRun())
// { // {
@ -899,16 +921,6 @@ void Foam::syncTools::syncEdgeMap
// //
// if (pd.nGlobalPoints() > 0) // 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. // // Combine on master.
// Pstream::listCombineGather(sharedPts, cop); // Pstream::listCombineGather(sharedPts, cop);
// Pstream::listCombineScatter(sharedPts); // Pstream::listCombineScatter(sharedPts);
@ -1208,6 +1220,8 @@ void Foam::syncTools::syncEdgePositions
const globalMeshData& gd = mesh.globalData(); const globalMeshData& gd = mesh.globalData();
const labelList& meshEdges = gd.coupledPatchMeshEdges(); const labelList& meshEdges = gd.coupledPatchMeshEdges();
const globalIndexAndTransform& git = gd.globalTransforms();
const mapDistribute& map = gd.globalEdgeSlavesMap();
List<point> cppFld(UIndirectList<point>(edgeValues, meshEdges)); List<point> cppFld(UIndirectList<point>(edgeValues, meshEdges));
@ -1216,8 +1230,8 @@ void Foam::syncTools::syncEdgePositions
cppFld, cppFld,
gd.globalEdgeSlaves(), gd.globalEdgeSlaves(),
gd.globalEdgeTransformedSlaves(), gd.globalEdgeTransformedSlaves(),
gd.globalEdgeSlavesMap(), map,
gd.globalTransforms(), git,
cop, cop,
true //position? true //position?
); );
@ -1505,140 +1519,28 @@ void Foam::syncTools::syncPointList
<< mesh.nPoints() << abort(FatalError); << 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); cppFld[i] = pointValues[meshPoints[i]];
}
// Send globalMeshData::syncData
forAll(patches, patchI)
{
if
( (
isA<processorPolyPatch>(patches[patchI]) cppFld,
&& patches[patchI].nPoints() > 0 gd.globalPointSlaves(),
) gd.globalPointTransformedSlaves(),
gd.globalPointSlavesMap(),
cop
);
// Extract back to mesh
forAll(meshPoints, i)
{ {
const processorPolyPatch& procPatch = pointValues[meshPoints[i]] = cppFld[i];
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;
}
}
}
}
// Do the cyclics.
forAll(patches, patchI)
{
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]];
}
} }
} }
@ -1664,140 +1566,28 @@ void Foam::syncTools::syncEdgeList
<< mesh.nEdges() << abort(FatalError); << 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); cppFld[i] = edgeValues[meshEdges[i]];
}
// Send globalMeshData::syncData
forAll(patches, patchI)
{
if
( (
isA<processorPolyPatch>(patches[patchI]) cppFld,
&& patches[patchI].nEdges() > 0 gd.globalEdgeSlaves(),
) gd.globalEdgeTransformedSlaves(),
gd.globalEdgeSlavesMap(),
cop
);
// Extract back to mesh
forAll(meshEdges, i)
{ {
const processorPolyPatch& procPatch = edgeValues[meshEdges[i]] = cppFld[i];
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;
}
}
}
}
// Do the cyclics.
forAll(patches, patchI)
{
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]];
}
} }
} }

View File

@ -138,11 +138,17 @@ private:
bool checkBothSigns bool checkBothSigns
) const; ) 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. //- Decode transform index. Hardcoded to 3 independent transforms max.
inline static FixedList<label, 3> decodeTransformIndex inline FixedList<label, 3> decodeTransformIndex
( (
const label transformIndex const label transformIndex
); ) const;
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
globalIndexAndTransform(const globalIndexAndTransform&); globalIndexAndTransform(const globalIndexAndTransform&);
@ -153,6 +159,10 @@ private:
public: public:
//- Declare friendship with the entry class for IO
friend class globalPoints;
// Constructors // Constructors
//- Construct from components //- Construct from components
@ -184,25 +194,25 @@ public:
) const; ) const;
//- Combine two transformIndices //- Combine two transformIndices
static inline label mergeTransformIndex inline label mergeTransformIndex
( (
const label transformIndex0, const label transformIndex0,
const label transformIndex1 const label transformIndex1
); ) const;
//- Combine two transformIndices //- Combine two transformIndices
static inline label minimumTransformIndex inline label minimumTransformIndex
( (
const label transformIndex0, const label transformIndex0,
const label transformIndex1 const label transformIndex1
); ) const;
//- Subtract two transformIndices //- Subtract two transformIndices
static inline label subtractTransformIndex inline label subtractTransformIndex
( (
const label transformIndex0, const label transformIndex0,
const label transformIndex1 const label transformIndex1
); ) const;
//- Encode index and bare index as components on own processor //- Encode index and bare index as components on own processor
inline static labelPair encode 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::FixedList<Foam::label, 3>
Foam::globalIndexAndTransform::decodeTransformIndex Foam::globalIndexAndTransform::decodeTransformIndex
( (
const label transformIndex const label transformIndex
) ) const
{ {
FixedList<label, 3> permutation; FixedList<label, 3> permutation(0);
label t = transformIndex; label t = transformIndex;
if (nIndependentTransforms() > 0)
{
permutation[0] = (t%3)-1; permutation[0] = (t%3)-1;
if (nIndependentTransforms() > 1)
{
t /= 3; t /= 3;
permutation[1] = (t%3)-1; permutation[1] = (t%3)-1;
if (nIndependentTransforms() > 2)
{
t /= 3; t /= 3;
permutation[2] = (t%3)-1; permutation[2] = (t%3)-1;
}
}
}
# ifdef FULLDEBUG # ifdef FULLDEBUG
t /= 3; t /= 3;
@ -222,10 +258,7 @@ Foam::label Foam::globalIndexAndTransform::addToTransformIndex
// Re-encode permutation // Re-encode permutation
// ~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~
return return encodeTransformIndex(permutation);
(permutation[2]+1)*9
+ (permutation[1]+1)*3
+ (permutation[0]+1);
} }
else else
{ {
@ -238,7 +271,7 @@ Foam::label Foam::globalIndexAndTransform::mergeTransformIndex
( (
const label transformIndex0, const label transformIndex0,
const label transformIndex1 const label transformIndex1
) ) const
{ {
FixedList<label, 3> permutation0 = decodeTransformIndex(transformIndex0); FixedList<label, 3> permutation0 = decodeTransformIndex(transformIndex0);
FixedList<label, 3> permutation1 = decodeTransformIndex(transformIndex1); FixedList<label, 3> permutation1 = decodeTransformIndex(transformIndex1);
@ -269,10 +302,7 @@ Foam::label Foam::globalIndexAndTransform::mergeTransformIndex
<< exit(FatalError); << exit(FatalError);
} }
} }
return return encodeTransformIndex(permutation0);
(permutation0[2]+1)*9
+ (permutation0[1]+1)*3
+ (permutation0[0]+1);
} }
@ -280,7 +310,7 @@ Foam::label Foam::globalIndexAndTransform::minimumTransformIndex
( (
const label transformIndex0, const label transformIndex0,
const label transformIndex1 const label transformIndex1
) ) const
{ {
FixedList<label, 3> permutation0 = decodeTransformIndex(transformIndex0); FixedList<label, 3> permutation0 = decodeTransformIndex(transformIndex0);
FixedList<label, 3> permutation1 = decodeTransformIndex(transformIndex1); FixedList<label, 3> permutation1 = decodeTransformIndex(transformIndex1);
@ -315,10 +345,7 @@ Foam::label Foam::globalIndexAndTransform::minimumTransformIndex
<< exit(FatalError); << exit(FatalError);
} }
} }
return return encodeTransformIndex(permutation0);
(permutation0[2]+1)*9
+ (permutation0[1]+1)*3
+ (permutation0[0]+1);
} }
@ -326,7 +353,7 @@ Foam::label Foam::globalIndexAndTransform::subtractTransformIndex
( (
const label transformIndex0, const label transformIndex0,
const label transformIndex1 const label transformIndex1
) ) const
{ {
FixedList<label, 3> permutation0 = decodeTransformIndex(transformIndex0); FixedList<label, 3> permutation0 = decodeTransformIndex(transformIndex0);
FixedList<label, 3> permutation1 = decodeTransformIndex(transformIndex1); FixedList<label, 3> permutation1 = decodeTransformIndex(transformIndex1);
@ -336,10 +363,7 @@ Foam::label Foam::globalIndexAndTransform::subtractTransformIndex
permutation0[i] -= permutation1[i]; permutation0[i] -= permutation1[i];
} }
return return encodeTransformIndex(permutation0);
(permutation0[2]+1)*9
+ (permutation0[1]+1)*3
+ (permutation0[0]+1);
} }