diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C index 08e12b876e..330f48be00 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C @@ -52,24 +52,13 @@ void Foam::mapDistribute::distribute if (domain != Pstream::myProcNo() && map.size()) { - List subField(map.size()); - forAll(map, i) - { - subField[i] = field[map[i]]; - } OPstream toNbr(Pstream::blocking, domain); - toNbr << subField; + toNbr << UIndirectList(field, map); } } // Subset myself - const labelList& mySubMap = subMap[Pstream::myProcNo()]; - - List subField(mySubMap.size()); - forAll(mySubMap, i) - { - subField[i] = field[mySubMap[i]]; - } + UIndirectList subField(field, subMap[Pstream::myProcNo()]); // Receive sub field from myself (subField) const labelList& map = constructMap[Pstream::myProcNo()]; @@ -126,13 +115,7 @@ void Foam::mapDistribute::distribute List newField(constructSize); // Subset myself - const labelList& mySubMap = subMap[Pstream::myProcNo()]; - - List subField(mySubMap.size()); - forAll(mySubMap, i) - { - subField[i] = field[mySubMap[i]]; - } + UIndirectList subField(field, subMap[Pstream::myProcNo()]); // Receive sub field from myself (subField) const labelList& map = constructMap[Pstream::myProcNo()]; @@ -152,16 +135,8 @@ void Foam::mapDistribute::distribute if (Pstream::myProcNo() == sendProc) { // I am sender. Send to recvProc. - const labelList& map = subMap[recvProc]; - - List subField(map.size()); - forAll(map, i) - { - subField[i] = field[map[i]]; - } - OPstream toNbr(Pstream::scheduled, recvProc); - toNbr << subField; + toNbr << UIndirectList(field, subMap[recvProc]); } else { @@ -374,24 +349,13 @@ void Foam::mapDistribute::distribute if (domain != Pstream::myProcNo() && map.size()) { - List subField(map.size()); - forAll(map, i) - { - subField[i] = field[map[i]]; - } OPstream toNbr(Pstream::blocking, domain); - toNbr << subField; + toNbr << UIndirectList(field, map); } } // Subset myself - const labelList& mySubMap = subMap[Pstream::myProcNo()]; - - List subField(mySubMap.size()); - forAll(mySubMap, i) - { - subField[i] = field[mySubMap[i]]; - } + UIndirectList subField(field, subMap[Pstream::myProcNo()]); // Receive sub field from myself (subField) const labelList& map = constructMap[Pstream::myProcNo()]; @@ -449,13 +413,7 @@ void Foam::mapDistribute::distribute List newField(constructSize, nullValue); // Subset myself - const labelList& mySubMap = subMap[Pstream::myProcNo()]; - - List subField(mySubMap.size()); - forAll(mySubMap, i) - { - subField[i] = field[mySubMap[i]]; - } + UIndirectList subField(field, subMap[Pstream::myProcNo()]); // Receive sub field from myself (subField) const labelList& map = constructMap[Pstream::myProcNo()]; @@ -475,16 +433,8 @@ void Foam::mapDistribute::distribute if (Pstream::myProcNo() == sendProc) { // I am sender. Send to recvProc. - const labelList& map = subMap[recvProc]; - - List subField(map.size()); - forAll(map, i) - { - subField[i] = field[map[i]]; - } - OPstream toNbr(Pstream::scheduled, recvProc); - toNbr << subField; + toNbr << UIndirectList(field, subMap[recvProc]); } else { diff --git a/src/OpenFOAM/meshes/primitiveShapes/triangle/triangle.H b/src/OpenFOAM/meshes/primitiveShapes/triangle/triangle.H index 1165046636..3bc3ea38a8 100644 --- a/src/OpenFOAM/meshes/primitiveShapes/triangle/triangle.H +++ b/src/OpenFOAM/meshes/primitiveShapes/triangle/triangle.H @@ -166,14 +166,11 @@ public: const intersection::direction dir = intersection::VECTOR ) const; - //- Fast intersection with a ray. Distance is normalised distance - // to the intersection (normalised with the vector magnitude). - // For a hit, the distance is signed. Positive number - // represents the point in front of triangle. In case of miss - // pointHit position is undefined. - // Only defined for VISIBLE, FULL_RAY or + //- Fast intersection with a ray. + // For a hit, the pointHit.distance() is the line parameter t : + // intersection=p+t*q. Only defined for VISIBLE, FULL_RAY or // HALF_RAY. tol increases the virtual size of the triangle - // by a relative factor. + // by a relative factor. inline pointHit intersection ( const point& p, diff --git a/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C b/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C index 0859e37d33..ee6cea3e12 100644 --- a/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C +++ b/src/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C @@ -45,6 +45,7 @@ Description #include "OFstream.H" #include "layerParameters.H" #include "combineFaces.H" +#include "IOmanip.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -1414,8 +1415,11 @@ void Foam::autoLayerDriver::calculateLayerThickness const indirectPrimitivePatch& pp, const labelList& patchIDs, const scalarField& patchExpansionRatio, - const scalarField& patchFinalLayerRatio, - const scalarField& patchRelMinThickness, + + const bool relativeSizes, + const scalarField& patchFinalLayerThickness, + const scalarField& patchMinThickness, + const labelList& cellLevel, const labelList& patchNLayers, const scalar edge0Len, @@ -1428,22 +1432,100 @@ void Foam::autoLayerDriver::calculateLayerThickness const fvMesh& mesh = meshRefiner_.mesh(); const polyBoundaryMesh& patches = mesh.boundaryMesh(); - if (min(patchRelMinThickness) < 0 || max(patchRelMinThickness) > 2) + + // Rework patch-wise layer parameters into minimum per point + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + // Reuse input fields + expansionRatio.setSize(pp.nPoints()); + expansionRatio = GREAT; + thickness.setSize(pp.nPoints()); + thickness = GREAT; + minThickness.setSize(pp.nPoints()); + minThickness = GREAT; + + forAll(patchIDs, i) { - FatalErrorIn("calculateLayerThickness(..)") - << "Thickness should be factor of local undistorted cell size." - << " Valid values are [0..2]." << nl - << " minThickness:" << patchRelMinThickness - << exit(FatalError); + label patchI = patchIDs[i]; + + const labelList& meshPoints = patches[patchI].meshPoints(); + + forAll(meshPoints, patchPointI) + { + label ppPointI = pp.meshPointMap()[meshPoints[patchPointI]]; + + expansionRatio[ppPointI] = min + ( + expansionRatio[ppPointI], + patchExpansionRatio[patchI] + ); + thickness[ppPointI] = min + ( + thickness[ppPointI], + patchFinalLayerThickness[patchI] + ); + minThickness[ppPointI] = min + ( + minThickness[ppPointI], + patchMinThickness[patchI] + ); + } } + syncTools::syncPointList + ( + mesh, + pp.meshPoints(), + expansionRatio, + minEqOp(), + GREAT, // null value + false // no separation + ); + syncTools::syncPointList + ( + mesh, + pp.meshPoints(), + thickness, + minEqOp(), + GREAT, // null value + false // no separation + ); + syncTools::syncPointList + ( + mesh, + pp.meshPoints(), + minThickness, + minEqOp(), + GREAT, // null value + false // no separation + ); - // Per point the max cell level of connected cells - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - labelList maxPointLevel(pp.nPoints(), labelMin); + // Now the thicknesses are set according to the minimum of connected + // patches. + + // Rework relative thickness into absolute + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // by multiplying with the internal cell size. + + if (relativeSizes) { + if (min(patchMinThickness) < 0 || max(patchMinThickness) > 2) + { + FatalErrorIn("calculateLayerThickness(..)") + << "Thickness should be factor of local undistorted cell size." + << " Valid values are [0..2]." << nl + << " minThickness:" << patchMinThickness + << exit(FatalError); + } + + + // Determine per point the max cell level of connected cells + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + labelList maxPointLevel(pp.nPoints(), labelMin); + forAll(pp, i) { label ownLevel = cellLevel[mesh.faceOwner()[pp.addressing()[i]]]; @@ -1465,113 +1547,44 @@ void Foam::autoLayerDriver::calculateLayerThickness labelMin, // null value false // no separation ); - } - // Rework patch-wise layer parameters into minimum per point - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - expansionRatio.setSize(pp.nPoints()); - expansionRatio = GREAT; - scalarField finalLayerRatio(pp.nPoints(), GREAT); - scalarField relMinThickness(pp.nPoints(), GREAT); - - { - forAll(patchIDs, i) + forAll(maxPointLevel, pointI) { - label patchI = patchIDs[i]; - - const labelList& meshPoints = patches[patchI].meshPoints(); - - forAll(meshPoints, patchPointI) - { - label ppPointI = pp.meshPointMap()[meshPoints[patchPointI]]; - - expansionRatio[ppPointI] = min - ( - expansionRatio[ppPointI], - patchExpansionRatio[patchI] - ); - finalLayerRatio[ppPointI] = min - ( - finalLayerRatio[ppPointI], - patchFinalLayerRatio[patchI] - ); - relMinThickness[ppPointI] = min - ( - relMinThickness[ppPointI], - patchRelMinThickness[patchI] - ); - } + // Find undistorted edge size for this level. + scalar edgeLen = edge0Len/(1<(), - GREAT, // null value - false // no separation - ); - syncTools::syncPointList - ( - mesh, - pp.meshPoints(), - finalLayerRatio, - minEqOp(), - GREAT, // null value - false // no separation - ); - syncTools::syncPointList - ( - mesh, - pp.meshPoints(), - relMinThickness, - minEqOp(), - GREAT, // null value - false // no separation - ); } - // Per mesh point the expansion parameters - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // Rework thickness (of final layer) into overall thickness of all layers + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - thickness.setSize(pp.nPoints()); - minThickness.setSize(pp.nPoints()); - - forAll(maxPointLevel, pointI) + forAll(thickness, pointI) { - // Find undistorted edge size for this level. - scalar edgeLen = edge0Len/(1< 0) + { + if (expansionRatio[ppPointI] == 1) + { + sumNearWallThickness += thickness[ppPointI]/nLay; + } + else + { + scalar s = + (1.0-pow(expansionRatio[ppPointI], nLay)) + / (1.0-expansionRatio[ppPointI]); + sumNearWallThickness += thickness[ppPointI]/s; + } + } + } + + label totNPoints = returnReduce(meshPoints.size(), sumOp