How to get started
Complete source code
1 #include
2 #include
3
4 using concepts::Real;
5
6 int main(int argc, char** argv) {
7
8
9 concepts::Square mesh(1, 1, 1);
10
11
12 concepts::BoundaryConditions bc;
13 bc.add(concepts::Attribute(1),concepts::Boundary(concepts::Boundary::DIRICHLET));
14
15
16 uint levelOfRefinement = 2;
17 uint polynomialDegree = 6;
18 hp2D::hpAdaptiveSpaceH1 space(mesh,levelOfRefinement,polynomialDegree,&bc);
19 space.rebuild();
20
21
22 concepts::ParsedFormula<> f("((2*pi*pi+1)*sin(pi*x)*sin(pi*y))");
23 hp2D::Riesz<Real> lform(f);
24
25
26 concepts::Vector<Real> rhs(space, lform);
27
28
29 hp2D::Laplace<Real> la;
30 hp2D::Identity<Real> id;
31
32
33 concepts::SparseMatrix<Real> S(space, la);
34 concepts::SparseMatrix<Real> M(space, id);
35
36
37 M.addInto(S, 1.);
38
39
40 std::unique_ptr<concepts::Operator<Real> > solver(nullptr);
41 solver.reset(new concepts::CG<Real>(S, 1e-12, 400));
42 concepts::Vector<Real> sol(space);
43 (*solver)(rhs, sol);
44
45
46 hp2D::IntegrableQuad::factory().get()->setTensor(concepts::TRAPEZE, true, polynomialDegree);
47 space.recomputeShapefunctions();
48
49
50 graphics::MatlabBinaryGraphics mbg(space, "firstSolution");
51 mbg.addSolution(space, "u", sol);
52
53 return 0;
54 }
numa: Concepts/howToGetStarted (last edited 2020-07-08 08:55:34 by semin)