|
[Sponsors] |
February 1, 2006, 09:57 |
Hello.
I'd like to have an
|
#1 |
Member
Rosario Russo
Join Date: Mar 2009
Location: Trieste, Italy
Posts: 56
Rep Power: 17 |
Hello.
I'd like to have an utility which creates in output a selected field variable file for a given boundary of the domain. It cannot be that hard, I know. But I'm a novel c++ user, and it is not easy to find inside the code what you need... For example for pressure field p (volScalarField) on the boundary "patchlabel" I'm supposed to have all the data in p.boundaryField()[patchLabel], but which function do I have to use to read actually the field values? I hope in a good hint... Thank you so much. |
|
February 1, 2006, 12:52 |
I'm not sure it's clean and co
|
#2 |
Member
Rosario Russo
Join Date: Mar 2009
Location: Trieste, Italy
Posts: 56
Rep Power: 17 |
I'm not sure it's clean and correct:
scalarField pp = p.boundaryField()[patchLabel]; Then I can access the field values by pp[i]; Anyway thank you for any other comment. |
|
February 1, 2006, 13:31 |
Close. Try:
const scalarFi
|
#3 |
Senior Member
Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,907
Rep Power: 33 |
Close. Try:
const scalarField& pp = p.boundaryField()[patchLabel]; and pp[i] if you do NOT want to change the values. If you do want to change them, use: scalarField& pp = p.boundaryField()[patchLabel]; Please notice the extra "&" - in your code you've made a copy of the patch field, which is not a good idea. Enjoy, Hrv
__________________
Hrvoje Jasak Providing commercial FOAM/OpenFOAM and CFD Consulting: http://wikki.co.uk |
|
February 2, 2006, 06:08 |
Ok.
Thank you very much.
B
|
#4 |
Member
Rosario Russo
Join Date: Mar 2009
Location: Trieste, Italy
Posts: 56
Rep Power: 17 |
Ok.
Thank you very much. By the way, I hope not to well out of your kindness too much, how can I get the dimension of my scalar field, namely "the lenght" of pp? I need to read all pp[i] and I think I can use something like: for (int ic=0; ic<??; ic++) {...pp[ic]... } or in a more smart way forall (..??.. ic) {...pp[ic]...} But I don't know what to put in ??... Thanks again. |
|
February 2, 2006, 06:21 |
p.dimensions() should do it.
|
#5 |
Senior Member
Eugene de Villiers
Join Date: Mar 2009
Posts: 725
Rep Power: 21 |
p.dimensions() should do it.
or do you mean size? p.size() To loop through any list use the "forAll" macro: forAll(pp, counter) { pp[counter]=... } Very useful, very neat. |
|
February 2, 2006, 06:43 |
pp.size() (dimensions mean di
|
#6 |
Senior Member
Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,907
Rep Power: 33 |
pp.size() (dimensions mean dimension set [mass length time etc] which is for geometric fields and dimensioned types).
So: forAll (pp, ppI) { pp[ppI] = ...; } (thanks Eugene and sorry to butt in) which expands to (for label ppI = 0; ppI < pp.size(); ppI++) { etc } This is very basic stuff, I recommend some digging through the code and examples to help you with more programming. Hrv
__________________
Hrvoje Jasak Providing commercial FOAM/OpenFOAM and CFD Consulting: http://wikki.co.uk |
|
February 2, 2006, 07:23 |
Thanks Eugene, thanks Hrvoje.
|
#7 |
Member
Rosario Russo
Join Date: Mar 2009
Location: Trieste, Italy
Posts: 56
Rep Power: 17 |
Thanks Eugene, thanks Hrvoje.
My problem is just to find out where and in which way the basic operations are placed in the code.. I'm using Doxygen documentation but I often have problems to identify the member function I need. In this example I tried also to access the source code of some macros such as "sum" or "forAll" which could help me to understand, I think. But I didn't manage to find them. Do you think there are some examples or some parts of the code to have a look at in order to catch a little deeper the structure of OpenFoam programming? It would be very useful to me.. |
|
July 7, 2006, 19:40 |
Hi
I am solving a flow ins
|
#8 |
New Member
Jeff Allen
Join Date: Mar 2009
Posts: 11
Rep Power: 17 |
Hi
I am solving a flow inside a domain consisting of a rectangular box. I would like to know how to determine the length width and height of this domain in a piece of code. Thanks Jeff |
|
July 7, 2006, 20:02 |
Oh, I forgot. This portion goe
|
#9 |
Senior Member
Srinath Madhavan (a.k.a pUl|)
Join Date: Mar 2009
Location: Edmonton, AB, Canada
Posts: 703
Rep Power: 21 |
Oh, I forgot. This portion[1] goes between these lines:
const fvPatchList& patches = mesh.boundary(); forAll(patches, patchI) [1]: forAll(U.boundaryField(), patchI) { if (U.boundaryField()[patchI].fixesValue()) { Uav += average(U.boundaryField()[patchI]); } } |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Boundary Condition definition for Tensorial Fields and viscoelastic flow simulation | titio | OpenFOAM Running, Solving & CFD | 1 | February 4, 2009 10:14 |
Gamma field on boundary patch | tom | OpenFOAM Post-Processing | 0 | March 23, 2008 07:56 |
[Commercial meshers] Only one boundary patch after gambitToFoam conversion | bewuethr | OpenFOAM Meshing & Mesh Conversion | 3 | August 22, 2007 11:30 |
How can we use the point patch fields given in OpenFOAM141srcfvMotionSolverpointPatchFieldsderived | jaswi | OpenFOAM Running, Solving & CFD | 0 | August 17, 2007 15:19 |
Fields as Boundary conditions? | Martin | CFX | 1 | October 15, 2003 20:02 |