RCS Header: /cvsroot/rheoplast/rheoplast.c,v 1.90 2004/08/23 14:51:52 hazelsct Exp
This is the main
RheoPlast
file. If you want to add a module, search this file for the word "modules"
to help you know where to insert your function calls, HELP definition, etc.
Also see section \ref{newmodule} for other files which need to be modified in
the process of adding a module.
Included Files
Preprocessor definitions
#define __FUNCT__ "temp_parameters_line"
#define __FUNCT__ "func_interior_line"
#define __FUNCT__ "step_interior_line"
#define __FUNCT__ "jack_interior_line"
#define __FUNCT__ "thets_rhs"
This provides a right hand side vector for
PETSc's
(semi-)implicit timestepping solvers using the function
func_interior_line.
This should probably go into timestep.h since it is generic. In the future,
it will calculate and store temporary parameters only on an "as-needed"
basis, which is to say, it will calculate and store them only at the line of
calculation and its neighbor lines (neighbor planes needed in 3-D). This
should save quite a bit of memory.
This is somewhat deprecated, now that timestep.c has constrained
(semi-)implicit timestepping which bypasses it (the implicit_steptime
function). But if such capability is up-ported into PETSc, then this will be
useful again.
int thets_rhs It returns zero (or an error code).
TS thets Timestepping context from
PETSc.
PetscScalar time Current time.
Vec unk Vector of unknowns from which to calculate functions.
Vec func Vector into which to put function values.
void *user User data structure pointer.
#define __FUNCT__ "tsmonitor"
#define DPRINTF( fmt, args... )
#define __FUNCT__ "main"
Local Variables
help
PETSc help string, printed when run with -help. Note that it includes
entries for each of the modules' header files.
static char help[]
Evaluate the functions which make up this system on one line of interior
points. The theory is that a line is big enough that the function call and
other overheads are really small and we can do acceleration using level 1
BLAS if appropriate, but small enough to be really simple.
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 )
- PetscScalar* x
- The data to evaluate the function for.
- PetscScalar* func
- Where to put the evaluated function.
- PetscScalar* temp
- Array of temporary field variables.
- 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 evaluate at.
- int gxm
- The
x-width
of the ``local'' vector's array, including shadow nodes, for the
y-increment.
- int gym
- The
y-width
of the ``local'' vector's array, including shadow nodes, for the
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.
This function simply calls the
interior_line_function
function from each of the modules.
Evaluate the Jacobian for this system on one line of interior points. The
theory is that a line is big enough that the function call and other
overheads are really small and we can do acceleration using level 1 BLAS if
appropriate, but small enough to be really simple.
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 )
- PetscScalar* x
- The data to evaluate the function for.
- PetscScalar* temp
- Array of temporary field variables.
- Mat jack
- Matrix into which to insert Jacobian values.
- PetscScalar time
- Current simulation time.
- int points
- Number of points to evaluate at.
- int gxm
- The
x-width
of the ``local'' vector's array, including shadow nodes, for the
y-increment.
- int gym
- The
y-width
of the ``local'' vector's array, including shadow nodes, for the
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).
- int firstrow
-
- void* user
- User data structure pointer.
This function simply calls the
interior_line_jacobian
function from each of the modules (if it exists).
This is
main().
int main ( int argc, char* argv[] )
- int main
- It returns an int to the OS.
- int argc
- Argument count.
- char* argv[]
- Arguments.
After
PETSc
and log file initialization, it sets the variable indices and labels based
on the user-chosen equations.
We then determine which of the modules will be included in the simulation,
and call those modules' initialization functions to determine the number of
field variables and temporary fields.
It then sets the basic timestepping parameters, from the command line if
appropriate.
Next it creates the
PETSc
distributed arrays, gets the sizes of the local and global boxes, and sets
the inverse square grid spacings.
Next it sets the initial condition, by getting the global arary and
calling the modules' labels_initcond functions.
It then initializes the graphics and runs the explicit timestepping
solver from
timestep.h.
If directed to do so with a nonzero
-ts_max_steps
command line setting, it then initializes and runs semi-implicit
timesteps.
An alternative semi-implicit section uses
PETSc's
semi-implicit timestepping solver. It is semi-deprecated due to the
constrained semi-implicit solver in implicit_steptime, but may come back if
that functionality is up-ported into PETSc.
Finally, it cleans up, closing the graphics displays and freeing all
memory.
This calculates the dynamic functions using the function
func_interior_line
and then uses them and the timestep size to determine the explicit
timestepping changes to the field variables, on one line.
void step_interior_line ( PetscScalar* old, PetscScalar* new, 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 )
- PetscScalar* old
- Field variable array in previous timestep.
- PetscScalar* new
- Field variable array to fill in new timestep.
- PetscScalar* temp
- Temporary parameters 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.
This function calculates the temporary parameters on which the function
calculation is based (in
func_interior_line).
The theory is that at some point, we'll calculate only the lines in the
neighborhood of the current function line, and save gobs and gobs of memory;
meanwhile, calculating these once saves a good amount of time.
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 from which temp parameters are calculated.
- PetscScalar* temp
- Storage for one line of temp parameters.
- PetscScalar time
- Current simulation time.
- int points
- Number of points to evaluate at.
- int gxm
- The
x-width
of the ``local'' vector's array, including shadow nodes, for the
y-increment.
- int gym
- The
y-width
of the ``local'' vector's array, including shadow nodes, for the
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 distributed array.
- int ny
- Overall
y-width of the entire distributed array.
- int nz
- Overall
z-width of the entire distributed array (zero if 2-D).
- void* user
- User data structure pointer.
This function simply calls the
temp_parameters_line
function from each of the modules.
This plots the current data, if the step number is right (according to the
monsteps and explicit_monsteps
command line options).
void tsmonitor ( int step, PetscScalar time, PetscScalar deltat, void* user )
- int step
- Current timestep number.
- PetscScalar time
- Current simulation time.
- PetscScalar deltat
- Current timestep size.
- void* user
- User data structure pointer.
In addition to printing various diagnostics
(delta t,
min/max field values, etc.), this also calculates the "time velocity" since
the last call to tsmonitor, which is the simulated time divided by CPU time
spent in this process.