MOAB: Mesh Oriented datABase
(version 5.4.1)
|
00001 c FindConnect: Interacting with iMesh 00002 c 00003 c This program shows how to get more information about a mesh, by 00004 c getting connectivity two different ways (as connectivity and as 00005 c adjacent 0-dimensional entities). 00006 00007 c Usage: FindConnect 00008 00009 program findconnect 00010 #include "iMesh_f.h" 00011 00012 c declarations 00013 iMesh_Instance mesh 00014 iBase_EntityHandle ents 00015 IBASE_HANDLE_T rpverts, rpallverts, ipoffsets 00016 pointer (rpents, ents(0:*)) 00017 pointer (rpverts, verts(0:*)) 00018 pointer (rpallverts, allverts(0:*)) 00019 pointer (ipoffsets, ioffsets(0,*)) 00020 integer ierr, ents_alloc, ents_size 00021 integer iverts_alloc, iverts_size 00022 integer allverts_alloc, allverts_size 00023 integer offsets_alloc, offsets_size 00024 00025 c create the Mesh instance 00026 call iMesh_newMesh("MOAB", mesh, ierr) 00027 00028 c load the mesh 00029 call iMesh_load(%VAL(mesh), %VAL(0), "125hex.vtk", "", ierr) 00030 00031 c get all 3d elements 00032 ents_alloc = 0 00033 call iMesh_getEntities(%VAL(mesh), %VAL(0), %VAL(iBase_REGION), 00034 1 %VAL(iMesh_ALL_TOPOLOGIES), rpents, ents_alloc, ents_size, 00035 1 ierr) 00036 00037 ivert_uses = 0 00038 00039 c iterate through them; 00040 do i = 0, ents_size-1 00041 c get connectivity 00042 iverts_alloc = 0 00043 call iMesh_getEntAdj(%VAL(mesh), %VAL(ents(i)), 00044 1 %VAL(iBase_VERTEX), rpverts, iverts_alloc, iverts_size, 00045 1 ierr) 00046 c sum number of vertex uses 00047 00048 vert_uses = vert_uses + iverts_size 00049 00050 call free(rpverts) 00051 end do 00052 00053 c now get adjacencies in one big block 00054 allverts_alloc = 0 00055 offsets_alloc = 0 00056 call iMesh_getEntArrAdj(%VAL(mesh), %VAL(rpents), 00057 1 %VAL(ents_size), %VAL(iBase_VERTEX), rpallverts, 00058 1 allverts_alloc, allverts_size, ipoffsets, offsets_alloc, 00059 1 offsets_size, ierr) 00060 00061 call free(rpallverts); 00062 call free(ipoffsets); 00063 call free(rpents); 00064 00065 c compare results of two calling methods 00066 if (allverts_size .ne. vert_uses) then 00067 write(*,'("Sizes didn''t agree!")') 00068 else 00069 write(*,'("Sizes did agree!")') 00070 endif 00071 00072 call iMesh_dtor(%VAL(mesh), ierr) 00073 00074 end