void TestTranslation3DWithUblas() { TrianglesMeshReader<3,3> mesh_reader("mesh/test/data/cube_136_elements"); TetrahedralMesh<3,3> mesh; mesh.ConstructFromMeshReader(mesh_reader); double volume = mesh.GetVolume(); double surface_area = mesh.GetSurfaceArea(); Node<3>* p_node1 = mesh.GetNode(36); ChastePoint<3> point1 = p_node1->GetPoint(); Node<3>* p_node2 = mesh.GetNode(23); ChastePoint<3> point2 = p_node2->GetPoint(); c_vector<double, 3> old_location1 = point1.rGetLocation(); c_vector<double, 3> old_location2 = point2.rGetLocation(); // Set translation Vector c_vector<double, 3> trans_vec; trans_vec(0) = 2.0; trans_vec(1) = 2.0; trans_vec(2) = 2.0; // Translate mesh.Translate(trans_vec); c_vector<double, 3> new_location1 = point1.rGetLocation(); c_vector<double, 3> new_location2 = point2.rGetLocation(); // Check Volume and Surface Area are invariant TS_ASSERT_DELTA(mesh.GetVolume(), volume, 1e-6); TS_ASSERT_DELTA(mesh.GetSurfaceArea(), surface_area, 1e-6); // Spot check a couple of nodes TS_ASSERT_DELTA(inner_prod(new_location1-old_location1, trans_vec), 0, 1e-6); TS_ASSERT_DELTA(inner_prod(new_location2-old_location2, trans_vec), 0, 1e-6); }
void TestTranslationMethod() throw (Exception) { TrianglesMeshReader<3,3> mesh_reader("mesh/test/data/cube_136_elements"); TetrahedralMesh<3,3> mesh; mesh.ConstructFromMeshReader(mesh_reader); // Pick a random node and store spatial position Node<3>* p_node = mesh.GetNode(10); ChastePoint<3> original_coordinate = p_node->GetPoint(); double mesh_volume = mesh.GetVolume(); const double x_movement = 1.0; const double y_movement = 2.5; const double z_movement = -3.75; mesh.Translate(x_movement, y_movement, z_movement); ChastePoint<3> new_coordinate = p_node->GetPoint(); double new_mesh_volume = mesh.GetVolume(); TS_ASSERT_DELTA(mesh_volume, new_mesh_volume, 1e-6); TS_ASSERT_DELTA(original_coordinate[0], new_coordinate[0]-x_movement, 1e-6); TS_ASSERT_DELTA(original_coordinate[1], new_coordinate[1]-y_movement, 1e-6); TS_ASSERT_DELTA(original_coordinate[2], new_coordinate[2]-z_movement, 1e-6); }
void Test3DMeshTranslationWithUblasMethod() { TrianglesMeshReader<3,3> mesh_reader("mesh/test/data/cube_136_elements"); TetrahedralMesh<3,3> mesh; mesh.ConstructFromMeshReader(mesh_reader); // Translations - add a constant vector to each node c_vector<double,3> displacement; displacement(0) = 1; displacement(1) = 1; displacement(2) = 1; // Translate the mesh along the vector displacement mesh.Translate(displacement); TetrahedralMesh<3,3> original_mesh; original_mesh.ConstructFromMeshReader(mesh_reader); for (unsigned i=0; i<mesh.GetNumNodes(); i++) { // Find new coordinates of the translated node Node<3>* p_node = mesh.GetNode(i); ChastePoint<3> new_coordinate = p_node->GetPoint(); // Get original node Node<3>* p_original_node = original_mesh.GetNode(i); ChastePoint<3> original_coordinate = p_original_node->GetPoint(); // Run a test to make sure the node has gone to the correct place TS_ASSERT_DELTA(original_coordinate[0] + displacement[0], new_coordinate[0], 1e-5); TS_ASSERT_DELTA(original_coordinate[1] + displacement[1], new_coordinate[1], 1e-5); TS_ASSERT_DELTA(original_coordinate[2] + displacement[2], new_coordinate[2], 1e-5); } // Check volume conservation double mesh_volume = mesh.GetVolume(); double original_mesh_volume = original_mesh.GetVolume(); TS_ASSERT_DELTA(mesh_volume, original_mesh_volume, 1e-5); }
void TestGeneralConvolution3DWithMethod() { TrianglesMeshReader<3,3> mesh_reader("mesh/test/data/cube_136_elements"); TetrahedralMesh<3,3> mesh; mesh.ConstructFromMeshReader(mesh_reader); double mesh_volume = mesh.GetVolume(); mesh.Translate(2.3, 3.1, 1.7); mesh.RotateZ(1.4); mesh.RotateY(0.3); mesh.RotateX(0.7); double new_mesh_volume = mesh.GetVolume(); TS_ASSERT_DELTA(mesh_volume, new_mesh_volume, 1e-6); ChastePoint<3> corner_after = mesh.GetNode(6)->GetPoint(); TS_ASSERT_DELTA(corner_after[0], 3.59782, 5e-5); TS_ASSERT_DELTA(corner_after[1], 0.583418, 5e-5); TS_ASSERT_DELTA(corner_after[2], 4.65889, 5e-5); }