diff --git a/applications/test/globalIndex2/Test-globalIndex2.cxx b/applications/test/globalIndex2/Test-globalIndex2.cxx index a8bd73c394..a2df1c3882 100644 --- a/applications/test/globalIndex2/Test-globalIndex2.cxx +++ b/applications/test/globalIndex2/Test-globalIndex2.cxx @@ -42,6 +42,21 @@ Description using namespace Foam; +void printTest1 +( + const globalIndex& gi, + const label proci, + const label value +) +{ + // With range check + Info<< " value:" << value << " on:" << gi.findProc(proci, value) + << " below/above: (" + << gi.findProcBelow(proci, value) << ' ' + << gi.findProcAbove(proci, value) << ')' << nl; +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // Main program: @@ -87,6 +102,52 @@ int main(int argc, char *argv[]) << nl; } + { + // From some offsets + globalIndex gi; + + globalIndex gi0 + ( + labelList({ 0, 10, 20, 30, 40, 50, 60 }) + ); + + Info<< "offsets: " << gi0.offsets() << nl; + + // Alternative to copy assigment + gi.reset(gi0); + + Info<< "globalIndex :"; gi.offsets().writeList(Info) << nl; + + // Resizing is fine, but also check the binary search results! + gi.resize(10); + Info<< "globalIndex :"; gi.offsets().writeList(Info) << nl; + + // NB: these routines are mostly failsafe on bad addresses + // for (const label proci : { 4, 8, -1 }) + + for (const label proci : { 4 }) + { + Info<< "proc:" << proci + << " : [" << gi.localStart(proci) + << "," << gi.localEnd(proci) << ")" << nl; + + for (label i = 0; i < 25; ++i) + { + const label value = rnd.position