CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Running, Solving & CFD (
-   -   Gradients on surfaces or how to find neighbour faces for face on a patch (

tehache May 7, 2007 10:09

Hi there, For a face on a p
Hi there,

For a face on a patch, I need variable values on the neighbouring faces (I want to compute a gradient on the surface).
I have spent quite some time now on it, but the only way I could figure out was to get the corresponding internal cell, cycle through its faces, get the neighbour cells for these faces, check their faces if they are external - in short, horribly messy and prone to errors.
Is there perhaps any hidden functionality which could give me that in an easier way?

Thank you!


olesen May 7, 2007 10:19

It sounds like you really wish
It sounds like you really wish to be iterating over the boundary patches.

The quick-start would be to look at
and see if they do something similar to what you need.

tehache May 7, 2007 11:18

Thank you - but there is some
Thank you - but there is some misunderstanding:

@Marc: its not just iterating - for each face (I can iterate through faces) I would like to know the faces sharing edges with this face on the surface - which reminds me right now that somewhere I have seen a function called edgesFaces .... have to search again ...

snGrad gives me the gradient normal to surface, I need the tangential one ...

I have also tried to figure out the finiteArea stuff - there is some code to compute gradients on areaMeshes - here I am stuck with that I do not know (Yet?) how to construct a faMesh. Found a constructor taking a polyMesh - but is that only my surface mesh? If so, how to make a polyMesh from my boundaryMesh?
Questions, questions, questions ....

I think you can really get lost in OpenFOAM - a lifetime occupation

ztukovic May 7, 2007 13:56

Tangential gradient can be cal
Tangential gradient can be calculated using finite are calculus. See the attached application and case.

Zeljko Tukovic

tehache May 8, 2007 02:30

Zeljko, sounds great! But t
Zeljko, sounds great!

But the links dont work, there is just an image

tehache May 8, 2007 02:44

sorry, just saw your mail.
sorry, just saw your mail.

Works out of the box, sweet!

Thank you a lot!


normunds May 8, 2007 04:32

Hello! May I also have the

May I also have the same example? The link in post above seems to be broken. Thank you a lot!


tehache May 8, 2007 07:33

Hi Normunds, I suppose its
Hi Normunds,

I suppose its o.k. if I post it here again, since Zeljko tried to do that already.
So here is what he tried to post and then sent me by mail:

normunds May 8, 2007 08:02

I got it. Thank you very much
I got it. Thank you very much both, Zeljko and Thomas, with it I will save a lot of my time!

Have a nice day!


tehache May 9, 2007 03:22

Zeljko, I just found out I

I just found out I apparently need the utility makeFaMesh to generate the surface mesh, however, I cant find it.
Do you have a hint perhaps?

Thanks again!


ztukovic May 9, 2007 03:34



tehache May 9, 2007 03:51

its in tutorials/finiteAreaFoam/surfactantsTransport/makeFaMesh

(at least in my OpenFOAM-1.3..)
but thanks!

tehache May 9, 2007 04:19

to whom it may concern: the
to whom it may concern:

the above mentioned makeFaMesh fails

I then downloaded from OpenFOAM-1.3.General_01_05_07.tgz, made a backup copy of my original finiteArea subdirectory, copied the one from the downloaded distribution there, built again, built makeFaMesh again, and voila - got the finite area mesh.

tehache May 9, 2007 05:07

Zeljko, Is there perhaps an

Is there perhaps an elegant way to transfer data from areaField (on surface mesh from a patch) to corresponding patchField (on patch from volume mesh) ?
Currently I am trying to iterate over them and to assign values, but have the strong feeling this is not OpenFOAM-Style

ztukovic May 9, 2007 05:42

May I see how you performe the
May I see how you performe the transfer?


ztukovic May 9, 2007 06:36

You can do all that using the
You can do all that using the following line:

TSurf.internalField() = T.boundaryField()[pathcID];


patchID = mesh.boundaryMesh().findPatchID("top");

If your area mesh consists of only one patch, face ordering in the area mesh is the same as in the patch.


eugene May 9, 2007 07:18

Hi Zeljko, Do you plan on p
Hi Zeljko,

Do you plan on porting the finite Area code to 1.4?
Are parallel edge communications working yet?


tehache May 9, 2007 07:35

alas ..... that changes everyt
alas ..... that changes everything ....
does it mean that code wont work in parallel?

ztukovic May 9, 2007 08:53

Yes, parallel edge communicati
Yes, parallel edge communications don't work yet. I plane to do that till the end of this year.

andrea June 22, 2009 09:15

finiteArea compiling error
hi everybody,
I would like to try the finiteArea method for a film simulation, I'm working with the 1.5 release and I downloaded the 1.5-dev in order to get the finite area stuff. But when I compile the lduSolver that I think it's needed for finiteArea I get this error:

In file included from lduPrecon/CholeskyPrecon/CholeskyPrecon.C:36:
lduPrecon/CholeskyPrecon/CholeskyPrecon.H:56: error: expected class-name before { token

and this is the code line:

class CholeskyPrecon
public lduPreconditioner
// Private Data

Have you any hint?
I've tried also with folders of version 1.4-dev and 1.4.1-dev, with same results.

Thanks you in advance

All times are GMT -4. The time now is 09:08.