本文整理汇总了C++中Grid3D::Set_Boundary_Conditions方法的典型用法代码示例。如果您正苦于以下问题:C++ Grid3D::Set_Boundary_Conditions方法的具体用法?C++ Grid3D::Set_Boundary_Conditions怎么用?C++ Grid3D::Set_Boundary_Conditions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Grid3D
的用法示例。
在下文中一共展示了Grid3D::Set_Boundary_Conditions方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
// timing variables
double start_total, stop_total, start_step, stop_step;
#ifdef CPU_TIME
double stop_init, init_min, init_max, init_avg;
double start_bound, stop_bound, bound_min, bound_max, bound_avg;
double start_hydro, stop_hydro, hydro_min, hydro_max, hydro_avg;
double init, bound, hydro;
init = bound = hydro = 0;
#endif //CPU_TIME
// start the total time
start_total = get_time();
/* Initialize MPI communication */
#ifdef MPI_CHOLLA
InitializeChollaMPI(&argc, &argv);
#endif /*MPI_CHOLLA*/
// declare Cfl coefficient and initial inverse timestep
Real C_cfl = 0.4; // CFL coefficient 0 < C_cfl < 0.5
Real dti = 0; // inverse time step, 1.0 / dt
// input parameter variables
char *param_file;
struct parameters P;
int nfile = 0; // number of output files
Real outtime = 0; // current output time
// read in command line arguments
if (argc != 2)
{
chprintf("usage: %s <parameter_file>\n", argv[0]);
chexit(0);
} else {
param_file = argv[1];
}
// create the grid
Grid3D G;
// read in the parameters
parse_params (param_file, &P);
// and output to screen
chprintf ("Parameter values: nx = %d, ny = %d, nz = %d, tout = %f, init = %s, boundaries = %d %d %d %d %d %d\n",
P.nx, P.ny, P.nz, P.tout, P.init, P.xl_bcnd, P.xu_bcnd, P.yl_bcnd, P.yu_bcnd, P.zl_bcnd, P.zu_bcnd);
chprintf ("Output directory: %s\n", P.outdir);
// initialize the grid
G.Initialize(&P);
chprintf("Local number of grid cells: %d %d %d %d\n", G.H.nx_real, G.H.ny_real, G.H.nz_real, G.H.n_cells);
// Set initial conditions and calculate first dt
chprintf("Setting initial conditions...\n");
G.Set_Initial_Conditions(P, C_cfl);
chprintf("Dimensions of each cell: dx = %f dy = %f dz = %f\n", G.H.dx, G.H.dy, G.H.dz);
chprintf("Ratio of specific heats gamma = %f\n",gama);
chprintf("Nstep = %d Timestep = %f Simulation time = %f\n", G.H.n_step, G.H.dt, G.H.t);
// set main variables for Read_Grid inital conditions
if (strcmp(P.init, "Read_Grid") == 0) {
outtime += G.H.t;
nfile = P.nfile;
dti = 1.0 / G.H.dt;
}
// set boundary conditions (assign appropriate values to ghost cells)
chprintf("Setting boundary conditions...\n");
G.Set_Boundary_Conditions(P);
chprintf("Boundary conditions set.\n");
#ifdef OUTPUT
// write the initial conditions to file
chprintf("Writing initial conditions to file...\n");
WriteData(G, P, nfile);
// add one to the output file count
nfile++;
#endif //OUTPUT
// increment the next output time
outtime += P.outstep;
#ifdef CPU_TIME
stop_init = get_time();
init = stop_init - start_total;
#ifdef MPI_CHOLLA
init_min = ReduceRealMin(init);
init_max = ReduceRealMax(init);
init_avg = ReduceRealAvg(init);
chprintf("Init min: %9.4f max: %9.4f avg: %9.4f\n", init_min, init_max, init_avg);
#else
printf("Init %9.4f\n", init);
#endif //MPI_CHOLLA
#endif //CPU_TIME
// Evolve the grid, one timestep at a time
chprintf("Starting caclulations.\n");
while (G.H.t < P.tout)
//.........这里部分代码省略.........