transform.H
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
00028
00029
00030
00031
00032
00033 #ifndef transform_H
00034 #define transform_H
00035
00036 #include "tensor.H"
00037 #include "mathematicalConstants.H"
00038
00039
00040
00041 namespace Foam
00042 {
00043
00044
00045
00046 inline tensor rotationTensor
00047 (
00048 const vector& n1,
00049 const vector& n2
00050 )
00051 {
00052 return
00053 (n1 & n2)*I
00054 + (1 - (n1 & n2))*sqr(n1 ^ n2)/(magSqr(n1 ^ n2) + VSMALL)
00055 + (n2*n1 - n1*n2);
00056 }
00057
00058
00059 inline label transform(const tensor&, const label i)
00060 {
00061 return i;
00062 }
00063
00064
00065 inline scalar transform(const tensor&, const scalar s)
00066 {
00067 return s;
00068 }
00069
00070
00071 template<class Cmpt>
00072 inline Vector<Cmpt> transform(const tensor& tt, const Vector<Cmpt>& v)
00073 {
00074 return tt & v;
00075 }
00076
00077
00078 template<class Cmpt>
00079 inline Tensor<Cmpt> transform(const tensor& tt, const Tensor<Cmpt>& t)
00080 {
00081
00082 return Tensor<Cmpt>
00083 (
00084 (tt.xx()*t.xx() + tt.xy()*t.yx() + tt.xz()*t.zx())*tt.xx()
00085 + (tt.xx()*t.xy() + tt.xy()*t.yy() + tt.xz()*t.zy())*tt.xy()
00086 + (tt.xx()*t.xz() + tt.xy()*t.yz() + tt.xz()*t.zz())*tt.xz(),
00087
00088 (tt.xx()*t.xx() + tt.xy()*t.yx() + tt.xz()*t.zx())*tt.yx()
00089 + (tt.xx()*t.xy() + tt.xy()*t.yy() + tt.xz()*t.zy())*tt.yy()
00090 + (tt.xx()*t.xz() + tt.xy()*t.yz() + tt.xz()*t.zz())*tt.yz(),
00091
00092 (tt.xx()*t.xx() + tt.xy()*t.yx() + tt.xz()*t.zx())*tt.zx()
00093 + (tt.xx()*t.xy() + tt.xy()*t.yy() + tt.xz()*t.zy())*tt.zy()
00094 + (tt.xx()*t.xz() + tt.xy()*t.yz() + tt.xz()*t.zz())*tt.zz(),
00095
00096 (tt.yx()*t.xx() + tt.yy()*t.yx() + tt.yz()*t.zx())*tt.xx()
00097 + (tt.yx()*t.xy() + tt.yy()*t.yy() + tt.yz()*t.zy())*tt.xy()
00098 + (tt.yx()*t.xz() + tt.yy()*t.yz() + tt.yz()*t.zz())*tt.xz(),
00099
00100 (tt.yx()*t.xx() + tt.yy()*t.yx() + tt.yz()*t.zx())*tt.yx()
00101 + (tt.yx()*t.xy() + tt.yy()*t.yy() + tt.yz()*t.zy())*tt.yy()
00102 + (tt.yx()*t.xz() + tt.yy()*t.yz() + tt.yz()*t.zz())*tt.yz(),
00103
00104 (tt.yx()*t.xx() + tt.yy()*t.yx() + tt.yz()*t.zx())*tt.zx()
00105 + (tt.yx()*t.xy() + tt.yy()*t.yy() + tt.yz()*t.zy())*tt.zy()
00106 + (tt.yx()*t.xz() + tt.yy()*t.yz() + tt.yz()*t.zz())*tt.zz(),
00107
00108 (tt.zx()*t.xx() + tt.zy()*t.yx() + tt.zz()*t.zx())*tt.xx()
00109 + (tt.zx()*t.xy() + tt.zy()*t.yy() + tt.zz()*t.zy())*tt.xy()
00110 + (tt.zx()*t.xz() + tt.zy()*t.yz() + tt.zz()*t.zz())*tt.xz(),
00111
00112 (tt.zx()*t.xx() + tt.zy()*t.yx() + tt.zz()*t.zx())*tt.yx()
00113 + (tt.zx()*t.xy() + tt.zy()*t.yy() + tt.zz()*t.zy())*tt.yy()
00114 + (tt.zx()*t.xz() + tt.zy()*t.yz() + tt.zz()*t.zz())*tt.yz(),
00115
00116 (tt.zx()*t.xx() + tt.zy()*t.yx() + tt.zz()*t.zx())*tt.zx()
00117 + (tt.zx()*t.xy() + tt.zy()*t.yy() + tt.zz()*t.zy())*tt.zy()
00118 + (tt.zx()*t.xz() + tt.zy()*t.yz() + tt.zz()*t.zz())*tt.zz()
00119 );
00120 }
00121
00122
00123 template<class Cmpt>
00124 inline SphericalTensor<Cmpt> transform
00125 (
00126 const tensor& tt,
00127 const SphericalTensor<Cmpt>& st
00128 )
00129 {
00130 return st;
00131 }
00132
00133
00134 template<class Cmpt>
00135 inline SymmTensor<Cmpt> transform(const tensor& tt, const SymmTensor<Cmpt>& st)
00136 {
00137 return SymmTensor<Cmpt>
00138 (
00139 (tt.xx()*st.xx() + tt.xy()*st.xy() + tt.xz()*st.xz())*tt.xx()
00140 + (tt.xx()*st.xy() + tt.xy()*st.yy() + tt.xz()*st.yz())*tt.xy()
00141 + (tt.xx()*st.xz() + tt.xy()*st.yz() + tt.xz()*st.zz())*tt.xz(),
00142
00143 (tt.xx()*st.xx() + tt.xy()*st.xy() + tt.xz()*st.xz())*tt.yx()
00144 + (tt.xx()*st.xy() + tt.xy()*st.yy() + tt.xz()*st.yz())*tt.yy()
00145 + (tt.xx()*st.xz() + tt.xy()*st.yz() + tt.xz()*st.zz())*tt.yz(),
00146
00147 (tt.xx()*st.xx() + tt.xy()*st.xy() + tt.xz()*st.xz())*tt.zx()
00148 + (tt.xx()*st.xy() + tt.xy()*st.yy() + tt.xz()*st.yz())*tt.zy()
00149 + (tt.xx()*st.xz() + tt.xy()*st.yz() + tt.xz()*st.zz())*tt.zz(),
00150
00151 (tt.yx()*st.xx() + tt.yy()*st.xy() + tt.yz()*st.xz())*tt.yx()
00152 + (tt.yx()*st.xy() + tt.yy()*st.yy() + tt.yz()*st.yz())*tt.yy()
00153 + (tt.yx()*st.xz() + tt.yy()*st.yz() + tt.yz()*st.zz())*tt.yz(),
00154
00155 (tt.yx()*st.xx() + tt.yy()*st.xy() + tt.yz()*st.xz())*tt.zx()
00156 + (tt.yx()*st.xy() + tt.yy()*st.yy() + tt.yz()*st.yz())*tt.zy()
00157 + (tt.yx()*st.xz() + tt.yy()*st.yz() + tt.yz()*st.zz())*tt.zz(),
00158
00159 (tt.zx()*st.xx() + tt.zy()*st.xy() + tt.zz()*st.xz())*tt.zx()
00160 + (tt.zx()*st.xy() + tt.zy()*st.yy() + tt.zz()*st.yz())*tt.zy()
00161 + (tt.zx()*st.xz() + tt.zy()*st.yz() + tt.zz()*st.zz())*tt.zz()
00162 );
00163 }
00164
00165
00166 template<class Type1, class Type2>
00167 inline Type1 transformMask(const Type2& t)
00168 {
00169 return t;
00170 }
00171
00172
00173 template<>
00174 inline sphericalTensor transformMask<sphericalTensor>(const tensor& t)
00175 {
00176 return sph(t);
00177 }
00178
00179
00180 template<>
00181 inline symmTensor transformMask<symmTensor>(const tensor& t)
00182 {
00183 return symm(t);
00184 }
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196 inline scalar pseudoAngle
00197 (
00198 const vector& e0,
00199 const vector& e1,
00200 const vector& vec
00201 )
00202 {
00203 scalar cos = vec & e0;
00204 scalar sin = vec & e1;
00205
00206 if (sin < -SMALL)
00207 {
00208 return (3.0 + cos)*mathematicalConstant::piByTwo;
00209 }
00210 else
00211 {
00212 return (1.0 - cos)*mathematicalConstant::piByTwo;
00213 }
00214 }
00215
00216
00217
00218
00219 }
00220
00221
00222
00223 #endif
00224
00225
Copyright © 2000-2009 OpenCFD Ltd