Skip to content

Commit

Permalink
Update tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
marcfehling committed Oct 12, 2021
1 parent 1cb1343 commit 75dd7fc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
12 changes: 6 additions & 6 deletions tests/physics/step-18-rotation_matrix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,14 @@ namespace Step18
Tensor<2, 3>
get_rotation_matrix(const std::vector<Tensor<1, 3>> &grad_u)
{
const Point<3> curl(grad_u[2][1] - grad_u[1][2],
grad_u[0][2] - grad_u[2][0],
grad_u[1][0] - grad_u[0][1]);
const double tan_angle = std::sqrt(curl * curl);
const Tensor<1, 3> curl({grad_u[2][1] - grad_u[1][2],
grad_u[0][2] - grad_u[2][0],
grad_u[1][0] - grad_u[0][1]});
const double tan_angle = std::sqrt(curl * curl);
// Note: Here the negative angle suggests that we're computing the rotation
// of the coordinate system around a fixed point
const double angle = -std::atan(tan_angle);
const Point<3> axis = curl / tan_angle;
const double angle = -std::atan(tan_angle);
const Tensor<1, 3> axis = curl / tan_angle;
return Physics::Transformations::Rotations::rotation_matrix_3d(axis, angle);
}
template <int dim>
Expand Down
14 changes: 9 additions & 5 deletions tests/physics/transformations-rotations_01.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ test_rotation_matrix_3d_z_axis(const double angle)
Assert(std::abs(determinant(R_z) - 1.0) < 1e-9,
ExcMessage("Rodrigues rotation matrix determinant is not unity"));
const Tensor<2, 3> R =
Transformations::Rotations::rotation_matrix_3d(Point<3>({0, 0, 1}), angle);
Transformations::Rotations::rotation_matrix_3d(Tensor<1, 3>({0., 0., 1.}),
angle);
Assert(std::abs(determinant(R) - 1.0) < 1e-9,
ExcMessage("Rotation matrix determinant is not unity"));

Expand All @@ -53,7 +54,7 @@ test_rotation_matrix_3d_z_axis(const double angle)
}

void
test_rotation_matrix_3d(const Point<3> &axis, const double angle)
test_rotation_matrix_3d(const Tensor<1, 3> &axis, const double angle)
{
// http://en.wikipedia.org/wiki/Rodrigues%27_rotation_formula
// http://en.wikipedia.org/wiki/Rotation_matrix
Expand Down Expand Up @@ -146,9 +147,12 @@ main()
test_rotation_matrix_3d_z_axis(45.0 * deg_to_rad);
test_rotation_matrix_3d_z_axis(60.0 * deg_to_rad);

test_rotation_matrix_3d(normalise(Point<3>({1, 1, 1})), 90.0 * deg_to_rad);
test_rotation_matrix_3d(normalise(Point<3>({0, 2, 1})), 45.0 * deg_to_rad);
test_rotation_matrix_3d(normalise(Point<3>({-1, 3, 2})), 60.0 * deg_to_rad);
test_rotation_matrix_3d(normalise(Tensor<1, 3>({1., 1., 1.})),
90.0 * deg_to_rad);
test_rotation_matrix_3d(normalise(Tensor<1, 3>({0., 2., 1.})),
45.0 * deg_to_rad);
test_rotation_matrix_3d(normalise(Tensor<1, 3>({-1., 3., 2.})),
60.0 * deg_to_rad);

deallog << "OK" << std::endl;
}
8 changes: 4 additions & 4 deletions tests/simplex/step-18.cc
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ namespace Step18
Tensor<2, 3>
get_rotation_matrix(const std::vector<Tensor<1, 3>> &grad_u)
{
const Point<3> curl(grad_u[2][1] - grad_u[1][2],
grad_u[0][2] - grad_u[2][0],
grad_u[1][0] - grad_u[0][1]);
const Tensor<1, 3> curl({grad_u[2][1] - grad_u[1][2],
grad_u[0][2] - grad_u[2][0],
grad_u[1][0] - grad_u[0][1]});

const double tan_angle = std::sqrt(curl * curl);
const double angle = std::atan(tan_angle);
Expand All @@ -177,7 +177,7 @@ namespace Step18
return rot;
}

const Point<3> axis = curl / tan_angle;
const Tensor<1, 3> axis = curl / tan_angle;
return Physics::Transformations::Rotations::rotation_matrix_3d(axis,
-angle);
}
Expand Down

0 comments on commit 75dd7fc

Please sign in to comment.