def test_spbox_3d(self): """ Check volume change of the mesh which is deformed using the SplineBox functions. """ from sfepy.discrete.fem import Mesh from sfepy.mesh.splinebox import SplineBox mesh = Mesh.from_file(data_dir + '/meshes/3d/cylinder.vtk') conn = mesh.get_conn('3_4') vol0 = tetravolume(conn, mesh.coors) bbox = nm.array(mesh.get_bounding_box()).T spbox = SplineBox(bbox, mesh.coors) cpoints0 = spbox.get_control_points(init=True) for ii in range(4): for jj in range(4): spbox.move_control_point((0, ii, jj), [-0.02, 0, 0]) coors = spbox.evaluate() vol1 = tetravolume(conn, coors) mesh.coors[:] = coors spbox.set_control_points(cpoints0) coors = spbox.evaluate() vol2 = tetravolume(conn, coors) ok = True actual_volumes = (vol0, vol1, vol2) expected_volumes = (1.22460186e-4, 1.46950423e-4, 1.22460186e-4) for ii in range(3): relerr = abs(actual_volumes[ii] - expected_volumes[ii])\ / expected_volumes[ii] ok = ok and (relerr < tolerance) if not ok: self.report('expected volumes:') self.report(expected_volumes) self.report('actual volumes:') self.report(actual_volumes) return ok