CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Post-Processing (http://www.cfd-online.com/Forums/openfoam-post-processing/)
-   -   Boundary patch fields (http://www.cfd-online.com/Forums/openfoam-post-processing/61456-boundary-patch-fields.html)

ariorus February 1, 2006 09:57

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.

ariorus February 1, 2006 12:52

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.

hjasak February 1, 2006 13:31

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

ariorus February 2, 2006 06:08

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.

eugene February 2, 2006 06:21

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.

hjasak February 2, 2006 06:43

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

ariorus February 2, 2006 07:23

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..

jballen July 7, 2006 18:40

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

msrinath80 July 7, 2006 19:02

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 18:34.