fluidfoam icon indicating copy to clipboard operation
fluidfoam copied to clipboard

Retrieval of mesh geometry for a group and face data

Open omaralvarez opened this issue 1 year ago • 2 comments

I am trying to retrieve the geometry for a dynamic hybrid mesh (with hexahedral and tetrahedral cells), so I have a mix of structured and unstructured mesh. I have a 2D case, so nz is 1. I'm wondering what is the proper way to obtain the mesh geometry for a certain group and timestep. Right now I am using:

mesh = np.array(readmesh(args.path, t_name, boundary="Wall_faces_group", verbose=True)[:2])

This I believe yields a set of mesh vertices, for the correct group, but just wanted to make sure that this is the proper way.

What I have not been able to figure out is how to get the face data so I can reconstruct the mesh surface and normals. Any suggestions on how to do this?

Thanks in advance, the library is awesome!

omaralvarez avatar Apr 04 '24 08:04 omaralvarez

Hello,

First of all, thank you for your interest in this package. It's a great pleasure for us to know that it's being used by the community. Your usage of readmesh will give you an array containing the position of the patch's faces (position in the barycenter sense, and patch being "Wall_faces_group").

Then, if you want to know the field associated with each face, simply use readfield in the same way as readmesh, something like : velocity = readfield(args.path, t_name, "U", boundary="Wall_faces_group", verbose=True)

But beware, it will give you the "U" values for each face if these values are indeed available in the "U" file (i.e. if they are present in the corresponding boundaryfield zone in the file). Otherwise, it will give you the value of the nearest cell for each face.

Enjoy !

CyrilleBonamy avatar Apr 04 '24 15:04 CyrilleBonamy

Thanks for the answer, not sure if I expressed the question correctly.

I am trying to obtain vertices and faces for normal estimation and mesh visualization for the Wall_faces_group.

For U and p I am using:

    cx = readscalar(args.path, args.timestep, "Cx")
    print_info("Cx:", cx)
    cy = readscalar(args.path, args.timestep, "Cy")
    print_info("Cy:", cy)
    cz = readscalar(args.path, args.timestep, "Cz")
    print_info("Cz:", cz)
    vel = readvector(args.path, args.timestep, "U")
    print_info("U:", vel)
    p = readscalar(args.path, args.timestep, "p")

To read the cell centers and their corresponding force values.

Please let me know if my code is correct, as you can tell I am not an OpenFOAM expert. Thanks for the help!

omaralvarez avatar Apr 05 '24 08:04 omaralvarez

I'm not used to using groups. So I'm not sure if the boundary option would work with groups.

In your last answer, you read mesh and fields everywhere. The arrays size is therefore equal to the number of cells in the entire mesh (and not just the group).

CyrilleBonamy avatar Apr 12 '24 06:04 CyrilleBonamy

Yes, you are right. In terms of pressure and velocity, I am not only interested in the group data, I need everything.

I finally had to use OpenFoamFile to read manually the data, since none of the functions allowed me to access the face data directly and I needed it to reconstruct the surface.

If you know of other ways, please let me know, right now I feel this is not the best way.

omaralvarez avatar Apr 12 '24 09:04 omaralvarez

Perhaps you could propose an extension to fluidfoam, to add this functionality?

CyrilleBonamy avatar Apr 12 '24 09:04 CyrilleBonamy

I can certainly do that, but right now I am in the middle of a big project. When I have time I will create a pull request.

omaralvarez avatar Apr 19 '24 11:04 omaralvarez

Great! It will be a pleasure to merge your request sweater.

CyrilleBonamy avatar May 21 '24 22:05 CyrilleBonamy