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

Error generating mesh #289

Open
PavelBlend opened this issue Apr 3, 2020 · 7 comments
Open

Error generating mesh #289

PavelBlend opened this issue Apr 3, 2020 · 7 comments
Assignees
Labels

Comments

@PavelBlend
Copy link
Contributor

It seems to me that the polygon mesh generator does not work correctly at some points.
The mesh is not Manifold.
01
test_apic_method.zip

@doyubkim
Copy link
Owner

doyubkim commented Apr 4, 2020

Looks like a marching cube problem for sure. Let me take a look.

@doyubkim doyubkim self-assigned this Apr 4, 2020
@doyubkim doyubkim added the bug label Apr 4, 2020
@utilForever
Copy link
Collaborator

I'll check this issue. Thanks. :)

@doyubkim doyubkim assigned utilForever and unassigned doyubkim Apr 6, 2020
@PavelBlend
Copy link
Contributor Author

I tested the simulator again and noticed one thing:
These invalid triangles are only created on the walls of the domain. I started to study the code in the file src\jet\marching_cubes.cpp to get a rough idea of the cause of the error. I saw that the mesh generator uses different algorithms for creating triangles for the walls of the domain and for the triangles within the domain. The error occurs in blocks of code that have comments:
Construct boundaries parallel to x-y plane
Construct boundaries parallel to y-z plane
Construct boundaries parallel to x-z plane

// Construct boundaries parallel to x-y plane

I hope this information will help you understand the cause of the error.

@doyubkim
Copy link
Owner

Thanks @PavelBlend ! So I guess what’s happening here is that boundary mesher is adding more triangles and the topology of it does not agree with the surface mesher. Maybe it’s direction-dependent; one side of the domain works fine but the opposite side might show this problem. @utilForever: one way to fix this is to make a simple repro case with two volumes close together and see how the lookup table is being referred for the particular case.

@PavelBlend
Copy link
Contributor Author

@doyubkim I created a small example:

from pyjet import *
import numpy as np


ANIM_NUM_FRAMES = 360
ANIM_FPS = 60
Logging.mute()
# Create APIC solver
resX = 50
solver = ApicSolver3(resolution=(resX, resX, resX), domainSizeX=1.0)
solver.useCompressedLinearSystem = True
# Setup emitter
sphere = Sphere3(center=(0.5, 0.5, 0.5), radius=0.15)
emitter = VolumeParticleEmitter3(implicitSurface=sphere, spacing=1.0 / (2 * resX), isOneShot=True)
solver.particleEmitter = emitter
# Convert to surface
grid_size = 1.0 / resX
grid = VertexCenteredScalarGrid3((resX, resX, resX), (grid_size, grid_size, grid_size))
# Make first frame
frame = Frame(0, 1.0 / ANIM_FPS)
for i in range(ANIM_NUM_FRAMES):
    print('Frame {:d}'.format(i))
    solver.update(frame)
    pos = np.array(solver.particleSystemData.positions, copy=False)
    converter = SphPointsToImplicit3(1.5 * grid_size, 0.5)
    converter.convert(pos.tolist(), grid)
    surface_mesh = marchingCubes(
        grid,
        (grid_size, grid_size, grid_size),
        (0, 0, 0),
        0.0,
        DIRECTION_ALL,
        DIRECTION_NONE
    )
    surface_mesh.writeObj('frame_{:06d}.obj'.format(i))
    frame.advance()

at frame 48 I get this mesh:
011111

Here is the obj file:
frame_000048.zip

I think this is due to the fact that two drops are in the same voxel:
01000

The mesh generator builds a polygon between the drops.

@utilForever
Copy link
Collaborator

@PavelBlend Thanks!

@doyubkim
Copy link
Owner

Yup, I think this is definitely a marching square issue where its lookup table is not consistent with the marching cube.

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

No branches or pull requests

3 participants