diff --git a/Apps/Common/Test/TestSIMNodalConstraint.C b/Apps/Common/Test/TestSIMNodalConstraint.C index 851f2d31..5609ea0b 100644 --- a/Apps/Common/Test/TestSIMNodalConstraint.C +++ b/Apps/Common/Test/TestSIMNodalConstraint.C @@ -30,16 +30,30 @@ auto&& check_mpc = [](MPC* mpc, int node) ASSERT_TRUE(mpc->getMaster(0).dof == 1); }; -TEST(TestSIMNodalConstraint, ASMs1DV1) + +class TestSIMNodalConstraint : public testing::Test, + public testing::WithParamInterface { +}; + + +TEST_P(TestSIMNodalConstraint, Vertex1D) +{ + if (GetParam() > 2) + return; + SIMNodalConstraint s({2}); - ASSERT_TRUE(s.read("refdata/nodal_1D_V1.xinp")); + std::stringstream str; + str << "refdata/nodal_1D_V" << GetParam() << ".xinp"; + ASSERT_TRUE(s.read(str.str().c_str())); s.preprocess(); const ASMbase& pch = *s.getPatch(1); for (size_t i=1; i <= pch.getNoNodes(); ++i) { - if (i == 1) + if (i == 1 && GetParam() == 1) check_mpc(pch.findMPC(i,1), pch.getNoNodes()); + else if (i == pch.getNoNodes() && GetParam() == 2) + check_mpc(pch.findMPC(i,1), 1); else ASSERT_TRUE(pch.findMPC(i, 1) == nullptr); ASSERT_TRUE(pch.findMPC(i, 2) == nullptr); @@ -47,53 +61,28 @@ TEST(TestSIMNodalConstraint, ASMs1DV1) } -TEST(TestSIMNodalConstraint, ASMs1DV2) +TEST_P(TestSIMNodalConstraint, Vertex2D) { - SIMNodalConstraint s({2}); - ASSERT_TRUE(s.read("refdata/nodal_1D_V2.xinp")); - s.preprocess(); + if (GetParam() > 4) + return; - const ASMbase& pch = *s.getPatch(1); - for (size_t i=1; i <= pch.getNoNodes(); ++i) { - if (i == pch.getNoNodes()) - check_mpc(pch.findMPC(i, 1), 1); - else - ASSERT_TRUE(pch.findMPC(i, 1) == nullptr); - ASSERT_TRUE(pch.findMPC(i, 2) == nullptr); - } -} - - -TEST(TestSIMNodalConstraint, ASMs2DV1) -{ SIMNodalConstraint s({2}); - ASSERT_TRUE(s.read("refdata/nodal_2D_V1.xinp")); + std::stringstream str; + str << "refdata/nodal_2D_V" << GetParam() << ".xinp"; + ASSERT_TRUE(s.read(str.str().c_str())); s.preprocess(); const ASMs2D& pch = static_cast(*s.getPatch(1)); int n1, n2; pch.getSize(n1,n2); for (size_t i=1; i <= pch.getNoNodes(); ++i) { - if (i == 1) + if (i == 1 && GetParam() == 1) check_mpc(pch.findMPC(i, 1), n1); - else - ASSERT_TRUE(pch.findMPC(i, 1) == nullptr); - ASSERT_TRUE(pch.findMPC(i, 2) == nullptr); - } -} - - -TEST(TestSIMNodalConstraint, ASMs2DV2) -{ - SIMNodalConstraint s({2}); - ASSERT_TRUE(s.read("refdata/nodal_2D_V2.xinp")); - s.preprocess(); - - const ASMs2D& pch = static_cast(*s.getPatch(1)); - int n1, n2; - pch.getSize(n1,n2); - for (size_t i=1; i <= pch.getNoNodes(); ++i) { - if (i == (size_t)n1) + else if (i == (size_t)n1 && GetParam() == 2) + check_mpc(pch.findMPC(i, 1), 1); + else if (i == (size_t)n1*(n2-1)+1 && GetParam() == 3) + check_mpc(pch.findMPC(i, 1), 1); + else if (i == pch.getNoNodes() && GetParam() == 4) check_mpc(pch.findMPC(i, 1), 1); else ASSERT_TRUE(pch.findMPC(i, 1) == nullptr); @@ -102,93 +91,29 @@ TEST(TestSIMNodalConstraint, ASMs2DV2) } -TEST(TestSIMNodalConstraint, ASMs2DV3) +TEST_P(TestSIMNodalConstraint, Edge2D) { + if (GetParam() > 4) + return; + SIMNodalConstraint s({2}); - ASSERT_TRUE(s.read("refdata/nodal_2D_V3.xinp")); + std::stringstream str; + str << "refdata/nodal_2D_E" << GetParam() << ".xinp"; + ASSERT_TRUE(s.read(str.str().c_str())); s.preprocess(); const ASMs2D& pch = static_cast(*s.getPatch(1)); int n1, n2; pch.getSize(n1,n2); for (size_t i=1; i <= pch.getNoNodes(); ++i) { - if (i == (size_t)n1*(n2-1)+1) - check_mpc(pch.findMPC(i, 1), 1); - else - ASSERT_TRUE(pch.findMPC(i, 1) == nullptr); - ASSERT_TRUE(pch.findMPC(i, 2) == nullptr); - } -} - - -TEST(TestSIMNodalConstraint, ASMs2DV4) -{ - SIMNodalConstraint s({2}); - ASSERT_TRUE(s.read("refdata/nodal_2D_V4.xinp")); - s.preprocess(); - - const ASMs2D& pch = static_cast(*s.getPatch(1)); - int n1, n2; - pch.getSize(n1,n2); - for (size_t i=1; i <= pch.getNoNodes(); ++i) { - if (i == pch.getNoNodes()) - check_mpc(pch.findMPC(i, 1), 1); - else - ASSERT_TRUE(pch.findMPC(i, 1) == nullptr); - ASSERT_TRUE(pch.findMPC(i, 2) == nullptr); - } -} - - -TEST(TestSIMNodalConstraint, ASMs2DE1) -{ - SIMNodalConstraint s({2}); - ASSERT_TRUE(s.read("refdata/nodal_2D_E1.xinp")); - s.preprocess(); - - const ASMs2D& pch = static_cast(*s.getPatch(1)); - int n1, n2; - pch.getSize(n1,n2); - for (size_t i=1; i <= pch.getNoNodes(); ++i) { - if (i % n1 == 1) + if (i % n1 == 1 && GetParam() == 1) check_mpc(pch.findMPC(i, 1), n1); - else - ASSERT_TRUE(pch.findMPC(i, 1) == nullptr); - ASSERT_TRUE(pch.findMPC(i, 2) == nullptr); - } -} - -TEST(TestSIMNodalConstraint, ASMs2DE2) -{ - SIMNodalConstraint s({2}); - ASSERT_TRUE(s.read("refdata/nodal_2D_E2.xinp")); - s.preprocess(); - - const ASMs2D& pch = static_cast(*s.getPatch(1)); - int n1, n2; - pch.getSize(n1,n2); - for (size_t i=1; i <= pch.getNoNodes(); ++i) { - if (i % n1 == 0) + else if (i % n1 == 0 && GetParam() == 2) check_mpc(pch.findMPC(i, 1), 1); - else - ASSERT_TRUE(pch.findMPC(i, 1) == nullptr); - ASSERT_TRUE(pch.findMPC(i, 2) == nullptr); - } -} - - -TEST(TestSIMNodalConstraint, ASMs2DE3) -{ - SIMNodalConstraint s({2}); - ASSERT_TRUE(s.read("refdata/nodal_2D_E3.xinp")); - s.preprocess(); - - const ASMs2D& pch = static_cast(*s.getPatch(1)); - int n1, n2; - pch.getSize(n1,n2); - for (size_t i=1; i <= pch.getNoNodes(); ++i) { - if (i <= (size_t)n1) + else if (i <= (size_t)n1 && GetParam() == 3) check_mpc(pch.findMPC(i, 1), n1*n2); + else if (i > (size_t)n1*(n2-1) && GetParam() == 4) + check_mpc(pch.findMPC(i, 1), 1); else ASSERT_TRUE(pch.findMPC(i, 1) == nullptr); ASSERT_TRUE(pch.findMPC(i, 2) == nullptr); @@ -196,206 +121,136 @@ TEST(TestSIMNodalConstraint, ASMs2DE3) } -TEST(TestSIMNodalConstraint, ASMs2DE4) +TEST_P(TestSIMNodalConstraint, Edge2Dmx) { - SIMNodalConstraint s({2}); - ASSERT_TRUE(s.read("refdata/nodal_2D_E4.xinp")); + if (GetParam() > 4) + return; + + SIMNodalConstraint s({2,2}); + std::stringstream str; + str << "refdata/nodal_2D_E" << GetParam() << "_mixed.xinp"; + ASSERT_TRUE(s.read(str.str().c_str())); s.preprocess(); const ASMs2D& pch = static_cast(*s.getPatch(1)); int n1, n2; - pch.getSize(n1,n2); - for (size_t i=1; i <= pch.getNoNodes(); ++i) { - if (i > (size_t)n1*(n2-1)) - check_mpc(pch.findMPC(i, 1), 1); - else - ASSERT_TRUE(pch.findMPC(i, 1) == nullptr); - ASSERT_TRUE(pch.findMPC(i, 2) == nullptr); - } -} - -#ifdef HAS_LRSPLINE -TEST(TestSIMNodalConstraint, ASMu2DV1) -{ - auto old = IFEM::getOptions().discretization; - IFEM::getOptions().discretization = ASM::LRSpline; - SIMNodalConstraint s({2}); - ASSERT_TRUE(s.read("refdata/nodal_2D_V1.xinp")); - s.preprocess(); - - const ASMu2D& pch = static_cast(*s.getPatch(1)); - for (size_t i=1; i <= pch.getNoNodes(); ++i) { - if (i == 1) - check_mpc(pch.findMPC(i, 1), pch.getCorner(1,-1,1)); - else - ASSERT_TRUE(pch.findMPC(i, 1) == nullptr); - ASSERT_TRUE(pch.findMPC(i, 2) == nullptr); - } - IFEM::getOptions().discretization = old; -} - - -TEST(TestSIMNodalConstraint, ASMu2DV2) -{ - auto old = IFEM::getOptions().discretization; - IFEM::getOptions().discretization = ASM::LRSpline; - SIMNodalConstraint s({2}); - ASSERT_TRUE(s.read("refdata/nodal_2D_V2.xinp")); - s.preprocess(); - - const ASMu2D& pch = static_cast(*s.getPatch(1)); - for (size_t i=1; i <= pch.getNoNodes(); ++i) { - if (i == (size_t)pch.getCorner(1,-1,1)) - check_mpc(pch.findMPC(i, 1), 1); - else - ASSERT_TRUE(pch.findMPC(i, 1) == nullptr); - ASSERT_TRUE(pch.findMPC(i, 2) == nullptr); - } - IFEM::getOptions().discretization = old; -} - - -TEST(TestSIMNodalConstraint, ASMu2DV3) -{ - auto old = IFEM::getOptions().discretization; - IFEM::getOptions().discretization = ASM::LRSpline; - SIMNodalConstraint s({2}); - ASSERT_TRUE(s.read("refdata/nodal_2D_V3.xinp")); - s.preprocess(); - - const ASMu2D& pch = static_cast(*s.getPatch(1)); - for (size_t i=1; i <= pch.getNoNodes(); ++i) { - if (i == (size_t)pch.getCorner(-1,1,1)) - check_mpc(pch.findMPC(i, 1), 1); - else - ASSERT_TRUE(pch.findMPC(i, 1) == nullptr); - ASSERT_TRUE(pch.findMPC(i, 2) == nullptr); - } - IFEM::getOptions().discretization = old; -} - - -TEST(TestSIMNodalConstraint, ASMu2DV4) -{ - auto old = IFEM::getOptions().discretization; - IFEM::getOptions().discretization = ASM::LRSpline; - SIMNodalConstraint s({2}); - ASSERT_TRUE(s.read("refdata/nodal_2D_V4.xinp")); - s.preprocess(); - - const ASMu2D& pch = static_cast(*s.getPatch(1)); - for (size_t i=1; i <= pch.getNoNodes(); ++i) { - if (i == (size_t)pch.getCorner(1,1,1)) - check_mpc(pch.findMPC(i, 1), 1); - else - ASSERT_TRUE(pch.findMPC(i, 1) == nullptr); - ASSERT_TRUE(pch.findMPC(i, 2) == nullptr); - } - IFEM::getOptions().discretization = old; -} - - -TEST(TestSIMNodalConstraint, ASMu2DE1) -{ - auto old = IFEM::getOptions().discretization; - IFEM::getOptions().discretization = ASM::LRSpline; - SIMNodalConstraint s({2}); - ASSERT_TRUE(s.read("refdata/nodal_2D_E1.xinp")); - s.preprocess(); - - const ASMu2D& pch = static_cast(*s.getPatch(1)); - auto nodes = pch.getEdgeNodes(LR::WEST, 1); - for (size_t i=1; i <= pch.getNoNodes(); ++i) { - if (std::find(nodes.begin(), nodes.end(), i) != nodes.end() && i != (size_t)pch.getCorner(1,-1,1)) - check_mpc(pch.findMPC(i, 1), pch.getCorner(1,-1,1)); - else - ASSERT_TRUE(pch.findMPC(i, 1) == nullptr); - ASSERT_TRUE(pch.findMPC(i, 2) == nullptr); - } - IFEM::getOptions().discretization = old; -} - -TEST(TestSIMNodalConstraint, ASMu2DE2) -{ - auto old = IFEM::getOptions().discretization; - IFEM::getOptions().discretization = ASM::LRSpline; - SIMNodalConstraint s({2}); - ASSERT_TRUE(s.read("refdata/nodal_2D_E2.xinp")); - s.preprocess(); - - const ASMu2D& pch = static_cast(*s.getPatch(1)); - auto nodes = pch.getEdgeNodes(LR::EAST, 1); - for (size_t i=1; i <= pch.getNoNodes(); ++i) { - if (std::find(nodes.begin(), nodes.end(), i) != nodes.end()) - check_mpc(pch.findMPC(i, 1), 1); - else - ASSERT_TRUE(pch.findMPC(i, 1) == nullptr); - ASSERT_TRUE(pch.findMPC(i, 2) == nullptr); - } - IFEM::getOptions().discretization = old; -} - - -TEST(TestSIMNodalConstraint, ASMu2DE3) -{ - auto old = IFEM::getOptions().discretization; - IFEM::getOptions().discretization = ASM::LRSpline; - SIMNodalConstraint s({2}); - ASSERT_TRUE(s.read("refdata/nodal_2D_E3.xinp")); - s.preprocess(); - - const ASMu2D& pch = static_cast(*s.getPatch(1)); - auto nodes = pch.getEdgeNodes(LR::SOUTH, 1); - for (size_t i=1; i <= pch.getNoNodes(); ++i) { - if (std::find(nodes.begin(), nodes.end(), i) != nodes.end()) - check_mpc(pch.findMPC(i, 1), pch.getCorner(1,1,1)); - else - ASSERT_TRUE(pch.findMPC(i, 1) == nullptr); - ASSERT_TRUE(pch.findMPC(i, 2) == nullptr); - } - IFEM::getOptions().discretization = old; -} - - -TEST(TestSIMNodalConstraint, ASMu2DE4) -{ - auto old = IFEM::getOptions().discretization; - IFEM::getOptions().discretization = ASM::LRSpline; - SIMNodalConstraint s({2}); - ASSERT_TRUE(s.read("refdata/nodal_2D_E4.xinp")); - s.preprocess(); - - const ASMu2D& pch = static_cast(*s.getPatch(1)); - auto nodes = pch.getEdgeNodes(LR::NORTH, 1); - for (size_t i=1; i <= pch.getNoNodes(); ++i) { - if (std::find(nodes.begin(), nodes.end(), i) != nodes.end()) - check_mpc(pch.findMPC(i, 1), 1); - else - ASSERT_TRUE(pch.findMPC(i, 1) == nullptr); - ASSERT_TRUE(pch.findMPC(i, 2) == nullptr); - } - IFEM::getOptions().discretization = old; -} - - -TEST(TestSIMNodalConstraint, ASMu2DmxE3) -{ - auto old = IFEM::getOptions().discretization; - IFEM::getOptions().discretization = ASM::LRSpline; - SIMNodalConstraint s({2,2}); - ASSERT_TRUE(s.read("refdata/nodal_2D_E3_mixed.xinp")); - s.preprocess(); - - const ASMu2D& pch = static_cast(*s.getPatch(1)); - auto nodes = pch.getEdgeNodes(LR::SOUTH, 2); + pch.getSize(n1,n2,2); size_t ofs = pch.getNoNodes(1); for (size_t i=1; i <= pch.getNoNodes(1); ++i) { ASSERT_TRUE(pch.findMPC(i, 1) == nullptr); ASSERT_TRUE(pch.findMPC(i, 2) == nullptr); } for (size_t i=1; i <= pch.getNoNodes(2); ++i) { - if (std::find(nodes.begin(), nodes.end(), i+ofs) != nodes.end()) + if (i % n1 == 1 && GetParam() == 1) + check_mpc(pch.findMPC(i+ofs, 1), n1+ofs); + else if (i % n1 == 0 && GetParam() == 2) + check_mpc(pch.findMPC(i+ofs, 1), 1+ofs); + else if (i <= (size_t)n1 && GetParam() == 3) + check_mpc(pch.findMPC(i+ofs, 1), n1*n2+ofs); + else if (i > (size_t)n1*(n2-1) && GetParam() == 4) + check_mpc(pch.findMPC(i+ofs, 1), 1+ofs); + else + ASSERT_TRUE(pch.findMPC(i+ofs, 1) == nullptr); + ASSERT_TRUE(pch.findMPC(i+ofs, 2) == nullptr); + } +} + + +#ifdef HAS_LRSPLINE +TEST_P(TestSIMNodalConstraint, Vertex2DLR) +{ + if (GetParam() > 4) + return; + + auto old = IFEM::getOptions().discretization; + IFEM::getOptions().discretization = ASM::LRSpline; + SIMNodalConstraint s({2}); + std::stringstream str; + str << "refdata/nodal_2D_V" << GetParam() << ".xinp"; + ASSERT_TRUE(s.read(str.str().c_str())); + s.preprocess(); + + const ASMu2D& pch = static_cast(*s.getPatch(1)); + for (size_t i=1; i <= pch.getNoNodes(); ++i) { + if (i == 1 && GetParam() == 1) + check_mpc(pch.findMPC(i, 1), pch.getCorner(1,-1,1)); + else if (i == (size_t)pch.getCorner(1,-1,1) && GetParam() == 2) + check_mpc(pch.findMPC(i, 1), 1); + else if (i == (size_t)pch.getCorner(-1,1,1) && GetParam() == 3) + check_mpc(pch.findMPC(i, 1), 1); + else if (i == (size_t)pch.getCorner(1,1,1) && GetParam() == 4) + check_mpc(pch.findMPC(i, 1), 1); + else + ASSERT_TRUE(pch.findMPC(i, 1) == nullptr); + ASSERT_TRUE(pch.findMPC(i, 2) == nullptr); + } + IFEM::getOptions().discretization = old; +} + + +TEST_P(TestSIMNodalConstraint, Edge2DLR) +{ + if (GetParam() > 4) + return; + + auto old = IFEM::getOptions().discretization; + IFEM::getOptions().discretization = ASM::LRSpline; + SIMNodalConstraint s({2}); + std::stringstream str; + str << "refdata/nodal_2D_E" << GetParam() << ".xinp"; + ASSERT_TRUE(s.read(str.str().c_str())); + s.preprocess(); + + const ASMu2D& pch = static_cast(*s.getPatch(1)); + static const std::vector E + {LR::WEST, LR::EAST, LR::SOUTH, LR::NORTH}; + auto nodes = pch.getEdgeNodes(E[GetParam()-1], 1); + for (size_t i=1; i <= pch.getNoNodes(); ++i) { + if (std::find(nodes.begin(), nodes.end(), i) != nodes.end() && + i != (size_t)pch.getCorner(1,-1,1) && GetParam() == 1) + check_mpc(pch.findMPC(i, 1), pch.getCorner(1,-1,1)); + else if (std::find(nodes.begin(), nodes.end(), i) != nodes.end() && GetParam() == 3) + check_mpc(pch.findMPC(i, 1), pch.getCorner(1,1,1)); + else if (std::find(nodes.begin(), nodes.end(), i) != nodes.end()) + check_mpc(pch.findMPC(i, 1), 1); + else + ASSERT_TRUE(pch.findMPC(i, 1) == nullptr); + ASSERT_TRUE(pch.findMPC(i, 2) == nullptr); + } + IFEM::getOptions().discretization = old; +} + + +TEST_P(TestSIMNodalConstraint, Edge2DLRmx) +{ + if (GetParam() > 4) + return; + + auto old = IFEM::getOptions().discretization; + IFEM::getOptions().discretization = ASM::LRSpline; + SIMNodalConstraint s({2,2}); + std::stringstream str; + str << "refdata/nodal_2D_E" << GetParam() << "_mixed.xinp"; + ASSERT_TRUE(s.read(str.str().c_str())); + s.preprocess(); + + const ASMu2D& pch = static_cast(*s.getPatch(1)); + static const std::vector E + {LR::WEST, LR::EAST, LR::SOUTH, LR::NORTH}; + auto nodes = pch.getEdgeNodes(E[GetParam()-1], 2); + size_t ofs = pch.getNoNodes(1); + for (size_t i=1; i <= pch.getNoNodes(1); ++i) { + ASSERT_TRUE(pch.findMPC(i, 1) == nullptr); + ASSERT_TRUE(pch.findMPC(i, 2) == nullptr); + } + for (size_t i=1; i <= pch.getNoNodes(2); ++i) { + if (std::find(nodes.begin(), nodes.end(), i+ofs) != nodes.end() && + i != ofs+pch.getCorner(1,-1,2) && GetParam() == 1) + check_mpc(pch.findMPC(i+ofs, 1), ofs+pch.getCorner(1,-1,2)); + else if (std::find(nodes.begin(), nodes.end(), i+ofs) != nodes.end() && GetParam() == 3) check_mpc(pch.findMPC(i+ofs, 1), ofs+pch.getCorner(1,1,2)); + else if (std::find(nodes.begin(), nodes.end(), i+ofs) != nodes.end()) + check_mpc(pch.findMPC(i+ofs, 1), ofs+1); else ASSERT_TRUE(pch.findMPC(i+ofs, 1) == nullptr); ASSERT_TRUE(pch.findMPC(i+ofs, 2) == nullptr); @@ -405,36 +260,30 @@ TEST(TestSIMNodalConstraint, ASMu2DmxE3) #endif -TEST(TestSIMNodalConstraint, ASMs3DV1) +TEST_P(TestSIMNodalConstraint, Vertex3D) { + if (GetParam() > 8) + return; + SIMNodalConstraint s({2}); - ASSERT_TRUE(s.read("refdata/nodal_3D_V1.xinp")); + std::stringstream str; + str << "refdata/nodal_3D_V" << GetParam() << ".xinp"; + ASSERT_TRUE(s.read(str.str().c_str())); s.preprocess(); const ASMs3D& pch = static_cast(*s.getPatch(1)); int n1, n2, n3; pch.getSize(n1,n2,n3); for (size_t i=1; i <= pch.getNoNodes(); ++i) { - if (i == 1) + if (i == 1 && GetParam() == 1) check_mpc(pch.findMPC(i, 1), n1); - else - ASSERT_TRUE(pch.findMPC(i, 1) == nullptr); - ASSERT_TRUE(pch.findMPC(i, 2) == nullptr); - } -} - - -TEST(TestSIMNodalConstraint, ASMs3DV2) -{ - SIMNodalConstraint s({2}); - ASSERT_TRUE(s.read("refdata/nodal_3D_V2.xinp")); - s.preprocess(); - - const ASMs3D& pch = static_cast(*s.getPatch(1)); - int n1, n2, n3; - pch.getSize(n1,n2,n3); - for (size_t i=1; i <= pch.getNoNodes(); ++i) { - if (i == (size_t)n1) + else if ((i == (size_t)n1 && GetParam() == 2) + || (i == (size_t)n1*(n2-1)+1 && GetParam() == 3) + || (i == (size_t)n1*n2 && GetParam() == 4) + || (i == (size_t)1+n1*n2*(n3-1) && GetParam() == 5) + || (i == (size_t)n1+n1*n2*(n3-1) && GetParam() == 6) + || (i == (size_t)1+n1*(n2-1)+n1*n2*(n3-1) && GetParam() == 7) + || (i == pch.getNoNodes() && GetParam() == 8)) check_mpc(pch.findMPC(i, 1), 1); else ASSERT_TRUE(pch.findMPC(i, 1) == nullptr); @@ -443,316 +292,42 @@ TEST(TestSIMNodalConstraint, ASMs3DV2) } -TEST(TestSIMNodalConstraint, ASMs3DV3) +TEST_P(TestSIMNodalConstraint, Edge3D) { SIMNodalConstraint s({2}); - ASSERT_TRUE(s.read("refdata/nodal_3D_V3.xinp")); + std::stringstream str; + str << "refdata/nodal_3D_E" << GetParam() << ".xinp"; + ASSERT_TRUE(s.read(str.str().c_str())); s.preprocess(); const ASMs3D& pch = static_cast(*s.getPatch(1)); int n1, n2, n3; pch.getSize(n1,n2,n3); for (size_t i=1; i <= pch.getNoNodes(); ++i) { - if (i == (size_t)n1*(n2-1)+1) - check_mpc(pch.findMPC(i, 1), 1); - else - ASSERT_TRUE(pch.findMPC(i, 1) == nullptr); - ASSERT_TRUE(pch.findMPC(i, 2) == nullptr); - } -} - - -TEST(TestSIMNodalConstraint, ASMs3DV4) -{ - SIMNodalConstraint s({2}); - ASSERT_TRUE(s.read("refdata/nodal_3D_V4.xinp")); - s.preprocess(); - - const ASMs3D& pch = static_cast(*s.getPatch(1)); - int n1, n2, n3; - pch.getSize(n1,n2,n3); - for (size_t i=1; i <= pch.getNoNodes(); ++i) { - if (i == (size_t)n1*n2) - check_mpc(pch.findMPC(i, 1), 1); - else - ASSERT_TRUE(pch.findMPC(i, 1) == nullptr); - ASSERT_TRUE(pch.findMPC(i, 2) == nullptr); - } -} - -TEST(TestSIMNodalConstraint, ASMs3DV5) -{ - SIMNodalConstraint s({2}); - ASSERT_TRUE(s.read("refdata/nodal_3D_V5.xinp")); - s.preprocess(); - - const ASMs3D& pch = static_cast(*s.getPatch(1)); - int n1, n2, n3; - pch.getSize(n1,n2,n3); - for (size_t i=1; i <= pch.getNoNodes(); ++i) { - if (i == (size_t)1+n1*n2*(n3-1)) - check_mpc(pch.findMPC(i, 1), 1); - else - ASSERT_TRUE(pch.findMPC(i, 1) == nullptr); - ASSERT_TRUE(pch.findMPC(i, 2) == nullptr); - } -} - - -TEST(TestSIMNodalConstraint, ASMs3DV6) -{ - SIMNodalConstraint s({2}); - ASSERT_TRUE(s.read("refdata/nodal_3D_V6.xinp")); - s.preprocess(); - - const ASMs3D& pch = static_cast(*s.getPatch(1)); - int n1, n2, n3; - pch.getSize(n1,n2,n3); - for (size_t i=1; i <= pch.getNoNodes(); ++i) { - if (i == (size_t)n1+n1*n2*(n3-1)) - check_mpc(pch.findMPC(i, 1), 1); - else - ASSERT_TRUE(pch.findMPC(i, 1) == nullptr); - ASSERT_TRUE(pch.findMPC(i, 2) == nullptr); - } -} - - -TEST(TestSIMNodalConstraint, ASMs3DV7) -{ - SIMNodalConstraint s({2}); - ASSERT_TRUE(s.read("refdata/nodal_3D_V7.xinp")); - s.preprocess(); - - const ASMs3D& pch = static_cast(*s.getPatch(1)); - int n1, n2, n3; - pch.getSize(n1,n2,n3); - for (size_t i=1; i <= pch.getNoNodes(); ++i) { - if (i == (size_t)1+n1*(n2-1)+n1*n2*(n3-1)) - check_mpc(pch.findMPC(i, 1), 1); - else - ASSERT_TRUE(pch.findMPC(i, 1) == nullptr); - ASSERT_TRUE(pch.findMPC(i, 2) == nullptr); - } -} - - -TEST(TestSIMNodalConstraint, ASMs3DV8) -{ - SIMNodalConstraint s({2}); - ASSERT_TRUE(s.read("refdata/nodal_3D_V8.xinp")); - s.preprocess(); - - const ASMs3D& pch = static_cast(*s.getPatch(1)); - int n1, n2, n3; - pch.getSize(n1,n2,n3); - for (size_t i=1; i <= pch.getNoNodes(); ++i) { - if (i == pch.getNoNodes()) - check_mpc(pch.findMPC(i, 1), 1); - else - ASSERT_TRUE(pch.findMPC(i, 1) == nullptr); - ASSERT_TRUE(pch.findMPC(i, 2) == nullptr); - } -} - - -TEST(TestSIMNodalConstraint, ASMs3DE1) -{ - SIMNodalConstraint s({2}); - ASSERT_TRUE(s.read("refdata/nodal_3D_E1.xinp")); - s.preprocess(); - - const ASMs3D& pch = static_cast(*s.getPatch(1)); - int n1, n2, n3; - pch.getSize(n1,n2,n3); - for (size_t i=1; i <= pch.getNoNodes(); ++i) { - if (i <= (size_t)n1) + if (i <= (size_t)n1 && GetParam() == 1) check_mpc(pch.findMPC(i, 1), n1*n2*n3); - else - ASSERT_TRUE(pch.findMPC(i, 1) == nullptr); - ASSERT_TRUE(pch.findMPC(i, 2) == nullptr); - } -} - - -TEST(TestSIMNodalConstraint, ASMs3DE2) -{ - SIMNodalConstraint s({2}); - ASSERT_TRUE(s.read("refdata/nodal_3D_E2.xinp")); - s.preprocess(); - - const ASMs3D& pch = static_cast(*s.getPatch(1)); - int n1, n2, n3; - pch.getSize(n1,n2,n3); - for (size_t i=1; i <= pch.getNoNodes(); ++i) { - if (i >= (size_t)n1*(n2-1)+1 && i <= (size_t)n1*n2) + else if (i >= (size_t)n1*(n2-1)+1 && i <= (size_t)n1*n2 && GetParam() == 2) check_mpc(pch.findMPC(i, 1), 1); - else - ASSERT_TRUE(pch.findMPC(i, 1) == nullptr); - ASSERT_TRUE(pch.findMPC(i, 2) == nullptr); - } -} - - -TEST(TestSIMNodalConstraint, ASMs3DE3) -{ - SIMNodalConstraint s({2}); - ASSERT_TRUE(s.read("refdata/nodal_3D_E3.xinp")); - s.preprocess(); - - const ASMs3D& pch = static_cast(*s.getPatch(1)); - int n1, n2, n3; - pch.getSize(n1,n2,n3); - for (size_t i=1; i <= pch.getNoNodes(); ++i) { - if (i >= (size_t)n1*n2*(n3-1)+1 && i <= (size_t)n1*n2*(n3-1)+n1) + else if (i >= (size_t)n1*n2*(n3-1)+1 && + i <= (size_t)n1*n2*(n3-1)+n1 && GetParam() == 3) check_mpc(pch.findMPC(i, 1), 1); - else - ASSERT_TRUE(pch.findMPC(i, 1) == nullptr); - ASSERT_TRUE(pch.findMPC(i, 2) == nullptr); - } -} - - -TEST(TestSIMNodalConstraint, ASMs3DE4) -{ - SIMNodalConstraint s({2}); - ASSERT_TRUE(s.read("refdata/nodal_3D_E4.xinp")); - s.preprocess(); - - const ASMs3D& pch = static_cast(*s.getPatch(1)); - int n1, n2, n3; - pch.getSize(n1,n2,n3); - for (size_t i=1; i <= pch.getNoNodes(); ++i) { - if (i >= (size_t)n1*n2*(n3-1)+n1*(n2-1)+1) + else if (i >= (size_t)n1*n2*(n3-1)+n1*(n2-1)+1 && GetParam() == 4) check_mpc(pch.findMPC(i, 1), 1); - else - ASSERT_TRUE(pch.findMPC(i, 1) == nullptr); - ASSERT_TRUE(pch.findMPC(i, 2) == nullptr); - } -} - - -TEST(TestSIMNodalConstraint, ASMs3DE5) -{ - SIMNodalConstraint s({2}); - ASSERT_TRUE(s.read("refdata/nodal_3D_E5.xinp")); - s.preprocess(); - - const ASMs3D& pch = static_cast(*s.getPatch(1)); - int n1, n2, n3; - pch.getSize(n1,n2,n3); - for (size_t i=1; i <= pch.getNoNodes(); ++i) { - if (i <= (size_t)n1*n2 && i % n2 == 1) + else if (i <= (size_t)n1*n2 && i % n2 == 1 && GetParam() == 5) check_mpc(pch.findMPC(i, 1), n1*n2*n3); - else - ASSERT_TRUE(pch.findMPC(i, 1) == nullptr); - ASSERT_TRUE(pch.findMPC(i, 2) == nullptr); - } -} - -TEST(TestSIMNodalConstraint, ASMs3DE6) -{ - SIMNodalConstraint s({2}); - ASSERT_TRUE(s.read("refdata/nodal_3D_E6.xinp")); - s.preprocess(); - - const ASMs3D& pch = static_cast(*s.getPatch(1)); - int n1, n2, n3; - pch.getSize(n1,n2,n3); - for (size_t i=1; i <= pch.getNoNodes(); ++i) { - if (i <= (size_t)n1*n2 && i % n2 == 0) + else if (i <= (size_t)n1*n2 && i % n2 == 0 && GetParam() == 6) check_mpc(pch.findMPC(i, 1), 1); - else - ASSERT_TRUE(pch.findMPC(i, 1) == nullptr); - ASSERT_TRUE(pch.findMPC(i, 2) == nullptr); - } -} - - -TEST(TestSIMNodalConstraint, ASMs3DE7) -{ - SIMNodalConstraint s({2}); - ASSERT_TRUE(s.read("refdata/nodal_3D_E7.xinp")); - s.preprocess(); - - const ASMs3D& pch = static_cast(*s.getPatch(1)); - int n1, n2, n3; - pch.getSize(n1,n2,n3); - for (size_t i=1; i <= pch.getNoNodes(); ++i) { - if (i >= (size_t)n1*n2*(n3-1)+1 && i % n2 == 1) + else if (i >= (size_t)n1*n2*(n3-1)+1 && i % n2 == 1 && GetParam() == 7) check_mpc(pch.findMPC(i, 1), 1); - else - ASSERT_TRUE(pch.findMPC(i, 1) == nullptr); - ASSERT_TRUE(pch.findMPC(i, 2) == nullptr); - } -} - - -TEST(TestSIMNodalConstraint, ASMs3DE8) -{ - SIMNodalConstraint s({2}); - ASSERT_TRUE(s.read("refdata/nodal_3D_E8.xinp")); - s.preprocess(); - - const ASMs3D& pch = static_cast(*s.getPatch(1)); - int n1, n2, n3; - pch.getSize(n1,n2,n3); - for (size_t i=1; i <= pch.getNoNodes(); ++i) { - if (i >= (size_t)n1*n2*(n3-1)+1 && i % n2 == 0) + else if (i >= (size_t)n1*n2*(n3-1)+1 && i % n2 == 0 && GetParam() == 8) check_mpc(pch.findMPC(i, 1), 1); - else - ASSERT_TRUE(pch.findMPC(i, 1) == nullptr); - ASSERT_TRUE(pch.findMPC(i, 2) == nullptr); - } -} - -TEST(TestSIMNodalConstraint, ASMs3DE9) -{ - SIMNodalConstraint s({2}); - ASSERT_TRUE(s.read("refdata/nodal_3D_E9.xinp")); - s.preprocess(); - - const ASMs3D& pch = static_cast(*s.getPatch(1)); - int n1, n2, n3; - pch.getSize(n1,n2,n3); - for (size_t i=1; i <= pch.getNoNodes(); ++i) { - if (i % (n1*n2) == 1) + else if (i % (n1*n2) == 1 && GetParam() == 9) check_mpc(pch.findMPC(i, 1), n1*n2*n3); - else - ASSERT_TRUE(pch.findMPC(i, 1) == nullptr); - ASSERT_TRUE(pch.findMPC(i, 2) == nullptr); - } -} - -TEST(TestSIMNodalConstraint, ASMs3DE10) -{ - SIMNodalConstraint s({2}); - ASSERT_TRUE(s.read("refdata/nodal_3D_E10.xinp")); - s.preprocess(); - - const ASMs3D& pch = static_cast(*s.getPatch(1)); - int n1, n2, n3; - pch.getSize(n1,n2,n3); - for (size_t i=1; i <= pch.getNoNodes(); ++i) { - if (i % (n1*n2) == (size_t)n1) + else if (i % (n1*n2) == (size_t)n1 && GetParam() == 10) check_mpc(pch.findMPC(i, 1), 1); - else - ASSERT_TRUE(pch.findMPC(i, 1) == nullptr); - ASSERT_TRUE(pch.findMPC(i, 2) == nullptr); - } -} - -TEST(TestSIMNodalConstraint, ASMs3DE11) -{ - SIMNodalConstraint s({2}); - ASSERT_TRUE(s.read("refdata/nodal_3D_E11.xinp")); - s.preprocess(); - - const ASMs3D& pch = static_cast(*s.getPatch(1)); - int n1, n2, n3; - pch.getSize(n1,n2,n3); - for (size_t i=1; i <= pch.getNoNodes(); ++i) { - if (i % (n1*n2) == (size_t)n1*(n2-1)+1) + else if (i % (n1*n2) == (size_t)n1*(n2-1)+1 && GetParam() == 11) + check_mpc(pch.findMPC(i, 1), 1); + else if (i % (n1*n2) == 0 && GetParam() == 12) check_mpc(pch.findMPC(i, 1), 1); else ASSERT_TRUE(pch.findMPC(i, 1) == nullptr); @@ -761,131 +336,32 @@ TEST(TestSIMNodalConstraint, ASMs3DE11) } -TEST(TestSIMNodalConstraint, ASMs3DE12) +TEST_P(TestSIMNodalConstraint, Face3D) { + if (GetParam() > 6) + return; + SIMNodalConstraint s({2}); - ASSERT_TRUE(s.read("refdata/nodal_3D_E12.xinp")); + std::stringstream str; + str << "refdata/nodal_3D_F" << GetParam() << ".xinp"; + ASSERT_TRUE(s.read(str.str().c_str())); s.preprocess(); const ASMs3D& pch = static_cast(*s.getPatch(1)); int n1, n2, n3; pch.getSize(n1,n2,n3); for (size_t i=1; i <= pch.getNoNodes(); ++i) { - if (i % (n1*n2) == 0) - check_mpc(pch.findMPC(i, 1), 1); - else - ASSERT_TRUE(pch.findMPC(i, 1) == nullptr); - ASSERT_TRUE(pch.findMPC(i, 2) == nullptr); - } -} - - -TEST(TestSIMNodalConstraint, ASMs3DF1) -{ - SIMNodalConstraint s({2}); - ASSERT_TRUE(s.read("refdata/nodal_3D_F1.xinp")); - s.preprocess(); - - const ASMs3D& pch = static_cast(*s.getPatch(1)); - int n1, n2, n3; - pch.getSize(n1,n2,n3); - for (size_t i=1; i <= pch.getNoNodes(); ++i) { - if (i % n1 == 1) + if (i % n1 == 1 && GetParam() == 1) check_mpc(pch.findMPC(i, 1), n1*n2*n3); - else - ASSERT_TRUE(pch.findMPC(i, 1) == nullptr); - ASSERT_TRUE(pch.findMPC(i, 2) == nullptr); - } -} - - -TEST(TestSIMNodalConstraint, ASMs3DF2) -{ - SIMNodalConstraint s({2}); - ASSERT_TRUE(s.read("refdata/nodal_3D_F2.xinp")); - s.preprocess(); - - const ASMs3D& pch = static_cast(*s.getPatch(1)); - int n1, n2, n3; - pch.getSize(n1,n2,n3); - for (size_t i=1; i <= pch.getNoNodes(); ++i) { - if (i % n1 == 0) + else if (i % n1 == 0 && GetParam() == 2) check_mpc(pch.findMPC(i, 1), 1); - else - ASSERT_TRUE(pch.findMPC(i, 1) == nullptr); - ASSERT_TRUE(pch.findMPC(i, 2) == nullptr); - } -} - - -TEST(TestSIMNodalConstraint, ASMs3DF3) -{ - SIMNodalConstraint s({2}); - ASSERT_TRUE(s.read("refdata/nodal_3D_F3.xinp")); - s.preprocess(); - - const ASMs3D& pch = static_cast(*s.getPatch(1)); - int n1, n2, n3; - pch.getSize(n1,n2,n3); - for (size_t i=1; i <= pch.getNoNodes(); ++i) { - if (i % (n1*n2) > 0 && i % (n1*n2) <= (size_t)n1) + else if (i % (n1*n2) > 0 && i % (n1*n2) <= (size_t)n1 && GetParam() == 3) check_mpc(pch.findMPC(i, 1), n1*n2*n3); - else - ASSERT_TRUE(pch.findMPC(i, 1) == nullptr); - ASSERT_TRUE(pch.findMPC(i, 2) == nullptr); - } -} - - -TEST(TestSIMNodalConstraint, ASMs3DF4) -{ - SIMNodalConstraint s({2}); - ASSERT_TRUE(s.read("refdata/nodal_3D_F4.xinp")); - s.preprocess(); - - const ASMs3D& pch = static_cast(*s.getPatch(1)); - int n1, n2, n3; - pch.getSize(n1,n2,n3); - for (size_t i=1; i <= pch.getNoNodes(); ++i) { - if (i % (n1*n2) >= (size_t)n1*(n2-1)+1 || i % (n1*n2) == 0) + else if ((i % (n1*n2) >= (size_t)n1*(n2-1)+1 || i % (n1*n2) == 0) && GetParam() == 4) check_mpc(pch.findMPC(i, 1), 1); - else - ASSERT_TRUE(pch.findMPC(i, 1) == nullptr); - ASSERT_TRUE(pch.findMPC(i, 2) == nullptr); - } -} - - -TEST(TestSIMNodalConstraint, ASMs3DF5) -{ - SIMNodalConstraint s({2}); - ASSERT_TRUE(s.read("refdata/nodal_3D_F5.xinp")); - s.preprocess(); - - const ASMs3D& pch = static_cast(*s.getPatch(1)); - int n1, n2, n3; - pch.getSize(n1,n2,n3); - for (size_t i=1; i <= pch.getNoNodes(); ++i) { - if (i <= (size_t)n1*n2) + else if (i <= (size_t)n1*n2 && GetParam() == 5) check_mpc(pch.findMPC(i, 1), n1*n2*n3); - else - ASSERT_TRUE(pch.findMPC(i, 1) == nullptr); - ASSERT_TRUE(pch.findMPC(i, 2) == nullptr); - } -} - - -TEST(TestSIMNodalConstraint, ASMs3DF6) -{ - SIMNodalConstraint s({2}); - ASSERT_TRUE(s.read("refdata/nodal_3D_F6.xinp")); - s.preprocess(); - - const ASMs3D& pch = static_cast(*s.getPatch(1)); - int n1, n2, n3; - pch.getSize(n1,n2,n3); - for (size_t i=1; i <= pch.getNoNodes(); ++i) { - if (i >= (size_t)n1*n2*(n3-1)+1) + else if (i >= (size_t)n1*n2*(n3-1)+1 && GetParam() == 6) check_mpc(pch.findMPC(i, 1), 1); else ASSERT_TRUE(pch.findMPC(i, 1) == nullptr); @@ -894,30 +370,6 @@ TEST(TestSIMNodalConstraint, ASMs3DF6) } -TEST(TestSIMNodalConstraint, ASMs2DmxE3) -{ - SIMNodalConstraint s({2,2}); - ASSERT_TRUE(s.read("refdata/nodal_2D_E3_mixed.xinp")); - s.preprocess(); - - const ASMs2Dmx& pch = static_cast(*s.getPatch(1)); - int n1, n2; - pch.getSize(n1,n2,2); - size_t ofs = pch.getNoNodes(1); - for (size_t i=1; i <= pch.getNoNodes(1); ++i) { - ASSERT_TRUE(pch.findMPC(i, 1) == nullptr); - ASSERT_TRUE(pch.findMPC(i, 2) == nullptr); - } - for (size_t i=1; i <= pch.getNoNodes(2); ++i) { - if (i <= (size_t)n1) - check_mpc(pch.findMPC(i+ofs, 1), ofs+n1*n2); - else - ASSERT_TRUE(pch.findMPC(i+ofs, 1) == nullptr); - ASSERT_TRUE(pch.findMPC(i+ofs, 2) == nullptr); - } -} - - TEST(TestSIMNodalConstraint, ASMs3DmxE3) { SIMNodalConstraint s({2,2}); @@ -940,3 +392,7 @@ TEST(TestSIMNodalConstraint, ASMs3DmxE3) ASSERT_TRUE(pch.findMPC(i+ofs, 2) == nullptr); } } + +const std::vector tests = {1,2,3,4,5,6,7,8,9,10,11,12}; +INSTANTIATE_TEST_CASE_P(TestSIMNodalConstraint, TestSIMNodalConstraint, + testing::ValuesIn(tests)); diff --git a/Apps/Common/Test/refdata/nodal_2D_E1_mixed.xinp b/Apps/Common/Test/refdata/nodal_2D_E1_mixed.xinp new file mode 100644 index 00000000..daa98357 --- /dev/null +++ b/Apps/Common/Test/refdata/nodal_2D_E1_mixed.xinp @@ -0,0 +1,13 @@ + + + + + + + 1 + + + + + + diff --git a/Apps/Common/Test/refdata/nodal_2D_E2_mixed.xinp b/Apps/Common/Test/refdata/nodal_2D_E2_mixed.xinp new file mode 100644 index 00000000..f1c93574 --- /dev/null +++ b/Apps/Common/Test/refdata/nodal_2D_E2_mixed.xinp @@ -0,0 +1,13 @@ + + + + + + + 2 + + + + + + diff --git a/Apps/Common/Test/refdata/nodal_2D_E4_mixed.xinp b/Apps/Common/Test/refdata/nodal_2D_E4_mixed.xinp new file mode 100644 index 00000000..649d6ed8 --- /dev/null +++ b/Apps/Common/Test/refdata/nodal_2D_E4_mixed.xinp @@ -0,0 +1,13 @@ + + + + + + + 4 + + + + + +