Example #1
0
    def solveStep(self, tstep, stageID=0, runInBackground=False):
        """
        Solves the problem for given time step.

        Proceeds the solution from actual state to given time.
        The actual state should not be updated at the end, as this method
        could be
        called multiple times for the same solution step until the global
        convergence
        is reached. When global convergence is reached, finishStep is called
        and then
        the actual state has to be updated.
        Solution can be split into individual stages identified by optional
        stageID parameter.
        In between the stages the additional data exchange can be performed.
        See also wait and isSolved services.

        :param TimeStep tstep: Solution step
        :param int stageID: optional argument identifying solution stage
         (default 0)
        :param bool runInBackground: optional argument, defualt False. If True,
        the solution will run in background (in separate thread or remotely).

        """
        if self.mieThread:
            if self.mieThread.is_alive():
                return

        # Check params and fields
        initConf.checkRequiredParameters(self.properties, PropertyID)

        # tstep is needed in _startmieProcess to get the Properties
        params = {'tstep': tstep}

        # Start thread to start Mie calculation
        self.mieThread = threading.Thread(target=self._startMieProcess,
                                          kwargs=params,
                                          group=None)
        self.mieThread.start()

        # Wait for process if applicaple
        if not runInBackground:
            self.mieThread.join()
Example #2
0
    def solveStep(self, tstep, stageID=0, runInBackground=False):
        """
        Solves the problem for given time step.

        Proceeds the solution from actual state to given time.
        The actual state should not be updated at the end, as this method
        could be
        called multiple times for the same solution step until the global
        convergence
        is reached. When global convergence is reached, finishStep is called
        and then
        the actual state has to be updated.
        Solution can be split into individual stages identified by optional
        stageID parameter.
        In between the stages the additional data exchange can be performed.
        See also wait and isSolved services.

        :param TimeStep tstep: Solution step
        :param int stageID: optional argument identifying solution stage
         (default 0)
        :param bool runInBackground: optional argument, defualt False. If True,
        the solution will run in background (in separate thread or remotely).

        """
        if self.mieThread:
            if self.mieThread.is_alive():
                return

        # Check params and fields
        initConf.checkRequiredParameters(self.properties, PropertyID)

        # tstep is needed in _startmieProcess to get the Properties
        params = {"tstep": tstep}

        # Start thread to start Mie calculation
        self.mieThread = threading.Thread(target=self._startMieProcess, kwargs=params, group=None)
        self.mieThread.start()

        # Wait for process if applicaple
        if not runInBackground:
            self.mieThread.join()
Example #3
0
    def solveStep(self, tstep, stageID=0, runInBackground=False):
        """
        Solves the problem for given time step.

        Proceeds the solution from actual state to given time.
        The actual state should not be updated at the end,
        as this method could be
        called multiple times for the same solution step
        until the global convergence
        is reached. When global convergence is reached,
        finishStep is called and then
        the actual state has to be updated.
        Solution can be split into individual stages
        identified by optional stageID parameter.
        In between the stages the additional data exchange can be performed.
        See also wait and isSolved services.

        :param TimeStep tstep: Solution step
        :param int stageID: optional argument identifying
               solution stage (default 0)
        :param bool runInBackground: optional argument, defualt False.
               If True, the solution will run in background (in separate thread
               or remotely).

        """
        # Check that old simulation is not running:
        if not self.isSolved():
            return

        # Check params and fields
        initConf.checkRequiredFields(self.fields, FieldID)
        initConf.checkRequiredParameters(self.properties, PropertyID)
        initConf.checkRequiredFunctions(self.functions, fID=FunctionID)

        # Set current tstep and copy previous results as starting values
        self._curTStep = tstep
        self._copyPreviousSolution()

        # Write out JSON file.
        self._writeInputJSON(tstep)

        # Get mie data from other app
        self._getMieData(tstep)

        # Start thread to start calculation
        self.tracerProcess = Popen(  # ["ping", "127.0.0.1",  "-n",
            # "3", "-w", "10"],
            # self.tracerProcess = Popen(["tracer",
            # "DefaultLED.json"],
            ["tracer-no-ray-save", "input.json"],
            stdout=PIPE,
            stderr=PIPE)

        # This thread will callback when tracer has ended.
        self.postThread = threading.Thread(target=self._runCallback,
                                           args=(self.tracerProcess,
                                                 self._tracerProcessEnded))
        # Post processing thread will wait for the tracer to finnish
        logger.info('Ray tracing starting...')
        self.postThread.start()

        # Wait for process if applicaple
        if not runInBackground:
            self.wait()
Example #4
0
    def solveStep(self, tstep, stageID=0, runInBackground=False):
        """
        Solves the problem for given time step.

        Proceeds the solution from actual state to given time.
        The actual state should not be updated at the end,
        as this method could be
        called multiple times for the same solution step
        until the global convergence
        is reached. When global convergence is reached,
        finishStep is called and then
        the actual state has to be updated.
        Solution can be split into individual stages
        identified by optional stageID parameter.
        In between the stages the additional data exchange can be performed.
        See also wait and isSolved services.

        :param TimeStep tstep: Solution step
        :param int stageID: optional argument identifying
               solution stage (default 0)
        :param bool runInBackground: optional argument, defualt False.
               If True, the solution will run in background (in separate thread
               or remotely).

        """
        # Check that old simulation is not running:
        if not self.isSolved():
            return

        # Check params and fields
        initConf.checkRequiredFields(self.fields, FieldID)
        initConf.checkRequiredParameters(self.properties, PropertyID)
        initConf.checkRequiredFunctions(self.functions, fID=FunctionID)

        # Set current tstep and copy previous results as starting values
        self._curTStep = tstep
        self._copyPreviousSolution()

        # Write out JSON file.
        self._writeInputJSON(tstep)

        # Get mie data from other app
        self._getMieData(tstep)

        # Start thread to start calculation
        self.tracerProcess = Popen(  # ["ping", "127.0.0.1",  "-n",
            # "3", "-w", "10"],
            # self.tracerProcess = Popen(["tracer",
            # "DefaultLED.json"],
            ["tracer-no-ray-save", "input.json"],
            stdout=PIPE,
            stderr=PIPE)

        # This thread will callback when tracer has ended.
        self.postThread = threading.Thread(target=self._runCallback,
                                           args=(self.tracerProcess,
                                                 self._tracerProcessEnded))
        # Post processing thread will wait for the tracer to finnish
        logger.info('Ray tracing starting...')
        self.postThread.start()

        # Wait for process if applicaple
        if not runInBackground:
            self.wait()