faceTemplates.C
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "face.H"
00028 #include "DynamicList.H"
00029
00030
00031
00032 template<unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
00033 Foam::label Foam::face::triangles
00034 (
00035 const pointField& points,
00036 DynamicList<face, SizeInc, SizeMult, SizeDiv>& triFaces
00037 ) const
00038 {
00039 label triI = triFaces.size();
00040 label quadI = 0;
00041 faceList quadFaces;
00042
00043
00044 triFaces.setSize(triI + nTriangles());
00045
00046 return split(SPLITTRIANGLE, points, triI, quadI, triFaces, quadFaces);
00047 }
00048
00049
00050 template<class Type>
00051 Type Foam::face::average
00052 (
00053 const pointField& meshPoints,
00054 const Field<Type>& f
00055 ) const
00056 {
00057
00058
00059
00060
00061 if (size() == 3)
00062 {
00063 return
00064 (1.0/3.0)
00065 *(
00066 f[operator[](0)]
00067 + f[operator[](1)]
00068 + f[operator[](2)]
00069 );
00070 }
00071
00072 label nPoints = size();
00073
00074 point centrePoint = point::zero;
00075 Type cf = pTraits<Type>::zero;
00076
00077 for (register label pI=0; pI<nPoints; pI++)
00078 {
00079 centrePoint += meshPoints[operator[](pI)];
00080 cf += f[operator[](pI)];
00081 }
00082
00083 centrePoint /= nPoints;
00084 cf /= nPoints;
00085
00086 scalar sumA = 0;
00087 Type sumAf = pTraits<Type>::zero;
00088
00089 for (register label pI=0; pI<nPoints; pI++)
00090 {
00091
00092 Type ttcf =
00093 (
00094 f[operator[](pI)]
00095 + f[operator[]((pI + 1) % nPoints)]
00096 + cf
00097 );
00098
00099
00100 scalar ta = Foam::mag
00101 (
00102 (meshPoints[operator[](pI)] - centrePoint)
00103 ^ (meshPoints[operator[]((pI + 1) % nPoints)] - centrePoint)
00104 );
00105
00106 sumA += ta;
00107 sumAf += ta*ttcf;
00108 }
00109
00110 if (sumA > VSMALL)
00111 {
00112 return sumAf/(3*sumA);
00113 }
00114 else
00115 {
00116 return cf;
00117 }
00118 }
00119
00120
Copyright © 2000-2009 OpenCFD Ltd