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
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #ifndef centreEdge_H
00040 #define centreEdge_H
00041
00042 #include "label.H"
00043 #include "primitiveMesh.H"
00044
00045
00046
00047 namespace Foam
00048 {
00049
00050
00051
00052
00053
00054
00055
00056 class centreEdge
00057 {
00058
00059
00060
00061 label faceLabel_;
00062
00063
00064 bool inOwner_;
00065
00066 public:
00067
00068
00069
00070
00071 class centreEdgeHash
00072 {
00073
00074 public:
00075
00076 centreEdgeHash()
00077 {}
00078
00079
00080 label operator()(const centreEdge& ce, const label tableSize) const
00081 {
00082 return (ce.faceLabel() + ce.inOwner()) % tableSize;
00083 }
00084 };
00085
00086
00087
00088
00089
00090 inline centreEdge()
00091 :
00092 faceLabel_(-1),
00093 inOwner_(-1)
00094 {}
00095
00096
00097 inline centreEdge(const label faceLabel, const bool inOwner)
00098 :
00099 faceLabel_(faceLabel),
00100 inOwner_(inOwner)
00101 {}
00102
00103
00104
00105 label faceLabel() const
00106 {
00107 return faceLabel_;
00108 }
00109
00110 bool inOwner() const
00111 {
00112 return inOwner_;
00113 }
00114
00115 template <class T>
00116 T interpolate
00117 (
00118 const primitiveMesh& mesh,
00119 const Field<T>& cellField,
00120 const Field<T>& faceField,
00121 const scalar weight
00122 ) const
00123 {
00124 label cellI;
00125 if (inOwner_)
00126 {
00127 cellI = mesh.faceOwner()[faceLabel_];
00128 }
00129 else
00130 {
00131 cellI = mesh.faceNeighbour()[faceLabel_];
00132 }
00133
00134 return
00135 (1-weight)*faceField[faceLabel_]
00136 + weight*cellField[cellI];
00137 }
00138
00139 point coord(const primitiveMesh& mesh, const scalar weight) const
00140 {
00141 return interpolate
00142 (
00143 mesh,
00144 mesh.cellCentres(),
00145 mesh.faceCentres(),
00146 weight
00147 );
00148 }
00149
00150
00151
00152
00153 bool operator==(const centreEdge& ce) const
00154 {
00155 return
00156 (faceLabel() == ce.faceLabel())
00157 && (inOwner() == ce.inOwner());
00158 }
00159
00160
00161
00162
00163 inline friend Ostream& operator<<(Ostream& os, const centreEdge& ce)
00164 {
00165 os << token::BEGIN_LIST
00166 << ce.faceLabel_ << token::SPACE
00167 << ce.inOwner_
00168 << token::END_LIST;
00169
00170
00171 os.check("Ostream& operator<<(Ostream&, const centreEdge&)");
00172
00173 return os;
00174 }
00175 };
00176
00177
00178
00179
00180 }
00181
00182
00183
00184 #endif
00185
00186