I made the change in the function so I now get this error
PetscErrorCode ComputeRho(DMMG *dmmg, Vec rho)
{
DA distA = (DA)dmmg->dm;
In function ‘PetscErrorCode Myfunc(_n_DMMG**, _p_Vec*)’:
error: request for member ‘dm’ in ‘* dmmg’, which is of non-class type ‘_n_DMMG*’
It looks like I have a null pointer to _n_DMMG** instead of _n_DMMG*
It seems like your code expects you to pass a DMMG object not a DMMG* object. There are two ways to fix this:
1) In your function 'ComputeRho' change all references of dmmg to *dmmg, i.e.:
DA distA = (DA)(*dmmg)->dm;
2) Change your function declaration back to what you had:
PetscErrorCode ComputeRho(DMMG dmmg, Vec rho)
{...}
and then pass the object to your function as so:
ComputeRho(*dmmg, b);
Do you need your dmmg to be a pointer in your 'main' function? It looks like your declaration could just be:
extern PetscErrorCode Myfunc(DMMG,Vec);
>>>>>>>>>>>>>>>>
int main(int argc,char **argv)
{
DMMG dmmg;
...Vec b;
Myfunc(dmmg,b)
}
PetscErrorCode Myfunc(DMMG dmmg, Vec b)
{
DA da = (DA)dmmg->dm;
.....
}
<<<<<<<<<<<<<<<<<
and that would fix everything.
Sean