1 -- Glasow Haskell 0.403 : FINITE ELEMENT PROGRAM V2 2 -- ********************************************************************** 3 -- * * 4 -- * FILE NAME : degrees.hs DATE : 13-3-1991 * 5 -- * * 6 -- * CONTENTS : Computes the degree numbers of each node. * 7 -- * * 8 -- * CHANGES : * 9 -- * 1. Mon Mar 11 10:28:10 GMT 1991 * 10 -- * Add new function degreesrlt for debug use. * 11 -- ********************************************************************** 12 13 module Degrees( ndgrs, getndgr, degreesrlt ) where 14 15 import Array 16 import Basics 17 import Vector 18 import DB_interface 19 20 ndgrs :: (Array Int Int, Array Int Float) -> Int 21 -- Return the total number of degrees 22 23 getndgr :: (Array Int Int, Array Int Float) -> Int -> [Int] 24 -- Return the degree numbers of a node (U, V and THETA) 25 26 ndgrs s = 27 fst (ndgrs_and_dgrsn s) 28 29 getndgr s node = 30 [u,v,theta] 31 where 32 u = dgrsn_s ! index 33 v = dgrsn_s ! (index + 1) 34 theta = dgrsn_s ! (index + 2) 35 dgrsn_s = dgrsn s 36 index = (node-1) * 3 + 1 37 38 dgrsn :: (Array Int Int, Array Int Float) -> Array Int Int 39 40 dgrsn s = listArray (1, (nnode s)*3) (snd (ndgrs_and_dgrsn s)) 41 42 ndgrs_and_dgrsn :: (Array Int Int, Array Int Float) -> (Int,[Int]) 43 44 ndgrs_and_dgrsn s = 45 foldl counting_one_node_s (0,[]) [1..(nnode s)] 46 where 47 counting_one_node_s = counting_one_node s 48 49 counting_one_node s (ndgrs_till_now,dgrsn_till_now) i = 50 (ndgrs_till_now + ndgrs_this_node, dgrsn_till_now ++ dgrsn_this_node) 51 where 52 dof = [ fod j | j <- [2,1,0]] 53 fod j = if (mod (div bc (e_10 j)) 10 == 1) then 54 1 55 else 0 56 e_10 j = if (j == 0) then (1::Int) else 10 * (e_10 (j-1)) 57 ndgrs_this_node = sum dof 58 dgrsn_this_node = [g j | j <- [0,1,2]] 59 g j = if ( (dof!!j) == 0 ) then 60 0 61 else 62 sum (take (j+1) dof) + ndgrs_till_now 63 bc = getnbc s i 64 65 66 degreesrlt :: (Array Int Int, Array Int Float) -> [Char] 67 68 degreesrlt s = 69 "DEGREE INFORMATION :\n\n" ++ 70 "\t Total degree numbers = " ++ showlj 4 (ndgrs s) ++ "\n\n" ++ 71 (concat ( map a_node_s [1..(nnode s)] )) ++ "\n\n" 72 where 73 a_node_s = a_node s 74 75 a_node s node = 76 " Node.no = " ++ (showrj 2 node) ++ 77 " u = " ++ (showrj 8 u) ++ " v = " ++ (showrj 8 v) ++ 78 " theta=" ++ (showrj 8 theta) ++ 79 " bc = " ++ ( showrj 3 bc) ++ "\n" 80 where 81 bc = getnbc s node 82 [u,v,theta] = getndgr s node 83 84