File: FinalStepDP.py

package info (click to toggle)
stopt 5.5%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 8,772 kB
  • sloc: cpp: 70,373; python: 5,942; makefile: 67; sh: 57
file content (44 lines) | stat: -rw-r--r-- 1,626 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# Copyright (C) 2016 EDF
# All Rights Reserved
# This code is published under the GNU Lesser General Public License (GNU LGPL)
import numpy as np


class FinalStepDP:
    
    def __init__(self, p_pGridCurrent, p_nbRegime):
        
        self.m_pGridCurrent = p_pGridCurrent
        self.m_nDim = p_pGridCurrent.getDimension()
        self.m_nbRegime = p_nbRegime
        
    def operator(self, p_funcValue, p_particles):
        
        finalValues = list(range(self.m_nbRegime))
        
        if self.m_pGridCurrent.getNbPoints() > 0:
            
            for iReg in range(self.m_nbRegime):
                finalValues[iReg] = np.zeros((p_particles.shape[1], self.m_pGridCurrent.getNbPoints()))
                
            # number of thread
            nbThreads = 1
            
            # create iterator on current grid treated for processor
            iterGridPoint = self.m_pGridCurrent.getGridIteratorInc(0)
            
            # iterates on points of the grid
            for iIter in range(self.m_pGridCurrent.getNbPoints()):
                iThread = 0
                
                if iterGridPoint.isValid():
                    pointCoord = iterGridPoint.getCoordinate()
                    
                    for iReg in range(self.m_nbRegime):
                        
                        #for i in range(p_particles.shape[1]):
                        finalValues[iReg][:,iterGridPoint.getCount()] = p_funcValue.set(iReg, pointCoord, p_particles)
                            
                    iterGridPoint.nextInc(nbThreads)
                    
        return finalValues