CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   How can I get a cell's height? (https://www.cfd-online.com/Forums/openfoam-programming-development/126873-how-can-i-get-cells-height.html)

sharonyue November 27, 2013 20:09

How can I get a cell's height?
 
Hi guys,

mesh.C() returns a vector. But I want this vector's height, for example, mesh.C().z()???

Thanks very much.

lixx November 28, 2013 00:08

mesh.C() returns a vectorField. If you want to get a specific cell's z-component, you still have to get the index of that cell.

sharonyue November 28, 2013 01:44

Quote:

Originally Posted by lixx (Post 463835)
mesh.C() returns a vectorField. If you want to get a specific cell's z-component, you still have to get the index of that cell.

Hi,

But I get a volScalarFields by mech.C().component(2)? It compiles well...:confused:

Code:

volScalarField Gk
    (
        IOobject
        (
            "Gk",
            runTime.timeName(),
            mesh,
            IOobject::NO_READ,
            IOobject::AUTO_WRITE
        ),
        GkReference + slot*mesh.C().component(2)//GkReference is volScalarField. slot is  dimensionedScalar
    );


akidess November 28, 2013 04:06

Quote:

Originally Posted by sharonyue (Post 463843)
But I get a volScalarFields by mech.C().component(2)?

What did you expect?

sharonyue November 30, 2013 20:28

Quote:

Originally Posted by akidess (Post 463865)
What did you expect?

Some others say I should use forAll:)

wyldckat November 30, 2013 21:25

Greetings to all!

This is what I usually do when I need to find a piece of code in OpenFOAM, more specifically for this kind:
Code:

cd $FOAM_UTILITIES
find . -name "*.[HC]" | xargs grep -sl "mesh.C()"

And the very first hit is shown here: https://github.com/OpenFOAM/OpenFOAM...ineSwirl.C#L56

Best regards,
Bruno


All times are GMT -4. The time now is 00:34.