From 569fa31d09f98e29d1aaf84d40bb16043f104ec6 Mon Sep 17 00:00:00 2001 From: Will Bainbridge Date: Mon, 9 May 2022 14:35:11 +0100 Subject: [PATCH] Non-Conformal Coupled (NCC): Conservative coupling of non-conforming patches This major development provides coupling of patches which are non-conformal, i.e. where the faces of one patch do not match the faces of the other. The coupling is fully conservative and second order accurate in space, unlike the Arbitrary Mesh Interface (AMI) and associated ACMI and Repeat AMI methods which NCC replaces. Description: A non-conformal couple is a connection between a pair of boundary patches formed by projecting one patch onto the other in a way that fills the space between them. The intersection between the projected surface and patch forms new faces that are incorporated into the finite volume mesh. These new faces are created identically on both sides of the couple, and therefore become equivalent to internal faces within the mesh. The affected cells remain closed, meaning that the area vectors sum to zero for all the faces of each cell. Consequently, the main benefits of the finite volume method, i.e. conservation and accuracy, are not undermined by the coupling. A couple connects parts of mesh that are otherwise disconnected and can be used in the following ways: + to simulate rotating geometries, e.g. a propeller or stirrer, in which a part of the mesh rotates with the geometry and connects to a surrounding mesh which is not moving; + to connect meshes that are generated separately, which do not conform at their boundaries; + to connect patches which only partially overlap, in which the non-overlapped section forms another boundary, e.g. a wall; + to simulate a case with a geometry which is periodically repeating by creating multiple couples with different transformations between patches. The capability for simulating partial overlaps replaces the ACMI functionality, currently provided by the 'cyclicACMI' patch type, and which is unreliable unless the couple is perfectly flat. The capability for simulating periodically repeating geometry replaces the Repeat AMI functionality currently provided by the 'cyclicRepeatAMI' patch type. Usage: The process of meshing for NCC is very similar to existing processes for meshing for AMI. Typically, a mesh is generated with an identifiable set of internal faces which coincide with the surface through which the mesh will be coupled. These faces are then duplicated by running the 'createBaffles' utility to create two boundary patches. The points are then split using 'splitBaffles' in order to permit independent motion of the patches. In AMI, these patches are assigned the 'cyclicAMI' patch type, which couples them using AMI interpolation methods. With NCC, the patches remain non-coupled, e.g. a 'wall' type. Coupling is instead achieved by running the new 'createNonConformalCouples' utility, which creates additional coupled patches of type 'nonConformalCyclic'. These appear in the 'constant/polyMesh/boundary' file with zero faces; they are populated with faces in the finite volume mesh during the connection process in NCC. For a single couple, such as that which separates the rotating and stationary sections of a mesh, the utility can be called using the non-coupled patch names as arguments, e.g. createNonConformalCouples -overwrite rotatingZoneInner rotatingZoneOuter where 'rotatingZoneInner' and 'rotatingZoneOuter' are the names of the patches. For multiple couples, and/or couples with transformations, 'createNonConformalCouples' should be run without arguments. Settings will then be read from a configuration file named 'system/createNonConformalCouplesDict'. See '$FOAM_ETC/caseDicts/annotated/createNonConformalCouplesDict' for examples. Boundary conditions must be specified for the non-coupled patches. For a couple where the patches fully overlap, boundary conditions corresponding to a slip wall are typically applied to fields, i.e 'movingWallSlipVelocity' (or 'slip' if the mesh is stationary) for velocity U, 'zeroGradient' or 'fixedFluxPressure' for pressure p, and 'zeroGradient' for other fields. For a couple with partially-overlapping patches, boundary conditions are applied which physically represent the non-overlapped region, e.g. a no-slip wall. Boundary conditions also need to be specified for the 'nonConformalCyclic' patches created by 'createNonConformalCouples'. It is generally recommended that this is done by including the '$FOAM_ETC/caseDicts/setConstraintTypes' file in the 'boundaryField' section of each of the field files, e.g. boundaryField { #includeEtc "caseDicts/setConstraintTypes" inlet { ... } ... } For moving mesh cases, it may be necessary to correct the mesh fluxes that are changed as a result of the connection procedure. If the connected patches do not conform perfectly to the mesh motion, then failure to correct the fluxes can result in noise in the pressure solution. Correction for the mesh fluxes is enabled by the 'correctMeshPhi' switch in the 'PIMPLE' (or equivalent) section of 'system/fvSolution'. When it is enabled, solver settings are required for 'MeshPhi'. The solution just needs to distribute the error enough to dissipate the noise. A smooth solver with a loose tolerance is typically sufficient, e.g. the settings in 'system/fvSolution' shown below: solvers { MeshPhi { solver smoothSolver; smoother symGaussSeidel; tolerance 1e-2; relTol 0; } ... } PIMPLE { correctMeshPhi yes; ... } The solution of 'MeshPhi' is an inexpensive computation since it is applied only to a small subset of the mesh adjacent to the couple. Conservation is maintained whether or not the mesh flux correction is enabled, and regardless of the solution tolerance for 'MeshPhi'. Advantages of NCC: + NCC maintains conservation which is required for many numerical schemes and algorithms to operate effectively, in particular those designed to maintain boundedness of a solution. + Closed-volume systems no longer suffer from accumulation or loss of mass, poor convergence of the pressure equation, and/or concentration of error in the reference cell. + Partially overlapped simulations are now possible on surfaces that are not perfectly flat. The projection fills space so no overlaps or spaces are generated inside contiguously overlapping sections, even if those sections have sharp angles. + The finite volume faces created by NCC have geometrically accurate centres. This makes the method second order accurate in space. + The polyhedral mesh no longer requires duplicate boundary faces to be generated in order to run a partially overlapped simulation. + Lagrangian elements can now transfer across non-conformal couplings in parallel. + Once the intersection has been computed and applied to the finite volume mesh, it can use standard cyclic or processor cyclic finite volume boundary conditions, with no need for additional patch types or matrix interfaces. + Parallel communication is done using the standard processor-patch-field system. This is more efficient than alternative systems since it has been carefully optimised for use within the linear solvers. + Coupled patches are disconnected prior to mesh motion and topology change and reconnected afterwards. This simplifies the boundary condition specification for mesh motion fields. Resolved Bug Reports: + https://bugs.openfoam.org/view.php?id=663 + https://bugs.openfoam.org/view.php?id=883 + https://bugs.openfoam.org/view.php?id=887 + https://bugs.openfoam.org/view.php?id=1337 + https://bugs.openfoam.org/view.php?id=1388 + https://bugs.openfoam.org/view.php?id=1422 + https://bugs.openfoam.org/view.php?id=1829 + https://bugs.openfoam.org/view.php?id=1841 + https://bugs.openfoam.org/view.php?id=2274 + https://bugs.openfoam.org/view.php?id=2561 + https://bugs.openfoam.org/view.php?id=3817 Deprecation: NCC replaces the functionality provided by AMI, ACMI and Repeat AMI. ACMI and Repeat AMI are insufficiently reliable to warrant further maintenance so are removed in an accompanying commit to OpenFOAM-dev. AMI is more widely used so will be retained alongside NCC for the next version release of OpenFOAM and then subsequently removed from OpenFOAM-dev. --- applications/test/fvMeshStitcher/Make/files | 3 + applications/test/fvMeshStitcher/Make/options | 9 + .../test/fvMeshStitcher/Test-fvMeshStitcher.C | 78 + applications/test/patchToPatch/Make/files | 3 + applications/test/patchToPatch/Make/options | 7 + .../test/patchToPatch/Test-patchToPatch.C | 77 + .../Test-volPointInterpolation.C | 92 +- .../createNonConformalCouples/Make/files | 3 + .../createNonConformalCouples/Make/options | 9 + .../createNonConformalCouples.C | 377 ++++ .../decomposePar/Make/files | 1 - .../decomposePar/Make/options | 16 +- .../decomposePar/decomposePar.C | 286 +-- .../decomposePar/fvFieldDecomposer.C | 134 +- .../decomposePar/fvFieldDecomposer.H | 73 +- .../fvFieldDecomposerDecomposeFields.C | 170 +- .../reconstructPar/Make/files | 3 + .../reconstructPar/Make/options | 14 +- .../reconstructPar/checkFaceAddressingComp.H | 48 - .../reconstructPar}/fvFieldReconstructor.C | 37 +- .../reconstructPar}/fvFieldReconstructor.H | 34 +- .../fvFieldReconstructorReconstructFields.C | 408 ++-- .../reconstructPar}/pointFieldReconstructor.C | 12 +- .../reconstructPar}/pointFieldReconstructor.H | 6 +- ...pointFieldReconstructorReconstructFields.C | 16 +- .../reconstructPar}/reconstructLagrangian.H | 6 +- .../reconstructLagrangianFields.C | 2 +- .../reconstructLagrangianPositions.C | 6 +- .../reconstructPar/reconstructPar.C | 551 +----- .../preProcessing/setFields/setFields.C | 104 +- bin/tools/CleanFunctions | 3 +- .../annotated/createNonConformalCouplesDict | 69 + etc/caseDicts/annotated/decomposeParDict | 17 +- .../mesh/manipulation/AMI/createPatchDict | 54 - .../{AMI => NCC}/createBafflesDict | 22 +- etc/caseDicts/setConstraintTypes | 16 +- src/Allwmake | 1 + .../LESdeltas/vanDriestDelta/vanDriestDelta.C | 9 + .../LESdeltas/vanDriestDelta/vanDriestDelta.H | 1 + .../epsilonWallFunctionFvPatchScalarField.C | 137 +- .../epsilonWallFunctionFvPatchScalarField.H | 10 - .../omegaWallFunctionFvPatchScalarField.C | 134 +- .../omegaWallFunctionFvPatchScalarField.H | 12 +- .../epsilonmWallFunctionFvPatchScalarField.C | 55 +- .../epsilonmWallFunctionFvPatchScalarField.H | 7 - .../GeometricField/GeometricBoundaryField.C | 33 +- .../GeometricField/GeometricBoundaryField.H | 8 + .../GeometricField/GeometricField.C | 24 + .../GeometricField/GeometricField.H | 3 + .../basic/coupled/coupledPointPatchField.H | 24 +- .../constraint/cyclic/cyclicPointPatchField.C | 66 +- .../constraint/cyclic/cyclicPointPatchField.H | 9 +- .../processor/processorPointPatchField.H | 10 +- .../processorCyclicPointPatchField.C | 85 +- .../processorCyclicPointPatchField.H | 16 +- src/OpenFOAM/global/argList/argList.C | 16 +- src/OpenFOAM/global/argList/argList.H | 3 + .../LduMatrix/LduMatrix/SolverPerformance.C | 6 +- .../cyclicGAMGInterfaceField.C | 18 +- .../processorCyclicGAMGInterfaceField.C | 18 +- .../cyclicGAMGInterface/cyclicGAMGInterface.C | 19 +- .../processorCyclicGAMGInterface.C | 18 +- src/OpenFOAM/matrices/solution/solution.C | 17 +- .../processor/processorPointPatch.H | 7 - .../polyBoundaryMesh/polyBoundaryMesh.C | 29 + .../polyBoundaryMesh/polyBoundaryMesh.H | 5 + src/OpenFOAM/meshes/polyMesh/polyMesh.H | 3 + src/OpenFOAM/meshes/polyMesh/polyMeshIO.C | 18 + .../processorCyclicPolyPatch.C | 30 + .../processorCyclicPolyPatch.H | 20 +- src/dynamicMesh/fvMeshSubset/fvMeshSubset.C | 16 +- src/dynamicMesh/fvMeshSubset/fvMeshSubset.H | 10 +- src/finiteVolume/Make/files | 18 + .../FvFaceCellWave/FvFaceCellWave.C | 53 +- .../basic/coupled/coupledFvPatchField.H | 8 +- .../basic/sliced/slicedFvPatchField.C | 42 +- .../basic/sliced/slicedFvPatchField.H | 18 +- .../constraint/cyclic/cyclicFvPatchField.C | 8 +- .../constraint/cyclic/cyclicFvPatchField.H | 5 +- .../cyclicACMI/cyclicACMIFvPatchField.C | 33 +- .../cyclicACMI/cyclicACMIFvPatchField.H | 8 +- .../cyclicAMI/cyclicAMIFvPatchField.C | 7 +- .../cyclicAMI/cyclicAMIFvPatchField.H | 5 +- .../jumpCyclic/jumpCyclicFvPatchField.C | 7 +- .../jumpCyclic/jumpCyclicFvPatchField.H | 7 +- .../jumpCyclicAMI/jumpCyclicAMIFvPatchField.C | 7 +- .../jumpCyclicAMI/jumpCyclicAMIFvPatchField.H | 7 +- .../nonConformalCyclicFvPatchField.C | 82 + .../nonConformalCyclicFvPatchField.H | 150 ++ .../nonConformalCyclicFvPatchFields.C | 43 + .../nonConformalCyclicFvPatchFields.H | 49 + .../nonConformalCyclicFvPatchFieldsFwd.H | 50 + .../nonConformalErrorFvPatchField.C | 82 + .../nonConformalErrorFvPatchField.H | 144 ++ .../nonConformalErrorFvPatchFields.C | 43 + .../nonConformalErrorFvPatchFields.H | 49 + .../nonConformalErrorFvPatchFieldsFwd.H | 50 + .../nonConformalProcessorCyclicFvPatchField.C | 110 ++ .../nonConformalProcessorCyclicFvPatchField.H | 180 ++ ...nonConformalProcessorCyclicFvPatchFields.C | 43 + ...nonConformalProcessorCyclicFvPatchFields.H | 49 + ...ConformalProcessorCyclicFvPatchFieldsFwd.H | 50 + .../processor/processorFvPatchField.C | 7 +- .../processor/processorFvPatchField.H | 7 +- .../processorCyclicFvPatchField.C | 6 +- .../fvPatchFields/fvPatchField/fvPatchField.C | 26 +- .../fvPatchFields/fvPatchField/fvPatchField.H | 29 +- .../basic/coupled/coupledFvsPatchFields.C | 3 +- .../basic/coupled/coupledFvsPatchFields.H | 3 +- .../nonConformalCalculatedFvsPatchField.C | 98 + .../nonConformalCalculatedFvsPatchField.H | 145 ++ .../nonConformalCalculatedFvsPatchFields.C | 44 + .../nonConformalCalculatedFvsPatchFields.H | 50 + .../nonConformalCalculatedFvsPatchFieldsFwd.H | 56 + .../constraint/cyclic/cyclicFvsPatchFields.C | 3 +- .../constraint/cyclic/cyclicFvsPatchFields.H | 3 +- .../nonConformalCyclicFvsPatchField.C | 100 + .../nonConformalCyclicFvsPatchField.H | 131 ++ .../nonConformalCyclicFvsPatchFields.C | 44 + .../nonConformalCyclicFvsPatchFields.H | 50 + .../nonConformalCyclicFvsPatchFieldsFwd.H | 50 + .../nonConformalErrorFvsPatchField.C | 100 + .../nonConformalErrorFvsPatchField.H | 131 ++ .../nonConformalErrorFvsPatchFields.C | 44 + .../nonConformalErrorFvsPatchFields.H | 50 + .../nonConformalErrorFvsPatchFieldsFwd.H | 50 + ...nonConformalProcessorCyclicFvsPatchField.C | 107 ++ ...nonConformalProcessorCyclicFvsPatchField.H | 147 ++ ...onConformalProcessorCyclicFvsPatchFields.C | 44 + ...onConformalProcessorCyclicFvsPatchFields.H | 50 + ...onformalProcessorCyclicFvsPatchFieldsFwd.H | 50 + .../processor/processorFvsPatchFields.C | 3 +- .../processor/processorFvsPatchFields.H | 3 +- .../processorCyclicFvsPatchField.C | 6 +- .../processorCyclicFvsPatchFields.C | 3 +- .../processorCyclicFvsPatchFields.H | 3 +- .../finiteVolume/fvSchemes/fvSchemes.C | 17 +- .../fvMatrices/fvMatrix/fvMatrix.C | 20 +- src/finiteVolume/fvMesh/fvMesh.C | 408 +++- src/finiteVolume/fvMesh/fvMesh.H | 136 +- src/finiteVolume/fvMesh/fvMeshGeometry.C | 152 +- .../fvMeshStitcher/fvMeshStitcher.C | 1481 +++++++++++++++ .../fvMeshStitcher/fvMeshStitcher.H | 405 ++++ .../fvMeshStitcher/fvMeshStitcherNew.C | 97 + .../fvMeshStitcher/fvMeshStitcherTemplates.C | 737 ++++++++ .../stationary/fvMeshStitchersStationary.C | 79 + .../stationary/fvMeshStitchersStationary.H | 106 ++ .../fvPatches/basic/coupled/coupledFvPatch.C | 57 +- .../fvPatches/basic/coupled/coupledFvPatch.H | 34 +- .../constraint/cyclic/cyclicFvPatch.C | 69 +- .../nonConformal/nonConformalFvPatch.C | 127 ++ .../nonConformal/nonConformalFvPatch.H | 126 ++ .../nonConformalCoupledFvPatch.C | 154 ++ .../nonConformalCoupledFvPatch.H | 136 ++ .../nonConformalCyclicFvPatch.C | 124 ++ .../nonConformalCyclicFvPatch.H | 145 ++ .../nonConformalErrorFvPatch.C | 92 + .../nonConformalErrorFvPatch.H | 118 ++ .../nonConformalProcessorCyclicFvPatch.C | 143 ++ .../nonConformalProcessorCyclicFvPatch.H | 142 ++ .../constraint/processor/processorFvPatch.C | 71 +- .../constraint/processor/processorFvPatch.H | 9 +- .../processorCyclic/processorCyclicFvPatch.H | 15 +- .../fvMesh/fvPatches/fvPatch/fvPatch.C | 2 +- .../fvMesh/fvPatches/fvPatch/fvPatch.H | 5 +- .../fvPatchDistWave/fvPatchDistWave.C | 21 +- .../fvPatchDistWave/fvPatchDistWave.H | 9 +- .../fvPatchDistWaveTemplates.C | 18 +- .../wallDist/nearWallDist/nearWallDist.C | 3 + .../meshWave/meshWavePatchDistMethod.C | 11 +- .../meshWave/meshWavePatchDistMethod.H | 7 +- .../volPointInterpolation.C | 499 +++-- .../volPointInterpolation.H | 97 +- .../volPointInterpolationTemplates.C | 269 +++ .../field/nearWallFields/findCellParticle.C | 29 +- .../field/nearWallFields/findCellParticle.H | 6 +- .../field/streamlines/streamlinesParticle.C | 46 +- .../field/streamlines/streamlinesParticle.H | 19 +- src/fvMeshDistributors/Make/options | 3 +- src/fvMeshMovers/Make/options | 3 +- src/fvMeshStitchers/Make/files | 3 + src/fvMeshStitchers/Make/options | 9 + .../moving/fvMeshStitchersMoving.C | 1075 +++++++++++ .../moving/fvMeshStitchersMoving.H | 148 ++ src/fvMeshTopoChangers/Make/options | 3 +- .../inverseDistanceDiffusivity.C | 1 + .../inverseFaceDistanceDiffusivity.C | 1 + .../parcels/Templates/DSMCParcel/DSMCParcel.C | 26 +- .../parcels/Templates/DSMCParcel/DSMCParcel.H | 12 +- src/lagrangian/basic/Cloud/Cloud.C | 255 ++- src/lagrangian/basic/Cloud/Cloud.H | 42 + src/lagrangian/basic/Cloud/CloudIO.C | 5 +- src/lagrangian/basic/particle/particle.C | 144 +- src/lagrangian/basic/particle/particle.H | 78 +- .../basic/particle/particleTemplates.C | 94 +- .../molecule/molecule/molecule.C | 18 +- .../molecule/molecule/molecule.H | 9 +- .../CollidingParcel/CollidingParcel.C | 4 +- .../Templates/MPPICParcel/MPPICParcel.C | 6 +- .../Templates/MomentumParcel/MomentumParcel.C | 18 +- .../Templates/MomentumParcel/MomentumParcel.H | 7 +- src/lagrangian/solidParticle/solidParticle.C | 22 +- src/lagrangian/solidParticle/solidParticle.H | 10 +- .../trackedParticle/trackedParticle.C | 49 +- .../trackedParticle/trackedParticle.H | 16 +- .../cyclicAMIPointPatchField.C | 106 +- .../cyclicAMIPointPatchField.H | 9 +- src/meshTools/Make/files | 17 + .../nonConformalCyclicPointPatchField.C | 98 + .../nonConformalCyclicPointPatchField.H | 128 ++ .../nonConformalCyclicPointPatchFields.C | 43 + .../nonConformalCyclicPointPatchFields.H | 49 + .../nonConformalErrorPointPatchField.C | 98 + .../nonConformalErrorPointPatchField.H | 128 ++ .../nonConformalErrorPointPatchFields.C | 43 + .../nonConformalErrorPointPatchFields.H | 49 + ...nConformalProcessorCyclicPointPatchField.C | 102 + ...nConformalProcessorCyclicPointPatchField.H | 129 ++ ...ConformalProcessorCyclicPointPatchFields.C | 43 + ...ConformalProcessorCyclicPointPatchFields.H | 49 + .../nonConformalCyclicPointPatch.C | 48 + .../nonConformalCyclicPointPatch.H | 86 + .../nonConformalErrorPointPatch.C | 48 + .../nonConformalErrorPointPatch.H | 86 + .../nonConformalProcessorCyclicPointPatch.C | 45 + .../nonConformalProcessorCyclicPointPatch.H | 83 + .../nonConformal/nonConformalPolyPatch.C | 191 ++ .../nonConformal/nonConformalPolyPatch.H | 138 ++ .../nonConformalCoupledPolyPatch.C | 196 ++ .../nonConformalCoupledPolyPatch.H | 154 ++ .../nonConformalCyclicPolyPatch.C | 397 ++++ .../nonConformalCyclicPolyPatch.H | 285 +++ .../nonConformalErrorPolyPatch.C | 164 ++ .../nonConformalErrorPolyPatch.H | 221 +++ .../nonConformalProcessorCyclicPolyPatch.C | 188 ++ .../nonConformalProcessorCyclicPolyPatch.H | 226 +++ .../nonConformalBoundary.C | 640 +++++++ .../nonConformalBoundary.H | 196 ++ src/parallel/Allwmake | 2 +- src/parallel/parallel/Make/files | 6 + src/parallel/parallel/Make/options | 11 + src/parallel/parallel/domainDecomposition.C | 1679 +++++++++++++++++ .../parallel/parallel}/domainDecomposition.H | 223 ++- .../parallel/domainDecompositionDecompose.C | 981 +++------- .../parallel/domainDecompositionReconstruct.C | 45 + src/parallel/parallel/processorRunTimes.C | 117 ++ src/parallel/parallel/processorRunTimes.H | 111 ++ src/parallel/reconstruct/Allwmake | 9 - .../reconstruct/reconstruct/Make/files | 6 - .../reconstruct/reconstruct/Make/options | 9 - .../reconstruct/reconstruct/processorMeshes.C | 223 --- .../reconstruct/reconstruct/processorMeshes.H | 136 -- .../sampledSet/sampledSetParticle.C | 14 +- .../sampledSet/sampledSetParticle.H | 5 +- 254 files changed, 18751 insertions(+), 4327 deletions(-) create mode 100644 applications/test/fvMeshStitcher/Make/files create mode 100644 applications/test/fvMeshStitcher/Make/options create mode 100644 applications/test/fvMeshStitcher/Test-fvMeshStitcher.C create mode 100644 applications/test/patchToPatch/Make/files create mode 100644 applications/test/patchToPatch/Make/options create mode 100644 applications/test/patchToPatch/Test-patchToPatch.C create mode 100644 applications/utilities/mesh/manipulation/createNonConformalCouples/Make/files create mode 100644 applications/utilities/mesh/manipulation/createNonConformalCouples/Make/options create mode 100644 applications/utilities/mesh/manipulation/createNonConformalCouples/createNonConformalCouples.C delete mode 100644 applications/utilities/parallelProcessing/reconstructPar/checkFaceAddressingComp.H rename {src/parallel/reconstruct/reconstruct => applications/utilities/parallelProcessing/reconstructPar}/fvFieldReconstructor.C (73%) rename {src/parallel/reconstruct/reconstruct => applications/utilities/parallelProcessing/reconstructPar}/fvFieldReconstructor.H (86%) rename {src/parallel/reconstruct/reconstruct => applications/utilities/parallelProcessing/reconstructPar}/fvFieldReconstructorReconstructFields.C (51%) rename {src/parallel/reconstruct/reconstruct => applications/utilities/parallelProcessing/reconstructPar}/pointFieldReconstructor.C (91%) rename {src/parallel/reconstruct/reconstruct => applications/utilities/parallelProcessing/reconstructPar}/pointFieldReconstructor.H (96%) rename {src/parallel/reconstruct/reconstruct => applications/utilities/parallelProcessing/reconstructPar}/pointFieldReconstructorReconstructFields.C (91%) rename {src/parallel/reconstruct/reconstruct => applications/utilities/parallelProcessing/reconstructPar}/reconstructLagrangian.H (94%) rename {src/parallel/reconstruct/reconstruct => applications/utilities/parallelProcessing/reconstructPar}/reconstructLagrangianFields.C (99%) rename {src/parallel/reconstruct/reconstruct => applications/utilities/parallelProcessing/reconstructPar}/reconstructLagrangianPositions.C (94%) create mode 100644 etc/caseDicts/annotated/createNonConformalCouplesDict delete mode 100644 etc/caseDicts/mesh/manipulation/AMI/createPatchDict rename etc/caseDicts/mesh/manipulation/{AMI => NCC}/createBafflesDict (56%) create mode 100644 src/finiteVolume/fields/fvPatchFields/constraint/nonConformalCyclic/nonConformalCyclicFvPatchField.C create mode 100644 src/finiteVolume/fields/fvPatchFields/constraint/nonConformalCyclic/nonConformalCyclicFvPatchField.H create mode 100644 src/finiteVolume/fields/fvPatchFields/constraint/nonConformalCyclic/nonConformalCyclicFvPatchFields.C create mode 100644 src/finiteVolume/fields/fvPatchFields/constraint/nonConformalCyclic/nonConformalCyclicFvPatchFields.H create mode 100644 src/finiteVolume/fields/fvPatchFields/constraint/nonConformalCyclic/nonConformalCyclicFvPatchFieldsFwd.H create mode 100644 src/finiteVolume/fields/fvPatchFields/constraint/nonConformalError/nonConformalErrorFvPatchField.C create mode 100644 src/finiteVolume/fields/fvPatchFields/constraint/nonConformalError/nonConformalErrorFvPatchField.H create mode 100644 src/finiteVolume/fields/fvPatchFields/constraint/nonConformalError/nonConformalErrorFvPatchFields.C create mode 100644 src/finiteVolume/fields/fvPatchFields/constraint/nonConformalError/nonConformalErrorFvPatchFields.H create mode 100644 src/finiteVolume/fields/fvPatchFields/constraint/nonConformalError/nonConformalErrorFvPatchFieldsFwd.H create mode 100644 src/finiteVolume/fields/fvPatchFields/constraint/nonConformalProcessorCyclic/nonConformalProcessorCyclicFvPatchField.C create mode 100644 src/finiteVolume/fields/fvPatchFields/constraint/nonConformalProcessorCyclic/nonConformalProcessorCyclicFvPatchField.H create mode 100644 src/finiteVolume/fields/fvPatchFields/constraint/nonConformalProcessorCyclic/nonConformalProcessorCyclicFvPatchFields.C create mode 100644 src/finiteVolume/fields/fvPatchFields/constraint/nonConformalProcessorCyclic/nonConformalProcessorCyclicFvPatchFields.H create mode 100644 src/finiteVolume/fields/fvPatchFields/constraint/nonConformalProcessorCyclic/nonConformalProcessorCyclicFvPatchFieldsFwd.H create mode 100644 src/finiteVolume/fields/fvsPatchFields/basic/nonConformalCalculated/nonConformalCalculatedFvsPatchField.C create mode 100644 src/finiteVolume/fields/fvsPatchFields/basic/nonConformalCalculated/nonConformalCalculatedFvsPatchField.H create mode 100644 src/finiteVolume/fields/fvsPatchFields/basic/nonConformalCalculated/nonConformalCalculatedFvsPatchFields.C create mode 100644 src/finiteVolume/fields/fvsPatchFields/basic/nonConformalCalculated/nonConformalCalculatedFvsPatchFields.H create mode 100644 src/finiteVolume/fields/fvsPatchFields/basic/nonConformalCalculated/nonConformalCalculatedFvsPatchFieldsFwd.H create mode 100644 src/finiteVolume/fields/fvsPatchFields/constraint/nonConformalCyclic/nonConformalCyclicFvsPatchField.C create mode 100644 src/finiteVolume/fields/fvsPatchFields/constraint/nonConformalCyclic/nonConformalCyclicFvsPatchField.H create mode 100644 src/finiteVolume/fields/fvsPatchFields/constraint/nonConformalCyclic/nonConformalCyclicFvsPatchFields.C create mode 100644 src/finiteVolume/fields/fvsPatchFields/constraint/nonConformalCyclic/nonConformalCyclicFvsPatchFields.H create mode 100644 src/finiteVolume/fields/fvsPatchFields/constraint/nonConformalCyclic/nonConformalCyclicFvsPatchFieldsFwd.H create mode 100644 src/finiteVolume/fields/fvsPatchFields/constraint/nonConformalError/nonConformalErrorFvsPatchField.C create mode 100644 src/finiteVolume/fields/fvsPatchFields/constraint/nonConformalError/nonConformalErrorFvsPatchField.H create mode 100644 src/finiteVolume/fields/fvsPatchFields/constraint/nonConformalError/nonConformalErrorFvsPatchFields.C create mode 100644 src/finiteVolume/fields/fvsPatchFields/constraint/nonConformalError/nonConformalErrorFvsPatchFields.H create mode 100644 src/finiteVolume/fields/fvsPatchFields/constraint/nonConformalError/nonConformalErrorFvsPatchFieldsFwd.H create mode 100644 src/finiteVolume/fields/fvsPatchFields/constraint/nonConformalProcessorCyclic/nonConformalProcessorCyclicFvsPatchField.C create mode 100644 src/finiteVolume/fields/fvsPatchFields/constraint/nonConformalProcessorCyclic/nonConformalProcessorCyclicFvsPatchField.H create mode 100644 src/finiteVolume/fields/fvsPatchFields/constraint/nonConformalProcessorCyclic/nonConformalProcessorCyclicFvsPatchFields.C create mode 100644 src/finiteVolume/fields/fvsPatchFields/constraint/nonConformalProcessorCyclic/nonConformalProcessorCyclicFvsPatchFields.H create mode 100644 src/finiteVolume/fields/fvsPatchFields/constraint/nonConformalProcessorCyclic/nonConformalProcessorCyclicFvsPatchFieldsFwd.H create mode 100644 src/finiteVolume/fvMesh/fvMeshStitchers/fvMeshStitcher/fvMeshStitcher.C create mode 100644 src/finiteVolume/fvMesh/fvMeshStitchers/fvMeshStitcher/fvMeshStitcher.H create mode 100644 src/finiteVolume/fvMesh/fvMeshStitchers/fvMeshStitcher/fvMeshStitcherNew.C create mode 100644 src/finiteVolume/fvMesh/fvMeshStitchers/fvMeshStitcher/fvMeshStitcherTemplates.C create mode 100644 src/finiteVolume/fvMesh/fvMeshStitchers/stationary/fvMeshStitchersStationary.C create mode 100644 src/finiteVolume/fvMesh/fvMeshStitchers/stationary/fvMeshStitchersStationary.H create mode 100644 src/finiteVolume/fvMesh/fvPatches/constraint/nonConformal/nonConformalFvPatch.C create mode 100644 src/finiteVolume/fvMesh/fvPatches/constraint/nonConformal/nonConformalFvPatch.H create mode 100644 src/finiteVolume/fvMesh/fvPatches/constraint/nonConformalCoupled/nonConformalCoupledFvPatch.C create mode 100644 src/finiteVolume/fvMesh/fvPatches/constraint/nonConformalCoupled/nonConformalCoupledFvPatch.H create mode 100644 src/finiteVolume/fvMesh/fvPatches/constraint/nonConformalCyclic/nonConformalCyclicFvPatch.C create mode 100644 src/finiteVolume/fvMesh/fvPatches/constraint/nonConformalCyclic/nonConformalCyclicFvPatch.H create mode 100644 src/finiteVolume/fvMesh/fvPatches/constraint/nonConformalError/nonConformalErrorFvPatch.C create mode 100644 src/finiteVolume/fvMesh/fvPatches/constraint/nonConformalError/nonConformalErrorFvPatch.H create mode 100644 src/finiteVolume/fvMesh/fvPatches/constraint/nonConformalProcessorCyclic/nonConformalProcessorCyclicFvPatch.C create mode 100644 src/finiteVolume/fvMesh/fvPatches/constraint/nonConformalProcessorCyclic/nonConformalProcessorCyclicFvPatch.H create mode 100644 src/finiteVolume/interpolation/volPointInterpolation/volPointInterpolationTemplates.C create mode 100644 src/fvMeshStitchers/Make/files create mode 100644 src/fvMeshStitchers/Make/options create mode 100644 src/fvMeshStitchers/moving/fvMeshStitchersMoving.C create mode 100644 src/fvMeshStitchers/moving/fvMeshStitchersMoving.H create mode 100644 src/meshTools/nonConformal/pointPatchFields/nonConformalCyclic/nonConformalCyclicPointPatchField.C create mode 100644 src/meshTools/nonConformal/pointPatchFields/nonConformalCyclic/nonConformalCyclicPointPatchField.H create mode 100644 src/meshTools/nonConformal/pointPatchFields/nonConformalCyclic/nonConformalCyclicPointPatchFields.C create mode 100644 src/meshTools/nonConformal/pointPatchFields/nonConformalCyclic/nonConformalCyclicPointPatchFields.H create mode 100644 src/meshTools/nonConformal/pointPatchFields/nonConformalError/nonConformalErrorPointPatchField.C create mode 100644 src/meshTools/nonConformal/pointPatchFields/nonConformalError/nonConformalErrorPointPatchField.H create mode 100644 src/meshTools/nonConformal/pointPatchFields/nonConformalError/nonConformalErrorPointPatchFields.C create mode 100644 src/meshTools/nonConformal/pointPatchFields/nonConformalError/nonConformalErrorPointPatchFields.H create mode 100644 src/meshTools/nonConformal/pointPatchFields/nonConformalProcessorCyclic/nonConformalProcessorCyclicPointPatchField.C create mode 100644 src/meshTools/nonConformal/pointPatchFields/nonConformalProcessorCyclic/nonConformalProcessorCyclicPointPatchField.H create mode 100644 src/meshTools/nonConformal/pointPatchFields/nonConformalProcessorCyclic/nonConformalProcessorCyclicPointPatchFields.C create mode 100644 src/meshTools/nonConformal/pointPatchFields/nonConformalProcessorCyclic/nonConformalProcessorCyclicPointPatchFields.H create mode 100644 src/meshTools/nonConformal/pointPatches/nonConformalCyclic/nonConformalCyclicPointPatch.C create mode 100644 src/meshTools/nonConformal/pointPatches/nonConformalCyclic/nonConformalCyclicPointPatch.H create mode 100644 src/meshTools/nonConformal/pointPatches/nonConformalError/nonConformalErrorPointPatch.C create mode 100644 src/meshTools/nonConformal/pointPatches/nonConformalError/nonConformalErrorPointPatch.H create mode 100644 src/meshTools/nonConformal/pointPatches/nonConformalProcessorCyclic/nonConformalProcessorCyclicPointPatch.C create mode 100644 src/meshTools/nonConformal/pointPatches/nonConformalProcessorCyclic/nonConformalProcessorCyclicPointPatch.H create mode 100644 src/meshTools/nonConformal/polyPatches/nonConformal/nonConformalPolyPatch.C create mode 100644 src/meshTools/nonConformal/polyPatches/nonConformal/nonConformalPolyPatch.H create mode 100644 src/meshTools/nonConformal/polyPatches/nonConformalCoupled/nonConformalCoupledPolyPatch.C create mode 100644 src/meshTools/nonConformal/polyPatches/nonConformalCoupled/nonConformalCoupledPolyPatch.H create mode 100644 src/meshTools/nonConformal/polyPatches/nonConformalCyclic/nonConformalCyclicPolyPatch.C create mode 100644 src/meshTools/nonConformal/polyPatches/nonConformalCyclic/nonConformalCyclicPolyPatch.H create mode 100644 src/meshTools/nonConformal/polyPatches/nonConformalError/nonConformalErrorPolyPatch.C create mode 100644 src/meshTools/nonConformal/polyPatches/nonConformalError/nonConformalErrorPolyPatch.H create mode 100644 src/meshTools/nonConformal/polyPatches/nonConformalProcessorCyclic/nonConformalProcessorCyclicPolyPatch.C create mode 100644 src/meshTools/nonConformal/polyPatches/nonConformalProcessorCyclic/nonConformalProcessorCyclicPolyPatch.H create mode 100644 src/meshTools/nonConformalBoundary/nonConformalBoundary.C create mode 100644 src/meshTools/nonConformalBoundary/nonConformalBoundary.H create mode 100644 src/parallel/parallel/Make/files create mode 100644 src/parallel/parallel/Make/options create mode 100644 src/parallel/parallel/domainDecomposition.C rename {applications/utilities/parallelProcessing/decomposePar => src/parallel/parallel}/domainDecomposition.H (50%) rename applications/utilities/parallelProcessing/decomposePar/domainDecomposition.C => src/parallel/parallel/domainDecompositionDecompose.C (58%) create mode 100644 src/parallel/parallel/domainDecompositionReconstruct.C create mode 100644 src/parallel/parallel/processorRunTimes.C create mode 100644 src/parallel/parallel/processorRunTimes.H delete mode 100755 src/parallel/reconstruct/Allwmake delete mode 100644 src/parallel/reconstruct/reconstruct/Make/files delete mode 100644 src/parallel/reconstruct/reconstruct/Make/options delete mode 100644 src/parallel/reconstruct/reconstruct/processorMeshes.C delete mode 100644 src/parallel/reconstruct/reconstruct/processorMeshes.H diff --git a/applications/test/fvMeshStitcher/Make/files b/applications/test/fvMeshStitcher/Make/files new file mode 100644 index 0000000000..013d3aa8e8 --- /dev/null +++ b/applications/test/fvMeshStitcher/Make/files @@ -0,0 +1,3 @@ +Test-fvMeshStitcher.C + +EXE = $(FOAM_USER_APPBIN)/Test-fvMeshStitcher diff --git a/applications/test/fvMeshStitcher/Make/options b/applications/test/fvMeshStitcher/Make/options new file mode 100644 index 0000000000..fbb5bf176c --- /dev/null +++ b/applications/test/fvMeshStitcher/Make/options @@ -0,0 +1,9 @@ +EXE_INC = \ + -I$(LIB_SRC)/fileFormats/lnInclude \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude + +EXE_LIBS = \ + -lfileFormats \ + -lfiniteVolume \ + -lmeshTools diff --git a/applications/test/fvMeshStitcher/Test-fvMeshStitcher.C b/applications/test/fvMeshStitcher/Test-fvMeshStitcher.C new file mode 100644 index 0000000000..2518c4e7f7 --- /dev/null +++ b/applications/test/fvMeshStitcher/Test-fvMeshStitcher.C @@ -0,0 +1,78 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2021-2022 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 "argList.H" +#include "fvMesh.H" +#include "Time.H" +#include "timeSelector.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +using namespace Foam; + +int main(int argc, char *argv[]) +{ + Foam::argList::addBoolOption("write", "write mesh/results files"); + #include "addOverwriteOption.H" + #include "addRegionOption.H" + + #include "setRootCase.H" + #include "createTime.H" + runTime.functionObjects().off(); + #include "createNamedMesh.H" + + const bool write = args.optionFound("write"); + const bool overwrite = args.optionFound("overwrite"); + + if (write || overwrite) + { + const word oldInstance = mesh.pointsInstance(); + + mesh.setInstance(runTime.timeName()); + + // Set the precision of the points data to 10 + IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision())); + + if (!overwrite) + { + runTime++; + } + else + { + mesh.setInstance(oldInstance); + } + + // Write resulting mesh + Info<< "Writing mesh to " << runTime.timeName() << nl << endl; + mesh.write(); + } + + Info<< "End" << nl << endl; + + return 0; +} + + +// ************************************************************************* // diff --git a/applications/test/patchToPatch/Make/files b/applications/test/patchToPatch/Make/files new file mode 100644 index 0000000000..af75781c67 --- /dev/null +++ b/applications/test/patchToPatch/Make/files @@ -0,0 +1,3 @@ +Test-patchToPatch.C + +EXE = $(FOAM_USER_APPBIN)/Test-patchToPatch diff --git a/applications/test/patchToPatch/Make/options b/applications/test/patchToPatch/Make/options new file mode 100644 index 0000000000..d820876f44 --- /dev/null +++ b/applications/test/patchToPatch/Make/options @@ -0,0 +1,7 @@ +EXE_INC = \ + -I$(LIB_SRC)/fileFormats/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude + +EXE_LIBS = \ + -lfileFormats \ + -lmeshTools diff --git a/applications/test/patchToPatch/Test-patchToPatch.C b/applications/test/patchToPatch/Test-patchToPatch.C new file mode 100644 index 0000000000..a25f9930fb --- /dev/null +++ b/applications/test/patchToPatch/Test-patchToPatch.C @@ -0,0 +1,77 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2021-2022 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 "argList.H" +#include "AMIInterpolation.H" +#include "cpuTime.H" +#include "patchToPatch.H" +#include "polyMesh.H" +#include "Time.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +using namespace Foam; + + +int main(int argc, char *argv[]) +{ + argList::validArgs.append("source"); + argList::validArgs.append("target"); + argList::validArgs.append("method"); + + #include "setRootCase.H" + #include "createTime.H" + #include "createPolyMesh.H" + + const polyPatch& srcPatch = mesh.boundaryMesh()[args[1]]; + const polyPatch& tgtPatch = mesh.boundaryMesh()[args[2]]; + const word& method = args[3]; + + cpuTime time; + + /* + AMIInterpolation(srcPatch, tgtPatch, faceAreaIntersect::tmMesh); + + Info<< nl << "AMI" << ": Completed in " + << time.cpuTimeIncrement() << " s" << nl << endl; + */ + + patchToPatch::New(method, false)->update + ( + srcPatch, + srcPatch.pointNormals(), + tgtPatch + ); + + Info<< nl << patchToPatch::typeName << ": Completed in " + << time.cpuTimeIncrement() << " s" << nl << endl; + + Info<< "End" << nl << endl; + + return 0; +} + + +// ************************************************************************* // diff --git a/applications/test/volPointInterpolation/Test-volPointInterpolation.C b/applications/test/volPointInterpolation/Test-volPointInterpolation.C index 3d06e2f764..799c39ec2e 100644 --- a/applications/test/volPointInterpolation/Test-volPointInterpolation.C +++ b/applications/test/volPointInterpolation/Test-volPointInterpolation.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -27,45 +27,45 @@ Application \*---------------------------------------------------------------------------*/ #include "fvCFD.H" +#include "timeSelector.H" #include "volPointInterpolation.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +template +bool interpolate(const fvMesh& mesh, const word& name) +{ + typeIOobject> io + ( + name, + mesh.time().timeName(), + mesh, + IOobject::MUST_READ + ); + + if (!io.headerOk()) return false; + + Info<< "Reading field " << name << nl << endl; + + const VolField vf(io, mesh); + const PointField pf(volPointInterpolation::New(mesh).interpolate(vf)); + + Info<< "Writing field " << pf.name() << nl << endl; + + return pf.write(); +} + + int main(int argc, char *argv[]) { + argList::validArgs.append("field"); + + Foam::timeSelector::addOptions(); #include "setRootCase.H" - #include "createTime.H" + Foam::instantList timeDirs = Foam::timeSelector::select0(runTime, args); #include "createMesh.H" - Info<< "Reading field p\n" << endl; - volScalarField p - ( - IOobject - ( - "p", - runTime.timeName(), - mesh, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh - ); - - Info<< "Reading field U\n" << endl; - volVectorField U - ( - IOobject - ( - "U", - runTime.timeName(), - mesh, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh - ); - const pointMesh& pMesh = pointMesh::New(mesh); const pointBoundaryMesh& pbm = pMesh.boundary(); @@ -78,21 +78,31 @@ int main(int argc, char *argv[]) << endl; } - const volPointInterpolation& pInterp = volPointInterpolation::New(mesh); + const word name = args.argRead(1); - - pointScalarField pp(pInterp.interpolate(p)); - Info<< pp.name() << " boundary" << endl; - forAll(pp.boundaryField(), patchi) + forAll(timeDirs, timei) { - Info<< pbm[patchi].name() << " coupled=" - << pp.boundaryField()[patchi].coupled()<< endl; + runTime.setTime(timeDirs[timei], timei); + + Info<< "Time = " << runTime.userTimeName() << endl; + + mesh.readUpdate(); + + if + ( + !interpolate(mesh, name) + && !interpolate(mesh, name) + && !interpolate(mesh, name) + && !interpolate(mesh, name) + && !interpolate(mesh, name) + ) + { + WarningInFunction + << "Could not find field " << name << nl << endl; + } } - pp.write(); - - pointVectorField pU(pInterp.interpolate(U)); - pU.write(); + Info<< "End\n" << endl; return 0; } diff --git a/applications/utilities/mesh/manipulation/createNonConformalCouples/Make/files b/applications/utilities/mesh/manipulation/createNonConformalCouples/Make/files new file mode 100644 index 0000000000..e35a967698 --- /dev/null +++ b/applications/utilities/mesh/manipulation/createNonConformalCouples/Make/files @@ -0,0 +1,3 @@ +createNonConformalCouples.C + +EXE = $(FOAM_APPBIN)/createNonConformalCouples diff --git a/applications/utilities/mesh/manipulation/createNonConformalCouples/Make/options b/applications/utilities/mesh/manipulation/createNonConformalCouples/Make/options new file mode 100644 index 0000000000..9b8c3dea8c --- /dev/null +++ b/applications/utilities/mesh/manipulation/createNonConformalCouples/Make/options @@ -0,0 +1,9 @@ +EXE_INC = \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/dynamicMesh/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude + +EXE_LIBS = \ + -lfiniteVolume \ + -ldynamicMesh \ + -lmeshTools diff --git a/applications/utilities/mesh/manipulation/createNonConformalCouples/createNonConformalCouples.C b/applications/utilities/mesh/manipulation/createNonConformalCouples/createNonConformalCouples.C new file mode 100644 index 0000000000..c92776a9d9 --- /dev/null +++ b/applications/utilities/mesh/manipulation/createNonConformalCouples/createNonConformalCouples.C @@ -0,0 +1,377 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2011-2022 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 . + +Application + createNonConformalCouples + +Description + Utility to create non-conformal couples between non-coupled patches. + +Usage + \b createNonConformalCouples + +Note + If run with two arguments, these arguments specify the patches between + which a single couple is to be created. The resulting couple will not have + a transformation. + +Usage + \b createNonConformalCouples + +Note + If run without arguments then settings are read from a \b + system/createNonConformalCouplesDict dictionary (or from a different + dictionary specified by the \b -dict option). This dictionary can specify + the creation of multiple couples and/or couples with transformations. + +\*---------------------------------------------------------------------------*/ + +#include "argList.H" +#include "fvMeshStitchersStationary.H" +#include "nonConformalCyclicPolyPatch.H" +#include "nonConformalErrorPolyPatch.H" +#include "nonConformalProcessorCyclicPolyPatch.H" +#include "polyMesh.H" +#include "processorPolyPatch.H" +#include "systemDict.H" +#include "Time.H" + +using namespace Foam; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +void createNonConformalCouples +( + fvMesh& mesh, + const List>& patchNames, + const wordList& cyclicNames, + const List& transforms +) +{ + const polyBoundaryMesh& patches = mesh.boundaryMesh(); + + List newPatches; + + // Find the first processor patch and face + label firstProcPatchi = patches.size(), firstProcFacei = mesh.nFaces(); + forAll(patches, patchi) + { + const polyPatch& pp = patches[patchi]; + + if (isA(pp) && firstProcPatchi == patches.size()) + { + firstProcPatchi = patchi; + firstProcFacei = pp.start(); + } + + if (!isA(pp) && firstProcPatchi != patches.size()) + { + FatalErrorInFunction + << "Processor patches do not follow boundary patches" + << exit(FatalError); + } + } + + // Clone the non-processor patches + for (label patchi = 0; patchi < firstProcPatchi; ++ patchi) + { + const polyPatch& pp = patches[patchi]; + + newPatches.append + ( + pp.clone(patches, patchi, pp.size(), pp.start()).ptr() + ); + } + + // Convenience function to generate patch names for the owner or neighbour + auto nccPatchNames = [&](const label i) + { + return + Pair + ( + cyclicNames[i] + "_on_" + patchNames[i][0], + cyclicNames[i] + "_on_" + patchNames[i][1] + ); + }; + + // Add the cyclic patches + forAll(patchNames, i) + { + Info<< indent << "Adding " + << nonConformalCyclicPolyPatch::typeName + << " interfaces between patches: " << incrIndent << nl + << indent << patchNames[i] << decrIndent << nl + << indent << "Named:" << incrIndent << nl + << indent << Pair(nccPatchNames(i)) << decrIndent << nl + << indent << "With transform: " << incrIndent << nl; + transforms[i].write(Info); + Info<< decrIndent << nl; + + newPatches.append + ( + new nonConformalCyclicPolyPatch + ( + nccPatchNames(i)[0], + 0, + firstProcFacei, + newPatches.size(), + patches, + nonConformalCyclicPolyPatch::typeName, + nccPatchNames(i)[1], + patchNames[i][0], + transforms[i] + ) + ); + newPatches.append + ( + new nonConformalCyclicPolyPatch + ( + nccPatchNames(i)[1], + 0, + firstProcFacei, + newPatches.size(), + patches, + nonConformalCyclicPolyPatch::typeName, + nccPatchNames(i)[0], + patchNames[i][1], + inv(transforms[i]) + ) + ); + } + + // Add the error patches. Note there is only one for each source patch, + // regardless of how many interfaces are attached to that patch. + auto appendErrorPatches = [&](const bool owner) + { + wordHashSet patchANames; + forAll(patchNames, i) + { + patchANames.insert(patchNames[i][!owner]); + } + forAllConstIter(wordHashSet, patchANames, iter) + { + newPatches.append + ( + new nonConformalErrorPolyPatch + ( + nonConformalErrorPolyPatch::typeName + "_on_" + iter.key(), + 0, + firstProcFacei, + newPatches.size(), + patches, + nonConformalErrorPolyPatch::typeName, + iter.key() + ) + ); + } + }; + appendErrorPatches(true); + appendErrorPatches(false); + + // Clone the processor patches + for (label patchi = firstProcPatchi; patchi < patches.size(); ++ patchi) + { + const polyPatch& pp = patches[patchi]; + + newPatches.append + ( + pp.clone(patches, newPatches.size(), pp.size(), pp.start()).ptr() + ); + } + + // Add the processor cyclic patches + if (Pstream::parRun()) + { + forAll(patchNames, i) + { + const polyPatch& patch1 = patches[patchNames[i][0]]; + const polyPatch& patch2 = patches[patchNames[i][1]]; + + boolList procHasPatch1(Pstream::nProcs(), false); + procHasPatch1[Pstream::myProcNo()] = !patch1.empty(); + Pstream::gatherList(procHasPatch1); + Pstream::scatterList(procHasPatch1); + + boolList procHasPatch2(Pstream::nProcs(), false); + procHasPatch2[Pstream::myProcNo()] = !patch2.empty(); + Pstream::gatherList(procHasPatch2); + Pstream::scatterList(procHasPatch2); + + // Multiple cyclic interfaces must be ordered in a specific way for + // processor communication to function correctly. + // + // A communication that is sent from the cyclic owner is received + // on the cyclic neighbour and vice versa. Therefore, in a coupled + // pair of processors if one sends the owner first the other must + // receive the neighbour first. + // + // We ensure the above by ordering the patches so that for the + // lower indexed processor the owner interface comes first, and for + // the higher indexed processor the neighbour comes first. + + auto appendProcPatches = [&](const bool owner, const bool first) + { + const boolList& procHasPatchA = + owner ? procHasPatch1 : procHasPatch2; + const boolList& procHasPatchB = + owner ? procHasPatch2 : procHasPatch1; + + if (procHasPatchA[Pstream::myProcNo()]) + { + forAll(procHasPatchB, proci) + { + if + ( + ( + (first && proci < Pstream::myProcNo()) + || (!first && proci > Pstream::myProcNo()) + ) + && procHasPatchB[proci] + ) + { + newPatches.append + ( + new nonConformalProcessorCyclicPolyPatch + ( + 0, + mesh.nFaces(), + newPatches.size(), + patches, + Pstream::myProcNo(), + proci, + nccPatchNames(i)[!owner], + patchNames[i][!owner] + ) + ); + } + } + } + }; + + appendProcPatches(true, true); + appendProcPatches(false, true); + appendProcPatches(false, false); + appendProcPatches(true, false); + } + } + + // Re-patch the mesh + mesh.removeFvBoundary(); + mesh.addFvPatches(newPatches); +} + + +int main(int argc, char *argv[]) +{ + #include "addOverwriteOption.H" + #include "addRegionOption.H" + #include "addDictOption.H" + + const bool haveArgs = argList::hasArgs(argc, argv); + if (haveArgs) + { + argList::validArgs.append("patch1"); + argList::validArgs.append("patch2"); + } + + #include "setRootCase.H" + #include "createTime.H" + runTime.functionObjects().off(); + + // Get the patches between which to create interfaces and the associated + // transformations. If there are arguments then read the patch names from + // the arguments and assume an identity transformation. If not, then load + // the system dictionary and read potentially multiple pairs of patches and + // associated transformations. + List> patchNames; + wordList cyclicNames; + List transforms; + if (haveArgs) + { + patchNames.append(Pair(args[1], args[2])); + cyclicNames.append(nonConformalCyclicPolyPatch::typeName); + transforms.append(cyclicTransform(true)); + } + else + { + static const word dictName("createNonConformalCouplesDict"); + + IOdictionary dict(systemDict(dictName, args, runTime)); + + forAllConstIter(dictionary, dict, iter) + { + patchNames.append(iter().dict().lookup>("patches")); + cyclicNames.append(iter().dict().dictName()); + transforms.append(cyclicTransform(iter().dict(), true)); + } + } + + Foam::word meshRegionName = polyMesh::defaultRegion; + args.optionReadIfPresent("region", meshRegionName); + + const bool overwrite = args.optionFound("overwrite"); + + #include "createNamedMesh.H" + + const word oldInstance = mesh.pointsInstance(); + + // Make sure the mesh is not connected before couples are added + fvMeshStitchers::stationary stitcher(mesh); + stitcher.disconnect(false, false); + + createNonConformalCouples + ( + mesh, + patchNames, + cyclicNames, + transforms + ); + + // Connect the mesh so that the new stitching topology gets written out + stitcher.connect(false, false); + + mesh.setInstance(runTime.timeName()); + + // Set the precision of the points data to 10 + IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision())); + + if (!overwrite) + { + runTime++; + } + else + { + mesh.setInstance(oldInstance); + } + + // Write resulting mesh + Info<< "Writing mesh to " << runTime.timeName() << nl << endl; + mesh.write(); + + Info<< "End\n" << endl; + + return 0; +} + + +// ************************************************************************* // diff --git a/applications/utilities/parallelProcessing/decomposePar/Make/files b/applications/utilities/parallelProcessing/decomposePar/Make/files index 077cbe902a..e5f8107a96 100644 --- a/applications/utilities/parallelProcessing/decomposePar/Make/files +++ b/applications/utilities/parallelProcessing/decomposePar/Make/files @@ -1,5 +1,4 @@ decomposePar.C -domainDecomposition.C dimFieldDecomposer.C fvFieldDecomposer.C pointFieldDecomposer.C diff --git a/applications/utilities/parallelProcessing/decomposePar/Make/options b/applications/utilities/parallelProcessing/decomposePar/Make/options index ca546847e5..75d78ebfd1 100644 --- a/applications/utilities/parallelProcessing/decomposePar/Make/options +++ b/applications/utilities/parallelProcessing/decomposePar/Make/options @@ -1,14 +1,16 @@ EXE_INC = \ - -I$(LIB_SRC)/parallel/decompose/decompositionMethods/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \ - -I$(LIB_SRC)/dynamicMesh/lnInclude \ - -I$(LIB_SRC)/lagrangian/basic/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/parallel/parallel/lnInclude \ + -I$(LIB_SRC)/parallel/decompose/decompositionMethods/lnInclude \ + -I$(LIB_SRC)/lagrangian/basic/lnInclude \ -I$(LIB_SRC)/regionModels/regionModel/lnInclude EXE_LIBS = \ - -ldynamicMesh \ - -lgenericPatchFields \ - -ldecompositionMethods -L$(FOAM_LIBBIN)/dummy -lmetisDecomp -lscotchDecomp \ + -lfiniteVolume \ + -lmeshTools\ + -lparallel \ + -ldecompositionMethods \ -llagrangian \ - -lregionModels + -lregionModels \ + -lgenericPatchFields diff --git a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C index 5f6bae24c7..c30621ee51 100644 --- a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C +++ b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C @@ -79,6 +79,7 @@ Usage \*---------------------------------------------------------------------------*/ +#include "processorRunTimes.H" #include "domainDecomposition.H" #include "decompositionMethod.H" #include "argList.H" @@ -114,14 +115,12 @@ namespace Foam void decomposeUniform ( const bool copyUniform, - const domainDecomposition& decomposition, - const Time& processorDb, + const bool distributeUniform, + const Time& runTime, + const Time& procRunTime, const word& regionDir = word::null ) { - const Time& runTime = decomposition.mesh().time(); - - // Any uniform data to copy/link? const fileName uniformDir(regionDir/"uniform"); if (fileHandler().isDir(runTime.timePath()/uniformDir)) @@ -131,9 +130,9 @@ void decomposeUniform << endl; const fileName timePath = - fileHandler().filePath(processorDb.timePath()); + fileHandler().filePath(procRunTime.timePath()); - if (copyUniform || decomposition.distributed()) + if (copyUniform || distributeUniform) { if (!fileHandler().exists(timePath/uniformDir)) { @@ -171,9 +170,9 @@ void decomposeUniform } -void writeDecomposition(const domainDecomposition& decomposition) +void writeDecomposition(const domainDecomposition& meshes) { - const labelList& procIds = decomposition.cellToProc(); + const labelList& procIds = meshes.cellToProc(); // Write the decomposition as labelList for use with 'manual' // decomposition method. @@ -182,8 +181,8 @@ void writeDecomposition(const domainDecomposition& decomposition) IOobject ( "cellDecomposition", - decomposition.mesh().facesInstance(), - decomposition.mesh(), + meshes.completeMesh().facesInstance(), + meshes.completeMesh(), IOobject::NO_READ, IOobject::NO_WRITE, false @@ -203,12 +202,12 @@ void writeDecomposition(const domainDecomposition& decomposition) IOobject ( "cellDist", - decomposition.mesh().time().timeName(), - decomposition.mesh(), + meshes.completeMesh().time().timeName(), + meshes.completeMesh(), IOobject::NO_READ, IOobject::AUTO_WRITE ), - decomposition.mesh(), + meshes.completeMesh(), dimless, scalarField(scalarList(procIds)) ); @@ -309,18 +308,20 @@ int main(int argc, char *argv[]) } // Set time from database - #include "createTime.H" + Info<< "Create time\n" << endl; + processorRunTimes runTimes(Foam::Time::controlDictName, args); // Allow override of time - instantList times = timeSelector::selectIfPresent(runTime, args); + const instantList times = runTimes.selectComplete(args); // Get region names - const wordList regionNames(selectRegionNames(args, runTime)); + const wordList regionNames = + selectRegionNames(args, runTimes.completeTime()); // Handle existing decomposition directories { // Determine the processor count from the directories - label nProcs = fileHandler().nProcs(runTime.path()); + label nProcs = fileHandler().nProcs(runTimes.completeTime().path()); if (forceOverwrite) { @@ -339,7 +340,7 @@ int main(int argc, char *argv[]) ( fileHandler().readDir ( - runTime.path(), + runTimes.completeTime().path(), fileType::directory ) ); @@ -379,12 +380,17 @@ int main(int argc, char *argv[]) << " domains, use the -force option or manually" << nl << "remove processor directories before decomposing. e.g.," << nl - << " rm -rf " << runTime.path().c_str() << "/processor*" + << " rm -rf " << runTimes.completeTime().path().c_str() + << "/processor*" << nl << exit(FatalError); } } + // Get the decomposition dictionary + const dictionary decomposeParDict = + decompositionMethod::decomposeParDict(runTimes.completeTime()); + // Decompose all regions forAll(regionNames, regioni) { @@ -394,12 +400,12 @@ int main(int argc, char *argv[]) Info<< "\n\nDecomposing mesh " << regionName << nl << endl; // Determine the existing processor count directly - label nProcs = fileHandler().nProcs(runTime.path(), regionDir); + const label nProcs = + fileHandler().nProcs(runTimes.completeTime().path(), regionDir); // Get requested numberOfSubdomains const label nDomains = - decompositionMethod::decomposeParDict(runTime) - .lookup