View Issue Details

IDProjectCategoryView StatusLast Update
0002278OpenFOAMPatchpublic2016-09-30 16:26
ReporterMattijsJ Assigned Tohenry  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformGNU/LinuxOSOpenSuSEOS Version13.2
Product Versiondev 
Fixed in Versiondev 
Summary0002278: triangle storage optimisation
DescriptionReturn barycentric coordinates as FixedList instead of List
TagsNo tags attached.

Activities

MattijsJ

2016-09-30 12:22

reporter  

barycentric.patch (16,828 bytes)   
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 4283fb7..343ba46 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<scalar, 4> 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<scalar, 4> bary;
     cellShapeControlMesh::Cell_handle ch;
 
     shapeControlMesh_.barycentricCoords(pt, bary, ch);
@@ -244,7 +244,7 @@ void Foam::cellShapeControl::cellSizeAndAlignment
     tensor& alignment
 ) const
 {
-    scalarList bary;
+    FixedList<scalar, 4> 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 8c1da2a..2c1c369 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<scalar, 4>& 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 3546c03..7e4bc90 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<scalar, 4>& 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 b2ed901..a644134 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<scalar, 4> 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<scalar, 4> bary;
 //    Cell_handle ch;
 //
 //    triangulatedMesh_.barycentricCoords(pt, bary, ch);
@@ -144,7 +144,7 @@ Foam::fileControl::~fileControl()
 //    tensor& alignment
 //) const
 //{
-//    scalarList bary;
+//    FixedList<scalar, 4> 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 5288541..a478f9e 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<scalar, 3> 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 201f148..badea19 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<scalar>& bary
+                FixedList<scalar, 4>& 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 8406efa..2c14d16 100644
--- a/src/OpenFOAM/meshes/primitiveShapes/tetrahedron/tetrahedronI.H
+++ b/src/OpenFOAM/meshes/primitiveShapes/tetrahedron/tetrahedronI.H
@@ -316,7 +316,7 @@ template<class Point, class PointRef>
 Foam::scalar Foam::tetrahedron<Point, PointRef>::barycentric
 (
     const point& pt,
-    List<scalar>& bary
+    FixedList<scalar, 4>& bary
 ) const
 {
     // Reference:
@@ -346,8 +346,6 @@ Foam::scalar Foam::tetrahedron<Point, PointRef>::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 6e8030c..d383816 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<scalar>& bary
+                FixedList<scalar, 3>& 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 f4eeb23..9b9ec18 100644
--- a/src/OpenFOAM/meshes/primitiveShapes/triangle/triangleI.H
+++ b/src/OpenFOAM/meshes/primitiveShapes/triangle/triangleI.H
@@ -267,7 +267,7 @@ template<class Point, class PointRef>
 Foam::scalar Foam::triangle<Point, PointRef>::barycentric
 (
     const point& pt,
-    List<scalar>& bary
+    FixedList<scalar, 3>& bary
 ) const
 {
     // Reference:
@@ -289,13 +289,11 @@ Foam::scalar Foam::triangle<Point, PointRef>::barycentric
     {
         // Degenerate triangle, returning 1/3 barycentric coordinates.
 
-        bary = List<scalar>(3, 1.0/3.0);
+        bary = FixedList<scalar, 3>(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 e24093d..58c3662 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<scalar> triWeights(3);
+        FixedList<scalar, 3> 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<scalar> triWeights(3);
+    FixedList<scalar, 3> 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 8bd162c..6d1b149 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<scalar> weights_;
+       FixedList<scalar, 4> weights_;
 
        //- Face vertex indices
-       List<label> faceVertices_;
+       FixedList<label, 3> faceVertices_;
 
 
     // Protected Member Functions
@@ -112,13 +112,13 @@ public:
         }
 
         //- Interpolation weights
-        inline const List<scalar>& weights() const
+        inline const FixedList<scalar, 4>& weights() const
         {
             return weights_;
         }
 
         //- Interpolation addressing for points on face
-        inline const List<label>& faceVertices() const
+        inline const FixedList<label, 3>& faceVertices() const
         {
             return faceVertices_;
         }
diff --git a/src/finiteVolume/interpolation/interpolation/interpolationCellPoint/interpolationCellPointI.H b/src/finiteVolume/interpolation/interpolation/interpolationCellPoint/interpolationCellPointI.H
index dfd3a3b..8cfa394 100644
--- a/src/finiteVolume/interpolation/interpolation/interpolationCellPoint/interpolationCellPointI.H
+++ b/src/finiteVolume/interpolation/interpolation/interpolationCellPoint/interpolationCellPointI.H
@@ -31,8 +31,8 @@ inline Type Foam::interpolationCellPoint<Type>::interpolate
     const cellPointWeight& cpw
 ) const
 {
-    const List<scalar>& weights = cpw.weights();
-    const List<label>& faceVertices = cpw.faceVertices();
+    const FixedList<scalar, 4>& weights = cpw.weights();
+    const FixedList<label, 3>& faceVertices = cpw.faceVertices();
 
     Type t = this->psi_[cpw.cell()]*weights[0];
     t += psip_[faceVertices[0]]*weights[1];
@@ -79,7 +79,7 @@ inline Type Foam::interpolationCellPoint<Type>::interpolate
         }
     }
 
-    List<scalar> weights;
+    FixedList<scalar, 4> weights;
 
     tetIs.tet(this->pMesh_).barycentric(position, weights);
 
diff --git a/src/finiteVolume/interpolation/interpolation/interpolationCellPointWallModified/interpolationCellPointWallModifiedI.H b/src/finiteVolume/interpolation/interpolation/interpolationCellPointWallModified/interpolationCellPointWallModifiedI.H
index d186113..803c7a4 100644
--- a/src/finiteVolume/interpolation/interpolation/interpolationCellPointWallModified/interpolationCellPointWallModifiedI.H
+++ b/src/finiteVolume/interpolation/interpolation/interpolationCellPointWallModified/interpolationCellPointWallModifiedI.H
@@ -31,8 +31,8 @@ inline Type Foam::interpolationCellPointWallModified<Type>::interpolate
     const cellPointWeightWallModified& cpw
 ) const
 {
-    const List<scalar>& weights = cpw.weights();
-    const List<label>& faceVertices = cpw.faceVertices();
+    const FixedList<scalar, 4>& weights = cpw.weights();
+    const FixedList<label, 3>& faceVertices = cpw.faceVertices();
 
     Type t = this->psi_[cpw.cell()]*weights[0];
     t += this->psip_[faceVertices[0]]*weights[1];
diff --git a/src/lagrangian/intermediate/submodels/MPPIC/AveragingMethods/Dual/Dual.C b/src/lagrangian/intermediate/submodels/MPPIC/AveragingMethods/Dual/Dual.C
index 6fefd04..c0974c6 100644
--- a/src/lagrangian/intermediate/submodels/MPPIC/AveragingMethods/Dual/Dual.C
+++ b/src/lagrangian/intermediate/submodels/MPPIC/AveragingMethods/Dual/Dual.C
@@ -55,9 +55,7 @@ Foam::AveragingMethods::Dual<Type>::Dual
     volumeCell_(mesh.V()),
     volumeDual_(mesh.nPoints(), 0.0),
     dataCell_(FieldField<Field, Type>::operator[](0)),
-    dataDual_(FieldField<Field, Type>::operator[](1)),
-    tetVertices_(3),
-    tetCoordinates_(4)
+    dataDual_(FieldField<Field, Type>::operator[](1))
 {
     forAll(this->mesh_.C(), celli)
     {
@@ -123,7 +121,10 @@ void Foam::AveragingMethods::Dual<Type>::tetGeometry
 
     tetIs.tet(this->mesh_).barycentric(position, tetCoordinates_);
 
-    tetCoordinates_ = max(tetCoordinates_, scalar(0));
+    forAll(tetCoordinates_, i)
+    {
+        tetCoordinates_[i] = max(tetCoordinates_[i], scalar(0));
+    }
 }
 
 
diff --git a/src/lagrangian/intermediate/submodels/MPPIC/AveragingMethods/Dual/Dual.H b/src/lagrangian/intermediate/submodels/MPPIC/AveragingMethods/Dual/Dual.H
index c9cc862..94c2a33 100644
--- a/src/lagrangian/intermediate/submodels/MPPIC/AveragingMethods/Dual/Dual.H
+++ b/src/lagrangian/intermediate/submodels/MPPIC/AveragingMethods/Dual/Dual.H
@@ -91,10 +91,10 @@ private:
         Field<Type>& dataDual_;
 
         //- Tet vertex labels
-        mutable List<label> tetVertices_;
+        mutable FixedList<label, 3> tetVertices_;
 
         //- Tet barycentric coordinates
-        mutable List<scalar> tetCoordinates_;
+        mutable FixedList<scalar, 4> tetCoordinates_;
 
 
     //- Private static member functions
diff --git a/src/lagrangian/intermediate/submodels/MPPIC/PackingModels/Implicit/Implicit.C b/src/lagrangian/intermediate/submodels/MPPIC/PackingModels/Implicit/Implicit.C
index 9f8cb4e..3393740 100644
--- a/src/lagrangian/intermediate/submodels/MPPIC/PackingModels/Implicit/Implicit.C
+++ b/src/lagrangian/intermediate/submodels/MPPIC/PackingModels/Implicit/Implicit.C
@@ -340,7 +340,7 @@ Foam::vector Foam::PackingModels::Implicit<CloudType>::velocityCorrection
     const label celli = p.cell();
     const label facei = p.tetFace();
     const tetIndices tetIs(celli, facei, p.tetPt(), mesh);
-    List<scalar> tetCoordinates(4);
+    FixedList<scalar, 4> tetCoordinates;
     tetIs.tet(mesh).barycentric(p.position(), tetCoordinates);
 
     // cell velocity
barycentric.patch (16,828 bytes)   

henry

2016-09-30 16:26

manager   ~0006947

Resolved by commit ff28c484770b5f98a0d35f7d480f08e0368e7ed0

Issue History

Date Modified Username Field Change
2016-09-30 12:22 MattijsJ New Issue
2016-09-30 12:22 MattijsJ File Added: barycentric.patch
2016-09-30 16:26 henry Assigned To => henry
2016-09-30 16:26 henry Status new => resolved
2016-09-30 16:26 henry Resolution open => fixed
2016-09-30 16:26 henry Fixed in Version => dev
2016-09-30 16:26 henry Note Added: 0006947