Commits

Vijay Mahadevan  committed 78e0bf7

Making sure that the interface is const correct when dealing with MOAB objects on the getter methods.

  • Participants
  • Parent commits f9f41ee
  • Branches dmmoab

Comments (0)

Files changed (5)

File include/petscdmmoab.h

 PETSC_EXTERN PetscErrorCode DMMoabGetInterface(DM dm,moab::Interface **iface);
 PETSC_EXTERN PetscErrorCode DMMoabSetLocalVertices(DM dm,moab::Range *range);
 PETSC_EXTERN PetscErrorCode DMMoabGetAllVertices(DM dm,moab::Range *local);
-PETSC_EXTERN PetscErrorCode DMMoabGetLocalVertices(DM dm,moab::Range *owned,moab::Range *ghost);
+PETSC_EXTERN PetscErrorCode DMMoabGetLocalVertices(DM dm,const moab::Range **owned,const moab::Range **ghost);
 PETSC_EXTERN PetscErrorCode DMMoabSetLocalElements(DM dm,moab::Range *range);
-PETSC_EXTERN PetscErrorCode DMMoabGetLocalElements(DM dm,moab::Range *range);
+PETSC_EXTERN PetscErrorCode DMMoabGetLocalElements(DM dm,const moab::Range **range);
 PETSC_EXTERN PetscErrorCode DMMoabSetLocalToGlobalTag(DM dm,moab::Tag ltogtag);
 PETSC_EXTERN PetscErrorCode DMMoabGetLocalToGlobalTag(DM dm,moab::Tag *ltog_tag);
 PETSC_EXTERN PetscErrorCode DMMoabSetBlockSize(DM dm,PetscInt bs);
 PETSC_EXTERN PetscErrorCode DMMoabVecGetArray(DM,Vec,void*);
 PETSC_EXTERN PetscErrorCode DMMoabVecRestoreArray(DM,Vec,void*);
 
-PETSC_EXTERN PetscErrorCode DMMoabCreateVector(DM dm, moab::Tag tag,moab::Range *range,PetscBool serial, PetscBool destroy_tag,Vec *X);
+PETSC_EXTERN PetscErrorCode DMMoabCreateVector(DM dm, moab::Tag tag,const moab::Range *range,PetscBool serial, PetscBool destroy_tag,Vec *X);
 PETSC_EXTERN PetscErrorCode DMMoabCreateMatrix(DM dm, MatType mtype,Mat *J);
 PETSC_EXTERN PetscErrorCode DMMoabGetVecTag(Vec vec,moab::Tag *tag);
 PETSC_EXTERN PetscErrorCode DMMoabGetVecRange(Vec vec,moab::Range *range);

File src/dm/impls/moab/dmmbvec.cxx

 
 #undef __FUNCT__
 #define __FUNCT__ "DMMoab_CreateVector_Private"
