|
[Sponsors] |
December 8, 2013, 09:20 |
3D vector in OpenFOAM
|
#1 |
New Member
Join Date: Oct 2013
Posts: 19
Rep Power: 12 |
Hi,
I would like to put some value in a simple 3d vector. Do you know why this fragment of code does not work?(No matching function Error...) vector someVec; for (int i = 1; i < 11; ++i) someVec(i, 1, 1) = 0; Also do you know why i cannot #include some c++ standard library such as std::vector in openFoam? (by typing #include <vector> , i get some errors,,this is happened also when i want to include some other c++ std libraries like map... |
|
December 8, 2013, 09:55 |
|
#2 |
Senior Member
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 21 |
You would need
Code:
vector someVec(i,1,1); |
|
December 8, 2013, 10:06 |
|
#3 | |
New Member
Join Date: Oct 2013
Posts: 19
Rep Power: 12 |
Quote:
error: no match for call to ‘(Foam::vector {aka Foam::Vector<double>}) (int&, int, int)’ someVec(i, 1, 1) = 0; |
||
December 8, 2013, 12:27 |
3D vector in OpenFOAM
|
#4 |
New Member
Join Date: Oct 2013
Posts: 19
Rep Power: 12 |
I need to define a 3D vector in OpenFOAM.
First,i tried to use std c++ vector library but #include <vector> gave me errors. Second, i tried to use the foam vector,but It seems that the FOAM::vector does not act like as the std vector.For example in this fragment of code: vector someVec(2,5,1); Info << someVec.x() << " " << someVec.y() << endl ; 2 and 5 does not represent the index of the vector, but the value of the vector! (the output is : 2 5 ) If i use : vectorList vec; i get the error that vectorList did not declared in this scope.(i included the vectorList.H...) Also including some other standard c++ library ,specially containers, gives me some errors.Is it correct way to use just : #include <aStdLibrary> ? (it works for iostream or cmath but not for containers) Last edited by Daniel73; December 8, 2013 at 13:59. |
|
December 8, 2013, 16:40 |
|
#5 | |
New Member
Join Date: Oct 2013
Posts: 19
Rep Power: 12 |
Quote:
But I've got error that ‘vector’ is not a member of ‘std’. Do you know how can i use the standard library of c++ in OpenFOAM? |
||
December 8, 2013, 21:22 |
|
#6 |
Senior Member
Sandeep Menon
Join Date: Mar 2009
Location: Amherst, MA
Posts: 403
Rep Power: 25 |
Here's the magic words:
#include <vector> |
|
December 9, 2013, 04:56 |
|
#7 |
New Member
Join Date: Oct 2013
Posts: 19
Rep Power: 12 |
||
December 9, 2013, 16:42 |
|
#8 |
Senior Member
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37 |
Hi Daniel,
I am not used to program using std, but if you want a list of 3d vectors, you can do as follows: Code:
vectorField v(mySize); Code:
List<vectorField> listv(anotherSize); 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. |
|
December 10, 2013, 01:56 |
|
#9 |
Senior Member
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 21 |
This is your third topic about this issue. What is it that you are exactly trying to achieve? Are you sure you need std::vector? There is likely a better solution in the OpenFOAM framework.
Thus, isn't this a XY problem? ( http://mywiki.wooledge.org/XyProblem ) |
|
December 10, 2013, 06:11 |
|
#10 | |
New Member
Join Date: Oct 2013
Posts: 19
Rep Power: 12 |
Quote:
I want to use std::vector in OpenFOAM but nobody knows why it is not working.Somebody in a forum as an answer of the question of another person told that use std::vector.But for me it does not work even by including(vector.h). Therefore i asked him again but he did not know,so i asked it generally maybe somebody can help me with an alternative way which does similar for me. |
||
December 10, 2013, 07:01 |
|
#11 |
Senior Member
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37 |
Hi Danial,
What is it you want to accomplish, which requires the use of std::vector? 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. |
|
December 10, 2013, 07:06 |
|
#12 | |
New Member
Join Date: Oct 2013
Posts: 19
Rep Power: 12 |
Quote:
in std::vector i can use this way : vec(i,j,z)= some value ; Now, as you told, im trying to use the List of vectors to save those coordinates but im thinking how to access each element of the list(a set of coordinate) to assign some value to that. |
||
December 10, 2013, 07:25 |
|
#13 |
Senior Member
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37 |
The class
Code:
pointField 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. |
|
December 10, 2013, 12:44 |
|
#14 | |
New Member
Join Date: Oct 2013
Posts: 19
Rep Power: 12 |
Quote:
I've done it. Just a question, is it possible to visualize that pointFields in paraview ? |
||
December 10, 2013, 16:49 |
|
#15 | |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128 |
Greetings to all!
Clean up complete. Daniel73's related posts and respective answers have been merged into this thread, from the other two threads, namely:
Quote:
Best regards, Bruno
__________________
|
||
December 12, 2013, 14:32 |
|
#16 |
Senior Member
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,900
Rep Power: 37 |
Thanks Bruno, I did not know how to visualise the point until know.
Cheers, Niels
__________________
Please note that I do not use the Friend-feature, so do not be offended, if I do not accept a request. |
|
January 21, 2014, 10:09 |
|
#17 | |
New Member
Join Date: Oct 2013
Posts: 19
Rep Power: 12 |
Quote:
Thank you for your answer but i need to plot my pointField which was initialized in my code.this just has x and y value in that and i need to plot those coordinates in paraview. I dont have any volVoctorField to have my coordinates on that to use glyph.(my coordinates don't match exactly on the cell's coordinates) |
||
January 21, 2014, 15:28 |
|
#18 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128 |
Hi Daniel73,
Mmm... OK, if you can put the list of points and respective data into a CSV file, then you can:
Best regards, Bruno
__________________
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Issues with OpenFoam | sanjibdsharma | OpenFOAM | 0 | August 14, 2009 08:41 |
Problem installing OpenFOAM 1.5 installation on RHEL 4. | vwsj84 | OpenFOAM Installation | 4 | April 23, 2009 04:48 |
2009 OpenFOAM Summer School in Zagreb, Croatia | hjasak | OpenFOAM Announcements from Other Sources | 0 | March 27, 2009 12:08 |
64bitrhel5 OF installation instructions | mirko | OpenFOAM Installation | 2 | August 12, 2008 18:07 |
OpenFOAM Training and Workshop | Hrvoje Jasak | Main CFD Forum | 0 | October 7, 2005 07:14 |