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, BASIC = basic |
---|
35 | ;--------------------------------------------------------- |
---|
36 | ; |
---|
37 | compile_opt idl2, strictarrsubs |
---|
38 | ; |
---|
39 | @cm_4mesh |
---|
40 | IF NOT keyword_set(key_forgetold) THEN BEGIN |
---|
41 | @updatenew |
---|
42 | ENDIF |
---|
43 | ;--------------------------------------------------------- |
---|
44 | tempsun = systime(1) ; pour key_performance |
---|
45 | ;------------------------------------------------------------ |
---|
46 | ; le masque est donne ou il faut prendre tmask? |
---|
47 | ;------------------------------------------------------------ |
---|
48 | ; |
---|
49 | msk = maskentree |
---|
50 | sizem = size(msk) |
---|
51 | nx = sizem[1] |
---|
52 | ny = sizem[2] |
---|
53 | ;------------------------------------------------------------ |
---|
54 | if keyword_set(key_periodic)*(nx EQ jpi) $ |
---|
55 | AND NOT keyword_set(basic) then BEGIN |
---|
56 | msk = [msk, msk[0, *]] |
---|
57 | nx = nx+1 |
---|
58 | ENDIF |
---|
59 | ; |
---|
60 | ; we will find the diamond that must be cut in two triangle using the |
---|
61 | ; horizontal diagonal. |
---|
62 | ; |
---|
63 | index = lindgen(nx, ny) |
---|
64 | index = index[0:nx-2, 1:ny-2] |
---|
65 | if n_elements(shifted) EQ 0 then shifted = 1 |
---|
66 | oddeven = (index/nx+1-shifted) MOD 2 |
---|
67 | msk1 = msk[index] |
---|
68 | msk2 = msk[index+1] |
---|
69 | sum = msk[index-nx+oddeven]+msk[index+nx+oddeven] |
---|
70 | sum1 = msk2+sum |
---|
71 | sum2 = msk1+sum |
---|
72 | ; |
---|
73 | ; horizontal |
---|
74 | ; |
---|
75 | singularpoint = where((msk1 EQ 0 AND sum1 EQ 3) OR (msk1 EQ 1 AND sum1 EQ 0) $ |
---|
76 | OR (msk2 EQ 0 AND sum2 EQ 3) OR (msk2 EQ 1 AND sum2 EQ 0) $ |
---|
77 | OR (sum EQ 0 AND (msk1+msk2) EQ 2) ) |
---|
78 | if singularpoint[0] NE -1 then begin |
---|
79 | horizontal = index[singularpoint] |
---|
80 | triang = definetri_e(nx, ny, horizontal, SHIFTED = shifted) |
---|
81 | ENDIF ELSE triang = definetri_e(nx, ny, SHIFTED = shifted) |
---|
82 | ; coinmont = index[where(sum EQ 2 AND (msk1+msk2) EQ 0)] |
---|
83 | ; coindesc = index[where(sum EQ 0 AND (msk1+msk2) EQ 2)] |
---|
84 | ; |
---|
85 | ; we keep only the triangles which are outside the land |
---|
86 | ; but for some reasons we will in fact delete the land diamond |
---|
87 | ; |
---|
88 | ; allrecinland = where(sum1+msk1 EQ 0) |
---|
89 | ; indexallinland = index[allrecinland] |
---|
90 | ; otherrec = (lindgen(nx, ny))[0:nx-2, 1:ny-2] |
---|
91 | ; otherrec = different(otherrec, indexallinland) |
---|
92 | ; ; |
---|
93 | ; index = lindgen(nx, ny) |
---|
94 | ; index = index[0:nx-3, 2:ny-3] |
---|
95 | ; out = inter(index, indexallinland) |
---|
96 | ; IF out[0] NE -1 THEN begin |
---|
97 | ; out = inter(out+1, indexallinland) |
---|
98 | ; IF out[0] NE -1 THEN begin |
---|
99 | ; out = out-1 |
---|
100 | ; oddeven = (out/nx+1-shifted) MOD 2 |
---|
101 | ; out = inter(out-nx+oddeven, otherrec) |
---|
102 | ; IF out[0] NE -1 THEN begin |
---|
103 | ; out = inter(out+2*nx, otherrec) |
---|
104 | ; IF out[0] NE -1 THEN begin |
---|
105 | ; out = out-(nx+((out/nx+shifted) MOD 2)) |
---|
106 | ; endif |
---|
107 | ; endif |
---|
108 | ; endif |
---|
109 | ; ENDIF |
---|
110 | ; help, out |
---|
111 | ; ; |
---|
112 | ; index = lindgen(nx, ny) |
---|
113 | ; index = index[0:nx-3, 2:ny-3] |
---|
114 | ; out = inter(index, otherrec) |
---|
115 | ; IF out[0] NE -1 THEN begin |
---|
116 | ; out = inter(out+1, otherrec) |
---|
117 | ; IF out[0] NE -1 THEN begin |
---|
118 | ; out = out-1 |
---|
119 | ; oddeven = (out/nx+1-shifted) MOD 2 |
---|
120 | ; out = inter(out-nx+oddeven, indexallinland) |
---|
121 | ; IF out[0] NE -1 THEN begin |
---|
122 | ; out = inter(out+2*nx, indexallinland) |
---|
123 | ; IF out[0] NE -1 THEN begin |
---|
124 | ; out = out-(nx+((out/nx+shifted) MOD 2)) |
---|
125 | ; endif |
---|
126 | ; endif |
---|
127 | ; endif |
---|
128 | ; endif |
---|
129 | ; help, out |
---|
130 | ; ; |
---|
131 | ; IF out[0] EQ -1 THEN out = different(indexallinland, out) ELSE out = indexallinland |
---|
132 | ; triout = numtri(out, nx, ny) |
---|
133 | ; triout = [triout, triout+1] |
---|
134 | ; goodtri = lindgen(2*(nx-1)*(ny-1)) |
---|
135 | ; goodtri = different(goodtri, triout) |
---|
136 | ; triang = triang[*, temporary(goodtri)] |
---|
137 | |
---|
138 | ; ; |
---|
139 | ;------------------------------------------------------------ |
---|
140 | ; quand key_periodic eq 1, triang est une liste d''indice d'un |
---|
141 | ; tableau qui a une colonne de trop. |
---|
142 | ; il faut ramener ca a la matrice initiale en mettant les indivces de |
---|
143 | ; la derniere colonne egaux a ceux de la derniere colonne... |
---|
144 | ;------------------------------------------------------------ |
---|
145 | tempdeux = systime(1) ; pour key_performance =2 |
---|
146 | if keyword_set(key_periodic)*(nx-1 EQ jpi) $ |
---|
147 | AND NOT keyword_set(basic) then BEGIN |
---|
148 | indicey = triang/nx |
---|
149 | indicex = triang-indicey*nx |
---|
150 | nx = nx-1 |
---|
151 | liste = where(indicex EQ nx) |
---|
152 | if liste[0] NE -1 then indicex[liste] = 0 |
---|
153 | triang = indicex+nx*indicey |
---|
154 | nx = nx+1 |
---|
155 | ; if coinmont[0] NE -1 then begin |
---|
156 | ; indicey = coinmont/nx |
---|
157 | ; indicex = coinmont-indicey*nx |
---|
158 | ; nx = nx-1 |
---|
159 | ; liste = where(indicex EQ nx) |
---|
160 | ; if liste[0] NE -1 THEN indicex[liste] = 0 |
---|
161 | ; coinmont = indicex+nx*indicey |
---|
162 | ; nx = nx+1 |
---|
163 | ; endif |
---|
164 | ; if coindesc[0] NE -1 then begin |
---|
165 | ; indicey = coindesc/nx |
---|
166 | ; indicex = coindesc-indicey*nx |
---|
167 | ; nx = nx-1 |
---|
168 | ; liste = where(indicex EQ nx) |
---|
169 | ; if liste[0] NE -1 THEN indicex[liste] = 0 |
---|
170 | ; coindesc = indicex+nx*indicey |
---|
171 | ; nx = nx+1 |
---|
172 | ; endif |
---|
173 | endif |
---|
174 | IF testvar(var = key_performance) EQ 2 THEN $ |
---|
175 | print, 'temps triangule: finitions', systime(1)-tempdeux |
---|
176 | |
---|
177 | ;------------------------------------------------------------ |
---|
178 | ; if arg_present(coinmonte) THEN coinmonte = coinmont ELSE twin_corners_up = coinmont |
---|
179 | ; if arg_present(coindescend) THEN coindescend = coindesc ELSE twin_corners_dn = coindesc |
---|
180 | ; |
---|
181 | ; IF NOT keyword_set(key_forgetold) THEN BEGIN |
---|
182 | ; @updateold |
---|
183 | ; ENDIF |
---|
184 | ;------------------------------------------------------------ |
---|
185 | |
---|
186 | |
---|
187 | IF keyword_set(key_performance) THEN print, 'temps triangule', systime(1)-tempsun |
---|
188 | |
---|
189 | return, triang |
---|
190 | |
---|
191 | END |
---|