Skip to content
Snippets Groups Projects
Commit f66c728a authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

[T] LIE: Simplify line element tests.

parent 86ac5192
No related branches found
No related tags found
No related merge requests found
...@@ -38,34 +38,17 @@ std::unique_ptr<MeshLib::Mesh> createTriangle( ...@@ -38,34 +38,17 @@ std::unique_ptr<MeshLib::Mesh> createTriangle(
} }
std::unique_ptr<MeshLib::Mesh> createLine( std::unique_ptr<MeshLib::Mesh> createLine(
std::array<double, 3> const& a, std::array<double, 3> const& b) std::array<std::array<double, 3>, 2> const& points)
{ {
MeshLib::Node** nodes = new MeshLib::Node*[2]; MeshLib::Node** nodes = new MeshLib::Node*[2];
nodes[0] = new MeshLib::Node(a); for (int i = 0; i < points.size(); ++i)
nodes[1] = new MeshLib::Node(b); nodes[i] = new MeshLib::Node(points[i]);
MeshLib::Element* e = new MeshLib::Line(nodes); MeshLib::Element* e = new MeshLib::Line(nodes);
return std::unique_ptr<MeshLib::Mesh>( return std::unique_ptr<MeshLib::Mesh>(
new MeshLib::Mesh("", new MeshLib::Mesh("",
std::vector<MeshLib::Node*>{nodes[0], nodes[1]}, std::vector<MeshLib::Node*>{nodes[0], nodes[1]},
std::vector<MeshLib::Element*>{e}) std::vector<MeshLib::Element*>{e}));
);
}
std::unique_ptr<MeshLib::Mesh> createX()
{
return createLine({{-1.0, 0.0, 0.0}}, {{1.0, 0.0, 0.0}});
}
std::unique_ptr<MeshLib::Mesh> createY()
{
return createLine({{0.0, -1.0, 0.0}}, {{0.0, 1.0, 0.0}});
}
std::unique_ptr<MeshLib::Mesh> createXY()
{
// 45degree inclined
return createLine({{0.0, 0.0, 0.0}}, {{2./std::sqrt(2), 2./std::sqrt(2), 0.0}});
} }
const double eps = std::numeric_limits<double>::epsilon(); const double eps = std::numeric_limits<double>::epsilon();
...@@ -124,7 +107,7 @@ TEST(LIE, rotationMatrixYZTriangle) ...@@ -124,7 +107,7 @@ TEST(LIE, rotationMatrixYZTriangle)
TEST(LIE, rotationMatrixX) TEST(LIE, rotationMatrixX)
{ {
auto msh(createX()); auto msh = createLine({{{{-1.0, 0.0, 0.0}}, {{1.0, 0.0, 0.0}}}});
auto e(msh->getElement(0)); auto e(msh->getElement(0));
Eigen::Vector3d nv; Eigen::Vector3d nv;
ProcessLib::LIE::computeNormalVector(*e, 2, nv); ProcessLib::LIE::computeNormalVector(*e, 2, nv);
...@@ -143,7 +126,7 @@ TEST(LIE, rotationMatrixX) ...@@ -143,7 +126,7 @@ TEST(LIE, rotationMatrixX)
TEST(LIE, rotationMatrixY) TEST(LIE, rotationMatrixY)
{ {
auto msh(createY()); auto msh = createLine({{{{0.0, -1.0, 0.0}}, {{0.0, 1.0, 0.0}}}});
auto e(msh->getElement(0)); auto e(msh->getElement(0));
Eigen::Vector3d nv; Eigen::Vector3d nv;
ProcessLib::LIE::computeNormalVector(*e, 2, nv); ProcessLib::LIE::computeNormalVector(*e, 2, nv);
...@@ -162,7 +145,9 @@ TEST(LIE, rotationMatrixY) ...@@ -162,7 +145,9 @@ TEST(LIE, rotationMatrixY)
TEST(LIE, rotationMatrixXY) TEST(LIE, rotationMatrixXY)
{ {
auto msh(createXY()); // 45degree inclined
auto msh = createLine(
{{{{0.0, 0.0, 0.0}}, {{2. / std::sqrt(2), 2. / std::sqrt(2), 0.0}}}});
auto e(msh->getElement(0)); auto e(msh->getElement(0));
Eigen::Vector3d nv; Eigen::Vector3d nv;
ProcessLib::LIE::computeNormalVector(*e, 2, nv); ProcessLib::LIE::computeNormalVector(*e, 2, nv);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment