本文整理汇总了C++中Physics::mass_flux_per_time方法的典型用法代码示例。如果您正苦于以下问题:C++ Physics::mass_flux_per_time方法的具体用法?C++ Physics::mass_flux_per_time怎么用?C++ Physics::mass_flux_per_time使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Physics
的用法示例。
在下文中一共展示了Physics::mass_flux_per_time方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
double t0 = solver.time();
if(output_run){
solution.add( t0, solver.begin(), solver.end_ext() );
solution.write_timestep_VTK_XML( 0, mesh, filename );
}
int nt = 11;
// initialise mass balance stats, and store for t0
DoubleVector fluid_mass(nt+1);
DoubleVector time_vec(nt+1);
fluid_mass[0] = physics.compute_mass(mesh, solver.begin());
time_vec[0] = t0;
// timestep the solution
double dt = (final_time-t0)/double(nt);
double nextTime = t0 + dt;
double startTime = MPI_Wtime();
for( int i=0; i<nt; i++ )
{
if( mpicomm->rank() == 0 )
std::cout << "starting timestep at time " << nextTime-dt << "( " << solver.time() << ")" << std::endl;
// advance the solution to nextTime
solver.advance(nextTime);
// save solution for output
if(output_run){
solution.add( nextTime, solver.begin(), solver.end_ext() );
solution.write_timestep_VTK_XML( i+1, mesh, filename );
}
fluid_mass[i+1] = physics.compute_mass(mesh, solver.begin());
time_vec[i+1] = nextTime;
nextTime = t0 + (double)(i+2)*dt;
}
double finalTime = MPI_Wtime() - startTime;
if( mpicomm->rank()==0)
std::cout << std::endl << "Simulation took : " << finalTime << " seconds" << std::endl;
if( mpicomm->size()==1 ){
// open file for output of stats
std::ofstream mfid;
std::string mfile_name;
std::string runname("run");
mfile_name = filename + ".m";
mfid.open(mfile_name.c_str());
assert( mfid );
// output basic stats to file
mfid << "maxOrder = " << maxOrder << ";" << std::endl;
// perform mass-balance caluclations
double flux_per_time = physics.mass_flux_per_time(mesh);
mfid << "massError_" << runname << " = [ ";
for( int i=1; i<nt+1; i++ ){
double time_elapsed = time_vec[i]-time_vec[0];
double mass_balance = fluid_mass[i] - fluid_mass[0];
double mass_error = fabs(mass_balance - time_elapsed*flux_per_time)/fluid_mass[i];
mfid << mass_error << " ";
}
mfid << "];" << std::endl;
// output step orders
const std::vector<int>& orders = integrator.step_orders();
mfid << "orders_" << runname << " = [";
for( int i=0; i<orders.size(); i++ )
mfid << orders[i] << " ";
mfid << "];" << std::endl;
// output step sizes
const std::vector<double>& sizes = integrator.step_sizes();
mfid << "stepSizes_" << runname << " = [";
for( int i=0; i<sizes.size(); i++ )
mfid << sizes[i] << " ";
mfid << "];" << std::endl;
mfid << "Feval_" << runname << " = " << physics.calls() << ";" << std::endl;
mfid.close();
}
// output the solution to file
if(output_run && mpicomm->size()==1){
solution.write_to_file( filename + ".run" );
}
// Output solver stats
if (mpicomm->rank() == 0) {
print_ida_stats(integrator.ida());
std::cout << "Physics calls = "
<< physics.calls() << std::endl;
#ifdef PRECON
std::cout << "Preconditioner setups = "
<< preconditioner.setups() << std::endl;
std::cout << "Preconditioner callbacks = "
<< preconditioner.callbacks() << std::endl;
std::cout << "Preconditioner applications = "
<< preconditioner.applications() << std::endl;
#endif
}
} catch (const std::exception& e) {
std::cerr << e.what() << std::endl;
}
}