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 static 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 /*@C 32 DMMoabOutput - Output the solution vectors that are stored in the DMMoab object as tags 33 along with the complete mesh data structure in the native H5M format. This output file 34 can be visualized directly with Paraview (if compiled with appropriate plugin) or converted 35 with tools/mbconvert to a VTK or Exodus file. 36 37 This routine can also be used for check-pointing purposes to store a complete history of 38 the solution along with any other necessary data to restart computations. 39 40 Not Collective 41 42 Input Parameters: 43 + dm - the discretization manager object containing solution in MOAB tags. 44 . filename - the name of the output file: e.g., poisson.h5m 45 - usrwriteopts - the parallel write options needed for serializing a MOAB mesh database. Can be NULL. 46 Reference (Parallel Mesh Initialization: http://www.mcs.anl.gov/~fathom/moab-docs/html/contents.html#fivetwo) 47 48 Level: intermediate 49 50 .keywords: discretization manager, set, component solution 51 52 .seealso: DMMoabLoadFromFile(), DMMoabSetGlobalFieldVector() 53 @*/ 54 PetscErrorCode DMMoabOutput(DM dm,const char* filename,const char* usrwriteopts) 55 { 56 DM_Moab *dmmoab; 57 PetscInt dbglevel=0; 58 const char *writeopts; 59 60 PetscErrorCode ierr; 61 moab::ErrorCode merr; 62 63 PetscFunctionBegin; 64 PetscValidHeaderSpecific(dm,DM_CLASSID,1); 65 dmmoab = (DM_Moab*)(dm)->data; 66 67 PetscBarrier((PetscObject)dm); 68 69 /* TODO: Use command-line options to control by_rank, verbosity, MoabReadMode and extra options */ 70 ierr = PetscOptionsBegin(PETSC_COMM_WORLD, "", "Options for reading/writing MOAB based meshes from file", "DMMoab"); 71 ierr = PetscOptionsInt("-dmmb_rw_dbg", "The verbosity level for reading and writing MOAB meshes", "dmmbutil.cxx", dbglevel, &dbglevel, NULL);CHKERRQ(ierr); 72 ierr = PetscOptionsEnd(); 73 74 /* add mesh loading options specific to the DM */ 75 ierr = DMMoab_GetWriteOptions_Private(dmmoab->pcomm->get_id(), dmmoab->pcomm->size(), dmmoab->dim, MOAB_PARWOPTS_WRITE_PART, dbglevel, usrwriteopts, &writeopts);CHKERRQ(ierr); 76 PetscInfo2(dm, "Writing file %s with options: %s\n",filename,writeopts); 77 78 /* output file, using parallel write */ 79 merr = dmmoab->mbiface->write_file(filename, NULL, writeopts, &dmmoab->fileset, 1);MBERRVM(dmmoab->mbiface,"Writing output of DMMoab failed.",merr); 80 PetscFunctionReturn(0); 81 } 82 83