1 | ;------------------------------------------------------------ |
---|
2 | ;------------------------------------------------------------ |
---|
3 | ;------------------------------------------------------------ |
---|
4 | ;+ |
---|
5 | ; NAME:triangule_e |
---|
6 | ; |
---|
7 | ; PURPOSE:buid the triangulation for a E-grid type |
---|
8 | ; |
---|
9 | ; CATEGORY: |
---|
10 | ; |
---|
11 | ; CALLING SEQUENCE: |
---|
12 | ; |
---|
13 | ; INPUTS: |
---|
14 | ; |
---|
15 | ; KEYWORD PARAMETERS: |
---|
16 | ; |
---|
17 | ; OUTPUTS: |
---|
18 | ; |
---|
19 | ; COMMON BLOCKS:common.pro |
---|
20 | ; |
---|
21 | ; SIDE EFFECTS: |
---|
22 | ; |
---|
23 | ; RESTRICTIONS: |
---|
24 | ; |
---|
25 | ; EXAMPLE: |
---|
26 | ; |
---|
27 | ; MODIFICATION HISTORY:Sebastien Masson (smasson@lodyc.jussieu.fr) |
---|
28 | ; june 2001 |
---|
29 | ;- |
---|
30 | ;------------------------------------------------------------ |
---|
31 | ;------------------------------------------------------------ |
---|
32 | ;------------------------------------------------------------ |
---|
33 | FUNCTION triangule_e, maskentree, COINMONTE = coinmonte, COINDESCEND = coindescend $ |
---|
34 | , SHIFTED = shifted, REGULIER = regulier, PERIODIQUE = periodique |
---|
35 | tempsun = systime(1) ; pour key_performance |
---|
36 | @common |
---|
37 | ;; |
---|
38 | ;------------------------------------------------------------ |
---|
39 | ; le masque est donne ou il faut prendre tmask? |
---|
40 | ;------------------------------------------------------------ |
---|
41 | ; |
---|
42 | msk = maskentree |
---|
43 | sizem = size(msk) |
---|
44 | nx = sizem[1] |
---|
45 | ny = sizem[2] |
---|
46 | ;------------------------------------------------------------ |
---|
47 | if n_elements(periodique) EQ 0 then periodique = keyword_set(key_periodique) |
---|
48 | if keyword_set(key_periodique) and keyword_set(periodique) $ |
---|
49 | AND NOT keyword_set(regulier) then BEGIN |
---|
50 | msk = [msk, msk[0, *]] |
---|
51 | nx = nx+1 |
---|
52 | ENDIF |
---|
53 | ; |
---|
54 | ; we will find the diamond that must be cut in two triangle using the |
---|
55 | ; horizontal diagonal. |
---|
56 | ; |
---|
57 | index = lindgen(nx, ny) |
---|
58 | index = index[0:nx-2, 1:ny-2] |
---|
59 | if n_elements(shifted) EQ 0 then shifted = 1 |
---|
60 | oddeven = (index/nx+1-shifted) MOD 2 |
---|
61 | msk1 = msk[index] |
---|
62 | msk2 = msk[index+1] |
---|
63 | sum = msk[index-nx+oddeven]+msk[index+nx+oddeven] |
---|
64 | sum1 = msk2+sum |
---|
65 | sum2 = msk1+sum |
---|
66 | ; |
---|
67 | ; horizontal |
---|
68 | ; |
---|
69 | singularpoint = where((msk1 EQ 0 AND sum1 EQ 3) OR (msk1 EQ 1 AND sum1 EQ 0) $ |
---|
70 | OR (msk2 EQ 0 AND sum2 EQ 3) OR (msk2 EQ 1 AND sum2 EQ 0) $ |
---|
71 | OR (sum EQ 0 AND (msk1+msk2) EQ 2) ) |
---|
72 | if singularpoint[0] NE -1 then begin |
---|
73 | horizontal = index[singularpoint] |
---|
74 | triang = definetri_e(nx, ny, horizontal, SHIFTED = shifted) |
---|
75 | ENDIF ELSE triang = definetri_e(nx, ny, SHIFTED = shifted) |
---|
76 | ; coinmont = index[where(sum EQ 2 AND (msk1+msk2) EQ 0)] |
---|
77 | ; coindesc = index[where(sum EQ 0 AND (msk1+msk2) EQ 2)] |
---|
78 | ; |
---|
79 | ; we keep only the triangles which are outside the land |
---|
80 | ; but for some reasons we will in fact delete the land diamond |
---|
81 | ; |
---|
82 | ; allrecinland = where(sum1+msk1 EQ 0) |
---|
83 | ; indexallinland = index[allrecinland] |
---|
84 | ; otherrec = (lindgen(nx, ny))[0:nx-2, 1:ny-2] |
---|
85 | ; otherrec = different(otherrec, indexallinland) |
---|
86 | ; ; |
---|
87 | ; index = lindgen(nx, ny) |
---|
88 | ; index = index[0:nx-3, 2:ny-3] |
---|
89 | ; out = inter(index, indexallinland) |
---|
90 | ; IF out[0] NE -1 THEN begin |
---|
91 | ; out = inter(out+1, indexallinland) |
---|
92 | ; IF out[0] NE -1 THEN begin |
---|
93 | ; out = out-1 |
---|
94 | ; oddeven = (out/nx+1-shifted) MOD 2 |
---|
95 | ; out = inter(out-nx+oddeven, otherrec) |
---|
96 | ; IF out[0] NE -1 THEN begin |
---|
97 | ; out = inter(out+2*nx, otherrec) |
---|
98 | ; IF out[0] NE -1 THEN begin |
---|
99 | ; out = out-(nx+((out/nx+shifted) MOD 2)) |
---|
100 | ; endif |
---|
101 | ; endif |
---|
102 | ; endif |
---|
103 | ; ENDIF |
---|
104 | ; help, out |
---|
105 | ; ; |
---|
106 | ; index = lindgen(nx, ny) |
---|
107 | ; index = index[0:nx-3, 2:ny-3] |
---|
108 | ; out = inter(index, otherrec) |
---|
109 | ; IF out[0] NE -1 THEN begin |
---|
110 | ; out = inter(out+1, otherrec) |
---|
111 | ; IF out[0] NE -1 THEN begin |
---|
112 | ; out = out-1 |
---|
113 | ; oddeven = (out/nx+1-shifted) MOD 2 |
---|
114 | ; out = inter(out-nx+oddeven, indexallinland) |
---|
115 | ; IF out[0] NE -1 THEN begin |
---|
116 | ; out = inter(out+2*nx, indexallinland) |
---|
117 | ; IF out[0] NE -1 THEN begin |
---|
118 | ; out = out-(nx+((out/nx+shifted) MOD 2)) |
---|
119 | ; endif |
---|
120 | ; endif |
---|
121 | ; endif |
---|
122 | ; endif |
---|
123 | ; help, out |
---|
124 | ; ; |
---|
125 | ; IF out[0] EQ -1 THEN out = different(indexallinland, out) ELSE out = indexallinland |
---|
126 | ; triout = numtri(out, nx, ny) |
---|
127 | ; triout = [triout, triout+1] |
---|
128 | ; goodtri = lindgen(2*(nx-1)*(ny-1)) |
---|
129 | ; goodtri = different(goodtri, triout) |
---|
130 | ; triang = triang[*, temporary(goodtri)] |
---|
131 | |
---|
132 | ; ; |
---|
133 | ;------------------------------------------------------------ |
---|
134 | ; quand key_periodique eq 1, triang est une liste d''indice d'un |
---|
135 | ; tableau qui a une colonne de trop. |
---|
136 | ; il faut ramener ca a la matrice initiale en mettant les indivces de |
---|
137 | ; la derniere colonne egaux a ceux de la derniere colonne... |
---|
138 | ;------------------------------------------------------------ |
---|
139 | tempdeux = systime(1) ; pour key_performance =2 |
---|
140 | if keyword_set(key_periodique) and keyword_set(periodique) $ |
---|
141 | AND NOT keyword_set(regulier) then BEGIN |
---|
142 | indicey = triang/nx |
---|
143 | indicex = triang-indicey*nx |
---|
144 | nx = nx-1 |
---|
145 | liste = where(indicex EQ nx) |
---|
146 | if liste[0] NE -1 then indicex[liste] = 0 |
---|
147 | triang = indicex+nx*indicey |
---|
148 | nx = nx+1 |
---|
149 | ; if coinmont[0] NE -1 then begin |
---|
150 | ; indicey = coinmont/nx |
---|
151 | ; indicex = coinmont-indicey*nx |
---|
152 | ; nx = nx-1 |
---|
153 | ; liste = where(indicex EQ nx) |
---|
154 | ; if liste[0] NE -1 THEN indicex[liste] = 0 |
---|
155 | ; coinmont = indicex+nx*indicey |
---|
156 | ; nx = nx+1 |
---|
157 | ; endif |
---|
158 | ; if coindesc[0] NE -1 then begin |
---|
159 | ; indicey = coindesc/nx |
---|
160 | ; indicex = coindesc-indicey*nx |
---|
161 | ; nx = nx-1 |
---|
162 | ; liste = where(indicex EQ nx) |
---|
163 | ; if liste[0] NE -1 THEN indicex[liste] = 0 |
---|
164 | ; coindesc = indicex+nx*indicey |
---|
165 | ; nx = nx+1 |
---|
166 | ; endif |
---|
167 | endif |
---|
168 | IF testvar(var = key_performance) EQ 2 THEN $ |
---|
169 | print, 'temps triangule: finitions', systime(1)-tempdeux |
---|
170 | |
---|
171 | ;------------------------------------------------------------ |
---|
172 | ; if arg_present(coinmonte) THEN coinmonte = coinmont ELSE cointerremont = coinmont |
---|
173 | ; if arg_present(coindescend) THEN coindescend = coindesc ELSE cointerredesc = coindesc |
---|
174 | ; |
---|
175 | ; |
---|
176 | ;------------------------------------------------------------ |
---|
177 | |
---|
178 | |
---|
179 | IF keyword_set(key_performance) THEN print, 'temps triangule', systime(1)-tempsun |
---|
180 | |
---|
181 | return, triang |
---|
182 | |
---|
183 | END |
---|