Commit 738c9440 authored by Liam M. Healy's avatar Liam M. Healy
Browse files

Fix computation of destination grid

Search map-n-grids to search the sources (first to last) for a model grid from which to define the destination, instead of using the first grid. Commit 17e1abc2 was an incorrect implementation; this commit fixes it so that grid:slice now works on pq-grids. A test has been added to grid-array-units to check for correct function.
parent d4ac81ab
;; Map and old grid to a new grid
;; Liam Healy 2009-11-15 18:05:16EST map.lisp
;; Time-stamp: <2013-03-09 10:40:13EST map.lisp>
;; Time-stamp: <2014-03-15 12:54:18EDT map.lisp>
;;
;; Copyright 2009, 2010, 2012 Liam M. Healy
;; Copyright 2009, 2010, 2012, 2013, 2014 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
;;
;; This program is free software: you can redistribute it and/or modify
......@@ -107,11 +107,12 @@
(make-destination
destination-affi
(or destination-specification
(alexandria:if-let
(source-grid (find (alexandria:compose #'gridp #'first) sources))
;; Find the first grid in the sources on which to model the destination grid
(specification source-grid)
(make-specification *default-grid-type* *default-dimensions* *default-element-type*)))
(let ((source-objs (mapcar #'first sources)))
(alexandria:if-let
(source-grid-pos (position-if #'gridp source-objs))
;; Find the first grid in the sources on which to model the destination grid
(specification (nth source-grid-pos source-objs))
(make-specification *default-grid-type* *default-dimensions* *default-element-type*))))
initial-element)))
(let* ((source-walkers
(mapcar (lambda (s) (affi:make-walker (second s))) sources))
......
;; Tests of physical quantities
;; Liam Healy 2011-01-09 17:38:41EST tests.lisp
;; Time-stamp: <2014-02-07 11:21:19EST physical-quantities-grid.lisp>
;; Time-stamp: <2014-03-15 12:53:26EDT physical-quantities-grid.lisp>
;; Copyright 2011, 2013, 2014 Liam M. Healy
;; Distributed under the terms of the GNU General Public License
......@@ -85,6 +85,15 @@
'meter)))))
(lisp-unit:define-test grid-array-units
(lisp-unit:assert-numerical-equal
;; see [[id:25d7e1e8-5adc-4433-b933-fb95069bc096][Search for default in sources instead of taking the first one]]
'(#_6.000000000000000d0_m #_5.000000000000000d0_m #_4.000000000000000d0_m)
(grid:contents
(grid:subgrid
(grid:make-foreign-array
'double-float
:initial-contents '(#_6.0_m #_5.0_m #_4_m #_3.0_m/s #_2.0_m/s #_1.0_m/s))
'(3) '(0))))
(lisp-unit:assert-true
;; An array with pqs as elements
(let ((grid #(#_1.0d0_m #_5.0d0_s)))
......@@ -145,7 +154,9 @@
(grid:make-foreign-array 'double-float
:dimensions '(4)
:initial-contents '(1.0d0 2.0d0 3.0d0 4.0d0))
#(meter meter second second))))
#(meter meter second second)))
)
#|
;;; Things that should be made to work.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment