diff --git a/src/parallel/decompose/kahipDecomp/kahipDecomp.C b/src/parallel/decompose/kahipDecomp/kahipDecomp.C index 9ad2b58eef..8cdc367fb8 100644 --- a/src/parallel/decompose/kahipDecomp/kahipDecomp.C +++ b/src/parallel/decompose/kahipDecomp/kahipDecomp.C @@ -26,6 +26,7 @@ License #include "kahipDecomp.H" #include "addToRunTimeSelectionTable.H" #include "Time.H" +#include "PrecisionAdaptor.H" #include "kaHIP_interface.h" @@ -33,6 +34,9 @@ License #include #include +// Provide a clear error message if we have a severe size mismatch +// Allow widening, but not narrowing + // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam @@ -217,59 +221,30 @@ Foam::label Foam::kahipDecomp::decomposeSerial // Output: number of cut edges int edgeCut = 0; - #if WM_LABEL_SIZE == 32 - - // Input: - int* xadjPtr = const_cast(xadj.begin()); - int* adjncyPtr = const_cast(adjncy.begin()); + // Addressing + ConstPrecisionAdaptor xadj_param(xadj); + ConstPrecisionAdaptor adjncy_param(adjncy); // Output: cell -> processor addressing - decomp.setSize(numCells); - int* decompPtr = decomp.begin(); + decomp.resize(numCells); + PrecisionAdaptor decomp_param(decomp); - #elif WM_LABEL_SIZE == 64 - - // input (copy) - List xadjCopy(xadj.size()); - List adjncyCopy(adjncy.size()); - - forAll(xadj,i) - { - xadjCopy[i] = xadj[i]; - } - forAll(adjncy,i) - { - adjncyCopy[i] = adjncy[i]; - } - - int* xadjPtr = xadjCopy.begin(); - int* adjncyPtr = adjncyCopy.begin(); - - if (decomp.size() != numCells) - { - decomp.clear(); - } - - // Output: cell -> processor addressing - List decompCopy(numCells); - int* decompPtr = decompCopy.begin(); - #endif #if 0 // WIP: #ifdef KAFFPA_CPP_INTERFACE kaffpa_cpp ( &numCells, // num vertices in graph (cellWeights.size() ? cellWeights.begin() : nullptr), // vertex wts - xadjPtr, // indexing into adjncy + xadj_param.constCast().data(), // indexing into adjncy nullptr, // edge wts - adjncyPtr, // neighbour info + adjncy_param.constCast().data(), // neighbour info &nParts, // nparts &imbalance, // amount of imbalance allowed !verbose, // suppress output seed, // for random int(kahipConfig), - &edgeCut, // [output] - decompPtr, // [output] + &edgeCut, // [output] + decomp_param.ref().data(), // [output] sizingParams ); #else @@ -277,35 +252,19 @@ Foam::label Foam::kahipDecomp::decomposeSerial ( &numCells, // num vertices in graph (cellWeights.size() ? cellWeights.begin() : nullptr), // vertex wts - xadjPtr, // indexing into adjncy + xadj_param.constCast().data(), // indexing into adjncy nullptr, // edge wts - adjncyPtr, // neighbour info + adjncy_param.constCast().data(), // neighbour info &nParts, // nparts &imbalance, // amount of imbalance allowed !verbose, // suppress output seed, // for random int(kahipConfig), - &edgeCut, // [output] - decompPtr // [output] + &edgeCut, // [output] + decomp_param.ref().data() // [output] ); #endif - #if WM_LABEL_SIZE == 64 - - // Drop input copy - xadjCopy.clear(); - adjncyCopy.clear(); - - // Copy back to List