From 61aaacd088fc9fcf3afb40526f1c943580fdcbf7 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 4 Mar 2024 16:48:59 +0100 Subject: [PATCH] ENH: adjust renumbering methods, extend renumberMesh options - renumberMesh now has -dry-run, -write-maps, -no-fields, -renumber-method, -renumber-coeffs options. * Use -dry-run with -write-maps to visualize the before/after effects of renumbering (creates a VTK file). * -no-fields to renumber the mesh only. This is useful and faster when the input fields are uniform and the -overwrite option is specified. * -renumber-method allows a quick means of specifying a different default renumber method (instead of Cuthill-McKee). The -renumber-coeffs option allows passing of dictionary content for the method. Examples, // Different ways to specify reverse Cuthill-McKee * -renumber-method RCM * -renumber-coeffs 'reverse true;' * -renumber-method CuthillMcKee * -renumber-coeffs 'reverse true;' * -renumber-coeffs 'method CuthillMcKee; reverse true;' // Other (without dictionary coefficients) * renumberMesh -renumber-method random // Other (with dictionary coefficients) renumberMesh \ -renumber-method spring \ -renumber-coeffs 'maxCo 0.1; maxIter 1000; freezeFraction 0.99;' // Other (with additional libraries) renumberMesh -renumber-method zoltan -lib zoltanRenumber COMP: build zoltan renumbering to MPI-specific location - zoltan and Sloan renumbering are now longer automatically linked to the renumberMesh utility but must be separately loaded by a command-line option or through a dictionary "libs" entry. ENH: add output cellID for decomposePar -dry-run -cellDist --- .../cavity/system/renumberMeshDict-random | 112 -- .../mesh/manipulation/renumberMesh/Allwmake | 26 - .../manipulation/renumberMesh/Make/options | 11 +- .../manipulation/renumberMesh/renumberMesh.C | 1078 +++++++++++------ .../domainDecompositionDryRunWrite.C | 1 + bin/tools/CleanFunctions | 2 +- etc/caseDicts/annotated/renumberMeshDict | 45 +- etc/config.sh/zoltan | 34 + src/Allwmake | 2 +- src/renumber/Allwmake | 1 + src/renumber/SloanRenumber/SloanRenumber.C | 12 +- src/renumber/SloanRenumber/SloanRenumber.H | 22 +- .../CuthillMcKeeRenumber.C | 68 +- .../CuthillMcKeeRenumber.H | 72 +- src/renumber/renumberMethods/Make/files | 5 +- .../manualRenumber/manualRenumber.C | 16 +- .../manualRenumber/manualRenumber.H | 20 +- .../renumberMethods/noRenumber/noRenumber.C | 102 ++ .../renumberMethods/noRenumber/noRenumber.H | 124 ++ .../randomRenumber/randomRenumber.C | 65 +- .../randomRenumber/randomRenumber.H | 42 +- .../renumberMethod/renumberMethod.C | 27 +- .../renumberMethod/renumberMethod.H | 91 +- .../springRenumber/springRenumber.C | 48 +- .../springRenumber/springRenumber.H | 3 + .../structuredRenumber/structuredRenumber.C | 12 +- .../structuredRenumber/structuredRenumber.H | 15 +- src/renumber/zoltanRenumber/Make/files | 3 +- src/renumber/zoltanRenumber/Make/options | 6 +- src/renumber/zoltanRenumber/zoltanRenumber.C | 344 ++++-- src/renumber/zoltanRenumber/zoltanRenumber.H | 6 +- tutorials/mesh/parallel/cavity/Allrun | 3 +- .../cavity/system/renumberMeshDict-random | 109 -- .../geometric/Allclean | 1 - wmake/scripts/have_zoltan | 31 +- 35 files changed, 1626 insertions(+), 933 deletions(-) delete mode 100644 applications/test/mapDistributePolyMesh/cavity/system/renumberMeshDict-random delete mode 100755 applications/utilities/mesh/manipulation/renumberMesh/Allwmake create mode 100644 etc/config.sh/zoltan create mode 100644 src/renumber/renumberMethods/noRenumber/noRenumber.C create mode 100644 src/renumber/renumberMethods/noRenumber/noRenumber.H delete mode 100644 tutorials/mesh/parallel/cavity/system/renumberMeshDict-random diff --git a/applications/test/mapDistributePolyMesh/cavity/system/renumberMeshDict-random b/applications/test/mapDistributePolyMesh/cavity/system/renumberMeshDict-random deleted file mode 100644 index d3d55f4fd1..0000000000 --- a/applications/test/mapDistributePolyMesh/cavity/system/renumberMeshDict-random +++ /dev/null @@ -1,112 +0,0 @@ -/*--------------------------------*- C++ -*----------------------------------*\ -| ========= | | -| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: v2312 | -| \\ / A nd | Website: www.openfoam.com | -| \\/ M anipulation | | -\*---------------------------------------------------------------------------*/ -FoamFile -{ - version 2.0; - format ascii; - class dictionary; - note "mesh renumbering dictionary"; - object renumberMeshDict; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -// Write maps from renumbered back to original mesh -writeMaps true; - -// Optional entry: sort cells on coupled boundaries to last for use with -// e.g. nonBlockingGaussSeidel. -sortCoupledFaceCells false; - -// Optional entry: renumber on a block-by-block basis. It uses a -// blockCoeffs dictionary to construct a decompositionMethod to do -// a block subdivision) and then applies the renumberMethod to each -// block in turn. This can be used in large cases to keep the blocks -// fitting in cache with all the cache misses bunched at the end. -// This number is the approximate size of the blocks - this gets converted -// to a number of blocks that is the input to the decomposition method. -//blockSize 1000; - -// Optional entry: sort points into internal and boundary points -//orderPoints false; - -// Optional: suppress renumbering cellSets,faceSets,pointSets -//renumberSets false; - - -//method CuthillMcKee; -//method Sloan; -//method manual; -method random; -//method structured; -//method spring; -//method zoltan; // only if compiled with zoltan support - -//CuthillMcKeeCoeffs -//{ -// // Reverse CuthillMcKee (RCM) or plain -// reverse true; -//} - -manualCoeffs -{ - // In system directory: new-to-original (i.e. order) labelIOList - dataFile "cellMap"; -} - - -// For extruded (i.e. structured in one direction) meshes -structuredCoeffs -{ - // Patches that mesh was extruded from. These determine the starting - // layer of cells - patches (movingWall); - // Method to renumber the starting layer of cells - method random; - - // Renumber in columns (depthFirst) or in layers - depthFirst true; - - // Reverse ordering - reverse false; -} - - -springCoeffs -{ - // Maximum jump of cell indices. Is fraction of number of cells - maxCo 0.01; - - // Limit the amount of movement; the fraction maxCo gets decreased - // with every iteration - freezeFraction 0.999; - - // Maximum number of iterations - maxIter 1000; -} - - -blockCoeffs -{ - method scotch; - //method hierarchical; - //hierarchicalCoeffs - //{ - // n (1 2 1); - // delta 0.001; - // order xyz; - //} -} - - -zoltanCoeffs -{ - ORDER_METHOD LOCAL_HSFC; -} - - -// ************************************************************************* // diff --git a/applications/utilities/mesh/manipulation/renumberMesh/Allwmake b/applications/utilities/mesh/manipulation/renumberMesh/Allwmake deleted file mode 100755 index 0f0d32738e..0000000000 --- a/applications/utilities/mesh/manipulation/renumberMesh/Allwmake +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh -cd "${0%/*}" || exit # Run from this directory -. ${WM_PROJECT_DIR:?}/wmake/scripts/AllwmakeParseArguments # (error catching) -. ${WM_PROJECT_DIR:?}/wmake/scripts/sysFunctions # General system functions -. ${WM_PROJECT_DIR:?}/wmake/scripts/have_zoltan - -#------------------------------------------------------------------------------ - -unset COMP_FLAGS LINK_FLAGS - -if findLibrary "$FOAM_LIBBIN/libSloanRenumber" > /dev/null -then - echo " found libSloanRenumber -- enabling sloan renumbering support." - export LINK_FLAGS="$LINK_FLAGS -lSloanRenumber" -fi - -if findLibrary "$FOAM_LIBBIN/libzoltanRenumber" > /dev/null && have_zoltan -then - echo " found libzoltanRenumber -- enabling zoltan renumbering support." - export COMP_FLAGS="$COMP_FLAGS -DHAVE_ZOLTAN" - export LINK_FLAGS="$LINK_FLAGS -lzoltanRenumber -L$ZOLTAN_LIB_DIR -lzoltan" -fi - -wmake $targetType - -#------------------------------------------------------------------------------ diff --git a/applications/utilities/mesh/manipulation/renumberMesh/Make/options b/applications/utilities/mesh/manipulation/renumberMesh/Make/options index 004f82049f..8aca81f2dc 100644 --- a/applications/utilities/mesh/manipulation/renumberMesh/Make/options +++ b/applications/utilities/mesh/manipulation/renumberMesh/Make/options @@ -1,21 +1,22 @@ EXE_INC = \ - $(COMP_FLAGS) \ - -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/fileFormats/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/dynamicMesh/lnInclude \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/renumber/renumberMethods/lnInclude \ - -I$(LIB_SRC)/renumber/zoltanRenumber/lnInclude \ + -I$(LIB_SRC)/parallel/decompose/decompose/lnInclude \ -I$(LIB_SRC)/parallel/decompose/decompositionMethods/lnInclude \ -I$(LIB_SRC)/parallel/reconstruct/reconstruct/lnInclude EXE_LIBS = \ - -lfiniteVolume \ + -lfileFormats \ -lmeshTools \ -ldynamicMesh \ + -lfiniteVolume \ -lgenericPatchFields \ -lrenumberMethods \ + -ldecompose \ -lreconstruct \ - $(LINK_FLAGS) \ -ldecompositionMethods \ -L$(FOAM_LIBBIN)/dummy \ -lkahipDecomp -lmetisDecomp -lscotchDecomp diff --git a/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C b/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C index b35202a4ad..7c08c679a5 100644 --- a/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C +++ b/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2016-2022 OpenCFD Ltd. + Copyright (C) 2016-2024 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -34,12 +34,96 @@ Description Renumbers the cell list in order to reduce the bandwidth, reading and renumbering all fields from all the time directories. - By default uses bandCompression (CuthillMcKee) but will - read system/renumberMeshDict if -dict option is present + By default uses bandCompression (Cuthill-McKee) or the method + specified by the -renumber-method option, but will read + system/renumberMeshDict if -dict option is present + +Usage + \b renumberMesh [OPTIONS] + + Options: + - \par -allRegions + Use all regions in regionProperties + + - \par -case \ + Specify case directory to use (instead of the cwd). + + - \par -constant + Include the 'constant/' dir in the times list. + + - \par -decompose + Aggregate initially with a decomposition method (serial only) + + - \par -decomposeParDict \ + Use specified file for decomposePar dictionary. + + - \par -dict \ + Use specified file for renumberMeshDict dictionary. + + - \par -dry-run + Test only + + - \par -frontWidth + Calculate the rms of the front-width + + - \par -latestTime + Select the latest time. + + - \par -lib \ + Additional library or library list to load (can be used multiple times). + + - \par -no-fields + Suppress renumber of fields + + - \par -noZero + Exclude the \a 0 dir from the times list. + + - \par -overwrite + Overwrite existing mesh/results files + + - \par -parallel + Run in parallel + + - \par -region \ + Renumber named region. + + - \par -regions \ + Renumber named regions. + + - \par -renumber-coeffs \ + String to create renumber dictionary contents. + + - \par -renumber-method \ + Specify renumber method (default: CuthillMcKee) without dictionary + + - \par -time \ + Specify time to select + + - \par -verbose + Additional verbosity. + + - \par -doc + Display documentation in browser. + + - \par -doc-source + Display source code in browser. + + - \par -help + Display short help and exit. + + - \par -help-man + Display full help (manpage format) and exit. + + - \par -help-notes + Display help notes (description) and exit. + + - \par -help-full + Display full help and exit. \*---------------------------------------------------------------------------*/ #include "argList.H" +#include "timeSelector.H" #include "IOobjectList.H" #include "fvMesh.H" #include "polyTopoChange.H" @@ -48,8 +132,9 @@ Description #include "surfaceFields.H" #include "SortableList.H" #include "decompositionMethod.H" +#include "decompositionModel.H" #include "renumberMethod.H" -#include "zeroGradientFvPatchFields.H" +#include "foamVtkInternalMeshWriter.H" #include "CuthillMcKeeRenumber.H" #include "fvMeshSubset.H" #include "cellSet.H" @@ -60,11 +145,6 @@ Description #include "regionProperties.H" #include "polyMeshTools.H" -#ifdef HAVE_ZOLTAN - #include "zoltanRenumber.H" -#endif - - using namespace Foam; @@ -80,16 +160,17 @@ tmp createScalarField ( name, mesh, - dimensionedScalar(dimless, Zero), + dimensionedScalar(word::null, dimless, -1), fvPatchFieldBase::zeroGradientType() ); auto& fld = tfld.ref(); - forAll(fld, celli) + forAll(elems, celli) { fld[celli] = elems[celli]; } + fld.correctBoundaryConditions(); return tfld; } @@ -140,10 +221,10 @@ void getBand bandwidth = max(cellBandwidth); // Do not use field algebra because of conversion label to scalar - profile = 0.0; - forAll(cellBandwidth, celli) + profile = 0; + for (const label width : cellBandwidth) { - profile += 1.0*cellBandwidth[celli]; + profile += scalar(width); } sumSqrIntersect = 0.0; @@ -175,54 +256,46 @@ labelList getFaceOrder label newFacei = 0; - labelList nbr; - labelList order; + DynamicList