How can I export a variable pr
How can I export a variable profile on a boundary patch ?
|
More precisely, how can I expo
More precisely, how can I export the content of a fvPatchField (either <double> or vector<double>) to a file ?
|
To better understand how class
To better understand how classes work, I tried to play a little. What I do not understand is why this code :
List<scalar> a(10); a=2; List<scalar> b(10); b=3; List<scalar> c=a+b; Info << "c(1) = " << c[1] << endl; gives the result c(1) = 5 since in the member functions of List I can not find the operator + |
Not sure what else you have ex
Not sure what else you have expected: 2 + 3 = 5.
Here, you created 2 lists of size 10, then assigned all elements of first list to 2 and all elements of the second list to 3 and summed them up. The actual operator+(...) you are using is: template<class> tmp<field<typename>::type> > operator Op(const UList<type1>& f1, const UList<type2>& f2); in /home/hjasak/OpenFOAM/OpenFOAM-1.4.1-dev/src/OpenFOAM/fields/Fields/Field/FieldF unctions.H Beware of the macros... Hrv |
Why are some operators impleme
Why are some operators implemented via member functions and others via macros ? It seems to me that macros are harder to find in the documentation ?
|
Because of code re-use and con
Because of code re-use and consistency. Templates, (of course, you mean templates! rather than member functions) are preferred whenever possible - in fact you will see that the macro I've showed you actually defines a template.
Other possible question you may be asking is why is eg. operator+= a member and operator+ a friend. There are VERY good reasons for it, to do with automatic type conversion on the rhs argument. A good C++ book will tell you why. Enjoy, Hrv |
All times are GMT -4. The time now is 22:37. |