-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.cpp
More file actions
67 lines (49 loc) · 1.64 KB
/
Copy pathapp.cpp
File metadata and controls
67 lines (49 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <proxpde/def.hpp>
#include <proxpde/assembly.hpp>
#include <proxpde/bc.hpp>
#include <proxpde/builder.hpp>
#include <proxpde/fe.hpp>
#include <proxpde/fespace.hpp>
#include <proxpde/iomanager.hpp>
#include <proxpde/mesh.hpp>
int main()
{
using namespace proxpde;
using Elem_T = Quad;
using Mesh_T = Mesh<Elem_T>;
using FESpace_T = FESpace<
Mesh_T,
LagrangeFE<Elem_T, 1>::RefFE_T,
LagrangeFE<Elem_T, 1>::RecommendedQR>;
auto const rhs = [](Vec3 const & p) { return M_PI * std::sin(M_PI * p(0)); };
auto const exactSol = [](Vec3 const & p)
{ return std::sin(M_PI * p(0)) / M_PI + p(0); };
uint const numElemsX = 20U;
uint const numElemsY = 20U;
Vec3 const origin{0.0, 0.0, 0.0};
Vec3 const length{1.0, 1.0, 0.0};
std::unique_ptr<Mesh_T> mesh{new Mesh_T};
buildHyperCube(*mesh, origin, length, {numElemsX, numElemsY, 0U});
FESpace_T feSpace{*mesh};
auto bc = BCEss{feSpace, side::LEFT};
bc << [](Vec3 const &) { return 0.0; };
AssemblyStiffness stiffness{1.0, feSpace};
AssemblyRhsAnalytic f{rhs, feSpace};
Builder builder{feSpace.dof.size};
builder.buildLhs(std::tuple{stiffness}, std::vector{bc});
builder.buildRhs(std::tuple{f}, std::vector{bc});
builder.closeMatrix();
Var sol{"u"};
LUSolver solver;
solver.analyzePattern(builder.A);
solver.factorize(builder.A);
sol.data = solver.solve(builder.b);
Var exact{"exact"};
interpolateAnalyticFunction(exactSol, feSpace, exact.data);
Var error{"error"};
error.data = sol.data - exact.data;
fmt::print("error: {}\n", error.data.norm());
IOManager io{feSpace, "output/sol"};
io.print({sol, exact, error});
return 0;
}