3D vector in OpenFOAM
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... |
You would need
Code:
vector someVec(i,1,1); |
Quote:
error: no match for call to ‘(Foam::vector {aka Foam::Vector<double>}) (int&, int, int)’ someVec(i, 1, 1) = 0; |
3D vector in OpenFOAM
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) |
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? |
Here's the magic words:
#include <vector> |
Quote:
maybe because there exist the vector.h header of the openFoam in InInclude folder and this code does not include the std library... |
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 |
Quote:
Thus, isn't this a XY problem? ( http://mywiki.wooledge.org/XyProblem ) |
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. |
Hi Danial,
What is it you want to accomplish, which requires the use of std::vector? Kind regards, Niels |
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. |
The class
Code:
pointField Kind regards Niels |
Quote:
I've done it. Just a question, is it possible to visualize that pointFields in paraview ? |
Greetings to all!
Quote:
Quote:
Best regards, Bruno |
Thanks Bruno, I did not know how to visualise the point until know.
Cheers, Niels |
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) |
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 |
All times are GMT -4. The time now is 05:55. |