1 #include <petsc-private/dmmbimpl.h> /*I "petscdmmoab.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* dm_opts, 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=" << MoabWriteModes[mode] << ";"; 15 if (fsetid>=0) str << "PARALLEL_COMM=" << fsetid << ";"; 16 } 17 18 if (strlen(dm_opts)) { 19 str << dm_opts << ";"; 20 } 21 22 if (dbglevel) 23 str << "CPUTIME;DEBUG_IO=" << dbglevel << ";"; 24 25 if (extra_opts) 26 str << extra_opts ; 27 28 *write_opts = str.str().c_str(); 29 PetscFunctionReturn(0); 30 } 31 32 33 #undef __FUNCT__ 34 #define __FUNCT__ "DMMoabOutput" 35 /*@C 36 DMMoabOutput - Output the solution vectors that are stored in the DMMoab object as tags 37 along with the complete mesh data structure in the native H5M format. This output file 38 can be visualized directly with Paraview (if compiled with appropriate plugin) or converted 39 with tools/mbconvert to a VTK or Exodus file. 40 41 This routine can also be used for check-pointing purposes to store a complete history of 42 the solution along with any other necessary data to restart computations. 43 44 Not Collective 45 46 Input Parameters: 47 + dm - the discretization manager object containing solution in MOAB tags. 48 . filename - the name of the output file: e.g., poisson.h5m 49 - usrwriteopts - the parallel write options needed for serializing a MOAB mesh database. Can be NULL. 50 Reference (Parallel Mesh Initialization: http://www.mcs.anl.gov/~fathom/moab-docs/html/contents.html#fivetwo) 51 52 Level: intermediate 53 54 .keywords: discretization manager, set, component solution 55 56 .seealso: DMMoabLoadFromFile(), DMMoabSetGlobalFieldVector() 57 @*/ 58 PetscErrorCode DMMoabOutput(DM dm,const char* filename,const char* usrwriteopts) 59 { 60 DM_Moab *dmmoab; 61 const char *writeopts; 62 PetscErrorCode ierr; 63 moab::ErrorCode merr; 64 65 PetscFunctionBegin; 66 PetscValidHeaderSpecific(dm,DM_CLASSID,1); 67 dmmoab = (DM_Moab*)(dm)->data; 68 69 /* add mesh loading options specific to the DM */ 70 ierr = DMMoab_GetWriteOptions_Private(dmmoab->pcomm->get_id(), dmmoab->pcomm->size(), dmmoab->dim, dmmoab->write_mode, 71 dmmoab->rw_dbglevel, dmmoab->extra_write_options, usrwriteopts, &writeopts);CHKERRQ(ierr); 72 PetscInfo2(dm, "Writing file %s with options: %s\n",filename,writeopts); 73 74 /* output file, using parallel write */ 75 merr = dmmoab->mbiface->write_file(filename, NULL, writeopts, &dmmoab->fileset, 1);MBERRVM(dmmoab->mbiface,"Writing output of DMMoab failed.",merr); 76 PetscFunctionReturn(0); 77 } 78 79