From a2f5eab5dafa9bef2d42872b76968efe4c198cf0 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@Germany> Date: Fri, 7 Nov 2008 21:53:21 +0100 Subject: [PATCH] allow construction of face() from triFace() --- src/OpenFOAM/meshes/meshShapes/face/face.C | 9 +++++++++ src/OpenFOAM/meshes/meshShapes/face/face.H | 9 ++++++++- src/OpenFOAM/meshes/meshShapes/face/faceI.H | 12 ++++++----- .../meshes/meshShapes/face/faceTemplates.C | 20 +++++++------------ 4 files changed, 31 insertions(+), 19 deletions(-) diff --git a/src/OpenFOAM/meshes/meshShapes/face/face.C b/src/OpenFOAM/meshes/meshShapes/face/face.C index b34f838b6a2..16d71fe9b06 100644 --- a/src/OpenFOAM/meshes/meshShapes/face/face.C +++ b/src/OpenFOAM/meshes/meshShapes/face/face.C @@ -25,6 +25,7 @@ License \*---------------------------------------------------------------------------*/ #include "face.H" +#include "triFace.H" #include "triPointRef.H" #include "mathematicalConstants.H" @@ -283,6 +284,14 @@ void Foam::face::split } +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::face::face(const triFace& f) +: + labelList(f) +{} + + // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // diff --git a/src/OpenFOAM/meshes/meshShapes/face/face.H b/src/OpenFOAM/meshes/meshShapes/face/face.H index fe9570e2b99..875df604959 100644 --- a/src/OpenFOAM/meshes/meshShapes/face/face.H +++ b/src/OpenFOAM/meshes/meshShapes/face/face.H @@ -56,6 +56,7 @@ namespace Foam // Forward declaration of friend functions and operators class face; +class triFace; inline bool operator==(const face& a, const face& b); inline bool operator!=(const face& a, const face& b); inline Istream& operator>>(Istream&, face&); @@ -135,12 +136,18 @@ public: //- Construct given size 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&); //- Construct by transferring the parameter contents explicit inline face(const xfer<labelList>&); + //- Copy construct from triFace + face(const triFace&); + //- Construct from Istream inline face(Istream&); diff --git a/src/OpenFOAM/meshes/meshShapes/face/faceI.H b/src/OpenFOAM/meshes/meshShapes/face/faceI.H index 50d1787a000..8b1d9a38ab8 100644 --- a/src/OpenFOAM/meshes/meshShapes/face/faceI.H +++ b/src/OpenFOAM/meshes/meshShapes/face/faceI.H @@ -42,32 +42,34 @@ inline Foam::label Foam::face::left(const label i) const // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -// Construct NULL inline Foam::face::face() {} -// Construct given size inline Foam::face::face(label s) : labelList(s, -1) {} -// Construct from components +inline Foam::face::face(const UList<label>& lst) +: + labelList(lst) +{} + + inline Foam::face::face(const labelList& lst) : labelList(lst) {} -// Construct from components + inline Foam::face::face(const xfer<labelList>& lst) : labelList(lst) {} -// Construct from Istream inline Foam::face::face(Istream& is) { is >> *this; diff --git a/src/OpenFOAM/meshes/meshShapes/face/faceTemplates.C b/src/OpenFOAM/meshes/meshShapes/face/faceTemplates.C index bfb9c751603..5d48a8d1470 100644 --- a/src/OpenFOAM/meshes/meshShapes/face/faceTemplates.C +++ b/src/OpenFOAM/meshes/meshShapes/face/faceTemplates.C @@ -26,15 +26,14 @@ License #include "face.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // 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 // area-weighted averaging their averages @@ -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 (size() == 3) { - return + return (1.0/3.0) *( f[operator[](0)] @@ -71,7 +70,7 @@ Type face::average(const pointField& meshPoints, const Field<Type>& f) const for (register label pI=0; pI<nPoints; pI++) { // Calculate 3*triangle centre field value - Type ttcf = + Type ttcf = ( f[operator[](pI)] + f[operator[]((pI + 1) % nPoints)] @@ -99,9 +98,4 @@ Type face::average(const pointField& meshPoints, const Field<Type>& f) const } } - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* // -- GitLab