mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: improve consistency in access for face, triFace, edge.
- ensure that each have found() and which() methods - add faceTraits for handling compile-time differences between 'normal' and tri-faces - provide line::unitVec method (complimentary to edge::unitVec)
This commit is contained in:
@ -112,6 +112,7 @@ Foam::UList<T> Foam::UList<T>::operator[](const labelRange& range)
|
|||||||
return UList<T>(&(this->v_[slice.start()]), slice.size()); // SubList
|
return UList<T>(&(this->v_[slice.start()]), slice.size()); // SubList
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
const Foam::UList<T> Foam::UList<T>::operator[](const labelRange& range) const
|
const Foam::UList<T> Foam::UList<T>::operator[](const labelRange& range) const
|
||||||
{
|
{
|
||||||
@ -132,6 +133,7 @@ Foam::UList<T> Foam::UList<T>::operator[]
|
|||||||
return UList<T>(&(this->v_[slice.start()]), slice.size()); // SubList
|
return UList<T>(&(this->v_[slice.start()]), slice.size()); // SubList
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
const Foam::UList<T> Foam::UList<T>::operator[]
|
const Foam::UList<T> Foam::UList<T>::operator[]
|
||||||
(
|
(
|
||||||
|
|||||||
@ -149,7 +149,11 @@ public:
|
|||||||
|
|
||||||
//- Return true if point label is found in edge.
|
//- Return true if point label is found in edge.
|
||||||
// Always false for a negative label.
|
// Always false for a negative label.
|
||||||
inline bool found(const label index) const;
|
inline bool found(const label pointLabel) const;
|
||||||
|
|
||||||
|
//- Return local index (0,1) of point label in edge -1 on failure
|
||||||
|
// Always return -1 for a negative label.
|
||||||
|
inline label which(const label pointLabel) const;
|
||||||
|
|
||||||
//- Do the edges share a common vertex index?
|
//- Do the edges share a common vertex index?
|
||||||
// Negative point labels never connect.
|
// Negative point labels never connect.
|
||||||
|
|||||||
@ -206,10 +206,28 @@ inline Foam::label Foam::edge::maxVertex() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool Foam::edge::found(const label index) const
|
inline bool Foam::edge::found(const label pointLabel) const
|
||||||
{
|
{
|
||||||
// -1: always false
|
// -1: always false
|
||||||
return (index >= 0 && (index == start() || index == end()));
|
return (pointLabel >= 0 && (pointLabel == start() || pointLabel == end()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::label Foam::edge::which(const label pointLabel) const
|
||||||
|
{
|
||||||
|
// -1: always false
|
||||||
|
if (pointLabel >= 0)
|
||||||
|
{
|
||||||
|
if (pointLabel == start())
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (pointLabel == end())
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -202,7 +202,10 @@ public:
|
|||||||
|
|
||||||
//- Navigation through face vertices
|
//- Navigation through face vertices
|
||||||
|
|
||||||
//- Which vertex on face (face index given a global index)
|
//- Return true if the global point label is found in face.
|
||||||
|
inline bool found(const label globalIndex) const;
|
||||||
|
|
||||||
|
//- Which local vertex on face given a global index.
|
||||||
// returns -1 if not found
|
// returns -1 if not found
|
||||||
label which(const label globalIndex) const;
|
label which(const label globalIndex) const;
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -116,20 +116,24 @@ inline Foam::edge Foam::face::faceEdge(const label n) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Next vertex on face
|
inline bool Foam::face::found(const label globalIndex) const
|
||||||
|
{
|
||||||
|
return which(globalIndex) != -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Foam::label Foam::face::nextLabel(const label i) const
|
inline Foam::label Foam::face::nextLabel(const label i) const
|
||||||
{
|
{
|
||||||
return operator[](fcIndex(i));
|
return operator[](fcIndex(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Previous vertex on face
|
|
||||||
inline Foam::label Foam::face::prevLabel(const label i) const
|
inline Foam::label Foam::face::prevLabel(const label i) const
|
||||||
{
|
{
|
||||||
return operator[](rcIndex(i));
|
return operator[](rcIndex(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Number of triangles directly known from number of vertices
|
|
||||||
inline Foam::label Foam::face::nTriangles() const
|
inline Foam::label Foam::face::nTriangles() const
|
||||||
{
|
{
|
||||||
return size() - 2;
|
return size() - 2;
|
||||||
|
|||||||
73
src/OpenFOAM/meshes/meshShapes/traits/faceTraits.H
Normal file
73
src/OpenFOAM/meshes/meshShapes/traits/faceTraits.H
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::faceTraits
|
||||||
|
|
||||||
|
Description
|
||||||
|
Traits class for faces
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef faceTraits_H
|
||||||
|
#define faceTraits_H
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
// Forward declarations
|
||||||
|
class triFace;
|
||||||
|
class labelledTri;
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class faceTraits Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
template<class FaceType>
|
||||||
|
class faceTraits
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Face-type only handles triangles. Not true in general.
|
||||||
|
inline static bool isTri() { return false; }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template<>
|
||||||
|
inline bool faceTraits<triFace>::isTri() { return true; }
|
||||||
|
|
||||||
|
template<>
|
||||||
|
inline bool faceTraits<labelledTri>::isTri() { return true; }
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -137,6 +137,13 @@ public:
|
|||||||
// The starting points of the original and reverse face are identical.
|
// The starting points of the original and reverse face are identical.
|
||||||
inline triFace reverseFace() const;
|
inline triFace reverseFace() const;
|
||||||
|
|
||||||
|
//- Return true if the global point label is found in face.
|
||||||
|
bool found(const label globalIndex) const;
|
||||||
|
|
||||||
|
//- Which local index (0,1,2) on face given a global index.
|
||||||
|
// returns -1 if not found
|
||||||
|
label which(const label globalIndex) const;
|
||||||
|
|
||||||
//- Return swept-volume from old-points to new-points
|
//- Return swept-volume from old-points to new-points
|
||||||
inline scalar sweptVol
|
inline scalar sweptVol
|
||||||
(
|
(
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -209,6 +209,21 @@ inline Foam::triFace Foam::triFace::reverseFace() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline bool Foam::triFace::found(const label globalIndex) const
|
||||||
|
{
|
||||||
|
return which(globalIndex) != -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::label Foam::triFace::which(const label globalIndex) const
|
||||||
|
{
|
||||||
|
if (operator[](0) == globalIndex) return 0;
|
||||||
|
if (operator[](1) == globalIndex) return 1;
|
||||||
|
if (operator[](2) == globalIndex) return 2;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Foam::scalar Foam::triFace::sweptVol
|
inline Foam::scalar Foam::triFace::sweptVol
|
||||||
(
|
(
|
||||||
const UList<point>& opts,
|
const UList<point>& opts,
|
||||||
|
|||||||
@ -98,10 +98,10 @@ public:
|
|||||||
|
|
||||||
// Access
|
// Access
|
||||||
|
|
||||||
//- Return first vertex
|
//- Return first point
|
||||||
inline PointRef start() const;
|
inline PointRef start() const;
|
||||||
|
|
||||||
//- Return second vertex
|
//- Return second point
|
||||||
inline PointRef end() const;
|
inline PointRef end() const;
|
||||||
|
|
||||||
|
|
||||||
@ -113,9 +113,12 @@ public:
|
|||||||
//- Return scalar magnitude
|
//- Return scalar magnitude
|
||||||
inline scalar mag() const;
|
inline scalar mag() const;
|
||||||
|
|
||||||
//- Return start-end vector
|
//- Return start-to-end vector
|
||||||
inline Point vec() const;
|
inline Point vec() const;
|
||||||
|
|
||||||
|
//- Return the unit vector (start-to-end)
|
||||||
|
inline Point unitVec() const;
|
||||||
|
|
||||||
//- Return nearest distance to line from a given point
|
//- Return nearest distance to line from a given point
|
||||||
// If the nearest point is on the line, return a hit
|
// If the nearest point is on the line, return a hit
|
||||||
PointHit<Point> nearestDist(const Point& p) const;
|
PointHit<Point> nearestDist(const Point& p) const;
|
||||||
|
|||||||
@ -90,6 +90,16 @@ inline Point Foam::line<Point, PointRef>::vec() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Point, class PointRef>
|
||||||
|
inline Point Foam::line<Point, PointRef>::unitVec() const
|
||||||
|
{
|
||||||
|
Point v = b_ - a_;
|
||||||
|
v /= ::Foam::mag(v) + VSMALL;
|
||||||
|
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Point, class PointRef>
|
template<class Point, class PointRef>
|
||||||
Foam::PointHit<Point> Foam::line<Point, PointRef>::nearestDist
|
Foam::PointHit<Point> Foam::line<Point, PointRef>::nearestDist
|
||||||
(
|
(
|
||||||
|
|||||||
Reference in New Issue
Block a user