Commit 4bdf712b authored by Henry Weller's avatar Henry Weller
Browse files

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
parent 5c921caa
......@@ -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);
......
......@@ -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
{
......
......@@ -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;
......
......@@ -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);
......
......@@ -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]
......
......@@ -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
......
......@@ -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();
......
......@@ -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.
......
......@@ -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];
......
......@@ -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)
{
......
......@@ -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_;
}
......
......@@ -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);
......
......@@ -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];
......
......@@ -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));
}
}
......
......@@ -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
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment