test_Mesh_to_FEM.cpp 1.56 KB
Newer Older
JasonPries's avatar
JasonPries committed
1 2 3 4 5 6 7 8 9
#include "test_Library_Integration.hpp"

class Library_Integration_Circle : public ::testing::Test {
public:
    virtual void SetUp() {
        sk = Sketch();

        auto v0 = sk.new_element<Vertex>(0.0,0.0);
        auto v1 = sk.new_element<Vertex>(1.0,0.0);
10 11
        auto v2 = sk.new_element<Vertex>(1.0 * std::cos(M_PI * 2.0 / 3.0), 1.0 * std::sin(M_PI * 2.0 / 3.0));
        auto v3 = sk.new_element<Vertex>(1.0 * std::cos(-M_PI * 2.0 / 3.0), 1.0 * std::sin(-M_PI * 2.0 / 3.0));
JasonPries's avatar
JasonPries committed
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50

        auto c0 = sk.new_element<CircularArc>(v1,v2,v0,1.0);
        auto c1 = sk.new_element<CircularArc>(v2,v3,v0,1.0);
        auto c2 = sk.new_element<CircularArc>(v3,v1,v0,1.0);

        auto f0 = sk.new_element<Fixation>(v0);
        auto f1 = sk.new_element<Fixation>(v1);
        auto f2 = sk.new_element<Fixation>(v2);
        auto f3 = sk.new_element<Fixation>(v3);

        double_t tol = sk.solve();
        EXPECT_LE(tol, FLT_EPSILON);

        bool result = sk.build();
        EXPECT_TRUE(result);

        EXPECT_EQ(sk.size_contours(),1);
    }

    Sketch sk;

    std::string save_dir = "./test/output/Integration/";
};

TEST_F(Library_Integration_Circle, Uniform_Current_Density) {
    sk.save_as<SaveMethod::Rasterize>(save_dir, std::string("circle_sketch"));

    Mesh me{sk};
    me.create();

    me.MinimumElementSize = 0.01;
    me.MaximumElementSize = 0.1;
    me.MinimumElementQuality = 0.5;

    me.refine();

    me.save_as(save_dir, std::string("circle_mesh"));


51 52 53
    FiniteElementMesh<2, 1> fem{me}; // TODO: Convert refineable mesh to FiniteElementMesh

    std::cout << std::endl;
JasonPries's avatar
JasonPries committed
54
}