diff --git a/HySoP/hysop/operator/analytic.py b/HySoP/hysop/operator/analytic.py index 586cbb8236afcae9257ac277b5cdb0e7d90606fd..0fbeba9ea656efb13bf6bfed7e364e1c10984a64 100644 --- a/HySoP/hysop/operator/analytic.py +++ b/HySoP/hysop/operator/analytic.py @@ -80,7 +80,7 @@ class Analytic(Operator): "Missing simulation value for computation." # Calling for requirements completion - for red in self._requirement: + for red in self.requirements: red.wait() for v in self.variables: diff --git a/HySoP/hysop/problem/problem.py b/HySoP/hysop/problem/problem.py index bf48da5445c93fb0efb2f57b3c93f2d669902c59..680c912c3f3ab29f6803aafbdefb05c2defe698c 100644 --- a/HySoP/hysop/problem/problem.py +++ b/HySoP/hysop/problem/problem.py @@ -21,9 +21,6 @@ class Problem(object): To solve the problem, a loop over time-steps is launched. A step consists in calling the apply method of each operators and monitors.\n To finish, a finalize method is called.\ - - \remark: In case of GPU real-time rendering (i.e. use of an - OpenGLRendering object), The loop over time-steps is passed to Qt4 """ @debug @@ -124,13 +121,6 @@ class Problem(object): if __VERBOSE__ and main_rank == 0: print "====" - for op in self.operators: - try: - if op.isGLRender: - self.glRenderer = op - op.setMainLoop(self) - except AttributeError: - pass def pre_setUp(self): """ @@ -186,24 +176,19 @@ class Problem(object): """ if main_rank == 0: print "\n\n Start solving ..." - try: - ## Pass the main loop to the OpenGL viewer - if not self.glRenderer is None: - self.glRenderer.startMainLoop() - except AttributeError: - while not self.simulation.isOver: - self.simulation.printState() - - for op in self.operators: - if __VERBOSE__: - print main_rank, op.__class__.__name__ - op.apply(self.simulation) - - testdump = \ - self.simulation.currentIteration % self.dumpFreq is 0 - self.simulation.advance() - if self._doDump and testdump: - self.dump() + while not self.simulation.isOver: + self.simulation.printState() + + for op in self.operators: + if __VERBOSE__: + print main_rank, op.__class__.__name__ + op.apply(self.simulation) + + testdump = \ + self.simulation.currentIteration % self.dumpFreq is 0 + self.simulation.advance() + if self._doDump and testdump: + self.dump() @debug def finalize(self): diff --git a/HySoP/hysop/problem/problem_with_GLRendering.py b/HySoP/hysop/problem/problem_with_GLRendering.py new file mode 100644 index 0000000000000000000000000000000000000000..6a3bc633fca0b5cb96c29581a8d28cd1bd93984c --- /dev/null +++ b/HySoP/hysop/problem/problem_with_GLRendering.py @@ -0,0 +1,66 @@ +""" +@file problem_with_GLRendering.py + +Extends Problem description to handel real time rendering wit OpenGL. +""" +from parmepy.constants import debug +from parmepy.tools.timers import timed_function +from parmepy.mpi import main_rank +from parmepy.problem.problem import Problem + + +class ProblemGLRender(Problem): + """ + For the GPU real-time rendering (i.e. use of an + OpenGLRendering object), The loop over time-steps is passed to Qt4 + """ + + @debug + def __init__(self, operators, simulation, monitors=None, + dumpFreq=100, name=None): + """ + Create a transport problem instance. + + @param operators : list of operators. + @param simulation : a parmepy.simulation.Simulation object + to describe simulation parameters. + @param monitors : list of monitors. + @param name : an id for the problem + @param dumpFreq : frequency of dump (i.e. saving to a file) + for the problem; set dumpFreq = -1 for no dumps. Default = 100. + """ + Problem.__init__(self, operators, simulation, + monitors=monitors, + dumpFreq=dumpFreq, + name=name) + self.gl_renderer = None + + @debug + @timed_function + def setUp(self): + """ + Prepare operators (create topologies, allocate memories ...) + """ + Problem.setUp(self) + for ope in self.operators: + try: + if ope.isGLRender: + self.gl_renderer = ope + ope.setMainLoop(self) + except AttributeError: + pass + + @debug + @timed_function + def solve(self): + """ + Solve problem. + + Performs simulations iterations by calling each + operators of the list until timer ends.\n + At end of time step, call an io step.\n + Displays timings at simulation end. + """ + if main_rank == 0: + print "\n\n Start solving ..." + self.gl_renderer.startMainLoop()