Problem with SimulationBase in python module
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.
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.
@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.