Hello, guys! (:<br><br>I've been trying to code a program that solves a simple 3D diffusion-convection problem, but there'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> ierr = SNESSolve(snes, PETSC_NULL, x); CHKERRQ(ierr);<br>
<br>Here's the main function: (I removed several comments of mine to make it smaller)<br><br>typedef struct {<br> 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__ "main"<br><br>int main(int argc, char **argv) {<br> SNES snes;<br> Mat J;<br> appContext ctx;<br> Vec x, r;<br> PetscErrorCode ierr;<br> PetscScalar hx, hy, hz;<br>
<br> PetscInitialize(&argc, &argv, (char*) 0, help);<br><br> ierr = PetscOptionsGetInt(PETSC_NULL, "-y", &M, PETSC_NULL); CHKERRQ(ierr);<br> ierr = PetscOptionsGetInt(PETSC_NULL, "-x", &N, PETSC_NULL); CHKERRQ(ierr);<br>
ierr = PetscOptionsGetInt(PETSC_NULL, "-z", &P, PETSC_NULL); CHKERRQ(ierr);<br><br> hx = 1.0 / (N+1); hy = 1.0 / (M+1); hz = 1.0 / (P+1);<br><br>// global variables<br> Hx2 = 1.0 / (2.0*hx*hx); Hy2 = 1.0 / (2.0*hy*hy); Hz2 = 1.0 / (2.0*hz*hz);<br>
Hx = 1.0 / (hx*hx); Hy = 1.0 / (hy*hy); Hz = 1.0 / (hz*hz);<br><br> ierr = SNESCreate(PETSC_COMM_WORLD, &snes); CHKERRQ(ierr);<br><br> 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, &ctx.da);<br>
<br> ierr = DACreateGlobalVector(ctx.da, &x); CHKERRQ(ierr);<br> ierr = VecDuplicate(x, &r); CHKERRQ(ierr);<br><br> ierr = DAGetMatrix(ctx.da, MATAIJ, &J); CHKERRQ(ierr);<br><br> ierr = SNESSetFunction(snes, r, computeFVector, &ctx); CHKERRQ(ierr);<br>
ierr = SNESSetJacobian(snes, J, J, computeJacobian, &ctx); CHKERRQ(ierr);<br><br> ierr = SNESSetFromOptions(snes); CHKERRQ(ierr);<br><br> ierr = formInitialGuess(x); CHKERRQ(ierr);<br> ierr = SNESSolve(snes, PETSC_NULL, x); CHKERRQ(ierr);<br>
<br> ierr = VecDestroy(x); CHKERRQ(ierr);<br> ierr = VecDestroy(r); CHKERRQ(ierr);<br> ierr = MatDestroy(J); CHKERRQ(ierr);<br> ierr = SNESDestroy(snes); CHKERRQ(ierr);<br> ierr = DADestroy(ctx.da); CHKERRQ(ierr);<br>
ierr = PetscFinalize(); CHKERRQ(ierr);<br><br> PetscFunctionReturn(0);<br>}<br><br><br>What am I missing here?<br><br>Regards,<br><br>Rafael Santos Coelho<br>