OpenFOAM には,ベクトルに対する様々な演算子が用意されています.次のプログラムを実行して,それぞれの演算子の意味を確認しましょう.
Test Program |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
#include "vector.H" #include "IOstreams.H" using namespace Foam; int main() { vector a(0.2, -0.51, 0.5); Info<< "cmptMax(a) = " << cmptMax(a) << endl; Info<< "cmptMin(a) = " << cmptMin(a) << endl; Info<< "cmptSum(a) = " << cmptSum(a) << endl; Info<< "cmptAv(a) = " << cmptAv(a) << endl; Info<< "cmptProduct(a) = " << cmptProduct(a) << endl; Info<< "cmptMag(a) = " << cmptMag(a) << endl; vector b(1.0, 2.0, 3.0); vector c(-3.0, 4.0, 1.0); Info<< "cmptMultiply(b, c) = " << cmptMultiply(b, c) << endl; Info<< "max(b, c) = " << max(b, c) << endl; Info<< "min(b, c) = " << min(b, c) << endl; return 0; } |
Results |
1 2 3 4 5 6 7 8 9 |
cmptMax(a) = 0.5 cmptMin(a) = -0.51 cmptSum(a) = 0.19 cmptAv(a) = 0.0633333 cmptProduct(a) = -0.051 cmptMag(a) = (0.2 0.51 0.5) cmptMultiply(b, c) = (-3 8 3) max(b, c) = (1 4 3) min(b, c) = (-3 2 1) |
Meaning of the Operations |
- cmptMax
$$cmptMax({\bf a}) = max (a_{1},\;a_{2},\;a_{3})$$
- cmptMin
$$cmptMin({\bf a}) = min (a_{1},\;a_{2},\;a_{3})$$
- cmptSum
$$cmptSum({\bf a}) = a_{1} + a_{2} + a_{3}$$
- cmptAv
$$cmptAv({\bf a}) = \frac{a_{1} + a_{2} + a_{3}}{3}$$
- cmptProduct
$$cmptProduct({\bf a}) = a_{1} \times a_{2} \times a_{3}$$
- cmptMag
$$cmptMag({\bf a}) = (|a_{1}|\;\;|a_{2}|\;\;|a_{3}|)$$
- cmptMultiply
$$cmptMultiply({\bf b},\;{\bf c}) = (b_{1}\times c_{1}\;\;b_{2}\times c_{2}\;\;b_{3}\times c_{3})$$
- max
$$max({\bf b},\;{\bf c}) = (max(b_{1},\;c_{1})\;\;max(b_{2},\;c_{2})\;\;max(b_{3},\;c_{3}))$$
- min
$$min({\bf b},\;{\bf c}) = (min(b_{1},\;c_{1})\;\;min(b_{2},\;c_{2})\;\;min(b_{3},\;c_{3}))$$
これらのベクトル演算子は,VectorSpaceI.H ファイルで実装されています.