-
Pierre-Antoine Rouby authored3617fde9
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# -*- coding: utf-8 -*-
from copy import copy
from tools import trace, timer
from Model.Except import NotImplementedMethodeError
from Model.BoundaryCondition.BoundaryConditionTypes import (
NotDefined,
PonctualContribution,
TimeOverZ, TimeOverDebit, ZOverDebit
)
class BoundaryConditionList(object):
def __init__(self):
super(BoundaryConditionList, self).__init__()
self._tabs = {
"liquid" : [],
"solid" : [],
"suspenssion" : []
}
def len(self, lst):
return len(self._tabs[lst])
def get_tab(self, lst):
return self._tabs[lst].copy()
def get(self, lst, row):
return self._tabs[lst][row]
def set(self, lst, row, new):
self._tabs[lst][row] = new
def new(self, lst, index):
n = NotDefined()
self._tabs[lst].insert(index, n)
return n
def insert(self, lst, index, new):
self._tabs[lst].insert(index, new)
def delete(self, lst, bcs):
for bc in bcs:
self._tabs[lst].remove(bc)
def delete_i(self, lst, indexes):
bcs = list(
map(
lambda x: x[1],
filter(
lambda x: x[0] in indexes,
enumerate(self._tabs[lst])
)
)
)
self.delete(lst, bcs)
def sort(self, lst, reverse=False, key=None):
self._tabs[lst].sort(reverse=reverse, key=key)
def move_up(self, lst, index):
if index < len(self._tabs[lst]):
next = index - 1
l = self._tabs[lst]
l[index], l[next] = l[next], l[index]
def move_down(self, lst, index):
if index >= 0:
prev = index + 1
l = self._tabs[lst]
l[index], l[prev] = l[prev], l[index]
def __copy__(self):
new = BoundaryConditionList()
for l in self._tabs:
new.tabs[l] = self._tabs[l].copy()
return new
def __deepcopy__(self):
new = BoundaryConditionList()
for l in self._tabs:
new.tabs[l] = self._tabs[l].deepcopy()
return new
def copy(self):
return copy(self)