File membrane.c

RCS Header: /cvsroot/rheoplast/membrane.c,v 1.47 2005/12/27 00:56:02 zhou Exp

This provides a simple nonsolvent/solvent/polymer membrane module for Rheoplast. It goes as The chemicalpotential is then the variation of this free energy, given by+html+ the homogeneous free energy derivative term and a laplacian term corresponding to the gradient penalty.


Included Files


Preprocessor definitions

#define __FUNCT__ "psiprime2"

#define __FUNCT__ "psiprime3"

#define __FUNCT__ "psidoubleprime2"

#define __FUNCT__ "psidoubleprime3"

#define __FUNCT__ "M22"

#define __FUNCT__ "M33"

#define __FUNCT__ "M23"

#define __FUNCT__ "M32"

#define __FUNCT__ "membrane_first_setup"

#define __FUNCT__ "membrane_labels_initcond"

#define SMALL_PRIME 1571

#define MEDIUM_PRIME 524287

#define LARGE_PRIME 2147483647

#define MY_RANDOM( pseudo_random )

#define phi2( point )

#define phi3( point )

#define phi2func( point )

#define phi3func( point )

#define mu2( point )

#define mu3( point )

#define __FUNCT__ "membrane_temp_parameters_line"

#define __FUNCT__ "membrane_temp_parameters_boundary_line"

#define __FUNCT__ "membrane_interior_line_function"

#define u( point )

#define v( point )

#define u( point )

#define v( point )

#define w( point )

#define __FUNCT__ "membrane_boundary_line_function"

#define u( point )

#define v( point )

#define u( point )

#define v( point )

#define w( point )

#define u( point )

#define v( point )

#define u( point )

#define v( point )

#define w( point )


Global Function membrane_boundary_line_function()

void membrane_boundary_line_function ( PetscScalar* x, PetscScalar* func, PetscScalar* temp, PetscTruth** mixed_constraints, int points, int gxm, int gym, PetscScalar xmin, PetscScalar xmax, PetscScalar ycoord, PetscScalar zcoord, PetscScalar time, AppCtx* data, int side )

Global Function membrane_first_setup()

The basic setup, assigning the number of solved and temporary field variables, the stencil width, and using options to set the parameters in the mparm struct typedef.

void membrane_first_setup ( PetscTruth threedee, int* vars, int* tempvars, int* stencilwid, AppCtx* data )

PetscTruth threedee
Request support for 3-D.
int* vars
Pointer to the number of solved field variables.
int* tempvars
Pointer to the number of temporary field variables.
int* stencilwid
Pointer to the stencil width.
AppCtx* data
Pointer to the AppCtx struct typedef, into whose mparm structure this inserts parameters from the command line.
This sets mobility and gradient penalties for use in membrane_labels_initcond().


Global Function membrane_interior_line_function()

This calculates the time derivative of phi_2,phi_3 using the divergence of flux, which goes down the gradient of chemical potential described above, with mobility M.

void membrane_interior_line_function ( PetscScalar* x, PetscScalar* func, PetscScalar* temp, PetscTruth** mixed_constraints, int points, int gxm, int gym, PetscScalar xmin, PetscScalar xmax, PetscScalar ycoord, PetscScalar zcoord, PetscScalar time, AppCtx* data )

PetscScalar* x
The field variables from which to evaluate the function.
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.
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.
PetscScalar xmin
First node x-coordinate.
PetscScalar xmax
Last node plus one x-coordinate.
PetscScalar ycoord
This line y-coordinate.
PetscScalar zcoord
This line z-coordinate.
PetscScalar time
Current simulation time.
AppCtx* data
Pointer to the main simulation parameter structure, which includes the mparm struct typedef, from which this gets needed parameters.
For now this assumes uniform M_{ij}.


Global Function membrane_labels_initcond()

This sets up the field variable labels, maximum stable explicit deltat, and initial condition for the Cahn-Hilliard variables.

void membrane_labels_initcond ( PetscScalar* globalarray, int nx, int ny, int nz, int xm, int ym, int zm, int xs, int ys, int zs, int vars, AppCtx* data, PetscScalar* max_explicit_deltat )

