Skip to content
Snippets Groups Projects
Commit a2f5eab5 authored by Mark Olesen's avatar Mark Olesen
Browse files

allow construction of face() from triFace()

parent e2ad94d9
Branches
Tags
No related merge requests found
...@@ -25,6 +25,7 @@ License ...@@ -25,6 +25,7 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "face.H" #include "face.H"
#include "triFace.H"
#include "triPointRef.H" #include "triPointRef.H"
#include "mathematicalConstants.H" #include "mathematicalConstants.H"
...@@ -283,6 +284,14 @@ void Foam::face::split ...@@ -283,6 +284,14 @@ void Foam::face::split
} }
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::face::face(const triFace& f)
:
labelList(f)
{}
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
......
...@@ -56,6 +56,7 @@ namespace Foam ...@@ -56,6 +56,7 @@ namespace Foam
// Forward declaration of friend functions and operators // Forward declaration of friend functions and operators
class face; class face;
class triFace;
inline bool operator==(const face& a, const face& b); inline bool operator==(const face& a, const face& b);
inline bool operator!=(const face& a, const face& b); inline bool operator!=(const face& a, const face& b);
inline Istream& operator>>(Istream&, face&); inline Istream& operator>>(Istream&, face&);
...@@ -135,12 +136,18 @@ public: ...@@ -135,12 +136,18 @@ public:
//- Construct given size //- Construct given size
explicit inline face(label); explicit inline face(label);
//- Construct from labelList //- Construct from list of labels
explicit inline face(const UList<label>&);
//- Construct from list of labels
explicit inline face(const labelList&); explicit inline face(const labelList&);
//- Construct by transferring the parameter contents //- Construct by transferring the parameter contents
explicit inline face(const xfer<labelList>&); explicit inline face(const xfer<labelList>&);
//- Copy construct from triFace
face(const triFace&);
//- Construct from Istream //- Construct from Istream
inline face(Istream&); inline face(Istream&);
......
...@@ -42,32 +42,34 @@ inline Foam::label Foam::face::left(const label i) const ...@@ -42,32 +42,34 @@ inline Foam::label Foam::face::left(const label i) const
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct NULL
inline Foam::face::face() inline Foam::face::face()
{} {}
// Construct given size
inline Foam::face::face(label s) inline Foam::face::face(label s)
: :
labelList(s, -1) labelList(s, -1)
{} {}
// Construct from components inline Foam::face::face(const UList<label>& lst)
:
labelList(lst)
{}
inline Foam::face::face(const labelList& lst) inline Foam::face::face(const labelList& lst)
: :
labelList(lst) labelList(lst)
{} {}
// Construct from components
inline Foam::face::face(const xfer<labelList>& lst) inline Foam::face::face(const xfer<labelList>& lst)
: :
labelList(lst) labelList(lst)
{} {}
// Construct from Istream
inline Foam::face::face(Istream& is) inline Foam::face::face(Istream& is)
{ {
is >> *this; is >> *this;
......
...@@ -26,15 +26,14 @@ License ...@@ -26,15 +26,14 @@ License
#include "face.H" #include "face.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type> template<class Type>
Type face::average(const pointField& meshPoints, const Field<Type>& f) const Type Foam::face::average
(
const pointField& meshPoints,
const Field<Type>& f
) const
{ {
// Calculate the average by breaking the face into triangles and // Calculate the average by breaking the face into triangles and
// area-weighted averaging their averages // area-weighted averaging their averages
...@@ -42,7 +41,7 @@ Type face::average(const pointField& meshPoints, const Field<Type>& f) const ...@@ -42,7 +41,7 @@ Type face::average(const pointField& meshPoints, const Field<Type>& f) const
// If the face is a triangle, do a direct calculation // If the face is a triangle, do a direct calculation
if (size() == 3) if (size() == 3)
{ {
return return
(1.0/3.0) (1.0/3.0)
*( *(
f[operator[](0)] f[operator[](0)]
...@@ -71,7 +70,7 @@ Type face::average(const pointField& meshPoints, const Field<Type>& f) const ...@@ -71,7 +70,7 @@ Type face::average(const pointField& meshPoints, const Field<Type>& f) const
for (register label pI=0; pI<nPoints; pI++) for (register label pI=0; pI<nPoints; pI++)
{ {
// Calculate 3*triangle centre field value // Calculate 3*triangle centre field value
Type ttcf = Type ttcf =
( (
f[operator[](pI)] f[operator[](pI)]
+ f[operator[]((pI + 1) % nPoints)] + f[operator[]((pI + 1) % nPoints)]
...@@ -99,9 +98,4 @@ Type face::average(const pointField& meshPoints, const Field<Type>& f) const ...@@ -99,9 +98,4 @@ Type face::average(const pointField& meshPoints, const Field<Type>& f) const
} }
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* // // ************************************************************************* //
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