File 3dgf.c

RCS Header: /cvsroot/petscgraphics/3dgf.c,v 1.12 2003/04/29 13:38:37 hazelsct Exp

This is a neat 3-D graphing application of Illuminator. Just put whatever function you like down in line 110 or so (or graph the examples provided), or run with -twodee and use PETSc's native 2-D graphics (though that would be BORING!). You might want to run it as:

./3dgf -da_grid_x 50 -da_grid_y 50 -da_grid_z 50
and hit return to end.


Included Files


Preprocessor definitions

#define DPRINTF( fmt, args... )

#define __FUNCT__ "function_3d"

#define __FUNCT__ "function_2d"

#define __FUNCT__ "main"


Local Variables

help
static char help[]

Global Function main()

The usual main function.

int main ( int argc, char** argv )

int main
Returns 0 or error.
int argc
Number of args.
char** argv
The args.
The program first calls PetscInitialize() and creates the distributed arrays. Note that even though this program doesn't do any communication between the CPUs, illuminator must do so in order to make the isoquants at CPU boundaries, so the stencil width must be at least one.
Next it gets the distributed array's local corner and global size information. It gets the global vector, and loops over the part stored on this CPU to set all of the function values, using function_3d() or function_2d() depending on whether the -twodee command line switch was used at runtime.
It then uses GeomviewBegin() or PetscViewerDrawOpen() to start the viewer, and either DATriangulate() and GeomviewDisplayTriangulation() or VecView() to display the solution.
Finally, it prompts the user to hit <return> before wrapping up.


Local Function function_2d()

This is where you put the 2-D function you'd like to graph using PETSc's native 2-D "contour" color graphics.

static inline PetscScalar function_2d ( PetscScalar x, PetscScalar y )

PetscScalar function_2d
It returns the function value.
PetscScalar x
The x-coordinate at which to calculate the function value.
PetscScalar y
The y-coordinate at which to calculate the function value.

Local Function function_3d()

This is where you put the 3-D function you'd like to graph, or the 2-D function you'd like to graph in 3-D using the zero contour of f(x,y)-z.

static inline PetscScalar function_3d ( PetscScalar x, PetscScalar y, PetscScalar z )

PetscScalar function_3d
It returns the function value.
PetscScalar x
The x-coordinate at which to calculate the function value.
PetscScalar y
The y-coordinate at which to calculate the function value.
PetscScalar z
The z-coordinate at which to calculate the function value.