def onAnimateEndEvent(self, e): if self.use_sofa_profiler_timer: records = Timer.getRecords("Animate") else: records = Timer.getRecords("cg_timer") if "AnimateVisitor" in records: methods = [] for k, v in zip(records['AnimateVisitor'].keys(), records['AnimateVisitor'].values()): match = re.search('Mechanical \((.*)\)', k) if match is not None: methods.append({ 'name': match.group(1), 'newton_steps': extract_newton_steps(v) }) elif k == 'Mechanical': if isinstance(v, list): for i, v in zip(range(len(v)), v): methods.append({ 'name': 'method_'+str(i), 'newton_steps': extract_newton_steps(v) }) else: methods.append({ 'name': 'method', 'newton_steps': extract_newton_steps(v) }) pretty_print_methods(methods) if not self.use_sofa_profiler_timer: Timer.end("cg_timer")
def onAnimateEndEvent(self, e): print("Done") self.total_time += e['dt'] if self.use_sofa_profiler_timer: records = Timer.getRecords("Animate") else: records = Timer.getRecords("timer") if "AnimateVisitor" in records: methods = [] for k, v in zip(records['AnimateVisitor'].keys(), records['AnimateVisitor'].values()): match = re.search('Mechanical \((.*)\)', k) if match is not None: methods.append({ 'name': match.group(1), 'newton_steps': extract_newton_steps(v) }) elif k == 'Mechanical': if isinstance(v, list): for i, v in zip(range(len(v)), v): methods.append({ 'name': 'method_'+str(i), 'newton_steps': extract_newton_steps(v) }) else: methods.append({ 'name': 'method', 'newton_steps': extract_newton_steps(v) }) print("Here are the results. Copy and paste them in a text editor without word wrap to visualize them.") pretty_print_methods(methods) if not self.use_sofa_profiler_timer: Timer.end("timer")
def onAnimateBeginEvent(self, e): if len(Timer.getRecords('Animate')): self.use_sofa_profiler_timer = True else: Timer.setEnabled("timer", True) Timer.begin("timer") # Update motion if self.total_time < self.motion_time: with self.dummy_points.position.writeableArray() as wa: wa[:] += self.motion_delta
def onAnimateEndEvent(self, event): if self.use_sofa_profiler_timer: records = Timer.getRecords("Animate") else: records = Timer.getRecords("cg_timer") step_time = records['AnimateVisitor']['Mechanical (meca)']['total_time'] print(f"Step took {step_time:.2f} ms") nb_iterations = records['AnimateVisitor']['Mechanical (meca)']['StaticSolver::Solve']['nb_iterations'] for i in range(int(nb_iterations)): total_time = records['AnimateVisitor']['Mechanical (meca)']['StaticSolver::Solve']['NewtonStep'][i]['total_time'] CG_iterations = records['AnimateVisitor']['Mechanical (meca)']['StaticSolver::Solve']['NewtonStep'][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: Timer.end("cg_timer")
def onAnimateBeginEvent(self, e): if len(Timer.getRecords('Animate')): self.use_sofa_profiler_timer = True else: Timer.setEnabled("cg_timer", True) Timer.begin("cg_timer")