From 4bdf712b35b8d0592cc4ed6038460a1309d7d394 Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Fri, 30 Sep 2016 16:22:55 +0100 Subject: [PATCH 1/3] triangle storage: Return barycentric coordinates as FixedList instead of List Patch contributed by Mattijs Janssens Resolves bug-report http://bugs.openfoam.org/view.php?id=2278 --- .../cellShapeControl/cellShapeControl/cellShapeControl.C | 6 +++--- .../cellShapeControlMesh/cellShapeControlMesh.C | 2 +- .../cellShapeControlMesh/cellShapeControlMesh.H | 4 ++-- .../fileControl/fileControl.C | 6 +++--- .../nonUniformField/nonUniformField.C | 5 ++--- .../meshes/primitiveShapes/tetrahedron/tetrahedron.H | 2 +- .../meshes/primitiveShapes/tetrahedron/tetrahedronI.H | 4 +--- src/OpenFOAM/meshes/primitiveShapes/triangle/triangle.H | 4 ++-- src/OpenFOAM/meshes/primitiveShapes/triangle/triangleI.H | 6 ++---- .../cellPointWeight/cellPointWeight.C | 8 +++----- .../cellPointWeight/cellPointWeight.H | 8 ++++---- .../interpolationCellPoint/interpolationCellPointI.H | 6 +++--- .../interpolationCellPointWallModifiedI.H | 4 ++-- .../submodels/MPPIC/AveragingMethods/Dual/Dual.C | 9 +++++---- .../submodels/MPPIC/AveragingMethods/Dual/Dual.H | 4 ++-- .../submodels/MPPIC/PackingModels/Implicit/Implicit.C | 2 +- 16 files changed, 37 insertions(+), 43 deletions(-) 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 8c1da2afc5..2c1c3695ad 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/cellShapeControlMesh/cellShapeControlMesh.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/cellShapeControl/cellShapeControlMesh/cellShapeControlMesh.C @@ -452,7 +452,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/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 6e8030c797..d3838166d9 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-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -173,7 +173,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 f4eeb23898..9b9ec18b15 100644 --- a/src/OpenFOAM/meshes/primitiveShapes/triangle/triangleI.H +++ b/src/OpenFOAM/meshes/primitiveShapes/triangle/triangleI.H @@ -267,7 +267,7 @@ template Foam::scalar Foam::triangle::barycentric ( const point& pt, - List& bary + FixedList& bary ) const { // Reference: @@ -289,13 +289,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