-- | The FunctionValues module contains the 'FunctionValues' type and
-- the functions used to manipulate it.
-module FunctionValues
+module FunctionValues (
+ FunctionValues,
+ empty_values,
+ eval,
+ make_values,
+ rotate,
+ function_values_tests,
+ value_at
+ )
where
import Prelude hiding (LT)
+import Test.HUnit
+import Test.Framework (Test, testGroup)
+import Test.Framework.Providers.HUnit (testCase)
import Test.QuickCheck (Arbitrary(..), choose)
-import Cardinal
+import Assertions (assertTrue)
+import Cardinal ( Cardinal(..) )
+import Examples (trilinear)
import Values (Values3D, dims, idx)
-- | The FunctionValues type represents the value of our function f at
back_right_down = eval fv (rotation BRD),
back_right_top = eval fv (rotation BRT),
interior = interior fv }
+
+
+
+-- | Ensure that the trilinear values wind up where we think they
+-- should.
+test_directions :: Assertion
+test_directions =
+ assertTrue "all direction functions work" (and equalities)
+ where
+ fvs = make_values trilinear 1 1 1
+ equalities = [ interior fvs == 4,
+ front fvs == 1,
+ back fvs == 7,
+ left fvs == 2,
+ right fvs == 6,
+ down fvs == 3,
+ top fvs == 5,
+ front_left fvs == 1,
+ front_right fvs == 1,
+ front_down fvs == 1,
+ front_top fvs == 1,
+ back_left fvs == 3,
+ back_right fvs == 11,
+ back_down fvs == 5,
+ back_top fvs == 9,
+ left_down fvs == 2,
+ left_top fvs == 2,
+ right_down fvs == 4,
+ right_top fvs == 8,
+ front_left_down fvs == 1,
+ front_left_top fvs == 1,
+ front_right_down fvs == 1,
+ front_right_top fvs == 1,
+ back_left_down fvs == 3,
+ back_left_top fvs == 3,
+ back_right_down fvs == 7,
+ back_right_top fvs == 15]
+
+
+function_values_tests :: Test.Framework.Test
+function_values_tests =
+ testGroup "FunctionValues Tests"
+ [ testCase "test directions" test_directions ]
import Cube hiding (i, j, k)
import FunctionValues
import Misc (all_equal, disjoint)
-import Tests.FunctionValues ()
import Tetrahedron (b0, b1, b2, b3, c, fv,
v0, v1, v2, v3, volume)
t0 = tetrahedron0 cube
t6 = tetrahedron6 cube
fvs = Tetrahedron.fv t0
- int = interior fvs
- f = front fvs
- r = right fvs
- l = left fvs
- b = back fvs
- ft = front_top fvs
- rt = right_top fvs
- lt = left_top fvs
- bt = back_top fvs
- t = top fvs
- d = down fvs
- fr = front_right fvs
- fl = front_left fvs
- br = back_right fvs
- bl = back_left fvs
- fd = front_down fvs
- rd = right_down fvs
- ld = left_down fvs
- bd = back_down fvs
+ (Cube _ i j k _ _) = cube
+ f = value_at fvs (i-1) j k
+ b = value_at fvs (i+1) j k
+ l = value_at fvs i (j-1) k
+ r = value_at fvs i (j+1) k
+ d = value_at fvs i j (k-1)
+ t = value_at fvs i j (k+1)
+ fl = value_at fvs (i-1) (j-1) k
+ fr = value_at fvs (i-1) (j+1) k
+ fd = value_at fvs (i-1) j (k-1)
+ ft = value_at fvs (i-1) j (k+1)
+ bl = value_at fvs (i+1) (j-1) k
+ br = value_at fvs (i+1) (j+1) k
+ bd = value_at fvs (i+1) j (k-1)
+ bt = value_at fvs (i+1) j (k+1)
+ ld = value_at fvs i (j-1) (k-1)
+ lt = value_at fvs i (j-1) (k+1)
+ rd = value_at fvs i (j+1) (k-1)
+ rt = value_at fvs i (j+1) (k+1)
+ fld = value_at fvs (i-1) (j-1) (k-1)
+ flt = value_at fvs (i-1) (j-1) (k+1)
+ frd = value_at fvs (i-1) (j+1) (k-1)
+ frt = value_at fvs (i-1) (j+1) (k+1)
+ bld = value_at fvs (i+1) (j-1) (k-1)
+ blt = value_at fvs (i+1) (j-1) (k+1)
+ brd = value_at fvs (i+1) (j+1) (k-1)
+ brt = value_at fvs (i+1) (j+1) (k+1)
+ int = value_at fvs i j k
+
-- Tests to check that the correct edges are incidental.
prop_t0_shares_edge_with_t1 :: Cube -> Bool
+++ /dev/null
-module Tests.FunctionValues
-where
-
-import Test.HUnit
-
-import Assertions
-import Examples
-import FunctionValues
-
-test_directions :: Assertion
-test_directions =
- assertTrue "all direction functions work" (and equalities)
- where
- fvs = make_values trilinear 1 1 1
- equalities = [ interior fvs == 4,
- front fvs == 1,
- back fvs == 7,
- left fvs == 2,
- right fvs == 6,
- down fvs == 3,
- top fvs == 5,
- front_left fvs == 1,
- front_right fvs == 1,
- front_down fvs == 1,
- front_top fvs == 1,
- back_left fvs == 3,
- back_right fvs == 11,
- back_down fvs == 5,
- back_top fvs == 9,
- left_down fvs == 2,
- left_top fvs == 2,
- right_down fvs == 4,
- right_top fvs == 8,
- front_left_down fvs == 1,
- front_left_top fvs == 1,
- front_right_down fvs == 1,
- front_right_top fvs == 1,
- back_left_down fvs == 3,
- back_left_top fvs == 3,
- back_right_down fvs == 7,
- back_right_top fvs == 15]
import Cardinal
import Comparisons
import FunctionValues
-import Tests.FunctionValues()
import Tetrahedron
import ThreeDimensional
import Test.HUnit
import Test.QuickCheck (Testable ())
+import FunctionValues (functionvalues_tests)
import Tests.Cardinal
import Tests.Cube as TC
-import Tests.FunctionValues
import Tests.Grid
import Tests.Misc
import Tests.Tetrahedron as TT
testGroup "Cardinal Tests" [
tc "c-tilde_2100 rotation correct" test_c_tilde_2100_rotation_correct ]
-function_values_tests :: Test.Framework.Test
-function_values_tests =
- testGroup "FunctionValues Tests" [ tc "test directions" test_directions ]
grid_tests :: Test.Framework.Test
grid_tests =