|
[Sponsors] |
April 23, 2011, 20:46 |
newbie question - simple pTraits
|
#1 |
New Member
Alan N. Sayre
Join Date: May 2009
Posts: 3
Rep Power: 17 |
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:Traits<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:Traits<double>' ansayre@ansayre2m4 /cygdrive/d/dev/OpenFOAM/OpenFOAM-1.7.1/gcc/pTraits I defined WM_DP. What else do I need to do? |
|
April 24, 2011, 11:19 |
|
#2 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
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
__________________
Last edited by wyldckat; April 25, 2011 at 18:48. Reason: typo: "You're" not "your"... |
|
February 5, 2014, 12:00 |
|
#3 |
Senior Member
Join Date: Jan 2013
Posts: 372
Rep Power: 14 |
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) |
|
February 5, 2014, 16:20 |
|
#4 | |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
Hi openfoammaofnepo,
Quote:
I'll try to have a look into it this coming weekend. Best regards, Bruno
__________________
|
||
February 5, 2014, 17:53 |
|
#5 |
Senior Member
Join Date: Jan 2013
Posts: 372
Rep Power: 14 |
Thank you in advance!
|
|
February 9, 2014, 16:38 |
|
#6 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
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 pTraits<vector>::zero ... 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
__________________
|
|
February 9, 2014, 17:00 |
|
#7 |
Senior Member
Join Date: Jan 2013
Posts: 372
Rep Power: 14 |
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! |
|
February 9, 2014, 17:48 |
|
#8 |
Senior Member
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,903
Rep Power: 37 |
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, :ne, 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 < GeometricField <typename outerProduct<vector, Type>::type, fvPatchField, volMesh> > grad ( const GeometricField<Type, fvPatchField, volMesh>& ) const = 0; Code:
./primitives/VectorSpace/products.H 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; }; Kind regards, Niels
__________________
Please note that I do not use the Friend-feature, so do not be offended, if I do not accept a request. |
|
August 17, 2015, 16:09 |
|
#9 | |
Senior Member
Join Date: Jan 2013
Posts: 372
Rep Power: 14 |
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_; patchField = (1 - alpha_)*patchField + alpha_* ( referenceField_ + rmsCorr*cmptMultiply ( randomField - 0.5*pTraits<Type>::one, fluctuationScale_ )*mag(referenceField_) ); Thank you so much. OFFO Quote:
Last edited by wyldckat; August 18, 2015 at 13:03. Reason: Added [CODE][/CODE] markers |
||
August 18, 2015, 13:05 |
|
#10 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
Quick answer: If the template implementation defined for "Type" is "vector", then yes, it should be the vector "(1 1 1)".
Last edited by wyldckat; August 18, 2015 at 14:56. Reason: typo |
|
August 18, 2015, 13:26 |
|
#11 |
Senior Member
Join Date: Jan 2013
Posts: 372
Rep Power: 14 |
||
December 15, 2016, 10:23 |
|
#12 |
Member
Emad Tandis
Join Date: Sep 2010
Posts: 77
Rep Power: 16 |
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; }; |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Simple Question Regarding Symmetry Planes | Atella | CFX | 3 | April 11, 2010 07:44 |
Simple Question Regarding Symmetry Planes | Atella | Main CFD Forum | 0 | April 9, 2010 11:58 |
Question of Anil Date's SIMPLE method | universez | Main CFD Forum | 0 | November 18, 2009 21:12 |
1D thermal stress problem simple barrodbeam | newsboost | OpenFOAM Running, Solving & CFD | 3 | January 2, 2009 16:12 |
A Simple Question | Thomas P. Abraham | Main CFD Forum | 3 | September 6, 1999 19:19 |