diff --git a/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduAddressing.C b/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduAddressing.C index db596157c8..282377f4f3 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduAddressing.C +++ b/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduAddressing.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -25,6 +25,7 @@ License #include "lduAddressing.H" #include "demandDrivenData.H" +#include "scalarField.H" // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -248,4 +249,28 @@ Foam::label Foam::lduAddressing::triIndex(const label a, const label b) const } +Foam::Tuple2 Foam::lduAddressing::band() const +{ + const labelUList& owner = lowerAddr(); + const labelUList& neighbour = upperAddr(); + + labelList cellBandwidth(size(), 0); + + forAll(neighbour, faceI) + { + label own = owner[faceI]; + label nei = neighbour[faceI]; + + // Note: mag not necessary for correct (upper-triangular) ordering. + label diff = nei-own; + cellBandwidth[nei] = max(cellBandwidth[nei], diff); + } + + label bandwidth = max(cellBandwidth); + scalar profile = sum(1.0*cellBandwidth); + + return Tuple2(bandwidth, profile); +} + + // ************************************************************************* // diff --git a/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduAddressing.H b/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduAddressing.H index 6266737285..3c9d1b2fcb 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduAddressing.H +++ b/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduAddressing.H @@ -98,6 +98,7 @@ SourceFiles #include "labelList.H" #include "lduSchedule.H" +#include "Tuple2.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -196,6 +197,9 @@ public: //- Return off-diagonal index given owner and neighbour label label triIndex(const label a, const label b) const; + + //- Calculate bandwidth and profile of addressing + Tuple2 band() const; };