diff --git a/applications/test/globalMeshData/Test-globalMeshData.C b/applications/test/globalMeshData/Test-globalMeshData.C index 6feaf5cc05d2cceb17f958852c9a00890575dbb6..3c789748bf85c6df98f84d33f58d9ac2c692dc76 100644 --- a/applications/test/globalMeshData/Test-globalMeshData.C +++ b/applications/test/globalMeshData/Test-globalMeshData.C @@ -70,7 +70,12 @@ int main(int argc, char *argv[]) ); // Exchange data. Apply positional transforms. - globalPointSlavesMap.distribute(transforms, coords, true); + globalPointSlavesMap.distribute + ( + transforms, + coords, + mapDistribute::transformPosition() + ); // Print forAll(slaves, pointI) @@ -127,7 +132,12 @@ int main(int argc, char *argv[]) } // Exchange data Apply positional transforms. - globalEdgeSlavesMap.distribute(transforms, ec, true); + globalEdgeSlavesMap.distribute + ( + transforms, + ec, + mapDistribute::transformPosition() + ); // Print forAll(slaves, edgeI) @@ -163,82 +173,131 @@ int main(int argc, char *argv[]) } - //// Test: (collocated) point to faces addressing - //{ - // const labelListList& globalPointBoundaryFaces = - // globalData.globalPointBoundaryFaces(); - // const mapDistribute& globalPointBoundaryFacesMap = - // globalData.globalPointBoundaryFacesMap(); - // - // label nBnd = mesh.nFaces()-mesh.nInternalFaces(); - // - // pointField fc(globalPointBoundaryFacesMap.constructSize()); - // SubList<point>(fc, nBnd).assign - // ( - // primitivePatch - // ( - // SubList<face> - // ( - // mesh.faces(), - // nBnd, - // mesh.nInternalFaces() - // ), - // mesh.points() - // ).faceCentres() - // ); - // - // // Exchange data - // globalPointBoundaryFacesMap.distribute(fc); - // - // // Print - // forAll(globalPointBoundaryFaces, pointI) - // { - // const labelList& bFaces = globalPointBoundaryFaces[pointI]; - // - // Pout<< "Point:" << pointI - // << " at:" << coupledPatch.localPoints()[pointI] - // << " connected to faces:" << endl; - // - // forAll(bFaces, i) - // { - // Pout<< " " << fc[bFaces[i]] << endl; - // } - // } - //} - // - // - //// Test:(collocated) point to cells addressing - //{ - // const labelList& boundaryCells = globalData.boundaryCells(); - // const labelListList& globalPointBoundaryCells = - // globalData.globalPointBoundaryCells(); - // const mapDistribute& globalPointBoundaryCellsMap = - // globalData.globalPointBoundaryCellsMap(); - // - // pointField cc(globalPointBoundaryCellsMap.constructSize()); - // forAll(boundaryCells, i) - // { - // cc[i] = mesh.cellCentres()[boundaryCells[i]]; - // } - // - // // Exchange data - // globalPointBoundaryCellsMap.distribute(cc); - // - // // Print - // forAll(globalPointBoundaryCells, pointI) - // { - // const labelList& bCells = globalPointBoundaryCells[pointI]; - // - // Pout<< "Point:" << pointI - // << " at:" << coupledPatch.localPoints()[pointI] - // << " connected to cells:" << endl; - // - // forAll(bCells, i) - // { - // Pout<< " " << cc[bCells[i]] << endl; - // } - // } - //} + // Test: point to faces addressing + { + const mapDistribute& globalPointBoundaryFacesMap = + globalData.globalPointBoundaryFacesMap(); + const labelListList& slaves = + globalData.globalPointBoundaryFaces(); + const labelListList& transformedSlaves = + globalData.globalPointTransformedBoundaryFaces(); + + label nBnd = mesh.nFaces()-mesh.nInternalFaces(); + + pointField fc(globalPointBoundaryFacesMap.constructSize()); + SubList<point>(fc, nBnd).assign + ( + primitivePatch + ( + SubList<face> + ( + mesh.faces(), + nBnd, + mesh.nInternalFaces() + ), + mesh.points() + ).faceCentres() + ); + + // Exchange data + globalPointBoundaryFacesMap.distribute + ( + transforms, + fc, + mapDistribute::transformPosition() + ); + + // Print + forAll(slaves, pointI) + { + const labelList& slaveFaces = slaves[pointI]; + + if (slaveFaces.size() > 0) + { + Pout<< "Master point:" << pointI + << " at:" << coupledPatch.localPoints()[pointI] + << " connected to " << slaveFaces.size() + << " untransformed faces:" << endl; + + forAll(slaveFaces, i) + { + Pout<< " " << fc[slaveFaces[i]] << endl; + } + } + + const labelList& transformedSlaveFaces = transformedSlaves[pointI]; + + if (transformedSlaveFaces.size() > 0) + { + Pout<< "Master point:" << pointI + << " connected to " << transformedSlaveFaces.size() + << " transformed faces:" << endl; + + forAll(transformedSlaveFaces, i) + { + Pout<< " " << fc[transformedSlaveFaces[i]] << endl; + } + } + } + } + + + // Test: point to cells addressing + { + const labelList& boundaryCells = globalData.boundaryCells(); + const mapDistribute& globalPointBoundaryCellsMap = + globalData.globalPointBoundaryCellsMap(); + const labelListList& slaves = globalData.globalPointBoundaryCells(); + const labelListList& transformedSlaves = + globalData.globalPointTransformedBoundaryCells(); + + pointField cc(globalPointBoundaryCellsMap.constructSize()); + forAll(boundaryCells, i) + { + cc[i] = mesh.cellCentres()[boundaryCells[i]]; + } + + // Exchange data + globalPointBoundaryCellsMap.distribute + ( + transforms, + cc, + mapDistribute::transformPosition() + ); + + // Print + forAll(slaves, pointI) + { + const labelList& pointCells = slaves[pointI]; + + if (pointCells.size() > 0) + { + Pout<< "Master point:" << pointI + << " at:" << coupledPatch.localPoints()[pointI] + << " connected to " << pointCells.size() + << " untransformed boundaryCells:" << endl; + + forAll(pointCells, i) + { + Pout<< " " << cc[pointCells[i]] << endl; + } + } + + const labelList& transformPointCells = transformedSlaves[pointI]; + + if (transformPointCells.size() > 0) + { + Pout<< "Master point:" << pointI + << " connected to " << transformPointCells.size() + << " transformed boundaryCells:" << endl; + + forAll(transformPointCells, i) + { + Pout<< " " << cc[transformPointCells[i]] << endl; + } + } + } + } Info<< "End\n" << endl; diff --git a/applications/test/syncTools/Test-syncTools.C b/applications/test/syncTools/Test-syncTools.C index 094068e94ab0e660e1c33509025f06383e062a86..6f9d5f408a802e5e2c08b79b264952138073b0af 100644 --- a/applications/test/syncTools/Test-syncTools.C +++ b/applications/test/syncTools/Test-syncTools.C @@ -30,12 +30,12 @@ Description \*---------------------------------------------------------------------------*/ +#include "syncTools.H" #include "argList.H" #include "polyMesh.H" #include "Time.H" #include "Random.H" #include "PackedList.H" -#include "syncTools.H" using namespace Foam; @@ -285,7 +285,7 @@ void testSparseData(const polyMesh& mesh, Random& rndGen) { // Create some data. Use slightly perturbed positions. - EdgeMap<vector> sparseData; + EdgeMap<point> sparseData; pointField fullData(mesh.nEdges(), point::max); const edgeList& edges = allBoundary.edges(); @@ -313,13 +313,13 @@ void testSparseData(const polyMesh& mesh, Random& rndGen) ( mesh, sparseData, - minEqOp<vector>() + minMagSqrEqOp<point>() ); syncTools::syncEdgeList ( mesh, fullData, - minEqOp<vector>(), + minMagSqrEqOp<point>(), point::max ); @@ -350,7 +350,7 @@ void testSparseData(const polyMesh& mesh, Random& rndGen) { const edge& e = mesh.edges()[meshEdgeI]; - EdgeMap<vector>::const_iterator iter = sparseData.find(e); + EdgeMap<point>::const_iterator iter = sparseData.find(e); if (iter != sparseData.end()) { diff --git a/src/OpenFOAM/fields/Fields/transformList/transformList.C b/src/OpenFOAM/fields/Fields/transformList/transformList.C index 04cff1b22d11a2270d8f65a8377085e5521f67a8..73353620d98a4b848981be5d4cea2d3da7dc1810 100644 --- a/src/OpenFOAM/fields/Fields/transformList/transformList.C +++ b/src/OpenFOAM/fields/Fields/transformList/transformList.C @@ -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 @@ -46,11 +46,17 @@ Foam::List<T> Foam::transform template <class T> -void Foam::transformList -( - const tensorField& rotTensor, - UList<T>& field -) +void Foam::transformList(const tensor& rotTensor, UList<T>& field) +{ + forAll(field, i) + { + field[i] = transform(rotTensor, field[i]); + } +} + + +template <class T> +void Foam::transformList(const tensorField& rotTensor, UList<T>& field) { if (rotTensor.size() == 1) { @@ -79,11 +85,17 @@ void Foam::transformList template <class T> -void Foam::transformList -( - const tensorField& rotTensor, - Map<T>& field -) +void Foam::transformList(const tensor& rotTensor, Map<T>& field) +{ + forAllIter(typename Map<T>, field, iter) + { + iter() = transform(rotTensor[0], iter()); + } +} + + +template <class T> +void Foam::transformList(const tensorField& rotTensor, Map<T>& field) { if (rotTensor.size() == 1) { @@ -105,11 +117,17 @@ void Foam::transformList template <class T> -void Foam::transformList -( - const tensorField& rotTensor, - EdgeMap<T>& field -) +void Foam::transformList(const tensor& rotTensor, EdgeMap<T>& field) +{ + forAllIter(typename EdgeMap<T>, field, iter) + { + iter() = transform(rotTensor[0], iter()); + } +} + + +template <class T> +void Foam::transformList(const tensorField& rotTensor, EdgeMap<T>& field) { if (rotTensor.size() == 1) { diff --git a/src/OpenFOAM/fields/Fields/transformList/transformList.H b/src/OpenFOAM/fields/Fields/transformList/transformList.H index 3dde0e65bbcce9901ea79682eaad32c50c0f0455..16fbc4b94655edcc5c8c7946f91dcf083620ce95 100644 --- a/src/OpenFOAM/fields/Fields/transformList/transformList.H +++ b/src/OpenFOAM/fields/Fields/transformList/transformList.H @@ -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 @@ -60,33 +60,57 @@ List<T> transform //- Apply transformation to list. Either single transformation tensor // or one tensor per element. template<class T> +void transformList(const tensor&, UList<T>&); +template<class T> void transformList(const tensorField&, UList<T>&); +template<class T> +void transformList(const tensor&, Map<T>&); template<class T> void transformList(const tensorField&, Map<T>&); +template<class T> +void transformList(const tensor&, EdgeMap<T>&); template<class T> void transformList(const tensorField&, EdgeMap<T>&); +template<> +inline void transformList(const tensor&, labelUList&) +{} template<> inline void transformList(const tensorField&, labelUList&) {} template<> +inline void transformList(const tensor&, Map<label>&) +{} +template<> inline void transformList(const tensorField&, Map<label>&) {} template<> +inline void transformList(const tensor&, EdgeMap<label>&) +{} +template<> inline void transformList(const tensorField&, EdgeMap<label>&) {} +template<> +inline void transformList(const tensor&, UList<scalar>&) +{} template<> inline void transformList(const tensorField&, UList<scalar>&) {} template<> +inline void transformList(const tensor&, Map<scalar>&) +{} +template<> inline void transformList(const tensorField&, Map<scalar>&) {} template<> +inline void transformList(const tensor&, EdgeMap<scalar>&) +{} +template<> inline void transformList(const tensorField&, EdgeMap<scalar>&) {} diff --git a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C index aeb05000b7da28b14d97923fb142d499c05feb05..52ccc834ff8e25592e170e4ae0008b495277e742 100644 --- a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C +++ b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C @@ -1064,398 +1064,504 @@ void Foam::globalMeshData::calcGlobalEdgeSlaves() const } -//// Calculate uncoupled boundary faces (without calculating -//// primitiveMesh::pointFaces()) -//void Foam::globalMeshData::calcPointBoundaryFaces -//( -// labelListList& pointBoundaryFaces -//) const -//{ -// const polyBoundaryMesh& bMesh = mesh_.boundaryMesh(); -// const Map<label>& meshPointMap = coupledPatch().meshPointMap(); -// -// // 1. Count -// -// labelList nPointFaces(coupledPatch().nPoints(), 0); -// -// forAll(bMesh, patchI) -// { -// const polyPatch& pp = bMesh[patchI]; -// -// if (!pp.coupled()) -// { -// forAll(pp, i) -// { -// const face& f = pp[i]; -// -// forAll(f, fp) -// { -// Map<label>::const_iterator iter = meshPointMap.find -// ( -// f[fp] -// ); -// if (iter != meshPointMap.end()) -// { -// nPointFaces[iter()]++; -// } -// } -// } -// } -// } -// -// -// // 2. Size -// -// pointBoundaryFaces.setSize(coupledPatch().nPoints()); -// forAll(nPointFaces, pointI) -// { -// pointBoundaryFaces[pointI].setSize(nPointFaces[pointI]); -// } -// nPointFaces = 0; -// -// -// // 3. Fill -// -// forAll(bMesh, patchI) -// { -// const polyPatch& pp = bMesh[patchI]; -// -// if (!pp.coupled()) -// { -// forAll(pp, i) -// { -// const face& f = pp[i]; -// forAll(f, fp) -// { -// Map<label>::const_iterator iter = meshPointMap.find -// ( -// f[fp] -// ); -// if (iter != meshPointMap.end()) -// { -// label bFaceI = -// pp.start() + i - mesh_.nInternalFaces(); -// pointBoundaryFaces[iter()][nPointFaces[iter()]++] = -// bFaceI; -// } -// } -// } -// } -// } -//} -// -// -//void Foam::globalMeshData::calcGlobalPointBoundaryFaces() const -//{ -// if (debug) -// { -// Pout<< "globalMeshData::calcGlobalPointBoundaryFaces() :" -// << " calculating coupled point to boundary face addressing." -// << endl; -// } -// -// // Construct local point to (uncoupled)boundaryfaces. -// labelListList pointBoundaryFaces; -// calcPointBoundaryFaces(pointBoundaryFaces); -// -// -// // Global indices for boundary faces -// globalBoundaryFaceNumberingPtr_.reset -// ( -// new globalIndex(mesh_.nFaces()-mesh_.nInternalFaces()) -// ); -// globalIndex& globalIndices = globalBoundaryFaceNumberingPtr_(); -// -// -// // Convert local boundary faces to global numbering -// globalPointBoundaryFacesPtr_.reset -// ( -// new labelListList(globalPointSlavesMap().constructSize()) -// ); -// labelListList& globalPointBoundaryFaces = globalPointBoundaryFacesPtr_(); -// -// forAll(pointBoundaryFaces, pointI) -// { -// const labelList& bFaces = pointBoundaryFaces[pointI]; -// labelList& globalFaces = globalPointBoundaryFaces[pointI]; -// globalFaces.setSize(bFaces.size()); -// forAll(bFaces, i) -// { -// globalFaces[i] = globalIndices.toGlobal(bFaces[i]); -// } -// } -// -// -// // Pull slave pointBoundaryFaces to master -// globalPointSlavesMap().distribute -// ( -// globalTransforms(), -// globalPointBoundaryFaces -// ); -// -// -// // Merge slave labels into master globalPointBoundaryFaces. -// // Split into untransformed and transformed values. -// const labelListList& pointSlaves = globalPointSlaves(); -// const labelListList& pointTransformSlaves = -// globalPointTransformedSlaves(); -// -// -// List<labelPairList> transformedFaces; -// -// -// forAll(pointSlaves, pointI) -// { -// const labelList& slaves = pointSlaves[pointI]; -// -// if (slaves.size() > 0) -// { -// labelList& myBFaces = globalPointBoundaryFaces[pointI]; -// -// forAll(slaves, i) -// { -// const labelList& slaveBFaces = -// globalPointBoundaryFaces[slaves[i]]; -// -// // Add all slaveBFaces. Note that need to check for -// // uniqueness only in case of cyclics. -// -// label sz = myBFaces.size(); -// myBFaces.setSize(sz+slaveBFaces.size()); -// forAll(slaveBFaces, j) -// { -// label slave = slaveBFaces[j]; -// if (findIndex(SubList<label>(myBFaces, sz), slave) == -1) -// { -// myBFaces[sz++] = slave; -// } -// } -// myBFaces.setSize(sz); -// } -// } -// } -// -// -// // Copy merged boundaryFaces back from master into slave slot -// forAll(pointSlaves, pointI) -// { -// const labelList& bFaces = globalPointBoundaryFaces[pointI]; -// const labelList& slaves = pointSlaves[pointI]; -// -// forAll(slaves, i) -// { -// globalPointBoundaryFaces[slaves[i]] = bFaces; -// } -// } -// -// -// // Sync back to slaves. -// globalPointSlavesMap().reverseDistribute -// ( -// coupledPatch().nPoints(), -// globalPointBoundaryFaces -// ); -// -// -// // Construct a map to get the face data directly -// List<Map<label> > compactMap(Pstream::nProcs()); -// -// globalPointTransformedBoundaryFacesPtr_.reset -// ( -// new labelList(transformedFaces.size()) -// ); -// -// globalPointBoundaryFacesMapPtr_.reset -// ( -// new mapDistribute -// ( -// globalIndices, -// globalPointBoundaryFaces, -// -// globalTransforms(), -// transformedFaces, -// globalPointTransformedBoundaryFacesPtr_, -// -// compactMap -// ) -// ); -// -// if (debug) -// { -// Pout<< "globalMeshData::calcGlobalPointBoundaryFaces() :" -// << " coupled points:" << coupledPatch().nPoints() -// << " local boundary faces:" << globalIndices.localSize() -// << " additional coupled faces:" -// << globalPointBoundaryFacesMapPtr_().constructSize() -// - globalIndices.localSize() -// << endl; -// } -//} - - -//void Foam::globalMeshData::calcGlobalPointBoundaryCells() const -//{ -// if (debug) -// { -// Pout<< "globalMeshData::calcGlobalPointBoundaryCells() :" -// << " calculating coupled point to boundary cell addressing." -// << endl; -// } -// -// // Create map of boundary cells and point-cell addressing -// // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// -// label bCellI = 0; -// Map<label> meshCellMap(4*coupledPatch().nPoints()); -// DynamicList<label> cellMap(meshCellMap.size()); -// -// // Create addressing for point to boundary cells (local) -// labelListList pointBoundaryCells(coupledPatch().nPoints()); -// -// forAll(coupledPatch().meshPoints(), pointI) -// { -// label meshPointI = coupledPatch().meshPoints()[pointI]; -// const labelList& pCells = mesh_.pointCells(meshPointI); -// -// labelList& bCells = pointBoundaryCells[pointI]; -// bCells.setSize(pCells.size()); -// -// forAll(pCells, i) -// { -// label cellI = pCells[i]; -// Map<label>::iterator fnd = meshCellMap.find(cellI); -// -// if (fnd != meshCellMap.end()) -// { -// bCells[i] = fnd(); -// } -// else -// { -// meshCellMap.insert(cellI, bCellI); -// cellMap.append(cellI); -// bCells[i] = bCellI; -// bCellI++; -// } -// } -// } -// -// -// boundaryCellsPtr_.reset(new labelList()); -// labelList& boundaryCells = boundaryCellsPtr_(); -// boundaryCells.transfer(cellMap.shrink()); -// -// -// // Convert point-cells to global point numbers -// // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// -// globalBoundaryCellNumberingPtr_.reset -// ( -// new globalIndex(boundaryCells.size()) -// ); -// globalIndex& globalIndices = globalBoundaryCellNumberingPtr_(); -// -// -// globalPointBoundaryCellsPtr_.reset -// ( -// new labelListList(globalPointSlavesMap().constructSize()) -// ); -// labelListList& globalPointBoundaryCells = globalPointBoundaryCellsPtr_(); -// -// forAll(pointBoundaryCells, pointI) -// { -// const labelList& pCells = pointBoundaryCells[pointI]; -// labelList& globalCells = globalPointBoundaryCells[pointI]; -// globalCells.setSize(pCells.size()); -// forAll(pCells, i) -// { -// globalCells[i] = globalIndices.toGlobal(pCells[i]); -// } -// } -// -// -// // Pull slave pointBoundaryCells to master -// globalPointSlavesMap().distribute(globalPointBoundaryCells); -// -// -// // Merge slave labels into master globalPointBoundaryCells -// const labelListList& pointSlaves = globalPointSlaves(); -// -// forAll(pointSlaves, pointI) -// { -// const labelList& slaves = pointSlaves[pointI]; -// -// if (slaves.size() > 0) -// { -// labelList& myBCells = globalPointBoundaryCells[pointI]; -// -// forAll(slaves, i) -// { -// const labelList& slaveBCells = -// globalPointBoundaryCells[slaves[i]]; -// -// // Add all slaveBCells. Note that need to check for -// // uniqueness only in case of cyclics. -// -// label sz = myBCells.size(); -// myBCells.setSize(sz+slaveBCells.size()); -// forAll(slaveBCells, j) -// { -// label slave = slaveBCells[j]; -// if (findIndex(SubList<label>(myBCells, sz), slave) == -1) -// { -// myBCells[sz++] = slave; -// } -// } -// myBCells.setSize(sz); -// } -// } -// } -// -// -// // Copy merged boundaryCells back from master into slave slot -// forAll(pointSlaves, pointI) -// { -// const labelList& bCells = globalPointBoundaryCells[pointI]; -// const labelList& slaves = pointSlaves[pointI]; -// -// forAll(slaves, i) -// { -// globalPointBoundaryCells[slaves[i]] = bCells; -// } -// } -// -// -// // Sync back to slaves. -// globalPointSlavesMap().reverseDistribute -// ( -// coupledPatch().nPoints(), -// globalPointBoundaryCells -// ); -// -// -// // Construct a map to get the cell data directly -// List<Map<label> > compactMap(Pstream::nProcs()); -// globalPointBoundaryCellsMapPtr_.reset -// ( -// new mapDistribute -// ( -// globalIndices, -// globalPointBoundaryCells, -// compactMap -// ) -// ); -// -// if (debug) -// { -// Pout<< "globalMeshData::calcGlobalPointBoundaryCells() :" -// << " coupled points:" << coupledPatch().nPoints() -// << " local boundary cells:" << globalIndices.localSize() -// << " additional coupled cells:" -// << globalPointBoundaryCellsMapPtr_().constructSize() -// - globalIndices.localSize() -// << endl; -// } -//} +// Calculate uncoupled boundary faces (without calculating +// primitiveMesh::pointFaces()) +void Foam::globalMeshData::calcPointBoundaryFaces +( + labelListList& pointBoundaryFaces +) const +{ + const polyBoundaryMesh& bMesh = mesh_.boundaryMesh(); + const Map<label>& meshPointMap = coupledPatch().meshPointMap(); + + // 1. Count + + labelList nPointFaces(coupledPatch().nPoints(), 0); + + forAll(bMesh, patchI) + { + const polyPatch& pp = bMesh[patchI]; + + if (!pp.coupled()) + { + forAll(pp, i) + { + const face& f = pp[i]; + + forAll(f, fp) + { + Map<label>::const_iterator iter = meshPointMap.find + ( + f[fp] + ); + if (iter != meshPointMap.end()) + { + nPointFaces[iter()]++; + } + } + } + } + } + + + // 2. Size + + pointBoundaryFaces.setSize(coupledPatch().nPoints()); + forAll(nPointFaces, pointI) + { + pointBoundaryFaces[pointI].setSize(nPointFaces[pointI]); + } + nPointFaces = 0; + + + // 3. Fill + + forAll(bMesh, patchI) + { + const polyPatch& pp = bMesh[patchI]; + + if (!pp.coupled()) + { + forAll(pp, i) + { + const face& f = pp[i]; + forAll(f, fp) + { + Map<label>::const_iterator iter = meshPointMap.find + ( + f[fp] + ); + if (iter != meshPointMap.end()) + { + label bFaceI = + pp.start() + i - mesh_.nInternalFaces(); + pointBoundaryFaces[iter()][nPointFaces[iter()]++] = + bFaceI; + } + } + } + } + } +} + + +void Foam::globalMeshData::calcGlobalPointBoundaryFaces() const +{ + if (debug) + { + Pout<< "globalMeshData::calcGlobalPointBoundaryFaces() :" + << " calculating coupled point to boundary face addressing." + << endl; + } + + // Construct local point to (uncoupled)boundaryfaces. + labelListList pointBoundaryFaces; + calcPointBoundaryFaces(pointBoundaryFaces); + + + // Global indices for boundary faces + globalBoundaryFaceNumberingPtr_.reset + ( + new globalIndex(mesh_.nFaces()-mesh_.nInternalFaces()) + ); + globalIndex& globalIndices = globalBoundaryFaceNumberingPtr_(); + + + // Convert local boundary faces to global numbering + globalPointBoundaryFacesPtr_.reset + ( + new labelListList(globalPointSlavesMap().constructSize()) + ); + labelListList& globalPointBoundaryFaces = globalPointBoundaryFacesPtr_(); + + forAll(pointBoundaryFaces, pointI) + { + const labelList& bFaces = pointBoundaryFaces[pointI]; + labelList& globalFaces = globalPointBoundaryFaces[pointI]; + globalFaces.setSize(bFaces.size()); + forAll(bFaces, i) + { + globalFaces[i] = globalIndices.toGlobal(bFaces[i]); + } + } + + + // Pull slave pointBoundaryFaces to master + globalPointSlavesMap().distribute + ( + globalPointBoundaryFaces, + true // put data on transformed points into correct slots + ); + + + // Merge slave labels into master globalPointBoundaryFaces. + // Split into untransformed and transformed values. + const labelListList& pointSlaves = globalPointSlaves(); + const labelListList& pointTransformSlaves = + globalPointTransformedSlaves(); + + + // Any faces coming in through transformation + List<labelPairList> transformedFaces(pointSlaves.size()); + + + forAll(pointSlaves, pointI) + { + const labelList& slaves = pointSlaves[pointI]; + const labelList& transformedSlaves = pointTransformSlaves[pointI]; + + if (slaves.size() > 0) + { + labelList& myBFaces = globalPointBoundaryFaces[pointI]; + label sz = myBFaces.size(); + + // Count + label n = 0; + forAll(slaves, i) + { + n += globalPointBoundaryFaces[slaves[i]].size(); + } + // Fill + myBFaces.setSize(sz+n); + n = sz; + forAll(slaves, i) + { + const labelList& slaveBFaces = + globalPointBoundaryFaces[slaves[i]]; + + // Add all slaveBFaces. Note that need to check for + // uniqueness only in case of cyclics. + + forAll(slaveBFaces, j) + { + label slave = slaveBFaces[j]; + if (findIndex(SubList<label>(myBFaces, sz), slave) == -1) + { + myBFaces[n++] = slave; + } + } + } + myBFaces.setSize(n); + } + + + if (transformedSlaves.size() > 0) + { + const labelList& untrafoFaces = globalPointBoundaryFaces[pointI]; + + labelPairList& myBFaces = transformedFaces[pointI]; + label sz = myBFaces.size(); + + // Count + label n = 0; + forAll(transformedSlaves, i) + { + n += globalPointBoundaryFaces[transformedSlaves[i]].size(); + } + // Fill + myBFaces.setSize(sz+n); + n = sz; + forAll(transformedSlaves, i) + { + label transformI = globalPointSlavesMap().whichTransform + ( + transformedSlaves[i] + ); + + const labelList& slaveBFaces = + globalPointBoundaryFaces[transformedSlaves[i]]; + + forAll(slaveBFaces, j) + { + label slave = slaveBFaces[j]; + // Check that same face not already present untransformed + if (findIndex(untrafoFaces, slave)== -1) + { + label procI = globalIndices.whichProcID(slave); + label faceI = globalIndices.toLocal(procI, slave); + + myBFaces[n++] = globalIndexAndTransform::encode + ( + procI, + faceI, + transformI + ); + } + } + } + myBFaces.setSize(n); + } + + + if (slaves.size() + transformedSlaves.size() == 0) + { + globalPointBoundaryFaces[pointI].clear(); + } + } + + // Construct a map to get the face data directly + List<Map<label> > compactMap(Pstream::nProcs()); + + globalPointTransformedBoundaryFacesPtr_.reset + ( + new labelListList(transformedFaces.size()) + ); + + globalPointBoundaryFacesMapPtr_.reset + ( + new mapDistribute + ( + globalIndices, + globalPointBoundaryFaces, + + globalTransforms(), + transformedFaces, + globalPointTransformedBoundaryFacesPtr_(), + + compactMap + ) + ); + globalPointBoundaryFaces.setSize(coupledPatch().nPoints()); + globalPointTransformedBoundaryFacesPtr_().setSize(coupledPatch().nPoints()); + + if (debug) + { + Pout<< "globalMeshData::calcGlobalPointBoundaryFaces() :" + << " coupled points:" << coupledPatch().nPoints() + << " local boundary faces:" << globalIndices.localSize() + << " additional coupled faces:" + << globalPointBoundaryFacesMapPtr_().constructSize() + - globalIndices.localSize() + << endl; + } +} + + +void Foam::globalMeshData::calcGlobalPointBoundaryCells() const +{ + if (debug) + { + Pout<< "globalMeshData::calcGlobalPointBoundaryCells() :" + << " calculating coupled point to boundary cell addressing." + << endl; + } + + // Create map of boundary cells and point-cell addressing + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + label bCellI = 0; + Map<label> meshCellMap(4*coupledPatch().nPoints()); + DynamicList<label> cellMap(meshCellMap.size()); + + // Create addressing for point to boundary cells (local) + labelListList pointBoundaryCells(coupledPatch().nPoints()); + + forAll(coupledPatch().meshPoints(), pointI) + { + label meshPointI = coupledPatch().meshPoints()[pointI]; + const labelList& pCells = mesh_.pointCells(meshPointI); + + labelList& bCells = pointBoundaryCells[pointI]; + bCells.setSize(pCells.size()); + + forAll(pCells, i) + { + label cellI = pCells[i]; + Map<label>::iterator fnd = meshCellMap.find(cellI); + + if (fnd != meshCellMap.end()) + { + bCells[i] = fnd(); + } + else + { + meshCellMap.insert(cellI, bCellI); + cellMap.append(cellI); + bCells[i] = bCellI; + bCellI++; + } + } + } + + + boundaryCellsPtr_.reset(new labelList()); + labelList& boundaryCells = boundaryCellsPtr_(); + boundaryCells.transfer(cellMap.shrink()); + + + // Convert point-cells to global (boundary)cell numbers + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + globalBoundaryCellNumberingPtr_.reset + ( + new globalIndex(boundaryCells.size()) + ); + globalIndex& globalIndices = globalBoundaryCellNumberingPtr_(); + + + globalPointBoundaryCellsPtr_.reset + ( + new labelListList(globalPointSlavesMap().constructSize()) + ); + labelListList& globalPointBoundaryCells = globalPointBoundaryCellsPtr_(); + + forAll(pointBoundaryCells, pointI) + { + const labelList& pCells = pointBoundaryCells[pointI]; + labelList& globalCells = globalPointBoundaryCells[pointI]; + globalCells.setSize(pCells.size()); + forAll(pCells, i) + { + globalCells[i] = globalIndices.toGlobal(pCells[i]); + } + } + + + // Pull slave pointBoundaryCells to master + globalPointSlavesMap().distribute + ( + globalPointBoundaryCells, + true // put data on transformed points into correct slots + ); + + + // Merge slave labels into master globalPointBoundaryCells + const labelListList& pointSlaves = globalPointSlaves(); + const labelListList& pointTransformSlaves = + globalPointTransformedSlaves(); + + List<labelPairList> transformedCells(pointSlaves.size()); + + + forAll(pointSlaves, pointI) + { + const labelList& slaves = pointSlaves[pointI]; + const labelList& transformedSlaves = pointTransformSlaves[pointI]; + + if (slaves.size() > 0) + { + labelList& myBCells = globalPointBoundaryCells[pointI]; + label sz = myBCells.size(); + + // Count + label n = 0; + forAll(slaves, i) + { + n += globalPointBoundaryCells[slaves[i]].size(); + } + // Fill + myBCells.setSize(sz+n); + n = sz; + forAll(slaves, i) + { + const labelList& slaveBCells = + globalPointBoundaryCells[slaves[i]]; + + // Add all slaveBCells. Note that need to check for + // uniqueness only in case of cyclics. + + forAll(slaveBCells, j) + { + label slave = slaveBCells[j]; + if (findIndex(SubList<label>(myBCells, sz), slave) == -1) + { + myBCells[n++] = slave; + } + } + } + myBCells.setSize(n); + } + + + if (transformedSlaves.size() > 0) + { + const labelList& untrafoCells = globalPointBoundaryCells[pointI]; + + labelPairList& myBCells = transformedCells[pointI]; + label sz = myBCells.size(); + + // Count + label n = 0; + forAll(transformedSlaves, i) + { + n += globalPointBoundaryCells[transformedSlaves[i]].size(); + } + // Fill + myBCells.setSize(sz+n); + n = sz; + forAll(transformedSlaves, i) + { + label transformI = globalPointSlavesMap().whichTransform + ( + transformedSlaves[i] + ); + + const labelList& slaveBCells = + globalPointBoundaryCells[transformedSlaves[i]]; + + forAll(slaveBCells, j) + { + label slave = slaveBCells[j]; + + // Check that same cell not already present untransformed + if (findIndex(untrafoCells, slave)== -1) + { + label procI = globalIndices.whichProcID(slave); + label cellI = globalIndices.toLocal(procI, slave); + myBCells[n++] = globalIndexAndTransform::encode + ( + procI, + cellI, + transformI + ); + } + } + } + myBCells.setSize(n); + } + + if (slaves.size() + transformedSlaves.size() == 0) + { + globalPointBoundaryCells[pointI].clear(); + } + } + + // Construct a map to get the cell data directly + List<Map<label> > compactMap(Pstream::nProcs()); + + globalPointTransformedBoundaryCellsPtr_.reset + ( + new labelListList(transformedCells.size()) + ); + + globalPointBoundaryCellsMapPtr_.reset + ( + new mapDistribute + ( + globalIndices, + globalPointBoundaryCells, + + globalTransforms(), + transformedCells, + globalPointTransformedBoundaryCellsPtr_(), + + compactMap + ) + ); + globalPointBoundaryCells.setSize(coupledPatch().nPoints()); + globalPointTransformedBoundaryCellsPtr_().setSize(coupledPatch().nPoints()); + + if (debug) + { + Pout<< "globalMeshData::calcGlobalPointBoundaryCells() :" + << " coupled points:" << coupledPatch().nPoints() + << " local boundary cells:" << globalIndices.localSize() + << " additional coupled cells:" + << globalPointBoundaryCellsMapPtr_().constructSize() + - globalIndices.localSize() + << endl; + } +} // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -1521,15 +1627,18 @@ void Foam::globalMeshData::clearOut() globalEdgeTransformedSlavesPtr_.clear(); globalEdgeSlavesMapPtr_.clear(); -// // Face -// globalBoundaryFaceNumberingPtr_.clear(); -// globalPointBoundaryFacesPtr_.clear(); -// globalPointBoundaryFacesMapPtr_.clear(); -// // Cell -// boundaryCellsPtr_.clear(); -// globalBoundaryCellNumberingPtr_.clear(); -// globalPointBoundaryCellsPtr_.clear(); -// globalPointBoundaryCellsMapPtr_.clear(); + // Face + globalBoundaryFaceNumberingPtr_.clear(); + globalPointBoundaryFacesPtr_.clear(); + globalPointTransformedBoundaryFacesPtr_.clear(); + globalPointBoundaryFacesMapPtr_.clear(); + + // Cell + boundaryCellsPtr_.clear(); + globalBoundaryCellNumberingPtr_.clear(); + globalPointBoundaryCellsPtr_.clear(); + globalPointTransformedBoundaryCellsPtr_.clear(); + globalPointBoundaryCellsMapPtr_.clear(); } @@ -1954,6 +2063,104 @@ const Foam::mapDistribute& Foam::globalMeshData::globalEdgeSlavesMap() const } +const Foam::globalIndex& Foam::globalMeshData::globalBoundaryFaceNumbering() +const +{ + if (!globalBoundaryFaceNumberingPtr_.valid()) + { + calcGlobalPointBoundaryFaces(); + } + return globalBoundaryFaceNumberingPtr_(); +} + + +const Foam::labelListList& Foam::globalMeshData::globalPointBoundaryFaces() +const +{ + if (!globalPointBoundaryFacesPtr_.valid()) + { + calcGlobalPointBoundaryFaces(); + } + return globalPointBoundaryFacesPtr_(); +} + + +const Foam::labelListList& +Foam::globalMeshData::globalPointTransformedBoundaryFaces() const +{ + if (!globalPointTransformedBoundaryFacesPtr_.valid()) + { + calcGlobalPointBoundaryFaces(); + } + return globalPointTransformedBoundaryFacesPtr_(); +} + + +const Foam::mapDistribute& Foam::globalMeshData::globalPointBoundaryFacesMap() +const +{ + if (!globalPointBoundaryFacesMapPtr_.valid()) + { + calcGlobalPointBoundaryFaces(); + } + return globalPointBoundaryFacesMapPtr_(); +} + + +const Foam::labelList& Foam::globalMeshData::boundaryCells() const +{ + if (!boundaryCellsPtr_.valid()) + { + calcGlobalPointBoundaryCells(); + } + return boundaryCellsPtr_(); +} + + +const Foam::globalIndex& Foam::globalMeshData::globalBoundaryCellNumbering() +const +{ + if (!globalBoundaryCellNumberingPtr_.valid()) + { + calcGlobalPointBoundaryCells(); + } + return globalBoundaryCellNumberingPtr_(); +} + + +const Foam::labelListList& Foam::globalMeshData::globalPointBoundaryCells() +const +{ + if (!globalPointBoundaryCellsPtr_.valid()) + { + calcGlobalPointBoundaryCells(); + } + return globalPointBoundaryCellsPtr_(); +} + + +const Foam::labelListList& +Foam::globalMeshData::globalPointTransformedBoundaryCells() const +{ + if (!globalPointTransformedBoundaryCellsPtr_.valid()) + { + calcGlobalPointBoundaryCells(); + } + return globalPointTransformedBoundaryCellsPtr_(); +} + + +const Foam::mapDistribute& Foam::globalMeshData::globalPointBoundaryCellsMap() +const +{ + if (!globalPointBoundaryCellsMapPtr_.valid()) + { + calcGlobalPointBoundaryCells(); + } + return globalPointBoundaryCellsMapPtr_(); +} + + Foam::autoPtr<Foam::globalIndex> Foam::globalMeshData::mergePoints ( labelList& pointToGlobal, diff --git a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.H b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.H index 94d0cf5715edf4f38063223b1a420a6ff243bf70..650d50638083ce48a634d4ba76dd4b05f54b62d4 100644 --- a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.H +++ b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.H @@ -194,18 +194,22 @@ class globalMeshData mutable autoPtr<mapDistribute> globalEdgeSlavesMapPtr_; - //// Coupled point to boundary faces - // - //mutable autoPtr<globalIndex> globalBoundaryFaceNumberingPtr_; - //mutable autoPtr<labelListList> globalPointBoundaryFacesPtr_; - //mutable autoPtr<mapDistribute> globalPointBoundaryFacesMapPtr_; - // - //// Coupled point to collocated boundary cells - // - //mutable autoPtr<labelList> boundaryCellsPtr_; - //mutable autoPtr<globalIndex> globalBoundaryCellNumberingPtr_; - //mutable autoPtr<labelListList> globalPointBoundaryCellsPtr_; - //mutable autoPtr<mapDistribute> globalPointBoundaryCellsMapPtr_; + // Coupled point to boundary faces + + mutable autoPtr<globalIndex> globalBoundaryFaceNumberingPtr_; + mutable autoPtr<labelListList> globalPointBoundaryFacesPtr_; + mutable autoPtr<labelListList> + globalPointTransformedBoundaryFacesPtr_; + mutable autoPtr<mapDistribute> globalPointBoundaryFacesMapPtr_; + + // Coupled point to collocated boundary cells + + mutable autoPtr<labelList> boundaryCellsPtr_; + mutable autoPtr<globalIndex> globalBoundaryCellNumberingPtr_; + mutable autoPtr<labelListList> globalPointBoundaryCellsPtr_; + mutable autoPtr<labelListList> + globalPointTransformedBoundaryCellsPtr_; + mutable autoPtr<mapDistribute> globalPointBoundaryCellsMapPtr_; // Globally shared point addressing @@ -288,6 +292,18 @@ class globalMeshData void calcGlobalEdgeSlaves() const; + // Global boundary face/cell addressing + + //- Calculate coupled point to uncoupled boundary faces. Local only. + void calcPointBoundaryFaces(labelListList&) const; + + //- Calculate global point to global boundary face addressing. + void calcGlobalPointBoundaryFaces() const; + + //- Calculate global point to global boundary cell addressing. + void calcGlobalPointBoundaryCells() const; + + //- Disallow default bitwise copy construct globalMeshData(const globalMeshData&); @@ -458,7 +474,7 @@ public: const globalIndexAndTransform& globalTransforms() const; //- Helper: synchronise data with transforms - template<class Type, class CombineOp> + template<class Type, class CombineOp, class TransformOp> static void syncData ( List<Type>& pointData, @@ -467,7 +483,7 @@ public: const mapDistribute& slavesMap, const globalIndexAndTransform&, const CombineOp& cop, - const bool isPosition + const TransformOp& top ); //- Helper: synchronise data without transforms @@ -490,13 +506,13 @@ public: const labelListList& globalPointSlaves() const; const labelListList& globalPointTransformedSlaves() const; const mapDistribute& globalPointSlavesMap() const; - //- Helper to synchronise mesh point data - template<class Type, class CombineOp> + //- Helper to synchronise coupled patch point data + template<class Type, class CombineOp, class TransformOp> void syncPointData ( List<Type>& pointData, const CombineOp& cop, - const bool isPosition + const TransformOp& top ) const; // Coupled edge to coupled edges. @@ -506,6 +522,28 @@ public: const labelListList& globalEdgeTransformedSlaves() const; const mapDistribute& globalEdgeSlavesMap() const; + // Coupled point to boundary faces. These are uncoupled boundary + // faces only but include empty patches. + + //- Numbering of boundary faces is face-mesh.nInternalFaces() + const globalIndex& globalBoundaryFaceNumbering() const; + const labelListList& globalPointBoundaryFaces() const; + const labelListList& globalPointTransformedBoundaryFaces() + const; + const mapDistribute& globalPointBoundaryFacesMap() const; + + // Coupled point to boundary cell + + //- From boundary cell to mesh cell + const labelList& boundaryCells() const; + + //- Numbering of boundary cells is according to boundaryCells() + const globalIndex& globalBoundaryCellNumbering() const; + const labelListList& globalPointBoundaryCells() const; + const labelListList& globalPointTransformedBoundaryCells() + const; + const mapDistribute& globalPointBoundaryCellsMap() const; + // Other diff --git a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshDataTemplates.C b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshDataTemplates.C index 93005abcac15386d791112c7c5a167d467c78351..7d31c61d636ba778cf2b39bc7bbbbbac06a829d5 100644 --- a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshDataTemplates.C +++ b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshDataTemplates.C @@ -29,7 +29,7 @@ License // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template<class Type, class CombineOp> +template<class Type, class CombineOp, class TransformOp> void Foam::globalMeshData::syncData ( List<Type>& elems, @@ -38,11 +38,11 @@ void Foam::globalMeshData::syncData const mapDistribute& slavesMap, const globalIndexAndTransform& transforms, const CombineOp& cop, - const bool isPosition + const TransformOp& top ) { // Pull slave data onto master - slavesMap.distribute(transforms, elems, isPosition); + slavesMap.distribute(transforms, elems, top); // Combine master data with slave data forAll(slaves, i) @@ -85,7 +85,7 @@ void Foam::globalMeshData::syncData transforms, elems.size(), elems, - isPosition + top ); } @@ -143,12 +143,12 @@ void Foam::globalMeshData::syncData } -template<class Type, class CombineOp> +template<class Type, class CombineOp, class TransformOp> void Foam::globalMeshData::syncPointData ( List<Type>& pointData, const CombineOp& cop, - const bool isPosition + const TransformOp& top ) const { if (pointData.size() != mesh_.nPoints()) @@ -171,7 +171,7 @@ void Foam::globalMeshData::syncPointData globalPointSlavesMap(), globalTransforms(), cop, - isPosition + top ); // Extract back onto mesh diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.C index 95c2d1d2321fa152da5c1793b14dd94c49882ca5..b8ed0276c71803919d1e0dc18280da0acbb2008f 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.C +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.C @@ -37,6 +37,99 @@ defineTypeNameAndDebug(Foam::mapDistribute, 0); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // +template<> +void Foam::mapDistribute::transform::operator() +( + const vectorTensorTransform&, + const bool, + List<label>& +) const +{} +template<> +void Foam::mapDistribute::transform::operator() +( + const coupledPolyPatch&, + UList<label>& +) const +{} +template<> +void Foam::mapDistribute::transform::operator() +( + const coupledPolyPatch&, + Map<label>& +) const +{} +template<> +void Foam::mapDistribute::transform::operator() +( + const coupledPolyPatch&, + EdgeMap<label>& +) const +{} + + +template<> +void Foam::mapDistribute::transform::operator() +( + const vectorTensorTransform&, + const bool, + List<scalar>& +) const +{} +template<> +void Foam::mapDistribute::transform::operator() +( + const coupledPolyPatch&, + UList<scalar>& +) const +{} +template<> +void Foam::mapDistribute::transform::operator() +( + const coupledPolyPatch&, + Map<scalar>& +) const +{} +template<> +void Foam::mapDistribute::transform::operator() +( + const coupledPolyPatch&, + EdgeMap<scalar>& +) const +{} + + +template<> +void Foam::mapDistribute::transform::operator() +( + const vectorTensorTransform&, + const bool, + List<bool>& +) const +{} +template<> +void Foam::mapDistribute::transform::operator() +( + const coupledPolyPatch&, + UList<bool>& +) const +{} +template<> +void Foam::mapDistribute::transform::operator() +( + const coupledPolyPatch&, + Map<bool>& +) const +{} +template<> +void Foam::mapDistribute::transform::operator() +( + const coupledPolyPatch&, + EdgeMap<bool>& +) const +{} + + Foam::List<Foam::labelPair> Foam::mapDistribute::schedule ( const labelListList& subMap, @@ -535,101 +628,6 @@ void Foam::mapDistribute::exchangeAddressing } -template<> -void Foam::mapDistribute::applyTransforms -( - const globalIndexAndTransform& globalTransforms, - List<point>& field, - const bool isPosition -) const -{ - const List<vectorTensorTransform>& totalTransform = - globalTransforms.transformPermutations(); - - forAll(totalTransform, trafoI) - { - const vectorTensorTransform& vt = totalTransform[trafoI]; - const labelList& elems = transformElements_[trafoI]; - label n = transformStart_[trafoI]; - - // Could be optimised to avoid memory allocations - - if (isPosition) - { - Field<point> transformFld - ( - vt.transformPosition(Field<point>(field, elems)) - ); - forAll(transformFld, i) - { - //cop(field[n++], transformFld[i]); - field[n++] = transformFld[i]; - } - } - else - { - Field<point> transformFld - ( - transform(vt.R(), Field<point>(field, elems)) - ); - - forAll(transformFld, i) - { - //cop(field[n++], transformFld[i]); - field[n++] = transformFld[i]; - } - } - } -} - - -template<> -void Foam::mapDistribute::applyInverseTransforms -( - const globalIndexAndTransform& globalTransforms, - List<point>& field, - const bool isPosition -) const -{ - const List<vectorTensorTransform>& totalTransform = - globalTransforms.transformPermutations(); - - forAll(totalTransform, trafoI) - { - const vectorTensorTransform& vt = totalTransform[trafoI]; - const labelList& elems = transformElements_[trafoI]; - label n = transformStart_[trafoI]; - - // Could be optimised to avoid memory allocations - - if (isPosition) - { - Field<point> transformFld - ( - vt.invTransformPosition - ( - SubField<point>(field, elems.size(), n) - ) - ); - forAll(transformFld, i) - { - field[elems[i]] = transformFld[i]; - } - } - else - { - Field<point> transformFld(SubField<point>(field, elems.size(), n)); - transform(transformFld, vt.R().T(), transformFld); - - forAll(transformFld, i) - { - field[elems[i]] = transformFld[i]; - } - } - } -} - - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // //- Construct null diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.H b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.H index 99a31d3d7d92a05d210bc9e2266693449a4b79ff..b5c31754ff15af2c0db7085d661ca05e24251af2 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.H +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.H @@ -127,12 +127,14 @@ SourceFiles #ifndef mapDistribute_H #define mapDistribute_H +#include "transformList.H" #include "labelList.H" #include "labelPair.H" #include "Pstream.H" #include "boolList.H" #include "Map.H" -#include "point.H" +#include "vectorTensorTransform.H" +#include "coupledPolyPatch.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -217,31 +219,124 @@ class mapDistribute template<class T> void applyDummyTransforms(List<T>& field) const; - template<class T> //, class CombineOp> + template<class T, class TransformOp> void applyTransforms ( const globalIndexAndTransform& globalTransforms, List<T>& field, - const bool isPosition - //const CombineOp& cop + const TransformOp& top ) const; //- Helper function: copy transformElements without transformation template<class T> void applyDummyInverseTransforms(List<T>& field) const; - template<class T> //, class CombineOp> + template<class T, class TransformOp> void applyInverseTransforms ( const globalIndexAndTransform& globalTransforms, List<T>& field, - const bool isPosition - //const CombineOp& cop + const TransformOp& top ) const; public: + // Public classes + + //- Default transformation behaviour + class transform + { + public: + + template<class T> + void operator() + ( + const vectorTensorTransform& vt, + const bool forward, + List<T>& fld + ) const + { + if (forward) + { + transformList(vt.R(), fld); + } + else + { + transformList(vt.R().T(), fld); + } + } + + //- Transform patch-based field + template<class T> + void operator()(const coupledPolyPatch& cpp, UList<T>& fld) const + { + if (!cpp.parallel()) + { + transformList(cpp.forwardT(), fld); + } + } + + //- Transform sparse field + template<class T, template<class> class Container> + void operator()(const coupledPolyPatch& cpp, Container<T>& map) + const + { + if (!cpp.parallel()) + { + transformList(cpp.forwardT(), map); + } + } + }; + + //- Default transformation behaviour for position + class transformPosition + { + public: + + void operator() + ( + const vectorTensorTransform& vt, + const bool forward, + List<point>& fld + ) const + { + pointField pfld(fld.xfer()); + if (forward) + { + fld = vt.transformPosition(pfld); + } + else + { + fld = vt.invTransformPosition(pfld); + } + } + //- Transform patch-based field + void operator()(const coupledPolyPatch& cpp, pointField& fld) const + { + cpp.transformPosition(fld); + } + template<template<class> class Container> + void operator()(const coupledPolyPatch& cpp, Container<point>& map) + const + { + Field<point> fld(map.size()); + label i = 0; + forAllConstIter(typename Container<point>, map, iter) + { + fld[i++] = iter(); + } + cpp.transformPosition(fld); + i = 0; + forAllIter(typename Container<point>, map, iter) + { + iter() = fld[i++]; + } + } + }; + + + // Declare name of the class and its debug switch ClassName("mapDistribute"); @@ -456,12 +551,12 @@ public: const; //- Same but with transforms - template<class T> + template<class T, class TransformOp> void distribute ( const globalIndexAndTransform&, List<T>& fld, - const bool isPosition + const TransformOp& top ) const; //- Reverse distribute data using default commsType. @@ -474,13 +569,13 @@ public: ) const; //- Same but with transforms - template<class T> + template<class T, class TransformOp> void reverseDistribute ( const globalIndexAndTransform&, const label constructSize, List<T>& fld, - const bool isPosition + const TransformOp& top ) const; //- Reverse distribute data using default commsType. @@ -496,14 +591,14 @@ public: ) const; //- Same but with transforms - template<class T> + template<class T, class TransformOp> void reverseDistribute ( const globalIndexAndTransform&, const label constructSize, const T& nullValue, List<T>& fld, - const bool isPosition + const TransformOp& top ) const; //- Do all sends using PstreamBuffers @@ -531,24 +626,85 @@ public: }; -//- Specialisation for transforms that can apply positional transform + +template<> +void mapDistribute::transform::operator() +( + const vectorTensorTransform&, + const bool, + List<label>& +) const; +template<> +void mapDistribute::transform::operator() +( + const coupledPolyPatch&, + UList<label>& +) const; +template<> +void mapDistribute::transform::operator() +( + const coupledPolyPatch&, + Map<label>& +) const; +template<> +void mapDistribute::transform::operator() +( + const coupledPolyPatch&, + EdgeMap<label>& +) const; + +template<> +void mapDistribute::transform::operator() +( + const coupledPolyPatch&, + UList<scalar>& +) const; template<> -void mapDistribute::applyTransforms +void mapDistribute::transform::operator() ( - const globalIndexAndTransform& globalTransforms, - List<point>& field, - const bool isPosition - //const CombineOp& cop + const vectorTensorTransform&, + const bool, + List<scalar>& +) const; +template<> +void mapDistribute::transform::operator() +( + const coupledPolyPatch&, + Map<scalar>& +) const; +template<> +void mapDistribute::transform::operator() +( + const coupledPolyPatch&, + EdgeMap<scalar>& ) const; -template<> //, class CombineOp> -void mapDistribute::applyInverseTransforms +template<> +void mapDistribute::transform::operator() +( + const coupledPolyPatch& cpp, + UList<bool>& fld +) const; +template<> +void mapDistribute::transform::operator() ( - const globalIndexAndTransform& globalTransforms, - List<point>& field, - const bool isPosition - //const CombineOp& cop + const vectorTensorTransform&, + const bool, + List<bool>& ) const; +template<> +void mapDistribute::transform::operator() +( + const coupledPolyPatch&, + Map<bool>& +) const; +template<> +void mapDistribute::transform::operator() +( + const coupledPolyPatch&, + EdgeMap<bool>& +) const; + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C index f72b83dd458a96308d95e716804328e3bc9a88a8..d22b3abaa3c76d90c342489977177427475a6434 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C @@ -812,30 +812,14 @@ void Foam::mapDistribute::applyDummyInverseTransforms(List<T>& field) const // Calculate transformed elements. -template<class T> //, class CombineOp> +template<class T, class TransformOp> //, class CombineOp> void Foam::mapDistribute::applyTransforms ( const globalIndexAndTransform& globalTransforms, List<T>& field, - const bool isPosition - //const CombineOp& cop + const TransformOp& top ) const { - if (isPosition) - { - FatalErrorIn - ( - "mapDistribute::applyTransforms\n" - "(\n" - " const globalIndexAndTransform&,\n" - " List<T>&,\n" - " const bool\n" - ") const\n" - ) << "It does not make sense to apply position transformation" - << " for anything else than pointFields." - << abort(FatalError); - } - const List<vectorTensorTransform>& totalTransform = globalTransforms.transformPermutations(); @@ -846,7 +830,8 @@ void Foam::mapDistribute::applyTransforms label n = transformStart_[trafoI]; // Could be optimised to avoid memory allocations - Field<T> transformFld(transform(vt.R(), Field<T>(field, elems))); + List<T> transformFld(UIndirectList<T>(field, elems)); + top(vt, true, transformFld); forAll(transformFld, i) { @@ -858,30 +843,14 @@ void Foam::mapDistribute::applyTransforms // Calculate transformed elements. -template<class T> //, class CombineOp> +template<class T, class TransformOp> //, class CombineOp> void Foam::mapDistribute::applyInverseTransforms ( const globalIndexAndTransform& globalTransforms, List<T>& field, - const bool isPosition - //const CombineOp& cop + const TransformOp& top ) const { - if (isPosition) - { - FatalErrorIn - ( - "mapDistribute::applyInverseTransforms\n" - "(\n" - " const globalIndexAndTransform&,\n" - " List<T>&,\n" - " const bool\n" - ") const\n" - ) << "It does not make sense to apply position transformation" - << " for anything else than pointFields." - << abort(FatalError); - } - const List<vectorTensorTransform>& totalTransform = globalTransforms.transformPermutations(); @@ -892,8 +861,8 @@ void Foam::mapDistribute::applyInverseTransforms label n = transformStart_[trafoI]; // Could be optimised to avoid memory allocations - Field<T> transformFld(SubField<T>(field, elems.size(), n)); - transform(transformFld, vt.R().T(), transformFld); + List<T> transformFld(SubList<T>(field, elems.size(), n)); + top(vt, false, transformFld); forAll(transformFld, i) { @@ -1073,54 +1042,54 @@ void Foam::mapDistribute::reverseDistribute //- Distribute data using default commsType. -template<class T> +template<class T, class TransformOp> void Foam::mapDistribute::distribute ( const globalIndexAndTransform& git, List<T>& fld, - const bool isPosition + const TransformOp& top ) const { // Distribute. Leave out dummy transforms since we're doing them ourselves distribute(fld, false); // Do transforms - applyTransforms(git, fld, isPosition); //, eqOp<T>()); + applyTransforms(git, fld, top); } -template<class T> +template<class T, class TransformOp> void Foam::mapDistribute::reverseDistribute ( const globalIndexAndTransform& git, const label constructSize, List<T>& fld, - const bool isPosition + const TransformOp& top ) const { // Fill slots with reverse-transformed data. Note that it also copies // back into the non-remote part of fld even though these values are not // used. - applyInverseTransforms(git, fld, isPosition); //, eqOp<T>()); + applyInverseTransforms(git, fld, top); // And send back (the remote slots). Disable dummy transformations. reverseDistribute(constructSize, fld, false); } -template<class T> +template<class T, class TransformOp> void Foam::mapDistribute::reverseDistribute ( const globalIndexAndTransform& git, const label constructSize, const T& nullValue, List<T>& fld, - const bool isPosition + const TransformOp& top ) const { // Fill slots with reverse-transformed data Note that it also copies // back into the non-remote part of fld even though these values are not // used. - applyInverseTransforms(git, fld, isPosition); //, eqOp<T>()); + applyInverseTransforms(git, fld, top); //, eqOp<T>()); // And send back (the remote slots) Disable dummy transformations. reverseDistribute(constructSize, nullValue, fld, false); diff --git a/src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.C b/src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.C index 51b6ee7a642f6c3afa0d822ef449267c689e4d0d..19a252964e89cd145dd7bd907a29eb91ed67ddba 100644 --- a/src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.C +++ b/src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.C @@ -25,77 +25,6 @@ License #include "syncTools.H" -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -template<> -void Foam::syncTools::transform::operator() -( - const coupledPolyPatch&, - Field<label>& -) const -{} -template<> -void Foam::syncTools::transform::operator() -( - const coupledPolyPatch&, - Map<label>& -) const -{} -template<> -void Foam::syncTools::transform::operator() -( - const coupledPolyPatch&, - EdgeMap<label>& -) const -{} - - -template<> -void Foam::syncTools::transform::operator() -( - const coupledPolyPatch&, - Field<scalar>& -) const -{} -template<> -void Foam::syncTools::transform::operator() -( - const coupledPolyPatch&, - Map<scalar>& -) const -{} -template<> -void Foam::syncTools::transform::operator() -( - const coupledPolyPatch&, - EdgeMap<scalar>& -) const -{} - - -template<> -void Foam::syncTools::transform::operator() -( - const coupledPolyPatch&, - Field<bool>& -) const -{} -template<> -void Foam::syncTools::transform::operator() -( - const coupledPolyPatch&, - Map<bool>& -) const -{} -template<> -void Foam::syncTools::transform::operator() -( - const coupledPolyPatch&, - EdgeMap<bool>& -) const -{} - - // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // Determines for every point whether it is coupled and if so sets only one. diff --git a/src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.H b/src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.H index f1572bd4ac7dcbe62e26ef6069c03ec3d4313526..01becb8b99dc548a5dfc8816b97cc092072dd373 100644 --- a/src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.H +++ b/src/OpenFOAM/meshes/polyMesh/syncTools/syncTools.H @@ -47,7 +47,7 @@ SourceFiles #include "PackedBoolList.H" #include "polyMesh.H" #include "coupledPolyPatch.H" -#include "transformList.H" +#include "mapDistribute.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -87,59 +87,6 @@ class syncTools public: - // Public classes - - class transform - { - public: - //- Transform patch-based field - template<class T> - void operator()(const coupledPolyPatch& cpp, Field<T>& fld) const - { - if (!cpp.parallel()) - { - transformList(cpp.forwardT(), fld); - } - } - - //- Transform sparse field - template<class T, template<class> class Container> - void operator()(const coupledPolyPatch& cpp, Container<T>& map) - const - { - if (!cpp.parallel()) - { - transformList(cpp.forwardT(), map); - } - } - }; - - class transformPosition - { - public: - void operator()(const coupledPolyPatch& cpp, pointField& fld) const - { - cpp.transformPosition(fld); - } - template<template<class> class Container> - void operator()(const coupledPolyPatch& cpp, Container<point>& map) - const - { - Field<point> fld(map.size()); - label i = 0; - forAllConstIter(typename Container<point>, map, iter) - { - fld[i++] = iter(); - } - cpp.transformPosition(fld); - i = 0; - forAllIter(typename Container<point>, map, iter) - { - iter() = fld[i++]; - } - } - }; - // Basic routines with user-supplied transformation. Preferably // use specialisations below. @@ -163,41 +110,41 @@ public: const CombineOp& cop, const TransformOp& top ); -// -// //- Synchronize values on all mesh points. -// template <class T, class CombineOp, class TransformOp> -// static void syncPointList -// ( -// const polyMesh&, -// UList<T>&, -// const CombineOp& cop, -// const T& nullValue, -// const TransformOp& top -// ); -// -// //- Synchronize values on selected mesh points. -// template <class T, class CombineOp, class TransformOp> -// static void syncPointList -// ( -// const polyMesh&, -// const labelList& meshPoints, -// UList<T>&, -// const CombineOp& cop, -// const T& nullValue, -// const TransformOp& top -// ); -// -// //- Synchronize values on all mesh edges. -// template <class T, class CombineOp, class TransformOp> -// static void syncEdgeList -// ( -// const polyMesh&, -// UList<T>&, -// const CombineOp& cop, -// const T& nullValue, -// const TransformOp& top -// ); -// + + //- Synchronize values on all mesh points. + template <class T, class CombineOp, class TransformOp> + static void syncPointList + ( + const polyMesh&, + List<T>&, + const CombineOp& cop, + const T& nullValue, + const TransformOp& top + ); + + //- Synchronize values on selected mesh points. + template <class T, class CombineOp, class TransformOp> + static void syncPointList + ( + const polyMesh&, + const labelList& meshPoints, + List<T>&, + const CombineOp& cop, + const T& nullValue, + const TransformOp& top + ); + + //- Synchronize values on all mesh edges. + template <class T, class CombineOp, class TransformOp> + static void syncEdgeList + ( + const polyMesh&, + List<T>&, + const CombineOp& cop, + const T& nullValue, + const TransformOp& top + ); + //- Synchronize values on boundary faces only. template <class T, class CombineOp, class TransformOp> static void syncBoundaryFaceList @@ -219,7 +166,17 @@ public: List<T>& l, const CombineOp& cop, const T& nullValue - ); + ) + { + syncPointList + ( + mesh, + l, + cop, + nullValue, + mapDistribute::transform() + ); + } //- Synchronize locations on all mesh points. template <class CombineOp> @@ -229,7 +186,17 @@ public: List<point>& l, const CombineOp& cop, const point& nullValue - ); + ) + { + syncPointList + ( + mesh, + l, + cop, + nullValue, + mapDistribute::transformPosition() + ); + } //- Synchronize values on selected mesh points. template <class T, class CombineOp> @@ -237,10 +204,21 @@ public: ( const polyMesh& mesh, const labelList& meshPoints, - UList<T>& l, + List<T>& l, const CombineOp& cop, const T& nullValue - ); + ) + { + syncPointList + ( + mesh, + meshPoints, + l, + cop, + nullValue, + mapDistribute::transform() + ); + } //- Synchronize locations on selected mesh points. template <class CombineOp> @@ -248,10 +226,21 @@ public: ( const polyMesh& mesh, const labelList& meshPoints, - UList<point>& l, + List<point>& l, const CombineOp& cop, const point& nullValue - ); + ) + { + syncPointList + ( + mesh, + meshPoints, + l, + cop, + nullValue, + mapDistribute::transformPosition() + ); + } // Synchronise edge-wise data @@ -261,20 +250,40 @@ public: static void syncEdgeList ( const polyMesh& mesh, - UList<T>& l, + List<T>& l, const CombineOp& cop, const T& nullValue - ); + ) + { + syncEdgeList + ( + mesh, + l, + cop, + nullValue, + mapDistribute::transform() + ); + } //- Synchronize values on all mesh edges. template <class CombineOp> static void syncEdgePositions ( const polyMesh& mesh, - UList<point>& l, + List<point>& l, const CombineOp& cop, const point& nullValue - ); + ) + { + syncEdgeList + ( + mesh, + l, + cop, + nullValue, + mapDistribute::transformPosition() + ); + } // Synchronise face-wise data @@ -288,7 +297,7 @@ public: const CombineOp& cop ) { - syncBoundaryFaceList(mesh, l, cop, transform()); + syncBoundaryFaceList(mesh, l, cop, mapDistribute::transform()); } //- Synchronize locations on boundary faces only. @@ -300,7 +309,13 @@ public: const CombineOp& cop ) { - syncBoundaryFaceList(mesh, l, cop, transformPosition()); + syncBoundaryFaceList + ( + mesh, + l, + cop, + mapDistribute::transformPosition() + ); } //- Synchronize values on all mesh faces. @@ -319,7 +334,13 @@ public: mesh.nInternalFaces() ); - syncBoundaryFaceList(mesh, bndValues, cop, transform()); + syncBoundaryFaceList + ( + mesh, + bndValues, + cop, + mapDistribute::transform() + ); } //- Synchronize locations on all mesh faces. @@ -337,7 +358,13 @@ public: mesh.nFaces()-mesh.nInternalFaces(), mesh.nInternalFaces() ); - syncBoundaryFaceList(mesh, bndValues, cop, transformPosition()); + syncBoundaryFaceList + ( + mesh, + bndValues, + cop, + mapDistribute::transformPosition() + ); } //- Swap coupled boundary face values. @@ -348,7 +375,13 @@ public: UList<T>& l ) { - syncBoundaryFaceList(mesh, l, eqOp<T>(), transform()); + syncBoundaryFaceList + ( + mesh, + l, + eqOp<T>(), + mapDistribute::transform() + ); } //- Swap coupled positions. @@ -359,7 +392,13 @@ public: UList<T>& l ) { - syncBoundaryFaceList(mesh, l, eqOp<T>(), transformPosition()); + syncBoundaryFaceList + ( + mesh, + l, + eqOp<T>(), + mapDistribute::transformPosition() + ); } //- Swap coupled face values. @@ -376,7 +415,13 @@ public: mesh.nFaces()-mesh.nInternalFaces(), mesh.nInternalFaces() ); - syncBoundaryFaceList(mesh, bndValues, eqOp<T>(), transform()); + syncBoundaryFaceList + ( + mesh, + bndValues, + eqOp<T>(), + mapDistribute::transform() + ); } // Sparse versions @@ -390,7 +435,7 @@ public: const CombineOp& cop ) { - syncPointMap(mesh, l, cop, transform()); + syncPointMap(mesh, l, cop, mapDistribute::transform()); } //- Synchronize locations on selected points. @@ -402,7 +447,7 @@ public: const CombineOp& cop ) { - syncPointMap(mesh, l, cop, transformPosition()); + syncPointMap(mesh, l, cop, mapDistribute::transformPosition()); } //- Synchronize values on selected edges. Edges are represented @@ -416,7 +461,7 @@ public: const CombineOp& cop ) { - syncEdgeMap(mesh, l, cop, transform()); + syncEdgeMap(mesh, l, cop, mapDistribute::transform()); } //- Synchronize locations on selected edges. @@ -428,7 +473,7 @@ public: const CombineOp& cop ) { - syncEdgeMap(mesh, l, cop, transformPosition()); + syncEdgeMap(mesh, l, cop, mapDistribute::transformPosition()); } // PackedList versions @@ -480,65 +525,6 @@ public: }; -template<> -void syncTools::transform::operator() -( - const coupledPolyPatch&, - Field<label>& -) const; -template<> -void syncTools::transform::operator() -( - const coupledPolyPatch&, - Map<label>& -) const; -template<> -void syncTools::transform::operator() -( - const coupledPolyPatch&, - EdgeMap<label>& -) const; - - -template<> -void syncTools::transform::operator() -( - const coupledPolyPatch&, - Field<scalar>& -) const; -template<> -void syncTools::transform::operator() -( - const coupledPolyPatch&, - Map<scalar>& -) const; -template<> -void syncTools::transform::operator() -( - const coupledPolyPatch&, - EdgeMap<scalar>& -) const; - -template<> -void syncTools::transform::operator() -( - const coupledPolyPatch& cpp, - Field<bool>& fld -) const; -template<> -void syncTools::transform::operator() -( - const coupledPolyPatch&, - Map<bool>& -) const; -template<> -void syncTools::transform::operator() -( - const coupledPolyPatch&, - EdgeMap<bool>& -) const; - - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/OpenFOAM/meshes/polyMesh/syncTools/syncToolsTemplates.C b/src/OpenFOAM/meshes/polyMesh/syncTools/syncToolsTemplates.C index d135e2b73abe7ff21dcec8b78381ca4f9ec253fc..23356b7069b78497338a1a22000da1ba8653c84f 100644 --- a/src/OpenFOAM/meshes/polyMesh/syncTools/syncToolsTemplates.C +++ b/src/OpenFOAM/meshes/polyMesh/syncTools/syncToolsTemplates.C @@ -764,7 +764,7 @@ void Foam::syncTools::syncEdgeMap //void Foam::syncTools::syncPointList //( // const polyMesh& mesh, -// UList<T>& pointValues, +// List<T>& pointValues, // const CombineOp& cop, // const T& nullValue, // const TransformOp& top @@ -775,7 +775,7 @@ void Foam::syncTools::syncEdgeMap // FatalErrorIn // ( // "syncTools<class T, class CombineOp>::syncPointList" -// "(const polyMesh&, UList<T>&, const CombineOp&, const T&" +// "(const polyMesh&, List<T>&, const CombineOp&, const T&" // ", const bool)" // ) << "Number of values " << pointValues.size() // << " is not equal to the number of points in the mesh " @@ -941,7 +941,7 @@ void Foam::syncTools::syncEdgeMap //( // const polyMesh& mesh, // const labelList& meshPoints, -// UList<T>& pointValues, +// List<T>& pointValues, // const CombineOp& cop, // const T& nullValue, // const TransformOp& top @@ -952,7 +952,7 @@ void Foam::syncTools::syncEdgeMap // FatalErrorIn // ( // "syncTools<class T, class CombineOp>::syncPointList" -// "(const polyMesh&, const labelList&, UList<T>&, const CombineOp&" +// "(const polyMesh&, const labelList&, List<T>&, const CombineOp&" // ", const T&, const bool)" // ) << "Number of values " << pointValues.size() // << " is not equal to the number of points " @@ -986,13 +986,14 @@ void Foam::syncTools::syncEdgeMap // } //} -template <class T, class CombineOp> +template <class T, class CombineOp, class TransformOp> void Foam::syncTools::syncPointList ( const polyMesh& mesh, List<T>& pointValues, const CombineOp& cop, - const T& nullValue + const T& nullValue, + const TransformOp& top ) { if (pointValues.size() != mesh.nPoints()) @@ -1000,48 +1001,50 @@ void Foam::syncTools::syncPointList FatalErrorIn ( "syncTools<class T, class CombineOp>::syncPointList" - "(const polyMesh&, UList<T>&, const CombineOp&, const T&)" + "(const polyMesh&, List<T>&, const CombineOp&, const T&" + ", const bool)" ) << "Number of values " << pointValues.size() << " is not equal to the number of points in the mesh " << mesh.nPoints() << abort(FatalError); } - mesh.globalData().syncPointData(pointValues, cop, false); + mesh.globalData().syncPointData(pointValues, cop, top); } -template <class CombineOp> -void Foam::syncTools::syncPointPositions -( - const polyMesh& mesh, - List<point>& pointValues, - const CombineOp& cop, - const point& nullValue -) -{ - if (pointValues.size() != mesh.nPoints()) - { - FatalErrorIn - ( - "syncTools<class CombineOp>::syncPointPositions" - "(const polyMesh&, List<point>&, const CombineOp&, const point&)" - ) << "Number of values " << pointValues.size() - << " is not equal to the number of points in the mesh " - << mesh.nPoints() << abort(FatalError); - } - - mesh.globalData().syncPointData(pointValues, cop, true); -} +//template <class CombineOp> +//void Foam::syncTools::syncPointPositions +//( +// const polyMesh& mesh, +// List<point>& pointValues, +// const CombineOp& cop, +// const point& nullValue +//) +//{ +// if (pointValues.size() != mesh.nPoints()) +// { +// FatalErrorIn +// ( +// "syncTools<class CombineOp>::syncPointPositions" +// "(const polyMesh&, List<point>&, const CombineOp&, const point&)" +// ) << "Number of values " << pointValues.size() +// << " is not equal to the number of points in the mesh " +// << mesh.nPoints() << abort(FatalError); +// } +// +// mesh.globalData().syncPointData(pointValues, cop, true); +//} -template <class T, class CombineOp> +template <class T, class CombineOp, class TransformOp> void Foam::syncTools::syncPointList ( const polyMesh& mesh, const labelList& meshPoints, - UList<T>& pointValues, + List<T>& pointValues, const CombineOp& cop, - const T& nullValue + const T& nullValue, + const TransformOp& top ) { if (pointValues.size() != meshPoints.size()) @@ -1049,7 +1052,7 @@ void Foam::syncTools::syncPointList FatalErrorIn ( "syncTools<class T, class CombineOp>::syncPointList" - "(const polyMesh&, UList<T>&, const CombineOp&, const T&)" + "(const polyMesh&, List<T>&, const CombineOp&, const T&)" ) << "Number of values " << pointValues.size() << " is not equal to the number of meshPoints " << meshPoints.size() << abort(FatalError); @@ -1078,7 +1081,7 @@ void Foam::syncTools::syncPointList gd.globalPointSlavesMap(), gd.globalTransforms(), cop, - false //position? + top ); forAll(meshPoints, i) @@ -1093,72 +1096,74 @@ void Foam::syncTools::syncPointList } -template <class CombineOp> -void Foam::syncTools::syncPointPositions -( - const polyMesh& mesh, - const labelList& meshPoints, - UList<point>& pointValues, - const CombineOp& cop, - const point& nullValue -) -{ - if (pointValues.size() != meshPoints.size()) - { - FatalErrorIn - ( - "syncTools<class CombineOp>::syncPointList" - "(const polyMesh&, UList<point>&, const CombineOp&, const point&)" - ) << "Number of values " << pointValues.size() - << " is not equal to the number of meshPoints " - << meshPoints.size() << abort(FatalError); - } - const globalMeshData& gd = mesh.globalData(); - const indirectPrimitivePatch& cpp = gd.coupledPatch(); - const Map<label>& mpm = cpp.meshPointMap(); - - List<point> cppFld(cpp.nPoints(), nullValue); - - forAll(meshPoints, i) - { - label pointI = meshPoints[i]; - Map<label>::const_iterator iter = mpm.find(pointI); - if (iter != mpm.end()) - { - cppFld[iter()] = pointValues[i]; - } - } - - globalMeshData::syncData - ( - cppFld, - gd.globalPointSlaves(), - gd.globalPointTransformedSlaves(), - gd.globalPointSlavesMap(), - gd.globalTransforms(), - cop, - true //position? - ); - - forAll(meshPoints, i) - { - label pointI = meshPoints[i]; - Map<label>::const_iterator iter = mpm.find(pointI); - if (iter != mpm.end()) - { - pointValues[i] = cppFld[iter()]; - } - } -} +//template <class CombineOp> +//void Foam::syncTools::syncPointPositions +//( +// const polyMesh& mesh, +// const labelList& meshPoints, +// List<point>& pointValues, +// const CombineOp& cop, +// const point& nullValue +//) +//{ +// if (pointValues.size() != meshPoints.size()) +// { +// FatalErrorIn +// ( +// "syncTools<class CombineOp>::syncPointList" +// "(const polyMesh&, List<point>&, const CombineOp&, const point&)" +// ) << "Number of values " << pointValues.size() +// << " is not equal to the number of meshPoints " +// << meshPoints.size() << abort(FatalError); +// } +// const globalMeshData& gd = mesh.globalData(); +// const indirectPrimitivePatch& cpp = gd.coupledPatch(); +// const Map<label>& mpm = cpp.meshPointMap(); +// +// List<point> cppFld(cpp.nPoints(), nullValue); +// +// forAll(meshPoints, i) +// { +// label pointI = meshPoints[i]; +// Map<label>::const_iterator iter = mpm.find(pointI); +// if (iter != mpm.end()) +// { +// cppFld[iter()] = pointValues[i]; +// } +// } +// +// globalMeshData::syncData +// ( +// cppFld, +// gd.globalPointSlaves(), +// gd.globalPointTransformedSlaves(), +// gd.globalPointSlavesMap(), +// gd.globalTransforms(), +// cop, +// true, //position? +// mapDistribute::transform() // not used +// ); +// +// forAll(meshPoints, i) +// { +// label pointI = meshPoints[i]; +// Map<label>::const_iterator iter = mpm.find(pointI); +// if (iter != mpm.end()) +// { +// pointValues[i] = cppFld[iter()]; +// } +// } +//} -template <class T, class CombineOp> +template <class T, class CombineOp, class TransformOp> void Foam::syncTools::syncEdgeList ( const polyMesh& mesh, - UList<T>& edgeValues, + List<T>& edgeValues, const CombineOp& cop, - const T& nullValue + const T& nullValue, + const TransformOp& top ) { if (edgeValues.size() != mesh.nEdges()) @@ -1166,7 +1171,7 @@ void Foam::syncTools::syncEdgeList FatalErrorIn ( "syncTools<class T, class CombineOp>::syncEdgeList" - "(const polyMesh&, UList<T>&, const CombineOp&, const T&)" + "(const polyMesh&, List<T>&, const CombineOp&, const T&)" ) << "Number of values " << edgeValues.size() << " is not equal to the number of edges in the mesh " << mesh.nEdges() << abort(FatalError); @@ -1187,7 +1192,7 @@ void Foam::syncTools::syncEdgeList edgeMap, git, cop, - false //position? + top ); // Extract back onto mesh @@ -1198,50 +1203,51 @@ void Foam::syncTools::syncEdgeList } -template <class CombineOp> -void Foam::syncTools::syncEdgePositions -( - const polyMesh& mesh, - UList<point>& edgeValues, - const CombineOp& cop, - const point& nullValue -) -{ - if (edgeValues.size() != mesh.nEdges()) - { - FatalErrorIn - ( - "syncTools<class CombineOp>::syncEdgePositions" - "(const polyMesh&, UList<point>&, const CombineOp&, const point&)" - ) << "Number of values " << edgeValues.size() - << " is not equal to the number of edges in the mesh " - << mesh.nEdges() << abort(FatalError); - } - - 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)); - - globalMeshData::syncData - ( - cppFld, - gd.globalEdgeSlaves(), - gd.globalEdgeTransformedSlaves(), - map, - git, - cop, - true //position? - ); - - // Extract back onto mesh - forAll(meshEdges, i) - { - edgeValues[meshEdges[i]] = cppFld[i]; - } -} +//template <class CombineOp> +//void Foam::syncTools::syncEdgePositions +//( +// const polyMesh& mesh, +// List<point>& edgeValues, +// const CombineOp& cop, +// const point& nullValue +//) +//{ +// if (edgeValues.size() != mesh.nEdges()) +// { +// FatalErrorIn +// ( +// "syncTools<class CombineOp>::syncEdgePositions" +// "(const polyMesh&, List<point>&, const CombineOp&, const point&)" +// ) << "Number of values " << edgeValues.size() +// << " is not equal to the number of edges in the mesh " +// << mesh.nEdges() << abort(FatalError); +// } +// +// 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)); +// +// globalMeshData::syncData +// ( +// cppFld, +// gd.globalEdgeSlaves(), +// gd.globalEdgeTransformedSlaves(), +// map, +// git, +// cop, +// true, //position? +// mapDistribute::transform() // not used +// ); +// +// // Extract back onto mesh +// forAll(meshEdges, i) +// { +// edgeValues[meshEdges[i]] = cppFld[i]; +// } +//} template <class T, class CombineOp, class TransformOp>