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