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

How to create a simulation grid with custom obstacles? #185

Open
sambaPython24 opened this issue Jan 27, 2025 · 3 comments
Open

How to create a simulation grid with custom obstacles? #185

sambaPython24 opened this issue Jan 27, 2025 · 3 comments

Comments

@sambaPython24
Copy link

Hey, thank you for your work and for your support on github!

In your examples pages, you show a nice example of how to create grids with custom obstacles, that are
created as boolean operations of boxes or how to load
a gmsh file as a grid.

Is there a more direct way of how to load a mesh for example by e.g. :

  • Giving e.g. a boolean voxel mask of where an object is (e.g. True) or is not (False) or
  • Loading a mesh consisting of e.g. vertices and faces (like for .obj files) without having to save it as a .msh file.

and - because I see only 2D Simulation examples in your code -

is that also possible for 3D Simulations?

@holl-
Copy link
Collaborator

holl- commented Jan 27, 2025

Hi @sambaPython24 Yes, 3D is also supported.
For obstacles on a regular grid, you can pass them directly to make_incompressible(). Here is an example. Of course, you can also union them!

@sambaPython24
Copy link
Author

sambaPython24 commented Jan 28, 2025

Thank you @holl- for your quick answer and indeed I see the line
``fluid.make_incompressible(v, obstacle, Solve(x0=p))``` and that you have been creating obstacles using the predefined Cuboid and Spheres. In another tutorial, one could also upload gmsh file.

I assume, that you convert the Cuboid and Spheres to a part of a voxel grid at some point anyways, hence my question is wether I could just skip this step and provide this voxel grid directly (either as the simulation grid or just a binary grid with the location of the "blocked" voxel).

I have been trying to somehow change the objects

phiml.math._tensors.Dense
phi.geom._grid.UniformGrid
phi.geom._box.Cuboid
phi.field._field.Field

but it appears to be impossible to get or even change the underlying values in any way.

@holl-
Copy link
Collaborator

holl- commented Feb 1, 2025

The reason you provide a Geometry or Obstacle object instead of a voxel grid is that the distance to the obstacle surface is also used in the computation.
If you only have a voxel grid, you can look at the experimental class phi.geom._voxels.Voxels, but this may not work for your use case.

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