本文整理汇总了C++中TetrahedralMesh::Translate方法的典型用法代码示例。如果您正苦于以下问题:C++ TetrahedralMesh::Translate方法的具体用法?C++ TetrahedralMesh::Translate怎么用?C++ TetrahedralMesh::Translate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TetrahedralMesh
的用法示例。
在下文中一共展示了TetrahedralMesh::Translate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
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);
}
示例2: TestTranslationMethod
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);
}
示例3: displacement
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);
}