diff base/charm/methods.lisp @ 253:b5ffec94ae6d

some very sketchy Charm constituent code
author Jamie Forth <j.forth@gold.ac.uk>
date Thu, 24 Feb 2011 11:23:18 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/base/charm/methods.lisp	Thu Feb 24 11:23:18 2011 +0000
@@ -0,0 +1,91 @@
+(cl:in-package #:amuse-charm)
+
+;;;=====================================================================
+;;; identifiers
+;;;=====================================================================
+
+(defmethod id ((o constituent-identifier))
+  (constituent-id o))
+
+(defmethod id ((o constituent))
+  (constituent-id (identifier o)))
+
+(defmethod id ((o event-identifier))
+  (event-id o))
+
+(defmethod id ((o event))
+  (event-id o))
+
+(defmethod id ((o composition-identifier))
+  (composition-id o))
+
+(defmethod id ((o composition))
+  (composition-id o))
+
+
+;;;=====================================================================
+;;; Specialised constructors
+;;;=====================================================================
+
+(defmethod make-charm-parent-identifier ((implementation
+					  (eql *package*)) id)
+  "A Charm constituent parent in this context is just another Charm
+constituent, i.e. a constituent has been defined which as a subset of
+another (parent) constituent."
+  (make-charm-constituent-identifier id))
+
+(defmethod make-charm-parent-identifier ((implementation
+					  (eql (find-package
+						"AMUSE-GEERDES"))) id)
+  "FIXME: This should be in amuse-geerdes"
+  (amuse-geerdes::g-id-file-id id))
+
+(defmethod make-charm-particle-identifier ((impl-package
+					    (eql *package*)) id)
+  "A CHARM particle in this context is just another CHARM constituent,
+i.e. a constituent has been defined which is the union of other
+previously defined constituents."
+  (make-charm-constituent-identifier id))
+
+(defmethod make-charm-particle-identifier ((impl-package
+					    (eql (find-package
+						  "AMUSE-GEERDES")))
+					   id)
+  "FIXME: This should be in amuse-geerdes"
+  (amuse-geerdes::make-geerdes-event-identifier id))
+
+;; (defmethod get-charm-particles (constituent-identifier ids
+;; 				(parent amuse-geerdes::composition))
+;;   "FIXME: This should be in amuse-geerdes"
+;;   (amuse-geerdes::select-events-by-ids parent ids))
+
+(defmethod get-charm-parent ((constituent-identifier
+			      amuse-geerdes::constituent-identifier))
+  (amuse-geerdes::get-composition constituent-identifier))
+
+;; (defmethod %cache-charm-particles ((impl-package (eql *package*))
+;; 				   constituent)
+;;   "hierarchy of constituents not yet implemented!")
+
+;; (defmethod %cache-charm-particles ((impl-package (eql (find-package
+;; 						       "AMUSE-GEERDES")))
+;; 				   constituent)
+;;   "FIXME: This should be in amuse-geerdes. This relies on identifier
+;; and particles being in the same order! Better to have generic
+;; functions within each implementation that can take a list of event
+;; identifiers and return a list of events from the database? Or maybe
+;; better still to make compositions proper CHARM constituents so that we
+;; can use 'make-sequence-like'?"
+;;   (let ((composition (amuse-geerdes::get-composition
+;; 		      (parent-identifier constituent))))
+;;     (loop with events = (%list-slot-sequence-data composition)
+;;        for identifier in (%list-slot-sequence-data constituent)
+;;        for event = (loop for events-head on events
+;; 		      until (eq (event-id (car events-head))
+;; 				(event-id identifier))
+;; 		      finally (progn (setf events events-head)
+;; 				     (return (car events-head))))
+;;        collect event into cached-events
+;;        finally (progn (setf (particle-cache constituent)
+;; 			    cached-events)
+;; 		      (return constituent)))))