def _flux(mesh, elements, coords, flux): ans = [] prog = progress.getProgress("Evaluating flux", progress.DEFINITE) ## TODO OPT: elements may be a generator, and converting it to a list ## is ugly and wasteful, but it's the only way to get its length, ## which we only need for the progress bar. We should either get ## rid of the progress bar, or find another way to get the number ## of elements. Perhaps giving the Output access to the domain ## would work. Output.evaluate isn't always called with a domain, ## though. See MeshDataGUI.updateData(). elist = list(elements) nel = len(elist) try: ecount = 0 for elem, ecoords in itertools.izip(elist, coords): mesh.begin_all_subproblems(elem) fluxes = elem.outputFluxes(mesh, flux, ecoords) ans.append(fluxes) mesh.end_all_subproblems(elem) ecount += 1 prog.setFraction((1. * ecount) / nel) prog.setMessage("%d/%d elements" % (ecount, nel)) return utils.flatten1(ans) finally: prog.finish()
def _pos(mesh, elements, coords): # The argument "elements" is a list of Elements or Edges, possibly # mixed together. The argument "coords" is a list of lists. Each # Element in the elements list corresponds to a list of # MasterCoords in the coords list, and each Edge corresponds to a # list of doubles (ie, master coords for the Edge, in the range # [0,1)). return utils.flatten1([element.position(coordList) for element,coordList in zip(elements, coords)])
def _flux(mesh, elements, coords, flux): ans = [] prog = progress.getProgress("Evaluating flux", progress.DEFINITE) #nel = mesh.nelements() # No! Should be len(elements), but # elements is a generator. elist = list(elements) nel = len(elist) try: ecount = 0 for element, ecoords in itertools.izip(elist, coords): mesh.begin_all_subproblems(element) ## element.begin_material_computation(mesh) ans.append(element.outputFluxes(mesh, flux, ecoords)) ## element.end_material_computation(mesh) mesh.end_all_subproblems(element) ecount += 1 prog.setFraction((1. * ecount) / nel) prog.setMessage("%d/%d elements" % (ecount, nel)) return utils.flatten1(ans) finally: prog.finish()
def _flux(mesh, elements, coords, flux): ans = [] prog = progress.getProgress("Evaluating flux", progress.DEFINITE) #nel = mesh.nelements() # No! Should be len(elements), but # elements is a generator. elist = list(elements) nel = len(elist) try: ecount = 0 for element, ecoords in itertools.izip(elist, coords): mesh.begin_all_subproblems(element) ## element.begin_material_computation(mesh) ans.append(element.outputFluxes(mesh, flux, ecoords)) ## element.end_material_computation(mesh) mesh.end_all_subproblems(element) ecount += 1 prog.setFraction((1.*ecount)/nel) prog.setMessage("%d/%d elements" % (ecount, nel)) return utils.flatten1(ans) finally: prog.finish()
def _field(mesh, elements, coords, field): return utils.flatten1([ element.outputFields(mesh, field, ecoords) for element, ecoords in itertools.izip(elements, coords) ])
def _fieldderiv(mesh, elements, coords, field, derivative): return utils.flatten1([ element.outputFieldDerivs(mesh, field, derivative, ecoords) for element, ecoords in itertools.izip(elements, coords) ])
def _field(mesh, elements, coords, field): return utils.flatten1([element.outputFields(mesh, field, ecoords) for element, ecoords in itertools.izip(elements, coords)])
def _fieldderiv(mesh, elements, coords, field, derivative): return utils.flatten1( [element.outputFieldDerivs(mesh, field, derivative, ecoords) for element, ecoords in itertools.izip(elements, coords)])