[petsc-users] DASetCoordinates

Randall Mackie rlmackie862 at gmail.com
Wed Oct 6 16:19:50 CDT 2010


>
>
> >
> > Maybe I'm just being dense, but I don't see how or where I set these at
> each level within
> > the DMMG framework.  Isn't all that buried within the DMMG routines, or
> is there some
> > way for me to specify this?
>
> It's kinda raw:
>
>    for (i=0; i<DMMGGetLevels(dmmg); i++) {
>      DA da = (DA)dmmg[i]->dm;
>      /* Set coordinates */
>    }
>


I'm trying to write a wrapper in c to do this, but as a first step I'm just
trying to set
uniform coordinates at each level. However, I am simultaneously trying to
learn c, learn about pointers,
and figure out how this all works with PETSc, and I am having a problem
which is probably
very obvious to you expert c programmers, but not obvious to me (a long-time
fortran programmer).

Here is what I have so far, which is based largely on what Jed wrote above
and zdmmg.c which
is one of the Fortran wrappers you guys have written:


#include "private/fortranimpl.h"
#include "petscda.h"
#include "petscdmmg.h"

#if defined(PETSC_HAVE_FORTRAN_CAPS)
#define dasetcoords_          DASETCOORDS
#elif !defined(PETSC_HAVE_FORTRAN_UNDERSCORE)
#define dasetcoords_          dasetcoords
#endif

EXTERN_C_BEGIN

void PETSC_STDCALL dasetcoords_(DMMG **dmmg, PetscErrorCode *ierr)
{
 PetscInt i, nlev;

 nlev = DMMGGetLevels(*dmmg);
 printf("The number of levels is %d \n",nlev);

 for (i=0; i < nlev; i++){
  DA da = (DA)dmmg[i]->dm;
  *ierr = DASetUniformCoordinates(da,0.0,1.0,0.0,1.0,0.0,1.0);
  }
}

EXTERN_C_END


But when I compile it I get:

dasetcoords.c(22): error: expression must have pointer-to-struct-or-union
type
    DA da = (DA)dmmg[i]->dm;
                ^


So, I've tried various things, but can't figure out how to do this
correctly. Can someone who
is a c expert help me here on how to get the DA set for each level?

Thanks, Randy M.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20101006/e4453cdd/attachment.htm>


More information about the petsc-users mailing list