diff --git a/applications/utilities/mesh/generation/blockMesh/blockMesh.C b/applications/utilities/mesh/generation/blockMesh/blockMesh.C index f82643e822..746d259040 100644 --- a/applications/utilities/mesh/generation/blockMesh/blockMesh.C +++ b/applications/utilities/mesh/generation/blockMesh/blockMesh.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -48,24 +48,16 @@ Usage \*---------------------------------------------------------------------------*/ +#include "argList.H" #include "Time.H" -#include "IOdictionary.H" -#include "IOPtrList.H" #include "systemDict.H" - #include "blockMesh.H" -#include "attachPolyTopoChanger.H" +#include "mergePatchPairs.H" #include "polyTopoChange.H" #include "emptyPolyPatch.H" #include "cyclicPolyPatch.H" - -#include "argList.H" -#include "OSspecific.H" #include "OFstream.H" -#include "Pair.H" -#include "slidingInterface.H" - using namespace Foam; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -236,22 +228,23 @@ int main(int argc, char *argv[]) // Read in a list of dictionaries for the merge patch pairs if (meshDict.found("mergePatchPairs")) { - List> mergePatchPairs + List> patchPairNames ( meshDict.lookup("mergePatchPairs") ); - #include "mergePatchPairs.H" + if (patchPairNames.size()) + { + const word oldInstance = mesh.pointsInstance(); + mergePatchPairs(mesh, patchPairNames, 1e-4); + mesh.setInstance(oldInstance); + } } else { - Info<< nl << "There are no merge patch pairs edges" << endl; + Info<< nl << "No patch pairs to merge" << endl; } - - // Set any cellZones (note: cell labelling unaffected by above - // mergePatchPairs) - label nZones = blocks.numZonedBlocks(); if (nZones > 0) diff --git a/applications/utilities/mesh/generation/blockMesh/mergePatchPairs.H b/applications/utilities/mesh/generation/blockMesh/mergePatchPairs.H deleted file mode 100644 index b60e16a4e3..0000000000 --- a/applications/utilities/mesh/generation/blockMesh/mergePatchPairs.H +++ /dev/null @@ -1,119 +0,0 @@ - if (mergePatchPairs.size()) - { - Info<< "Creating merge patch pairs" << nl << endl; - - // Create and add point and face zones and mesh modifiers - List pz(mergePatchPairs.size()); - List fz(3*mergePatchPairs.size()); - List cz(0); - - forAll(mergePatchPairs, pairI) - { - const word mergeName - ( - mergePatchPairs[pairI].first() - + mergePatchPairs[pairI].second() - + name(pairI) - ); - - pz[pairI] = new pointZone - ( - mergeName + "CutPointZone", - labelList(0), - 0, - mesh.pointZones() - ); - - // Master patch - const word masterPatchName(mergePatchPairs[pairI].first()); - const polyPatch& masterPatch = - mesh.boundaryMesh()[masterPatchName]; - - labelList isf(masterPatch.size()); - - forAll(isf, i) - { - isf[i] = masterPatch.start() + i; - } - - fz[3*pairI] = new faceZone - ( - mergeName + "MasterZone", - isf, - boolList(masterPatch.size(), false), - 0, - mesh.faceZones() - ); - - // Slave patch - const word slavePatchName(mergePatchPairs[pairI].second()); - const polyPatch& slavePatch = - mesh.boundaryMesh()[slavePatchName]; - - labelList osf(slavePatch.size()); - - forAll(osf, i) - { - osf[i] = slavePatch.start() + i; - } - - fz[3*pairI + 1] = new faceZone - ( - mergeName + "SlaveZone", - osf, - boolList(slavePatch.size(), false), - 1, - mesh.faceZones() - ); - - // Add empty zone for cut faces - fz[3*pairI + 2] = new faceZone - ( - mergeName + "CutFaceZone", - labelList(0), - boolList(0, false), - 2, - mesh.faceZones() - ); - } // end of all merge pairs - - Info<< "Adding point and face zones" << endl; - mesh.addZones(pz, fz, cz); - - - Info<< "Creating attachPolyTopoChanger" << endl; - attachPolyTopoChanger polyMeshAttacher(mesh); - polyMeshAttacher.setSize(mergePatchPairs.size()); - - forAll(mergePatchPairs, pairI) - { - const word mergeName - ( - mergePatchPairs[pairI].first() - + mergePatchPairs[pairI].second() - + name(pairI) - ); - - // Add the sliding interface mesh modifier - polyMeshAttacher.set - ( - pairI, - new slidingInterface - ( - "couple" + name(pairI), - mesh, - mergeName + "MasterZone", - mergeName + "SlaveZone", - mergeName + "CutPointZone", - mergeName + "CutFaceZone", - mergePatchPairs[pairI].first(), - mergePatchPairs[pairI].second(), - slidingInterface::INTEGRAL, // always integral - false, - intersection::algorithm::visible - ) - ); - } - - polyMeshAttacher.attach(true); - } diff --git a/applications/utilities/mesh/manipulation/stitchMesh/stitchMesh.C b/applications/utilities/mesh/manipulation/stitchMesh/stitchMesh.C index e15690fcf3..7ed9e9c173 100644 --- a/applications/utilities/mesh/manipulation/stitchMesh/stitchMesh.C +++ b/applications/utilities/mesh/manipulation/stitchMesh/stitchMesh.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2023 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -25,185 +25,55 @@ Application stitchMesh Description - 'Stitches' a mesh. + Utility to stitch or conform pairs of patches, + converting the patch faces either into internal faces + or conformal faces or another patch. - Takes a mesh and two patches and merges the faces on the two patches - (if geometrically possible) so the faces become internal. +Usage + \b stitchMesh (\) - Can do - - 'perfect' match: faces and points on patches align exactly. Order might - be different though. - - 'integral' match: where the surfaces on both patches exactly - match but the individual faces not - - 'partial' match: where the non-overlapping part of the surface remains - in the respective patch. + E.g. to stitch patches \c top1 to \c top2 and \c bottom1 to \c bottom2 + stitchMesh "((top1 top2) (bottom1 bottom2))" - Note : Is just a front-end to perfectInterface/slidingInterface. + Options: + - \par -overwrite \n + Replace the old mesh with the new one, rather than writing the new one + into a separate time directory - Comparable to running a meshModifier of the form - (if masterPatch is called "M" and slavePatch "S"): + - \par -region \ + Specify an alternative mesh region. - \verbatim - couple - { - type slidingInterface; - masterFaceZoneName MSMasterZone - slaveFaceZoneName MSSlaveZone - cutPointZoneName MSCutPointZone - cutFaceZoneName MSCutFaceZone - masterPatchName M; - slavePatchName S; - typeOfMatch partial or integral - } - \endverbatim + - \par -fields + Update vol and point fields + - \par -tol + Merge tolerance relative to local edge length (default 1e-4) + +See also + Foam::mergePatchPairs \*---------------------------------------------------------------------------*/ #include "argList.H" -#include "polyTopoChanger.H" -#include "polyTopoChangeMap.H" -#include "slidingInterface.H" -#include "perfectInterface.H" +#include "fvMesh.H" +#include "timeSelector.H" #include "ReadFields.H" #include "volFields.H" -#include "surfaceFields.H" #include "pointFields.H" +#include "mergePatchPairs.H" using namespace Foam; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -label addPointZone(const polyMesh& mesh, const word& name) -{ - label zoneID = mesh.pointZones().findIndex(name); - - if (zoneID != -1) - { - Info<< "Reusing existing pointZone " - << mesh.pointZones()[zoneID].name() - << " at index " << zoneID << endl; - } - else - { - meshPointZones& pointZones = const_cast(mesh).pointZones(); - zoneID = pointZones.size(); - Info<< "Adding pointZone " << name << " at index " << zoneID << endl; - - pointZones.setSize(zoneID+1); - pointZones.set - ( - zoneID, - new pointZone - ( - name, - labelList(0), - zoneID, - pointZones - ) - ); - } - return zoneID; -} - - -label addFaceZone(const polyMesh& mesh, const word& name) -{ - label zoneID = mesh.faceZones().findIndex(name); - - if (zoneID != -1) - { - Info<< "Reusing existing faceZone " << mesh.faceZones()[zoneID].name() - << " at index " << zoneID << endl; - } - else - { - meshFaceZones& faceZones = const_cast(mesh).faceZones(); - zoneID = faceZones.size(); - Info<< "Adding faceZone " << name << " at index " << zoneID << endl; - - faceZones.setSize(zoneID+1); - faceZones.set - ( - zoneID, - new faceZone - ( - name, - labelList(0), - boolList(), - zoneID, - faceZones - ) - ); - } - return zoneID; -} - - -label addCellZone(const polyMesh& mesh, const word& name) -{ - label zoneID = mesh.cellZones().findIndex(name); - - if (zoneID != -1) - { - Info<< "Reusing existing cellZone " << mesh.cellZones()[zoneID].name() - << " at index " << zoneID << endl; - } - else - { - meshCellZones& cellZones = const_cast(mesh).cellZones(); - zoneID = cellZones.size(); - Info<< "Adding cellZone " << name << " at index " << zoneID << endl; - - cellZones.setSize(zoneID+1); - cellZones.set - ( - zoneID, - new cellZone - ( - name, - labelList(0), - zoneID, - cellZones - ) - ); - } - return zoneID; -} - - -// Checks whether patch present -void checkPatch(const polyBoundaryMesh& bMesh, const word& name) -{ - const label patchi = bMesh.findIndex(name); - - if (patchi == -1) - { - FatalErrorInFunction - << "Cannot find patch " << name << endl - << "It should be present and of non-zero size" << endl - << "Valid patches are " << bMesh.names() - << exit(FatalError); - } - - if (bMesh[patchi].empty()) - { - FatalErrorInFunction - << "Patch " << name << " is present but zero size" - << exit(FatalError); - } -} - - - int main(int argc, char *argv[]) { + timeSelector::addOptions(true, false); + argList::addNote ( - "Merge the faces on the specified patches (if geometrically possible)\n" - "so the faces become internal.\n" - "Integral matching is used when the options -partial and -perfect are " - "omitted.\n" + "Stitch the faces on the specified patch pairs\n" + "converting the overlapping patch faces into internal faces.\n" ); argList::noParallel(); @@ -211,276 +81,61 @@ int main(int argc, char *argv[]) #include "addRegionOption.H" argList::addBoolOption ( - "noFields", - "do not update fields" - ); - - argList::validArgs.append("masterPatch"); - argList::validArgs.append("slavePatch"); - - argList::addBoolOption - ( - "partial", - "couple partially overlapping patches (optional)" - ); - argList::addBoolOption - ( - "perfect", - "couple perfectly aligned patches (optional)" + "fields", + "update fields" ); argList::addOption ( - "toleranceDict", - "file", - "dictionary file with tolerances" + "tol", + "scalar", + "merge tolerance relative to local edge length (default 1e-4)" ); + argList::validArgs.append("patchPairs"); + #include "setRootCase.H" #include "createTimeNoFunctionObjects.H" + + // Select time if specified + timeSelector::selectIfPresent(runTime, args); + #include "createNamedMesh.H" + const scalar snapTol = args.optionLookupOrDefault("tol", 1e-4); + const bool overwrite = args.optionFound("overwrite"); + const bool fields = args.optionFound("fields"); + + const List> patchPairNames((IStringStream(args[1])())); + const word oldInstance = mesh.pointsInstance(); - const word masterPatchName = args[1]; - const word slavePatchName = args[2]; - - const bool partialCover = args.optionFound("partial"); - const bool perfectCover = args.optionFound("perfect"); - const bool overwrite = args.optionFound("overwrite"); - const bool fields = !args.optionFound("noFields"); - - if (partialCover && perfectCover) - { - FatalErrorInFunction - << "Cannot supply both partial and perfect." << endl - << "Use perfect match option if the patches perfectly align" - << " (both vertex positions and face centres)" << endl - << exit(FatalError); - } - - - const word mergePatchName(masterPatchName + slavePatchName); - const word cutZoneName(mergePatchName + "CutFaceZone"); - - slidingInterface::typeOfMatch tom = slidingInterface::INTEGRAL; - - if (partialCover) - { - Info<< "Coupling partially overlapping patches " - << masterPatchName << " and " << slavePatchName << nl - << "Resulting internal faces will be in faceZone " << cutZoneName - << nl - << "Any uncovered faces will remain in their patch" - << endl; - - tom = slidingInterface::PARTIAL; - } - else if (perfectCover) - { - Info<< "Coupling perfectly aligned patches " - << masterPatchName << " and " << slavePatchName << nl - << "Resulting (internal) faces will be in faceZone " << cutZoneName - << nl << nl - << "Note: both patches need to align perfectly." << nl - << "Both the vertex" - << " positions and the face centres need to align to within" << nl - << "a tolerance given by the minimum edge length on the patch" - << endl; - } - else - { - Info<< "Coupling patches " << masterPatchName << " and " - << slavePatchName << nl - << "Resulting (internal) faces will be in faceZone " << cutZoneName - << nl << nl - << "Note: the overall area covered by both patches should be" - << " identical (\"integral\" interface)." << endl - << "If this is not the case use the -partial option" << nl << endl; - } - - // set up the tolerances for the sliding mesh - dictionary slidingTolerances; - if (args.options().found("toleranceDict")) - { - IOdictionary toleranceFile - ( - IOobject - ( - args.options()["toleranceDict"], - runTime.constant(), - mesh, - IOobject::MUST_READ_IF_MODIFIED, - IOobject::NO_WRITE - ) - ); - slidingTolerances += toleranceFile; - } - - // Check for non-empty master and slave patches - checkPatch(mesh.boundaryMesh(), masterPatchName); - checkPatch(mesh.boundaryMesh(), slavePatchName); - - // Create and add face zones and mesh modifiers - - // Master patch - const polyPatch& masterPatch = mesh.boundaryMesh()[masterPatchName]; - - // Make list of masterPatch faces - labelList isf(masterPatch.size()); - - forAll(isf, i) - { - isf[i] = masterPatch.start() + i; - } - - polyTopoChanger stitcher(mesh); - stitcher.setSize(1); - - mesh.pointZones().clearAddressing(); - mesh.faceZones().clearAddressing(); - mesh.cellZones().clearAddressing(); - - if (perfectCover) - { - // Add empty zone for resulting internal faces - label cutZoneID = addFaceZone(mesh, cutZoneName); - - mesh.faceZones()[cutZoneID].resetAddressing - ( - isf, - boolList(masterPatch.size(), false) - ); - - // Add the perfect interface mesh modifier - stitcher.set - ( - 0, - new perfectInterface - ( - "couple", - mesh, - cutZoneName, - masterPatchName, - slavePatchName - ) - ); - } - else - { - label pointZoneID = addPointZone(mesh, mergePatchName + "CutPointZone"); - mesh.pointZones()[pointZoneID] = labelList(0); - - label masterZoneID = addFaceZone(mesh, mergePatchName + "MasterZone"); - - mesh.faceZones()[masterZoneID].resetAddressing - ( - isf, - boolList(masterPatch.size(), false) - ); - - // Slave patch - const polyPatch& slavePatch = mesh.boundaryMesh()[slavePatchName]; - - labelList osf(slavePatch.size()); - - forAll(osf, i) - { - osf[i] = slavePatch.start() + i; - } - - label slaveZoneID = addFaceZone(mesh, mergePatchName + "SlaveZone"); - mesh.faceZones()[slaveZoneID].resetAddressing - ( - osf, - boolList(slavePatch.size(), false) - ); - - // Add empty zone for cut faces - label cutZoneID = addFaceZone(mesh, cutZoneName); - mesh.faceZones()[cutZoneID].resetAddressing - ( - labelList(0), - boolList(0, false) - ); - - - // Add the sliding interface mesh modifier - stitcher.set - ( - 0, - new slidingInterface - ( - "couple", - mesh, - mergePatchName + "MasterZone", - mergePatchName + "SlaveZone", - mergePatchName + "CutPointZone", - cutZoneName, - masterPatchName, - slavePatchName, - tom, // integral or partial - true // couple/decouple mode - ) - ); - static_cast(stitcher[0]).setTolerances - ( - slidingTolerances, - true - ); - } - - // Search for list of objects for this time - IOobjectList objects(mesh, runTime.name()); + IOobjectList objects(mesh, runTime.timeName()); if (fields) Info<< "Reading geometric fields" << nl << endl; #include "readVolFields.H" - // #include "readSurfaceFields.H" #include "readPointFields.H" + Info<< endl; + if (!overwrite) { runTime++; } - // Execute all polyMeshModifiers - autoPtr map = stitcher.changeMesh(true); - - mesh.setPoints(map->preMotionPoints()); + // Stitch the patch-pairs + mergePatchPairs(mesh, patchPairNames, snapTol); // Write mesh if (overwrite) { mesh.setInstance(oldInstance); } - Info<< nl << "Writing polyMesh to time " << runTime.name() << endl; - IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision())); + Info<< "Writing mesh to " << mesh.facesInstance() << endl; - // Bypass runTime write (since only writes at writeTime) - if - ( - !runTime.objectRegistry::writeObject - ( - runTime.writeFormat(), - IOstream::currentVersion, - runTime.writeCompression(), - true - ) - ) - { - FatalErrorInFunction - << "Failed writing polyMesh." - << exit(FatalError); - } - - mesh.faceZones().write(); - mesh.pointZones().write(); - mesh.cellZones().write(); - - // Write fields - runTime.write(); + mesh.write(); Info<< "End\n" << endl; diff --git a/applications/utilities/surface/surfaceToPatch/surfaceToPatch.C b/applications/utilities/surface/surfaceToPatch/surfaceToPatch.C index 7243fe58b6..11dcbf9cff 100644 --- a/applications/utilities/surface/surfaceToPatch/surfaceToPatch.C +++ b/applications/utilities/surface/surfaceToPatch/surfaceToPatch.C @@ -36,7 +36,6 @@ Description #include "polyMesh.H" #include "faceSet.H" #include "polyTopoChange.H" -#include "polyModifyFace.H" #include "globalMeshData.H" using namespace Foam; diff --git a/etc/caseDicts/annotated/toleranceDict b/etc/caseDicts/annotated/toleranceDict deleted file mode 100644 index d6913720f9..0000000000 --- a/etc/caseDicts/annotated/toleranceDict +++ /dev/null @@ -1,44 +0,0 @@ -/*--------------------------------*- C++ -*----------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Website: https://openfoam.org - \\ / A nd | Version: dev - \\/ M anipulation | -\*---------------------------------------------------------------------------*/ -FoamFile -{ - format ascii; - class dictionary; - object toleranceDict; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -// For complete details on what this dictionary file should provide, see -// $FOAM_SRC/src/polyTopoChange/slidingInterface/slidingInterface.C -// method: Foam::slidingInterface::setTolerances - -//- Point merge tolerance -pointMergeTol 0.05; - -//- Edge merge tolerance -edgeMergeTol 0.01; - -//- Estimated number of faces an edge goes through -nFacesPerSlaveEdge 5; - -//- Edge-face interaction escape limit -edgeFaceEscapeLimit 10; - -//- Integral match point adjustment tolerance -integralAdjTol 0.05; - -//- Edge intersection master catch fraction -edgeMasterCatchFraction 0.4; - -//- Edge intersection co-planar tolerance -edgeCoPlanarTol 0.8; - -//- Edge end cut-off tolerance -edgeEndCutoffTol 0.0001; - -// ************************************************************************* // diff --git a/etc/config.sh/bash_completion b/etc/config.sh/bash_completion index be976b37ff..fd62425882 100644 --- a/etc/config.sh/bash_completion +++ b/etc/config.sh/bash_completion @@ -355,7 +355,7 @@ _checkMesh_ () local line=${COMP_LINE} local used=$(echo "$line" | grep -oE "\-[a-zA-Z]+ ") - opts="-allGeometry -allTopology -case -constant -doc -fileHandler -help -hostRoots -latestTime -libs -meshQuality -noFunctionObjects -noTopology -noZero -parallel -region -roots -srcDoc -time -writeSets" + opts="-allGeometry -allTopology -case -constant -doc -fileHandler -help -hostRoots -latestTime -libs -meshQuality -noFunctionObjects -nonOrthThreshold -noTopology -noZero -parallel -region -roots -setFormat -skewThreshold -srcDoc -surfaceFormat -time -writeSets -writeSurfaces" for o in $used ; do opts="${opts/$o/}" ; done extra="" @@ -367,7 +367,7 @@ _checkMesh_ () opts="uncollated collated masterUncollated" ; extra="" ;; -time) opts="$(foamListTimes -withZero 2> /dev/null)" ; extra="" ;; - -hostRoots|-libs|-region|-roots|-writeSets) + -hostRoots|-libs|-nonOrthThreshold|-region|-roots|-setFormat|-skewThreshold|-surfaceFormat) opts="" ; extra="" ;; *) ;; esac @@ -1989,31 +1989,6 @@ _mixtureAdiabaticFlameT_ () } complete -o filenames -o nospace -F _mixtureAdiabaticFlameT_ mixtureAdiabaticFlameT -_modifyMesh_ () -{ - local cur="${COMP_WORDS[COMP_CWORD]}" - local prev="${COMP_WORDS[COMP_CWORD-1]}" - local line=${COMP_LINE} - local used=$(echo "$line" | grep -oE "\-[a-zA-Z]+ ") - - opts="-case -doc -fileHandler -help -hostRoots -libs -noFunctionObjects -overwrite -parallel -roots -srcDoc" - for o in $used ; do opts="${opts/$o/}" ; done - extra="" - - [ "$COMP_CWORD" = 1 ] || \ - case "$prev" in - -case) - opts="" ; extra="-d" ;; - -fileHandler) - opts="uncollated collated masterUncollated" ; extra="" ;; - -hostRoots|-libs|-roots) - opts="" ; extra="" ;; - *) ;; - esac - COMPREPLY=( $(compgen -W "${opts}" $extra -- ${cur}) ) -} -complete -o filenames -o nospace -F _modifyMesh_ modifyMesh - _mshToFoam_ () { local cur="${COMP_WORDS[COMP_CWORD]}" @@ -2994,31 +2969,6 @@ _splitCells_ () } complete -o filenames -o nospace -F _splitCells_ splitCells -_splitMesh_ () -{ - local cur="${COMP_WORDS[COMP_CWORD]}" - local prev="${COMP_WORDS[COMP_CWORD-1]}" - local line=${COMP_LINE} - local used=$(echo "$line" | grep -oE "\-[a-zA-Z]+ ") - - opts="-case -doc -fileHandler -help -libs -noFunctionObjects -overwrite -srcDoc" - for o in $used ; do opts="${opts/$o/}" ; done - extra="" - - [ "$COMP_CWORD" = 1 ] || \ - case "$prev" in - -case) - opts="" ; extra="-d" ;; - -fileHandler) - opts="uncollated collated masterUncollated" ; extra="" ;; - -libs) - opts="" ; extra="" ;; - *) ;; - esac - COMPREPLY=( $(compgen -W "${opts}" $extra -- ${cur}) ) -} -complete -o filenames -o nospace -F _splitMesh_ splitMesh - _splitMeshRegions_ () { local cur="${COMP_WORDS[COMP_CWORD]}" @@ -3132,7 +3082,7 @@ _stitchMesh_ () local line=${COMP_LINE} local used=$(echo "$line" | grep -oE "\-[a-zA-Z]+ ") - opts="-case -doc -fileHandler -help -libs -noFields -noFunctionObjects -overwrite -partial -perfect -region -srcDoc -toleranceDict" + opts="-case -constant -doc -fields -fileHandler -help -latestTime -libs -noFunctionObjects -noZero -overwrite -region -srcDoc -time -tol" for o in $used ; do opts="${opts/$o/}" ; done extra="" @@ -3140,11 +3090,11 @@ _stitchMesh_ () case "$prev" in -case) opts="" ; extra="-d" ;; - -toleranceDict) - opts="" ; extra="-d -f" ;; -fileHandler) opts="uncollated collated masterUncollated" ; extra="" ;; - -libs|-region) + -time) + opts="$(foamListTimes -withZero 2> /dev/null)" ; extra="" ;; + -libs|-region|-tol) opts="" ; extra="" ;; *) ;; esac diff --git a/src/OpenFOAM/meshes/Identifiers/DynamicID/DynamicID.H b/src/fvMeshMovers/engine/DynamicID/DynamicID.H similarity index 100% rename from src/OpenFOAM/meshes/Identifiers/DynamicID/DynamicID.H rename to src/fvMeshMovers/engine/DynamicID/DynamicID.H diff --git a/src/OpenFOAM/meshes/Identifiers/patch/polyPatchDynamicID.H b/src/fvMeshMovers/engine/DynamicID/polyPatchDynamicID.H similarity index 100% rename from src/OpenFOAM/meshes/Identifiers/patch/polyPatchDynamicID.H rename to src/fvMeshMovers/engine/DynamicID/polyPatchDynamicID.H diff --git a/src/meshTools/Make/files b/src/meshTools/Make/files index d58ba59779..ec15fff477 100644 --- a/src/meshTools/Make/files +++ b/src/meshTools/Make/files @@ -275,4 +275,9 @@ nonConformal/boundary/nonConformalBoundary.C pointDist/pointEdgeDist.C pointDist/pointDist.C +patchIntersection/star/star.C +patchIntersection/patchIntersection.C +patchIntersection/primitivePatchIntersection.C +patchIntersection/polyPatchIntersection.C + LIB = $(FOAM_LIBBIN)/libmeshTools diff --git a/src/meshTools/patchIntersection/FacePatchIntersection.C b/src/meshTools/patchIntersection/FacePatchIntersection.C new file mode 100644 index 0000000000..1e1d7869d8 --- /dev/null +++ b/src/meshTools/patchIntersection/FacePatchIntersection.C @@ -0,0 +1,510 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2023 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "FacePatchIntersection.H" +#include "cpuTime.H" +#include "primitiveTriPatch.H" +#include "polygonTriangulate.H" +#include "TriPatchIntersection.H" +#include "vtkWritePolyData.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +template +void inplaceRemove(ListType& lst, const T& value) +{ + if (lst.size()) + { + inplaceRemove(lst, value, lst[0]); + } +} + +template +void inplaceRemove(ListType& lst, const T& value, const NotT&) +{ + forAll(lst, i) + { + if (lst[i].size()) + { + inplaceRemove(lst[i], value, lst[i][0]); + } + } +} + +template +void inplaceRemove(ListType& lst, const T& value, const T&) +{ + label iNew = 0; + forAll(lst, iOld) + { + if (lst[iOld] != value) + { + lst[iNew] = lst[iOld]; + ++ iNew; + } + } + lst.resize(iNew); +} + +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +Foam::FacePatchIntersection::FacePatchIntersection +( + const SrcPatchType& srcPatch, + const TgtPatchType& tgtPatch, + const scalar snapTol +) +: + FacePatchIntersection(srcPatch, srcPatch.pointNormals(), tgtPatch, snapTol) +{} + + +template +Foam::FacePatchIntersection::FacePatchIntersection +( + const SrcPatchType& srcPatch, + const vectorField& srcPointNormals, + const TgtPatchType& tgtPatch, + const scalar snapTol +) +: + PatchIntersection(srcPatch, tgtPatch) +{ + cpuTime time; + + Info<< type() << ": Intersecting " + << this->srcPatch_.size() << " source faces and " + << this->tgtPatch_.size() << " target faces" << incrIndent << endl; + + if (this->debug) + { + Info<< indent << "Writing patches" << incrIndent << endl; + const fileName srcFileName = type() + "_srcPatch.vtk"; + Info<< indent << "Writing patch to " << srcFileName << endl; + vtkWritePolyData::write + ( + srcFileName, + "source", + false, + this->srcPatch_.localPoints(), + labelList(), + labelListList(), + this->srcPatch_.localFaces() + ); + const fileName tgtFileName = type() + "_tgtPatch.vtk"; + Info<< indent << "Writing patch to " << tgtFileName << endl; + vtkWritePolyData::write + ( + tgtFileName, + "target", + false, + this->tgtPatch_.localPoints(), + labelList(), + labelListList(), + this->tgtPatch_.localFaces() + ); + Info<< decrIndent; + } + + // Step 1: Triangulate the source and target patches and create addressing + DynamicList srcTris, tgtTris; + DynamicList