Browse code

Тест на скачке: газовая среда

Dmitrii Kashin authored on 19/05/2015 03:52:56
Showing 2 changed files
... ...
@@ -78,9 +78,9 @@
78 78
 	   ))
79 79
 
80 80
     (when (>= *debug-level* 10)
81
-	     (format t "10: final grid~%")
82
-	     (print-grid newgrid :print-out-border t)
83
-	     (format t "----~%~%"))
81
+      (format t "10: final grid~%")
82
+      (print-grid newgrid :print-out-border t)
83
+      (format t "----~%~%"))
84 84
     
85 85
     ;; по завершении маршевой функции возвращаем последнюю полученную сетку
86 86
     grid
... ...
@@ -1,7 +1,14 @@
1 1
 (in-package :clf)
2 2
 
3
-(defun test-kt-constant (&key (cells-nx 2) (cells-ny 1) (cu 1) (output-dir #P"~/prog/clfpv/test-KT-constant/"))
4
-  "Тест на постоянном поле"
3
+(defun kt-dbg (level text grid)
4
+  (when (>= *debug-level* level)
5
+    (format t "~a: ~%" text)
6
+    (print-grid grid :print-out-border nil)
7
+    (format t "----~%~%")))
8
+
9
+(defun test-kt-constant (&key (cells-nx 10) (cells-ny 1) (cu 1) (output-dir #P"~/prog/clfpv/test-KT-constant/"))
10
+  "Тест на постоянном поле. Он нужен в основном для того, чтобы
11
+проверить консервативность схемы, а также для дебага программы."
5 12
   (ensure-directories-exist output-dir)
6 13
   (let ((*DEFAULT-PATHNAME-DEFAULTS* output-dir))
7 14
     (let ((grid (make-instance 'grid2d-cv
... ...
@@ -11,12 +18,7 @@
11 11
 			       :right-boundary-condition 'zeroe
12 12
 			       :bottom-boundary-condition 'zeroe
13 13
 			       :top-boundary-condition 'zeroe)))
14
-
15
-      (when (>= *debug-level* 10)
16
-	(format t "1: ~%")
17
-	(print-grid grid :print-out-border t)
18
-	(format t "----~%~%"))
19
-
14
+      (kt-dbg 10 "1" grid)
20 15
       (init-grid grid
21 16
 		 :left-border-coord 0.0d0
22 17
 		 :right-border-coord 1.0d0
... ...
@@ -24,54 +26,74 @@
24 24
 		 :bottom-border-line (constant-function 0.0d0)
25 25
 		 :thickening-coef-x 1
26 26
 		 :thickening-coef-y 1)
27
-
28
-      (when (>= *debug-level* 10)
29
-	(format t "2: ~%")
30
-	(print-grid grid :print-out-border t)
31
-	(format t "----~%~%"))
32
-
27
+      (kt-dbg 10 "2" grid)
33 28
       (set-constant-field-2d grid
34 29
 			     (make-instance 'conservative-variables
35 30
 					    :phi 0.999999d0
36 31
 					    :P 100000.0d0
37 32
 					    :ug 25.0d0
38 33
 					    :ul 25.0d0))
39
-
40
-      (when (>= *debug-level* 10)
41
-	(format t "3: ~%")
42
-	(print-grid grid :print-out-border t)
43
-	(format t "----~%~%"))
44
-
34
+      (kt-dbg 10 "3" grid)
45 35
       (update-boundary-cells grid)
46
-
47
-      (when (>= *debug-level* 10)
48
-	(format t "4.1: ~%")
49
-	(print-grid grid :print-out-border t)
50
-	(format t "----~%~%"))
51
-      
52
-      ;;(update-gradients grid)
53
-
54
-      (when (>= *debug-level* 10)
55
-	(format t "4.2: ~%")
56
-	(print-grid grid :print-out-border t)
57
-	(format t "----~%~%"))
58
-
59
-
60
-      (when (>= *debug-level* 3)
61
-	(format t "start-grid: ~%")
62
-	(print-grid grid :print-out-border t)
63
-	(format t "----~%~%"))
64
-      
36
+      (kt-dbg 10 "4" grid)
37
+      (kt-dbg 3 "start-grid" grid)
65 38
       (let ((newgrid (march grid
66 39
 			    :finish-step 10
67 40
 			    :cu cu
68 41
 			    )))
69
-
70
-	(when (>= *debug-level* 3)
71
-	  (format t "final-grid: ~%")
72
-	  (print-grid newgrid :print-out-border t)
73
-	  (format t "----~%~%"))
74
-	
42
+	(kt-dbg 3 "final-grid" newgrid)
75 43
 	newgrid
76 44
 	))))
77 45
 
46
+(defun test-kt-split-1 (&key (cells-nx 100) (cells-ny 1) (cu 1) (output-dir #P"~/prog/clfpv/test-kt-split-1/"))
47
+  "Тест на скачке. В данном тесте значение phi близко к 1, а это
48
+значит, что решение должно быть почти таким же, как в газе."
49
+  (ensure-directories-exist output-dir)
50
+  (let ((*DEFAULT-PATHNAME-DEFAULTS* output-dir))
51
+    (let ((grid (make-instance 'grid2d-cv
52
+			       :cells-amount-x cells-nx
53
+			       :cells-amount-y cells-ny
54
+			       :left-boundary-condition 'zeroe
55
+			       :right-boundary-condition 'zeroe
56
+			       :bottom-boundary-condition 'zeroe
57
+			       :top-boundary-condition 'zeroe)))
58
+      (kt-dbg 10 "1 (instance)" grid)
59
+      (init-grid grid
60
+		 :left-border-coord 0.0d0
61
+		 :right-border-coord 1.0d0
62
+		 :top-border-line (constant-function 1.0d0)
63
+		 :bottom-border-line (constant-function 0.0d0)
64
+		 :thickening-coef-x 1
65
+		 :thickening-coef-y 1)
66
+      (kt-dbg 10 "2 (init-grid)" grid)
67
+      (let* ((left-vars (make-instance 'primitive-variables
68
+				       :phi 0.999999
69
+				       :rg 1.0
70
+				       :ug 400.0
71
+				       :ul 400.0))
72
+	     (right-vars (make-instance 'primitive-variables
73
+					:phi (phi left-vars)
74
+					:ug (/ (* *sos* *sos*)
75
+					       (* *kappa* (ug left-vars)))
76
+					:ul (/ (* *sos* *sos*)
77
+					       (* *kappa* (ul left-vars)))
78
+					:rg (/ (* (rg left-vars) (ug left-vars))
79
+					       ;; на ug справа
80
+					       (/ (* *sos* *sos*)
81
+						  (* *kappa* (ug left-vars)))))))
82
+	(set-splitted-field-2d-x grid
83
+				 :left-vars left-vars
84
+				 :right-vars right-vars))
85
+      (kt-dbg 10 "3 (set-field)" grid)
86
+      (update-boundary-cells grid)
87
+      (kt-dbg 10 "4 (boundaries)" grid)
88
+      (kt-dbg 3 "start-grid" grid)
89
+      (let ((newgrid (march grid
90
+			    :finish-step 1000
91
+			    :output-every-step 50
92
+			    :cu cu
93
+			    )))
94
+	(kt-dbg 3 "final-grid" newgrid)
95
+	newgrid
96
+	)
97
+      )))