Date: 2016-07-24T17:01:40+00:00

Actual source code: dmmbio.cxx
petsc-3.7.3 2016-07-24
Report Typos and Errors

      1: #include <petsc/private/dmmbimpl.h> /*I  "petscdmmoab.h"   I*/
      2: #include <petscdmmoab.h>

      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: {
      9:   char           *wopts;
     10:   char           wopts_par[PETSC_MAX_PATH_LEN];
     11:   char           wopts_parid[PETSC_MAX_PATH_LEN];
     12:   char           wopts_dbg[PETSC_MAX_PATH_LEN];

     15:   PetscMalloc(PETSC_MAX_PATH_LEN,&wopts);
     16:   PetscMemzero(&wopts_par,PETSC_MAX_PATH_LEN);
     17:   PetscMemzero(&wopts_parid,PETSC_MAX_PATH_LEN);
     18:   PetscMemzero(&wopts_dbg,PETSC_MAX_PATH_LEN);

     20:   // do parallel read unless only one processor
     21:   if (numproc > 1) {
     22:     PetscSNPrintf(wopts_par, PETSC_MAX_PATH_LEN, "PARALLEL=%s;",MoabWriteModes[mode]);
     23:     if (fsetid >= 0) {
     24:       PetscSNPrintf(wopts_parid, PETSC_MAX_PATH_LEN, "PARALLEL_COMM=%d;",fsetid);
     25:     }
     26:   }

     28:   if (dbglevel) {
     29:     PetscSNPrintf(wopts_dbg, PETSC_MAX_PATH_LEN, "CPUTIME;DEBUG_IO=%d;",dbglevel);
     30:   }

     32:   PetscSNPrintf(wopts, PETSC_MAX_PATH_LEN, "%s%s%s%s%s",wopts_par,wopts_parid,wopts_dbg,(extra_opts?extra_opts:""),(dm_opts?dm_opts:""));
     33:   *write_opts=wopts;
     34:   return(0);
     35: }

     40: /*@C
     41:   DMMoabOutput - Output the solution vectors that are stored in the DMMoab object as tags
     42:   along with the complete mesh data structure in the native H5M or VTK format. The H5M output file
     43:   can be visualized directly with Paraview (if compiled with appropriate plugin) or converted
     44:   with MOAB/tools/mbconvert to a VTK or Exodus file.

     46:   This routine can also be used for check-pointing purposes to store a complete history of
     47:   the solution along with any other necessary data to restart computations.

     49:   Collective

     51:   Input Parameters:
     52: + dm     - the discretization manager object containing solution in MOAB tags.
     53: .  filename - the name of the output file: e.g., poisson.h5m
     54: -  usrwriteopts - the parallel write options needed for serializing a MOAB mesh database. Can be NULL.
     55:    Reference (Parallel Mesh Initialization: http://ftp.mcs.anl.gov/pub/fathom/moab-docs/contents.html#fivetwo)

     57:   Level: intermediate

     59: .keywords: discretization manager, set, component solution

     61: .seealso: DMMoabLoadFromFile(), DMMoabSetGlobalFieldVector()
     62: @*/
     63: PetscErrorCode DMMoabOutput(DM dm,const char* filename,const char* usrwriteopts)
     64: {
     65:   DM_Moab         *dmmoab;
     66:   const char      *writeopts;
     67:   PetscBool       isftype;
     68:   PetscErrorCode  ierr;
     69:   moab::ErrorCode merr;

     73:   dmmoab = (DM_Moab*)(dm)->data;

     75:   PetscStrendswith(filename,"h5m",&isftype);

     77:   /* add mesh loading options specific to the DM */
     78:   if (isftype) {
     79:     DMMoab_GetWriteOptions_Private(dmmoab->pcomm->get_id(), dmmoab->pcomm->size(), dmmoab->dim, dmmoab->write_mode,
     80:                                           dmmoab->rw_dbglevel, dmmoab->extra_write_options, usrwriteopts, &writeopts);
     81:     PetscInfo2(dm, "Writing file %s with options: %s\n",filename,writeopts);
     82:   }
     83:   else {
     84:     writeopts=NULL;
     85:   }

     87:   /* output file, using parallel write */
     88:   merr = dmmoab->mbiface->write_file(filename, NULL, writeopts, &dmmoab->fileset, 1);MBERRVM(dmmoab->mbiface,"Writing output of DMMoab failed.",merr);
     89:   PetscFree(writeopts);
     90:   return(0);
     91: }