def get_wear_rate_source(bucket, alpha, delta_t, wm, ER): """Calculate wear_rate on the boundary surface""" linear_data = bucket.system.boundary.bnd wear = numpy.zeros((linear_data.GetNumberOfPoints())) volume = numpy.zeros(linear_data.GetNumberOfPoints()) for _ in range(linear_data.GetNumberOfCells()): cell = linear_data.GetCell(_) pnt_ids = cell.GetPointIds() cv_mass = IO.get_measure(cell) / cell.GetNumberOfPoints() for dummy_1 in range(pnt_ids.GetNumberOfIds()): volume[pnt_ids.GetId(dummy_1)] += cv_mass for col in bucket.collisions(): if col.time < bucket.time - bucket.delta_t: continue cell = linear_data.GetCell(col.cell) gid = barocentric_id(cell, col.pos) wear[gid] += col.get_wear(wm, ER) / delta_t wear /= volume print "Lily max wear rate source for %s is %s at %s with %s" % (ER, max(wear), delta_t, max(volume)) print "Lily min wear rate source for %s is %s at %s with %s" % (ER, min(wear), delta_t, min(volume)) return wear
def get_cv_fraction(bucket, data): """Calculate the particle volume fraction using control volumes""" linear_data = IO.get_linear_block(data) is2d = linear_data.GetCell(0).GetCellType() == vtk.VTK_TRIANGLE cvs = vtp.vtkShowCVs() cvs.SetContinuity(-1) if vtk.vtkVersion.GetVTKMajorVersion() < 6: cvs.SetInput(linear_data) else: cvs.SetInputData(linear_data) cvs.Update() cv_data = cvs.GetOutput() locator = vtk.vtkCellLocator() locator.SetDataSet(cv_data) locator.BuildLocator() output = numpy.zeros(linear_data.GetNumberOfPoints()) volume = numpy.zeros(linear_data.GetNumberOfPoints()) for _ in range(linear_data.GetNumberOfCells()): cell = linear_data.GetCell(_) pnt_ids = cell.GetPointIds() cv_mass = IO.get_measure(cell) / cell.GetNumberOfPoints() for dummy_1 in range(pnt_ids.GetNumberOfIds()): volume[pnt_ids.GetId(dummy_1)] += cv_mass for par in bucket: index = locator.FindCell(par.pos) if index < 0: continue ele, l_id = divmod(index, linear_data.GetCell(0).GetNumberOfPoints()) gid = linear_data.GetCell(ele).GetPointId(l_id) if is2d: output[gid] += par.parameters.get_area() else: output[gid] += par.parameters.get_volume() return output / volume