Commit e661fd97 authored by JasonPries's avatar JasonPries
Browse files

Nightly Commit

Upgrades test of relative rotation motion using a SlidingInterface to include spatially varying excitation so that the motion is observable
parent 0c9df1d0
......@@ -96,7 +96,7 @@ public:
}
}
// TODO: SlidingInterface& opertor--() {...};
// TODO: SlidingInterface& operator--() {...};
void apply(std::vector<Eigen::Triplet<double>> &triplets) const override {
for(size_t i = 0; i!=Value.size();++i){
......
......@@ -960,10 +960,12 @@ public:
tri.push_back(Triangle<1>(4, 0_zu, 5_zu, 6_zu));
tri.push_back(Triangle<1>(5, 0_zu, 6_zu, 1_zu));
region_i = std::make_shared<Region<2>>(std::vector<size_t>{0, 1, 2, 3, 4, 5});
region_ip = std::make_shared<Region<2>>(std::vector<size_t>{0, 1, 2});
region_in = std::make_shared<Region<2>>(std::vector<size_t>{3, 4, 5});
boundary_io = std::make_shared<Boundary<2>>(std::vector<size_t>{1, 2, 3, 4, 5, 6});
reg.push_back(region_i);
reg.push_back(region_ip);
reg.push_back(region_in);
bnd.push_back(boundary_io);
// Outer Region
......@@ -1013,7 +1015,8 @@ public:
std::vector<std::shared_ptr<Region<2>>> reg;
std::vector<std::shared_ptr<Boundary<2>>> bnd;
std::shared_ptr<Region<2>> region_i;
std::shared_ptr<Region<2>> region_ip;
std::shared_ptr<Region<2>> region_in;
std::shared_ptr<Region<2>> region_o;
std::shared_ptr<Boundary<2>> boundary_io;
......@@ -1082,16 +1085,22 @@ public:
};
TEST_F(TwoRegionHexagonRotation, magnetostatic_forcing) {
// TODO: Test with spatially varying forcing condition instead
// Tests sliding interface condition for implementing virtual rotational motion
Magnetostatic<2, 1, 1, Variable::A> ms{femesh};
ms.time(0.0);
auto ff = [](double t) { return 1.0; };
auto f_positive = [](double t) { return 1.0; };
auto f_negative = [](double t) { return -1.0; };
ms.add_current_density(ff, {region_i});
ms.add_current_density(f_positive, {region_ip});
ms.add_current_density(f_negative, {region_in});
ms.add_magnetic_insulation({boundary_oo});
auto position = ms.add_sliding_interface(boundary_io->nodes(), boundary_oi->nodes(), std::vector<double>(6, 1.0), false);
std::vector<double> v_expected{0.0, 0.0, 1.15908e-7, 1.15908e-7, 0.0, -1.15908e-7, -1.15908e-7};
std::vector<double> b_mag_expected{1.33839e-7, 1.33839e-7, 1.33839e-7, 1.33839e-7, 1.33839e-7, 1.33839e-7, 1.26675e-7, 1.58333e-7, 1.02214e-7, 1.5833e-7, 1.26675e-7, 0.0, 1.26675e-7, 1.58333e-7, 1.02214e-7, 1.5833e-7, 1.26675e-7, 0.0};
std::vector<double> b_ang_expected{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 53.794, 150.0, 180.0, -150.0, -53.794, -90.0, 53.794, 150.0, 180.0, -150.0, -53.794, -90.0};
for (size_t iter = 0; iter != 6; ++iter) {
ms.build_matrices();
ms.apply_conditions();
......@@ -1110,12 +1119,6 @@ TEST_F(TwoRegionHexagonRotation, magnetostatic_forcing) {
ms.calculate_forcing(f);
double nodal_current{sqrt(3.0) / 4.0 / 3.0};
EXPECT_NEAR(f(0), nodal_current * 6.0, FLT_EPSILON);
for (size_t i = 1; i != 7; ++i) {
EXPECT_NEAR(f(i), nodal_current * 2.0, FLT_EPSILON);
}
ms.linearize(J, v, r, f, Fx, Fy, dFxdx, dFydy, dFxdy);
Eigen::SimplicialLDLT<Eigen::SparseMatrix<double>> ldlt;
......@@ -1130,9 +1133,8 @@ TEST_F(TwoRegionHexagonRotation, magnetostatic_forcing) {
}
// Fundamental solution is 0.25*r^2 + C in forced region (0)
EXPECT_NEAR(v(0), v(1) + 0.25 * mu_0, mu_0 * FLT_EPSILON);
for (size_t i = 1; i != 7; ++i) {
EXPECT_NEAR(v(1), v(i), FLT_EPSILON);
for (size_t i = 0; i != 7; ++i) {
EXPECT_NEAR(v(i), v_expected[i], FLT_EPSILON);
}
// Test flux-density values
......@@ -1145,9 +1147,23 @@ TEST_F(TwoRegionHexagonRotation, magnetostatic_forcing) {
for (size_t i = 0; i != By.size(); ++i) {
Bmag(i) = hypot(Bx(i), By(i));
Bang(i) = atan2(By(i), Bx(i)) * 180.0 / M_PI;
if (std::abs(Bang(i) + 180.0) < 0.01) {
Bang(i) += 180.0;
}
EXPECT_NEAR(Bmag(i), b_mag_expected[i], 1e-11);
EXPECT_NEAR(Bang(i), b_ang_expected[i], 1e-3);
}
test_flux_density_element_order_1(v, Bx, By, Bmag, Bang);
std::rotate(b_mag_expected.begin() + 6,b_mag_expected.end() - 2, b_mag_expected.end());
std::rotate(b_ang_expected.begin() + 6,b_ang_expected.end() - 2, b_ang_expected.end());
for (auto i = b_ang_expected.begin() + 6; i != b_ang_expected.end(); ++i) {
*i = std::fmod(*i + 60.0 + 180.0, 360.0) - 180.0;
if(std::abs(*i + 180) < 0.01) {
*i += 180.0;
}
}
++*position;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment