dbName="noise.silo"
mat = MaterialAttributes()
matAlgorithms = [mat.ZooClipping, mat.Isovolume, mat.Discrete]
matAlgorithmNames = ["Zoo", "Isovolume", "Discrete"]
def TestMat(meshname, matname, matnumber):
expr_defn = "volume(%s)*matvf(%s, \"%s\")" %(meshname, matname, matnumber)
DefineScalarExpression("mat_vol", expr_defn)
AddPlot("Pseudocolor", "mat_vol")
s = SILRestriction()
s.TurnOnAll()
SetPlotSILRestriction(s)
DrawPlots()
Query("Variable Sum")
real_vol = GetQueryOutputValue()
Query("NumZones",1)
num_zones = GetQueryOutputValue()
DeleteExpression("mat_vol")
DeleteAllPlots()
print "\tThe true volume is %f" %(real_vol)
expr_defn = "if(gt(matvf(%s, \"%s\"),0),1,0)" %(matname,matnumber)
DefineScalarExpression("has_mat", expr_defn)
AddPlot("Pseudocolor", "has_mat")
DrawPlots()
Query("Variable Sum")
num_zones = GetQueryOutputValue()
DeleteExpression("has_mat")
DeleteAllPlots()
print "\tThe number of zones involving %s is %d" %(matnumber, num_zones)
# if ((matvf(mat) > 0) && (nmats(mat) > 1) then 1 else 0
expr_defn = "if(and( gt(matvf(%s, \"%s\"),0), gt(nmats(%s),1)), 1,0)" %(matname,matnumber,matname)
DefineScalarExpression("mixed_mats", expr_defn)
AddPlot("Pseudocolor", "mixed_mats")
DrawPlots()
Query("Variable Sum")
num_zones = GetQueryOutputValue()
DeleteExpression("mixed_mats")
DeleteAllPlots()
print "\tThe number of mixed zones involving %s is %d" %(matnumber, num_zones)
for j in range(len(matAlgorithms)):
print "\tTesting material algorithm %s" %(matAlgorithmNames[j])
m = MaterialAttributes()
m.algorithm = matAlgorithms[j]
SetMaterialAttributes(m)
AddPlot("FilledBoundary", matname)
s = SILRestriction()
s.TurnOffAll()
setlist = s.SetsInCategory(matname)
for x in setlist:
if matnumber == s.SetName(x):
s.TurnOnSet(x)
SetPlotSILRestriction(s)
DrawPlots()
Query("Volume")
vol = GetQueryOutputValue()
print "\t\tThe volume is %f" %(vol)
Query("NumZones",1)
nz = GetQueryOutputValue()
print "\t\tThe number of zones is %d" %(nz)
Query("2D area",1)
sa = GetQueryOutputValue()
print "\t\tThe surface area is %f" %(sa)
DeleteAllPlots()
expr_defn = "nmats(%s)" %(matname)
DefineScalarExpression("nmats", expr_defn)
AddPlot("Pseudocolor", "nmats")
AddOperator("Threshold")
t = ThresholdAttributes()
t.listedVarNames = ("nmats")
t.lowerBounds = (1.5)
t.upperBounds = (100000)
SetOperatorOptions(t)
s = SILRestriction()
s.TurnOffAll()
setlist = s.SetsInCategory(matname)
for x in setlist:
if matnumber == s.SetName(x):
s.TurnOnSet(x)
DrawPlots()
Query("NumZones",1)
nz = GetQueryOutputValue()
DeleteExpression("nmats")
DeleteAllPlots()
print "\t\tThe number of zones coming from mixed zones is %d" %(nz)
SuppressQueryOutputOn()
OpenDatabase(dbName)
md = GetMetaData(dbName)
if md.GetNumMaterials() < 1:
print "No materials in %s" %(dbName)
for j in range(md.GetNumMaterials()):
mat = md.GetMaterials(j)
for m in range(mat.numMaterials):
print "Working on material %s" %(mat.materialNames[m])
TestMat(mat.meshName, mat.name, mat.materialNames[m])
import sys
sys.exit()