43 #define CHECK(a) if (a .ne. iBase_SUCCESS) call exit(a)
46 use,
intrinsic :: iso_c_binding
51 imesh_instance :: imesh
52 ibase_entitysethandle root_set
53 integer :: nverts, tmpflag
54 integer ierr, nquads, nquads_tmp
55 ibase_taghandle tag1h, tag2h
56 TYPE(c_ptr) verts_ptr, quads_ptr, conn_ptr, x_ptr, y_ptr, z_ptr, tag1_ptr, tag2_ptr
57 TYPE(c_ptr) tmp_quads_ptr, offsets_ptr
58 real(c_double),
pointer :: x(:), y(:), z(:), tag1(:), tag2(:)
59 integer,
pointer :: offsets(:)
60 ibase_entityhandle,
pointer :: quads(:), verts(:), conn(:), tmp_quads(:)
61 ibase_entityarriterator viter, qiter
62 integer(C_SIZE_T) :: startv, startq, v_ind, e_ind
63 integer count, vpere, e, i, j, v, offsets_size, tmp_quads_size, n_dis
67 call imesh_newmesh(
"", imesh, ierr)
69 call imesh_getrootset(%val(imesh), root_set, ierr)
79 call imesh_getentities(%val(imesh), %val(root_set), %val(0), %val(ibase_vertex), &
80 verts_ptr, nverts, nverts, ierr)
82 call c_f_pointer(verts_ptr, verts, [nverts])
84 call imesh_getentities(%val(imesh), %val(root_set), %val(2), %val(imesh_quadrilateral), &
85 quads_ptr, nquads, nquads, ierr)
87 call c_f_pointer(quads_ptr, quads, [nquads])
92 call imesh_freememory(%val(imesh), quads_ptr)
95 opt =
'moab:TAG_STORAGE_TYPE=DENSE moab:TAG_DEFAULT_valUE=0'
96 call imesh_createtagwithoptions(%val(imesh),
'tag1', opt, %val(3), %val(ibase_double), &
97 tag1h, ierr, %val(4), %val(56))
99 call imesh_createtagwithoptions(%val(imesh),
'tag2', opt, %val(3), %val(ibase_double), &
100 tag2h, ierr, %val(4), %val(56))
104 call imesh_initentarriter(%val(imesh), %val(root_set), %val(ibase_vertex), %val(imesh_all_topologies), &
105 %val(nverts), %val(0), viter, ierr)
107 call imesh_coordsiterate(%val(imesh), %val(viter), x_ptr, y_ptr, z_ptr, count, ierr)
110 call c_f_pointer(x_ptr, x, [nverts])
111 call c_f_pointer(y_ptr, y, [nverts])
112 call c_f_pointer(z_ptr, z, [nverts])
115 call imesh_initentarriter(%val(imesh), %val(root_set), %val(ibase_face), %val(imesh_all_topologies), &
116 %val(nquads), %val(0), qiter, ierr)
118 call imesh_connectiterate(%val(imesh), %val(qiter), conn_ptr, vpere, count, ierr)
120 call c_f_pointer(conn_ptr, conn, [vpere*nquads])
121 call imesh_tagiterate(%val(imesh), %val(tag1h), %val(qiter), tag1_ptr, count, ierr)
123 call c_f_pointer(tag1_ptr, tag1, [3*nquads])
124 call imesh_tagiterate(%val(imesh), %val(tag2h), %val(qiter), tag2_ptr, count, ierr)
126 call c_f_pointer(tag2_ptr, tag2, [3*nquads])
135 v_ind = conn(1+vpere*i+j)
136 v_ind = v_ind - startv
137 tag1(1+3*i+0) = tag1(1+3*i+0) + x(1+v_ind)
138 tag1(1+3*i+1) = tag1(1+3*i+1) + y(1+v_ind)
139 tag1(1+3*i+2) = tag1(1+3*i+2) + z(1+v_ind)
141 tag1(1+3*i+0) = tag1(1+3*i+0) / vpere;
142 tag1(1+3*i+1) = tag1(1+3*i+1) / vpere
143 tag1(1+3*i+2) = tag1(1+3*i+2) / vpere;
151 tmpflag = imesh_quadrilateral
152 call imesh_getentarradj(%val(imesh), verts, %val(nverts), %val(tmpflag), &
153 tmp_quads_ptr, tmp_quads_size, tmp_quads_size, &
154 offsets_ptr, offsets_size, offsets_size, ierr)
157 call c_f_pointer(tmp_quads_ptr, tmp_quads, [tmp_quads_size])
158 call c_f_pointer(offsets_ptr, offsets, [offsets_size])
159 call imesh_freememory(%val(imesh), verts_ptr)
161 do e = 1+offsets(1+v), 1+offsets(1+v+1)-1
163 e_ind = e_ind - startq
164 tag2(1+3*e_ind+0) = tag2(1+3*e_ind+0) + x(1+v)
165 tag2(1+3*e_ind+1) = tag2(1+3*e_ind+1) + y(1+v)
166 tag2(1+3*e_ind+2) = tag2(1+3*e_ind+2) + z(1+v)
169 call imesh_freememory(%val(imesh), tmp_quads_ptr)
170 call imesh_freememory(%val(imesh), offsets_ptr)
178 tag2(1+3*e+j) = tag2(1+3*e+j) / vpere
180 if (tag1(1+3*e) .ne. tag2(1+3*e) .or. tag1(1+3*e+1) .ne. tag2(1+3*e+1) .or. tag1(1+3*e+2) .ne. tag2(1+3*e+2))
then
181 print *,
"Tag1, tag2 disagree for element ", e
182 print *,
"tag1: ", tag1(1+3*e), tag1(1+3*e+1), tag1(1+3*e+2)
183 print *,
"tag2: ", tag2(1+3*e), tag2(1+3*e+1), tag2(1+3*e+2)
187 if (n_dis .eq. 0)
then
188 print *,
'All tags agree, success!'
192 call imesh_dtor(%val(imesh), ierr)
197 use,
intrinsic :: iso_c_binding
204 real(C_DOUBLE),
pointer :: coords(:,:)
205 TYPE(c_ptr) tmp_ents_ptr, stat_ptr
206 ibase_entityhandle,
pointer :: connect(:), tmp_ents(:)
207 integer nverts, tmp_size, stat_size, i
212 nverts = 2*(nquads+1)
213 allocate(coords(0:2, 0:nverts-1))
218 coords(1,2*i+1) = 1.0
220 coords(2,2*i+1) = 0.0
223 coords(0, nverts-2) = nquads
224 coords(0, nverts-1) = nquads
225 coords(1, nverts-2) = 0.0
226 coords(1, nverts-1) = 1.0
227 coords(2, nverts-2) = 0.0
228 coords(2, nverts-1) = 0.0
231 call imesh_createvtxarr(%val(imesh), %val(nverts), %val(ibase_interleaved), &
232 coords, %val(3*nverts), tmp_ents_ptr, tmp_size, tmp_size, ierr)
234 call c_f_pointer(tmp_ents_ptr, tmp_ents, [nverts])
236 allocate(connect(0:4*nquads-1))
238 connect(4*i+0) = tmp_ents(1+2*i)
239 connect(4*i+1) = tmp_ents(1+2*i+2)
240 connect(4*i+2) = tmp_ents(1+2*i+3)
241 connect(4*i+3) = tmp_ents(1+2*i+1)
244 stat_ptr = c_null_ptr
247 call imesh_createentarr(%val(imesh), %val(imesh_quadrilateral), connect, %val(4*nquads), &
248 tmp_ents_ptr, tmp_size, tmp_size, stat_ptr, stat_size, stat_size, ierr)
253 call imesh_freememory(%val(imesh), tmp_ents_ptr)
254 call imesh_freememory(%val(imesh), stat_ptr)