SPlisHSPlasH icon indicating copy to clipboard operation
SPlisHSPlasH copied to clipboard

SIGSEGV, Segmentation fault in CubicLagrangeDiscreteGrid::determineShapeFunctions

Open TrevorSundberg opened this issue 10 months ago • 1 comments

When I attempt to run a simulation file that I created I receive a SEGFAULT. If I increase the particle size to 0.05 the crash no longer occurs.

{
	"Configuration": 
	{
		"particleRadius": 0.020,
		"numberOfStepsPerRenderUpdate": 1,
		"density0": 1.225,
		"simulationMethod": 4,
		"gravitation": [0,-9.81,0], 
		"cflMethod": 0, 
		"cflFactor": 1,
		"timeStepSize": 0.0001,
		"cflMinTimeStepSize": 0.0001,
		"cflMaxTimeStepSize": 0.0001,
		"minIterations": 1e0,
		"maxIterations": 1e0,
		"maxError": 0,
		"minIterationsV": 1e0,
		"maxIterationsV": 1e0,
		"maxErrorV": 0,		
		"stiffness": 100000,
		"exponent": 20,
		"velocityUpdateMethod": 0,
		"enableDivergenceSolver": true,
		"particleAttributes": "velocity",
		"boundaryHandlingMethod": 1
	},
	"Simulation": 
	{
		"timeStepSize": 0.004101,
		"subSteps": 1e0,
		"maxIterations": 1e0,
		"maxIterationsV" : 1e0,
		"velocityUpdateMethod" : 0,
		"contactTolerance": 0.01,
		"tetModelSimulationMethod": 2,
		"triangleModelSimulationMethod": 2,
		"triangleModelBendingMethod": 2,
		"contactStiffnessRigidBody" : 1.0,
		"contactStiffnessParticleRigidBody": 1000.0,
		"cloth_stiffness": 1.0,
		"cloth_bendingStiffness": 0.005,
		"cloth_xxStiffness": 1.0,
		"cloth_yyStiffness": 1.0,
		"cloth_xyStiffness": 1.0,
		"cloth_xyPoissonRatio": 0.3,
		"cloth_yxPoissonRatio": 0.3,
		"cloth_normalizeStretch": 0,
		"cloth_normalizeShear": 0, 
		"solid_stiffness": 1.0,
		"solid_poissonRatio": 0.2,
		"solid_normalizeStretch": 0,
		"solid_normalizeShear": 0,
		"gravity": [0,-9.81,0],
		"gravitation": [0,-9.81,0]
	},
	"Materials": [
		{
			"id": "Fluid",
			"density0": 1.225,
			"colorMapType": 1,
			"surfaceTension": 0,
			"surfaceTensionMethod": 0,
			"viscosity": 0,
			"viscosityOmega": 0,
			"viscosityMethod": 1,
			"vorticityMethod": 1, 
			"vorticity": 0.1
		}
	],
	"RigidBodies": [
		{
			"id": 0,
			"geometryFile": "../models/UnitBox.obj",
			"translation": [0,0,0],
			"rotationAxis": [1, 0, 0],
			"rotationAngle": 0,
			"scale": [2, 6, 2],
			"color": [0.1, 0.4, 0.6, 1.0], 
			"isDynamic": false,
			"isWall": true,
			"mapInvert": true, 
			"mapThickness": 0.0,
			"mapResolution": [25,25,25]
		},
		{
			"id": 1,
			"geometryFile": "../models/propeller.obj",
			"translation": [0,0,0],
			"rotationAxis": [1, 0, 0],
			"rotationAngle": 0,
			"scale": [6,6,6],
			"color": [0.1, 0.4, 0.6, 1.0], 
			"density": 600,
			"isDynamic": true,
			"isWall": false,
			"mapInvert": false, 
			"mapThickness": 0.01,
			"mapResolution": [200,200,200]
		}
	],
	"TargetVelocityMotorHingeJoints": [
		{
			"bodyID1": 1,
			"bodyID2": 0,
			"position": [0,0,0],
      "axis": [0,1,0],
      "target": -250
		}
	],
	"FluidBlocks": [
		{
			"denseMode": 2,
			"start": [-0.999, -0.999, -0.999],
			"end": [0.999, 0.999, 0.999],
			"translation": [0.0, 0, 0.0],
			"scale": [1,3,1]
		}
	]	
}

Had to attach the propeller .obj file as a text file otherwise it wouldn't let me propeller.obj.txt

Built from commit e773d3e26655b32ab67a9ac7c48f6f2bf22f9429. I ran it through gdb and got this trace:

Thread 16 "SPHSimulator" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffeaa00640 (LWP 3194683)]
0x0000555555952fcc in Discregrid::CubicLagrangeDiscreteGrid::determineShapeFunctions(unsigned int, Eigen::Matrix<double, 3, 1, 0, 3, 1> const&, std::array<unsigned int, 32ul>&, Eigen::Matrix<double, 3, 1, 0, 3, 1>&, Eigen::Matrix<double, 32, 1, 0, 32, 1>&, Eigen::Matrix<double, 32, 3, 0, 32, 3>*) const ()
(gdb) bt
#0  0x0000555555952fcc in Discregrid::CubicLagrangeDiscreteGrid::determineShapeFunctions(unsigned int, Eigen::Matrix<double, 3, 1, 0, 3, 1> const&, std::array<unsigned int, 32ul>&, Eigen::Matrix<double, 3, 1, 0, 3, 1>&, Eigen::Matrix<double, 32, 1, 0, 32, 1>&, Eigen::Matrix<double, 32, 3, 0, 32, 3>*) const ()
#1  0x00005555557faf45 in SPH::TimeStep::computeDensityAndGradient(unsigned int, unsigned int, Eigen::Matrix<float, 3, 1, 2, 3, 1> const&) ()
#2  0x00005555557fb360 in SPH::TimeStep::computeDensityAndGradient() [clone ._omp_fn.0] ()
#3  0x00007ffff7c96c0e in ?? () from /lib/x86_64-linux-gnu/libgomp.so.1
#4  0x00007ffff7694ac3 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
#5  0x00007ffff7726850 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81

TrevorSundberg avatar Apr 12 '25 20:04 TrevorSundberg

I cannot reproduce this error. For me the scene works without segfault. However, your mesh is not closed which might lead to a wrong signed distance field. Moreover, I would recommend to use either volume maps or a particle-based boundary handling.

janbender avatar Apr 29 '25 12:04 janbender