PetscMap no longer public

2006-06-21 Thread Barry Smith

   Bram,

Sorry for the delay. I've attached a new src/vec/vec/impls/mpi/pmap.c
just drop it in  and do make lib shared in that directory. Also add the 
following lines to include/private/vecimpl.h

EXTERN PetscErrorCode PETSCVEC_DLLEXPORT 
PetscMapSetLocalSize(PetscMap*,PetscInt);
EXTERN PetscErrorCode PETSCVEC_DLLEXPORT 
PetscMapGetLocalSize(PetscMap*,PetscInt *);
PetscPolymorphicFunction(PetscMapGetLocalSize,(PetscMap m),(m,s),PetscInt,s)
EXTERN PetscErrorCode PETSCVEC_DLLEXPORT PetscMapSetSize(PetscMap*,PetscInt);
EXTERN PetscErrorCode PETSCVEC_DLLEXPORT PetscMapGetSize(PetscMap*,PetscInt *);
PetscPolymorphicFunction(PetscMapGetSize,(PetscMap m),(m,s),PetscInt,s)
EXTERN PetscErrorCode PETSCVEC_DLLEXPORT 
PetscMapGetLocalRange(PetscMap*,PetscInt *,PetscInt *);
EXTERN PetscErrorCode PETSCVEC_DLLEXPORT 
PetscMapGetGlobalRange(PetscMap*,PetscInt *[]);
EXTERN PetscErrorCode PETSCVEC_DLLEXPORT 
PetscMapSetSizeBlockSize(PetscMap*,PetscInt);
EXTERN PetscErrorCode PETSCVEC_DLLEXPORT 
PetscMapGetSizeBlockSize(PetscMap*,PetscInt *);

   The manual pages are in the pmap.c file. Please let us know if you have
any difficulties.

Barry



On Mon, 19 Jun 2006, Bram Metsch wrote:

 Hi,

 in PETSc 2.3.1, PetscMap is not longer a public object. However, my code
 depends quite a lot on this object and its functions like
 PetscMapGetGlobalRange. So far I have not managed to port
 my code to version 2.3.1. Is there another way to obtain functionality
 of the PetscMap object?

 Best regards,

 Bram Metsch

-- next part --
#define PETSCVEC_DLL
/*
   This file contains routines for basic map object implementation.
*/

#include private/vecimpl.h   /*I  petscvec.h   I*/
/*@C
 PetscMapInitialize - given a map where you have set either the global or 
local
   size sets up the map so that it may be used.

Collective on MPI_Comm

   Input Parameters:
+comm - the MPI communicator
-map - pointer to the map

   Level: intermediate

Notes:
   You must call PetscMapSetBlockSize() and either PetscMapSetSize() or 
PetscMapSetLocalSize()
   before calling this routine.

   Unlike regular PETSc objects you work with a pointer to the object 
instead of 
 the object directly.

Fortran Notes: 
  Not available from Fortran

.seealso: PetscMapSetLocalSize(), PetscMapSetSize(), PetscMapGetSize(), 
PetscMapGetLocalSize(),
  PetscMapGetLocalRange(), PetscMapGetGlobalRange(), 
PetscMapSetBlockSize(), PetscMapGetBlockSize()

@*/
#undef __FUNCT__  
#define __FUNCT__ PetscMapInitialize
PetscErrorCode PETSCVEC_DLLEXPORT PetscMapInitialize(MPI_Comm comm,PetscMap 
*map)
{
  PetscMPIIntrank,size;
  PetscInt   p;
  PetscErrorCode ierr;

  PetscFunctionBegin;
  ierr = MPI_Comm_size(comm, size);CHKERRQ(ierr);
  ierr = MPI_Comm_rank(comm, rank);CHKERRQ(ierr); 
  if (map-bs =0) {SETERRQ(PETSC_ERR_ARG_WRONGSTATE,BlockSize not yet set);}
  if (map-n  0) map-n = map-n/map-bs;
  if (map-N  0) map-N = map-N/map-bs;
  ierr = PetscSplitOwnership(comm,map-n,map-N);CHKERRQ(ierr);
  map-n = map-n*map-bs;
  map-N = map-N*map-bs;
  if (!map-range) {
ierr = PetscMalloc((size+1)*sizeof(PetscInt), map-range);CHKERRQ(ierr);
  }
  ierr = MPI_Allgather(map-n, 1, MPIU_INT, map-range+1, 1, MPIU_INT, 
comm);CHKERRQ(ierr);

  map-range[0] = 0;
  for(p = 2; p = size; p++) {
map-range[p] += map-range[p-1];
  }

  map-rstart = map-range[rank];
  map-rend   = map-range[rank+1];
  PetscFunctionReturn(0);
}

