Mesh Oriented datABase
(version 5.4.1)
Array-based unstructured mesh datastructure
|
00001 /* 00002 * This program updates a manufactured tracer field from time T0 to time T1, in parallel. 00003 * Input: arrival mesh, already distributed on processors, and a departure position for 00004 * each vertex, saved in a tag DP 00005 */ 00006 #include <string> 00007 #include <iostream> 00008 #include "moab/Core.hpp" 00009 #include "moab/IntxMesh/Intx2MeshOnSphere.hpp" 00010 #include "moab/IntxMesh/IntxUtils.hpp" 00011 00012 #include "moab_mpi.h" 00013 #include "iMeshP.h" 00014 #include "MBiMesh.hpp" 00015 00016 #define IMESH_ASSERT( ierr ) \ 00017 if( ( ierr ) != 0 ) std::cout << "iMesh Assert: \n"; 00018 #define IMESH_NULL 0 00019 00020 extern "C" void update_tracer( iMesh_Instance instance, iBase_EntitySetHandle imesh_euler_set, int* ierr ); 00021 00022 int main( int argc, char* argv[] ) 00023 { 00024 MPI_Init( &argc, &argv ); 00025 00026 iMesh_Instance imesh; 00027 iMeshP_PartitionHandle partn; 00028 int ierr, num_sets; 00029 00030 iBase_EntitySetHandle root; 00031 imesh = IMESH_NULL; 00032 iMesh_newMesh( 0, &imesh, &ierr, 0 ); 00033 IMESH_ASSERT( ierr ); 00034 iMesh_getRootSet( imesh, &root, &ierr ); 00035 IMESH_ASSERT( ierr ); 00036 00037 iMeshP_createPartitionAll( imesh, MPI_COMM_WORLD, &partn, &ierr ); 00038 int rank, size; 00039 MPI_Comm_rank( MPI_COMM_WORLD, &rank ); 00040 MPI_Comm_size( MPI_COMM_WORLD, &size ); 00041 IMESH_ASSERT( ierr ); 00042 00043 const char options[] = " moab:PARALLEL=READ_PART " 00044 " moab:PARTITION=PARALLEL_PARTITION " 00045 " moab:PARALLEL_RESOLVE_SHARED_ENTS " 00046 " moab:PARTITION_DISTRIBUTE "; 00047 const char* filename = "HN16DP.h5m"; // the file should have the dp tag already 00048 00049 if( 0 == rank ) std::cout << "Load in parallel the file: " << filename << std::endl; 00050 iMeshP_loadAll( imesh, partn, root, filename, options, &ierr, strlen( filename ), strlen( options ) ); 00051 IMESH_ASSERT( ierr ); 00052 00053 iMesh_getNumEntSets( imesh, IMESH_NULL, 1, &num_sets, &ierr ); 00054 IMESH_ASSERT( ierr ); 00055 std::cout << "There's " << num_sets << " entity sets here on process rank " << rank << std::endl; 00056 00057 iBase_EntitySetHandle euler_set; 00058 00059 iMesh_createEntSet( imesh, 0, &euler_set, &ierr ); 00060 IMESH_ASSERT( ierr ); 00061 00062 iBase_EntityHandle* cells = NULL; 00063 int ents_alloc = 0; 00064 int ents_size = 0; 00065 00066 iMesh_getEntities( imesh, root, iBase_FACE, iMesh_ALL_TOPOLOGIES, &cells, &ents_alloc, &ents_size, &ierr ); 00067 IMESH_ASSERT( ierr ); 00068 00069 iMesh_addEntArrToSet( imesh, cells, ents_size, euler_set, &ierr ); 00070 IMESH_ASSERT( ierr ); 00071 00072 update_tracer( imesh, euler_set, &ierr ); 00073 IMESH_ASSERT( ierr ); 00074 00075 // write everything 00076 const char* out_name = "out.h5m"; 00077 const char optionswrite[] = " moab:PARALLEL=WRITE_PART "; 00078 iMeshP_saveAll( imesh, partn, euler_set, out_name, optionswrite, &ierr, strlen( out_name ), 00079 strlen( optionswrite ) ); 00080 IMESH_ASSERT( ierr ); 00081 00082 if( 0 == rank ) std::cout << "Done\n"; 00083 MPI_Finalize(); 00084 00085 return 0; 00086 }