Git Product home page Git Product logo

Comments (3)

flothesof avatar flothesof commented on June 13, 2024 1

Hi @thoth291

I've tried to approach your problem from a simpler perspective: by making a simpler double-sphere inside a rectangular volume.
It has three "materials":

  • 0 for "the outside"
  • 1 for the inner ROI
  • 2 for the outer ROI

Here's the script:

import numpy as np
import pygalmesh

Nx = 72
Ny = 41
Nz = 28
h = [0.2] * 3

vol = np.zeros((Nx, Ny, Nz))
X, Y, Z = np.meshgrid(np.linspace(0, Nx * h[0], num=Nx),
                      np.linspace(0, Ny * h[1], num=Ny),
                      np.linspace(0, Nz * h[2], num=Nz), indexing='ij')

x0, y0, z0 = X.mean(), Y.mean(), Z.mean()

# let's define spherical ROIs
roi_outer = (X-x0)**2 + (Y - y0)**2 + (Z - z0)**2 < 2**2
roi_inner = (X-x0)**2 + (Y - y0)**2 + (Z - z0)**2 < 1

# ... and assign some values to them (in reverse order else it will overwrite the previous values)
vol[roi_outer] = 2
vol[roi_inner] = 1

# and let's make a mesh with it
mesh = pygalmesh.generate_from_array(vol.astype(np.uint8), h, facet_distance=0.2, cell_size=0.5)
mesh.write("spheres_in_square.vtk")

Here's the result, visualized with Paraview:
image

So the implicit convention is that the outer mesh geometry will correspond to class 0. We can test this understanding by initializing the volume with a different value (e.g. 3): vol = np.zeros((Nx, Ny, Nz)) + 3.

In that case, the result is:
image

I hope this helps you get started.

Cheers
Florian

from pygalmesh.

nschloe avatar nschloe commented on June 13, 2024

I'd just play around with the code in the readme.

from pygalmesh.

thoth291 avatar thoth291 commented on June 13, 2024

@nschloe , what I did is simply something like this (not real code):

vol = (vol==1).astype(np.uint8)

And it seems to be doing something, but since I don't know how my mesh should look like in the first place I'm still exploring and testing.

from pygalmesh.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.