CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Programming & Development (
-   -   U_.mesh() and mesh. (

sharonyue September 3, 2013 23:28

U_.mesh() and mesh.
Hi guys,


            found("phases") ? word("alpha" + phase1Name_) : alpha1Name,
        U_.mesh()// mesh

In this piece of code, can I turn it into"mesh"? Whats the dfference between U_.mesh() and mesh?
Thanks in advance.

Lieven September 4, 2013 06:43

Hi Sharonyue,

From the looks of it, this seems like a part of a constructor of a class. So if there is a mesh-object passed as argument with the constructor, then you can change U_.mesh() by mesh. But there probably isn't. Just ask yourself the question, why would you pass both U and mesh as arguments, when U already has a reference to the same mesh object...



Bernhard September 4, 2013 09:34

Where is your code snippet from? Is it a default OpenFOAM piece?

Anyhow, I would guess you are just passing around pointers here, so constructing this field one way or the other does not really make a difference.

jhoepken September 10, 2013 03:24

As Lieven stated, this is part of the initialization list of a constructor. Apparently the mesh itself is not registered in this class and not passed as a parameter, either. The volVectorField U_ is of generic type GeometricField<...> and stores a reference to the mesh as a private class attribute. It can be accessed by the public mesh() member function of GeometricField<...>.

In this class itself, it is very unlikely that you can substitute U_.mesh() with mesh. Why would you like to do this?

All times are GMT -4. The time now is 01:17.