easier to understand
This commit is contained in:
parent
6682f58f86
commit
aa11e1aca3
|
@ -577,24 +577,24 @@ class ConfigMaterial(Config):
|
|||
|
||||
for k,v in shape.items():
|
||||
target = (N_materials,N_constituents) + dim.get(k,())
|
||||
obj = np.broadcast_to(np.array(v).reshape(util.shapeshifter(np.array(v).shape,target,'right')),target)
|
||||
broadcasted = np.broadcast_to(np.array(v).reshape(util.shapeshifter(np.array(v).shape,target,'right')),target)
|
||||
if k == 'v':
|
||||
if np.min(obj) < 0 or np.max(obj) > 1:
|
||||
if np.min(broadcasted) < 0 or np.max(broadcasted) > 1:
|
||||
raise ValueError('volume fraction "v" out of range')
|
||||
if len(np.atleast_1d(obj)) > 1:
|
||||
total = np.sum(obj,axis=-1)
|
||||
if len(np.atleast_1d(broadcasted)) > 1:
|
||||
total = np.sum(broadcasted,axis=-1)
|
||||
if np.min(total) < 0 or np.max(total) > 1:
|
||||
raise ValueError('volume fraction "v" out of range')
|
||||
if k == 'O' and not np.allclose(1.0,np.linalg.norm(obj,axis=-1)):
|
||||
if k == 'O' and not np.allclose(1.0,np.linalg.norm(broadcasted,axis=-1)):
|
||||
raise ValueError('orientation "O" is not a unit quaterion')
|
||||
elif k == 'V_e' and not np.allclose(obj,tensor.symmetric(obj)):
|
||||
elif k == 'V_e' and not np.allclose(broadcasted,tensor.symmetric(broadcasted)):
|
||||
raise ValueError('elastic stretch "V_e" is not symmetric')
|
||||
for i in range(N_materials):
|
||||
if k == 'homogenization':
|
||||
mat[i][k] = obj[i,0]
|
||||
mat[i][k] = broadcasted[i,0]
|
||||
else:
|
||||
for j in range(N_constituents):
|
||||
mat[i]['constituents'][j][k] = obj[i,j]
|
||||
mat[i]['constituents'][j][k] = broadcasted[i,j]
|
||||
|
||||
dup = self.copy()
|
||||
dup['material'] = dup['material'] + mat if 'material' in dup else mat
|
||||
|
|
Loading…
Reference in New Issue