![]() |
Hello.
I'd like to have an
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. |
I'm not sure it's clean and co
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. |
Close. Try:
const scalarFi
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 |
Ok.
Thank you very much.
B
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. |
p.dimensions() should do it.
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. |
pp.size() (dimensions mean di
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 |
Thanks Eugene, thanks Hrvoje.
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.. |
Hi
I am solving a flow ins
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 |
Oh, I forgot. This portion goe
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]); } } |
| All times are GMT -4. The time now is 05:21. |