#undef __FUNCT__  
#define __FUNCT__ PetscMapCopy
PetscErrorCode PETSCVEC_DLLEXPORT PetscMapCopy(MPI_Comm comm,PetscMap 
*in,PetscMap *out)
{
  PetscMPIIntsize;
  PetscErrorCode ierr;
  PetscInt   *range = out-range;

  PetscFunctionBegin;
  ierr = MPI_Comm_size(comm,size);CHKERRQ(ierr);
  ierr = PetscMemcpy(out,in,sizeof(PetscMap));CHKERRQ(ierr);
  if (!range) {
ierr = PetscMalloc((size+1)*sizeof(PetscInt),out-range);CHKERRQ(ierr);
  } else {
out-range = range;
  }
  ierr = 
PetscMemcpy(out-range,in-range,(size+1)*sizeof(PetscInt));CHKERRQ(ierr);
  PetscFunctionReturn(0);
}

/*@C
 PetscMapSetLocalSize - Sets the local size for a PetscMap object.

Collective on PetscMap

   Input Parameters:
+map - pointer to the map
-n - the local size

   Level: intermediate

Notes:
   Call this after the call to PetscMapInitialize()

   Unlike regular PETSc objects you work with a pointer to the object 
instead of 
 the object directly.

Fortran Notes: 
  Not available from Fortran

.seealso: PetscMapInitialize(), PetscMapSetSize(), PetscMapGetSize(), 
PetscMapGetLocalSize(),
  PetscMapGetLocalRange(), PetscMapGetGlobalRange(), 
PetscMapSetBlockSize(), PetscMapGetBlockSize()

@*/
#undef __FUNCT__  
#define __FUNCT__ PetscMapSetLocalSize
PetscErrorCode PETSCVEC_DLLEXPORT PetscMapSetLocalSize(PetscMap *map,PetscInt n)
{
  PetscFunctionBegin;
  map-n = n;
  PetscFunctionReturn(0);
}

/*@C
 PetscMapGetLocalSize - Gets the local 

PetscMap no longer public

2006-06-19 Thread Bram Metsch
Hi,

in PETSc 2.3.1, PetscMap is not longer a public object. However, my code
depends quite a lot on this object and its functions like
PetscMapGetGlobalRange. So far I have not managed to port
my code to version 2.3.1. Is there another way to obtain functionality
of the PetscMap object?

Best regards,

Bram Metsch 
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: not available
URL: 
http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20060619/eb828d7d/attachment.pgp


PetscMap no longer public

2006-06-19 Thread Barry Smith

   Bram,

  I appologize for excluding those functions from the last release.
I will get them back into the development copy and send you a patch
as soon as I can.

  Barry


On Mon, 19 Jun 2006, Bram Metsch wrote:

 Hi,

 in PETSc 2.3.1, PetscMap is not longer a public object. However, my code
 depends quite a lot on this object and its functions like
 PetscMapGetGlobalRange. So far I have not managed to port
 my code to version 2.3.1. Is there another way to obtain functionality
 of the PetscMap object?

 Best regards,

 Bram Metsch