fixed ConfigMaterial.from_table; 2D grid.from_table now acceptable
This commit is contained in:
parent
4a00254dba
commit
69316f186b
|
@ -68,6 +68,7 @@ class ConfigMaterial(Config):
|
|||
pos pos pos qu qu qu qu phase homog
|
||||
0 0 0 0 0.19 0.8 0.24 -0.51 Aluminum SX
|
||||
1 1 0 0 0.8 0.19 0.24 -0.51 Steel SX
|
||||
1 1 1 0 0.8 0.19 0.24 -0.51 Steel SX
|
||||
>>> cm.from_table(t,O='qu',phase='phase',homogenization='homog')
|
||||
material:
|
||||
- constituents:
|
||||
|
@ -84,15 +85,11 @@ class ConfigMaterial(Config):
|
|||
phase: {}
|
||||
|
||||
"""
|
||||
# constituents_ = {k:table.get(v) for k,v in constituents.items()}
|
||||
kwargs_ = {k:table.get(v) for k,v in kwargs.items()}
|
||||
|
||||
_,idx = np.unique(kwargs_.values(),return_index=True,axis=0)
|
||||
# _,idx = np.unique(np.hstack(list({**constituents_,**kwargs_}.values())),return_index=True,axis=0)
|
||||
|
||||
_,idx = np.unique(np.hstack(list(kwargs_.values())),return_index=True,axis=0)
|
||||
idx = np.sort(idx)
|
||||
# constituents_ = {k:np.atleast_1d(v[idx].squeeze()) for k,v in constituents_.items()}
|
||||
kwargs_ = {k:np.atleast_1d(v[idx].squeeze()) for k,v in kwargs_.items()}
|
||||
kwargs_ = {k:np.atleast_1d(v[idx].squeeze()) for k,v in kwargs_.items()}
|
||||
|
||||
return ConfigMaterial().material_add(**kwargs_)
|
||||
|
||||
|
|
|
@ -122,7 +122,7 @@ class Grid:
|
|||
|
||||
@size.setter
|
||||
def size(self,size):
|
||||
if len(size) != 3 or any(np.array(size) <= 0):
|
||||
if len(size) != 3 or any(np.array(size) < 0):
|
||||
raise ValueError(f'invalid size {size}')
|
||||
else:
|
||||
self._size = np.array(size)
|
||||
|
@ -303,7 +303,7 @@ class Grid:
|
|||
Need to be ordered (1./x fast, 3./z slow).
|
||||
labels : str or list of str
|
||||
Label(s) of the columns containing the material definition.
|
||||
Each unique combintation of values results in one material ID.
|
||||
Each unique combination of values results in one material ID.
|
||||
|
||||
"""
|
||||
cells,size,origin = grid_filters.cellsSizeOrigin_coordinates0_point(table.get(coordinates))
|
||||
|
|
|
@ -89,12 +89,10 @@ class TestConfigMaterial:
|
|||
a = np.vstack((np.hstack((np.arange(N),np.arange(N)[::-1])),np.ones(N*2),np.zeros(N*2),np.ones(N*2),np.ones(N*2))).T
|
||||
print(a)
|
||||
t = Table(a,{'varying':1,'constant':4})
|
||||
c = ConfigMaterial.from_table(t,**{'phase':'varying','O':'constant'})
|
||||
c = ConfigMaterial.from_table(t,**{'phase':'varying','O':'constant','homogenization':'4_constant'})
|
||||
assert len(c['material']) == N
|
||||
print(c)
|
||||
# for i,m in enumerate(c['material']):
|
||||
# c = m['constituents'][0]
|
||||
# assert m['c'] == 1 and c['b'] == 0 and (c['a'] == [i,1]).all()
|
||||
for i,m in enumerate(c['material']):
|
||||
assert m['homogenization'] == 1 and (m['constituents'][0]['O'] == [1,0,1,1]).all()
|
||||
|
||||
@pytest.mark.parametrize('N,n,kw',[
|
||||
(1,1,{'phase':'Gold',
|
||||
|
|
Loading…
Reference in New Issue