def calculate_axial_from_stress(self, R, J): """ Calculate the axial force by integrating sigma_zz over the area Parameters: R final residual J final jacobian """ #pylint: disable=no-value-for-parameter, invalid-unary-operand-type if self.state_np1.ndim == 1: dx = self.state_np1.basis.interpolate( self.state_np1.mesh.p[0] )[0][0] * self.state_np1.basis.dx * 2.0 * np.pi else: dx = self.state_np1.basis.dx fake_force = self._internal_force(self.state_np1.tangent[:, :, 2, 2]) de = utils.solve(*utils.condense(J, fake_force, D=self.edofs), solver=utils.solver_direct_scipy()) fake_strain = self.calculate_strain(de) integrand1 = np.einsum('iijk', self.state_np1.tangent[2, 2] * fake_strain) integrand2 = self.state_np1.tangent[2, 2, 2, 2] self.state_np1.force = np.sum(self.state_np1.stress[2, 2] * dx) self.state_np1.stiffness = np.sum( (-integrand1 + integrand2) * dx) / self.state_np1.h
def linear_solve(self, J, R): """ Do the linear solve for a particular jacobian and residual Parameters: J Jacobian sparse matrix R residual vector """ #pylint: disable=no-value-for-parameter return utils.solve(*utils.condense(J, R, D=self.edofs), solver=utils.solver_direct_scipy())