1 #include <petsc-private/dmmbimpl.h> /*I "petscdm.h" I*/ 2 #include <petscdmmoab.h> 3 4 #undef __FUNCT__ 5 #define __FUNCT__ "DMMoab_GetWriteOptions_Private" 6 PetscErrorCode DMMoab_GetWriteOptions_Private(PetscInt fsetid, PetscInt numproc, PetscInt dim, MoabWriteMode mode, PetscInt dbglevel, const char* extra_opts, const char** write_opts) 7 { 8 std::ostringstream str; 9 10 PetscFunctionBegin; 11 12 // do parallel read unless only one processor 13 if (numproc > 1) { 14 str << "PARALLEL=" << mode << ";"; 15 if (fsetid>=0) str << "PARALLEL_COMM=" << fsetid << ";"; 16 } 17 18 if (dbglevel) 19 str << "CPUTIME;DEBUG_IO=" << dbglevel << ";"; 20 21 if (extra_opts) 22 str << extra_opts ; 23 24 *write_opts = str.str().c_str(); 25 PetscFunctionReturn(0); 26 } 27 28 29 #undef __FUNCT__ 30 #define __FUNCT__ "DMMoabOutput" 31 PetscErrorCode DMMoabOutput(DM dm,const char* filename,const char* usrwriteopts) 32 { 33 DM_Moab *dmmoab; 34 PetscInt dbglevel=0; 35 const char *writeopts; 36 37 PetscErrorCode ierr; 38 moab::ErrorCode merr; 39 40 PetscFunctionBegin; 41 PetscValidHeaderSpecific(dm,DM_CLASSID,1); 42 dmmoab = (DM_Moab*)(dm)->data; 43 44 PetscBarrier((PetscObject)dm); 45 46 /* TODO: Use command-line options to control by_rank, verbosity, MoabReadMode and extra options */ 47 ierr = PetscOptionsBegin(PETSC_COMM_WORLD, "", "Options for reading/writing MOAB based meshes from file", "DMMoab"); 48 ierr = PetscOptionsInt("-dmmb_rw_dbg", "The verbosity level for reading and writing MOAB meshes", "dmmbutil.cxx", dbglevel, &dbglevel, NULL);CHKERRQ(ierr); 49 ierr = PetscOptionsEnd(); 50 51 /* add mesh loading options specific to the DM */ 52 ierr = DMMoab_GetWriteOptions_Private(dmmoab->pcomm->get_id(), dmmoab->pcomm->size(), dmmoab->dim, MOAB_PARWOPTS_WRITE_PART, dbglevel, usrwriteopts, &writeopts);CHKERRQ(ierr); 53 PetscInfo2(dm, "Writing file %s with options: %s\n",filename,writeopts); 54 55 /* output file, using parallel write */ 56 merr = dmmoab->mbiface->write_file(filename, NULL, writeopts, &dmmoab->fileset, 1);MBERRVM(dmmoab->mbiface,"Writing output of DMMoab failed.",merr); 57 PetscFunctionReturn(0); 58 } 59 60