MOAB: Mesh Oriented datABase  (version 5.5.0)
imeshp_test.F90 File Reference
#include "moab/MOABConfig.h"
#include "mpif.h"
#include "iMeshP_f.h"
+ Include dependency graph for imeshp_test.F90:

Go to the source code of this file.

Macros

#define ERROR(rval)   if (0 .ne. rval) call exit(1)
 

Functions/Subroutines

program imeshp_test
 
subroutine create_mesh (imesh, imeshp, part, comm, numv, nume, vgids, nvpe, tp, posn, iconn, vertsPtr, entsPtr, ierr)
 

Macro Definition Documentation

◆ ERROR

#define ERROR (   rval)    if (0 .ne. rval) call exit(1)

Function/Subroutine Documentation

◆ create_mesh()

subroutine create_mesh (   imesh,
  imeshp,
  part,
integer  comm,
integer  numv,
integer  nume,
integer, dimension(0:*)  vgids,
integer  nvpe,
integer  tp,
real*8, dimension(0:*)  posn,
integer, dimension(0:*)  iconn,
type(c_ptr)  vertsPtr,
type(c_ptr)  entsPtr,
integer  ierr 
)

Definition at line 176 of file imeshp_test.F90.

183  !
184  ! create a mesh with numv vertices and nume elements, with elements of type tp
185  ! vertices have positions in posn (3 coordinates each, interleaved xyzxyz...), indexed from 0
186  ! elements have nvpe vertices per entity, with connectivity indices stored in iconn, referencing
187  ! vertices using 0-based indices; vertex and entity handles are output in arrays passed in
188  !
189  ! if imesh/imeshp are 0, imesh/imeshp are initialized in this subroutine
190  !
191 
192  use iso_c_binding
193  implicit none
194 
195 #ifdef MOAB_HAVE_MPI
196 # include "iMeshP_f.h"
197 # include "mpif.h"
198 #else
199 # include "iMesh_f.h"
200 #endif
201 
202  ! subroutine arguments
203  imesh_instance imesh
204  TYPE(C_PTR) :: vertsPtr, entsPtr
205  integer numv, nume, nvpe, vgids(0:*), iconn(0:*), ierr, tp
206  real*8 posn(0:*)
207 
208  imeshp_partitionhandle imeshp
209  integer comm
210 
211 
212  ! local variables
213  integer comm_sz, comm_rank, numa, numo, iv, ie
214  TYPE(C_PTR) :: statsPtr
215  integer, allocatable, target :: stats(:)
216  ibase_taghandle tagh
217  integer i
218  ibase_entityhandle, pointer :: verts(:), ents(:)
219  ibase_entityhandle, allocatable :: conn(:)
220  ibase_entitysethandle root_set
221  ibase_entitysethandle file_set
222 
223  ibase_handle_t mpi_comm_c
224  TYPE(C_PTR) :: partsPtr
225  imeshp_parthandle, pointer :: parts(:)
226  imeshp_parthandle part
227  integer partsa, partso
228  character (len=10) filename
229 
230  ! create the Mesh instance
231  if (imesh .eq. 0) then
232  call imesh_newmesh("MOAB", imesh, ierr)
233  end if
234 
235 
236  if (imeshp .eq. 0) then
237  call imeshp_getcommunicator(%VAL(imesh), mpi_comm_world, mpi_comm_c, ierr)
238  error(ierr)
239  call imeshp_createpartitionall(%VAL(imesh), %VAL(mpi_comm_c), imeshp, ierr)
240  error(ierr)
241  call imeshp_createpart(%VAL(imesh), %VAL(imeshp), part, ierr)
242  error(ierr)
243  else
244  partsa = 0
245  call imeshp_getlocalparts(%VAL(imesh), %VAL(imeshp), partsptr, partsa, partso, ierr)
246  error(ierr)
247  call c_f_pointer(partsptr, parts, [partso])
248  part = parts(1)
249  end if
250  call mpi_comm_rank(comm, comm_rank, ierr)
251  error(ierr)
252  call mpi_comm_size(comm, comm_sz, ierr)
253  error(ierr)
254 
255  ! create the vertices, all in one call
256  numa = 0
257  call imesh_createvtxarr(%VAL(imesh), %VAL(numv), %VAL(ibase_interleaved), posn, %VAL(3*numv), &
258  vertsptr, numa, numo, ierr)
259  error(ierr)
260 
261  ! fill in the connectivity array, based on indexing from iconn
262  allocate (conn(0:nvpe*nume-1))
263  call c_f_pointer(vertsptr, verts, [numv])
264  do i = 0, nvpe*nume-1
265  conn(i) = verts(1+iconn(i))
266  end do
267  ! create the elements
268  numa = 0
269  allocate(stats(0:nume-1))
270  statsptr = c_loc(stats(0))
271  call imesh_createentarr(%VAL(imesh), %VAL(tp), conn, %VAL(nvpe*nume), &
272  entsptr, numa, numo, statsptr, numa, numo, ierr)
273  deallocate(stats)
274  deallocate(conn)
275 
276  ! take care of parallel stuff
277 
278  ! add entities to part, using iMesh
279  call c_f_pointer(entsptr, ents, [numo])
280  call imesh_addentarrtoset(%VAL(imesh), ents, %VAL(numo), %VAL(part), ierr)
281  error(ierr)
282  ! set global ids on vertices, needed for sharing between procs
283  call imesh_gettaghandle(%VAL(imesh), "GLOBAL_ID", tagh, ierr, %VAL(9))
284  if (ibase_success .ne. ierr) then
285  ! didn't get handle, need to create the tag
286  call imesh_createtag(%VAL(imesh), "GLOBAL_ID", %VAL(ibase_integer), tagh, ierr)
287  error(ierr)
288  end if
289  call imesh_setintarrdata(%VAL(imesh), verts, %VAL(numv), %VAL(tagh), vgids, %VAL(numv), ierr)
290  error(ierr)
291  ! now resolve shared verts and exchange ghost cells
292  call imeshp_syncmeshall(%VAL(imesh), %VAL(imeshp), ierr)
293  error(ierr)
294 
295  call imeshp_createghostentsall(%VAL(imesh), %VAL(imeshp), %VAL(2), %VAL(1), %VAL(1), %VAL(0), ierr)
296  error(ierr)
297 
298  call imesh_freememory(%VAL(imesh), vertsptr);
299  call imesh_freememory(%VAL(imesh), entsptr);
300 
301  return

References error().

◆ imeshp_test()

program imeshp_test

Definition at line 11 of file imeshp_test.F90.

References create_mesh(), and error().