Mesh Oriented datABase  (version 5.5.1)
An array-based unstructured mesh library
DirectAccessNoHolesF90.F90 File Reference

Go to the source code of this file.

Functions/Subroutines

program directaccessnoholesf90
 
subroutine create_mesh_no_holes (imesh, nquads, ierr)
 

Function/Subroutine Documentation

◆ create_mesh_no_holes()

subroutine create_mesh_no_holes (   imesh,
integer  nquads,
integer  ierr 
)

Definition at line 196 of file DirectAccessNoHolesF90.F90.

197  use, intrinsic :: iso_c_binding
198  implicit none
199 #include "iMesh_f.h"
200 
201  imesh_instance imesh
202  integer nquads, ierr
203 
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
208 
209  ! first make the mesh, a 1d array of quads with left hand side x = elem_num;
210  ! vertices are numbered in layers
211  ! create verts, num is 2(nquads+1) because they're in a 1d row
212  nverts = 2*(nquads+1)
213  allocate(coords(0:2, 0:nverts-1))
214  do i = 0, nquads-1
215  coords(0,2*i) = i
216  coords(0,2*i+1) = i ! x values are all i
217  coords(1,2*i) = 0.0
218  coords(1,2*i+1) = 1.0 ! y coords
219  coords(2,2*i) = 0.0
220  coords(2,2*i+1) = 0.0 ! z values, all zero (2d mesh)
221  end do
222  ! last two vertices
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 ! y coords
227  coords(2, nverts-2) = 0.0
228  coords(2, nverts-1) = 0.0 ! z values, all zero (2d mesh)
229  tmp_size = 0
230  !!!!!! VSM: This is the culprit call that screws up IBM xlf compiler
231  call imesh_createvtxarr(%val(imesh), %val(nverts), %val(ibase_interleaved), &
232  coords, %val(3*nverts), tmp_ents_ptr, tmp_size, tmp_size, ierr)
233  check(ierr)
234  call c_f_pointer(tmp_ents_ptr, tmp_ents, [nverts])
235  deallocate(coords)
236  allocate(connect(0:4*nquads-1))
237  do i = 0, 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)
242  end do
243  stat_size = 0
244  stat_ptr = c_null_ptr
245  ! re-use tmp_ents here;
246  ! we know it'll always be larger than nquads so it's ok
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)
249  check(ierr)
250 
251  ierr = ibase_success
252 
253  call imesh_freememory(%val(imesh), tmp_ents_ptr)
254  call imesh_freememory(%val(imesh), stat_ptr)
255  deallocate(connect)
256 
257  return

References check().

Referenced by directaccessnoholesf90().

◆ directaccessnoholesf90()

program directaccessnoholesf90

Definition at line 45 of file DirectAccessNoHolesF90.F90.

References check(), and create_mesh_no_holes().