CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Export patch profile (https://www.cfd-online.com/Forums/openfoam-solving/59197-export-patch-profile.html)

johndeas January 17, 2008 05:50

How can I export a variable pr
 
How can I export a variable profile on a boundary patch ?

johndeas January 22, 2008 08:45

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 ?

johndeas January 23, 2008 07:54

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 +

hjasak January 23, 2008 08:30

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

johndeas January 25, 2008 05:17

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 ?

hjasak January 25, 2008 05:27

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.