File: OneDimRegularSpaceGrid.py

package info (click to toggle)
stopt 5.12%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 8,860 kB
  • sloc: cpp: 70,456; python: 5,950; makefile: 72; sh: 57
file content (49 lines) | stat: -rw-r--r-- 1,245 bytes parent folder | download | duplicates (2)
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
45
46
47
48
49
# Copyright (C) 2016 EDF
# All Rights Reserved
# This code is published under the GNU Lesser General Public License (GNU LGPL)
import math

# Defines a specialization of the RegularSpaceGrid  object in one dimension


# define a grid in one dimension
class OneDimRegularSpaceGrid:
    
#     # Default constructor
#     def __init__(self):
#         
#         return None
     
    # Constructor
    # p_lowValue   minimal value of the grid
    # p_step       step size
    # p_nbStep     number of steps
    def __init__(self, p_lowValue, p_step, p_nbStep):
        
        self.m_lowValue = p_lowValue
        self.m_step = p_step
        self.m_nbStep = p_nbStep
        
    # To a coordinate get back the mesh number
    # p_coord   coordinate
    # return mesh number associated to the coordinate
    def getMesh(self, p_coord):
        
        if (self.m_lowValue <= p_coord) == False:
            pass
        
        return min(int(math.ceil((p_coord - self.m_lowValue) / self.m_step)), self.m_nbStep)
    
    # get back value
    
    def getLowValue(self):
        
        return self.m_lowValue
    
    def getStep(self):
        
        return self.m_step
    
    def getNbStep(self):
        
        return self.m_nbStep