PetscScalar* globalarray
The global field array.
int nx
Overall x-width of the global array.
int ny
Overall y-width of the global array.
int nz
Overall z-width of the global array.
int xm
The x-width of the local part of the array.
int ym
The y-width of the local part of the array.
int zm
The z-width of the local part of the array.
int xs
The (integer) x-coordinate of the start of the local part of the array.
int ys
The (integer) y-coordinate of the start of the local part of the array.
int zs
The (integer) z-coordinate of the start of the local part of the array.
int vars
Total number of field variables to be solved.
AppCtx* data
Pointer to the AppCtx struct typedef, whose mparm structure this uses for various purposes.
PetscScalar* max_explicit_deltat
Pointer to the largest allowable explicit timestep size for this equation, which this function can set/modify.
For random fluctuations in this module, it's necessary to generate different random sequences on each process, even though rand() will return the same sequences. So we create a random counter which takes on values between zero and SMALL_PRIME-1; this is initialized to rank times LARGE_PRIME (which should make it sort of random), and incremented by MEDIUM_PRIME then re-moduloed to SMALL_PRIME for each random number generated. This counter, in turn, is divided by SMALL_PRIME and the result added to rand()/RAND_MAX then modulo 1, in order to give a "different random number" (at least at the resolution of SMALL_PRIME) in each process. This is not a great algorithm, but should do for the purpose needed here.
Eventually it might be good to make this resource available to the whole code.
If we're not loading in data as the initial condition, the phi2 and phi3 fields are initiated here. There are several types of initial conditions here which are chosen by command-line parameters:
If the option -m_random_fluct is selected without -m_random_center, then random fluctuations with uniform distribution of width twice the fluctuation value are added to any other initial condition present.


Global Function membrane_temp_parameters_boundary_line()

void membrane_temp_parameters_boundary_line ( PetscScalar* x, PetscScalar* temp, int points, int gxm, int gym, PetscScalar xmin, PetscScalar xmax, PetscScalar ycoord, PetscScalar zcoord, PetscScalar time, AppCtx* data, int side )

Global Function membrane_temp_parameters_line()

This calculates the membrane temporary parameters mu_2 and mu_3, which are the chemical potentials given as the following:

void membrane_temp_parameters_line ( PetscScalar* x, PetscScalar* temp, int points, int gxm, int gym, PetscScalar xmin, PetscScalar xmax, PetscScalar ycoord, PetscScalar zcoord, PetscScalar time, AppCtx* data )

PetscScalar* x
Array with the "real" field variables.
PetscScalar* temp
Array with the temporary field variables.
int points
Number of points at which to calculate the temporary variables.
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.
PetscScalar xmin
First node x-coordinate.
PetscScalar xmax
Last node plus one x-coordinate.
PetscScalar ycoord
This line y-coordinate.
PetscScalar zcoord
This line z-coordinate.
PetscScalar time
Current simulation time.
AppCtx* data
Pointer to the main simulation parameter structure, which includes the mparm struct typedef, from which this gets needed parameters.

Local Function M22()

static inline PetscScalar M22 ( PetscScalar phi2, PetscScalar phi3, mparm* themembrane )

Local Function M23()

static inline PetscScalar M23 ( PetscScalar phi2, PetscScalar phi3, mparm* themembrane )

Local Function M32()

static inline PetscScalar M32 ( PetscScalar phi2, PetscScalar phi3, mparm* themembrane )

Local Function M33()

static inline PetscScalar M33 ( PetscScalar phi2, PetscScalar phi3, mparm* themembrane )

Local Function psidoubleprime2()

static inline PetscScalar psidoubleprime2 ( PetscScalar phi2, PetscScalar phi3, mparm* themembrane )

Local Function psidoubleprime3()

static inline PetscScalar psidoubleprime3 ( PetscScalar phi2, PetscScalar phi3, mparm* themembrane )

Local Function psiprime2()

This abstracts out the function for Psi_2'(phi_2,phi_3), the derivative of homogeneous free energy, so it can be easily modified.

static inline PetscScalar psiprime2 ( PetscScalar phi2, PetscScalar phi3, mparm* themembrane )

PetscScalar psiprime2
It returns the derivative of homogeneous free energy.
PetscScalar phi2
The phi_2 parameter it's a function of.
PetscScalar phi3
The phi_3 parameter it's a function of.
mparm* themembrane
membrane parameter structure.

Local Function psiprime3()

This abstracts out the function for Psi_3'(phi_2,phi_3), the derivative of homogeneous free energy, so it can be easily modified.

static inline PetscScalar psiprime3 ( PetscScalar phi2, PetscScalar phi3, mparm* themembrane )

PetscScalar psiprime3
It returns the derivative of homogeneous free energy.
PetscScalar phi2
The phi_2 parameter it's a function of.
PetscScalar phi3
The phi_3 parameter it's a function of.
mparm* themembrane
membrane parameter structure.