diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/cellShapeControl/cellShapeControl.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/cellShapeControl/cellShapeControl.C index 4283fb7c35..343ba46a6e 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/cellShapeControl/cellShapeControl.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/cellShapeControl/cellShapeControl.C @@ -97,7 +97,7 @@ Foam::scalarField Foam::cellShapeControl::cellSize Foam::scalar Foam::cellShapeControl::cellSize(const point& pt) const { - scalarList bary; + FixedList bary; cellShapeControlMesh::Cell_handle ch; shapeControlMesh_.barycentricCoords(pt, bary, ch); @@ -172,7 +172,7 @@ Foam::scalar Foam::cellShapeControl::cellSize(const point& pt) const Foam::tensor Foam::cellShapeControl::cellAlignment(const point& pt) const { - scalarList bary; + FixedList bary; cellShapeControlMesh::Cell_handle ch; shapeControlMesh_.barycentricCoords(pt, bary, ch); @@ -244,7 +244,7 @@ void Foam::cellShapeControl::cellSizeAndAlignment tensor& alignment ) const { - scalarList bary; + FixedList bary; cellShapeControlMesh::Cell_handle ch; shapeControlMesh_.barycentricCoords(pt, bary, ch); diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/cellShapeControlMesh/cellShapeControlMesh.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/cellShapeControlMesh/cellShapeControlMesh.C index 32afeaa491..965a89996e 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/cellShapeControlMesh/cellShapeControlMesh.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/cellShapeControlMesh/cellShapeControlMesh.C @@ -450,7 +450,7 @@ Foam::cellShapeControlMesh::~cellShapeControlMesh() void Foam::cellShapeControlMesh::barycentricCoords ( const Foam::point& pt, - scalarList& bary, + FixedList& bary, Cell_handle& ch ) const { diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/cellShapeControlMesh/cellShapeControlMesh.H b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/cellShapeControlMesh/cellShapeControlMesh.H index 3546c03d9e..7e4bc9041c 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/cellShapeControlMesh/cellShapeControlMesh.H +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/cellShapeControlMesh/cellShapeControlMesh.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -122,7 +122,7 @@ public: void barycentricCoords ( const Foam::point& pt, - scalarList& bary, + FixedList& bary, Cell_handle& ch ) const; diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/cellSizeAndAlignmentControl/fileControl/fileControl.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/cellSizeAndAlignmentControl/fileControl/fileControl.C index b2ed90169f..a644134066 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/cellSizeAndAlignmentControl/fileControl/fileControl.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/cellSizeAndAlignmentControl/fileControl/fileControl.C @@ -94,7 +94,7 @@ Foam::fileControl::~fileControl() // //Foam::scalar Foam::fileControl::cellSize(const point& pt) const //{ -// scalarList bary; +// FixedList bary; // Cell_handle ch; // // triangulatedMesh_.barycentricCoords(pt, bary, ch); @@ -112,7 +112,7 @@ Foam::fileControl::~fileControl() ////- Return the cell alignment at the given location //Foam::tensor Foam::fileControl::cellAlignment(const point& pt) const //{ -// scalarList bary; +// FixedList bary; // Cell_handle ch; // // triangulatedMesh_.barycentricCoords(pt, bary, ch); @@ -144,7 +144,7 @@ Foam::fileControl::~fileControl() // tensor& alignment //) const //{ -// scalarList bary; +// FixedList bary; // Cell_handle ch; // // triangulatedMesh_.barycentricCoords(pt, bary, ch); diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/surfaceCellSizeFunction/nonUniformField/nonUniformField.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/surfaceCellSizeFunction/nonUniformField/nonUniformField.C index 5288541538..a478f9e513 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/surfaceCellSizeFunction/nonUniformField/nonUniformField.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellSizeControlSurfaces/surfaceCellSizeFunction/nonUniformField/nonUniformField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -118,8 +118,7 @@ Foam::scalar Foam::nonUniformField::interpolate pts[faceHitByPt[2]] ); - scalarList bary(3, 0.0); - + FixedList bary; tri.barycentric(pt, bary); // return pointCellSize_[pMap[faceHitByPt[0]]]*bary[0] diff --git a/src/OpenFOAM/containers/HashTables/Map/Map.H b/src/OpenFOAM/containers/HashTables/Map/Map.H index 46de9dbedb..8ef2f560bc 100644 --- a/src/OpenFOAM/containers/HashTables/Map/Map.H +++ b/src/OpenFOAM/containers/HashTables/Map/Map.H @@ -91,6 +91,11 @@ public: HashTable>(map) {} + //- Construct from an initializer list + Map(std::initializer_list> map) + : + HashTable>(map) + {} }; diff --git a/src/OpenFOAM/containers/Lists/SortableList/SortableList.C b/src/OpenFOAM/containers/Lists/SortableList/SortableList.C index 784b1f9e1d..fbafc9cf0f 100644 --- a/src/OpenFOAM/containers/Lists/SortableList/SortableList.C +++ b/src/OpenFOAM/containers/Lists/SortableList/SortableList.C @@ -72,6 +72,15 @@ Foam::SortableList::SortableList(const SortableList& lst) {} +template +Foam::SortableList::SortableList(std::initializer_list values) +: + List(values) +{ + sort(); +} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // @@ -138,20 +147,27 @@ inline void Foam::SortableList::operator=(const T& t) template -inline void Foam::SortableList::operator=(const UList& rhs) +inline void Foam::SortableList::operator=(const UList& lst) { - List::operator=(rhs); + List::operator=(lst); indices_.clear(); } template -inline void Foam::SortableList::operator=(const SortableList& rhs) +inline void Foam::SortableList::operator=(const SortableList& lst) { - List::operator=(rhs); - indices_ = rhs.indices(); + List::operator=(lst); + indices_ = lst.indices(); +} + + +template +inline void Foam::SortableList::operator=(std::initializer_list lst) +{ + List::operator=(lst); + sort(); } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // ************************************************************************* // diff --git a/src/OpenFOAM/containers/Lists/SortableList/SortableList.H b/src/OpenFOAM/containers/Lists/SortableList/SortableList.H index a6f4b4586c..65fb6dc7f4 100644 --- a/src/OpenFOAM/containers/Lists/SortableList/SortableList.H +++ b/src/OpenFOAM/containers/Lists/SortableList/SortableList.H @@ -67,33 +67,36 @@ public: //- Null constructor, sort later (eg, after assignment or transfer) SortableList(); - //- Construct from UList, sorting immediately. + //- Construct from UList, sorting immediately explicit SortableList(const UList&); - //- Construct from transferred List, sorting immediately. + //- Construct from transferred List, sorting immediately explicit SortableList(const Xfer>&); - //- Construct given size. Sort later on. + //- Construct given size. Sort later on // The indices remain empty until the list is sorted explicit SortableList(const label size); - //- Construct given size and initial value. Sort later on. + //- Construct given size and initial value. Sort later on // The indices remain empty until the list is sorted SortableList(const label size, const T&); - //- Construct as copy. + //- Construct as copy SortableList(const SortableList&); + //- Construct from an initializer list, sorting immediately + SortableList(std::initializer_list); + // Member Functions - //- Return the list of sorted indices. Updated every sort. + //- Return the list of sorted indices. Updated every sort const labelList& indices() const { return indices_; } - //- Return non-const access to the sorted indices. Updated every sort. + //- Return non-const access to the sorted indices. Updated every sort labelList& indices() { return indices_; @@ -121,12 +124,14 @@ public: //- Assignment of all entries to the given value inline void operator=(const T&); - //- Assignment to UList operator. Takes linear time. + //- Assignment to UList operator. Takes linear time inline void operator=(const UList&); - //- Assignment operator. Takes linear time. + //- Assignment operator. Takes linear time inline void operator=(const SortableList&); + //- Assignment to an initializer list + void operator=(std::initializer_list); }; diff --git a/src/OpenFOAM/fields/Fields/Field/Field.C b/src/OpenFOAM/fields/Fields/Field/Field.C index dfd8a413e3..1c021bcca2 100644 --- a/src/OpenFOAM/fields/Fields/Field/Field.C +++ b/src/OpenFOAM/fields/Fields/Field/Field.C @@ -244,6 +244,13 @@ Foam::Field::Field(const UList& list) {} +template +Foam::Field::Field(const UIndirectList& list) +: + List(list) +{} + + #ifndef NoConstructFromTmp template Foam::Field::Field(const tmp>& tf) diff --git a/src/OpenFOAM/fields/Fields/Field/Field.H b/src/OpenFOAM/fields/Fields/Field/Field.H index edb788a1b3..6fcab57ea0 100644 --- a/src/OpenFOAM/fields/Fields/Field/Field.H +++ b/src/OpenFOAM/fields/Fields/Field/Field.H @@ -123,6 +123,9 @@ public: //- Construct as copy of a UList\ explicit Field(const UList&); + //- Construct as copy of a UIndirectList\ + explicit Field(const UIndirectList&); + //- Construct by transferring the List contents explicit Field(const Xfer>&); diff --git a/src/OpenFOAM/meshes/primitiveShapes/tetrahedron/tetrahedron.H b/src/OpenFOAM/meshes/primitiveShapes/tetrahedron/tetrahedron.H index 201f14819f..badea19542 100644 --- a/src/OpenFOAM/meshes/primitiveShapes/tetrahedron/tetrahedron.H +++ b/src/OpenFOAM/meshes/primitiveShapes/tetrahedron/tetrahedron.H @@ -249,7 +249,7 @@ public: inline scalar barycentric ( const point& pt, - List& bary + FixedList& bary ) const; //- Return nearest point to p on tetrahedron. Is p itself diff --git a/src/OpenFOAM/meshes/primitiveShapes/tetrahedron/tetrahedronI.H b/src/OpenFOAM/meshes/primitiveShapes/tetrahedron/tetrahedronI.H index 8406efaa81..2c14d16121 100644 --- a/src/OpenFOAM/meshes/primitiveShapes/tetrahedron/tetrahedronI.H +++ b/src/OpenFOAM/meshes/primitiveShapes/tetrahedron/tetrahedronI.H @@ -316,7 +316,7 @@ template Foam::scalar Foam::tetrahedron::barycentric ( const point& pt, - List& bary + FixedList& bary ) const { // Reference: @@ -346,8 +346,6 @@ Foam::scalar Foam::tetrahedron::barycentric vector res = inv(t, detT) & (pt - d_); - bary.setSize(4); - bary[0] = res.x(); bary[1] = res.y(); bary[2] = res.z(); diff --git a/src/OpenFOAM/meshes/primitiveShapes/triangle/triangle.H b/src/OpenFOAM/meshes/primitiveShapes/triangle/triangle.H index 299ea32661..d689fa0b1e 100644 --- a/src/OpenFOAM/meshes/primitiveShapes/triangle/triangle.H +++ b/src/OpenFOAM/meshes/primitiveShapes/triangle/triangle.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -248,7 +248,7 @@ public: inline scalar barycentric ( const point& pt, - List& bary + FixedList& bary ) const; //- Return point intersection with a ray. diff --git a/src/OpenFOAM/meshes/primitiveShapes/triangle/triangleI.H b/src/OpenFOAM/meshes/primitiveShapes/triangle/triangleI.H index 6314bfc108..eee54fd92c 100644 --- a/src/OpenFOAM/meshes/primitiveShapes/triangle/triangleI.H +++ b/src/OpenFOAM/meshes/primitiveShapes/triangle/triangleI.H @@ -280,7 +280,7 @@ template Foam::scalar Foam::triangle::barycentric ( const point& pt, - List& bary + FixedList& bary ) const { // Reference: @@ -302,13 +302,11 @@ Foam::scalar Foam::triangle::barycentric { // Degenerate triangle, returning 1/3 barycentric coordinates. - bary = List(3, 1.0/3.0); + bary = FixedList(1.0/3.0); return denom; } - bary.setSize(3); - bary[1] = (d11*d20 - d01*d21)/denom; bary[2] = (d00*d21 - d01*d20)/denom; bary[0] = 1.0 - bary[1] - bary[2]; diff --git a/src/finiteVolume/interpolation/interpolation/interpolationCellPoint/cellPointWeight/cellPointWeight.C b/src/finiteVolume/interpolation/interpolation/interpolationCellPoint/cellPointWeight/cellPointWeight.C index e24093da41..58c3662301 100644 --- a/src/finiteVolume/interpolation/interpolation/interpolationCellPoint/cellPointWeight/cellPointWeight.C +++ b/src/finiteVolume/interpolation/interpolation/interpolationCellPoint/cellPointWeight/cellPointWeight.C @@ -166,7 +166,7 @@ void Foam::cellPointWeight::findTriangle { const tetIndices& tetIs = faceTets[tetI]; - List triWeights(3); + FixedList triWeights; // Barycentric coordinates of the position scalar det = tetIs.faceTri(mesh).barycentric(position, triWeights); @@ -234,7 +234,7 @@ void Foam::cellPointWeight::findTriangle // determinant is suitable. If not, the return from barycentric // to triWeights is safe. - List triWeights(3); + FixedList triWeights; tetIs.faceTri(mesh).barycentric(position, triWeights); @@ -260,9 +260,7 @@ Foam::cellPointWeight::cellPointWeight const label facei ) : - celli_(celli), - weights_(4), - faceVertices_(3) + celli_(celli) { if (facei < 0) { diff --git a/src/finiteVolume/interpolation/interpolation/interpolationCellPoint/cellPointWeight/cellPointWeight.H b/src/finiteVolume/interpolation/interpolation/interpolationCellPoint/cellPointWeight/cellPointWeight.H index 8bd162c1ce..6d1b14948b 100644 --- a/src/finiteVolume/interpolation/interpolation/interpolationCellPoint/cellPointWeight/cellPointWeight.H +++ b/src/finiteVolume/interpolation/interpolation/interpolationCellPoint/cellPointWeight/cellPointWeight.H @@ -58,10 +58,10 @@ protected: const label celli_; //- Weights applied to tet vertices - List weights_; + FixedList weights_; //- Face vertex indices - List