File diffuse.c

RCS Header: /cvsroot/rheoplast/diffuse.c,v 1.26 2004/08/18 21:19:52 hazelsct Exp

This uses the new explicit timestepping framework to solve the diffusion equation in finite differences really, really fast. (Yes, diffusion is boring, but you gotta start somewhere. :-)


Included Files


Preprocessor definitions

#define DPRINTF( fmt, args... )

Typedef AppCtx

typedef struct {...} AppCtx
struct 
   { 
     DA theda; 
     Vec global; 
     Vec local; 
     PetscScalar mesh_fourier_x; 
     PetscScalar mesh_fourier_y; 
     PetscScalar mesh_fourier_z; 
     int plotsteps; 
     PetscTruth contours; 
     PetscTruth twodee; 
     PetscViewer theviewer; 
     CommStyle style; 
   } 

Local Variables

help
PETSc help string, printed when run with -help.

static char help[]


Global Function func_interior_line()

void func_interior_line ( PetscScalar* x, PetscScalar* func, PetscScalar* temp, PetscTruth** mixed_constraints, PetscScalar time, int points, int gxm, int gym, int gzm, int xs, int ys, int zs, int xm, int nx, int ny, int nz, void* user )

Global Function jack_interior_line()

void jack_interior_line ( PetscScalar* x, PetscScalar* temp, Mat jack, PetscScalar time, int points, int gxm, int gym, int gzm, int xs, int ys, int zs, int xm, int nx, int ny, int nz, int firstrow, void* user )

Global Function main()

int main ( int argc, char* argv[] )

Global Function step_interior_line()

This performs one explicit timestep for a line of data in the 2-D or 3-D array. In this simple example, it uses BLAS functions (defined in petscblaslapack.h) to do this extremely fast. Fastest explicit diffusion solver you'll find!

void step_interior_line ( PetscScalar* old, PetscScalar* new, PetscScalar* temps, PetscTruth** mixed_constraints, PetscScalar time, int points, int gxm, int gym, int gzm, int xs, int ys, int zs, int xm, int nx, int ny, int nz, void* user )

PetscScalar* old
Field variable array in previous timestep.
PetscScalar* new
Field variable array to fill in new timestep.
PetscScalar* temps
Temporary parameters (empty here) calculated by temp_parameters_line.
PetscTruth** mixed_constraints
Arrays of boolean variables indicating constraint equations in mixed timestep-constraint fields.
PetscScalar time
Current simulation time.
int points
Number of points to calculate at.
int gxm
Overall x-width of the array (for y increment).
int gym
Overall y-width of the array (for z increment).
int gzm
Overall z-width of the array (zero if 2-D).
int xs
Starting x-coordinate of the line.
int ys
Starting y-coordinate of the line.
int zs
Starting z-coordinate of the line.
int xm
Width of the interior part of the line.
int nx
Overall x-width of the entire global array.
int ny
Overall y-width of the entire global array.
int nz
Overall z-width of the entire global array (zero if 2-D).
void* user
User data structure pointer.

Global Function temp_parameters_line()

This is not necessary, so it does nothing.

void temp_parameters_line ( PetscScalar* x, PetscScalar* temp, PetscScalar time, int points, int gxm, int gym, int gzm, int xs, int ys, int zs, int xm, int nx, int ny, int nz, void* user )

PetscScalar* x
Array of unknowns.
PetscScalar* temp
Array of temporary parameters to calculate.
PetscScalar time
Current simulation time.
int points
Number of points to calculate at.
int gxm
Overall x-width of the array (for y increment).
int gym
Overall y-width of the array (for z increment).
int gzm
Overall z-width of the array (zero if 2-D).
int xs
Starting x-coordinate of the line.
int ys
Starting y-coordinate of the line.
int zs
Starting z-coordinate of the line.
int xm
Width of the interior part of the line.
int nx
Overall x-width of the entire global array.
int ny
Overall y-width of the entire global array.
int nz
Overall z-width of the entire global array (zero if 2-D).
void* user
User data structure pointer.

Global Function tsmonitor()

This plots the current data, if the step number is right (according to the plotsteps and explicit_plotsteps command line options).

void tsmonitor ( int time, PetscScalar realtime, PetscScalar deltat, void* user )

int time
Current timestep number.
PetscScalar realtime
Current simulation time.
PetscScalar deltat
Current timestep size.
void* user
User data structure pointer.