Commits

BarryFSmith committed dae86d5 Merge

Merge branch 'feature-dmmoab' into next

Comments (0)

Files changed (9)

 testexamples_YAML: ${TESTEXAMPLES_YAML}
 testexamples_THREADCOMM: ${TESTEXAMPLES_THREADCOMM}
 testexamples_MOAB: ${TESTEXAMPLES_MOAB}
+testexamples_MOAB_HDF5: ${TESTEXAMPLES_MOAB_HDF5}
 testexamples_X:
 testexamples_OPENGL:
 testexamples_MPE:

config/PETSc/utilities/Regression.py

         for i in self.framework.packages:
           if not i.name.upper() in ['SOWING','C2HTML','BLASLAPACK','MPI','SCALAPACK','PTHREAD','CUDA','THRUST','VALGRIND','NUMDIFF','MAKE','FBLASLAPACK']:
             ejobs.append(i.name.upper())
+          # horrible python here
+          if i.name.upper() == 'MOAB':
+            for j in self.framework.packages:
+              if j.name.upper() == 'HDF5':
+                ejobs.append('MOAB_HDF5')
 
     self.addMakeMacro('TEST_RUNS',' '.join(jobs)+' '+' '.join(ejobs)+' '+' '.join(rjobs))
     return

src/dm/impls/moab/dmmbio.cxx

 #define __FUNCT__ "DMMoabOutput"
 /*@C
   DMMoabOutput - Output the solution vectors that are stored in the DMMoab object as tags 
-  along with the complete mesh data structure in the native H5M format. This output file
+  along with the complete mesh data structure in the native H5M or VTK format. The H5M output file
   can be visualized directly with Paraview (if compiled with appropriate plugin) or converted
-  with tools/mbconvert to a VTK or Exodus file.
+  with MOAB/tools/mbconvert to a VTK or Exodus file.
 
   This routine can also be used for check-pointing purposes to store a complete history of 
   the solution along with any other necessary data to restart computations.
 
-  Not Collective
+  Collective
 
   Input Parameters:
 + dm     - the discretization manager object containing solution in MOAB tags.
 .  filename - the name of the output file: e.g., poisson.h5m
 -  usrwriteopts - the parallel write options needed for serializing a MOAB mesh database. Can be NULL.
-   Reference (Parallel Mesh Initialization: http://www.mcs.anl.gov/~fathom/moab-docs/html/contents.html#fivetwo)
+   Reference (Parallel Mesh Initialization: http://ftp.mcs.anl.gov/pub/fathom/moab-docs/contents.html#fivetwo)
 
   Level: intermediate
 
 {
   DM_Moab         *dmmoab;
   const char      *writeopts;
+  PetscBool       isftype;
   PetscErrorCode  ierr;
   moab::ErrorCode merr;
 
   PetscValidHeaderSpecific(dm,DM_CLASSID,1);
   dmmoab = (DM_Moab*)(dm)->data;
 
+  ierr = PetscStrendswith(filename,"h5m",&isftype);CHKERRQ(ierr);
+
   /* add mesh loading options specific to the DM */
