0-based material indices
This commit is contained in:
parent
c3a413e023
commit
5f03e8cf8f
|
@ -417,7 +417,7 @@ class Geom:
|
||||||
Number of periods per unit cell. Defaults to 1.
|
Number of periods per unit cell. Defaults to 1.
|
||||||
materials : (int, int), optional
|
materials : (int, int), optional
|
||||||
Material IDs. Defaults to (1,2).
|
Material IDs. Defaults to (1,2).
|
||||||
|
|
||||||
Notes
|
Notes
|
||||||
-----
|
-----
|
||||||
The following triply-periodic minimal surfaces are implemented:
|
The following triply-periodic minimal surfaces are implemented:
|
||||||
|
@ -687,10 +687,10 @@ class Geom:
|
||||||
|
|
||||||
|
|
||||||
def renumber(self):
|
def renumber(self):
|
||||||
"""Renumber sorted material indices to 1,...,N."""
|
"""Renumber sorted material indices to 0,...,N-1."""
|
||||||
renumbered = np.empty(self.grid,dtype=self.material.dtype)
|
renumbered = np.empty(self.grid,dtype=self.material.dtype)
|
||||||
for i, oldID in enumerate(np.unique(self.material)):
|
for i, oldID in enumerate(np.unique(self.material)):
|
||||||
renumbered = np.where(self.material == oldID, i+1, renumbered)
|
renumbered = np.where(self.material == oldID, i, renumbered)
|
||||||
|
|
||||||
return Geom(material = renumbered,
|
return Geom(material = renumbered,
|
||||||
size = self.size,
|
size = self.size,
|
||||||
|
|
|
@ -176,6 +176,7 @@ class TestGeom:
|
||||||
material = default.material.copy()
|
material = default.material.copy()
|
||||||
for m in np.unique(material):
|
for m in np.unique(material):
|
||||||
material[material==m] = material.max() + np.random.randint(1,30)
|
material[material==m] = material.max() + np.random.randint(1,30)
|
||||||
|
default.material -= 1
|
||||||
modified = Geom(material,
|
modified = Geom(material,
|
||||||
default.size,
|
default.size,
|
||||||
default.origin)
|
default.origin)
|
||||||
|
|
Loading…
Reference in New Issue