本文整理汇总了C++中Iter::get_iter方法的典型用法代码示例。如果您正苦于以下问题:C++ Iter::get_iter方法的具体用法?C++ Iter::get_iter怎么用?C++ Iter::get_iter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Iter
的用法示例。
在下文中一共展示了Iter::get_iter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test
int test(int argc, char* argv[])
{
if ( argc != 3 ) {
std::cout << "error." << std::endl;
std::cout << "./run <n> <endtimestep>" << std::endl;
return 1;
}
const int n = std::atoi(argv[1]);
//----------------------------------------------
// define space domain
//----------------------------------------------
const int D = 2;
const real l = 1.0;
const int hn = 3;
//const int hn = 2;
//----------------------------------------------
// define mesh
//----------------------------------------------
const Mesh mesh( hn, l, n, l, n );
//mesh.print_mesh_data();
//----------------------------------------------
// define time domain
//----------------------------------------------
const real dt = 0.1 * mesh.delta(0) / 1.0;
//const real dt = 1.0e-5;
const real endtime = 200 * 1.0 / 1.0;
const int endstep = static_cast<int>(endtime / dt);
//const int endstep = std::atoi(argv[2]);
real * u = new real[mesh.size()];
real * v = new real[mesh.size()];
real * p = new real[mesh.size()];
real * nu = new real[mesh.size()];
real * nv = new real[mesh.size()];
uniform_value( u, 0.0, mesh );
uniform_value( v, 0.0, mesh );
uniform_value( nu, 0.0, mesh );
uniform_value( nv, 0.0, mesh );
uniform_value( p, 0.0, mesh );
boundary_update_u_v( u, v, mesh );
for ( int timestep = 0 ; timestep < endstep ; timestep++ ) {
const Iter iter = time_marching_RK1_cavity( nu, nv, p, u, v, dt, mesh );
swap( &nu, &u );
swap( &nv, &v );
//const Iter iter = time_marching_RK2_cavity( &u, &v, &p, dt, mesh );
if ( timestep % 100 == 0 ) {
real * const div = new real[mesh.size()];
uniform_value( div, 0.0, mesh );
calc_div( div, u, v, mesh );
const std::string div_filename( "div.dat" );
const std::string div_position( "cell_center" );
//save_array( D, div, div_filename, div_position, mesh );
abs_array( div, mesh );
const real max_abs_div_value = max_from_array( div, mesh );
delete[] div;
std::cout << timestep / static_cast<real>(endstep) * 100 << " %";
std::cout << "\t timestep = " << timestep;
std::cout << "\titer = " << iter.get_iter() << "\terr = " << iter.get_error();
std::cout << "\tdiv = " << std::scientific << std::showpos << max_abs_div_value << std::endl;
}
}
const std::string u_filename( "u.dat" );
const std::string u_position( "staggered_x" );
save_array( D, u, u_filename, u_position, mesh );
const std::string v_filename( "v.dat" );
const std::string v_position( "staggered_y" );
save_array( D, v, v_filename, v_position, mesh );
const std::string p_filename( "p.dat" );
const std::string p_position( "cell_center" );
save_array( D, p, p_filename, p_position, mesh );
output_result( "result_u.dat", "result_v.dat", u, v, mesh );
delete[] u;
delete[] v;
delete[] p;
delete[] nu;
delete[] nv;
return 0;
}