-  ierr = DMMoab_GetWriteOptions_Private(dmmoab->pcomm->get_id(), dmmoab->pcomm->size(), dmmoab->dim, dmmoab->write_mode,
+  if (isftype) {
+    ierr = DMMoab_GetWriteOptions_Private(dmmoab->pcomm->get_id(), dmmoab->pcomm->size(), dmmoab->dim, dmmoab->write_mode,
                                           dmmoab->rw_dbglevel, dmmoab->extra_write_options, usrwriteopts, &writeopts);CHKERRQ(ierr);
-  PetscInfo2(dm, "Writing file %s with options: %s\n",filename,writeopts);
+    PetscInfo2(dm, "Writing file %s with options: %s\n",filename,writeopts);
+  }
+  else {
+    writeopts=NULL;
+  }
 
   /* output file, using parallel write */
   merr = dmmoab->mbiface->write_file(filename, NULL, writeopts, &dmmoab->fileset, 1);MBERRVM(dmmoab->mbiface,"Writing output of DMMoab failed.",merr);

src/dm/impls/moab/dmmbmat.cxx

 PetscErrorCode DMCreateMatrix_Moab(DM dm,Mat *J)
 {
   PetscErrorCode  ierr;
-  PetscInt        innz,ionz,nlsiz;
+  PetscInt        innz=0,ionz=0,nlsiz;
   DM_Moab         *dmmoab=(DM_Moab*)dm->data;
   PetscInt        *nnz=0,*onz=0;
   char            *tmp=0;
 PetscErrorCode DMMoab_Compute_NNZ_From_Connectivity(DM dm,PetscInt* innz,PetscInt* nnz,PetscInt* ionz,PetscInt* onz,PetscBool isbaij)
 {
   PetscInt        i,f,nloc,vpere,bs,ivtx,n_nnz,n_onz;
-  PetscInt        ibs,jbs,inbsize,iobsize,nfields;
+  PetscInt        ibs,jbs,inbsize,iobsize,nfields,nlsiz;
   DM_Moab         *dmmoab = (DM_Moab*)dm->data;
   const moab::EntityHandle *connect;
   moab::Range     adjs,found,allvlocal,allvghost;
   nloc = dmmoab->nloc;
   nfields = dmmoab->numFields;
   isinterlaced=(isbaij || bs==nfields ? PETSC_TRUE : PETSC_FALSE);
+  nlsiz = (isinterlaced ? nloc:nloc*nfields);
 
   /* find the truly user-expected layer of ghosted entities to decipher NNZ pattern */
   merr = dmmoab->mbiface->get_entities_by_type(dmmoab->fileset,moab::MBVERTEX,allvlocal,true);MBERRNM(merr);
     }
   }
 
-  for (i=0;i<nloc*(isbaij?1:nfields);i++)
+  for (i=0;i<nlsiz;i++)
     nnz[i]+=1;  /* self count the node */
 
   for (ivtx=0;ivtx<nloc;ivtx++) {
   if (innz || ionz) {
     if (innz) *innz=0;
     if (ionz) *ionz=0;
-    for (i=0;i<nloc*nfields;i++) {
+    for (i=0;i<nlsiz;i++) {
       if (innz && (nnz[i]>*innz)) *innz=nnz[i];
       if ((ionz && onz) && (onz[i]>*ionz)) *ionz=onz[i];
     }

src/ksp/ksp/examples/tutorials/ex35.cxx

   PetscErrorCode ierr;
   PetscInt       bc,np;
   Vec            b,x;
-  PetscBool      use_extfile;
+  PetscBool      use_extfile,io;
 
   PetscInitialize(&argc,&argv,(char*)0,help);
 
   MPI_Comm_size(PETSC_COMM_WORLD,&np);
 
-  ierr        = PetscOptionsBegin(PETSC_COMM_WORLD, "", "Options for the inhomogeneous Poisson equation", "ex2.c");
+  ierr        = PetscOptionsBegin(PETSC_COMM_WORLD, "", "Options for the inhomogeneous Poisson equation", "ex35.c");
   user.dim    = 2;
-  ierr        = PetscOptionsInt("-dim", "The dimension of the problem", "ex2.c", user.dim, &user.dim, NULL);CHKERRQ(ierr);
+  ierr        = PetscOptionsInt("-dim", "The dimension of the problem", "ex35.c", user.dim, &user.dim, NULL);CHKERRQ(ierr);
   user.n      = 2;
-  ierr        = PetscOptionsInt("-n", "The elements in each direction", "ex2.c", user.n, &user.n, NULL);CHKERRQ(ierr);
+  ierr        = PetscOptionsInt("-n", "The elements in each direction", "ex35.c", user.n, &user.n, NULL);CHKERRQ(ierr);
   user.rho    = 0.5;
-  ierr        = PetscOptionsReal("-rho", "The conductivity", "ex2.c", user.rho, &user.rho, NULL);CHKERRQ(ierr);
+  ierr        = PetscOptionsReal("-rho", "The conductivity", "ex35.c", user.rho, &user.rho, NULL);CHKERRQ(ierr);
   user.xref   = 0.5;
-  ierr        = PetscOptionsReal("-xref", "The x-coordinate of Gaussian center", "ex2.c", user.xref, &user.xref, NULL);CHKERRQ(ierr);
+  ierr        = PetscOptionsReal("-xref", "The x-coordinate of Gaussian center", "ex35.c", user.xref, &user.xref, NULL);CHKERRQ(ierr);
   user.yref   = 0.5;
-  ierr        = PetscOptionsReal("-yref", "The y-coordinate of Gaussian center", "ex2.c", user.yref, &user.yref, NULL);CHKERRQ(ierr);
+  ierr        = PetscOptionsReal("-yref", "The y-coordinate of Gaussian center", "ex35.c", user.yref, &user.yref, NULL);CHKERRQ(ierr);
   user.nu     = 0.05;
-  ierr        = PetscOptionsReal("-nu", "The width of the Gaussian source", "ex2.c", user.nu, &user.nu, NULL);CHKERRQ(ierr);
+  ierr        = PetscOptionsReal("-nu", "The width of the Gaussian source", "ex35.c", user.nu, &user.nu, NULL);CHKERRQ(ierr);
+  io          = PETSC_FALSE;
+  ierr        = PetscOptionsBool("-io", "Write out the solution and mesh data", "ex35.c", io, &io, NULL);CHKERRQ(ierr);
   bc          = (PetscInt)DIRICHLET;
-  ierr        = PetscOptionsEList("-bc_type","Type of boundary condition","ex2.c",bcTypes,2,bcTypes[0],&bc,NULL);CHKERRQ(ierr);
+  ierr        = PetscOptionsEList("-bc_type","Type of boundary condition","ex35.c",bcTypes,2,bcTypes[0],&bc,NULL);CHKERRQ(ierr);
   user.bcType = (BCType)bc;
-  ierr        = PetscOptionsString("-file", "The mesh file for the problem", "ex2.c", "",user.filename,PETSC_MAX_PATH_LEN,&use_extfile);CHKERRQ(ierr);
+  ierr        = PetscOptionsString("-file", "The mesh file for the problem", "ex35.c", "",user.filename,PETSC_MAX_PATH_LEN,&use_extfile);CHKERRQ(ierr);
   ierr        = PetscOptionsEnd();
 
   /* Create the DM object from either a mesh file or from in-memory structured grid */
   ierr = KSPGetSolution(ksp,&x);CHKERRQ(ierr);
   ierr = KSPGetRhs(ksp,&b);CHKERRQ(ierr);
 
-  ierr = DMMoabSetGlobalFieldVector(dm, x);CHKERRQ(ierr);
-  ierr = DMMoabOutput(dm, "ex2.h5m", "");CHKERRQ(ierr);
+  if (io) {
+    /* Write out the solution along with the mesh */
+    ierr = DMMoabSetGlobalFieldVector(dm, x);CHKERRQ(ierr);
+#ifdef MOAB_HDF5_H
+    ierr = DMMoabOutput(dm, "ex35.h5m", "");CHKERRQ(ierr);
+#else
+    /* MOAB does not support true parallel writers that aren't HDF5 based
+       And so if you are using VTK as the output format in parallel,
+       the data could be jumbled due to the order in which the processors
+       write out their parts of the mesh and solution tags
+    */
+    ierr = DMMoabOutput(dm, "ex35.vtk", "");CHKERRQ(ierr);
+#endif
+  }
 
   /* Cleanup objects */
   ierr = DMDestroy(&dm);CHKERRQ(ierr);

src/ksp/ksp/examples/tutorials/makefile

 TESTEXAMPLES_SUPERLU_DIST      = ex10.PETSc runex10_superlu_dist_lu_1 runex10_superlu_dist_lu_2 runex10_superlu_dist_redundant ex10.rm
 TESTEXAMPLES_CUDA              = ex10.PETSc runex10_aijcusparse ex10.rm
 TESTEXAMPLES_PCBDDC            = ex59.PETSc runex59 runex59_2 runex59_3 ex59.rm
-TESTEXAMPLES_MOAB              = ex35.PETSc runex35 runex35_2 ex35.rm
+TESTEXAMPLES_MOAB              = ex35.PETSc runex35 ex35.rm
+TESTEXAMPLES_MOAB_HDF5         = ex35.PETSc runex35_2 ex35.rm
 
 include ${PETSC_DIR}/conf/test

src/ts/examples/tutorials/ex30.cxx

   PetscReal uleft,uright;       /* Dirichlet boundary conditions */
   PetscReal vleft,vright;       /* Dirichlet boundary conditions */
   PetscInt  npts;               /* Number of mesh points */
+  PetscBool io;
 
   moab::ParallelComm *pcomm;
   moab::Interface *mbint;
   ierr = PetscPrintf(PETSC_COMM_WORLD,"%s at time %g after %D steps\n",TSConvergedReasons[reason],(double)ftime,steps);CHKERRQ(ierr);
 
   /* Write out the final mesh */
-  merr = user.mbint->write_file("ex30.h5m");MBERRNM(merr);
+  if (user.io) {
+#ifdef MOAB_HDF5_H
+    merr = user.mbint->write_file("ex30.h5m");MBERRNM(merr);
+#else
+    merr = user.mbint->write_file("ex30.vtk");MBERRNM(merr);
+#endif
+  }
 
   ierr = VecView(X,PETSC_VIEWER_STDOUT_WORLD);CHKERRQ(ierr);
 
 
   PetscFunctionBegin;
 
-  ierr = PetscOptionsBegin(PETSC_COMM_WORLD,NULL,"Advection-reaction options",""); {
+  ierr = PetscOptionsBegin(PETSC_COMM_WORLD,NULL,"Advection-reaction options","ex30.cxx"); {
     user.A      = 1;
     user.B      = 3;
     user.alpha  = 0.02;
     user.vleft  = 3;
     user.vright = 3;
     user.npts   = 11;
-    ierr = PetscOptionsReal("-A","Reaction rate","",user.A,&user.A,NULL);CHKERRQ(ierr);
-    ierr = PetscOptionsReal("-B","Reaction rate","",user.B,&user.B,NULL);CHKERRQ(ierr);
-    ierr = PetscOptionsReal("-alpha","Diffusion coefficient","",user.alpha,&user.alpha,NULL);CHKERRQ(ierr);
-    ierr = PetscOptionsReal("-uleft","Dirichlet boundary condition","",user.uleft,&user.uleft,NULL);CHKERRQ(ierr);
-    ierr = PetscOptionsReal("-uright","Dirichlet boundary condition","",user.uright,&user.uright,NULL);CHKERRQ(ierr);
-    ierr = PetscOptionsReal("-vleft","Dirichlet boundary condition","",user.vleft,&user.vleft,NULL);CHKERRQ(ierr);
-    ierr = PetscOptionsReal("-vright","Dirichlet boundary condition","",user.vright,&user.vright,NULL);CHKERRQ(ierr);
-    ierr = PetscOptionsInt("-npts","Number of mesh points","",user.npts,&user.npts,NULL);CHKERRQ(ierr);
+    user.io     = PETSC_FALSE;
+    ierr = PetscOptionsReal("-A","Reaction rate","ex30.cxx",user.A,&user.A,NULL);CHKERRQ(ierr);
+    ierr = PetscOptionsReal("-B","Reaction rate","ex30.cxx",user.B,&user.B,NULL);CHKERRQ(ierr);
+    ierr = PetscOptionsReal("-alpha","Diffusion coefficient","ex30.cxx",user.alpha,&user.alpha,NULL);CHKERRQ(ierr);
+    ierr = PetscOptionsReal("-uleft","Dirichlet boundary condition","ex30.cxx",user.uleft,&user.uleft,NULL);CHKERRQ(ierr);
+    ierr = PetscOptionsReal("-uright","Dirichlet boundary condition","ex30.cxx",user.uright,&user.uright,NULL);CHKERRQ(ierr);
+    ierr = PetscOptionsReal("-vleft","Dirichlet boundary condition","ex30.cxx",user.vleft,&user.vleft,NULL);CHKERRQ(ierr);
+    ierr = PetscOptionsReal("-vright","Dirichlet boundary condition","ex30.cxx",user.vright,&user.vright,NULL);CHKERRQ(ierr);
+    ierr = PetscOptionsInt("-npts","Number of mesh points","ex30.cxx",user.npts,&user.npts,NULL);CHKERRQ(ierr);
+    ierr = PetscOptionsBool("-io", "Write out the solution and mesh data", "ex30.cxx", user.io, &user.io, NULL);CHKERRQ(ierr);
   } ierr = PetscOptionsEnd();CHKERRQ(ierr);
 
   user.mbint = new moab::Core;

src/ts/examples/tutorials/ex35.cxx

   PetscFunctionBegin;
   ierr = PetscNew(&user);CHKERRQ(ierr);
 
-  ierr = PetscOptionsBegin(PETSC_COMM_WORLD,NULL,"Advection-reaction options","");
+  ierr = PetscOptionsBegin(PETSC_COMM_WORLD,NULL,"Advection-reaction options","ex35.cxx");
   {
     user->nvars  = 2;
     user->A      = 1;
     user->ntsteps = 10000;
     user->ftype = 0;
     user->io = PETSC_FALSE;
-    ierr = PetscOptionsReal("-A","Reaction rate","",user->A,&user->A,NULL);CHKERRQ(ierr);
-    ierr = PetscOptionsReal("-B","Reaction rate","",user->B,&user->B,NULL);CHKERRQ(ierr);
-    ierr = PetscOptionsReal("-alpha","Diffusion coefficient","",user->alpha,&user->alpha,NULL);CHKERRQ(ierr);
-    ierr = PetscOptionsReal("-uleft","Dirichlet boundary condition","",user->leftbc.u,&user->leftbc.u,NULL);CHKERRQ(ierr);
-    ierr = PetscOptionsReal("-uright","Dirichlet boundary condition","",user->rightbc.u,&user->rightbc.u,NULL);CHKERRQ(ierr);
-    ierr = PetscOptionsReal("-vleft","Dirichlet boundary condition","",user->leftbc.v,&user->leftbc.v,NULL);CHKERRQ(ierr);
-    ierr = PetscOptionsReal("-vright","Dirichlet boundary condition","",user->rightbc.v,&user->rightbc.v,NULL);CHKERRQ(ierr);
-    ierr = PetscOptionsInt("-n","Number of 1-D elements","",user->n,&user->n,NULL);CHKERRQ(ierr);
-    ierr = PetscOptionsInt("-ndt","Number of time steps","",user->ntsteps,&user->ntsteps,NULL);CHKERRQ(ierr);
-    ierr = PetscOptionsInt("-ftype","Type of function evaluation model for FEM assembly","",user->ftype,&user->ftype,NULL);CHKERRQ(ierr);
-    ierr = PetscOptionsBool("-io","Write the mesh and solution output to a file.","",user->io,&user->io,NULL);CHKERRQ(ierr);
+    ierr = PetscOptionsReal("-A","Reaction rate","ex35.cxx",user->A,&user->A,NULL);CHKERRQ(ierr);
+    ierr = PetscOptionsReal("-B","Reaction rate","ex35.cxx",user->B,&user->B,NULL);CHKERRQ(ierr);
+    ierr = PetscOptionsReal("-alpha","Diffusion coefficient","ex35.cxx",user->alpha,&user->alpha,NULL);CHKERRQ(ierr);
+    ierr = PetscOptionsReal("-uleft","Dirichlet boundary condition","ex35.cxx",user->leftbc.u,&user->leftbc.u,NULL);CHKERRQ(ierr);
+    ierr = PetscOptionsReal("-uright","Dirichlet boundary condition","ex35.cxx",user->rightbc.u,&user->rightbc.u,NULL);CHKERRQ(ierr);
+    ierr = PetscOptionsReal("-vleft","Dirichlet boundary condition","ex35.cxx",user->leftbc.v,&user->leftbc.v,NULL);CHKERRQ(ierr);
+    ierr = PetscOptionsReal("-vright","Dirichlet boundary condition","ex35.cxx",user->rightbc.v,&user->rightbc.v,NULL);CHKERRQ(ierr);
+    ierr = PetscOptionsInt("-n","Number of 1-D elements","ex35.cxx",user->n,&user->n,NULL);CHKERRQ(ierr);
+    ierr = PetscOptionsInt("-ndt","Number of time steps","ex35.cxx",user->ntsteps,&user->ntsteps,NULL);CHKERRQ(ierr);
+    ierr = PetscOptionsInt("-ftype","Type of function evaluation model for FEM assembly","ex35.cxx",user->ftype,&user->ftype,NULL);CHKERRQ(ierr);
+    ierr = PetscOptionsBool("-io","Write the mesh and solution output to a file.","ex35.cxx",user->io,&user->io,NULL);CHKERRQ(ierr);
     user->npts   = user->n+1;
   }
   ierr = PetscOptionsEnd();CHKERRQ(ierr);
 
     /* Write out the solution along with the mesh */
     ierr = DMMoabSetGlobalFieldVector(dm, X);CHKERRQ(ierr);
-    ierr = DMMoabOutput(dm, "ex1.h5m", "");CHKERRQ(ierr);
+#ifdef MOAB_HDF5_H
+    ierr = DMMoabOutput(dm, "ex35.h5m", "");CHKERRQ(ierr);
+#else
+    /* MOAB does not support true parallel writers that aren't HDF5 based
+       And so if you are using VTK as the output format in parallel,
+       the data could be jumbled due to the order in which the processors
+       write out their parts of the mesh and solution tags
+    */
+    ierr = DMMoabOutput(dm, "ex35.vtk", "");CHKERRQ(ierr);
+#endif
   }
 
   /* Free work space.

src/ts/examples/tutorials/makefile

 TESTEXAMPLES_13		  = ex2.PETSc ex2.rm ex3.PETSc ex3.rm ex4.PETSc ex4.rm \
                             ex5.PETSc ex5.rm
 TESTEXAMPLES_EXODUSII     = ex11.PETSc runex11 ex11.rm
-TESTEXAMPLES_MOAB         = ex30.PETSc runex30 ex30.rm ex35.PETSc runex35 runex35_2 ex35.rm
+TESTEXAMPLES_MOAB         = ex30.PETSc runex30 ex30.rm ex35.PETSc runex35 ex35.rm
+TESTEXAMPLES_MOAB_HDF5    = ex30.PETSc runex30_2 ex30.rm ex35.PETSc runex35_2 ex35.rm
 
 include ${PETSC_DIR}/conf/test