diff --git a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C index 6b63430918..2406cb667c 100644 --- a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C +++ b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C @@ -369,7 +369,10 @@ int main(int argc, char *argv[]) // Add all the surface regions as patches // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - labelList globalToPatch; + //- Global surface region to patch (non faceZone surface) or patches + // (faceZone surfaces) + labelList globalToMasterPatch; + labelList globalToSlavePatch; { Info<< nl << "Adding patches for surface regions" << nl @@ -377,7 +380,8 @@ int main(int argc, char *argv[]) << endl; // From global region number to mesh patch. - globalToPatch.setSize(surfaces.nRegions(), -1); + globalToMasterPatch.setSize(surfaces.nRegions(), -1); + globalToSlavePatch.setSize(surfaces.nRegions(), -1); Info<< "Patch\tType\tRegion" << nl << "-----\t----\t------" @@ -394,36 +398,111 @@ int main(int argc, char *argv[]) Info<< surfaces.names()[surfI] << ':' << nl << nl; - forAll(regNames, i) + if (surfaces.faceZoneNames()[surfI].empty()) { - label globalRegionI = surfaces.globalRegion(surfI, i); - - label patchI; - - if (surfacePatchInfo.set(globalRegionI)) + // 'Normal' surface + forAll(regNames, i) { - patchI = meshRefiner.addMeshedPatch - ( - regNames[i], - surfacePatchInfo[globalRegionI] - ); + label globalRegionI = surfaces.globalRegion(surfI, i); + + label patchI; + + if (surfacePatchInfo.set(globalRegionI)) + { + patchI = meshRefiner.addMeshedPatch + ( + regNames[i], + surfacePatchInfo[globalRegionI] + ); + } + else + { + dictionary patchInfo; + patchInfo.set("type", wallPolyPatch::typeName); + + patchI = meshRefiner.addMeshedPatch + ( + regNames[i], + patchInfo + ); + } + + Info<< patchI << '\t' << mesh.boundaryMesh()[patchI].type() + << '\t' << regNames[i] << nl; + + globalToMasterPatch[globalRegionI] = patchI; + globalToSlavePatch[globalRegionI] = patchI; } - else + } + else + { + // Zoned surface + forAll(regNames, i) { - dictionary patchInfo; - patchInfo.set("type", wallPolyPatch::typeName); + label globalRegionI = surfaces.globalRegion(surfI, i); - patchI = meshRefiner.addMeshedPatch - ( - regNames[i], - patchInfo - ); + // Add master side patch + { + label patchI; + + if (surfacePatchInfo.set(globalRegionI)) + { + patchI = meshRefiner.addMeshedPatch + ( + regNames[i], + surfacePatchInfo[globalRegionI] + ); + } + else + { + dictionary patchInfo; + patchInfo.set("type", wallPolyPatch::typeName); + + patchI = meshRefiner.addMeshedPatch + ( + regNames[i], + patchInfo + ); + } + + Info<< patchI << '\t' + << mesh.boundaryMesh()[patchI].type() + << '\t' << regNames[i] << nl; + + globalToMasterPatch[globalRegionI] = patchI; + } + // Add slave side patch + { + const word slaveName = regNames[i] + "_slave"; + label patchI; + + if (surfacePatchInfo.set(globalRegionI)) + { + patchI = meshRefiner.addMeshedPatch + ( + slaveName, + surfacePatchInfo[globalRegionI] + ); + } + else + { + dictionary patchInfo; + patchInfo.set("type", wallPolyPatch::typeName); + + patchI = meshRefiner.addMeshedPatch + ( + slaveName, + patchInfo + ); + } + + Info<< patchI << '\t' + << mesh.boundaryMesh()[patchI].type() + << '\t' << slaveName << nl; + + globalToSlavePatch[globalRegionI] = patchI; + } } - - Info<< patchI << '\t' << mesh.boundaryMesh()[patchI].type() - << '\t' << regNames[i] << nl; - - globalToPatch[globalRegionI] = patchI; } Info<< nl; @@ -479,7 +558,8 @@ int main(int argc, char *argv[]) meshRefiner, decomposer, distributor, - globalToPatch + globalToMasterPatch, + globalToSlavePatch ); // Refinement parameters @@ -510,7 +590,8 @@ int main(int argc, char *argv[]) autoSnapDriver snapDriver ( meshRefiner, - globalToPatch + globalToMasterPatch, + globalToSlavePatch ); // Snap parameters @@ -544,7 +625,12 @@ int main(int argc, char *argv[]) { cpuTime timer; - autoLayerDriver layerDriver(meshRefiner, globalToPatch); + autoLayerDriver layerDriver + ( + meshRefiner, + globalToMasterPatch, + globalToSlavePatch + ); // Layer addition parameters layerParameters layerParams(layerDict, mesh.boundaryMesh()); diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C index b08cccbb85..7dff414859 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C @@ -2372,11 +2372,13 @@ void Foam::autoLayerDriver::getLayerCellsFaces Foam::autoLayerDriver::autoLayerDriver ( meshRefinement& meshRefiner, - const labelList& globalToPatch + const labelList& globalToMasterPatch, + const labelList& globalToSlavePatch ) : meshRefiner_(meshRefiner), - globalToPatch_(globalToPatch) + globalToMasterPatch_(globalToMasterPatch), + globalToSlavePatch_(globalToSlavePatch) {} @@ -2435,7 +2437,12 @@ void Foam::autoLayerDriver::addLayers // Create baffles (pairs of faces that share the same points) // Baffles stored as owner and neighbour face that have been created. List baffles; - meshRefiner_.createZoneBaffles(globalToPatch_, baffles); + meshRefiner_.createZoneBaffles + ( + globalToMasterPatch_, + globalToSlavePatch_, + baffles + ); if (debug&meshRefinement::MESH) { diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.H b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.H index 272f1af09e..416544a719 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.H +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.H @@ -99,7 +99,10 @@ class autoLayerDriver meshRefinement& meshRefiner_; //- From surface region to patch - const labelList globalToPatch_; + const labelList globalToMasterPatch_; + + //- From surface region to patch + const labelList globalToSlavePatch_; @@ -518,7 +521,8 @@ public: autoLayerDriver ( meshRefinement& meshRefiner, - const labelList& globalToPatch + const labelList& globalToMasterPatch, + const labelList& globalToSlavePatch ); diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriverShrink.C b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriverShrink.C index 73d09f449f..8ffcaa5f57 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriverShrink.C +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriverShrink.C @@ -1135,6 +1135,12 @@ void Foam::autoLayerDriver::medialAxisSmoothingInfo << " " << medialRatio.name() << " : ratio of medial distance to wall distance" << nl << endl; + meshRefiner_.mesh().setInstance(meshRefiner_.timeName()); + meshRefiner_.write + ( + debug, + mesh.time().path()/meshRefiner_.timeName() + ); dispVec.write(); medialDist.write(); medialVec.write(); @@ -1409,6 +1415,94 @@ void Foam::autoLayerDriver::shrinkMeshMedialDistance *dispVec[pointI]; } + + +//XXXXX +// // Smear displacement away from fixed values (medialRatio=0 or 1) +// { +// const edgeList& edges = mesh.edges(); +// scalarField edgeWeight(edges.size(), 0.0); +// forAll(edges, edgeI) +// { +// if (isMasterEdge[edgeI]) +// { +// scalar eMag = edges[edgeI].mag(mesh.points()); +// if (eMag > VSMALL) +// { +// edgeWeight[edgeI] = 1.0/eMag; +// } +// else +// { +// edgeWeight[edgeI] = GREAT; +// } +// } +// } +// scalarField invSumWeight(mesh.nPoints()); +// sumWeights(isMasterEdge, edgeWeight, invSumWeight); +// +// +// // Get smoothly varying patch field. +// Info<< "shrinkMeshDistance : Smoothing displacement ..." << endl; +// +// const scalar lambda = 0.33; +// const scalar mu = -0.34; +// +// pointField average(mesh.nPoints()); +// for (label iter = 0; iter < 90; iter++) +// { +// // Calculate average of field +// averageNeighbours +// ( +// mesh, +// edgeWeight, +// invSumWeight, +// displacement, +// average +// ); +// +// forAll(displacement, i) +// { +// if (medialRatio[i] > SMALL && medialRatio[i] < 1-SMALL) +// { +// displacement[i] = +// (1-lambda)*displacement[i] +// +lambda*average[i]; +// } +// } +// +// +// // Calculate average of field +// averageNeighbours +// ( +// mesh, +// edgeWeight, +// invSumWeight, +// displacement, +// average +// ); +// +// forAll(displacement, i) +// { +// if (medialRatio[i] > SMALL && medialRatio[i] < 1-SMALL) +// { +// displacement[i] = (1-mu)*displacement[i]+mu*average[i]; +// } +// } +// +// +// // Do residual calculation every so often. +// if ((iter % 10) == 0) +// { +// Info<< " Iteration " << iter << " residual " +// << gSum(mag(displacement-average)) +// /returnReduce(average.size(), sumOp