Hello, guys! (:<br><br>I&#39;ve been trying to code a program that solves a simple 3D diffusion-convection problem, but there&#39;s something weird going on. Whenever I run it, I get the following error message:<br><br>$ mpirun -np 1 ./ex8 -x 8 -y 8 -z 8 <br>
[0]PETSC ERROR: --------------------- Error Message ------------------------------------<br>[0]PETSC ERROR: Invalid argument!<br>[0]PETSC ERROR: Wrong type of object: Parameter # 2!<br>[0]PETSC ERROR: ------------------------------------------------------------------------<br>
[0]PETSC ERROR: VecMaxPointwiseDivide() line 35 in src/vec/vec/interface/rvector.c<br>[0]PETSC ERROR: SNESLineSearchCubic() line 544 in src/snes/impls/ls/ls.c<br>[0]PETSC ERROR: SNESSolve_LS() line 211 in src/snes/impls/ls/ls.c<br>
[0]PETSC ERROR: SNESSolve() line 1871 in src/snes/interface/snes.c<br>[0]PETSC ERROR: main() line 135 in src/snes/examples/tutorials/ex8.c<br><br>Well, line 135 is:<br>&nbsp;&nbsp; ierr = SNESSolve(snes, PETSC_NULL, x); CHKERRQ(ierr);<br>
<br>Here&#39;s the main function: (I removed several comments of mine to make it smaller)<br><br>typedef struct {<br>&nbsp;&nbsp; DA da;<br>} appContext;<br><br>PetscScalar Hx, Hy, Hz, Hx2, Hy2, Hz2;<br>PetscInt M = 9, N = 9, P = 9;<br>
<br>#undef __FUNCT__<br>#define __FUNCT__ &quot;main&quot;<br><br>int main(int argc, char **argv) {<br>&nbsp;&nbsp; SNES snes;<br>&nbsp;&nbsp; Mat J;<br>&nbsp;&nbsp; appContext ctx;<br>&nbsp;&nbsp; Vec x, r;<br>&nbsp;&nbsp; PetscErrorCode ierr;<br>&nbsp;&nbsp; PetscScalar hx, hy, hz;<br>
<br>&nbsp;&nbsp; PetscInitialize(&amp;argc, &amp;argv, (char*) 0, help);<br><br>&nbsp;&nbsp; ierr = PetscOptionsGetInt(PETSC_NULL, &quot;-y&quot;, &amp;M, PETSC_NULL); CHKERRQ(ierr);<br>&nbsp;&nbsp; ierr = PetscOptionsGetInt(PETSC_NULL, &quot;-x&quot;, &amp;N, PETSC_NULL); CHKERRQ(ierr);<br>
&nbsp;&nbsp; ierr = PetscOptionsGetInt(PETSC_NULL, &quot;-z&quot;, &amp;P, PETSC_NULL); CHKERRQ(ierr);<br><br>&nbsp;&nbsp; hx = 1.0 / (N+1); hy = 1.0 / (M+1); hz = 1.0 / (P+1);<br><br>// global variables<br>&nbsp;&nbsp; Hx2 = 1.0 / (2.0*hx*hx); Hy2 = 1.0 / (2.0*hy*hy); Hz2 = 1.0 / (2.0*hz*hz);<br>
&nbsp;&nbsp; Hx = 1.0 / (hx*hx); Hy = 1.0 / (hy*hy); Hz = 1.0 / (hz*hz);<br><br>&nbsp;&nbsp; ierr = SNESCreate(PETSC_COMM_WORLD, &amp;snes); CHKERRQ(ierr);<br><br>&nbsp;&nbsp; ierr = DACreate3d(PETSC_COMM_WORLD, DA_NONPERIODIC, DA_STENCIL_STAR, M, N, P, PETSC_DECIDE, PETSC_DECIDE, PETSC_DECIDE, 1, 1, PETSC_NULL, PETSC_NULL, PETSC_NULL, &amp;ctx.da);<br>
<br>&nbsp;&nbsp; ierr = DACreateGlobalVector(ctx.da, &amp;x); CHKERRQ(ierr);<br>&nbsp;&nbsp; ierr = VecDuplicate(x, &amp;r); CHKERRQ(ierr);<br><br>&nbsp;&nbsp; ierr = DAGetMatrix(ctx.da, MATAIJ, &amp;J); CHKERRQ(ierr);<br><br>&nbsp;&nbsp; ierr = SNESSetFunction(snes, r, computeFVector, &amp;ctx); CHKERRQ(ierr);<br>
&nbsp; ierr = SNESSetJacobian(snes, J, J, computeJacobian, &amp;ctx); CHKERRQ(ierr);<br><br>&nbsp;&nbsp; ierr = SNESSetFromOptions(snes); CHKERRQ(ierr);<br><br>&nbsp;&nbsp; ierr = formInitialGuess(x); CHKERRQ(ierr);<br>&nbsp;&nbsp; ierr = SNESSolve(snes, PETSC_NULL, x); CHKERRQ(ierr);<br>
<br>&nbsp;&nbsp; ierr = VecDestroy(x); CHKERRQ(ierr);<br>&nbsp;&nbsp; ierr = VecDestroy(r); CHKERRQ(ierr);<br>&nbsp;&nbsp; ierr = MatDestroy(J); CHKERRQ(ierr);<br>&nbsp;&nbsp; ierr = SNESDestroy(snes); CHKERRQ(ierr);<br>&nbsp;&nbsp; ierr = DADestroy(ctx.da); CHKERRQ(ierr);<br>
&nbsp;&nbsp; ierr = PetscFinalize(); CHKERRQ(ierr);<br><br>&nbsp;&nbsp; PetscFunctionReturn(0);<br>}<br><br><br>What am I missing here?<br><br>Regards,<br><br>Rafael Santos Coelho<br>