BC: Some change.

This commit is contained in:
Pierre-Antoine Rouby committed 2023-05-02 17:53:00 +02:00
1 parent 8d3bfa4c8c
commit 6b1a77b235
7 files changed
+526 -48

No files matched your search

@@ -1,30 +1,7 @@
# -*- coding: utf-8 -*-
from copy import copy
from Model.Except import NotImplementedMethodeError
class BoundaryConditionList(object):
def __init__(self):
self._data = []
def __len__(self):
return len(self._data)
def __getitem__(self, index):
return self._data[index]
def __setitem__(self, index, value):
self._data[index] = value
def __copy__(self):
new = BoundaryConditionList()
new._data = self._data.copy()
return new
def copy(self):
return copy(self)
class BoundaryCondition(object):
def __init__(self, name:str = ""):
super(BoundaryCondition, self).__init__()
@@ -67,6 +44,12 @@ class BoundaryCondition(object):
def data(self):
return self._data.copy()
def _default_0(self):
return self._types[0](0)
def _default_1(self):
return self._types[1](0.0)
def is_define(self):
return self._data is not None
@@ -117,9 +100,3 @@ class BoundaryCondition(object):
new._set_i_c_v(ind, j, v[i])
return new
def _default_0(self):
return self._types[0](0)
def _default_1(self):
return self._types[1](0.0)
@@ -0,0 +1,68 @@
# -*- 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(list):
def __init__(self):
super(BoundaryConditionList, self).__init__()
def new(self, index):
n = NotDefined()
self.insert(index, n)
return n
def delete(self, bcs):
for bc in bcs:
self.remove(bc)
def delete_i(self, indexes):
bcs = map(
lambda x: x[1],
filter(
lambda x: x[0] in indexes,
enumerate(self)
)
)
for bc in bcs:
self.remove(bc)
def move_up(self, index):
if index < len(self):
next = index - 1
self[index], self[next] = self[next], self[index]
def move_down(self, index):
if index >= 0:
prev = index + 1
self[index], self[prev] = self[prev], self[index]
def __copy__(self):
new = BoundaryConditionList()
for bc in self:
new.append(bc)
return new
def __deepcopy__(self):
new = BoundaryConditionList()
for bc in self:
new.append(deepcopy(bc))
return new
def copy(self):
return copy(self)
@@ -4,12 +4,14 @@ from Model.Except import NotImplementedMethodeError
from Model.BoundaryCondition.BoundaryCondition import BoundaryCondition
BC_types = [
"PC",
"TZ",
"TD",
"ZD"
]
class NotDefined(BoundaryCondition):
def __init__(self, name:str = ""):
super(NotDefined, self).__init__(name=name)
self._type = "ND"
self._header = ["", ""]
self._types = [str, str]
class PonctualContribution(BoundaryCondition):
def __init__(self, name:str = ""):