void solver(vertex * node, fval * fvar, mg_grid * level, pbcs& pbc, int restart_count)
{		
	double max_div; 
	ofstream fp_res, fp_time; //Filestream to write the residuals as per time for the 3 flow variables
	
	fp_res.open("global_residuals.dat");
	fp_time.open("center_line_maxmin.dat");
	
	cout<<"The time step is "<<dt<<"\n"; 
	cout<<"The no.of timesteps is "<<ite<<"\n"; 
	cout<<"The spacing is dx = "<<dx<< " dy= "<<dy<<"\n"; 

	for(int t=restart_count+1;t<=ite;t++)
	{
		explicit_solver(node,fvar,level,pbc);
		max_div = div_calc(node,fvar);
		  
		cout<<"----------- "<<"ite "<<t<<" "<<max_div<<"------------"<<"\n"; 	
		global_residuals(fvar,fp_res,t);
		//write_time_file(fvar,t,fp_time); 
		
		if(t%file_freq==0) write_to_file(node,fvar,t); 		
		if(t%r_file_freq==0) write_restart(fvar,t);
	}
	
	fp_res.close(); 
}
示例#2
0
文件: analysis.c 项目: sleitner/cart
void writebegin(){
    int icell;
    write_restart( WRITE_SAVE, WRITE_SAVE, WRITE_SAVE );
}
示例#3
0
文件: main.c 项目: sirianray/lblc
int main(int argc, char *argv[]){
	MPI_Init(&argc, &argv);
        MPI_Comm_split_type(MPI_COMM_WORLD, MPI_COMM_TYPE_SHARED, 0, MPI_INFO_NULL, &shmcomm);
        MPI_Comm_size(MPI_COMM_WORLD, &numprocs);
        MPI_Comm_rank(MPI_COMM_WORLD, &myid);

	double t_begin;
	int i, j, k, ii, id, id1;

	t_begin = MPI_Wtime();		// record the begining CPU time
	
	read_param();
	lattice_vec();
	allocate();
	p_allocate();

	if (flow_on!=0) {
		build_stream();
	}

	if (Q_on!=0) {
		build_neighbor();		
	}

	init_surf();
	add_patch();
	p_init();
	p_iden();
	init();

	if (flow_on!=0) cal_fequ(f);	
	if (Q_on!=0) cal_dQ();

	if (Q_on!=0 && flow_on!=0 && newrun_on!=0) {
		while(qconverge==0) {
			t_current++;
			for (ii=0; ii<n_evol_Q; ii++) {
                                cal_dQ();
                                evol_Q();
                        }
			if (t_current%t_print==0) monitor();
		}
		e_tot     =-1;
		k_eng     =-1;
		qconverge = 0;	
		uconverge = 0;
		t_current =-1;
	}

	if (Q_on!=0 && flow_on!=0) {
		cal_W();
		cal_stress();
		cal_sigma_p();
	}
        MPI_Barrier(MPI_COMM_WORLD);

	output1(1,'z',Nx/2,Ny/2);
	output3(1);
	if(myid==0) printf("Q initialized\n");
	MPI_Barrier(MPI_COMM_WORLD);

	while (t_current<t_max && uconverge*qconverge==0) {
		e_toto=e_tot;
		if (Q_on!=0 && qconverge==0) {
			if (flow_on!=0 && uconverge==0) cal_W();
			for (ii=0; ii<n_evol_Q; ii++) {
				cal_dQ();
				evol_Q();
			}			
		}

		if (flow_on!=0 && uconverge==0) {
			if (Q_on!=0 && qconverge==0) {
				cal_stress();
				cal_sigma_p();
			}
			evol_f(f,f2);
		}

		if (Q_on!=0 && qconverge==0) {
			if (flow_on!=0 && uconverge==0) cal_W();
			for (ii=0; ii<n_evol_Q; ii++) {
				cal_dQ();
				evol_Q();
			}			
		}

		if (flow_on!=0 && uconverge==0) {
			if (Q_on!=0 && qconverge==0) {
				cal_stress();
				cal_sigma_p();
			}
			evol_f(f2,f);
		}
		
		if (t_current%t_print==0) monitor();
		if (t_current%t_write==0) {
			output1(0,'z',Nx/2,Ny/2);
			output3(0);
			fflush(stdout);
		}
		t_current++;
	}
	
	
	output_time(t_begin);
	output1(0,'z',Nx/2,Ny/2);
	output3(0);
	
	write_restart();

	p_deallocate();
	deallocate();

	return 0;
}