-PetscErrorCode DMMoab_CreateVector_Private(DM dm,moab::Tag tag,moab::Range* userrange,PetscBool is_global_vec,PetscBool destroy_tag,Vec *vec)
+PetscErrorCode DMMoab_CreateVector_Private(DM dm,moab::Tag tag,const moab::Range* userrange,PetscBool is_global_vec,PetscBool destroy_tag,Vec *vec)
 {
   PetscErrorCode         ierr;
   moab::ErrorCode        merr;
   PetscBool              is_newtag;
-  moab::Range           *range;
+  const moab::Range      *range;
   PetscInt               count,lnative_vec,gnative_vec;
   std::string ttname;
   PetscScalar *data_ptr;
 
 .keywords: DMMoab, create
 @*/
-PetscErrorCode DMMoabCreateVector(DM dm,moab::Tag tag,moab::Range* range,PetscBool is_global_vec,PetscBool destroy_tag,Vec *vec)
+PetscErrorCode DMMoabCreateVector(DM dm,moab::Tag tag,const moab::Range* range,PetscBool is_global_vec,PetscBool destroy_tag,Vec *vec)
 {
   PetscErrorCode     ierr;
 

File src/dm/impls/moab/dmmoab.cxx

 
 .keywords: DMMoab, create
 @*/
-PetscErrorCode DMMoabGetLocalVertices(DM dm,moab::Range *owned,moab::Range *ghost)
+PetscErrorCode DMMoabGetLocalVertices(DM dm,const moab::Range **owned,const moab::Range **ghost)
 {
   PetscFunctionBegin;
   PetscValidHeaderSpecific(dm,DM_CLASSID,1);
-  if (owned) *owned = *((DM_Moab*)dm->data)->vowned;
-  if (ghost) *ghost = *((DM_Moab*)dm->data)->vghost;
+  if (owned) *owned = ((DM_Moab*)dm->data)->vowned;
+  if (ghost) *ghost = ((DM_Moab*)dm->data)->vghost;
   PetscFunctionReturn(0);
 }
 
 
 .keywords: DMMoab, create
 @*/
-PetscErrorCode DMMoabGetLocalElements(DM dm,moab::Range *range)
+PetscErrorCode DMMoabGetLocalElements(DM dm,const moab::Range **range)
 {
   PetscFunctionBegin;
   PetscValidHeaderSpecific(dm,DM_CLASSID,1);
-  if (range) *range = *((DM_Moab*)dm->data)->elocal;
+  if (range) *range = ((DM_Moab*)dm->data)->elocal;
   PetscFunctionReturn(0);
 }
 

File src/dm/impls/moab/examples/tests/ex2.c

   moab::ErrorCode   merr;
   moab::Interface*  mbImpl;
   moab::Tag         solndofs;
-  moab::Range       ownedvtx;
+  const moab::Range *ownedvtx;
   const PetscReal   bounds[2] = {0.0,1.0};
   const char        *fields[2] = {"U","V"};
   PetscScalar       deflt[2]={0.0,0.0};
   merr = mbImpl->tag_get_handle("UNKNOWNS",2,moab::MB_TYPE_DOUBLE,solndofs,
                                   moab::MB_TAG_DENSE|moab::MB_TAG_CREAT,deflt);MBERRNM(merr);
 
-  ierr = DMMoabCreateVector(dm, solndofs, &ownedvtx, PETSC_TRUE, PETSC_FALSE, &X);CHKERRQ(ierr);
+  ierr = DMMoabCreateVector(dm, solndofs, ownedvtx, PETSC_TRUE, PETSC_FALSE, &X);CHKERRQ(ierr);
 
   ierr = FormInitialSolution(ts,X,user);CHKERRQ(ierr);
   ierr = TSSetSolution(ts,X);CHKERRQ(ierr);
   const Field       *x;
   Field             *f;
   PetscInt          dof_index;
-  moab::Range       ownedvtx;
+  const moab::Range *ownedvtx;
   PetscErrorCode    ierr;
 
   PetscFunctionBegin;
   ierr = DMMoabGetLocalVertices(dm, &ownedvtx, NULL);CHKERRQ(ierr);
 
   /* Compute function over the locally owned part of the grid */
-  for(moab::Range::iterator iter = ownedvtx.begin(); iter != ownedvtx.end(); iter++) {
+  for(moab::Range::iterator iter = ownedvtx->begin(); iter != ownedvtx->end(); iter++) {
     const moab::EntityHandle vhandle = *iter;
     ierr = DMMoabGetDofsBlockedLocal(dm, 1, &vhandle, &dof_index);CHKERRQ(ierr);
 
   PetscReal           hx;
   DM                  dm;
   moab::Interface*    mbImpl;
-  moab::Range         elocal;
+  const moab::Range   *elocal;
   PetscInt            dof_indices[2];
   PetscBool           elem_on_boundary;
 
   /* Compute function over the locally owned part of the grid 
      Assemble the operator by looping over edges and computing
      contribution for each vertex dof                         */
-  for(moab::Range::iterator iter = elocal.begin(); iter != elocal.end(); iter++) {
+  for(moab::Range::iterator iter = elocal->begin(); iter != elocal->end(); iter++) {
     const moab::EntityHandle ehandle = *iter;
 
     // Get connectivity information in canonical order
   Field             *x;
   PetscErrorCode    ierr;
   moab::Interface*  mbImpl;
-  moab::Range       vowned;
+  const moab::Range *vowned;
   PetscInt          dof_index;
   moab::Range::iterator iter;
 
   ierr = DMMoabVecGetArray(dm, X, &x);CHKERRQ(ierr);
 
   /* Compute function over the locally owned part of the grid */
-  for(moab::Range::iterator iter = vowned.begin(); iter != vowned.end(); iter++) {
+  for(moab::Range::iterator iter = vowned->begin(); iter != vowned->end(); iter++) {
     const moab::EntityHandle vhandle = *iter;
     ierr = DMMoabGetDofsBlockedLocal(dm, 1, &vhandle, &dof_index);CHKERRQ(ierr);
 
   const int& idx_left = dof_indices[0];
   const int& idx_right = dof_indices[1];
   moab::Interface*  mbImpl;
-  moab::Range       elocal;
+  const moab::Range   *elocal;
 
   PetscFunctionBegin;
   hx = 1.0/user->n;
   ierr = DMMoabVecGetArray(dm, F, &f);CHKERRQ(ierr);
 
   /* loop over local elements */
-  for(moab::Range::iterator iter = elocal.begin(); iter != elocal.end(); iter++) {
+  for(moab::Range::iterator iter = elocal->begin(); iter != elocal->end(); iter++) {
     const moab::EntityHandle ehandle = *iter;
 
     // Get connectivity information in canonical order
   PetscInt            i,vpere=2;
   const moab::EntityHandle *connect;
   moab::Interface*  mbImpl;
-  moab::Range       elocal;
+  const moab::Range   *elocal;
   PetscInt           *dofs;
   const int& idl = dof_indices[0];
   const int& idr = dof_indices[1];
      contribution for each vertex dof                         */
 
   /* loop over local elements */
-  for(moab::Range::iterator iter = elocal.begin(); iter != elocal.end(); iter++) {
+  for(moab::Range::iterator iter = elocal->begin(); iter != elocal->end(); iter++) {
     const moab::EntityHandle ehandle = *iter;
 
     // Get connectivity information in canonical order
   PetscInt            dof_indices[2];
 
   moab::Interface*  mbImpl;
-  moab::Range       elocal;
+  const moab::Range *elocal;
 
   PetscFunctionBegin;
   hx = 1.0/user->n;
   const int& idr = dof_indices[1];
 
   /* loop over local elements */
-  for(moab::Range::iterator iter = elocal.begin(); iter != elocal.end(); iter++) {
+  for(moab::Range::iterator iter = elocal->begin(); iter != elocal->end(); iter++) {
     const moab::EntityHandle ehandle = *iter;
 
     // Get connectivity information in canonical order

File src/dm/impls/moab/examples/tests/ex4.c

   PetscScalar       vpos[VPERE*3],quadrature[NQPTS*3],jxw[NQPTS];
   PetscInt          i,q,num_conn;
   const moab::EntityHandle *connect;
-  moab::Range       elocal;
+  const moab::Range *elocal;
   moab::Interface*  mbImpl;
   PetscScalar       phi[VPERE*NQPTS],localv[VPERE];
   PetscBool         elem_on_boundary;
   ierr = DMMoabGetLocalElements(dm, &elocal);CHKERRQ(ierr);
 
   /* loop over local elements */
-  for(moab::Range::iterator iter = elocal.begin(); iter != elocal.end(); iter++) {
+  for(moab::Range::iterator iter = elocal->begin(); iter != elocal->end(); iter++) {
     const moab::EntityHandle ehandle = *iter;
 
     ierr = PetscMemzero(localv,sizeof(PetscScalar)*VPERE);CHKERRQ(ierr);
 #define __FUNCT__ "ComputeMatrix_MOAB"
 PetscErrorCode ComputeMatrix_MOAB(KSP ksp,Mat J,Mat jac,MatStructure *str,void *ctx)
 {
-  UserContext    *user = (UserContext*)ctx;
-  DM            dm;
- 
-  PetscInt       i,j,q,num_conn;
-  PetscInt dof_indices[VPERE];
-  PetscScalar vpos[VPERE*3],quadrature[NQPTS*3],jxw[NQPTS];
-  PetscBool dbdry[VPERE];
+  UserContext       *user = (UserContext*)ctx;
+  DM                dm;
+  PetscInt          i,j,q,num_conn;
+  PetscInt          dof_indices[VPERE];
+  PetscScalar       vpos[VPERE*3],quadrature[NQPTS*3],jxw[NQPTS];
+  PetscBool         dbdry[VPERE];
   const moab::EntityHandle *connect;
-  moab::Range elocal;
+  const moab::Range *elocal;
   moab::Interface*  mbImpl;
   PetscBool         elem_on_boundary;
-  PetscScalar  array[VPERE*VPERE];
-  PetscScalar phi[VPERE*NQPTS], dphidx[VPERE*NQPTS], dphidy[VPERE*NQPTS];
-  PetscReal      rho;
-  PetscErrorCode ierr;
+  PetscScalar       array[VPERE*VPERE];
+  PetscScalar       phi[VPERE*NQPTS], dphidx[VPERE*NQPTS], dphidy[VPERE*NQPTS];
+  PetscReal         rho;
+  PetscErrorCode    ierr;
  
   PetscFunctionBeginUser;
   ierr      = KSPGetDM(ksp,&dm);CHKERRQ(ierr);
   ierr = DMMoabGetLocalElements(dm, &elocal);CHKERRQ(ierr);
 
   /* loop over local elements */
-  for(moab::Range::iterator iter = elocal.begin(); iter != elocal.end(); iter++) {
+  for(moab::Range::iterator iter = elocal->begin(); iter != elocal->end(); iter++) {
     const moab::EntityHandle ehandle = *iter;
 
     // Get connectivity information: