mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
BC: Add BC list object and some change.
This commit is contained in:
1 parent
81b8fd67a6
commit
8d3bfa4c8c
4 files changed
+136
-13
No files matched your search
@@ -1,7 +1,30 @@
|
||||
# -*- 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__()
|
||||
@@ -10,8 +33,8 @@ class BoundaryCondition(object):
|
||||
self._type = ""
|
||||
self._node = None
|
||||
self._data = []
|
||||
self.header = []
|
||||
self.types = [int, float]
|
||||
self._header = []
|
||||
self._types = [int, float]
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
@@ -68,16 +91,19 @@ class BoundaryCondition(object):
|
||||
def sort(self, _reverse):
|
||||
self._data.sort(reverse=_reverse)
|
||||
|
||||
def get_i(self, index):
|
||||
return self.data[index]
|
||||
|
||||
def _set_i_c_v(self, index, column, value):
|
||||
v = list(self._data[index])
|
||||
v[column] = self.types[column](value)
|
||||
v[column] = self._types[column](value)
|
||||
self._data[index] = tuple(v)
|
||||
|
||||
def set_i_0(self, index:int, value):
|
||||
self._set_i_c_v(index, 0, value):
|
||||
self._set_i_c_v(index, 0, value)
|
||||
|
||||
def set_i_1(self, index:int, value):
|
||||
self._set_i_c_v(index, 1, value):
|
||||
self._set_i_c_v(index, 1, value)
|
||||
|
||||
def convert(self, cls):
|
||||
new = cls(name = self.name)
|
||||
@@ -86,14 +112,14 @@ class BoundaryCondition(object):
|
||||
|
||||
for i in [0,1]:
|
||||
for j in [0,1]:
|
||||
if self.header[i] == new.header[j]:
|
||||
if self._header[i] == new.header[j]:
|
||||
for ind, v in self.data:
|
||||
new._set_i_c_v(ind, j, v[i])
|
||||
|
||||
return new
|
||||
|
||||
def _default_0(self):
|
||||
return self.types[0](0)
|
||||
return self._types[0](0)
|
||||
|
||||
def _default_1(self):
|
||||
return self.types[1](0.0)
|
||||
return self._types[1](0.0)
|
||||
Reference in new issue
Block a user