Skip to content
Snippets Groups Projects
Commit 00ee4e9f authored by Jean-Matthieu Etancelin's avatar Jean-Matthieu Etancelin
Browse files

Fix analytic operator requirements. Separate old GL-rendering problem form default problem

parent 095bff6d
No related branches found
No related tags found
No related merge requests found
...@@ -80,7 +80,7 @@ class Analytic(Operator): ...@@ -80,7 +80,7 @@ class Analytic(Operator):
"Missing simulation value for computation." "Missing simulation value for computation."
# Calling for requirements completion # Calling for requirements completion
for red in self._requirement: for red in self.requirements:
red.wait() red.wait()
for v in self.variables: for v in self.variables:
......
...@@ -21,9 +21,6 @@ class Problem(object): ...@@ -21,9 +21,6 @@ class Problem(object):
To solve the problem, a loop over time-steps is launched. A step consists 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 in calling the apply method of each operators and monitors.\n
To finish, a finalize method is called.\ 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 @debug
...@@ -124,13 +121,6 @@ class Problem(object): ...@@ -124,13 +121,6 @@ class Problem(object):
if __VERBOSE__ and main_rank == 0: if __VERBOSE__ and main_rank == 0:
print "====" print "===="
for op in self.operators:
try:
if op.isGLRender:
self.glRenderer = op
op.setMainLoop(self)
except AttributeError:
pass
def pre_setUp(self): def pre_setUp(self):
""" """
...@@ -186,24 +176,19 @@ class Problem(object): ...@@ -186,24 +176,19 @@ class Problem(object):
""" """
if main_rank == 0: if main_rank == 0:
print "\n\n Start solving ..." print "\n\n Start solving ..."
try: while not self.simulation.isOver:
## Pass the main loop to the OpenGL viewer self.simulation.printState()
if not self.glRenderer is None:
self.glRenderer.startMainLoop() for op in self.operators:
except AttributeError: if __VERBOSE__:
while not self.simulation.isOver: print main_rank, op.__class__.__name__
self.simulation.printState() op.apply(self.simulation)
for op in self.operators: testdump = \
if __VERBOSE__: self.simulation.currentIteration % self.dumpFreq is 0
print main_rank, op.__class__.__name__ self.simulation.advance()
op.apply(self.simulation) if self._doDump and testdump:
self.dump()
testdump = \
self.simulation.currentIteration % self.dumpFreq is 0
self.simulation.advance()
if self._doDump and testdump:
self.dump()
@debug @debug
def finalize(self): def finalize(self):
......
"""
@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()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment