[petsc-users] Problems ablout setting up variables and SNES
Yingjie Wu
yjwu16 at gmail.com
Mon Sep 17 03:22:13 CDT 2018
Dear Petsc developer:
Hi,
Thank you very much for your previous reply, recently I encountered some
problems in the implementation of the program.
1. Previously I used DMDA to create distributed variables (Variables are
different in each grids). Now I want to add a single variable (independent
of the grid). How do I add it? How do I write programs with distributed
variables and single variables exist at the same time?
I've created three "Field" variables before, and I'd like to add a single
variable. How should I describe it in the program? The codes are as below.
ierr=DMDACreate2d(PETSC_COMM_WORLD,DM_BOUNDARY_NONE,DM_BOUNDARY_NONE,DMDA_STENCIL_STAR,10,10,PETSC_DECIDE,PETSC_DECIDE,3,1,0,0,&da);CHKERRQ(ierr);
ierr = DMSetFromOptions(da);CHKERRQ(ierr);
ierr = DMSetUp(da);CHKERRQ(ierr);
ierr = SNESSetDM(snes,(DM)da);CHKERRQ(ierr);
ierr = DMDASetFieldName(da,0,"Pressure");CHKERRQ(ierr);
ierr = DMDASetFieldName(da,1,"Y-Velocity");CHKERRQ(ierr);
ierr = DMDASetFieldName(da,2,"Fluid_temperature");CHKERRQ(ierr);
ierr = DMCreateGlobalVector(da,&x);CHKERRQ(ierr);
2. At present, I am solving nonlinear equations. Now I need to do one-step
nonlinear calculation first, and then treat the results as coefficients for
the subsequent nonlinear calculation. Now I used to use SNESSolve()
directly to solve the problem. How can we calculate step by step and
process the result before entering the next nonlinear step?
Since I'm a beginner in PETSc, I would be grateful if there were any
examples.
I'm looking forward to your reply~
Thanks,
Yingjie
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20180917/0672f8c1/attachment.html>
More information about the petsc-users
mailing list