newbie question - simple pTraits
I want to compile the pTraits test routine using just command line e.g.
g++ pTraitsTest.C I get: gcc version 4.3.4 20090804 (release) 1 (GCC) $ g++ pTraitsTest.C pTraits.H: In instantiation of `Foam::pTraits<double>': pTraitsTest.C:42: instantiated from here pTraits.H:52: error: base type `double' fails to be a struct or class type pTraitsTest.C: In function `int main()': pTraitsTest.C:42: error: `typeName' is not a member of `Foam::pTraits<double>' ansayre@ansayre2m4 /cygdrive/d/dev/OpenFOAM/OpenFOAM-1.7.1/gcc/pTraits I defined WM_DP. What else do I need to do? |
Greetings Alan,
Newbie? You're using Cygwin! ;) You need OpenFOAM to be already built under your development environment. If that has already been achieved, simply use this command: Code:
wmake Code:
echo $FOAM_USER_APPBIN Best regards, Bruno |
Dear Bruno,
About the pTraits, can we view them as a special scalar or vector? Because now I have met two situations they are used: 1, used in the operations: Code:
vector omg = 2*ranGen.vector01() - pTraits<vector>::one Code:
loc_(pTraits<vector>::zero) |
Hi openfoammaofnepo,
Quote:
I'll try to have a look into it this coming weekend. Best regards, Bruno |
Thank you in advance!
|
Hi openfoammaofnepo,
I did a quick search and this is what I've figured out:
As for the question you asked: Code:
pTraits<vector>::one ... and I'm a bit lost in the code. I'm not 100% certain, but it either it's for accessing the static definitions of one and zero for vector, or to have access to the mathematical operators wrapped up in pTraits. Best regards, Bruno |
Thank you very much for your so detailed explanantion. I think I have more understanding after I read your reply for me.
Thank you again! |
Good evening,
I will probably not be able to tell the full story, but let me share what I know: As Bruno says, it is merely a matter of accessing ::zero, ::one, the size (e.g. number of elements) of a given type (etc). pTraits was (allegedly) introduced in order to handle this smoothly for scalars, because they were previously derived directly from the std:: namespace, i.e. if-sentences were needed to distinguish between scalars and everything else. This caused loss of computational efficiency. Therefore, pTraits is merely a wrapper class, which unifies access to certain properties for all primitive types. It is used in the very core of everything, e.g. whenever you compute a gradient of a given field, the following function is called in the grad schemes: Code:
virtual tmp Code:
./primitives/VectorSpace/products.H Code:
template<class arg1, class arg2> Kind regards, Niels |
Dear ngj,
Thank you so much. Today I met the pTraits in the turbulentInlet.C again. So I had a look at thread again. The codes are as follows: Code:
scalar rmsCorr = sqrt(12*(2*alpha_ - sqr(alpha_)))/alpha_; Thank you so much. OFFO Quote:
|
Quote:
|
Thank you!!
Quote:
|
Hi openfoammaofnepo
can you explain about below code: template<class arg1, class arg2> class outerProduct { public: typedef typename typeOfRank < typename pTraits<arg1>::cmptType, int(pTraits<arg1>::rank) + int(pTraits<arg2>::rank) >::type type; }; |
All times are GMT -4. The time now is 07:18. |