Simple stretch test #3019
Replies: 6 comments 33 replies
-
|
Hi @ateixeira0163, in your stretch test, can you test if there is a difference between Regarding the assembly of the stiffness/mass matrices, it is still a work in progress. Some works are available in pull request (sofa-framework/SofaPython3#262 and sofa-framework/SofaPython3#260).
|
Beta Was this translation helpful? Give feedback.
-
|
(edit)
and using the following cases:
everything works here.
beam.addObject('LinearMovementConstraint', indices='@box_end.indices',
keyTimes=[0, 100, 999],
movements=[0, 0, 0,
0, 0, .1,
0, 0, .1],
relativeMovements=True, showMovement=True)Let me know if this helps |
Beta Was this translation helpful? Give feedback.
-
|
We would need additional eyes on this topic. Instabilities (vibrations/oscillations) are noticed when a bar is stretched. Here are the current conclusions of the investigation:
@ateixeira0163 My only interpretation is that the time step is way to large regarding the mesh size (about A 🍺 for the problem solver ! @alxbilger @jnbrunet @ChristianDuriez @courtecuisse @StephaneCotin ! A basic scene to test (click to expand)(E = 1.25e6 ν = .45 ρ = 1160 dt = .1 gravity = 0 displacement = 0.001/step) : # Required import for python
import Sofa
import numpy as np
L = 0.35
D = 0.0083
e = 1e-5
def main():
import SofaRuntime
import Sofa.Gui
root = Sofa.Core.Node("root")
createScene(root)
Sofa.Simulation.init(root)
Sofa.Gui.GUIManager.Init("myscene", "qglviewer")
Sofa.Gui.GUIManager.createGUI(root, __file__)
Sofa.Gui.GUIManager.SetDimension(1080, 600)
Sofa.Gui.GUIManager.MainLoop(root)
Sofa.Gui.GUIManager.closeGUI()
def createScene(root):
root.gravity = [0, 0, 0]
root.dt = .1
# root.addObject('DefaultAnimationLoop')
root.addObject('FreeMotionAnimationLoop')
root.addObject('GenericConstraintSolver', maxIterations=1000, tolerance=1e-6)
root.addObject('DefaultVisualManagerLoop')
root.addObject('VisualStyle', displayFlags="showForceFields showBehaviorModels")
beam = root.addChild('beam')
beam.addObject('EulerImplicitSolver', solveConstraint=True)
# --- LinearSolvers --- #
# beam.addObject('CGLinearSolver', template="CompressedRowSparseMatrixMat3x3d", name='linear_solver_correction', iterations=1000, tolerance=1e-5, threshold=1e-5)
beam.addObject('SparseLDLSolver', name='linear_solver_correction', template="CompressedRowSparseMatrixMat3x3d")
# --- Rest --- #
beam.addObject('RegularGridTopology', name="beam_grid_topology", n=[5, 5, round(L / (D / 4))],
min=[-D / 2, -D / 2, 0], max=[D / 2, D / 2, L])
beam.addObject('HexahedronSetTopologyContainer', name='topology', src='@beam_grid_topology')
beam.addObject('HexahedronSetGeometryAlgorithms')
beam.addObject('MechanicalObject', template='Vec3d', name='mech_obj', src='@beam_grid_topology', showObject=True, showObjectScale=2)
beam.addObject('MeshMatrixMass', massDensity=1160, topology='@topology', geometryState='@mech_obj')
beam.addObject('HexahedronFEMForceField', name='ff', src='@topology', poissonRatio=.45,
youngModulus=1.25e6)
beam.addObject('BoxROI', name='box_fix', box=[-D, -D, -e, D, D, e], template='Vec3d', drawBoxes=True)
beam.addObject('FixedConstraint', indices='@box_fix.indices')
beam.addObject('BoxROI', name='box_end', box=[-D, -D, L - e, D, D, L + e], template='Vec3d')
beam.addObject('LinearMovementConstraint', indices='@box_end.indices',
keyTimes=[0, 100, 999],
movements=[0, 0, 0,
0, 0, .1,
0, 0, .1],
relativeMovements=True, showMovement=True)
beam.addObject('LinearSolverConstraintCorrection', solverName='linear_solver_correction')
return root
# Function used only if this script is called from a python environment
if __name__ == '__main__':
main() |
Beta Was this translation helpful? Give feedback.
-
|
|
Beta Was this translation helpful? Give feedback.
-
|
|
Beta Was this translation helpful? Give feedback.
-
|
|
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
-
Hi there! I was recently interested by the behavior of a simple stretch simulation using different solvers. Interestingly enough, I found some weird behaviors while using some solvers and I could not understand why. To exemplify, I used a scene described below:
So the idea being just a beam being stretched by a
LinearMovementConstraintwhile fixed on the other end using Hexahedron elements.But, the thing is, for example, using:
A. DefaultAnimationLoop + EulerImplicitSolver + CG + HexahedronFF + MeshMatrixMass = I get a plausible result as expected.
But if I change the linear solver for a direct solver like
SparseLDLSolverfor example, the beam starts to oscillate quite quickly and it only gets worse (img down below). I've tried others direct solversSparseLU,SparseCholeskybut with no success (always the same result) even when trying to reduce the tolerance. Even theShewchukPCGthat is also an iterative solver (but uses a direct solver to precondition) didn't manage to keep the beam from oscillating.I also did some tests with Caribou, but I sent the questions to Jean Nicolas.
After that, I tried to do the same tests but using
FreeMotionAnimationLoop(this is kinda important for my simulation goal at the end). The first result using the combo EulerImplicitSolver + CG + HexaFF + MeshMatrixMass result in the image below:Where it seems that the deformation is not "communicated" with the rest of the body. As I read, the
FreeMotionAnimationLoopneeds aConstraintCorrectionobject. For that I need to useLinearSolverConstraintCorrection(the other ones are too approximated for my end case). The problem with that being that the direct solvers doesn't solve correctly the problem but they work with the ConstraintCorrection and CG does not work withLinearSolverConstraintCorrection. I was trying to evaluate the condition number of the stiffness matrix but I only found the matrix by elements, is there a way to assemble and get all the stiffness/mass matrix of the system before calling the linear solver ?So I would like to know if there's any tests made for the stretching and any thoughts on this.
Thanks! (I hope it was not very confusing, because I, myself, am confused with these results)
Alexandre T
Beta Was this translation helpful? Give feedback.
All reactions