def flux_offset(self, mesh, element, flux, masterpos, time, smallsystem): # Retrieve the plastic strain field and evaluate it at this # masterposition. ep_val = symmmatrix.SymmMatrix3() ep = field.getField('Plastic') efi = element.funcnode_iterator() while not efi.end(): coef = efi.shapefunction(masterpos) ep_output = ep.output(mesh, efi.funcnode()) ep_val += ep_output.valuePtr() * coef efi += 1 # Now ep_val contains the plastic strain at this gausspoint. # We can do the arithmetic. Note that this assumes the same # gausspoint set from one iteration to the next, which will in # general be a bad assumption. modulus = self.elasticity.cijkl(mesh, element, masterpos) ij = fieldindex.SymTensorIterator() while (not ij.end()): offset = 0.0 kl = ep_val.getIterator() while (not kl.end()): idx = kl.integer() cijkl = modulus[ij.integer(), kl.integer()] if idx < 3: offset += cijkl * ep_val[kl] else: offset += 2.0 * cijkl * ep_val[kl] kl.next() smallsystem.add_offset_element(ij, offset) ij.next()
def evaluate_constraint(self, mesh, element, eqn, masterpos, smallsystem): # TODO: Test for the right equation. # Compute the stress -- start with the strain. strain = symmmatrix.SymmMatrix3 ep = field.getField('Plastic') efi = element.funcnode_iterator() while not efi.end(): coef = efi.shapefunction(masterpos) ep_output = ep.output(mesh, efi.funcnode()) strain -= ep_output.valuePtr() * coef efi += 1 disp = field.getField('Displacement') efi = element.funcnode_iterator() while not efi.end(): ddx = efi.dshapefunction(0, masterpos) ddy = efi.dshapefunction(1, masterpos) uxx = disp(efi, 0).value() * ddx uxy = disp(efi, 0).value() * ddy uyx = disp(efi, 1).value() * ddx uyy = disp(efi, 1).value() * ddy strain.set(0, 0, strain.get(0, 0) + uxx) strain.set(0, 1, strain.get(0, 1) + (0.5 * uxy + uyx)) strain.set(1, 1, strain.get(1, 1) + uyy) try: ops = field.getField('Displacement_z') except: pass else: efi = element.funcnode_iterator() while not efi.end(): uxz = ops(efi, 0).value() uyz = ops(efi, 1).value() uyz = ops(efi, 2).value() strain.set(0, 2, strain.get(0, 2) + uxz) strain.set(1, 2, strain.get(1, 2) + uyz) strain.set(2, 2, strain.get(2, 2) + uzz) # At this point, "strain" contains the elastic strain, # geometric minus plastic. modulus = self.elasticity.cijkl(mesh, element, masterpos) ij = fieldindex.SymTensorIterator() while (not ij.end()): stressij = 0.0 kl = ep_val.getIterator() while (not kl.end()): idx = kl.integer cijkl = modulus[ij.integer(), kl.integer()] if idx < 3: stressij += cijkl * strain[kl] else: stressij += 2.0 * cijkl * strain[kl] kl.next() # Accumulate the stress somewhere. ij.next()
def flux_offset(self, mesh, element, flux, point, time, fluxdata): cijkl = self.elasticity.cijkl(mesh, element, point) strain0 = symmmatrix.SymmMatrix3(0.1, 0.1, 0.1, 0, 0, 0) ij = problem.Stress.iterator(planarity.ALL_INDICES) while not ij.end(): kl = fieldindex.SymTensorIterator() while not kl.end(): strain_kl = strain0.get(kl.row(), kl.col()) # TODO: too ugly if kl.diagonal(): fluxdata.add_offset_vector_element( ij, cijkl[ij.integer(), kl.integer()] * strain_kl) else: fluxdata.add_offset_vector_element( ij, 2.0 * cijkl[ij.integer(), kl.integer()] * strain_kl) kl.next() ij.next()