Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added element type class + implementation of linear line element

  • Loading branch information...
commit db55a8b353f537945769a6c42b8c45b2314e1187 1 parent 0d3c73a
@adrienhaxaire authored
Showing with 67 additions and 0 deletions.
  1. +67 −0 Numeric/Funfem/Elements.hs
View
67 Numeric/Funfem/Elements.hs
@@ -0,0 +1,67 @@
+----------------------------------------------------------------------------------
+-- |
+-- Module : Elements
+-- Copyright : (c) Adrien Haxaire 2012
+-- Licence : BSD3
+--
+-- Maintainer : Adrien Haxaire <adrien@funfem.org>
+-- Stability : experimental
+-- Portabilty : not tested
+--
+----------------------------------------------------------------------------------
+--
+
+module Numeric.Funfem.Elements where
+
+import qualified Data.Vector as V
+import qualified Data.Map as M
+
+import Numeric.Funfem.Algebra.Vector
+import Numeric.Funfem.Algebra.Matrix
+
+type Point = [Double]
+
+data Node = Node {coordinates :: Point, nodeNumber :: Int}
+ deriving (Eq, Ord, Show)
+
+type Material = M.Map String Double
+
+-- | Type class for an element.
+class Element a where
+ nodes :: a -> [Node]
+ material :: a -> Material
+ shape :: a -> [([Double] -> Double)]
+
+-- | Linear line element.
+data Lin2 = Lin2 {nodesLin2 :: [Node], matLin2 :: Material}
+ deriving (Eq, Ord, Show)
+
+coorsLin2 :: Lin2 -> [Double]
+coorsLin2 el = map (head . coordinates) $ nodesLin2 el
+
+lengthLin2 :: Lin2 -> Double
+lengthLin2 el = let [x1,x2] = coorsLin2 el in abs (x1 - x2)
+
+shapeLin2 :: Lin2 -> [([Double] -> Double)]
+shapeLin2 el = [f1, f2]
+ where
+ l = lengthLin2 el
+ f1 [x] = 1-x/l
+ f2 [x] = x/l
+
+instance Element Lin2 where
+ nodes = nodesLin2
+ material = matLin2
+ shape = shapeLin2
+
+
+
+
+
+{-
+n1 = Node [0.0] 1
+n2 = Node [1.0] 2
+mat = M.fromList [("conductivity", 1.0)]
+
+el1 = Lin2 [n1,n2] mat
+-}
Please sign in to comment.
Something went wrong with that request. Please try again.