43#include "implicit_f.inc"
52 INTEGER,
INTENT(INOUT) :: NTG, NTGI
53 INTEGER,
DIMENSION(NUMNOD),
INTENT(IN) :: ITAB
57 INTEGER(8) :: EDGE_PTR, PAIR_VEC_PTR, GRAPH_PTR, LIST_PTR
58 INTEGER :: II, JJ, KK, IDX, NEDGE
59 INTEGER,
DIMENSION(:),
ALLOCATABLE :: , EDGE_ARRAY_N2,
60 . EDGE_ARRAY_ELEM, NB_CONNECT, EDGE_ELEM, IAD_EDGE_ELEM, PAIR_LIST,
61 . SIZES, INV_LIST, LIST
62 INTEGER :: NB_DUPLICATED_ELTS, NODE_LIST1(3), NODE_LIST2(3), IAD1, IAD2, NB_CON,
63 . IELEM1, IELEM2, NB_COMMON_NODE, ELEM_ID1, ELEM_ID2, NPAIR
64 INTEGER :: NB_CONNEX_COMP, ICOMP, PATH_SIZE
65 INTEGER,
DIMENSION(:),
ALLOCATABLE :: FLAG_ELEM, PATHS
66 INTEGER :: NTG_NEW, NTGI_NEW
67 INTEGER,
DIMENSION(:, :),
ALLOCATABLE :: ELEM
68 INTEGER,
DIMENSION(:),
ALLOCATABLE :: ISAVE
70 CALL my_alloc(isave, (ntg + ntgi))
73 isave(ii) = t_monvoln%ELTG(ii)
75 DEALLOCATE(t_monvoln%ELTG)
76 CALL my_alloc(t_monvoln%ELTG, (ntg + ntgi))
78 t_monvoln%ELTG(ii) = isave(ii)
81 CALL my_alloc(edge_array_n1, (3 * (ntg + ntgi)))
82 CALL my_alloc(edge_array_n2, (3 * (ntg + ntgi)))
83 CALL my_alloc(edge_array_elem, (3 * (ntg + ntgi)))
86 edge_array_n1(idx + 1) =
min(t_monvoln%ELEM(1, ii), t_monvoln%ELEM(2, ii))
87 edge_array_n2(idx + 1) =
max(t_monvoln%ELEM(1, ii), t_monvoln%ELEM(2, ii))
88 edge_array_n1(idx + 2) =
min(t_monvoln%ELEM(2, ii), t_monvoln%ELEM(3, ii))
89 edge_array_n2(idx + 2) =
max(t_monvoln%ELEM(2, ii), t_monvoln%ELEM(3, ii))
90 edge_array_n1(idx + 3) =
min(t_monvoln%ELEM(3, ii), t_monvoln%ELEM(1, ii))
91 edge_array_n2(idx + 3) =
max(t_monvoln%ELEM(3, ii), t_monvoln%ELEM(1, ii))
92 edge_array_elem(idx + 1 : idx + 3) = ii
99 CALL edge_sort(edge_ptr, edge_array_n1, edge_array_n2, edge_array_elem, nedge)
101 CALL my_alloc(nb_connect, (nedge))
102 CALL edge_get_nb_connect(edge_ptr, nb_connect)
103 CALL my_alloc(edge_elem, (sum(nb_connect)))
104 CALL my_alloc(iad_edge_elem, (nedge + 1))
105 CALL edge_get_connect(edge_ptr, edge_elem)
109 iad_edge_elem(ii) = iad_edge_elem(ii - 1) + nb_connect(ii - 1)
113 CALL intvector_create(pair_vec_ptr)
115 iad1 = iad_edge_elem(ii)
116 iad2 = iad_edge_elem(ii + 1) - 1
117 nb_con = iad2 - iad1 + 1
120 DO ielem1 = iad1, iad2
121 DO ielem2 = iad1, iad2
122 elem_id1 = edge_elem(ielem1)
123 elem_id2 = edge_elem(ielem2)
124 IF (elem_id1 /= elem_id2)
THEN
125 node_list1(1:3) = t_monvoln%ELEM(1:3, elem_id1)
126 node_list2(1:3) = t_monvoln%ELEM(1:3, elem_id2)
130 IF (node_list1(jj) == node_list2(kk))
THEN
131 nb_common_node = nb_common_node + 1
136 IF (nb_common_node == 3)
THEN
138 CALL intvector_push_back(pair_vec_ptr, elem_id1)
139 CALL intvector_push_back(pair_vec_ptr, elem_id2)
148 CALL intvector_get_size(pair_vec_ptr, npair)
149 CALL my_alloc(pair_list, (npair))
150 CALL intvector_copy_to(pair_vec_ptr, pair_list)
154 CALL my_alloc(flag_elem, (ntg + ntgi))
155 flag_elem(1:ntg + ntgi) = 0
156 CALL my_alloc(inv_list, (ntg + ntgi))
157 inv_list(1:ntg + ntgi) = 0
159 nb_duplicated_elts = 0
160 CALL intvector_create(list_ptr)
162 IF (flag_elem(pair_list(2 * (ii - 1) + 1)) == 0)
THEN
163 CALL intvector_push_back(list_ptr, pair_list(2 * (ii - 1) + 1))
164 nb_duplicated_elts = nb_duplicated_elts + 1
165 inv_list(pair_list(2 * (ii - 1) + 1)) = nb_duplicated_elts
166 flag_elem(pair_list(2 * (ii - 1) + 1)) = 1
168 IF (flag_elem(pair_list(2 * (ii - 1) + 2)) == 0)
THEN
169 CALL intvector_push_back(list_ptr, pair_list(2 * (ii - 1) + 2))
170 nb_duplicated_elts = nb_duplicated_elts + 1
171 inv_list(pair_list(2 * (ii - 1) + 2)) = nb_duplicated_elts
172 flag_elem(pair_list(2 * (ii - 1) + 2)) = 1
176 IF (nb_duplicated_elts == 0)
THEN
180 CALL intvector_get_size(list_ptr, nb_duplicated_elts)
181 CALL my_alloc(list, (nb_duplicated_elts))
182 CALL intvector_copy_to(list_ptr, list)
185 pair_list(2 * (ii - 1) + 1) = inv_list(pair_list(2 * (ii - 1) + 1)) - 1
186 pair_list(2 * (ii - 1) + 2) = inv_list(pair_list(2 * (ii - 1) + 2)) - 1
190 CALL graph_build_path(nb_duplicated_elts, npair, pair_list, nb_connex_comp, graph_ptr)
191 CALL my_alloc(sizes, (nb_connex_comp))
192 CALL graph_get_sizes(graph_ptr, sizes)
193 path_size = sum(sizes)
194 CALL my_alloc(paths, (path_size))
195 CALL graph_get_path(graph_ptr, paths)
198 paths(ii) = list(paths(ii) + 1)
203 flag_elem(1:ntg + ntgi) = 1
205 DO icomp = 1, nb_connex_comp
206 iad2 = iad1 + sizes(icomp) - 1
208 elem_id1 = paths(iad1)
212 IF(t_monvoln%ELEM(1, elem_id1) > 0 .AND. t_monvoln%ELEM(1,elem_id1) <= numnod)
213 . node_list1(1) = itab(t_monvoln%ELEM(1, elem_id1))
214 IF(t_monvoln%ELEM(2, elem_id1) > 0 .AND. t_monvoln%ELEM(2,elem_id1) <= numnod)
215 . node_list1(2) = itab(t_monvoln%ELEM(2, elem_id1))
216 IF(t_monvoln%ELEM(3, elem_id1) > 0 .AND. t_monvoln%ELEM(3,elem_id1) <= numnod)
217 . node_list1(3) = itab(t_monvoln%ELEM(3, elem_id1))
219 CALL ancmsg(msgid = 2072, anmode = aninfo, msgtype = msgwarning,
220 . i1 = t_monvoln%ID, c1 = t_monvoln%TITLE,
221 . i2 = node_list1(1), i3 = node_list1(2), i4 = node_list1(3), i5 = sizes(icomp)-1)
222 DO ii = iad1 + 1, iad2
223 flag_elem(paths(ii)) = 0
225 iad1 = iad1 + sizes(icomp)
228 ntg_new = sum(flag_elem(1:ntg))
229 ntgi_new = sum(flag_elem(ntg + 1:ntg + ntgi))
231 CALL my_alloc(elem, 3, ntg_new + ntgi_new)
233 DO ii = 1, ntg + ntgi
234 IF (flag_elem(ii) == 1)
THEN
235 elem(1:3, iad1) = t_monvoln%ELEM(1:3, ii)
239 DEALLOCATE(t_monvoln%ELEM)
241 DO ii = 1, ntg + ntgi
242 isave(ii) = t_monvoln%FVBAG_ELEMID(ii)
244 DEALLOCATE(t_monvoln%FVBAG_ELEMID)
245 CALL my_alloc(t_monvoln%FVBAG_ELEMID, ntg_new + ntgi_new)
247 DO ii = 1, ntg + ntgi
248 IF (flag_elem(ii) == 1)
THEN
249 t_monvoln%FVBAG_ELEMID(iad1) = isave(ii)
254 DO ii = 1, ntg + ntgi
255 isave(ii) = t_monvoln%ELTG(ii)
257 DEALLOCATE(t_monvoln%ELTG)
258 CALL my_alloc(t_monvoln%ELTG, (ntg_new + ntgi_new))
260 DO ii = 1, ntg + ntgi
261 IF (flag_elem(ii) == 1)
THEN
262 t_monvoln%ELTG(iad1) = isave(ii)
267 t_monvoln%NTG = ntg_new
268 t_monvoln%NTGI = ntgi_new
271 CALL my_alloc(t_monvoln%ELEM, 3, ntg + ntgi)
272 DO ii = 1, ntg + ntgi
273 t_monvoln%ELEM(1:3, ii) = elem(1:3, ii)
279 CALL edge_free_memory(edge_ptr)
280 CALL intvector_delete(pair_vec_ptr)
281 CALL intvector_delete(list_ptr)
283 DEALLOCATE(edge_array_n1)
284 DEALLOCATE(edge_array_n2)
285 DEALLOCATE(edge_array_elem)
286 DEALLOCATE(nb_connect)
287 DEALLOCATE(edge_elem)
288 DEALLOCATE(iad_edge_elem)
289 DEALLOCATE(pair_list)
290 DEALLOCATE(flag_elem)
subroutine ancmsg(msgid, msgtype, anmode, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12, i13, i14, i15, i16, i17, i18, i19, i20, r1, r2, r3, r4, r5, r6, r7, r8, r9, c1, c2, c3, c4, c5, c6, c7, c8, c9, prmode)