cellModel.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 "cellModel.H"
00028 #include "pyramid.H"
00029
00030
00031
00032 Foam::vector Foam::cellModel::centre
00033 (
00034 const labelList& pointLabels,
00035 const pointField& points
00036 ) const
00037 {
00038
00039 vector cEst = vector::zero;
00040
00041
00042 forAll(pointLabels, i)
00043 {
00044 cEst += points[pointLabels[i]];
00045 }
00046
00047
00048 cEst /= scalar(pointLabels.size());
00049
00050
00051
00052
00053 scalar sumV = 0.0;
00054 vector sumVc = vector::zero;
00055
00056 const faceList cellFaces = faces(pointLabels);
00057
00058 forAll(cellFaces, i)
00059 {
00060 const face& curFace = cellFaces[i];
00061
00062 scalar pyrVol =
00063 pyramid<point, const point&, const face&>
00064 (
00065 curFace,
00066 cEst
00067 ).mag(points);
00068
00069 if (pyrVol > SMALL)
00070 {
00071 WarningIn("cellModel::centre(const labelList&, const pointField&)")
00072 << "zero or negative pyramid volume: " << -pyrVol
00073 << " for face " << i
00074 << endl;
00075 }
00076
00077 sumVc -=
00078 pyrVol
00079 *pyramid<point, const point&, const face&>(curFace, cEst)
00080 .centre(points);
00081
00082 sumV -= pyrVol;
00083 }
00084
00085 return sumVc/(sumV + VSMALL);
00086 }
00087
00088
00089 Foam::scalar Foam::cellModel::mag
00090 (
00091 const labelList& pointLabels,
00092 const pointField& points
00093 ) const
00094 {
00095
00096 vector cEst = vector::zero;
00097
00098
00099 forAll(pointLabels, i)
00100 {
00101 cEst += points[pointLabels[i]];
00102 }
00103
00104
00105 cEst /= scalar(pointLabels.size());
00106
00107
00108
00109
00110
00111
00112 scalar v = 0;
00113
00114 const faceList cellFaces = faces(pointLabels);
00115
00116 forAll(cellFaces, i)
00117 {
00118 const face& curFace =cellFaces[i];
00119
00120 scalar pyrVol =
00121 pyramid<point, const point&, const face&>
00122 (
00123 curFace,
00124 cEst
00125 ).mag(points);
00126
00127 if (pyrVol > SMALL)
00128 {
00129 WarningIn("cellModel::mag(const labelList&, const pointField&)")
00130 << "zero or negative pyramid volume: " << -pyrVol
00131 << " for face " << i
00132 << endl;
00133 }
00134
00135 v -= pyrVol;
00136 }
00137
00138 return v;
00139 }
00140
00141
Copyright © 2000-2009 OpenCFD Ltd