CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Openfoam coding question

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 15, 2012, 20:25
Default Openfoam coding question
  #1
Member
 
Join Date: Jun 2012
Posts: 65
Rep Power: 13
conceptone is on a distinguished road
Hi everyone, I have two questions in openfoam's coding. One is that if one variable is stated as the vector, so can it be a vector container e.g.
vector p=(
(1 2 3)
(4 5 6)
(7 8 9)
)
or just only used like (1 2 3)?
;the second is that if I wanna define a variable distance = mag(the z component of position-the z component of position0), I write the code as distance= mag(position.z()-position0.z()), where position and position is the vector type, but the compiler reports error, how should I make it? The original code is distance = mag(position()-position0()).
Thanks
conceptone is offline   Reply With Quote

Old   August 16, 2012, 02:09
Default
  #2
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 21
Bernhard is on a distinguished road
Considering your first question.
No, a vector is a vector. It has three components. If you want to store multiple vectors in one variable, you should make a variable of type vectorList.

Your second question is vague. Post the code you have tried, and the error message you got, otherwise we can only guess.
Bernhard is offline   Reply With Quote

Old   August 16, 2012, 02:43
Default
  #3
Senior Member
 
Yogesh Bapat
Join Date: Oct 2010
Posts: 102
Rep Power: 15
ybapat is on a distinguished road
About your second question :

You are trying to calculate mag(position.z()-position0.z()).You need not take magnitude as you will directly get scalar when you take difference of only z-coordinates.
ybapat is offline   Reply With Quote

Old   August 16, 2012, 03:34
Default
  #4
Senior Member
 
Arne Stahlmann
Join Date: Nov 2009
Location: Hanover, Germany
Posts: 209
Rep Power: 17
Arnoldinho is on a distinguished road
One comment on your first question: I think it depends on which 'vector' you are talking about. If it is the standard OF vector, then it has three components only. But if you consider the c++ vector, then this can have more entries, as it is more like a hashSet. A construct like
Code:
std::vector<std::vector<std::pair<label, double> > > movePointsCorrelation;
e.g. contains entries in a pair of label and double values, stored in a vector (list), which are further stored in a vector (list). These vectors can then even have different sizes.

Greetings,
Arne
Arnoldinho is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
A general openfoam development question about boundary condition kaifu OpenFOAM 10 August 15, 2012 12:51
OpenFOAM 1.6.x, 1.7.0 and 1.7.x are not fully prepared to work with gcc-4.5.x wyldckat OpenFOAM Bugs 18 October 21, 2010 05:51
Cross-compiling OpenFOAM 1.7.0 on Linux for Windows 32 and 64bits with Mingw-w64 wyldckat OpenFOAM Announcements from Other Sources 3 September 8, 2010 06:25
[mesh manipulation] createPatch / cyclicGgi / OpenFoam 1.5-dev OFU OpenFOAM Meshing & Mesh Conversion 0 June 16, 2010 04:36
Questions for the bdivb function in OpenFOAM gkang OpenFOAM Running, Solving & CFD 3 May 13, 2006 11:11


All times are GMT -4. The time now is 09:27.