Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retrieval of mesh geometry for a group and face data #57

Open
omaralvarez opened this issue Apr 4, 2024 · 7 comments
Open

Retrieval of mesh geometry for a group and face data #57

omaralvarez opened this issue Apr 4, 2024 · 7 comments

Comments

@omaralvarez
Copy link

omaralvarez commented Apr 4, 2024

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!

@CyrilleBonamy
Copy link
Collaborator

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 !

@omaralvarez
Copy link
Author

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!

@CyrilleBonamy
Copy link
Collaborator

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

@omaralvarez
Copy link
Author

omaralvarez commented Apr 12, 2024

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.

@CyrilleBonamy
Copy link
Collaborator

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

@omaralvarez
Copy link
Author

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.

@CyrilleBonamy
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants