[docs]classTestMeshReadData(TestFixture.TestFixture):# output from explore patch.g:# Number of nodes = 36# Number of elements = 50# Number of element blocks = 1# Number of nodal point sets = 5# Length of node list = 30# Length of distribution list = 30# Number of element side sets = 5# Length of element list = 25# Length of node list = 50# Length of distribution list = 50
[docs]deftest_dirichlet_patch_test(self):ebcs=[FunctionSpace.EssentialBC(nodeSet='left',component=0),FunctionSpace.EssentialBC(nodeSet='left',component=1),FunctionSpace.EssentialBC(nodeSet='bottom',component=0),FunctionSpace.EssentialBC(nodeSet='bottom',component=1),FunctionSpace.EssentialBC(nodeSet='right',component=0),FunctionSpace.EssentialBC(nodeSet='right',component=1),FunctionSpace.EssentialBC(nodeSet='top',component=0),FunctionSpace.EssentialBC(nodeSet='top',component=1)]targetDispGrad=np.array([[0.1,-0.2],[0.4,-0.1]])U=self.mesh.coords@targetDispGrad.TfieldDim=U.shape[1]dofManager=FunctionSpace.DofManager(self.fs,fieldDim,ebcs)# Uu is U_unconstrainedUbc=dofManager.get_bc_values(U)@jitdefobjective(Uu):U=dofManager.create_field(Uu,Ubc)returnself.compute_strain_energy(U,self.internalVariables,self.props)grad_func=jit(grad(objective))Uu,solverSuccess=newton_solve(objective,dofManager.get_unknown_values(U))self.assertTrue(solverSuccess)U=dofManager.create_field(Uu,Ubc)dispGrads=FunctionSpace.compute_field_gradient(self.fs,U)ne,nqpe=self.fs.vols.shapefordgindispGrads.reshape(ne*nqpe,2,2):self.assertArrayNear(dg,targetDispGrad,14)self.assertNear(np.linalg.norm(grad_func(Uu)),0.0,14)