Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions examples/advanced_timer.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ def onAnimateEndEvent(self, event):
step_time = records['solve']['Mechanical (meca)']['total_time']
print(f"Step took {step_time:.2f} ms")

nb_iterations = records['solve']['Mechanical (meca)']['StaticSolver::Solve']['nb_iterations']
nb_iterations = records['solve']['Mechanical (meca)']['NewtonStep']['StaticSolver::Solve']['nb_iterations']
for i in range(int(nb_iterations)):
total_time = records['solve']['Mechanical (meca)']['StaticSolver::Solve']['NewtonStep'][i]['total_time']
CG_iterations = records['solve']['Mechanical (meca)']['StaticSolver::Solve']['NewtonStep'][i]['MBKSolve']['CG iterations']
total_time = records['solve']['Mechanical (meca)']['NewtonStep']['StaticSolver::Solve'][i]['total_time']
CG_iterations = records['solve']['Mechanical (meca)']['NewtonStep']['StaticSolver::Solve'][i]['MBKSolve']['CG iterations']
print(f" Newton iteration #{i} took {total_time:.2f} ms using {int(CG_iterations)} CG iterations")

if not self.use_sofa_profiler_timer:
if self.use_sofa_profiler_timer:
Timer.end("Animate")
else:
Timer.end("cg_timer")


Expand Down Expand Up @@ -70,7 +72,8 @@ def createScene(root):

# Create our mechanical node
root.addChild("meca")
root.meca.addObject("StaticSolver", newton_iterations=5, printLog=False)
root.meca.addObject("NewtonRaphsonSolver", name="newtonSolver_springs", maxNbIterationsNewton=5, maxNbIterationsLineSearch=1, warnWhenLineSearchFails=False, printLog=False)
root.meca.addObject("StaticSolver", newtonSolver="@newtonSolver_springs")
root.meca.addObject("CGLinearSolver", iterations=25, tolerance=1e-5, threshold=1e-5)

root.meca.addObject('MechanicalObject', name='mo', position='@../grid.position')
Expand Down
Loading