(in-package :clf)

;; каркас ячейки

(defclass cell-base (cell-coordinates cell-size)
  ((convergence :initarg :convergence
		:initform 0.0
		:accessor convergence)
   (dimensions :initarg :dimensions
	       :accessor dimensions)
   (headers/cell-base :initform '(convergence)
		      :allocation :class)))

(make-header-for-class cell-base)

;; одномерная ячейка

(defclass cell1d-pv (primitive-variables cell-base)
  ((dimensions :initform 1
	       :accessor dimensions)
   (headers/cell1d-pv :initform '()
		      :allocation :class)))

(print-functions-for-class cell1d-pv 
			   ((inherit . cell-coordinates)
			    (inherit . primitive-variables)
			    (inherit . cell-size)
			    (inherit . cell-base)))

(defmethod make-dummy-cell ((type (eql 'cell1d-pv)))
  (make-instance type
		 :coord-vector (vector 'undef)
		 :size-vector (vector 'undef)
		 :number 'undef))

;; двумерная ячейка

(defclass cell2d-pv (primitive-variables cell-base)
  ((dimensions :initarg :dimensions
	       :initform 2
	       :accessor dimensions)
   (headers/cell2d-pv :initform '()
		      :allocation :class)))

(print-functions-for-class cell2d-pv 
			   ((inherit . cell-coordinates)
			    (inherit . primitive-variables)
			    (inherit . cell-size)
			    (inherit . cell-base)))


(defmethod make-dummy-cell ((type (eql 'cell2d-pv)))
  (make-instance type
		 :coord-vector (vector 'undef 'undef)
		 :size-vector (vector 'undef 'undef)
		 :number 'undef))

(defmethod clone ((cell cell2d-pv))
  (make-instance 'cell2d-pv
		 :coord-vector (coord-vector cell)
		 :size-vector (size-vector cell)
		 :P (P cell)
		 :phi (phi cell)
		 :ug (ug cell)
		 :ul (ul cell)
		 ))