Main program for the Brownian coagulation example problem.
For example, the program is run as ./Brownian_Coagulation 1 3 Brownian_Coagulation.input. This sets dimension = 1 , number of quadrature points = 3, Brownain_Coagulation.input as the input file to be read. Note that for univariate problems selective glex is not used. int main (int argc, char **argv) { Declare variable solver_params as an object of the inputs class. solver_params can then access the member function input_reader that reads the input file inputs solver_params Declare as extern variables defined elsewhere in inputs.c. num_steps : total number of time steps, print_interval : intervals at which output is to be printed, dt : time step, tau : time scale, mu_g : geometric mean of initial lognormal distribution, std_g : standard deviation of initial distribution extern int num_steps, print_interval; extern double dt; extern double mu_g, std_g; Invoke the the input_reader function which is a member of the inputs class of which solver_params is declared to be a member. The argv[3] is the third variable in the command line options when running the example. solver_params.input_reader(argv[3]); Declare the dimension of the problem. atoi(argv[1]) assigns the first variable in the command line options to dimension. size_t dimension = atoi(argv[1]);
Declare the number of quadrature points to be used in the problem. atoi(argv[2]) assigns the second variable in the command line options to num_points. size_t num_points = atoi(argv[2]);
The total number of moments required for the chosen dimension and num_points. size_t itot = num_points + dimension*num_points;
Declare the moment vectors and the equivalent quadrature-weights+points vectors. moms is an object of the moments class and quadwts is an object of the quadrature-weights+points class. Both are intialized with the size of the problem itot. Initial conditions for moments (in this example, log-normal with given geometric mean and standard deviation read in from the input file. moms = moms.univariate_lognormal(dimension, num_points, mu_g, std_g); In this example we choose to solve the moment equations directly using QMOM. The function solve is called with the dimension, the number of quadrature points num_points, the time step dt, the number of steps num_steps, the interval to print print_interval. dimension, num_points can be changed in the command line. This example only works with dimension = 1. The other variables can be changed in the input file. moms.solve ( dimension, num_points, dt, num_steps, print_interval ); Exit the program return 0;
}
|