]> gitweb.michael.orlitzky.com - numerical-analysis.git/blob - examples/fem1.hs
Add a FEM.R1 example (should be moved into the tree after being cleaned up).
[numerical-analysis.git] / examples / fem1.hs
1 module Main
2 where
3
4 import FEM.R1
5 import Linear.Matrix hiding ((*))
6 import Naturals
7 import Piecewise
8
9 big_A' :: Double -> Double
10 big_A' = const 1
11
12 c' :: Double -> Double
13 c' x = sin x
14
15 f' :: Double -> Double
16 f' x = x*(sin x)
17
18 bdy' :: BoundaryConditions Double
19 bdy' = Left (Dirichlet (0,1))
20
21
22 pde' :: PDE Double
23 pde' = PDE big_A' c' f' bdy'
24
25 mesh' :: Col4 (Double,Double)
26 mesh' = fromList [[(0.0,1/3)],
27 [(1/3,2/3)],
28 [(2/3,4/5)],
29 [(4/5,1.0)]]
30
31 pvec' :: Col4 Int
32 pvec' = fromList [[2],[3],[2],[1]]
33
34 params' :: Params N4 N3 N7 Double
35 params' = Params mesh' pvec'
36
37
38 soln :: Piecewise Double
39 soln = solution pde' params'