;  Facts assertted by Polyflow must be defined in a template file..
;  Each fact must have a (Stage) facet of type integer.
; TEMPLATE DEFINITIONS for the general rules (and QA).

(deftemplate Solver
   (slot Itmax (type INTEGER) (default 0) )
   (slot Type (type SYMBOL) )
   (slot Influence (type SYMBOL) )
   (slot Index (type INTEGER) (default 0) )
   (slot Name (type STRING))
   (multislot ProblemName (type STRING))
   (slot Converg (type FLOAT))
   (slot Diverg (type FLOAT))
   (slot Stage (type INTEGER) (default 0))
)

(deftemplate SolverMemory
   (slot SubDomains (type INTEGER) (default 1))
   (slot PrecisionBuffer (type SYMBOL) (allowed-symbols Single Double))
   (slot PrecisionSchur (type SYMBOL) (allowed-symbols Single Double))
   (slot Blas (type INTEGER) (allowed-integers 1 2 3))
   (slot BlocSize (type INTEGER))
   (slot Buffering (type SYMBOL) (allowed-symbols CoreMemory OnDisk))
   (slot BeforeElimination (type FLOAT) )
   (slot FactorizedMatrix (type FLOAT))
   (slot SchurComplement (type FLOAT))
   (slot WorkVector (type FLOAT))
   (slot ActiveMatrix(type FLOAT))
   (slot Swap (type FLOAT))
   (slot Disk (type FLOAT))
   (slot RAM (type FLOAT))
   (slot EliminationCost (type FLOAT))
   (slot Stage (type INTEGER) (default 0))
 )

(deftemplate SolverVariables
   (slot Active (type INTEGER))
   (slot Static (type INTEGER))
   (slot Stage (type INTEGER) (default 0))
 )

(deftemplate EndSolver
   (slot Niter (type INTEGER) (default 0) )
   (slot Status (type SYMBOL) 
                (allowed-symbols Convergence Divergence DiagUnsafe Unknown)
                (default Unknown)
    )
   (slot Stage (type INTEGER) (default 0))
 )

(deftemplate BeginIteration
   (slot Iter (type INTEGER) (default 0) )
   (slot Stage (type INTEGER) (default 0))
 )

(deftemplate EndIteration
   (slot Iter (type INTEGER) (default 0))
   (slot CPU (type FLOAT))
   (slot Elapsed (type FLOAT))
   (slot Stage (type INTEGER) (default 0))
   (slot SecantIter (type INTEGER) (default 0))
 )

(deftemplate LinAlgrebra
   (slot PMin (type FLOAT))
   (slot PMax (type FLOAT))
   (slot Sign (type INTEGER))
   (slot LogDet (type FLOAT))
   (slot Iter (type INTEGER) (default 0) )
   (slot Stage (type INTEGER) (default 0))
 )
(deftemplate LinAlgrebraSTR
   (slot PMin (type STRING))
   (slot PMax (type STRING))
   (slot Sign (type INTEGER))
   (slot LogDet (type STRING))
   (slot Iter (type INTEGER) (default 0) )
   (slot Stage (type INTEGER) (default 0))
 )
(deftemplate Cotest
   (slot Field (type SYMBOL) )
   (slot PflId (type INTEGER) )
   (slot Check (type SYMBOL) )
   (slot Incr (type FLOAT) )
   (slot Value (type FLOAT) )
   (slot Rhs  (type FLOAT) )
   (slot Iter (type INTEGER) (default 0) )
   (slot SecantIter (type INTEGER) (default 0) )
   (slot Stage (type INTEGER) (default 0))
 )
(deftemplate CotestSTR
   (slot Field (type SYMBOL) )
   (slot PflId (type INTEGER) )
   (slot Check (type SYMBOL) )
   (slot Incr (type STRING) )
   (slot Value (type STRING) )
   (slot Rhs  (type STRING) )
   (slot Iter (type INTEGER) (default 0) )
   (slot SecantIter (type INTEGER) (default 0) )
   (slot Stage (type INTEGER) (default 0))
 )

(deftemplate LocalValue
   (slot Sigle (type SYMBOL) )
   (slot Min (type FLOAT))
   (slot MinElementLocation (type INTEGER))
   (multislot MinCoordLocation (type FLOAT))
   (slot Max (type FLOAT))
   (slot MaxElementLocation (type INTEGER))
   (multislot MaxCoordLocation (type FLOAT))
   (slot Mid (type FLOAT))
   (slot Sde (type FLOAT))
   (slot Iter (type INTEGER) (default 0) )
   (slot Stage (type INTEGER) (default 0))
)
(deftemplate LocalValueSTR
   (slot Sigle (type SYMBOL) )
   (slot Min (type STRING))
   (slot MinElementLocation (type INTEGER))
   (multislot MinCoordLocation (type FLOAT))
   (slot Max (type STRING))
   (slot MaxElementLocation (type INTEGER))
   (multislot MaxCoordLocation (type FLOAT))
   (slot Mid (type STRING))
   (slot Sde (type STRING))
   (slot Iter (type INTEGER) (default 0) )
   (slot Stage (type INTEGER) (default 0))
)

(deftemplate ZeroPivot
   (slot Variable (type STRING))
   (slot Stage (type INTEGER) (default 0))
)

(deftemplate TotalNumberOfIterations 
   (slot NIter (type INTEGER) (default 0))
   (slot Stage (type INTEGER) (default 0))
 )


(deftemplate NaNOccursAtIteration 
   (slot Iteration (type INTEGER) (default 0))
   (slot Stage (type INTEGER) (default 0))
 )
