def apply(self, femesh, field, time=None, singleFieldDef=False): if singleFieldDef: # The purpose of calling node.fieldDefCount is to ensure # that we don't set the value of a field that is defined # in more than one subproblem when that field gets defined # on the second subproblem. Doing so would wipe out a # value that might have been set by the first subproblem. fniter = femesh.funcnode_iterator() while not fniter.end(): node = fniter.node() if node.fieldDefCount(field) == 1: position = node.position() for i in range(field.ndof()): # field component field.setvalue(femesh, node, i, self.func(position, time, i)) fniter.next() else: fniter = femesh.funcnode_iterator() while not fniter.end(): node = fniter.node() if node.hasField(field): position = node.position() for i in range(field.ndof()): # field component field.setvalue(femesh, node, i, self.func(position, time, i)) fniter.next()
def apply(self, femesh, field, time=None, singleFieldDef=False): if singleFieldDef: # The purpose of calling node.fieldDefCount is to ensure # that we don't set the value of a field that is defined # in more than one subproblem when that field gets defined # on the second subproblem. Doing so would wipe out a # value that might have been set by the first subproblem. fniter = femesh.funcnode_iterator() while not fniter.end(): node = fniter.node() if node.fieldDefCount(field)==1: position = node.position() for i in range(field.ndof()): # field component field.setvalue(femesh, node, i, self.func(position, time, i)) fniter.next() else: fniter = femesh.funcnode_iterator() while not fniter.end(): node = fniter.node() if node.hasField(field): position = node.position() for i in range(field.ndof()): # field component field.setvalue(femesh, node, i, self.func(position, time, i)) fniter.next()
def _loadFieldValues(menuitem, mesh, fields, field_values): meshctxt = ooflib.engine.mesh.meshes[mesh] femesh = meshctxt.getObject() fieldlist = [getFieldObj(fld) for fld in fields] # get objects from names for fv in field_values: index = fv[0] node = femesh.getNode(index) pointer = 1 for field in fieldlist: for i in range(field.ndof()): field.setvalue(femesh, node, i, fv[pointer]) pointer += 1 # Field values can change the appearance of a newly-loaded mesh. switchboard.notify("mesh data changed", meshctxt) switchboard.notify("redraw")