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

Problem with SimulationBase in python module #330

Open
Tudor42 opened this issue Aug 24, 2024 · 2 comments
Open

Problem with SimulationBase in python module #330

Tudor42 opened this issue Aug 24, 2024 · 2 comments

Comments

@Tudor42
Copy link

Tudor42 commented Aug 24, 2024

Hi,

There may be some a problem with SimulationBase cleanup as the module breaks when a second SimulationBase is created with the same scene file.

import pysplishsplash as sph
for _ in range(2):
    base = sph.Exec.SimulatorBase()

    curr = os.path.dirname(os.path.abspath(__file__))

    base.init(useGui=True, sceneFile=curr+'/scene.json', outputDir=curr, useCache=False)

    gui = sph.GUI.Simulator_GUI_imgui(base)
    base.setGui(gui)
    base.initSimulation()
    base.runSimulation()
    base.cleanup()

The scene is loaded normally the second time but the fluid model disappears on start, and getPosition returns Nan.

Additionally, the logger created in the constructor is not removed when the SimulationBase is destroyed, which leads to duplicated lines in the output.

The custom exporter feature can lead to NPE on python side at gc or at SimulationBase destruction as both try to cleanup the exporter pointer.

@janbender
Copy link
Member

I tested your script using the DoubleDamBreak.json example. Both simulations ran without any problem. However, I also got the double output from the logger.

@Tudor42
Copy link
Author

Tudor42 commented Aug 26, 2024

@janbender, can you try this scene file? thanks

{
    "Configuration": {
        "sim2D": true,
        "particleRadius": 0.025,
        "colorMapType": 1,
        "simulationMethod": 4,
        "gravitation": [0,-9.81,0],
        "maxIterations": 100,
        "maxError": 0.1,
        "maxIterationsV": 100,
        "maxErrorV": 0.1,
        "boundaryHandlingMethod": 0
    },
    "RigidBodies": [
        {
            "geometryFile": "../models/UnitBox.obj",
            "translation": [0,2.0,0],
            "rotationAxis": [1,0,0],
            "rotationAngle": 0,
            "scale": [8,4,1],
            "color": [0.1,0.4,0.6,1.0],
            "isDynamic": false,
            "isWall": true,
            "mapInvert": true,
            "mapThickness": 0.0,
            "mapResolution": [30,30,20]
        }
    ],
    "FluidBlocks": [
        {
            "start": [-4.0,0.0,1],
            "end": [-2.5,1.5,1],
            "translation": [0.9608643433454694,0.5630674433145372,0.0],
            "scale": [1,1.3556061016376884,1]
        },
        {
            "start": [0.0,0.0,-1
            ],
            "end": [2.5,1.5,1],
            "translation": [1,0.025,0.0],
            "scale": [1,1.0417812759459015,1]
        }
    ]
}

I installed the module with python setup.py install_lib. Python version 3.10.

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