diff --git a/src/OpenFOAM/containers/Lists/ListOps/ListOps.H b/src/OpenFOAM/containers/Lists/ListOps/ListOps.H index a0422e31e9..f1fadd14b5 100644 --- a/src/OpenFOAM/containers/Lists/ListOps/ListOps.H +++ b/src/OpenFOAM/containers/Lists/ListOps/ListOps.H @@ -183,6 +183,12 @@ label findLower ); +//- To construct a List from a C array. Has extra Container type +// to initialise e.g. wordList from arrays of char*. +template +List initList(const T[nRows]); + + //- To construct a (square) ListList from a C array. Has extra Container type // to initialise e.g. faceList from arrays of labels. template diff --git a/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C b/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C index 2a2792af53..53866772aa 100644 --- a/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C +++ b/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C @@ -486,6 +486,19 @@ Foam::label Foam::findLower } +template +Foam::List Foam::initList(const T elems[nRows]) +{ + List faces(nRows); + + forAll(faces, faceI) + { + faces[faceI] = Container(elems[faceI]); + } + return faces; +} + + template Foam::List Foam::initListList(const T elems[nRows][nColumns]) {