def output(self, mesh, element, propertyoutput, position): if propertyoutput.name() == "Energy": return outputval.ScalarOutputVal(3.14) * position.mastercoord()[0] if propertyoutput.name() == "Strain": stype = propertyoutput.getRegisteredParamName("type") if stype == "Geometric": return symmmatrix.SymmMatrix3(0, 1, 2, 3, 4, 5)
def _component(mesh, elements, coords, field, component): if field: # 'component' is a string, "x" or "xy" or the like firstfield = next(iter(field)) comp = firstfield.getIndex(component) # convert string to IndexP return [outputval.ScalarOutputVal(f[comp]) for f in field] return []
def output(self, mesh, element, output, pos): if output.name() == "Energy": etype = output.getEnumParam("etype") if etype in ("Total", "Elastic"): mod = self.modulus() # strain is a SymmMatrix3. modulus is a cijkl.Cijkl strain = cstrain.findGeometricStrain(mesh, element, pos, False) stress = mod * strain # another SymmMatrix3. return outputval.ScalarOutputVal(0.5 * stress.contract(strain))
def _scalarFunctionOutput(mesh, elements, coords, f): ans = [] t = mesh.getCurrentTime() prog = progress.getProgress("Function evaluation", progress.DEFINITE) ecount = 0 nel = mesh.nelements() for element, coordlist in itertools.izip(elements, coords): realcoords = itertools.imap(element.from_master, coordlist) ans.extend(outputval.ScalarOutputVal(f(coord, t)) for coord in realcoords) ecount += 1 prog.setFraction((1.*ecount)/nel) prog.setMessage("%d/%d elements" % (ecount, nel)) prog.finish() return ans
def scalar_instancefn(self): return outputval.ScalarOutputVal(0.0)
def zeroVal(self, output): return outputval.ScalarOutputVal(0.0)