18 implicit real*8 (a-h,o-z)
20 integer(kind=kint),
dimension(:),
allocatable :: WR, WS, IW1, IW2
22 type (hecmwST_local_mesh) :: hecMESH
32 hecmesh%n_adapt_node_cur= hecmesh%n_node
33 hecmesh%n_adapt_node_old= hecmesh%n_node
34 intcount = hecmesh%nn_internal
37 do ie= 1, hecmesh%n_adapt_edge
38 n1= hecmesh%adapt_edge_node(2*ie-1)
39 n2= hecmesh%adapt_edge_node(2*ie )
41 if ( hecmesh%adapt_iemb(ie) .eq. 1)
then
42 hecmesh%n_adapt_node_cur= hecmesh%n_adapt_node_cur + 1
43 if (hecmesh%n_adapt_node_cur.gt.hecmesh%nn_array)
then
47 ieh= hecmesh%adapt_edge_home(ie)
48 nod= hecmesh%n_adapt_node_cur
50 hecmesh%node_ID(2*nod)= ieh
51 if (ieh.eq.hecmesh%my_rank)
then
52 intcount= intcount + 1
53 hecmesh%adapt_mid_edge(ie)= intcount
54 hecmesh%node_ID(2*nod-1) = intcount
56 hecmesh%adapt_mid_edge(ie)= nod
57 hecmesh%node_ID (2*nod-1) = nod
60 hecmesh%when_i_was_refined_node(nod)= hecmesh%n_adapt
61 hecmesh%adapt_IWK(ie) = nod
63 if (ieh.eq.hecmesh%my_rank) icou= icou + 1
65 hecmesh%node(3*nod-2)= 0.5d0 * ( hecmesh%node(3*n1-2) + &
66 & hecmesh%node(3*n2-2) )
67 hecmesh%node(3*nod-1)= 0.5d0 * ( hecmesh%node(3*n1-1) + &
68 & hecmesh%node(3*n2-1) )
69 hecmesh%node(3*nod )= 0.5d0 * ( hecmesh%node(3*n1 ) + &
70 & hecmesh%node(3*n2 ) )
74 call mpi_barrier (hecmesh%MPI_COMM,ierr)
76 hecmesh%nn_adapt_internal_cur= hecmesh%nn_internal + icou
90 call mpi_allreduce (hecmesh%nn_internal, nodtotg_old, 1, &
91 & mpi_integer, mpi_sum, hecmesh%MPI_COMM, ierr)
92 call mpi_allreduce (hecmesh%nn_adapt_internal_cur, nodtotg_cur, 1,&
93 & mpi_integer, mpi_sum, hecmesh%MPI_COMM, ierr)
95 if (hecmesh%my_rank.eq.0)
then
96 write (*,
'(" total node number (before)", i8 )') nodtotg_old
97 write (*,
'(" total node number (curr. )", i8,/)') nodtotg_cur
100 hecmesh%n_node = hecmesh%n_adapt_node_cur
101 hecmesh%nn_internal = hecmesh%nn_adapt_internal_cur
105 allocate (iw1(hecmesh%n_adapt_edge))
107 iw1= hecmesh%adapt_mid_edge
109 n1= hecmesh%adapt_import_edge_index(hecmesh%n_neighbor_pe)
110 n2= hecmesh%adapt_export_edge_index(hecmesh%n_neighbor_pe)
112 allocate (ws(m), wr(m))
117 & ( hecmesh%n_adapt_edge, &
118 & hecmesh%n_neighbor_pe, hecmesh%neighbor_pe, &
119 & hecmesh%adapt_import_edge_index, &
120 & hecmesh%adapt_import_edge_item , &
121 & hecmesh%adapt_export_edge_index, &
122 & hecmesh%adapt_export_edge_item , &
123 & ws, wr, hecmesh%adapt_mid_edge, hecmesh%MPI_COMM, &
124 & hecmesh%my_rank, 1, m)
127 do ie= 1, hecmesh%n_adapt_edge
128 if (hecmesh%adapt_iemb(ie).eq.1 .and. &
129 & hecmesh%adapt_edge_home(ie).ne.hecmesh%my_rank)
then
130 ing= hecmesh%adapt_mid_edge(ie)
132 hecmesh%node_ID(2*inl )= hecmesh%adapt_edge_home(ie)
133 hecmesh%node_ID(2*inl-1)= ing
137 do ie= 1, hecmesh%n_adapt_edge
138 if (hecmesh%adapt_iemb(ie).eq.1)
then
140 hecmesh%adapt_mid_edge(ie)= inl
151 allocate (iw1(-1:hecmesh%n_neighbor_pe), &
152 & iw2(-1:hecmesh%n_neighbor_pe))
153 allocate (hecmesh%adapt_NEWtoOLD_node(hecmesh%n_node), &
154 & hecmesh%adapt_OLDtoNEW_node(hecmesh%n_node))
158 hecmesh%adapt_NEWtoOLD_node= 0
159 hecmesh%adapt_OLDtoNEW_node= 0
161 do in= 1, hecmesh%n_node
162 ih = hecmesh%node_ID(2*in)
163 ihr = hecmesh%rev_neighbor_pe(ih)
164 iw1(ihr)= iw1(ihr) + 1
167 do neib= 0, hecmesh%n_neighbor_pe
168 iw2(neib)= iw2(neib-1) + iw1(neib)
172 do in= 1, hecmesh%n_node
173 ih = hecmesh%node_ID(2*in)
174 ihr = hecmesh%rev_neighbor_pe(ih)
175 iw1(ihr)= iw1(ihr) + 1
176 is = iw2(ihr-1) + iw1(ihr)
177 hecmesh%adapt_OLDtoNEW_node(in)= is
178 hecmesh%adapt_NEWtoOLD_node(is)= in
182 deallocate (iw1, iw2)