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

getter/setter function for the velocity nodes in a simple Cartesian grid

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By Bernhard

Reply
 
LinkBack Thread Tools Display Modes
Old   December 6, 2013, 07:19
Default getter/setter function for the velocity nodes in a simple Cartesian grid
  #1
ooo
Member
 
Join Date: Feb 2012
Posts: 49
Rep Power: 5
ooo is on a distinguished road
I would like to set/get the velocity of the nodes of a simple Cartesian grid by a simple loop to be able to do some interpolation of them(and put the interpolated value into an user-defined vector!)
For example i would like to store/change the velocity by these kind of loops :

for (indices i = 1 ; i < ... ; ++i) {
u(indices of a particular node) = 0 ; //Setting value...
double a = u(indices of a particular node);} //Getting value...


I would appreciate if you tell me how can i find the index of nodes.
For example, this code(mesh.findCell(point(x, y, z)); ) gives the index of the nearest cell, but i need to have an overview of the index of all cells(e.g to be able to iterate through them with a for loop).
Also i don't know whether with the below code, can i SET the velocity of the index? or it is just a getter function? : U.mesh().C()[Index].x();
ooo is offline   Reply With Quote

Old   December 6, 2013, 08:45
Default
  #2
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 12
Bernhard is on a distinguished road
What do you exactly want?

Anyhow, you might be looking for the forAll loop that comes with OpenFOAM. Structure looks something like this

Code:
 forAll(U, cellI)
 { 
    U[cellI] = ...
 }
ooo likes this.
Bernhard is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
mesh airfoil NACA0012 anand_30 OpenFOAM Meshing & Mesh Conversion 12 December 12, 2011 05:16
ParaView for OF-1.6-ext Chrisi1984 OpenFOAM Installation 0 December 31, 2010 07:42
Velocity Under-relaxation in SIMPLE type methods Matt U. Main CFD Forum 6 July 4, 2005 05:29
Variables Definition in CFX Solver 5.6 R P CFX 2 October 26, 2004 02:13
Terrible Mistake In Fluid Dynamics History Abhi Main CFD Forum 12 July 8, 2002 09:11


All times are GMT -4. The time now is 12:40.