diff --git a/demo_drivers/advection_diffusion/two_d_adv_diff_SUPG/two_d_adv_diff_SUPG.cc b/demo_drivers/advection_diffusion/two_d_adv_diff_SUPG/two_d_adv_diff_SUPG.cc index 249d43669068..4875df96c27a 100644 --- a/demo_drivers/advection_diffusion/two_d_adv_diff_SUPG/two_d_adv_diff_SUPG.cc +++ b/demo_drivers/advection_diffusion/two_d_adv_diff_SUPG/two_d_adv_diff_SUPG.cc @@ -302,7 +302,7 @@ void SUPGAdvectionDiffusionProblem::doc_solution() // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); diff --git a/demo_drivers/advection_diffusion/two_d_adv_diff_adapt/two_d_adv_diff_adapt.cc b/demo_drivers/advection_diffusion/two_d_adv_diff_adapt/two_d_adv_diff_adapt.cc index 0367852ebfd6..668e647aecb1 100644 --- a/demo_drivers/advection_diffusion/two_d_adv_diff_adapt/two_d_adv_diff_adapt.cc +++ b/demo_drivers/advection_diffusion/two_d_adv_diff_adapt/two_d_adv_diff_adapt.cc @@ -285,7 +285,7 @@ void RefineableAdvectionDiffusionProblem::doc_solution() // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -293,7 +293,7 @@ void RefineableAdvectionDiffusionProblem::doc_solution() // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); mesh_pt()->output_fct(some_file,npts,TanhSolnForAdvectionDiffusion::get_exact_u); @@ -302,7 +302,7 @@ void RefineableAdvectionDiffusionProblem::doc_solution() // Doc error and return of the square of the L2 error //--------------------------------------------------- double error,norm; - sprintf(filename,"%s/error%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); mesh_pt()->compute_error(some_file,TanhSolnForAdvectionDiffusion::get_exact_u, diff --git a/demo_drivers/advection_diffusion/two_d_adv_diff_adapt/two_d_adv_diff_adapt2.cc b/demo_drivers/advection_diffusion/two_d_adv_diff_adapt/two_d_adv_diff_adapt2.cc index 2f5b22e2b644..d9065ca24e82 100644 --- a/demo_drivers/advection_diffusion/two_d_adv_diff_adapt/two_d_adv_diff_adapt2.cc +++ b/demo_drivers/advection_diffusion/two_d_adv_diff_adapt/two_d_adv_diff_adapt2.cc @@ -263,7 +263,7 @@ void RefineableAdvectionDiffusionProblem::doc_solution( // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); diff --git a/demo_drivers/advection_diffusion/two_d_adv_diff_flux_bc/two_d_adv_diff_flux_bc.cc b/demo_drivers/advection_diffusion/two_d_adv_diff_flux_bc/two_d_adv_diff_flux_bc.cc index 1cebf492daca..67a5446f3c61 100644 --- a/demo_drivers/advection_diffusion/two_d_adv_diff_flux_bc/two_d_adv_diff_flux_bc.cc +++ b/demo_drivers/advection_diffusion/two_d_adv_diff_flux_bc/two_d_adv_diff_flux_bc.cc @@ -353,7 +353,7 @@ doc_solution(DocInfo& doc_info) // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); @@ -361,7 +361,7 @@ doc_solution(DocInfo& doc_info) // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output_fct(some_file,npts,TanhSolnForAdvectionDiffusion::get_exact_u); @@ -371,7 +371,7 @@ doc_solution(DocInfo& doc_info) // Doc error and return of the square of the L2 error //--------------------------------------------------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->compute_error(some_file,TanhSolnForAdvectionDiffusion::get_exact_u, diff --git a/demo_drivers/advection_diffusion/two_d_variable_diff/two_d_variable_diff_adapt.cc b/demo_drivers/advection_diffusion/two_d_variable_diff/two_d_variable_diff_adapt.cc index e050eed3208c..27018dccd9ef 100644 --- a/demo_drivers/advection_diffusion/two_d_variable_diff/two_d_variable_diff_adapt.cc +++ b/demo_drivers/advection_diffusion/two_d_variable_diff/two_d_variable_diff_adapt.cc @@ -314,7 +314,7 @@ void RefineableAdvectionDiffusionProblem::doc_solution() // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -323,7 +323,7 @@ void RefineableAdvectionDiffusionProblem::doc_solution() // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); mesh_pt()->output_fct(some_file,npts,RachelsAdvectionDiffusion::get_exact_u); @@ -333,7 +333,7 @@ void RefineableAdvectionDiffusionProblem::doc_solution() // Doc error and return of the square of the L2 error //--------------------------------------------------- double error,norm; - sprintf(filename,"%s/error%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); mesh_pt()->compute_error(some_file,RachelsAdvectionDiffusion::get_exact_u, diff --git a/demo_drivers/all_foeppl_von_karman/axisym_displ_based_fvk.cc b/demo_drivers/all_foeppl_von_karman/axisym_displ_based_fvk.cc index 5a4ffafe7850..3a08ca4d612b 100644 --- a/demo_drivers/all_foeppl_von_karman/axisym_displ_based_fvk.cc +++ b/demo_drivers/all_foeppl_von_karman/axisym_displ_based_fvk.cc @@ -176,7 +176,7 @@ void AxisymFvKProblem::doc_solution() // Output solution with specified number of plot points per element char filename[100]; - sprintf(filename, "%s/soln%i.dat", + snprintf(filename, sizeof(filename), "%s/soln%i.dat", AxisymFvKParameters::Directory.c_str(),Doc_info.number()); ofstream solution_file(filename,ios::app); mesh_pt()->output(solution_file,npts); @@ -184,14 +184,14 @@ void AxisymFvKProblem::doc_solution() // Output exact solution - sprintf(filename, "%s/exactsol%i.dat", + snprintf(filename, sizeof(filename), "%s/exactsol%i.dat", AxisymFvKParameters::Directory.c_str(),Doc_info.number()); ofstream exact_file(filename,ios::app); mesh_pt()->output_fct(exact_file,npts,AxisymFvKParameters::get_exact_u); exact_file.close(); // Output solution at the centre (r=0) as function of the pressure - sprintf(filename, "%s/w_centre.dat",AxisymFvKParameters::Directory.c_str()); + snprintf(filename, sizeof(filename), "%s/w_centre.dat",AxisymFvKParameters::Directory.c_str()); ofstream w_centre_file(filename,ios::app); w_centre_file << AxisymFvKParameters::Pressure << " " << mesh_pt()->node_pt(0)->value(0) << std::endl; diff --git a/demo_drivers/all_foeppl_von_karman/axisym_fvk.cc b/demo_drivers/all_foeppl_von_karman/axisym_fvk.cc index c03ff8f2af44..7410ab5227ec 100644 --- a/demo_drivers/all_foeppl_von_karman/axisym_fvk.cc +++ b/demo_drivers/all_foeppl_von_karman/axisym_fvk.cc @@ -167,7 +167,7 @@ void AxisymFvKProblem::doc_solution() // Output solution with specified number of plot points per element char filename[100]; - sprintf(filename, "%s/sol_%i.dat", + snprintf(filename, sizeof(filename), "%s/sol_%i.dat", AxisymFvKParameters::Directory.c_str(),Doc_info.number()); ofstream solution_file(filename,ios::app); mesh_pt()->output(solution_file,npts); @@ -175,7 +175,7 @@ void AxisymFvKProblem::doc_solution() // Output exact solution - sprintf(filename, "%s/exact_sol_%i.dat", + snprintf(filename, sizeof(filename), "%s/exact_sol_%i.dat", AxisymFvKParameters::Directory.c_str(),Doc_info.number()); ofstream exact_file(filename,ios::app); mesh_pt()->output_fct(exact_file,npts,AxisymFvKParameters::get_exact_u); @@ -183,7 +183,7 @@ void AxisymFvKProblem::doc_solution() // Output solution at the centre (r=0) as function of the pressure - sprintf(filename, "%s/w_centre.dat",AxisymFvKParameters::Directory.c_str()); + snprintf(filename, sizeof(filename), "%s/w_centre.dat",AxisymFvKParameters::Directory.c_str()); ofstream w_centre_file(filename,ios::app); w_centre_file << AxisymFvKParameters::Pressure << " " << mesh_pt()->node_pt(0)->value(0) << std::endl; diff --git a/demo_drivers/all_foeppl_von_karman/circular_disk.cc b/demo_drivers/all_foeppl_von_karman/circular_disk.cc index 84185a57b8a0..bc354e8c2373 100644 --- a/demo_drivers/all_foeppl_von_karman/circular_disk.cc +++ b/demo_drivers/all_foeppl_von_karman/circular_disk.cc @@ -335,7 +335,7 @@ UnstructuredFvKProblem::UnstructuredFvKProblem(double element_area) build_global_mesh(); char filename[100]; - sprintf(filename, "RESLT/trace.dat"); + snprintf(filename, sizeof(filename), "RESLT/trace.dat"); Trace_file.open(filename); oomph_info << "Number of equations: " @@ -423,14 +423,14 @@ void UnstructuredFvKProblem::doc_solution() // Number of plot points unsigned npts = 5; - sprintf(filename,"RESLT/soln%i.dat",Doc_info.number()); + snprintf(filename, sizeof(filename), "RESLT/soln%i.dat",Doc_info.number()); some_file.open(filename); this->My_mesh_pt->output(some_file,npts); some_file.close(); // Output boundaries //------------------ - sprintf(filename,"RESLT/boundaries%i.dat",Doc_info.number()); + snprintf(filename, sizeof(filename), "RESLT/boundaries%i.dat",Doc_info.number()); some_file.open(filename); My_mesh_pt->output_boundaries(some_file); some_file.close(); @@ -453,7 +453,7 @@ void UnstructuredFvKProblem::doc_solution() } // Plot solution along radial line - sprintf(filename,"RESLT/soln_along_radial_line%i.dat",Doc_info.number()); + snprintf(filename, sizeof(filename), "RESLT/soln_along_radial_line%i.dat",Doc_info.number()); some_file.open(filename); Vector x(2); unsigned nplot=Radial_sample_point_pt.size(); @@ -473,7 +473,7 @@ void UnstructuredFvKProblem::doc_solution() // Doc error and return of the square of the L2 error //--------------------------------------------------- double dummy_error,zero_norm; - sprintf(filename,"RESLT/norm%i.dat",Doc_info.number()); + snprintf(filename, sizeof(filename), "RESLT/norm%i.dat",Doc_info.number()); some_file.open(filename); My_mesh_pt->compute_error(some_file,GlobalParameters::zero, dummy_error,zero_norm); diff --git a/demo_drivers/all_foeppl_von_karman/displacement_based_circular_disk.cc b/demo_drivers/all_foeppl_von_karman/displacement_based_circular_disk.cc index 854f01fdbdf1..55789f8d8b1f 100644 --- a/demo_drivers/all_foeppl_von_karman/displacement_based_circular_disk.cc +++ b/demo_drivers/all_foeppl_von_karman/displacement_based_circular_disk.cc @@ -336,7 +336,7 @@ UnstructuredFvKProblem::UnstructuredFvKProblem(double element_area) build_global_mesh(); char filename[100]; - sprintf(filename, "RESLT/trace.dat"); + snprintf(filename, sizeof(filename), "RESLT/trace.dat"); Trace_file.open(filename); oomph_info << "Number of equations: " @@ -485,14 +485,14 @@ void UnstructuredFvKProblem::doc_solution() // Number of plot points unsigned npts = 5; - sprintf(filename,"RESLT/soln%i.dat",Doc_info.number()); + snprintf(filename, sizeof(filename), "RESLT/soln%i.dat",Doc_info.number()); some_file.open(filename); this->My_mesh_pt->output(some_file,npts); some_file.close(); // Output boundaries //------------------ - sprintf(filename,"RESLT/boundaries%i.dat",Doc_info.number()); + snprintf(filename, sizeof(filename), "RESLT/boundaries%i.dat",Doc_info.number()); some_file.open(filename); My_mesh_pt->output_boundaries(some_file); some_file.close(); @@ -516,7 +516,7 @@ void UnstructuredFvKProblem::doc_solution() // Plot solution along radial line - sprintf(filename,"RESLT/soln_along_radial_line%i.dat",Doc_info.number()); + snprintf(filename, sizeof(filename), "RESLT/soln_along_radial_line%i.dat",Doc_info.number()); some_file.open(filename); Vector x(2); unsigned nplot=Radial_sample_point_pt.size(); @@ -538,7 +538,7 @@ void UnstructuredFvKProblem::doc_solution() // Doc error and return of the square of the L2 error //--------------------------------------------------- double dummy_error,zero_norm; - sprintf(filename,"RESLT/norm%i.dat",Doc_info.number()); + snprintf(filename, sizeof(filename), "RESLT/norm%i.dat",Doc_info.number()); some_file.open(filename); My_mesh_pt->compute_error(some_file,GlobalParameters::zero, dummy_error,zero_norm); diff --git a/demo_drivers/axisym_advection_diffusion/pipe/pipe.cc b/demo_drivers/axisym_advection_diffusion/pipe/pipe.cc index 811f36b3c43f..af8513707e42 100644 --- a/demo_drivers/axisym_advection_diffusion/pipe/pipe.cc +++ b/demo_drivers/axisym_advection_diffusion/pipe/pipe.cc @@ -250,7 +250,7 @@ void RefineableAdvectionDiffusionPipeProblem::doc_solution() // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); diff --git a/demo_drivers/axisym_advection_diffusion/pipe/pipe_variable_diff.cc b/demo_drivers/axisym_advection_diffusion/pipe/pipe_variable_diff.cc index 0abe289a87ef..e37f34f0f0d8 100644 --- a/demo_drivers/axisym_advection_diffusion/pipe/pipe_variable_diff.cc +++ b/demo_drivers/axisym_advection_diffusion/pipe/pipe_variable_diff.cc @@ -307,7 +307,7 @@ void RefineableAdvectionDiffusionPipeProblem::doc_solution() // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); diff --git a/demo_drivers/axisym_displ_based_foeppl_von_karman/axisym_displ_based_fvk.cc b/demo_drivers/axisym_displ_based_foeppl_von_karman/axisym_displ_based_fvk.cc index f77e7b8d20fb..6345720bf0fe 100644 --- a/demo_drivers/axisym_displ_based_foeppl_von_karman/axisym_displ_based_fvk.cc +++ b/demo_drivers/axisym_displ_based_foeppl_von_karman/axisym_displ_based_fvk.cc @@ -176,7 +176,7 @@ void AxisymFvKProblem::doc_solution() // Output solution with specified number of plot points per element char filename[100]; - sprintf(filename, "%s/soln%i.dat", + snprintf(filename, sizeof(filename), "%s/soln%i.dat", AxisymFvKParameters::Directory.c_str(),Doc_info.number()); ofstream solution_file(filename,ios::app); mesh_pt()->output(solution_file,npts); @@ -184,14 +184,14 @@ void AxisymFvKProblem::doc_solution() // Output exact solution - sprintf(filename, "%s/exactsol%i.dat", + snprintf(filename, sizeof(filename), "%s/exactsol%i.dat", AxisymFvKParameters::Directory.c_str(),Doc_info.number()); ofstream exact_file(filename,ios::app); mesh_pt()->output_fct(exact_file,npts,AxisymFvKParameters::get_exact_u); exact_file.close(); // Output solution at the centre (r=0) as function of the pressure - sprintf(filename, "%s/w_centre.dat",AxisymFvKParameters::Directory.c_str()); + snprintf(filename, sizeof(filename), "%s/w_centre.dat",AxisymFvKParameters::Directory.c_str()); ofstream w_centre_file(filename,ios::app); w_centre_file << AxisymFvKParameters::Pressure << " " << mesh_pt()->node_pt(0)->value(0) << std::endl; diff --git a/demo_drivers/axisym_foeppl_von_karman/axisym_fvk.cc b/demo_drivers/axisym_foeppl_von_karman/axisym_fvk.cc index e0e17d9a76da..ccbcd911baaa 100644 --- a/demo_drivers/axisym_foeppl_von_karman/axisym_fvk.cc +++ b/demo_drivers/axisym_foeppl_von_karman/axisym_fvk.cc @@ -167,7 +167,7 @@ void AxisymFvKProblem::doc_solution() // Output solution with specified number of plot points per element char filename[100]; - sprintf(filename, "%s/sol_%i.dat", + snprintf(filename, sizeof(filename), "%s/sol_%i.dat", AxisymFvKParameters::Directory.c_str(),Doc_info.number()); ofstream solution_file(filename,ios::app); mesh_pt()->output(solution_file,npts); @@ -175,7 +175,7 @@ void AxisymFvKProblem::doc_solution() // Output exact solution - sprintf(filename, "%s/exact_sol_%i.dat", + snprintf(filename, sizeof(filename), "%s/exact_sol_%i.dat", AxisymFvKParameters::Directory.c_str(),Doc_info.number()); ofstream exact_file(filename,ios::app); mesh_pt()->output_fct(exact_file,npts,AxisymFvKParameters::get_exact_u); @@ -183,7 +183,7 @@ void AxisymFvKProblem::doc_solution() // Output solution at the centre (r=0) as function of the pressure - sprintf(filename, "%s/w_centre.dat",AxisymFvKParameters::Directory.c_str()); + snprintf(filename, sizeof(filename), "%s/w_centre.dat",AxisymFvKParameters::Directory.c_str()); ofstream w_centre_file(filename,ios::app); w_centre_file << AxisymFvKParameters::Pressure << " " << mesh_pt()->node_pt(0)->value(0) << std::endl; diff --git a/demo_drivers/axisym_linear_elasticity/cylinder/cylinder.cc b/demo_drivers/axisym_linear_elasticity/cylinder/cylinder.cc index 1c36dc577c44..5b7fed653535 100644 --- a/demo_drivers/axisym_linear_elasticity/cylinder/cylinder.cc +++ b/demo_drivers/axisym_linear_elasticity/cylinder/cylinder.cc @@ -355,7 +355,7 @@ AxisymmetricLinearElasticityProblem() // for (unsigned it=0;itoutput(some_file,npts); some_file.close(); // Output exact solution - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output_fct(some_file,npts,time_pt()->time(), @@ -687,7 +687,7 @@ doc_solution(DocInfo& doc_info) // Doc error double error=0.0; double norm=0.0; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->compute_error(some_file, diff --git a/demo_drivers/axisym_navier_stokes/axi_static_cap/axi_static_cap.cc b/demo_drivers/axisym_navier_stokes/axi_static_cap/axi_static_cap.cc index 66c92b644017..d9111a8b0f6a 100644 --- a/demo_drivers/axisym_navier_stokes/axi_static_cap/axi_static_cap.cc +++ b/demo_drivers/axisym_navier_stokes/axi_static_cap/axi_static_cap.cc @@ -429,7 +429,7 @@ void CapProblem::parameter_study(const string& dir_name) // Open trace file char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); Trace_file.open(filename); Trace_file << "VARIABLES=\"aprescribed\","; Trace_file << "\"hleft\",\"hright\","; @@ -473,7 +473,7 @@ void CapProblem::doc_solution(DocInfo& doc_info) //Output domain - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); @@ -481,7 +481,7 @@ void CapProblem::doc_solution(DocInfo& doc_info) some_file.close(); //Output domain in paraview format - sprintf(filename,"%s/soln%i.vtu",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.vtu",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output_paraview(some_file,npts); @@ -941,7 +941,7 @@ void PseudoSolidCapProblem::parameter_study(const string& dir_name) // Open trace file char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); Trace_file.open(filename); Trace_file << "VARIABLES=\"aprescribed\","; Trace_file << "\"hleft\",\"hright\","; @@ -984,7 +984,7 @@ void PseudoSolidCapProblem::doc_solution(DocInfo& doc_info) unsigned npts=5; //Output domain - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); diff --git a/demo_drivers/axisym_navier_stokes/counter_rotating_disks/counter_rotating_disks.cc b/demo_drivers/axisym_navier_stokes/counter_rotating_disks/counter_rotating_disks.cc index 27ede0b83c8b..4cc6f7c599df 100644 --- a/demo_drivers/axisym_navier_stokes/counter_rotating_disks/counter_rotating_disks.cc +++ b/demo_drivers/axisym_navier_stokes/counter_rotating_disks/counter_rotating_disks.cc @@ -341,7 +341,7 @@ doc_solution(DocInfo& doc_info) const unsigned npts = 5; // Open solution output file - sprintf(filename,"%s/base_soln%i.dat", + snprintf(filename, sizeof(filename), "%s/base_soln%i.dat", doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); @@ -672,7 +672,7 @@ doc_solution(DocInfo& doc_info) const unsigned npts = 5; // Open solution output file - sprintf(filename,"%s/perturbed_soln%i.dat", + snprintf(filename, sizeof(filename), "%s/perturbed_soln%i.dat", doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); @@ -962,7 +962,7 @@ int main(int argc, char* argv[]) // Create and initialise trace file ofstream trace; char filename[256]; - sprintf(filename,"%s/trace.dat", + snprintf(filename, sizeof(filename), "%s/trace.dat", doc_info.directory().c_str()); trace.open(filename); trace << "Re, dominating eigenvalue, n_power_method_iterations" << std::endl; @@ -1028,7 +1028,7 @@ int main(int argc, char* argv[]) // Create and initialise trace file ofstream trace; char filename[256]; - sprintf(filename,"%s/trace.dat", + snprintf(filename, sizeof(filename), "%s/trace.dat", doc_info.directory().c_str()); trace.open(filename); trace << "Re, dominating eigenvalue, n_power_method_iterations" << std::endl; diff --git a/demo_drivers/axisym_navier_stokes/counter_rotating_disks/counter_rotating_disks_ref.cc b/demo_drivers/axisym_navier_stokes/counter_rotating_disks/counter_rotating_disks_ref.cc index d442ef6f72c9..2ec97782249e 100644 --- a/demo_drivers/axisym_navier_stokes/counter_rotating_disks/counter_rotating_disks_ref.cc +++ b/demo_drivers/axisym_navier_stokes/counter_rotating_disks/counter_rotating_disks_ref.cc @@ -368,7 +368,7 @@ doc_solution(DocInfo& doc_info) const unsigned npts = 5; // Open solution output file - sprintf(filename,"%s/base_soln%i.dat", + snprintf(filename, sizeof(filename), "%s/base_soln%i.dat", doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); @@ -733,7 +733,7 @@ doc_solution(DocInfo& doc_info) const unsigned npts = 5; // Open solution output file - sprintf(filename,"%s/perturbed_soln%i.dat", + snprintf(filename, sizeof(filename), "%s/perturbed_soln%i.dat", doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); @@ -1023,7 +1023,7 @@ int main(int argc, char* argv[]) // Create and initialise trace file ofstream trace; char filename[256]; - sprintf(filename,"%s/trace.dat", + snprintf(filename, sizeof(filename), "%s/trace.dat", doc_info.directory().c_str()); trace.open(filename); trace << "Re, dominating eigenvalue, n_power_method_iterations" << std::endl; @@ -1104,7 +1104,7 @@ int main(int argc, char* argv[]) // Create and initialise trace file ofstream trace; char filename[256]; - sprintf(filename,"%s/trace.dat", + snprintf(filename, sizeof(filename), "%s/trace.dat", doc_info.directory().c_str()); trace.open(filename); trace << "Re, dominating eigenvalue, n_power_method_iterations" << std::endl; diff --git a/demo_drivers/axisym_navier_stokes/fibre/fibre.cc b/demo_drivers/axisym_navier_stokes/fibre/fibre.cc index 042317ef0e23..fe979815c474 100644 --- a/demo_drivers/axisym_navier_stokes/fibre/fibre.cc +++ b/demo_drivers/axisym_navier_stokes/fibre/fibre.cc @@ -442,7 +442,7 @@ doc_solution(DocInfo &doc_info) const unsigned npts = 5; // Open solution output file - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); diff --git a/demo_drivers/axisym_navier_stokes/rayleigh_instability/rayleigh_instability.cc b/demo_drivers/axisym_navier_stokes/rayleigh_instability/rayleigh_instability.cc index 124409bd50aa..716ae7242d8c 100644 --- a/demo_drivers/axisym_navier_stokes/rayleigh_instability/rayleigh_instability.cc +++ b/demo_drivers/axisym_navier_stokes/rayleigh_instability/rayleigh_instability.cc @@ -369,7 +369,7 @@ doc_solution(DocInfo &doc_info) const unsigned npts = 5; // Open solution output file - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); @@ -394,7 +394,7 @@ doc_solution(DocInfo &doc_info) // Output solution to file in paraview format string file_name="soln"+StringConversion::to_string(doc_info.number()) +".vtu"; - sprintf(filename,"%s/%s",doc_info.directory().c_str(),file_name.c_str()); + snprintf(filename, sizeof(filename), "%s/%s",doc_info.directory().c_str(),file_name.c_str()); some_file.open(filename); Bulk_mesh_pt->output_paraview(some_file,npts); some_file.close(); @@ -432,7 +432,7 @@ unsteady_run(const double &t_max, const double &dt) // Open trace file char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); Trace_file.open(filename); // Initialise trace file @@ -453,7 +453,7 @@ unsteady_run(const double &t_max, const double &dt) // Open pvd file -- a wrapper for all the different // vtu output files plus information about continuous time // to facilitate animations in paraview - sprintf(filename,"%s/soln.pvd",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/soln.pvd",doc_info.directory().c_str()); Global_Physical_Variables::Pvd_file.open(filename); ParaviewHelper::write_pvd_header(Global_Physical_Variables::Pvd_file); diff --git a/demo_drivers/axisym_navier_stokes/rotating_ends/rotating_ends.cc b/demo_drivers/axisym_navier_stokes/rotating_ends/rotating_ends.cc index 93d6c71f99b8..a036e85ca4e4 100644 --- a/demo_drivers/axisym_navier_stokes/rotating_ends/rotating_ends.cc +++ b/demo_drivers/axisym_navier_stokes/rotating_ends/rotating_ends.cc @@ -336,7 +336,7 @@ void RotatingProblem::solve_system() //Output data at each step //Create the filename, including the array index - sprintf(filename,"Re%g.dat",Re); + snprintf(filename, sizeof(filename), "Re%g.dat",Re); //Actually, write the data file.open(filename); mesh_pt()->output(file,5); diff --git a/demo_drivers/axisym_navier_stokes/single_layer_free_surface_axisym/single_layer_free_surface_axisym.cc b/demo_drivers/axisym_navier_stokes/single_layer_free_surface_axisym/single_layer_free_surface_axisym.cc index 3d79a1127c8c..b5c154e93b9b 100644 --- a/demo_drivers/axisym_navier_stokes/single_layer_free_surface_axisym/single_layer_free_surface_axisym.cc +++ b/demo_drivers/axisym_navier_stokes/single_layer_free_surface_axisym/single_layer_free_surface_axisym.cc @@ -354,7 +354,7 @@ void InterfaceProblem::doc_solution(DocInfo &doc_info) const unsigned npts = 5; // Open solution output file - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); @@ -397,7 +397,7 @@ unsteady_run(const double &t_max, const double &dt) // Open trace file char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); Trace_file.open(filename); // Initialise trace file diff --git a/demo_drivers/axisym_navier_stokes/spin_up/spin_up.cc b/demo_drivers/axisym_navier_stokes/spin_up/spin_up.cc index d2eb750c6373..b1f9aefa195a 100644 --- a/demo_drivers/axisym_navier_stokes/spin_up/spin_up.cc +++ b/demo_drivers/axisym_navier_stokes/spin_up/spin_up.cc @@ -330,7 +330,7 @@ doc_solution(DocInfo& doc_info) const unsigned npts = 5; // Open solution output file - sprintf(filename,"%s/soln%i.dat", + snprintf(filename, sizeof(filename), "%s/soln%i.dat", doc_info.directory().c_str(),doc_info.number()); some_file.open(filename); diff --git a/demo_drivers/axisym_navier_stokes/torus/torus.cc b/demo_drivers/axisym_navier_stokes/torus/torus.cc index ea9b3dd4dc98..5468b1f70cc8 100644 --- a/demo_drivers/axisym_navier_stokes/torus/torus.cc +++ b/demo_drivers/axisym_navier_stokes/torus/torus.cc @@ -404,7 +404,7 @@ void TorusProblem::solve_system(const double &dt, //Output data after the first timestep //Create the filename, including the array index - sprintf(filename,"soln_Re%g_t%g.dat",Re,time()); + snprintf(filename, sizeof(filename), "soln_Re%g_t%g.dat",Re,time()); //Actually, write the data file.open(filename); mesh_pt()->output(file,5); @@ -423,7 +423,7 @@ void TorusProblem::solve_system(const double &dt, //Output data at each step //Create the filename, including the array index - sprintf(filename,"soln_Re%g_t%g.dat",Re,time()); + snprintf(filename, sizeof(filename), "soln_Re%g_t%g.dat",Re,time()); //Actually, write the data file.open(filename); mesh_pt()->output(file,5); diff --git a/demo_drivers/axisym_navier_stokes/two_fluid_spherical_cap/two_fluid_spherical_cap.cc b/demo_drivers/axisym_navier_stokes/two_fluid_spherical_cap/two_fluid_spherical_cap.cc index 15c35a43b16c..c2fa2ef99dcc 100644 --- a/demo_drivers/axisym_navier_stokes/two_fluid_spherical_cap/two_fluid_spherical_cap.cc +++ b/demo_drivers/axisym_navier_stokes/two_fluid_spherical_cap/two_fluid_spherical_cap.cc @@ -370,7 +370,7 @@ void CapProblem::solve_system() steady_newton_solve(); //Create the filename, including the array index - sprintf(filename,"step%i_spine.dat",i); + snprintf(filename, sizeof(filename), "step%i_spine.dat",i); //Actually, write the data file.open(filename); Bulk_mesh_pt->output(file,5); diff --git a/demo_drivers/axisym_navier_stokes/two_layer_interface_axisym/elastic_two_layer_interface_axisym.cc b/demo_drivers/axisym_navier_stokes/two_layer_interface_axisym/elastic_two_layer_interface_axisym.cc index 097434f72028..6aa84268e28d 100644 --- a/demo_drivers/axisym_navier_stokes/two_layer_interface_axisym/elastic_two_layer_interface_axisym.cc +++ b/demo_drivers/axisym_navier_stokes/two_layer_interface_axisym/elastic_two_layer_interface_axisym.cc @@ -715,7 +715,7 @@ void InterfaceProblem::doc_solution(DocInfo &doc_info) const unsigned npts = 5; // Open solution output file - sprintf(filename,"%s/soln%i.dat", + snprintf(filename, sizeof(filename), "%s/soln%i.dat", doc_info.directory().c_str(),doc_info.number()); some_file.open(filename); @@ -726,7 +726,7 @@ void InterfaceProblem::doc_solution(DocInfo &doc_info) some_file.close(); // Open interface solution output file - sprintf(filename,"%s/interface_soln%i.dat", + snprintf(filename, sizeof(filename), "%s/interface_soln%i.dat", doc_info.directory().c_str(),doc_info.number()); some_file.open(filename); @@ -768,7 +768,7 @@ unsteady_run(const double &t_max, const double &dt) // Open trace file char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); Trace_file.open(filename); // Initialise trace file diff --git a/demo_drivers/axisym_navier_stokes/two_layer_interface_axisym/spine_two_layer_interface_axisym.cc b/demo_drivers/axisym_navier_stokes/two_layer_interface_axisym/spine_two_layer_interface_axisym.cc index fca5863f1a52..aec1ed1372fc 100644 --- a/demo_drivers/axisym_navier_stokes/two_layer_interface_axisym/spine_two_layer_interface_axisym.cc +++ b/demo_drivers/axisym_navier_stokes/two_layer_interface_axisym/spine_two_layer_interface_axisym.cc @@ -448,7 +448,7 @@ void InterfaceProblem::doc_solution(DocInfo &doc_info) const unsigned npts = 5; // Open solution output file - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); @@ -491,7 +491,7 @@ unsteady_run(const double &t_max, const double &dt) // Open trace file char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); Trace_file.open(filename); // Initialise trace file diff --git a/demo_drivers/axisym_navier_stokes/unstructured_torus/pressure_driven_torus.cc b/demo_drivers/axisym_navier_stokes/unstructured_torus/pressure_driven_torus.cc index 4c77b8086582..90e62f2ddbcd 100644 --- a/demo_drivers/axisym_navier_stokes/unstructured_torus/pressure_driven_torus.cc +++ b/demo_drivers/axisym_navier_stokes/unstructured_torus/pressure_driven_torus.cc @@ -389,7 +389,7 @@ void set_initial_condition() { using namespace Global_Physical_Variables; /*char filename[100]; - sprintf(filename,"./pre_adapt_%g_%g_%g.dat", Re, Delta,Mu); + snprintf(filename, sizeof(filename), "./pre_adapt_%g_%g_%g.dat", Re, Delta,Mu); std::ofstream out_file(filename); Fluid_mesh_pt->output(out_file,5); out_file.close();*/ @@ -488,7 +488,7 @@ void set_initial_condition() //Dump the output /*char filename[100]; - sprintf(filename,"./post_adapt_%g_%g_%g.dat", Re, Delta,Mu); + snprintf(filename, sizeof(filename), "./post_adapt_%g_%g_%g.dat", Re, Delta,Mu); std::ofstream out_file(filename); Fluid_mesh_pt->output(out_file,5); out_file.close();*/ @@ -823,7 +823,7 @@ void UnstructuredTorusProblem::solve_system(const double &dt, std::ofstream file; //Output data after the first timestep //Create the filename, including the array index - sprintf(filename,"%s/soln_De%g_Delta%g_Mu%g.dat",directory.c_str(),Dean, + snprintf(filename, sizeof(filename), "%s/soln_De%g_Delta%g_Mu%g.dat",directory.c_str(),Dean, Delta,Mu); //Actually, write the data file.open(filename); @@ -841,7 +841,7 @@ void UnstructuredTorusProblem::solve_system(const double &dt, //this->steady_newton_solve(1); this->Fluid_mesh_pt->set_lagrangian_nodal_coordinates(); - sprintf(filename,"%s/soln_De%g_Delta%g_Mu%g.dat",directory.c_str(),Dean, + snprintf(filename, sizeof(filename), "%s/soln_De%g_Delta%g_Mu%g.dat",directory.c_str(),Dean, Delta,Mu); //Actually, write the data file.open(filename); @@ -870,7 +870,7 @@ void UnstructuredTorusProblem::solve_system(const double &dt, this->Fluid_mesh_pt->set_lagrangian_nodal_coordinates(); - sprintf(filename,"%s/soln_De%g_Delta%g_Mu%g.dat",directory.c_str(),Dean, + snprintf(filename, sizeof(filename), "%s/soln_De%g_Delta%g_Mu%g.dat",directory.c_str(),Dean, Delta,Mu); //Actually, write the data file.open(filename); diff --git a/demo_drivers/axisym_navier_stokes/unstructured_torus/unstructured_torus.cc b/demo_drivers/axisym_navier_stokes/unstructured_torus/unstructured_torus.cc index 829f5acc4be5..ba3e2568a2a4 100644 --- a/demo_drivers/axisym_navier_stokes/unstructured_torus/unstructured_torus.cc +++ b/demo_drivers/axisym_navier_stokes/unstructured_torus/unstructured_torus.cc @@ -646,7 +646,7 @@ void UnstructuredTorusProblem::solve_system(const double &dt, //Output data after the first timestep //Create the filename, including the array index - sprintf(filename,"%s/soln_Re%g_t%g.dat",directory.c_str(),Re,time()); + snprintf(filename, sizeof(filename), "%s/soln_Re%g_t%g.dat",directory.c_str(),Re,time()); //Actually, write the data file.open(filename); mesh_pt()->output(file,5); @@ -667,7 +667,7 @@ void UnstructuredTorusProblem::solve_system(const double &dt, //Output data at each step //Create the filename, including the array index - sprintf(filename,"%s/soln_Re%g_t%g.dat",directory.c_str(),Re,time()); + snprintf(filename, sizeof(filename), "%s/soln_Re%g_t%g.dat",directory.c_str(),Re,time()); //Actually, write the data file.open(filename); mesh_pt()->output(file,5); diff --git a/demo_drivers/axisym_poroelasticity/unstructured_two_d_curved/unstructured_two_d_curved.cc b/demo_drivers/axisym_poroelasticity/unstructured_two_d_curved/unstructured_two_d_curved.cc index fbc26c135b63..e04c9d3bb5f5 100644 --- a/demo_drivers/axisym_poroelasticity/unstructured_two_d_curved/unstructured_two_d_curved.cc +++ b/demo_drivers/axisym_poroelasticity/unstructured_two_d_curved/unstructured_two_d_curved.cc @@ -924,7 +924,7 @@ AxiPoroProblem::AxiPoroProblem() char filename[500]; // Trace filename - sprintf(filename,"%s/trace.dat",ProblemParameters::Directory.c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",ProblemParameters::Directory.c_str()); // Open the trace file Trace_file.open(filename); @@ -1235,7 +1235,7 @@ void AxiPoroProblem::doc_solution(const unsigned &label) char filename[100]; unsigned npts=5; - sprintf(filename,"%s/soln%i.dat",ProblemParameters::Directory.c_str(),label); + snprintf(filename, sizeof(filename), "%s/soln%i.dat",ProblemParameters::Directory.c_str(),label); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); some_file.close(); @@ -1243,14 +1243,14 @@ void AxiPoroProblem::doc_solution(const unsigned &label) // Output coarse solution //----------------------- unsigned npts_coarse=2; - sprintf(filename,"%s/coarse_soln%i.dat",ProblemParameters::Directory.c_str(),label); + snprintf(filename, sizeof(filename), "%s/coarse_soln%i.dat",ProblemParameters::Directory.c_str(),label); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts_coarse); some_file.close(); // Output boundary condition elements //----------------------------------- - sprintf(filename,"%s/bc_elements%i.dat",ProblemParameters::Directory.c_str(),label); + snprintf(filename, sizeof(filename), "%s/bc_elements%i.dat",ProblemParameters::Directory.c_str(),label); some_file.open(filename); Surface_mesh_pt->output(some_file,npts); some_file.close(); @@ -1260,7 +1260,7 @@ void AxiPoroProblem::doc_solution(const unsigned &label) // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",ProblemParameters::Directory.c_str(),label); + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",ProblemParameters::Directory.c_str(),label); some_file.open(filename); Bulk_mesh_pt->output_fct(some_file, npts, @@ -1272,7 +1272,7 @@ void AxiPoroProblem::doc_solution(const unsigned &label) //---------- Vector norm(3,0.0); Vector error(3,0.0); - sprintf(filename,"%s/error%i.dat",ProblemParameters::Directory.c_str(),label); + snprintf(filename, sizeof(filename), "%s/error%i.dat",ProblemParameters::Directory.c_str(),label); some_file.open(filename); Bulk_mesh_pt->compute_error(some_file, ProblemParameters::exact_soln, diff --git a/demo_drivers/beam/steady_ring/steady_ring.cc b/demo_drivers/beam/steady_ring/steady_ring.cc index fff21bda9e97..c2921998ca61 100644 --- a/demo_drivers/beam/steady_ring/steady_ring.cc +++ b/demo_drivers/beam/steady_ring/steady_ring.cc @@ -301,7 +301,7 @@ void ElasticRingProblem::doc_solution(DocInfo& doc_info, unsigned npts=5; // Output solution - sprintf(filename,"%s/ring%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/ring%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -339,7 +339,7 @@ void ElasticRingProblem::parameter_study(DocInfo& doc_info) //Open a trace file char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); ofstream trace_file(filename); trace_file << "VARIABLES=\"p_e_x_t\",\"R_1\",\"R_2\"" << std::endl; trace_file << "ZONE" << std::endl; diff --git a/demo_drivers/beam/steady_third_ring/steady_third_ring.cc b/demo_drivers/beam/steady_third_ring/steady_third_ring.cc index 7befaf315108..d56e925151a8 100644 --- a/demo_drivers/beam/steady_third_ring/steady_third_ring.cc +++ b/demo_drivers/beam/steady_third_ring/steady_third_ring.cc @@ -287,7 +287,7 @@ void ElasticRingProblem::doc_solution(DocInfo& doc_info, unsigned npts=5; // Output solution - sprintf(filename,"%s/ring%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/ring%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); for(unsigned i=0;i::parameter_study(DocInfo& doc_info) //Open a trace file char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); ofstream trace_file(filename); trace_file << "VARIABLES=\"p_e_x_t\",\"R_1\",\"R_2\"" << std::endl; trace_file << "ZONE" << std::endl; diff --git a/demo_drivers/beam/tensioned_string/tensioned_string.cc b/demo_drivers/beam/tensioned_string/tensioned_string.cc index c8b53a3ba411..2af6abeb3bfb 100644 --- a/demo_drivers/beam/tensioned_string/tensioned_string.cc +++ b/demo_drivers/beam/tensioned_string/tensioned_string.cc @@ -236,7 +236,7 @@ void ElasticBeamProblem::parameter_study() } // Document the solution - sprintf(filename,"RESLT/beam%i.dat",i); + snprintf(filename, sizeof(filename), "RESLT/beam%i.dat",i); file.open(filename); mesh_pt()->output(file,5); file.close(); diff --git a/demo_drivers/beam/unsteady_ring/lin_unsteady_ring.cc b/demo_drivers/beam/unsteady_ring/lin_unsteady_ring.cc index 5e4b9f200387..62e023ac9de4 100644 --- a/demo_drivers/beam/unsteady_ring/lin_unsteady_ring.cc +++ b/demo_drivers/beam/unsteady_ring/lin_unsteady_ring.cc @@ -257,7 +257,7 @@ void ElasticRingProblem::doc_solution( unsigned npts=5; // Output solution - sprintf(filename,"%s/ring%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/ring%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -267,7 +267,7 @@ void ElasticRingProblem::doc_solution( unsigned nsteps=time_stepper_pt()->nprev_values(); for (unsigned t=0;t<=nsteps;t++) { - sprintf(filename,"%s/ring%i-%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/ring%i-%i.dat",doc_info.directory().c_str(), doc_info.number(),t); some_file.open(filename); unsigned Nelem=mesh_pt()->nelement(); @@ -280,7 +280,7 @@ void ElasticRingProblem::doc_solution( } // Output for initial condition object - sprintf(filename,"%s/ic_ring%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/ic_ring%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); @@ -331,7 +331,7 @@ void ElasticRingProblem::unsteady_run() // Set up trace file char filename[100]; - sprintf(filename,"%s/trace_ring.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace_ring.dat",doc_info.directory().c_str()); Trace_file.open(filename); Trace_file << "VARIABLES=\"time\",\"Rctrl\",\"Epot\""; diff --git a/demo_drivers/beam/unsteady_ring/unsteady_ring.cc b/demo_drivers/beam/unsteady_ring/unsteady_ring.cc index c9d5bf1455f4..7bbf63c8c81f 100644 --- a/demo_drivers/beam/unsteady_ring/unsteady_ring.cc +++ b/demo_drivers/beam/unsteady_ring/unsteady_ring.cc @@ -266,7 +266,7 @@ void ElasticRingProblem::doc_solution( unsigned npts=5; // Output solution - sprintf(filename,"%s/ring%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/ring%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -289,7 +289,7 @@ void ElasticRingProblem::doc_solution( unsigned nsteps=time_stepper_pt()->nprev_values(); for (unsigned t=0;t<=nsteps;t++) { - sprintf(filename,"%s/ring%i-%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/ring%i-%i.dat",doc_info.directory().c_str(), doc_info.number(),t); some_file.open(filename); unsigned n_elem=mesh_pt()->nelement(); @@ -303,7 +303,7 @@ void ElasticRingProblem::doc_solution( // Write restart file - sprintf(filename,"%s/ring_restart%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/ring_restart%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); dump_it(some_file); @@ -476,7 +476,7 @@ void ElasticRingProblem::unsteady_run() // Set up trace file char filename[100]; - sprintf(filename,"%s/trace_ring.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace_ring.dat",doc_info.directory().c_str()); Trace_file.open(filename); Trace_file << "VARIABLES=\"time\",\"Rctrl\",\"Epot\""; diff --git a/demo_drivers/bifurcation_tracking/periodic_orbit.cc b/demo_drivers/bifurcation_tracking/periodic_orbit.cc index a18d00ba6572..e2dc1824d5d2 100644 --- a/demo_drivers/bifurcation_tracking/periodic_orbit.cc +++ b/demo_drivers/bifurcation_tracking/periodic_orbit.cc @@ -561,7 +561,7 @@ void ABCProblem::solve() dynamic_cast*>( assembly_handler_pt())->set_previous_dofs_to_current_dofs(); - sprintf(filename,"orbit%g_%g.dat",Global_Physical_Variables::P[0], + snprintf(filename, sizeof(filename), "orbit%g_%g.dat",Global_Physical_Variables::P[0], 1.0/this->dof(this->ndof()-1)); std::ofstream crap(filename); dynamic_cast*>(assembly_handler_pt()) diff --git a/demo_drivers/bifurcation_tracking/track_pitch.cc b/demo_drivers/bifurcation_tracking/track_pitch.cc index f0ab97ddf8a7..d90869ec2760 100644 --- a/demo_drivers/bifurcation_tracking/track_pitch.cc +++ b/demo_drivers/bifurcation_tracking/track_pitch.cc @@ -544,7 +544,7 @@ void RotatingProblem::solve_system() //Output data at each step //Create the filename, including the array index - /*sprintf(filename,"step%g_%g.dat",Length,Re); + /*snprintf(filename, sizeof(filename), "step%g_%g.dat",Length,Re); //Actually, write the data file.open(filename); mesh_pt()->output(file,5); diff --git a/demo_drivers/darcy/unstructured_two_d_circle/unstructured_two_d_circle.cc b/demo_drivers/darcy/unstructured_two_d_circle/unstructured_two_d_circle.cc index cb1f5c087469..dcc92e1e0a6d 100644 --- a/demo_drivers/darcy/unstructured_two_d_circle/unstructured_two_d_circle.cc +++ b/demo_drivers/darcy/unstructured_two_d_circle/unstructured_two_d_circle.cc @@ -378,7 +378,7 @@ DarcyProblem::DarcyProblem() // Open trace file char filename[50]; - sprintf(filename,"%s/trace.dat",TestProblem::Directory.c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",TestProblem::Directory.c_str()); Trace_file.open(filename); } // end of problem constructor @@ -570,7 +570,7 @@ void DarcyProblem::doc_shape_functions() // Coarse solution unsigned npts_coarse=2; - sprintf(filename,"%s/coarse_soln.dat",TestProblem::Directory.c_str()); + snprintf(filename, sizeof(filename), "%s/coarse_soln.dat",TestProblem::Directory.c_str()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts_coarse); some_file.close(); @@ -677,7 +677,7 @@ void DarcyProblem::doc_shape_functions() delete face_el_pt; // Plot - sprintf(filename,"%s/q_shape_fct%i.dat",TestProblem::Directory.c_str(), + snprintf(filename, sizeof(filename), "%s/q_shape_fct%i.dat",TestProblem::Directory.c_str(), count_shape_doc++); some_file.open(filename); unsigned nel=Bulk_mesh_pt->nelement(); @@ -689,7 +689,7 @@ void DarcyProblem::doc_shape_functions() some_file.close(); - sprintf(filename,"%s/outer_unit_normal%i.dat", + snprintf(filename, sizeof(filename), "%s/outer_unit_normal%i.dat", TestProblem::Directory.c_str(),j); some_file.open(filename); some_file << x[0] << " " @@ -700,7 +700,7 @@ void DarcyProblem::doc_shape_functions() some_file.close(); - sprintf(filename,"%s/flux_interpolation_point%i.dat", + snprintf(filename, sizeof(filename), "%s/flux_interpolation_point%i.dat", TestProblem::Directory.c_str(),j); some_file.open(filename); Vector flux_interpolation_point(2); @@ -711,7 +711,7 @@ void DarcyProblem::doc_shape_functions() << std::endl; some_file.close(); - sprintf(filename,"%s/q_shape_fct_with_project%i.dat", + snprintf(filename, sizeof(filename), "%s/q_shape_fct_with_project%i.dat", TestProblem::Directory.c_str(),j); some_file.open(filename); for (unsigned e=0;e::doc_shape_functions() for (unsigned j=n_q_basis_edge;jset_q_internal(j-n_q_basis_edge,1.0); - sprintf(filename,"%s/q_shape_fct%i.dat", + snprintf(filename, sizeof(filename), "%s/q_shape_fct%i.dat", TestProblem::Directory.c_str(), count_shape_doc++); some_file.open(filename); @@ -750,7 +750,7 @@ void DarcyProblem::doc_shape_functions() for (unsigned j=0;jset_p_value(j,1.0); - sprintf(filename,"%s/p_shape_fct%i.dat", + snprintf(filename, sizeof(filename), "%s/p_shape_fct%i.dat", TestProblem::Directory.c_str(), count_shape_doc++); some_file.open(filename); @@ -812,7 +812,7 @@ void DarcyProblem::doc_solution(const unsigned &label) // Output computed solution //------------------------- unsigned npts=5; - sprintf(filename,"%s/soln%i.dat",TestProblem::Directory.c_str(),label); + snprintf(filename, sizeof(filename), "%s/soln%i.dat",TestProblem::Directory.c_str(),label); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); some_file.close(); @@ -821,14 +821,14 @@ void DarcyProblem::doc_solution(const unsigned &label) // Output coarse solution //----------------------- unsigned npts_coarse=2; - sprintf(filename,"%s/coarse_soln%i.dat",TestProblem::Directory.c_str(),label); + snprintf(filename, sizeof(filename), "%s/coarse_soln%i.dat",TestProblem::Directory.c_str(),label); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts_coarse); some_file.close(); // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",TestProblem::Directory.c_str(),label); + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",TestProblem::Directory.c_str(),label); some_file.open(filename); Bulk_mesh_pt->output_fct(some_file, npts, @@ -837,7 +837,7 @@ void DarcyProblem::doc_solution(const unsigned &label) // Output boundary condition elements //----------------------------------- - sprintf(filename,"%s/bc_elements%i.dat",TestProblem::Directory.c_str(),label); + snprintf(filename, sizeof(filename), "%s/bc_elements%i.dat",TestProblem::Directory.c_str(),label); some_file.open(filename); Surface_mesh_pt->output(some_file,npts); some_file.close(); @@ -846,7 +846,7 @@ void DarcyProblem::doc_solution(const unsigned &label) //---------- Vector norm(2,0.0); Vector error(2,0.0); - sprintf(filename,"%s/error%i.dat",TestProblem::Directory.c_str(),label); + snprintf(filename, sizeof(filename), "%s/error%i.dat",TestProblem::Directory.c_str(),label); some_file.open(filename); Bulk_mesh_pt->compute_error(some_file, TestProblem::exact_soln, diff --git a/demo_drivers/eigenproblems/harmonic/complex_harmonic.cc b/demo_drivers/eigenproblems/harmonic/complex_harmonic.cc index b671157fabd3..aba154769631 100644 --- a/demo_drivers/eigenproblems/harmonic/complex_harmonic.cc +++ b/demo_drivers/eigenproblems/harmonic/complex_harmonic.cc @@ -421,7 +421,7 @@ void ComplexHarmonicProblem::doc_solution( npts=5; // Output solution with specified number of plot points per element - sprintf(filename,"soln%i.dat",label); + snprintf(filename, sizeof(filename), "soln%i.dat",label); some_file.open(filename); mesh_pt()->output(some_file,npts); some_file.close(); @@ -495,7 +495,7 @@ solve(const unsigned& label) this->doc_solution(label); char filename[100]; - sprintf(filename,"eigenvalues%i.dat",label); + snprintf(filename, sizeof(filename), "eigenvalues%i.dat",label); //Open an output file for the sorted eigenvalues ofstream evalues(filename); diff --git a/demo_drivers/eigenproblems/harmonic/harmonic.cc b/demo_drivers/eigenproblems/harmonic/harmonic.cc index 4493d8972898..50072ee013f6 100644 --- a/demo_drivers/eigenproblems/harmonic/harmonic.cc +++ b/demo_drivers/eigenproblems/harmonic/harmonic.cc @@ -338,7 +338,7 @@ void HarmonicProblem::doc_solution(const unsigned& label) npts=5; // Output solution with specified number of plot points per element - sprintf(filename,"soln%i.dat",label); + snprintf(filename, sizeof(filename), "soln%i.dat",label); some_file.open(filename); mesh_pt()->output(some_file,npts); some_file.close(); @@ -410,7 +410,7 @@ solve(const unsigned& label) this->doc_solution(label); char filename[100]; - sprintf(filename,"eigenvalues%i.dat",label); + snprintf(filename, sizeof(filename), "eigenvalues%i.dat",label); //Open an output file for the sorted eigenvalues ofstream evalues(filename); diff --git a/demo_drivers/eigenproblems/orr_sommerfeld/orr_sommerfeld.cc b/demo_drivers/eigenproblems/orr_sommerfeld/orr_sommerfeld.cc index 655b2b7ee51d..6df94904db4f 100644 --- a/demo_drivers/eigenproblems/orr_sommerfeld/orr_sommerfeld.cc +++ b/demo_drivers/eigenproblems/orr_sommerfeld/orr_sommerfeld.cc @@ -906,7 +906,7 @@ void OrrSommerfeldProblem::doc_solution(const unsigned& label) npts=5; // Output solution with specified number of plot points per element - sprintf(filename,"soln%i.dat",label); + snprintf(filename, sizeof(filename), "soln%i.dat",label); some_file.open(filename); mesh_pt()->output(some_file,npts); some_file.close(); @@ -1064,7 +1064,7 @@ class ContinuationProblem : public Problem //Output to a trace file trace << Param::Re << " " << element_pt->eval() << std::endl; - //sprintf(filename,"output.%g.dat",Param::Re); + //snprintf(filename, sizeof(filename), "output.%g.dat",Param::Re); //output_file.open(filename); //element_pt->output(output_file,5); //output_file.close(); diff --git a/demo_drivers/extrude_quad_mesh_to_cube_mesh/extrude_triangle_generated_mesh.cc b/demo_drivers/extrude_quad_mesh_to_cube_mesh/extrude_triangle_generated_mesh.cc index f0099f6081b7..c48ce0190a4a 100644 --- a/demo_drivers/extrude_quad_mesh_to_cube_mesh/extrude_triangle_generated_mesh.cc +++ b/demo_drivers/extrude_quad_mesh_to_cube_mesh/extrude_triangle_generated_mesh.cc @@ -23,415 +23,415 @@ //LIC// The authors may be contacted at oomph-lib@maths.man.ac.uk. //LIC// //LIC//==================================================================== -// Driver for 2D moving block - -// Generic includes -#include "generic.h" -#include "navier_stokes.h" - -// Mesh headers -#include "meshes/quad_from_triangle_mesh.h" -#include "meshes/extruded_cube_mesh_from_quad_mesh_with_macro_elements.h" - -using namespace oomph; - -/////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////// - -//======start_of_GlobalParameters_namespace=============================== -/// Global parameters for the problem -//======================================================================== -namespace GlobalParameters -{ - /// Reynolds number - double Re=100.0; - - /// Length of the mesh in the z-direction - double L_z=3.0; - - /// Number of elements in the z-direction - unsigned N_z=5; - - /// Helper for documenting - DocInfo Doc_info; -} // End of GlobalParameters - -/////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////////// - -//======start_of_problem_class============================================ -/// Moving block problem -//======================================================================== -template -class MovingBlockProblem : public Problem -{ -public: - /// Constructor - MovingBlockProblem(); - - /// Destructor (empty) - ~MovingBlockProblem() {} - - /// Update the problem specs before solve. Reset velocity boundary - /// conditions just to be on the safe side... - void actions_before_newton_solve() - { - // Call the helper function to set the boundary conditions - apply_boundary_conditions(); - } // End of actions_before_newton_solve - - /// Update the after solve (empty) - void actions_after_newton_solve() {} - - /// After adaptation: Unpin pressure and pin redudant pressure dofs. - void actions_after_adapt(); - - /// Doc the solution - void doc_solution(); - -private: - // Make an alias for the 3D cube element - typedef RefineableQTaylorHoodElement<3> EXTRUDED_ELEMENT; - - /// Pointer to the 3D "extruded" mesh - RefineableExtrudedCubeMeshFromQuadMesh* Extruded_mesh_pt; - - /// Generate a 2D mesh and "extrude" it to create a 3D mesh - void create_extruded_mesh(); - - /// Set the chosen boundary conditions - void apply_boundary_conditions(); - - /// Finish the build of the elements: assign their problem parameter pointers - void complete_element_build(); - - /// Fix pressure in element e at pressure dof pdof and set to pvalue - void fix_pressure(const unsigned &e, - const unsigned &p_dof, - const double &p_value) - { - // Cast to full element type and fix the pressure at that element - dynamic_cast(mesh_pt()->element_pt(e))-> - fix_pressure(p_dof,p_value); - } // End of fix_pressure - - // Enumeration of the boundaries of the 3D mesh - enum - { - Lower_boundary_id=0, - Right_boundary_id=1, - Upper_boundary_id=2, - Left_boundary_id=3, - Cylinder_surface_boundary_id=4, - Initial_time_boundary_id=5, - Final_time_boundary_id=6 - }; -}; // End of MovingBlockProblem class - -//==start_of_constructor================================================== -/// Constructor for MovingBlock problem -//======================================================================== -template -MovingBlockProblem::MovingBlockProblem() -{ - // Set the maximum residuals value - Problem::Max_residuals=100.0; - - // Create the extruded 3D mesh - create_extruded_mesh(); - - // Set the chosen boundary conditions - apply_boundary_conditions(); - - // Finish the build of the elements: assign their problem parameter pointers - complete_element_build(); - - // We're using QTaylorHood elements so we need to pin the redundant nodal - // pressure dofs and because we're not using traction BCs, the pressure is - // only determined up to a constant so need to add a constraint to make the - // solution unique. For this, we set the first pressure value in element 0 - // to 0.0. This is all implemented in actions_after_adapt(). - actions_after_adapt(); - - // Setup equation numbering scheme - std::cout << "Number of equations: " << assign_eqn_numbers() << std::endl; -} // End of MovingBlockProblem - - -//======start_of_create_extruded_mesh====================================== -/// Generate the extruded 3D mesh -//========================================================================= -template -void MovingBlockProblem::create_extruded_mesh() -{ - // Convert arguments to strings that specify the input file names - const string node_file_name("triangle_meshes/box_hole.1.node"); - const string element_file_name("triangle_meshes/box_hole.1.ele"); - const string poly_file_name("triangle_meshes/box_hole.1.poly"); - - // Record the start time - double start_t=TimingHelpers::timer(); - - // Create the bulk mesh - RefineableQuadFromTriangleMesh* twod_mesh_pt= - new RefineableQuadFromTriangleMesh( - node_file_name,element_file_name,poly_file_name); - - // Record the end time and compute the mesh setup time - oomph_info << "Time to generate quad mesh [sec]: " - << TimingHelpers::timer()-start_t << std::endl; - - // Output the number of elements - oomph_info << "\nNumber of quad mesh elements: " << twod_mesh_pt->nelement() - << "\nNumber of quad mesh nodes: " << twod_mesh_pt->nnode() - << std::endl; - - // Record the start time - start_t=TimingHelpers::timer(); - - // Create the extruded mesh - Extruded_mesh_pt=new RefineableExtrudedCubeMeshFromQuadMesh( - twod_mesh_pt,GlobalParameters::N_z,GlobalParameters::L_z); - - // Record the end time and compute the mesh setup time - oomph_info << "Time to generate extruded mesh [sec]: " - << TimingHelpers::timer()-start_t << std::endl; - - // Create/set error estimator - Extruded_mesh_pt->spatial_error_estimator_pt()=new Z2ErrorEstimator; - - // Choose error tolerances to force some uniform refinement - Extruded_mesh_pt->min_permitted_error()=1.0e-03; - Extruded_mesh_pt->max_permitted_error()=3.0e-02; - - // Create the main mesh - mesh_pt()=Extruded_mesh_pt; - - // Output the number of elements - oomph_info << "\nNumber of extruded mesh elements: " << mesh_pt()->nelement() - << "\nNumber of extruded mesh nodes: " << mesh_pt()->nnode() - << std::endl; -} // End of create_extruded_mesh - - -//=====start_of_apply_boundary_conditions=================================== -/// Set the chosen boundary conditions -//========================================================================== -template -void MovingBlockProblem::apply_boundary_conditions() -{ - // Get the start time - double start_t=TimingHelpers::timer(); - - // Set the boundary conditions for this problem: All nodes are free by - // default -- just pin the ones that have Dirichlet conditions here. - // Ignore the lower boundary (b=0) so we can do it separately afterwards - unsigned n_boundary=mesh_pt()->nboundary(); - for (unsigned b=1; bnboundary_node(b); - for (unsigned n=0; nboundary_node_pt(b,n); - - unsigned n_value=boundary_node_pt->nvalue(); - - // Just pin the velocity dofs - for (unsigned i=0; ipin(i); - - // No-slip BCs on the side walls - boundary_node_pt->set_value(i,0.0); - } - } // for (unsigned n=0; nnboundary_node(Lower_boundary_id); - for (unsigned n=0; nboundary_node_pt(Lower_boundary_id,n); - - // The number of N.St. unknowns - unsigned n_value=boundary_node_pt->nvalue(); - - // Just pin the velocity dofs - for (unsigned i=0; ipin(i); - } - - // Horizontal flow - boundary_node_pt->set_value(0,1.0); - boundary_node_pt->set_value(1,0.0); - boundary_node_pt->set_value(2,0.0); - } // for (unsigned n=0; n -void MovingBlockProblem::complete_element_build() -{ - // Get the start time - double start_t=TimingHelpers::timer(); - - // Find number of elements in mesh - unsigned n_element=mesh_pt()->nelement(); - - // Loop over the elements to set up element-specific things that cannot be - // handled by constructor - for (unsigned e=0; e(mesh_pt()->element_pt(e)); - - // Set the Reynolds number - el_pt->re_pt()=&GlobalParameters::Re; - } - - // Output the setup time to the screen - oomph_info << "\nTime taken to complete build of elements [sec]: " - << TimingHelpers::timer()-start_t << std::endl; -} // End of complete_element_build - - -//======start_of_actions_after_adapt======================================== -/// After adaptation: Unpin pressure and pin redudant pressure dofs. -//========================================================================== -template -void MovingBlockProblem::actions_after_adapt() -{ - // Unpin all pressure dofs - RefineableNavierStokesEquations<3>:: - unpin_all_pressure_dofs(mesh_pt()->element_pt()); - - // Pin redundant pressure dofs - RefineableNavierStokesEquations<3>:: - pin_redundant_nodal_pressures(mesh_pt()->element_pt()); - - // Now set the first pressure dof in the first element to 0.0 - fix_pressure(0,0,0.0); -} // End of actions_after_adapt - - -//======start_of_doc_solution============================================= -/// Doc the solution -//======================================================================== -template -void MovingBlockProblem::doc_solution() -{ - // Stream to output the data to the output file - std::ofstream some_file; - - // Storage for the filename - char filename[200]; - - // Number of plot points - unsigned n_plot_point=2; - - // Output solution - sprintf(filename,"%s/soln%i.dat", - GlobalParameters::Doc_info.directory().c_str(), - GlobalParameters::Doc_info.number()); - - // Document the solution - some_file.open(filename); - mesh_pt()->output(some_file,n_plot_point); - some_file.close(); - - // Increment the counter - GlobalParameters::Doc_info.number()++; -} // End of doc_solution - -//////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////// - -//==start_of_main====================================================== -/// Driver for MovingBlock test problem -- test drive -/// with two different types of element. -//===================================================================== -int main(int argc, char *argv[]) -{ -#ifdef OOMPH_HAS_MPI - // Initialise MPI - MPI_Helpers::init(argc,argv); - - // Switch off output modifier - oomph_info.output_modifier_pt()=&default_output_modifier; - - // Switch off oomph_info output for all processors but rank 0 - if (MPI_Helpers::communicator_pt()->my_rank()!=0) - { - oomph_info.stream_pt()=&oomph_nullstream; - OomphLibWarning::set_stream_pt(&oomph_nullstream); - OomphLibError::set_stream_pt(&oomph_nullstream); - } - else - { - oomph_info << "\n=====================================================\n" - << "Number of processors: " - << MPI_Helpers::communicator_pt()->nproc() - << "\n=====================================================\n" - << std::endl; - } -#endif - - // Record the start time - double start_t=TimingHelpers::timer(); - - // Set output directory - GlobalParameters::Doc_info.set_directory("RESLT"); - - // Step number - GlobalParameters::Doc_info.number()=0; - - // Typedef the ELEMENT and MESH type - typedef RefineableQTaylorHoodElement<2> ELEMENT; - - // Build the problem with QCrouzeixRaviartElements - MovingBlockProblem problem; - - // Tell the user - oomph_info << "Using RefineableQTaylorHoodElement<2>" << std::endl; - - // Solve the problem - problem.newton_solve(); - - // Output the solution - problem.doc_solution(); - - // Solve the problem - problem.adapt(); - - // Solve the problem - problem.newton_solve(); - - // Output the solution - problem.doc_solution(); - - // Record the end time and compute the mesh setup time - oomph_info << "Simulation complete.\n\nTime taken for simulation [sec]: " - << TimingHelpers::timer()-start_t << std::endl; - -#ifdef OOMPH_HAS_MPI - // Initialise MPI - MPI_Helpers::finalize(); -#endif -} // end_of_main - +// Driver for 2D moving block + +// Generic includes +#include "generic.h" +#include "navier_stokes.h" + +// Mesh headers +#include "meshes/quad_from_triangle_mesh.h" +#include "meshes/extruded_cube_mesh_from_quad_mesh_with_macro_elements.h" + +using namespace oomph; + +/////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////// + +//======start_of_GlobalParameters_namespace=============================== +/// Global parameters for the problem +//======================================================================== +namespace GlobalParameters +{ + /// Reynolds number + double Re=100.0; + + /// Length of the mesh in the z-direction + double L_z=3.0; + + /// Number of elements in the z-direction + unsigned N_z=5; + + /// Helper for documenting + DocInfo Doc_info; +} // End of GlobalParameters + +/////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////// + +//======start_of_problem_class============================================ +/// Moving block problem +//======================================================================== +template +class MovingBlockProblem : public Problem +{ +public: + /// Constructor + MovingBlockProblem(); + + /// Destructor (empty) + ~MovingBlockProblem() {} + + /// Update the problem specs before solve. Reset velocity boundary + /// conditions just to be on the safe side... + void actions_before_newton_solve() + { + // Call the helper function to set the boundary conditions + apply_boundary_conditions(); + } // End of actions_before_newton_solve + + /// Update the after solve (empty) + void actions_after_newton_solve() {} + + /// After adaptation: Unpin pressure and pin redudant pressure dofs. + void actions_after_adapt(); + + /// Doc the solution + void doc_solution(); + +private: + // Make an alias for the 3D cube element + typedef RefineableQTaylorHoodElement<3> EXTRUDED_ELEMENT; + + /// Pointer to the 3D "extruded" mesh + RefineableExtrudedCubeMeshFromQuadMesh* Extruded_mesh_pt; + + /// Generate a 2D mesh and "extrude" it to create a 3D mesh + void create_extruded_mesh(); + + /// Set the chosen boundary conditions + void apply_boundary_conditions(); + + /// Finish the build of the elements: assign their problem parameter pointers + void complete_element_build(); + + /// Fix pressure in element e at pressure dof pdof and set to pvalue + void fix_pressure(const unsigned &e, + const unsigned &p_dof, + const double &p_value) + { + // Cast to full element type and fix the pressure at that element + dynamic_cast(mesh_pt()->element_pt(e))-> + fix_pressure(p_dof,p_value); + } // End of fix_pressure + + // Enumeration of the boundaries of the 3D mesh + enum + { + Lower_boundary_id=0, + Right_boundary_id=1, + Upper_boundary_id=2, + Left_boundary_id=3, + Cylinder_surface_boundary_id=4, + Initial_time_boundary_id=5, + Final_time_boundary_id=6 + }; +}; // End of MovingBlockProblem class + +//==start_of_constructor================================================== +/// Constructor for MovingBlock problem +//======================================================================== +template +MovingBlockProblem::MovingBlockProblem() +{ + // Set the maximum residuals value + Problem::Max_residuals=100.0; + + // Create the extruded 3D mesh + create_extruded_mesh(); + + // Set the chosen boundary conditions + apply_boundary_conditions(); + + // Finish the build of the elements: assign their problem parameter pointers + complete_element_build(); + + // We're using QTaylorHood elements so we need to pin the redundant nodal + // pressure dofs and because we're not using traction BCs, the pressure is + // only determined up to a constant so need to add a constraint to make the + // solution unique. For this, we set the first pressure value in element 0 + // to 0.0. This is all implemented in actions_after_adapt(). + actions_after_adapt(); + + // Setup equation numbering scheme + std::cout << "Number of equations: " << assign_eqn_numbers() << std::endl; +} // End of MovingBlockProblem + + +//======start_of_create_extruded_mesh====================================== +/// Generate the extruded 3D mesh +//========================================================================= +template +void MovingBlockProblem::create_extruded_mesh() +{ + // Convert arguments to strings that specify the input file names + const string node_file_name("triangle_meshes/box_hole.1.node"); + const string element_file_name("triangle_meshes/box_hole.1.ele"); + const string poly_file_name("triangle_meshes/box_hole.1.poly"); + + // Record the start time + double start_t=TimingHelpers::timer(); + + // Create the bulk mesh + RefineableQuadFromTriangleMesh* twod_mesh_pt= + new RefineableQuadFromTriangleMesh( + node_file_name,element_file_name,poly_file_name); + + // Record the end time and compute the mesh setup time + oomph_info << "Time to generate quad mesh [sec]: " + << TimingHelpers::timer()-start_t << std::endl; + + // Output the number of elements + oomph_info << "\nNumber of quad mesh elements: " << twod_mesh_pt->nelement() + << "\nNumber of quad mesh nodes: " << twod_mesh_pt->nnode() + << std::endl; + + // Record the start time + start_t=TimingHelpers::timer(); + + // Create the extruded mesh + Extruded_mesh_pt=new RefineableExtrudedCubeMeshFromQuadMesh( + twod_mesh_pt,GlobalParameters::N_z,GlobalParameters::L_z); + + // Record the end time and compute the mesh setup time + oomph_info << "Time to generate extruded mesh [sec]: " + << TimingHelpers::timer()-start_t << std::endl; + + // Create/set error estimator + Extruded_mesh_pt->spatial_error_estimator_pt()=new Z2ErrorEstimator; + + // Choose error tolerances to force some uniform refinement + Extruded_mesh_pt->min_permitted_error()=1.0e-03; + Extruded_mesh_pt->max_permitted_error()=3.0e-02; + + // Create the main mesh + mesh_pt()=Extruded_mesh_pt; + + // Output the number of elements + oomph_info << "\nNumber of extruded mesh elements: " << mesh_pt()->nelement() + << "\nNumber of extruded mesh nodes: " << mesh_pt()->nnode() + << std::endl; +} // End of create_extruded_mesh + + +//=====start_of_apply_boundary_conditions=================================== +/// Set the chosen boundary conditions +//========================================================================== +template +void MovingBlockProblem::apply_boundary_conditions() +{ + // Get the start time + double start_t=TimingHelpers::timer(); + + // Set the boundary conditions for this problem: All nodes are free by + // default -- just pin the ones that have Dirichlet conditions here. + // Ignore the lower boundary (b=0) so we can do it separately afterwards + unsigned n_boundary=mesh_pt()->nboundary(); + for (unsigned b=1; bnboundary_node(b); + for (unsigned n=0; nboundary_node_pt(b,n); + + unsigned n_value=boundary_node_pt->nvalue(); + + // Just pin the velocity dofs + for (unsigned i=0; ipin(i); + + // No-slip BCs on the side walls + boundary_node_pt->set_value(i,0.0); + } + } // for (unsigned n=0; nnboundary_node(Lower_boundary_id); + for (unsigned n=0; nboundary_node_pt(Lower_boundary_id,n); + + // The number of N.St. unknowns + unsigned n_value=boundary_node_pt->nvalue(); + + // Just pin the velocity dofs + for (unsigned i=0; ipin(i); + } + + // Horizontal flow + boundary_node_pt->set_value(0,1.0); + boundary_node_pt->set_value(1,0.0); + boundary_node_pt->set_value(2,0.0); + } // for (unsigned n=0; n +void MovingBlockProblem::complete_element_build() +{ + // Get the start time + double start_t=TimingHelpers::timer(); + + // Find number of elements in mesh + unsigned n_element=mesh_pt()->nelement(); + + // Loop over the elements to set up element-specific things that cannot be + // handled by constructor + for (unsigned e=0; e(mesh_pt()->element_pt(e)); + + // Set the Reynolds number + el_pt->re_pt()=&GlobalParameters::Re; + } + + // Output the setup time to the screen + oomph_info << "\nTime taken to complete build of elements [sec]: " + << TimingHelpers::timer()-start_t << std::endl; +} // End of complete_element_build + + +//======start_of_actions_after_adapt======================================== +/// After adaptation: Unpin pressure and pin redudant pressure dofs. +//========================================================================== +template +void MovingBlockProblem::actions_after_adapt() +{ + // Unpin all pressure dofs + RefineableNavierStokesEquations<3>:: + unpin_all_pressure_dofs(mesh_pt()->element_pt()); + + // Pin redundant pressure dofs + RefineableNavierStokesEquations<3>:: + pin_redundant_nodal_pressures(mesh_pt()->element_pt()); + + // Now set the first pressure dof in the first element to 0.0 + fix_pressure(0,0,0.0); +} // End of actions_after_adapt + + +//======start_of_doc_solution============================================= +/// Doc the solution +//======================================================================== +template +void MovingBlockProblem::doc_solution() +{ + // Stream to output the data to the output file + std::ofstream some_file; + + // Storage for the filename + char filename[200]; + + // Number of plot points + unsigned n_plot_point=2; + + // Output solution + snprintf(filename, sizeof(filename), "%s/soln%i.dat", + GlobalParameters::Doc_info.directory().c_str(), + GlobalParameters::Doc_info.number()); + + // Document the solution + some_file.open(filename); + mesh_pt()->output(some_file,n_plot_point); + some_file.close(); + + // Increment the counter + GlobalParameters::Doc_info.number()++; +} // End of doc_solution + +//////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////// + +//==start_of_main====================================================== +/// Driver for MovingBlock test problem -- test drive +/// with two different types of element. +//===================================================================== +int main(int argc, char *argv[]) +{ +#ifdef OOMPH_HAS_MPI + // Initialise MPI + MPI_Helpers::init(argc,argv); + + // Switch off output modifier + oomph_info.output_modifier_pt()=&default_output_modifier; + + // Switch off oomph_info output for all processors but rank 0 + if (MPI_Helpers::communicator_pt()->my_rank()!=0) + { + oomph_info.stream_pt()=&oomph_nullstream; + OomphLibWarning::set_stream_pt(&oomph_nullstream); + OomphLibError::set_stream_pt(&oomph_nullstream); + } + else + { + oomph_info << "\n=====================================================\n" + << "Number of processors: " + << MPI_Helpers::communicator_pt()->nproc() + << "\n=====================================================\n" + << std::endl; + } +#endif + + // Record the start time + double start_t=TimingHelpers::timer(); + + // Set output directory + GlobalParameters::Doc_info.set_directory("RESLT"); + + // Step number + GlobalParameters::Doc_info.number()=0; + + // Typedef the ELEMENT and MESH type + typedef RefineableQTaylorHoodElement<2> ELEMENT; + + // Build the problem with QCrouzeixRaviartElements + MovingBlockProblem problem; + + // Tell the user + oomph_info << "Using RefineableQTaylorHoodElement<2>" << std::endl; + + // Solve the problem + problem.newton_solve(); + + // Output the solution + problem.doc_solution(); + + // Solve the problem + problem.adapt(); + + // Solve the problem + problem.newton_solve(); + + // Output the solution + problem.doc_solution(); + + // Record the end time and compute the mesh setup time + oomph_info << "Simulation complete.\n\nTime taken for simulation [sec]: " + << TimingHelpers::timer()-start_t << std::endl; + +#ifdef OOMPH_HAS_MPI + // Initialise MPI + MPI_Helpers::finalize(); +#endif +} // end_of_main + diff --git a/demo_drivers/extrude_quad_mesh_to_cube_mesh/extrude_with_macro_element_representation.cc b/demo_drivers/extrude_quad_mesh_to_cube_mesh/extrude_with_macro_element_representation.cc index 1419b337ba22..fa2419b4eda7 100644 --- a/demo_drivers/extrude_quad_mesh_to_cube_mesh/extrude_with_macro_element_representation.cc +++ b/demo_drivers/extrude_quad_mesh_to_cube_mesh/extrude_with_macro_element_representation.cc @@ -536,7 +536,7 @@ doc_solution() // Output solution: //----------------- // Create the filename - sprintf(filename,"%s/soln%i.dat", + snprintf(filename, sizeof(filename), "%s/soln%i.dat", GlobalParameters::Doc_info.directory().c_str(), GlobalParameters::Doc_info.number()); @@ -552,7 +552,7 @@ doc_solution() //----------------------- // Output exact solution: //----------------------- - sprintf(filename,"%s/exact_soln%i.dat", + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat", GlobalParameters::Doc_info.directory().c_str(), GlobalParameters::Doc_info.number()); @@ -572,7 +572,7 @@ doc_solution() double error=0.0, norm=0.0; // Create the filename - sprintf(filename,"%s/error%i.dat", + snprintf(filename, sizeof(filename), "%s/error%i.dat", GlobalParameters::Doc_info.directory().c_str(), GlobalParameters::Doc_info.number()); diff --git a/demo_drivers/flux_transport/advection/one_d_advection.cc b/demo_drivers/flux_transport/advection/one_d_advection.cc index 4a654d14595b..f05c9a6ea26a 100644 --- a/demo_drivers/flux_transport/advection/one_d_advection.cc +++ b/demo_drivers/flux_transport/advection/one_d_advection.cc @@ -376,12 +376,12 @@ class AdvectionProblem : public Problem { if(disc) { - sprintf(filename,"disc_%li_time%g.dat",mesh_pt()->nelement(), + snprintf(filename, sizeof(filename), "disc_%li_time%g.dat",mesh_pt()->nelement(), this->time()); } else { - sprintf(filename,"cont_%li_time%g.dat",mesh_pt()->nelement(), + snprintf(filename, sizeof(filename), "cont_%li_time%g.dat",mesh_pt()->nelement(), this->time()); } outfile.open(filename); diff --git a/demo_drivers/flux_transport/advection/two_d_advection.cc b/demo_drivers/flux_transport/advection/two_d_advection.cc index 7e3746b64fa8..91a74e674e8c 100644 --- a/demo_drivers/flux_transport/advection/two_d_advection.cc +++ b/demo_drivers/flux_transport/advection/two_d_advection.cc @@ -320,11 +320,11 @@ class TwoDDGProblem : public Problem { if(disc) { - sprintf(filename,"disc_%li_time%g.dat",mesh_pt()->nelement(),time()); + snprintf(filename, sizeof(filename), "disc_%li_time%g.dat",mesh_pt()->nelement(),time()); } else { - sprintf(filename,"cont_%li_time%g.dat",mesh_pt()->nelement(),time()); + snprintf(filename, sizeof(filename), "cont_%li_time%g.dat",mesh_pt()->nelement(),time()); } std::ofstream outfile(filename); mesh_pt()->output(outfile); diff --git a/demo_drivers/flux_transport/euler/couette.cc b/demo_drivers/flux_transport/euler/couette.cc index e51a3f87e0b7..a17d8da3c361 100644 --- a/demo_drivers/flux_transport/euler/couette.cc +++ b/demo_drivers/flux_transport/euler/couette.cc @@ -490,11 +490,11 @@ class TwoDDGProblem : public Problem { if(disc) { - sprintf(filename,"disc_%li_time%g.dat",mesh_pt()->nelement(),time()); + snprintf(filename, sizeof(filename), "disc_%li_time%g.dat",mesh_pt()->nelement(),time()); } else { - sprintf(filename,"cont_%li_time%g.dat",mesh_pt()->nelement(),time()); + snprintf(filename, sizeof(filename), "cont_%li_time%g.dat",mesh_pt()->nelement(),time()); } std::ofstream outfile(filename); mesh_pt()->output(outfile); diff --git a/demo_drivers/flux_transport/euler/ff_step.cc b/demo_drivers/flux_transport/euler/ff_step.cc index 7740334a9bc0..033d17577d48 100644 --- a/demo_drivers/flux_transport/euler/ff_step.cc +++ b/demo_drivers/flux_transport/euler/ff_step.cc @@ -1524,11 +1524,11 @@ class TwoDDGProblem : public Problem { if(disc) { - sprintf(filename,"disc_%li_time%g.dat",mesh_pt()->nelement(),time()); + snprintf(filename, sizeof(filename), "disc_%li_time%g.dat",mesh_pt()->nelement(),time()); } else { - sprintf(filename,"cont_%li_time%g.dat",mesh_pt()->nelement(),time()); + snprintf(filename, sizeof(filename), "cont_%li_time%g.dat",mesh_pt()->nelement(),time()); } std::ofstream outfile(filename); mesh_pt()->output(outfile); diff --git a/demo_drivers/flux_transport/euler/one_d_euler.cc b/demo_drivers/flux_transport/euler/one_d_euler.cc index 0f2c64b61c91..0e98694a6c08 100644 --- a/demo_drivers/flux_transport/euler/one_d_euler.cc +++ b/demo_drivers/flux_transport/euler/one_d_euler.cc @@ -371,12 +371,12 @@ class EulerProblem : public Problem if(sod) { - sprintf(filename,"sod_%li_time%g.dat",mesh_pt()->nelement(), + snprintf(filename, sizeof(filename), "sod_%li_time%g.dat",mesh_pt()->nelement(), this->time()); } else { - sprintf(filename,"lax_%li_time%g.dat",mesh_pt()->nelement(), + snprintf(filename, sizeof(filename), "lax_%li_time%g.dat",mesh_pt()->nelement(), this->time()); } outfile.open(filename); @@ -396,12 +396,12 @@ class EulerProblem : public Problem { if(sod) { - sprintf(filename,"sod_%li_time%g.dat",mesh_pt()->nelement(), + snprintf(filename, sizeof(filename), "sod_%li_time%g.dat",mesh_pt()->nelement(), this->time()); } else { - sprintf(filename,"lax_%li_time%g.dat",mesh_pt()->nelement(), + snprintf(filename, sizeof(filename), "lax_%li_time%g.dat",mesh_pt()->nelement(), this->time()); } outfile.open(filename); diff --git a/demo_drivers/flux_transport/euler/ramp.cc b/demo_drivers/flux_transport/euler/ramp.cc index 037d02a27baa..4b34612d2b59 100644 --- a/demo_drivers/flux_transport/euler/ramp.cc +++ b/demo_drivers/flux_transport/euler/ramp.cc @@ -1162,11 +1162,11 @@ class TwoDDGProblem : public Problem { if(disc) { - sprintf(filename,"disc_%li_time%g.dat",mesh_pt()->nelement(),time()); + snprintf(filename, sizeof(filename), "disc_%li_time%g.dat",mesh_pt()->nelement(),time()); } else { - sprintf(filename,"cont_%li_time%g.dat",mesh_pt()->nelement(),time()); + snprintf(filename, sizeof(filename), "cont_%li_time%g.dat",mesh_pt()->nelement(),time()); } std::ofstream outfile(filename); mesh_pt()->output(outfile); diff --git a/demo_drivers/flux_transport/euler/two_d_euler.cc b/demo_drivers/flux_transport/euler/two_d_euler.cc index d12e04ca0fd2..28b220bfeeca 100644 --- a/demo_drivers/flux_transport/euler/two_d_euler.cc +++ b/demo_drivers/flux_transport/euler/two_d_euler.cc @@ -547,11 +547,11 @@ class TwoDDGProblem : public Problem { if(disc) { - sprintf(filename,"disc_%li_time%g.dat",mesh_pt()->nelement(),time()); + snprintf(filename, sizeof(filename), "disc_%li_time%g.dat",mesh_pt()->nelement(),time()); } else { - sprintf(filename,"cont_%li_time%g.dat",mesh_pt()->nelement(),time()); + snprintf(filename, sizeof(filename), "cont_%li_time%g.dat",mesh_pt()->nelement(),time()); } std::ofstream outfile(filename); mesh_pt()->output(outfile); diff --git a/demo_drivers/foeppl_von_karman/circular_disk/circular_disk.cc b/demo_drivers/foeppl_von_karman/circular_disk/circular_disk.cc index d8bfcc2a368f..32dd6a614a70 100644 --- a/demo_drivers/foeppl_von_karman/circular_disk/circular_disk.cc +++ b/demo_drivers/foeppl_von_karman/circular_disk/circular_disk.cc @@ -426,7 +426,7 @@ UnstructuredFvKProblem::UnstructuredFvKProblem(double element_area) build_global_mesh(); char filename[100]; - sprintf(filename, "RESLT/trace.dat"); + snprintf(filename, sizeof(filename), "RESLT/trace.dat"); Trace_file.open(filename); oomph_info << "Number of equations: " @@ -547,7 +547,7 @@ void UnstructuredFvKProblem::doc_solution(const // Number of plot points unsigned npts = 5; - sprintf(filename,"RESLT/soln%i-%f.dat",Doc_info.number(),Element_area); + snprintf(filename, sizeof(filename), "RESLT/soln%i-%f.dat",Doc_info.number(),Element_area); some_file.open(filename); this->My_mesh_pt->output(some_file,npts); some_file << "TEXT X = 22, Y = 92, CS=FRAME T = \"" @@ -556,7 +556,7 @@ void UnstructuredFvKProblem::doc_solution(const // Output boundaries //------------------ - sprintf(filename,"RESLT/boundaries%i-%f.dat",Doc_info.number(),Element_area); + snprintf(filename, sizeof(filename), "RESLT/boundaries%i-%f.dat",Doc_info.number(),Element_area); some_file.open(filename); My_mesh_pt->output_boundaries(some_file); some_file.close(); @@ -564,7 +564,7 @@ void UnstructuredFvKProblem::doc_solution(const // Output along radial boundary // ---------------------------- - sprintf(filename,"RESLT/radial_soln%i-%f.dat",Doc_info.number(),Element_area); + snprintf(filename, sizeof(filename), "RESLT/radial_soln%i-%f.dat",Doc_info.number(),Element_area); some_file.open(filename); for(unsigned b = Inner_boundary2; b <= Inner_boundary5; b++) { @@ -601,7 +601,7 @@ void UnstructuredFvKProblem::doc_solution(const for (unsigned r = 0; r < n_region; r++) { //Attempt to output elements in different regions - sprintf(filename,"RESLT/region%i%i-%f.dat",r,Doc_info.number(), + snprintf(filename, sizeof(filename), "RESLT/region%i%i-%f.dat",r,Doc_info.number(), Element_area); some_file.open(filename); unsigned nel = My_mesh_pt->nregion_element(r); @@ -617,7 +617,7 @@ void UnstructuredFvKProblem::doc_solution(const double bubble_volume = 0; if (n_region > 1) { - sprintf(filename,"RESLT/bubble_volume%i.dat",Doc_info.number()); + snprintf(filename, sizeof(filename), "RESLT/bubble_volume%i.dat",Doc_info.number()); some_file.open(filename); unsigned n_inner_el; unsigned n_bubble_regions = Bubble_regions.size(); @@ -644,7 +644,7 @@ void UnstructuredFvKProblem::doc_solution(const //--------------------------------------------------- //double error,norm,dummy_error,zero_norm; double dummy_error,zero_norm; - sprintf(filename,"RESLT/error%i-%f.dat",Doc_info.number(),Element_area); + snprintf(filename, sizeof(filename), "RESLT/error%i-%f.dat",Doc_info.number(),Element_area); some_file.open(filename); My_mesh_pt->compute_error(some_file,TestSoln::zero, diff --git a/demo_drivers/fourier_decomposed_helmholtz/sphere_scattering/sphere_scattering.cc b/demo_drivers/fourier_decomposed_helmholtz/sphere_scattering/sphere_scattering.cc index a6d17a3d3e80..b4b2807f2d3e 100644 --- a/demo_drivers/fourier_decomposed_helmholtz/sphere_scattering/sphere_scattering.cc +++ b/demo_drivers/fourier_decomposed_helmholtz/sphere_scattering/sphere_scattering.cc @@ -512,7 +512,7 @@ void FourierDecomposedHelmholtzProblem::check_gamma(DocInfo& doc_info) ofstream some_file; char filename[100]; - sprintf(filename,"%s/gamma_test%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/gamma_test%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); @@ -582,7 +582,7 @@ void FourierDecomposedHelmholtzProblem::doc_solution(DocInfo& doc_info) // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); @@ -591,7 +591,7 @@ void FourierDecomposedHelmholtzProblem::doc_solution(DocInfo& doc_info) // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output_fct(some_file,npts,ProblemParameters::get_exact_u); @@ -601,7 +601,7 @@ void FourierDecomposedHelmholtzProblem::doc_solution(DocInfo& doc_info) // Doc error and return of the square of the L2 error //--------------------------------------------------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->compute_error(some_file,ProblemParameters::get_exact_u, @@ -618,10 +618,10 @@ void FourierDecomposedHelmholtzProblem::doc_solution(DocInfo& doc_info) // Compute/output the radiated power //---------------------------------- - sprintf(filename,"%s/power%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/power%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); - sprintf(filename,"%s/total_power%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/total_power%i.dat",doc_info.directory().c_str(), doc_info.number()); // Accumulate contribution from elements diff --git a/demo_drivers/fourier_decomposed_helmholtz/sphere_scattering/unstructured_sphere_scattering.cc b/demo_drivers/fourier_decomposed_helmholtz/sphere_scattering/unstructured_sphere_scattering.cc index 05f104549fcb..68adf4e9abbd 100644 --- a/demo_drivers/fourier_decomposed_helmholtz/sphere_scattering/unstructured_sphere_scattering.cc +++ b/demo_drivers/fourier_decomposed_helmholtz/sphere_scattering/unstructured_sphere_scattering.cc @@ -683,7 +683,7 @@ void FourierDecomposedHelmholtzProblem::check_gamma(DocInfo& doc_info) ofstream some_file; char filename[100]; - sprintf(filename,"%s/gamma_test%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/gamma_test%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); @@ -753,7 +753,7 @@ void FourierDecomposedHelmholtzProblem::doc_solution(DocInfo& doc_info) // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); @@ -762,7 +762,7 @@ void FourierDecomposedHelmholtzProblem::doc_solution(DocInfo& doc_info) // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output_fct(some_file,npts,ProblemParameters::get_exact_u); @@ -772,7 +772,7 @@ void FourierDecomposedHelmholtzProblem::doc_solution(DocInfo& doc_info) // Doc error and return of the square of the L2 error //--------------------------------------------------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->compute_error(some_file,ProblemParameters::get_exact_u, diff --git a/demo_drivers/generalised_newtonian_axisym_navier_stokes/axisym_vibrating_shell/axisym_vibrating_shell_non_newtonian.cc b/demo_drivers/generalised_newtonian_axisym_navier_stokes/axisym_vibrating_shell/axisym_vibrating_shell_non_newtonian.cc index 1c53ea181e63..2bba5b11cbf7 100644 --- a/demo_drivers/generalised_newtonian_axisym_navier_stokes/axisym_vibrating_shell/axisym_vibrating_shell_non_newtonian.cc +++ b/demo_drivers/generalised_newtonian_axisym_navier_stokes/axisym_vibrating_shell/axisym_vibrating_shell_non_newtonian.cc @@ -1406,7 +1406,7 @@ doc_solution(const std::string& comment) !CommandLineArgs::command_line_flag_has_been_set ("--validation") ) { - sprintf(filename,"%s/restart%i.dat", + snprintf(filename, sizeof(filename), "%s/restart%i.dat", Problem_Parameter::Doc_info_soln.directory().c_str(), Problem_Parameter::Doc_info_soln.number()); ofstream dump_file; @@ -1432,7 +1432,7 @@ doc_solution(const std::string& comment) // Actual solution - sprintf(filename,"%s/soln%i.dat", + snprintf(filename, sizeof(filename), "%s/soln%i.dat", Problem_Parameter::Doc_info_soln.directory().c_str(), Problem_Parameter::Doc_info_soln.number()); some_file.open(filename); @@ -1443,7 +1443,7 @@ doc_solution(const std::string& comment) // Actual solution on the free surface - sprintf(filename,"%s/free_surface_soln%i.dat", + snprintf(filename, sizeof(filename), "%s/free_surface_soln%i.dat", Problem_Parameter::Doc_info_soln.directory().c_str(), Problem_Parameter::Doc_info_soln.number()); some_file.open(filename); @@ -1457,7 +1457,7 @@ doc_solution(const std::string& comment) // Output free surface - sprintf(filename,"%s/free_surface%i.dat", + snprintf(filename, sizeof(filename), "%s/free_surface%i.dat", Problem_Parameter::Doc_info_soln.directory().c_str(), Problem_Parameter::Doc_info_soln.number()); some_file.open(filename); @@ -1475,7 +1475,7 @@ doc_solution(const std::string& comment) // Coarse solution (mesh) unsigned npts_coarse=2; - sprintf(filename,"%s/coarse_soln%i.dat", + snprintf(filename, sizeof(filename), "%s/coarse_soln%i.dat", Problem_Parameter::Doc_info_soln.directory().c_str(), Problem_Parameter::Doc_info_soln.number()); some_file.open(filename); @@ -1485,7 +1485,7 @@ doc_solution(const std::string& comment) some_file.close(); // Doc body force - sprintf(filename,"%s/body_force%i.dat", + snprintf(filename, sizeof(filename), "%s/body_force%i.dat", Problem_Parameter::Doc_info_soln.directory().c_str(), Problem_Parameter::Doc_info_soln.number()); some_file.open(filename); @@ -1515,7 +1515,7 @@ doc_solution(const std::string& comment) // Output boundaries - sprintf(filename,"%s/boundaries%i.dat", + snprintf(filename, sizeof(filename), "%s/boundaries%i.dat", Problem_Parameter::Doc_info_soln.directory().c_str(), Problem_Parameter::Doc_info_soln.number()); some_file.open(filename); diff --git a/demo_drivers/generalised_newtonian_navier_stokes/vibrating_shell/vibrating_shell_non_newtonian.cc b/demo_drivers/generalised_newtonian_navier_stokes/vibrating_shell/vibrating_shell_non_newtonian.cc index 7065d8e46dd0..e376444ab327 100644 --- a/demo_drivers/generalised_newtonian_navier_stokes/vibrating_shell/vibrating_shell_non_newtonian.cc +++ b/demo_drivers/generalised_newtonian_navier_stokes/vibrating_shell/vibrating_shell_non_newtonian.cc @@ -1395,7 +1395,7 @@ doc_solution(const std::string& comment) !CommandLineArgs::command_line_flag_has_been_set ("--validation") ) { - sprintf(filename,"%s/restart%i.dat", + snprintf(filename, sizeof(filename), "%s/restart%i.dat", Problem_Parameter::Doc_info_soln.directory().c_str(), Problem_Parameter::Doc_info_soln.number()); ofstream dump_file; @@ -1421,7 +1421,7 @@ doc_solution(const std::string& comment) // Actual solution - sprintf(filename,"%s/soln%i.dat", + snprintf(filename, sizeof(filename), "%s/soln%i.dat", Problem_Parameter::Doc_info_soln.directory().c_str(), Problem_Parameter::Doc_info_soln.number()); some_file.open(filename); @@ -1432,7 +1432,7 @@ doc_solution(const std::string& comment) // Actual solution on the free surface - sprintf(filename,"%s/free_surface_soln%i.dat", + snprintf(filename, sizeof(filename), "%s/free_surface_soln%i.dat", Problem_Parameter::Doc_info_soln.directory().c_str(), Problem_Parameter::Doc_info_soln.number()); some_file.open(filename); @@ -1446,7 +1446,7 @@ doc_solution(const std::string& comment) // Output free surface - sprintf(filename,"%s/free_surface%i.dat", + snprintf(filename, sizeof(filename), "%s/free_surface%i.dat", Problem_Parameter::Doc_info_soln.directory().c_str(), Problem_Parameter::Doc_info_soln.number()); some_file.open(filename); @@ -1464,7 +1464,7 @@ doc_solution(const std::string& comment) // Coarse solution (mesh) unsigned npts_coarse=2; - sprintf(filename,"%s/coarse_soln%i.dat", + snprintf(filename, sizeof(filename), "%s/coarse_soln%i.dat", Problem_Parameter::Doc_info_soln.directory().c_str(), Problem_Parameter::Doc_info_soln.number()); some_file.open(filename); @@ -1474,7 +1474,7 @@ doc_solution(const std::string& comment) some_file.close(); // Doc body force - sprintf(filename,"%s/body_force%i.dat", + snprintf(filename, sizeof(filename), "%s/body_force%i.dat", Problem_Parameter::Doc_info_soln.directory().c_str(), Problem_Parameter::Doc_info_soln.number()); some_file.open(filename); @@ -1503,7 +1503,7 @@ doc_solution(const std::string& comment) // Output boundaries - sprintf(filename,"%s/boundaries%i.dat", + snprintf(filename, sizeof(filename), "%s/boundaries%i.dat", Problem_Parameter::Doc_info_soln.directory().c_str(), Problem_Parameter::Doc_info_soln.number()); some_file.open(filename); diff --git a/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/circular_boulder_melt.cc b/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/circular_boulder_melt.cc index 9efc0b9b1d28..ba9d06f1b9d8 100644 --- a/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/circular_boulder_melt.cc +++ b/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/circular_boulder_melt.cc @@ -304,7 +304,7 @@ class MeltContactProblem : public Problem // Output flux with melt ofstream some_file; char filename[100]; - sprintf(filename,"flux_with_melt_before.dat"); + snprintf(filename, sizeof(filename), "flux_with_melt_before.dat"); some_file.open(filename); unsigned nel=Left_surface_melt_mesh_pt->nelement(); for (unsigned e=0;enelement(); for (unsigned e=0;e::doc_solution() npts=5; // Output solution - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); @@ -1120,7 +1120,7 @@ void MeltContactProblem::doc_solution() // Output solution coarsely (only element vertices for easier // mesh visualisation) - sprintf(filename,"%s/coarse_soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/coarse_soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,2); @@ -1128,7 +1128,7 @@ void MeltContactProblem::doc_solution() // Output contact elements - sprintf(filename,"%s/contact%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/contact%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); unsigned nel=Surface_contact_mesh_pt->nelement(); @@ -1140,7 +1140,7 @@ void MeltContactProblem::doc_solution() some_file.close(); // Output flux with melt - sprintf(filename,"%s/flux_with_melt%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/flux_with_melt%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); nel=Left_surface_melt_mesh_pt->nelement(); @@ -1153,7 +1153,7 @@ void MeltContactProblem::doc_solution() // Output exact solution - sprintf(filename,"%s/exact_soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output_fct( @@ -1162,7 +1162,7 @@ void MeltContactProblem::doc_solution() some_file.close(); // Output exact position of melting line - sprintf(filename,"%s/exact_height%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_height%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); unsigned nplot=100; @@ -1176,7 +1176,7 @@ void MeltContactProblem::doc_solution() some_file.close(); // Output exact solution - sprintf(filename,"%s/exact_soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output_fct( @@ -1185,7 +1185,7 @@ void MeltContactProblem::doc_solution() some_file.close(); // Output exact position of melting line - sprintf(filename,"%s/exact_height%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_height%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); nplot=100; @@ -1200,7 +1200,7 @@ void MeltContactProblem::doc_solution() // Output penetrator - sprintf(filename,"%s/penetrator%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/penetrator%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); unsigned n=100; @@ -1209,7 +1209,7 @@ void MeltContactProblem::doc_solution() // Output Number of Newton iterations in form that can be visualised // as vector in paraview - sprintf(filename,"%s/newton_iter%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/newton_iter%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); some_file << "0 0 0 " << Nnewton_iter_taken << std::endl; diff --git a/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/circular_boulder_solar_radiation.cc b/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/circular_boulder_solar_radiation.cc index 6286c8d0cde2..cb712c1788c9 100644 --- a/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/circular_boulder_solar_radiation.cc +++ b/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/circular_boulder_solar_radiation.cc @@ -1174,7 +1174,7 @@ void SolarRadiationProblem::doc_solution() npts=5; // Output solution - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); @@ -1182,14 +1182,14 @@ void SolarRadiationProblem::doc_solution() // Output solution coarsely (only element vertices for easier // mesh visualisation) - sprintf(filename,"%s/coarse_soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/coarse_soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,2); some_file.close(); // Output contact elements - sprintf(filename,"%s/contact%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/contact%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); unsigned nel=Surface_contact_mesh_pt->nelement(); @@ -1201,7 +1201,7 @@ void SolarRadiationProblem::doc_solution() some_file.close(); // Output exact solution - sprintf(filename,"%s/exact_soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output_fct( @@ -1217,7 +1217,7 @@ void SolarRadiationProblem::doc_solution() solar_flux_magnitude, solar_flux_unit_vector, total_diffuse_radiation); - sprintf(filename,"%s/solar_radiation%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/solar_radiation%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); some_file << "0.0 3.5 " @@ -1229,7 +1229,7 @@ void SolarRadiationProblem::doc_solution() // Output atmospheric radiation along all exposed surfaces - sprintf(filename,"%s/atmospheric_radiation%i.dat", + snprintf(filename, sizeof(filename), "%s/atmospheric_radiation%i.dat", Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); @@ -1244,7 +1244,7 @@ void SolarRadiationProblem::doc_solution() // Output illumination angles for all integration points - sprintf(filename,"%s/illumination_angles%i.dat", + snprintf(filename, sizeof(filename), "%s/illumination_angles%i.dat", Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); @@ -1269,7 +1269,7 @@ void SolarRadiationProblem::doc_solution() unsigned count=0; for (unsigned e=0;e::doc_solution() count=0; for (unsigned e=0;e::doc_solution() count=0; for (unsigned e=0;e::doc_solution() // Output penetrator - sprintf(filename,"%s/penetrator%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/penetrator%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); unsigned n=100; @@ -1315,7 +1315,7 @@ void SolarRadiationProblem::doc_solution() // Output Number of Newton iterations in form that can be visualised // as vector in paraview - sprintf(filename,"%s/newton_iter%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/newton_iter%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); some_file << "0 0 0 " << Nnewton_iter_taken << std::endl; diff --git a/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/heated_linear_solid_contact_with_gravity.cc b/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/heated_linear_solid_contact_with_gravity.cc index 14f8349c10e4..65a81635cf5d 100644 --- a/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/heated_linear_solid_contact_with_gravity.cc +++ b/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/heated_linear_solid_contact_with_gravity.cc @@ -2985,7 +2985,7 @@ class ContactProblem : public Problem // // Output contact elements // ofstream some_file; // char filename[100]; - // sprintf(filename,"contact_before.dat"); + // snprintf(filename, sizeof(filename), "contact_before.dat"); // some_file.open(filename); // unsigned nel=Surface_contact_mesh_pt->nelement(); // for (unsigned e=0;eoutput(some_file); some_file.close(); @@ -3057,7 +3057,7 @@ class ContactProblem : public Problem // Output impose displ elements ofstream some_file; char filename[100]; - sprintf(filename,"impose_after.dat"); + snprintf(filename, sizeof(filename), "impose_after.dat"); some_file.open(filename); Displ_imposition_mesh_pt->output(some_file); some_file.close(); @@ -4381,7 +4381,7 @@ void ContactProblem::doc_solution() // Write restart file -/* sprintf(filename,"%s/restart%i.dat",doc_info.directory().c_str(), +/* snprintf(filename, sizeof(filename), "%s/restart%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); dump(some_file); @@ -4392,7 +4392,7 @@ void ContactProblem::doc_solution() npts=3; // Output solution - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); @@ -4400,28 +4400,28 @@ void ContactProblem::doc_solution() // Output solution coarsely (only element vertices for easier // mesh visualisation) - sprintf(filename,"%s/coarse_soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/coarse_soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,2); some_file.close(); // Output solution - sprintf(filename,"%s/boulder_soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/boulder_soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Boulder_mesh_pt->output(some_file,npts); some_file.close(); // Output contact region on boulder - sprintf(filename,"%s/boulder_contact%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/boulder_contact%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Boulder_surface_contact_mesh_pt->output(some_file,npts); some_file.close(); // Output contact region on boulder - sprintf(filename,"%s/boulder_heat_flux%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/boulder_heat_flux%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Boulder_surface_heat_flux_mesh_pt->output(some_file,npts); @@ -4429,21 +4429,21 @@ void ContactProblem::doc_solution() // Output solution coarsely (only element vertices for easier // mesh visualisation) - sprintf(filename,"%s/boulder_coarse_soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/boulder_coarse_soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Boulder_mesh_pt->output(some_file,2); some_file.close(); // Output contact elements - sprintf(filename,"%s/imposed_displ%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/imposed_displ%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Displ_imposition_mesh_pt->output(some_file); some_file.close(); // Output contact elements - sprintf(filename,"%s/contact%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/contact%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); unsigned nel=Surface_contact_mesh_pt->nelement(); @@ -4457,7 +4457,7 @@ void ContactProblem::doc_solution() // Output integration points of contact elements - sprintf(filename,"%s/contact_integration_points%i.dat", + snprintf(filename, sizeof(filename), "%s/contact_integration_points%i.dat", Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); @@ -4482,7 +4482,7 @@ void ContactProblem::doc_solution() // Output penetrator - sprintf(filename,"%s/penetrator%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/penetrator%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); unsigned n=500; @@ -4492,7 +4492,7 @@ void ContactProblem::doc_solution() // Output contact elements and assemble total resulting force Vector total_contact_force(2,0.0); Vector contact_force(2,0.0); - sprintf(filename,"%s/contact%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/contact%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); nel=Surface_contact_mesh_pt->nelement(); @@ -4537,7 +4537,7 @@ void ContactProblem::doc_solution() } // Output Hertzian pressure contact distribution - sprintf(filename,"%s/hertz%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/hertz%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); n=500; diff --git a/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/linear_solid_contact_with_gravity.cc b/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/linear_solid_contact_with_gravity.cc index 48de60745bdf..22cc7f9ee6a7 100644 --- a/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/linear_solid_contact_with_gravity.cc +++ b/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/linear_solid_contact_with_gravity.cc @@ -965,7 +965,7 @@ class ContactProblem : public Problem // // Output contact elements // ofstream some_file; // char filename[100]; - // sprintf(filename,"contact_before.dat"); + // snprintf(filename, sizeof(filename), "contact_before.dat"); // some_file.open(filename); // unsigned nel=Surface_contact_mesh_pt->nelement(); // for (unsigned e=0;eoutput(some_file); some_file.close(); @@ -1031,7 +1031,7 @@ class ContactProblem : public Problem // Output impose displ elements ofstream some_file; char filename[100]; - sprintf(filename,"impose_after.dat"); + snprintf(filename, sizeof(filename), "impose_after.dat"); some_file.open(filename); Displ_imposition_mesh_pt->output(some_file); some_file.close(); @@ -2117,7 +2117,7 @@ void ContactProblem::doc_solution() npts=5; // Output solution - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); @@ -2125,21 +2125,21 @@ void ContactProblem::doc_solution() // Output solution coarsely (only element vertices for easier // mesh visualisation) - sprintf(filename,"%s/coarse_soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/coarse_soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,2); some_file.close(); // Output contact elements - sprintf(filename,"%s/imposed_displ%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/imposed_displ%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Displ_imposition_mesh_pt->output(some_file); some_file.close(); // Output contact elements - sprintf(filename,"%s/contact%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/contact%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); unsigned nel=Surface_contact_mesh_pt->nelement(); @@ -2153,7 +2153,7 @@ void ContactProblem::doc_solution() // Output integration points of contact elements - sprintf(filename,"%s/contact_integration_points%i.dat", + snprintf(filename, sizeof(filename), "%s/contact_integration_points%i.dat", Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); @@ -2177,7 +2177,7 @@ void ContactProblem::doc_solution() // Output penetrator - sprintf(filename,"%s/penetrator%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/penetrator%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); unsigned nplot=500; @@ -2187,7 +2187,7 @@ void ContactProblem::doc_solution() // Output contact elements and assemble total resulting force Vector total_contact_force(2,0.0); Vector contact_force(2,0.0); - sprintf(filename,"%s/contact%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/contact%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); nel=Surface_contact_mesh_pt->nelement(); @@ -2228,7 +2228,7 @@ void ContactProblem::doc_solution() } // Output Hertzian pressure contact distribution - sprintf(filename,"%s/hertz%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/hertz%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); unsigned n=500; diff --git a/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/melt.cc b/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/melt.cc index 025804a585c7..b50459a44947 100644 --- a/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/melt.cc +++ b/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/melt.cc @@ -623,7 +623,7 @@ void UnsteadyHeatMeltProblem::doc_solution() cout << "=================================================" << std::endl; // Output solution - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); @@ -631,14 +631,14 @@ void UnsteadyHeatMeltProblem::doc_solution() // Output solution coarsely (only element vertices for easier // mesh visualisation) - sprintf(filename,"%s/coarse_soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/coarse_soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,2); some_file.close(); // Output flux with melt - sprintf(filename,"%s/flux_with_melt%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/flux_with_melt%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); unsigned nel=Surface_melt_mesh_pt->nelement(); @@ -652,7 +652,7 @@ void UnsteadyHeatMeltProblem::doc_solution() // Output Number of Newton iterations in form that can be visualised // as vector in paraview - sprintf(filename,"%s/newton_iter%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/newton_iter%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); some_file << "0 0 0 " << Nnewton_iter_taken << std::endl; @@ -660,7 +660,7 @@ void UnsteadyHeatMeltProblem::doc_solution() // Output exact solution - sprintf(filename,"%s/exact_soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output_fct( @@ -669,7 +669,7 @@ void UnsteadyHeatMeltProblem::doc_solution() some_file.close(); // Output exact position of melting line - sprintf(filename,"%s/exact_height%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_height%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); unsigned nplot=100; diff --git a/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/pretend_melt.cc b/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/pretend_melt.cc index 92ce1b6e0b46..19938e4cf4d5 100644 --- a/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/pretend_melt.cc +++ b/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/pretend_melt.cc @@ -483,7 +483,7 @@ void UnsteadyHeatProblem::doc_solution(DocInfo& doc_info) // Output solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); @@ -491,14 +491,14 @@ void UnsteadyHeatProblem::doc_solution(DocInfo& doc_info) // Output solution coarsely (only element vertices for easier // mesh visualisation) - sprintf(filename,"%s/coarse_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/coarse_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,2); some_file.close(); // Output flux with melt - sprintf(filename,"%s/flux_with_melt%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/flux_with_melt%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); unsigned nnod=dynamic_cast*>( @@ -513,7 +513,7 @@ void UnsteadyHeatProblem::doc_solution(DocInfo& doc_info) // Output Number of Newton iterations in form that can be visualised // as vector in paraview - sprintf(filename,"%s/newton_iter%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/newton_iter%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); some_file << "0 0 0 " << Nnewton_iter_taken << std::endl; diff --git a/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/solid_contact.cc b/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/solid_contact.cc index 47291d69b856..f00a765ddcbb 100644 --- a/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/solid_contact.cc +++ b/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/solid_contact.cc @@ -146,7 +146,7 @@ class ContactProblem : public Problem // // Output contact elements // ofstream some_file; // char filename[100]; - // sprintf(filename,"contact_before.dat"); + // snprintf(filename, sizeof(filename), "contact_before.dat"); // some_file.open(filename); // unsigned nel=Surface_contact_mesh_pt->nelement(); // for (unsigned e=0;enelement(); // for (unsigned e=0;e::doc_solution() npts=5; // Output solution - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); @@ -559,7 +559,7 @@ void ContactProblem::doc_solution() // Output solution coarsely (only element vertices for easier // mesh visualisation) - sprintf(filename,"%s/coarse_soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/coarse_soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,2); @@ -567,7 +567,7 @@ void ContactProblem::doc_solution() // Output contact elements - sprintf(filename,"%s/contact%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/contact%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); unsigned nel=Surface_contact_mesh_pt->nelement(); @@ -580,7 +580,7 @@ void ContactProblem::doc_solution() // Output penetrator - sprintf(filename,"%s/penetrator%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/penetrator%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); unsigned nplot=500; diff --git a/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/solid_contact_with_gravity.cc b/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/solid_contact_with_gravity.cc index 12ec8179962d..d42244db6de5 100644 --- a/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/solid_contact_with_gravity.cc +++ b/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/solid_contact_with_gravity.cc @@ -738,7 +738,7 @@ class ContactProblem : public Problem // // Output contact elements // ofstream some_file; // char filename[100]; - // sprintf(filename,"contact_before.dat"); + // snprintf(filename, sizeof(filename), "contact_before.dat"); // some_file.open(filename); // unsigned nel=Surface_contact_mesh_pt->nelement(); // for (unsigned e=0;enelement(); // for (unsigned e=0;e::doc_solution() npts=5; // Output solution - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); @@ -1713,7 +1713,7 @@ void ContactProblem::doc_solution() // Output solution coarsely (only element vertices for easier // mesh visualisation) - sprintf(filename,"%s/coarse_soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/coarse_soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,2); @@ -1721,7 +1721,7 @@ void ContactProblem::doc_solution() // Output contact elements - sprintf(filename,"%s/contact%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/contact%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); unsigned nel=Surface_contact_mesh_pt->nelement(); @@ -1735,7 +1735,7 @@ void ContactProblem::doc_solution() // Output integration points of contact elements - sprintf(filename,"%s/contact_integration_points%i.dat", + snprintf(filename, sizeof(filename), "%s/contact_integration_points%i.dat", Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); @@ -1761,7 +1761,7 @@ void ContactProblem::doc_solution() // Output penetrator - sprintf(filename,"%s/penetrator%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/penetrator%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); unsigned nplot=500; @@ -1771,7 +1771,7 @@ void ContactProblem::doc_solution() // Output contact elements and assemble total resulting force Vector total_contact_force(2,0.0); Vector contact_force(2,0.0); - sprintf(filename,"%s/contact%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/contact%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); nel=Surface_contact_mesh_pt->nelement(); @@ -1803,7 +1803,7 @@ void ContactProblem::doc_solution() } // Output Hertzian pressure contact distribution - sprintf(filename,"%s/hertz%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/hertz%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); unsigned n=500; diff --git a/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/spring_contact.cc b/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/spring_contact.cc index 385264cba8ab..30870f43172c 100644 --- a/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/spring_contact.cc +++ b/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/spring_contact.cc @@ -304,7 +304,7 @@ int main(int argc, char **argv) << std::endl << std::endl; char name[100]; - sprintf(name,"landscape%i.dat",j); + snprintf(name, sizeof(name), "landscape%i.dat",j); std::string filename(name); GlobalFct::plot_it(filename); try @@ -316,7 +316,7 @@ int main(int argc, char **argv) << BlackBoxFDNewtonSolver::N_iter_taken++ << std::endl; char name[100]; - sprintf(name,"soln%i.dat",j); + snprintf(name, sizeof(name), "soln%i.dat",j); ofstream outfile; outfile.open(name); outfile << unknowns[0] << " " diff --git a/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/spring_contact2.cc b/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/spring_contact2.cc index 63e34fec503b..8814c0ddebee 100644 --- a/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/spring_contact2.cc +++ b/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/spring_contact2.cc @@ -175,7 +175,7 @@ int main(int argc, char **argv) << std::endl << std::endl; char name[100]; - sprintf(name,"landscape%i.dat",j); + snprintf(name, sizeof(name), "landscape%i.dat",j); std::string filename(name); GlobalFct::plot_it(filename); try @@ -189,7 +189,7 @@ int main(int argc, char **argv) << BlackBoxFDNewtonSolver::N_iter_taken++ << std::endl; char name[100]; - sprintf(name,"soln%i.dat",j); + snprintf(name, sizeof(name), "soln%i.dat",j); ofstream outfile; outfile.open(name); outfile << unknowns[0] << " " diff --git a/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/stefan_boltzmann.cc b/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/stefan_boltzmann.cc index 3844414f4538..ac8029075fa1 100644 --- a/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/stefan_boltzmann.cc +++ b/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/stefan_boltzmann.cc @@ -670,7 +670,7 @@ void StefanBoltzmannProblem::doc_solution(DocInfo& doc_info) // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); @@ -679,7 +679,7 @@ void StefanBoltzmannProblem::doc_solution(DocInfo& doc_info) // Output solution //----------------- - sprintf(filename,"%s/coarse_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/coarse_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); unsigned npts_coarse=2; some_file.open(filename); @@ -688,7 +688,7 @@ void StefanBoltzmannProblem::doc_solution(DocInfo& doc_info) // Output Stefan Boltzmann radiation (best suited for tecplot) //------------------------------------------------------------ - sprintf(filename,"%s/stefan_boltzmann_radiation%i.dat", + snprintf(filename, sizeof(filename), "%s/stefan_boltzmann_radiation%i.dat", doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); @@ -711,7 +711,7 @@ if (output_rays) unsigned nel=Unsteady_heat_flux_mesh_pt->nelement(); for (unsigned e=0;eoutput_fct(some_file,npts,time_pt()->time(), @@ -753,7 +753,7 @@ some_file.close(); // Doc error //---------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->compute_error(some_file, diff --git a/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/stefan_boltzmann_melt.cc b/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/stefan_boltzmann_melt.cc index a223b8ab948f..944a4e6df70d 100644 --- a/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/stefan_boltzmann_melt.cc +++ b/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/stefan_boltzmann_melt.cc @@ -1358,14 +1358,14 @@ void StefanBoltzmannProblem::setup_sb_radiation() oomph_info << "Docing bins for step " << Doc_info.number() << std::endl; - sprintf(filename,"%s/populated_bins%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/populated_bins%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); StefanBoltzmannHelper::doc_bins(some_file); some_file.close(); // Doc the sample points used to assess visibility - sprintf(filename,"%s/sample_points%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/sample_points%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); StefanBoltzmannHelper::doc_sample_points(some_file, @@ -1396,7 +1396,7 @@ void StefanBoltzmannProblem::doc_solution() // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); @@ -1405,7 +1405,7 @@ void StefanBoltzmannProblem::doc_solution() // Output solution //----------------- - sprintf(filename,"%s/coarse_soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/coarse_soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); unsigned npts_coarse=2; some_file.open(filename); @@ -1419,7 +1419,7 @@ void StefanBoltzmannProblem::doc_solution() //---------------------------------------------------- // Output rays - sprintf(filename,"%s/stefan_boltzmann_rays_left%i.dat", + snprintf(filename, sizeof(filename), "%s/stefan_boltzmann_rays_left%i.dat", Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); @@ -1429,7 +1429,7 @@ void StefanBoltzmannProblem::doc_solution() // Output rays - sprintf(filename,"%s/stefan_boltzmann_rays_right%i.dat", + snprintf(filename, sizeof(filename), "%s/stefan_boltzmann_rays_right%i.dat", Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); @@ -1441,7 +1441,7 @@ void StefanBoltzmannProblem::doc_solution() // Output exact outer radius //-------------------------- double r=GlobalParameters::radius(time_pt()->time()); - sprintf(filename,"%s/exact_melt_surface%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_melt_surface%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); unsigned np=300; @@ -1455,7 +1455,7 @@ void StefanBoltzmannProblem::doc_solution() // Output heat flux (x,y,u,flux,n_x,n_y) //-------------------------------------- -sprintf(filename,"%s/flux%i.dat", +snprintf(filename, sizeof(filename), "%s/flux%i.dat", Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); @@ -1481,7 +1481,7 @@ double inc_inner_exact= Vector s(1); Vector x(2); Vector unit_normal(2); - sprintf(filename,"%s/sb_radiation%i.dat", + snprintf(filename, sizeof(filename), "%s/sb_radiation%i.dat", Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); @@ -1591,7 +1591,7 @@ double melt_exact=GlobalParameters::melt_flux(time_pt()->time()); double average_melt=0.0; unsigned count=0; Vector s(1); - sprintf(filename,"%s/melt%i.dat", + snprintf(filename, sizeof(filename), "%s/melt%i.dat", Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); @@ -1676,7 +1676,7 @@ Trace_file << time_pt()->time() << " " // Output exact solution //---------------------- -sprintf(filename,"%s/exact_soln%i.dat",Doc_info.directory().c_str(), +snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output_fct(some_file,npts,time_pt()->time(), @@ -1686,7 +1686,7 @@ some_file.close(); // Doc error //---------- double error,norm; -sprintf(filename,"%s/error%i.dat",Doc_info.directory().c_str(), +snprintf(filename, sizeof(filename), "%s/error%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Bulk_mesh_pt->compute_error(some_file, diff --git a/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/temporary_stefan_boltzmann_elements.h b/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/temporary_stefan_boltzmann_elements.h index 6eee4325350b..e8e786f20fda 100644 --- a/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/temporary_stefan_boltzmann_elements.h +++ b/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/temporary_stefan_boltzmann_elements.h @@ -2642,7 +2642,7 @@ namespace StefanBoltzmannHelper { if (plot_it) { - sprintf(filename,"RESLT/latest_ray.dat"); + snprintf(filename, sizeof(filename), "RESLT/latest_ray.dat"); some_file.open(filename); } diff --git a/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/two_d_unsteady_heat.cc b/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/two_d_unsteady_heat.cc index f2f99e24cbf4..01c274138ea1 100644 --- a/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/two_d_unsteady_heat.cc +++ b/demo_drivers/heat_transfer_and_melting/two_d_unsteady_heat_melt/two_d_unsteady_heat.cc @@ -421,7 +421,7 @@ doc_solution(DocInfo& doc_info,ofstream& trace_file) // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); @@ -441,7 +441,7 @@ doc_solution(DocInfo& doc_info,ofstream& trace_file) // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output_fct(some_file,npts,time_pt()->time(), @@ -451,7 +451,7 @@ doc_solution(DocInfo& doc_info,ofstream& trace_file) // Doc error //---------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->compute_error(some_file, @@ -509,7 +509,7 @@ int main() // Open a trace file ofstream trace_file; char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); trace_file.open(filename); trace_file << "VARIABLES=\"time\",\"uFE\"," << "\"uexact\",\"norm of error\",\"norm of solution\"" diff --git a/demo_drivers/helmholtz/point_source/helmholtz_point_source.cc b/demo_drivers/helmholtz/point_source/helmholtz_point_source.cc index 9b835ac531d9..2a78303ddc23 100644 --- a/demo_drivers/helmholtz/point_source/helmholtz_point_source.cc +++ b/demo_drivers/helmholtz/point_source/helmholtz_point_source.cc @@ -595,7 +595,7 @@ void HelmholtzPointSourceProblem::doc_solution(DocInfo& // Compute/output the radiated power //---------------------------------- - sprintf(filename,"%s/power%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/power%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); @@ -613,7 +613,7 @@ void HelmholtzPointSourceProblem::doc_solution(DocInfo& // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); @@ -621,7 +621,7 @@ void HelmholtzPointSourceProblem::doc_solution(DocInfo& // Output solution in Paraview //--------------------------- - sprintf(filename,"%s/soln%i.vtu",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.vtu",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output_paraview(some_file,npts); diff --git a/demo_drivers/helmholtz/scattering/scattering.cc b/demo_drivers/helmholtz/scattering/scattering.cc index 54204620af97..a06bcab0b389 100644 --- a/demo_drivers/helmholtz/scattering/scattering.cc +++ b/demo_drivers/helmholtz/scattering/scattering.cc @@ -526,7 +526,7 @@ void ScatteringProblem::doc_solution(DocInfo& // Compute/output the radiated power //---------------------------------- - sprintf(filename,"%s/power%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/power%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); @@ -545,7 +545,7 @@ void ScatteringProblem::doc_solution(DocInfo& // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); @@ -553,14 +553,14 @@ void ScatteringProblem::doc_solution(DocInfo& // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output_fct(some_file,npts,GlobalParameters::get_exact_u); some_file.close(); double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->compute_error(some_file,GlobalParameters::get_exact_u, @@ -577,11 +577,11 @@ void ScatteringProblem::doc_solution(DocInfo& unsigned nstep=40; for (unsigned i=0;i::doc_solution(DocInfo& // Compute/output the radiated power //---------------------------------- - sprintf(filename,"%s/power%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/power%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); @@ -643,7 +643,7 @@ void ScatteringProblem::doc_solution(DocInfo& // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); @@ -651,14 +651,14 @@ void ScatteringProblem::doc_solution(DocInfo& // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output_fct(some_file,npts,GlobalParameters::get_exact_u); some_file.close(); double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->compute_error(some_file,GlobalParameters::get_exact_u, @@ -678,11 +678,11 @@ void ScatteringProblem::doc_solution(DocInfo& unsigned nstep=40; for (unsigned i=0;i::CoatedDiskProblem() // Open trace file char filename[100]; - sprintf(filename,"%s/trace.dat",Doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",Doc_info.directory().c_str()); Trace_file.open(filename); @@ -737,7 +737,7 @@ void CoatedDiskProblem::doc_solution() // Compute/output the radiated power //---------------------------------- - sprintf(filename,"%s/power%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/power%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); @@ -786,7 +786,7 @@ void CoatedDiskProblem::doc_solution() // Output displacement field //-------------------------- - sprintf(filename,"%s/elast_soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/elast_soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Solid_mesh_pt->output(some_file,n_plot); @@ -795,7 +795,7 @@ void CoatedDiskProblem::doc_solution() // Output fsi traction elements //----------------------------- - sprintf(filename,"%s/traction_soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/traction_soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); FSI_traction_mesh_pt->output(some_file,n_plot); @@ -804,7 +804,7 @@ void CoatedDiskProblem::doc_solution() // Output Helmholtz fsi flux elements //----------------------------------- - sprintf(filename,"%s/flux_bc_soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/flux_bc_soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Helmholtz_fsi_flux_mesh_pt->output(some_file,n_plot); @@ -813,7 +813,7 @@ void CoatedDiskProblem::doc_solution() // Output Helmholtz //----------------- - sprintf(filename,"%s/helmholtz_soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/helmholtz_soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Helmholtz_mesh_pt->output(some_file,n_plot); @@ -823,7 +823,7 @@ void CoatedDiskProblem::doc_solution() // Output exact solution for Helmholtz //------------------------------------ - sprintf(filename,"%s/exact_helmholtz_soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_helmholtz_soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Helmholtz_mesh_pt->output_fct(some_file,n_plot, diff --git a/demo_drivers/interaction/acoustic_fsi/unstructured_acoustic_fsi.cc b/demo_drivers/interaction/acoustic_fsi/unstructured_acoustic_fsi.cc index add53f049df8..cfb0c573229a 100644 --- a/demo_drivers/interaction/acoustic_fsi/unstructured_acoustic_fsi.cc +++ b/demo_drivers/interaction/acoustic_fsi/unstructured_acoustic_fsi.cc @@ -693,7 +693,7 @@ CoatedDiskProblem::CoatedDiskProblem() // Open trace file char filename[100]; - sprintf(filename,"%s/trace.dat",Doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",Doc_info.directory().c_str()); Trace_file.open(filename); @@ -1107,7 +1107,7 @@ void CoatedDiskProblem::doc_solution() // Compute/output the radiated power //---------------------------------- - sprintf(filename,"%s/power%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/power%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); @@ -1161,7 +1161,7 @@ void CoatedDiskProblem::doc_solution() // Output displacement field //-------------------------- - sprintf(filename,"%s/elast_soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/elast_soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Solid_mesh_pt->output(some_file,n_plot); @@ -1169,7 +1169,7 @@ void CoatedDiskProblem::doc_solution() // Output solid traction elements //-------------------------------- - sprintf(filename,"%s/solid_traction_soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/solid_traction_soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Solid_traction_mesh_pt->output(some_file,n_plot); @@ -1177,7 +1177,7 @@ void CoatedDiskProblem::doc_solution() // Output fsi traction elements //----------------------------- - sprintf(filename,"%s/traction_soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/traction_soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); FSI_traction_mesh_pt->output(some_file,n_plot); @@ -1186,7 +1186,7 @@ void CoatedDiskProblem::doc_solution() // Output Helmholtz fsi flux elements //----------------------------------- - sprintf(filename,"%s/flux_bc_soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/flux_bc_soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Helmholtz_fsi_flux_mesh_pt->output(some_file,n_plot); @@ -1195,7 +1195,7 @@ void CoatedDiskProblem::doc_solution() // Output Helmholtz //----------------- - sprintf(filename,"%s/helmholtz_soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/helmholtz_soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Helmholtz_mesh_pt->output(some_file,n_plot); @@ -1207,7 +1207,7 @@ void CoatedDiskProblem::doc_solution() unsigned nreg=Solid_mesh_pt->nregion(); for (unsigned r=0;rnregion_element(r); @@ -1225,7 +1225,7 @@ void CoatedDiskProblem::doc_solution() unsigned nstep=40; for (unsigned i=0;i::doc_solution(DocInfo& doc_info) // Output solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); unsigned n_bulk=Bulk_mesh_pt->nbulk(); @@ -2149,7 +2149,7 @@ void AirwayReopeningProblem::parameter_study(const unsigned& nsteps, // Open trace file char filename[100], dumpfile[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); Trace_file.open(filename); Trace_file << "VARIABLES=\"Ca\","; @@ -2207,7 +2207,7 @@ void AirwayReopeningProblem::parameter_study(const unsigned& nsteps, if(step > 1) { using namespace Global_Physical_Variables; - sprintf(dumpfile, + snprintf(dumpfile, sizeof(dumpfile), "%s/dump.Ca_%g.Bo_%g.Re_%g.H_%g.TW_%g_Frac_%g.Kstiff_%g.dat", doc_info.directory().c_str(), Ca,Bo,Re,H,Tube_width, diff --git a/demo_drivers/interaction/fourier_decomposed_acoustic_fsi/fourier_decomposed_acoustic_fsi.cc b/demo_drivers/interaction/fourier_decomposed_acoustic_fsi/fourier_decomposed_acoustic_fsi.cc index 28e1c7e4a0d1..d1f8f47ba30e 100644 --- a/demo_drivers/interaction/fourier_decomposed_acoustic_fsi/fourier_decomposed_acoustic_fsi.cc +++ b/demo_drivers/interaction/fourier_decomposed_acoustic_fsi/fourier_decomposed_acoustic_fsi.cc @@ -404,7 +404,7 @@ CoatedSphereProblem() // Open trace file char filename[100]; - sprintf(filename,"%s/trace.dat",Global_Parameters::Directory.c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",Global_Parameters::Directory.c_str()); Trace_file.open(filename); // Setup equation numbering scheme @@ -615,7 +615,7 @@ doc_solution(DocInfo& doc_info) // Compute/output the radiated power //---------------------------------- - sprintf(filename,"%s/power%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/power%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); @@ -634,7 +634,7 @@ doc_solution(DocInfo& doc_info) // Output displacement field //-------------------------- - sprintf(filename,"%s/elast_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/elast_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Solid_mesh_pt->output(some_file,n_plot); @@ -642,7 +642,7 @@ doc_solution(DocInfo& doc_info) // Output Helmholtz //----------------- - sprintf(filename,"%s/helmholtz_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/helmholtz_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Helmholtz_mesh_pt->output(some_file,n_plot); @@ -651,7 +651,7 @@ doc_solution(DocInfo& doc_info) // Output fsi traction elements //----------------------------- - sprintf(filename,"%s/fsi_traction_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/fsi_traction_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); FSI_traction_mesh_pt->output(some_file,n_plot); @@ -660,7 +660,7 @@ doc_solution(DocInfo& doc_info) // Output Helmholtz fsi flux elements //----------------------------------- - sprintf(filename,"%s/fsi_flux_bc_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/fsi_flux_bc_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Helmholtz_fsi_flux_mesh_pt->output(some_file,n_plot); diff --git a/demo_drivers/interaction/fourier_decomposed_acoustic_fsi/unstructured_fourier_decomposed_acoustic_fsi.cc b/demo_drivers/interaction/fourier_decomposed_acoustic_fsi/unstructured_fourier_decomposed_acoustic_fsi.cc index eeb472969538..c17f9092f7e5 100644 --- a/demo_drivers/interaction/fourier_decomposed_acoustic_fsi/unstructured_fourier_decomposed_acoustic_fsi.cc +++ b/demo_drivers/interaction/fourier_decomposed_acoustic_fsi/unstructured_fourier_decomposed_acoustic_fsi.cc @@ -800,7 +800,7 @@ CoatedSphereProblem() // Open trace file char filename[100]; - sprintf(filename,"%s/trace.dat",Global_Parameters::Directory.c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",Global_Parameters::Directory.c_str()); Trace_file.open(filename); // Setup equation numbering scheme @@ -1276,7 +1276,7 @@ doc_solution(DocInfo& doc_info) // Compute/output the radiated power //---------------------------------- - sprintf(filename,"%s/power%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/power%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); @@ -1295,7 +1295,7 @@ doc_solution(DocInfo& doc_info) // Output displacement field //-------------------------- - sprintf(filename,"%s/elast_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/elast_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Solid_mesh_pt->output(some_file,n_plot); @@ -1303,7 +1303,7 @@ doc_solution(DocInfo& doc_info) // Output Helmholtz //----------------- - sprintf(filename,"%s/helmholtz_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/helmholtz_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Helmholtz_mesh_pt->output(some_file,n_plot); @@ -1312,7 +1312,7 @@ doc_solution(DocInfo& doc_info) // Output fsi traction elements //----------------------------- - sprintf(filename,"%s/fsi_traction_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/fsi_traction_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); FSI_traction_mesh_pt->output(some_file,n_plot); @@ -1321,7 +1321,7 @@ doc_solution(DocInfo& doc_info) // Output Helmholtz fsi flux elements //----------------------------------- - sprintf(filename,"%s/fsi_flux_bc_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/fsi_flux_bc_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Helmholtz_fsi_flux_mesh_pt->output(some_file,n_plot); diff --git a/demo_drivers/interaction/free_boundary_poisson/algebraic_free_boundary_poisson.cc b/demo_drivers/interaction/free_boundary_poisson/algebraic_free_boundary_poisson.cc index 0d174f478dcb..254b36edabb5 100644 --- a/demo_drivers/interaction/free_boundary_poisson/algebraic_free_boundary_poisson.cc +++ b/demo_drivers/interaction/free_boundary_poisson/algebraic_free_boundary_poisson.cc @@ -251,7 +251,7 @@ RefineableFishPoissonProblem::RefineableFishPoissonProblem( // Open trace file char filename[100]; - sprintf(filename,"%s/trace.dat",directory_name.c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",directory_name.c_str()); Trace_file.open(filename); Trace_file @@ -415,12 +415,12 @@ void RefineableFishPoissonProblem::doc_solution() // Output solution if (Case_id!=0) { - sprintf(filename,"%s/soln_%i_%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln_%i_%i.dat",Doc_info.directory().c_str(), Case_id,Doc_info.number()); } else { - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); } some_file.open(filename); diff --git a/demo_drivers/interaction/free_boundary_poisson/doc_sparse_macro_node_update.cc b/demo_drivers/interaction/free_boundary_poisson/doc_sparse_macro_node_update.cc index 89925d5e20d6..746870d704f3 100644 --- a/demo_drivers/interaction/free_boundary_poisson/doc_sparse_macro_node_update.cc +++ b/demo_drivers/interaction/free_boundary_poisson/doc_sparse_macro_node_update.cc @@ -75,7 +75,7 @@ int main() // Output initial mesh unsigned count=0; - sprintf(filename,"RESLT/soln%i.dat",count); + snprintf(filename, sizeof(filename), "RESLT/soln%i.dat",count); some_file.open(filename); Fish_mesh_pt->output(some_file,npts); some_file.close(); @@ -96,7 +96,7 @@ int main() Fish_mesh_pt->node_pt(i)->node_update(); // Doc mesh - sprintf(filename,"RESLT/soln%i.dat",count); + snprintf(filename, sizeof(filename), "RESLT/soln%i.dat",count); some_file.open(filename); Fish_mesh_pt->output(some_file,npts); some_file.close(); diff --git a/demo_drivers/interaction/free_boundary_poisson/elastic_mesh_update.cc b/demo_drivers/interaction/free_boundary_poisson/elastic_mesh_update.cc index 6b281ddce379..56cfa3991b5a 100644 --- a/demo_drivers/interaction/free_boundary_poisson/elastic_mesh_update.cc +++ b/demo_drivers/interaction/free_boundary_poisson/elastic_mesh_update.cc @@ -394,7 +394,7 @@ void DeformableFishPoissonProblem::doc_solution(DocInfo& doc_info) unsigned npts = 5; // Call output function for all elements - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -428,7 +428,7 @@ void DeformableFishPoissonProblem::run() // Open trace file char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); Trace_file.open(filename); Trace_file << "VARIABLES=\"ycircle\",\"ucontrol\"" diff --git a/demo_drivers/interaction/free_boundary_poisson/elastic_poisson.cc b/demo_drivers/interaction/free_boundary_poisson/elastic_poisson.cc index c904f087d52f..28417f904182 100644 --- a/demo_drivers/interaction/free_boundary_poisson/elastic_poisson.cc +++ b/demo_drivers/interaction/free_boundary_poisson/elastic_poisson.cc @@ -397,7 +397,7 @@ void DeformableFishPoissonProblem::doc_solution(DocInfo& doc_info) unsigned npts = 5; // Call output function for all elements - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -431,7 +431,7 @@ void DeformableFishPoissonProblem::run() // Open trace file char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); Trace_file.open(filename); Trace_file << "VARIABLES=\"ycircle\",\"ucontrol\"" diff --git a/demo_drivers/interaction/free_boundary_poisson/geom_object_element.cc b/demo_drivers/interaction/free_boundary_poisson/geom_object_element.cc index 88fea46919a6..b1f1e35fe9a4 100644 --- a/demo_drivers/interaction/free_boundary_poisson/geom_object_element.cc +++ b/demo_drivers/interaction/free_boundary_poisson/geom_object_element.cc @@ -136,7 +136,7 @@ GeomObjectAsGeneralisedElementProblem::GeomObjectAsGeneralisedElementProblem() // Open trace file char filename[100]; - sprintf(filename,"%s/trace.dat",Doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",Doc_info.directory().c_str()); Trace_file.open(filename); Trace_file << "VARIABLES=\"load\",\"ycircle\"" << std::endl; @@ -162,7 +162,7 @@ void GeomObjectAsGeneralisedElementProblem::doc_solution() Vector r(2); // Output solution - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); for (unsigned i=0;i::RefineableFishPoissonProblem( // Open trace file char filename[100]; - sprintf(filename,"%s/trace.dat",directory_name.c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",directory_name.c_str()); Trace_file.open(filename); Trace_file << "VARIABLES=\"load\",\"ycircle\",\"ucontrol\"" @@ -347,7 +347,7 @@ void RefineableFishPoissonProblem::doc_solution() // Output solution - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); fish_mesh_pt()->output(some_file,npts); diff --git a/demo_drivers/interaction/fsi_channel_seg_and_precond/fsi_chan_problem.h b/demo_drivers/interaction/fsi_channel_seg_and_precond/fsi_chan_problem.h index d518dbd091ce..95268041f3e4 100644 --- a/demo_drivers/interaction/fsi_channel_seg_and_precond/fsi_chan_problem.h +++ b/demo_drivers/interaction/fsi_channel_seg_and_precond/fsi_chan_problem.h @@ -864,21 +864,21 @@ doc_solution_steady( npts=5; // Output fluid solution - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); bulk_mesh_pt()->output(some_file,npts); some_file.close(); // Document the wall shape - sprintf(filename,"%s/beam%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/beam%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); wall_mesh_pt()->output(some_file,npts); some_file.close(); // Write restart file - sprintf(filename,"%s/restart%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/restart%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); some_file.precision(16); @@ -926,21 +926,21 @@ doc_solution_unsteady( npts=5; // Output fluid solution - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); bulk_mesh_pt()->output(some_file,npts); some_file.close(); // Document the wall shape - sprintf(filename,"%s/beam%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/beam%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); wall_mesh_pt()->output(some_file,npts); some_file.close(); // Write restart file - sprintf(filename,"%s/restart%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/restart%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); dump_it(some_file); @@ -1174,7 +1174,7 @@ void FSICollapsibleChannelProblem::steady_run() // Open a trace file ofstream trace_file; char filename[100]; - sprintf(filename,"%s/trace.dat",Doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",Doc_info.directory().c_str()); trace_file.open(filename); // Write trace file header @@ -1309,7 +1309,7 @@ void FSICollapsibleChannelProblem::unsteady_run(const double& dt) // Open a trace file ofstream trace_file; char filename[100]; - sprintf(filename,"%s/trace.dat",Doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",Doc_info.directory().c_str()); trace_file.open(filename); diff --git a/demo_drivers/interaction/fsi_channel_seg_and_precond/fsi_chan_seg_driver.cc b/demo_drivers/interaction/fsi_channel_seg_and_precond/fsi_chan_seg_driver.cc index 235cd18ab058..110cd4344dd6 100644 --- a/demo_drivers/interaction/fsi_channel_seg_and_precond/fsi_chan_seg_driver.cc +++ b/demo_drivers/interaction/fsi_channel_seg_and_precond/fsi_chan_seg_driver.cc @@ -782,21 +782,21 @@ void SegregatedFSICollapsibleChannelProblem:: doc_solution_steady( npts=5; // Output fluid solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); this->bulk_mesh_pt()->output(some_file,npts); some_file.close(); // Document the wall shape - sprintf(filename,"%s/beam%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/beam%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); this->wall_mesh_pt()->output(some_file,npts); some_file.close(); // Write restart file - sprintf(filename,"%s/restart%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/restart%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); some_file.precision(16); @@ -863,21 +863,21 @@ void SegregatedFSICollapsibleChannelProblem::doc_solution_unsteady( npts=5; // Output fluid solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); this->bulk_mesh_pt()->output(some_file,npts); some_file.close(); // Document the wall shape - sprintf(filename,"%s/beam%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/beam%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); this->wall_mesh_pt()->output(some_file,npts); some_file.close(); // Write restart file - sprintf(filename,"%s/restart%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/restart%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); this->dump_it(some_file); @@ -946,7 +946,7 @@ void SegregatedFSICollapsibleChannelProblem::steady_run() // Open a trace file ofstream trace_file; char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); trace_file.open(filename); @@ -1067,7 +1067,7 @@ void SegregatedFSICollapsibleChannelProblem::steady_run() halt_timer(); char filename[100]; - sprintf(filename,"%s/picard_convergence%i.dat", + snprintf(filename, sizeof(filename), "%s/picard_convergence%i.dat", doc_info.directory().c_str(), doc_info.number()); Convergence_file.open(filename); @@ -1124,7 +1124,7 @@ void SegregatedFSICollapsibleChannelProblem::steady_run() store_solid_dofs(); char filename[100]; - sprintf(filename,"%s/newton_convergence%i.dat", + snprintf(filename, sizeof(filename), "%s/newton_convergence%i.dat", doc_info.directory().c_str(), doc_info.number()); Convergence_file.open(filename); @@ -1225,7 +1225,7 @@ void SegregatedFSICollapsibleChannelProblem::unsteady_run( // Open a trace file ofstream trace_file; char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); trace_file.open(filename); @@ -1318,7 +1318,7 @@ void SegregatedFSICollapsibleChannelProblem::unsteady_run( //store_solid_dofs(); char filename[100]; - sprintf(filename,"%s/picard_convergence%i.dat", + snprintf(filename, sizeof(filename), "%s/picard_convergence%i.dat", doc_info.directory().c_str(), doc_info.number()); Convergence_file.open(filename); @@ -1372,7 +1372,7 @@ void SegregatedFSICollapsibleChannelProblem::unsteady_run( store_solid_dofs(); char filename[100]; - sprintf(filename,"%s/newton_convergence%i.dat", + snprintf(filename, sizeof(filename), "%s/newton_convergence%i.dat", doc_info.directory().c_str(), doc_info.number()); Convergence_file.open(filename); diff --git a/demo_drivers/interaction/fsi_channel_seg_and_precond/simple_segregated_driver.cc b/demo_drivers/interaction/fsi_channel_seg_and_precond/simple_segregated_driver.cc index 77f94d9484fe..123aaa9a5280 100644 --- a/demo_drivers/interaction/fsi_channel_seg_and_precond/simple_segregated_driver.cc +++ b/demo_drivers/interaction/fsi_channel_seg_and_precond/simple_segregated_driver.cc @@ -334,14 +334,14 @@ void SegregatedFSICollapsibleChannelProblem:: doc_solution( unsigned npts=5; // Output fluid solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); this->bulk_mesh_pt()->output(some_file,npts); some_file.close(); // Document the wall shape - sprintf(filename,"%s/beam%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/beam%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); this->wall_mesh_pt()->output(some_file,npts); diff --git a/demo_drivers/interaction/fsi_channel_with_leaflet/fsi_channel_with_leaflet.cc b/demo_drivers/interaction/fsi_channel_with_leaflet/fsi_channel_with_leaflet.cc index 47daa28be9b3..58562e17aa17 100644 --- a/demo_drivers/interaction/fsi_channel_with_leaflet/fsi_channel_with_leaflet.cc +++ b/demo_drivers/interaction/fsi_channel_with_leaflet/fsi_channel_with_leaflet.cc @@ -641,14 +641,14 @@ void FSIChannelWithLeafletProblem::doc_solution(DocInfo& doc_info, npts=5; // Output fluid solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Fluid_mesh_pt->output(some_file,npts); some_file.close(); // Output wall solution - sprintf(filename,"%s/wall_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/wall_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Wall_mesh_pt->output(some_file,npts); @@ -678,7 +678,7 @@ void FSIChannelWithLeafletProblem::doc_solution(DocInfo& doc_info, // Output fluid elements on fluid mesh boundary 4 (associated with // the "front") unsigned bound=4; - sprintf(filename,"%s/fluid_boundary_elements_front_%i.dat", + snprintf(filename, sizeof(filename), "%s/fluid_boundary_elements_front_%i.dat", doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); @@ -694,7 +694,7 @@ void FSIChannelWithLeafletProblem::doc_solution(DocInfo& doc_info, // Output fluid elements on fluid mesh boundary 5 (associated with // the "back") bound=5; - sprintf(filename,"%s/fluid_boundary_elements_back_%i.dat", + snprintf(filename, sizeof(filename), "%s/fluid_boundary_elements_back_%i.dat", doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); @@ -708,7 +708,7 @@ void FSIChannelWithLeafletProblem::doc_solution(DocInfo& doc_info, // Output normal vector on wall elements - sprintf(filename,"%s/wall_normal_%i.dat", + snprintf(filename, sizeof(filename), "%s/wall_normal_%i.dat", doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); @@ -787,7 +787,7 @@ int main(int argc, char* argv[]) // Trace file ofstream trace; char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); trace.open(filename); diff --git a/demo_drivers/interaction/fsi_collapsible_channel/fsi_collapsible_channel.cc b/demo_drivers/interaction/fsi_collapsible_channel/fsi_collapsible_channel.cc index 390b53cbe711..8ff7e592412a 100644 --- a/demo_drivers/interaction/fsi_collapsible_channel/fsi_collapsible_channel.cc +++ b/demo_drivers/interaction/fsi_collapsible_channel/fsi_collapsible_channel.cc @@ -696,14 +696,14 @@ void FSICollapsibleChannelProblem:: doc_solution(DocInfo& doc_info, npts=5; // Output fluid solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); bulk_mesh_pt()->output(some_file,npts); some_file.close(); // Document the wall shape - sprintf(filename,"%s/beam%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/beam%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); wall_mesh_pt()->output(some_file,npts); @@ -905,7 +905,7 @@ int main(int argc, char* argv[]) // Open a trace file ofstream trace_file; char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); trace_file.open(filename); // Output the initial solution diff --git a/demo_drivers/interaction/fsi_collapsible_channel/fsi_collapsible_channel_adapt.cc b/demo_drivers/interaction/fsi_collapsible_channel/fsi_collapsible_channel_adapt.cc index f79784d71751..14e5684e0162 100644 --- a/demo_drivers/interaction/fsi_collapsible_channel/fsi_collapsible_channel_adapt.cc +++ b/demo_drivers/interaction/fsi_collapsible_channel/fsi_collapsible_channel_adapt.cc @@ -723,14 +723,14 @@ void FSICollapsibleChannelProblem:: doc_solution(DocInfo& doc_info, npts=5; // Output fluid solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); bulk_mesh_pt()->output(some_file,npts); some_file.close(); // Document the wall shape - sprintf(filename,"%s/beam%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/beam%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); wall_mesh_pt()->output(some_file,npts); @@ -742,7 +742,7 @@ void FSICollapsibleChannelProblem:: doc_solution(DocInfo& doc_info, unsigned nsteps=time_stepper_pt(1)->nprev_values(); for (unsigned t=0;t<=nsteps;t++) { - sprintf(filename,"%s/wall%i-%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/wall%i-%i.dat",doc_info.directory().c_str(), doc_info.number(),t); some_file.open(filename); unsigned n_elem=wall_mesh_pt()->nelement(); @@ -1068,7 +1068,7 @@ int main(int argc, char* argv[]) // Open a trace file ofstream trace_file; char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); trace_file.open(filename); // Output the initial condition diff --git a/demo_drivers/interaction/fsi_collapsible_channel/fsi_pseudo_solid_collapsible_channel.cc b/demo_drivers/interaction/fsi_collapsible_channel/fsi_pseudo_solid_collapsible_channel.cc index caa742ea290c..452ea752d595 100644 --- a/demo_drivers/interaction/fsi_collapsible_channel/fsi_pseudo_solid_collapsible_channel.cc +++ b/demo_drivers/interaction/fsi_collapsible_channel/fsi_pseudo_solid_collapsible_channel.cc @@ -765,14 +765,14 @@ void FSICollapsibleChannelProblem:: doc_solution(DocInfo& doc_info, npts=5; // Output fluid solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); bulk_mesh_pt()->output(some_file,npts); some_file.close(); // Document the wall shape - sprintf(filename,"%s/beam%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/beam%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); wall_mesh_pt()->output(some_file,npts); @@ -784,7 +784,7 @@ void FSICollapsibleChannelProblem:: doc_solution(DocInfo& doc_info, unsigned nsteps=time_stepper_pt(1)->nprev_values(); for (unsigned t=0;t<=nsteps;t++) { - sprintf(filename,"%s/wall%i-%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/wall%i-%i.dat",doc_info.directory().c_str(), doc_info.number(),t); some_file.open(filename); unsigned n_elem=wall_mesh_pt()->nelement(); @@ -1093,7 +1093,7 @@ int main(int argc, char* argv[]) // Open a trace file ofstream trace_file; char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); trace_file.open(filename); // Output the initial condition diff --git a/demo_drivers/interaction/fsi_collapsible_channel/fsi_pseudo_solid_collapsible_channel_adapt.cc b/demo_drivers/interaction/fsi_collapsible_channel/fsi_pseudo_solid_collapsible_channel_adapt.cc index dc63095bcd17..7817c90b3bce 100644 --- a/demo_drivers/interaction/fsi_collapsible_channel/fsi_pseudo_solid_collapsible_channel_adapt.cc +++ b/demo_drivers/interaction/fsi_collapsible_channel/fsi_pseudo_solid_collapsible_channel_adapt.cc @@ -792,14 +792,14 @@ void FSICollapsibleChannelProblem:: doc_solution(DocInfo& doc_info, npts=5; // Output fluid solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); bulk_mesh_pt()->output(some_file,npts); some_file.close(); // Document the wall shape - sprintf(filename,"%s/beam%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/beam%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); wall_mesh_pt()->output(some_file,npts); @@ -811,7 +811,7 @@ void FSICollapsibleChannelProblem:: doc_solution(DocInfo& doc_info, unsigned nsteps=time_stepper_pt(1)->nprev_values(); for (unsigned t=0;t<=nsteps;t++) { - sprintf(filename,"%s/wall%i-%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/wall%i-%i.dat",doc_info.directory().c_str(), doc_info.number(),t); some_file.open(filename); unsigned n_elem=wall_mesh_pt()->nelement(); @@ -1216,7 +1216,7 @@ int main(int argc, char* argv[]) // Open a trace file ofstream trace_file; char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); trace_file.open(filename); // Output the initial condition diff --git a/demo_drivers/interaction/fsi_driven_cavity/fsi_driven_cavity_driver.cc b/demo_drivers/interaction/fsi_driven_cavity/fsi_driven_cavity_driver.cc index 57c4c0051059..943ca96ca62d 100644 --- a/demo_drivers/interaction/fsi_driven_cavity/fsi_driven_cavity_driver.cc +++ b/demo_drivers/interaction/fsi_driven_cavity/fsi_driven_cavity_driver.cc @@ -80,7 +80,7 @@ int main(int argc, char* argv[]) // Open a trace file ofstream trace_file; char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); trace_file.open(filename); // Output the initial solution diff --git a/demo_drivers/interaction/fsi_driven_cavity/fsi_driven_cavity_problem.h b/demo_drivers/interaction/fsi_driven_cavity/fsi_driven_cavity_problem.h index aeeb722973c0..908e8318f648 100644 --- a/demo_drivers/interaction/fsi_driven_cavity/fsi_driven_cavity_problem.h +++ b/demo_drivers/interaction/fsi_driven_cavity/fsi_driven_cavity_problem.h @@ -511,14 +511,14 @@ void FSIDrivenCavityProblem:: doc_solution(DocInfo& doc_info, npts=5; // Output fluid solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); bulk_mesh_pt()->output(some_file,npts); some_file.close(); // Document the wall shape - sprintf(filename,"%s/beam%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/beam%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); wall_mesh_pt()->output(some_file,npts); diff --git a/demo_drivers/interaction/fsi_driven_cavity/fsi_driven_cavity_segregated_driver.cc b/demo_drivers/interaction/fsi_driven_cavity/fsi_driven_cavity_segregated_driver.cc index 6a7a19df7156..e24a45063721 100644 --- a/demo_drivers/interaction/fsi_driven_cavity/fsi_driven_cavity_segregated_driver.cc +++ b/demo_drivers/interaction/fsi_driven_cavity/fsi_driven_cavity_segregated_driver.cc @@ -423,7 +423,7 @@ int main(int argc, char* argv[]) // Open a trace file ofstream trace_file; char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); trace_file.open(filename); // Output the initial solution diff --git a/demo_drivers/interaction/fsi_osc_ring/fsi_osc_ring.cc b/demo_drivers/interaction/fsi_osc_ring/fsi_osc_ring.cc index a682f838ecb2..b0414842ffb2 100644 --- a/demo_drivers/interaction/fsi_osc_ring/fsi_osc_ring.cc +++ b/demo_drivers/interaction/fsi_osc_ring/fsi_osc_ring.cc @@ -379,7 +379,7 @@ void FSIRingProblem::doc_solution(const unsigned& i, ofstream some_file; char filename[100]; //Construct the output filename from the doc_info number and the //output directory - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); //Open the output file some_file.open(filename); diff --git a/demo_drivers/interaction/fsi_osc_ring/fsi_osc_ring_compare_jacs.cc b/demo_drivers/interaction/fsi_osc_ring/fsi_osc_ring_compare_jacs.cc index 6068d85622d7..d00623f181bf 100644 --- a/demo_drivers/interaction/fsi_osc_ring/fsi_osc_ring_compare_jacs.cc +++ b/demo_drivers/interaction/fsi_osc_ring/fsi_osc_ring_compare_jacs.cc @@ -380,7 +380,7 @@ void FSIRingProblem::doc_solution(const unsigned& i, ofstream some_file; char filename[100]; //Construct the output filename from the doc_info number and the //output directory - sprintf(filename,"%s/soln%i_%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i_%i.dat",doc_info.directory().c_str(), i_case,doc_info.number()); //Open the output file some_file.open(filename); diff --git a/demo_drivers/interaction/fsi_osc_ring/osc_ring_alg.cc b/demo_drivers/interaction/fsi_osc_ring/osc_ring_alg.cc index 58bd54f626d4..4e13d312a287 100644 --- a/demo_drivers/interaction/fsi_osc_ring/osc_ring_alg.cc +++ b/demo_drivers/interaction/fsi_osc_ring/osc_ring_alg.cc @@ -499,7 +499,7 @@ void OscRingNStProblem::doc_solution(DocInfo& doc_info) // Output solution on fluid mesh //------------------------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); //some_file.precision(20); some_file.open(filename); @@ -514,7 +514,7 @@ void OscRingNStProblem::doc_solution(DocInfo& doc_info) // Plot wall posn //--------------- - sprintf(filename,"%s/Wall%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/Wall%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); @@ -532,7 +532,7 @@ void OscRingNStProblem::doc_solution(DocInfo& doc_info) // Doc Sarah's asymptotic solution //-------------------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); fluid_mesh_pt()->output_fct(some_file,npts, @@ -655,7 +655,7 @@ void OscRingNStProblem::doc_solution(DocInfo& doc_info) } // Output fluid solution on coarse mesh - sprintf(filename,"%s/coarse_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/coarse_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); nelem=coarse_mesh_pt->nelement(); @@ -667,7 +667,7 @@ void OscRingNStProblem::doc_solution(DocInfo& doc_info) some_file.close(); // Write restart file - sprintf(filename,"%s/restart%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/restart%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); dump_it(some_file,doc_info); @@ -735,7 +735,7 @@ void OscRingNStProblem::unsteady_run(const unsigned& ntsteps, // Open trace file char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); Trace_file.open(filename); // Max. number of adaptations per solve diff --git a/demo_drivers/interaction/fsi_osc_ring/osc_ring_macro.cc b/demo_drivers/interaction/fsi_osc_ring/osc_ring_macro.cc index 7b49a7b88804..2b7d66a58d9c 100644 --- a/demo_drivers/interaction/fsi_osc_ring/osc_ring_macro.cc +++ b/demo_drivers/interaction/fsi_osc_ring/osc_ring_macro.cc @@ -498,7 +498,7 @@ void OscRingNStProblem::doc_solution(DocInfo& doc_info) // Output solution on fluid mesh //------------------------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); //some_file.precision(20); some_file.open(filename); @@ -513,7 +513,7 @@ void OscRingNStProblem::doc_solution(DocInfo& doc_info) // Plot wall posn //--------------- - sprintf(filename,"%s/Wall%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/Wall%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); @@ -531,7 +531,7 @@ void OscRingNStProblem::doc_solution(DocInfo& doc_info) // Doc Sarah's asymptotic solution //-------------------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); fluid_mesh_pt()->output_fct(some_file,npts, @@ -654,7 +654,7 @@ void OscRingNStProblem::doc_solution(DocInfo& doc_info) } // Output fluid solution on coarse mesh - sprintf(filename,"%s/coarse_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/coarse_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); nelem=coarse_mesh_pt->nelement(); @@ -666,7 +666,7 @@ void OscRingNStProblem::doc_solution(DocInfo& doc_info) some_file.close(); // Write restart file - sprintf(filename,"%s/restart%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/restart%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); dump_it(some_file,doc_info); @@ -734,7 +734,7 @@ void OscRingNStProblem::unsteady_run(const unsigned& ntsteps, // Open trace file char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); Trace_file.open(filename); // Max. number of adaptations per solve diff --git a/demo_drivers/interaction/linearised_fsi_pulsewave/linearised_fsi_pulsewave.cc b/demo_drivers/interaction/linearised_fsi_pulsewave/linearised_fsi_pulsewave.cc index b76c2bfbd675..614a458fd6a0 100644 --- a/demo_drivers/interaction/linearised_fsi_pulsewave/linearised_fsi_pulsewave.cc +++ b/demo_drivers/interaction/linearised_fsi_pulsewave/linearised_fsi_pulsewave.cc @@ -875,7 +875,7 @@ void PressureWaveFSIProblem::doc_solution( ofstream file; // Fluid - sprintf(filename,"%s/soln-fluid%i.dat", + snprintf(filename, sizeof(filename), "%s/soln-fluid%i.dat", doc_info.directory().c_str(), doc_info.number()); file.open(filename); @@ -883,7 +883,7 @@ void PressureWaveFSIProblem::doc_solution( file.close(); // Fluid traction - sprintf(filename,"%s/fluid_traction%i.dat", + snprintf(filename, sizeof(filename), "%s/fluid_traction%i.dat", doc_info.directory().c_str(), doc_info.number()); file.open(filename); @@ -892,7 +892,7 @@ void PressureWaveFSIProblem::doc_solution( // Fluid traction - sprintf(filename,"%s/fluid_fsi_traction%i.dat", + snprintf(filename, sizeof(filename), "%s/fluid_fsi_traction%i.dat", doc_info.directory().c_str(), doc_info.number()); file.open(filename); @@ -901,7 +901,7 @@ void PressureWaveFSIProblem::doc_solution( // // Fluid traction - // sprintf(filename,"%s/tmp_fluid_fsi_traction%i.dat", + // snprintf(filename, sizeof(filename), "%s/tmp_fluid_fsi_traction%i.dat", // doc_info.directory().c_str(), // doc_info.number()); // file.open(filename); @@ -909,7 +909,7 @@ void PressureWaveFSIProblem::doc_solution( // file.close(); // Solid - sprintf(filename,"%s/soln-solid%i.dat", + snprintf(filename, sizeof(filename), "%s/soln-solid%i.dat", doc_info.directory().c_str(), doc_info.number()); file.open(filename); @@ -918,7 +918,7 @@ void PressureWaveFSIProblem::doc_solution( // Solid traction - sprintf(filename,"%s/solid_traction%i.dat", + snprintf(filename, sizeof(filename), "%s/solid_traction%i.dat", doc_info.directory().c_str(), doc_info.number()); file.open(filename); @@ -927,7 +927,7 @@ void PressureWaveFSIProblem::doc_solution( // Solid traction - sprintf(filename,"%s/outside_solid_traction%i.dat", + snprintf(filename, sizeof(filename), "%s/outside_solid_traction%i.dat", doc_info.directory().c_str(), doc_info.number()); file.open(filename); @@ -936,7 +936,7 @@ void PressureWaveFSIProblem::doc_solution( // Fluid at regularly spaced points - sprintf(filename,"%s/regular_fluid%i.dat", + snprintf(filename, sizeof(filename), "%s/regular_fluid%i.dat", doc_info.directory().c_str(), doc_info.number()); file.open(filename); @@ -970,7 +970,7 @@ void PressureWaveFSIProblem::doc_solution( // Output "exact" pulse wave solution //----------------------------------- - sprintf(filename,"%s/pulse_wave%i.dat", + snprintf(filename, sizeof(filename), "%s/pulse_wave%i.dat", doc_info.directory().c_str(), doc_info.number()); file.open(filename); diff --git a/demo_drivers/interaction/linearised_poroelastic_fsi_pulsewave/linearised_poroelastic_fsi_pulsewave.cc b/demo_drivers/interaction/linearised_poroelastic_fsi_pulsewave/linearised_poroelastic_fsi_pulsewave.cc index 5fe8f86e2e02..e1fad0aebfc0 100644 --- a/demo_drivers/interaction/linearised_poroelastic_fsi_pulsewave/linearised_poroelastic_fsi_pulsewave.cc +++ b/demo_drivers/interaction/linearised_poroelastic_fsi_pulsewave/linearised_poroelastic_fsi_pulsewave.cc @@ -1129,7 +1129,7 @@ doc_solution(DocInfo& doc_info) ofstream file; // Fluid - sprintf(filename,"%s/soln-fluid%i.dat", + snprintf(filename, sizeof(filename), "%s/soln-fluid%i.dat", doc_info.directory().c_str(), doc_info.number()); file.open(filename); @@ -1155,7 +1155,7 @@ doc_solution(DocInfo& doc_info) pad="0"; } - sprintf(filename,"%s/soln-fluid%s%i.vtu",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln-fluid%s%i.vtu",doc_info.directory().c_str(), pad.c_str(),doc_info.number()); file.open(filename); Fluid_mesh_pt->output_paraview(file,5); @@ -1163,7 +1163,7 @@ doc_solution(DocInfo& doc_info) // Fluid at regularly spaced points - sprintf(filename,"%s/regular_fluid%i.dat", + snprintf(filename, sizeof(filename), "%s/regular_fluid%i.dat", doc_info.directory().c_str(), doc_info.number()); file.open(filename); @@ -1196,7 +1196,7 @@ doc_solution(DocInfo& doc_info) file.close(); // Fluid inflow traction - sprintf(filename,"%s/fluid_traction%i.dat", + snprintf(filename, sizeof(filename), "%s/fluid_traction%i.dat", doc_info.directory().c_str(), doc_info.number()); file.open(filename); @@ -1204,7 +1204,7 @@ doc_solution(DocInfo& doc_info) file.close(); // Fluid FSI traction - sprintf(filename,"%s/fluid_fsi_traction%i.dat", + snprintf(filename, sizeof(filename), "%s/fluid_fsi_traction%i.dat", doc_info.directory().c_str(), doc_info.number()); file.open(filename); @@ -1212,7 +1212,7 @@ doc_solution(DocInfo& doc_info) file.close(); // Poroelasticity - sprintf(filename,"%s/soln-poro%i.dat", + snprintf(filename, sizeof(filename), "%s/soln-poro%i.dat", doc_info.directory().c_str(), doc_info.number()); file.open(filename); @@ -1221,7 +1221,7 @@ doc_solution(DocInfo& doc_info) // Output solution to file in paraview format - sprintf(filename,"%s/soln-poro%s%i.vtu", + snprintf(filename, sizeof(filename), "%s/soln-poro%s%i.vtu", doc_info.directory().c_str(), pad.c_str(), doc_info.number()); @@ -1230,7 +1230,7 @@ doc_solution(DocInfo& doc_info) file.close(); // Solid at regularly spaced points - sprintf(filename,"%s/regular_poro%i.dat", + snprintf(filename, sizeof(filename), "%s/regular_poro%i.dat", doc_info.directory().c_str(), doc_info.number()); file.open(filename); @@ -1258,7 +1258,7 @@ doc_solution(DocInfo& doc_info) file.close(); // Poroelasticity FSI traction - sprintf(filename,"%s/poro_traction%i.dat", + snprintf(filename, sizeof(filename), "%s/poro_traction%i.dat", doc_info.directory().c_str(), doc_info.number()); file.open(filename); diff --git a/demo_drivers/interaction/pseudo_solid_collapsible_tube/pseudo_solid_collapsible_tube.cc b/demo_drivers/interaction/pseudo_solid_collapsible_tube/pseudo_solid_collapsible_tube.cc index d546878a858f..7e83a2f6536b 100644 --- a/demo_drivers/interaction/pseudo_solid_collapsible_tube/pseudo_solid_collapsible_tube.cc +++ b/demo_drivers/interaction/pseudo_solid_collapsible_tube/pseudo_solid_collapsible_tube.cc @@ -900,7 +900,7 @@ PseudoElasticCollapsibleChannelProblem() //Doc boundary coordinates in fluid char filename[100]; - sprintf(filename,"RESLT/fluid_boundary_coordinates.dat"); + snprintf(filename, sizeof(filename), "RESLT/fluid_boundary_coordinates.dat"); Multi_domain_functions::Doc_boundary_coordinate_file.open(filename); // Setup FSI: Pass ID of fluid FSI boundary and associated @@ -1382,7 +1382,7 @@ doc_solid_boundary_coordinates() //Doc boundary coordinates in fluid char filename[100]; - sprintf(filename,"RESLT/solid_boundary_coordinates.dat"); + snprintf(filename, sizeof(filename), "RESLT/solid_boundary_coordinates.dat"); std::ofstream the_file(filename); // Loop over traction elements @@ -1446,7 +1446,7 @@ doc_solution(DocInfo& doc_info) // Output solid boundaries //------------------------ - sprintf(filename,"%s/solid_boundaries%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/solid_boundaries%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Solid_mesh_pt->output_boundaries(some_file); @@ -1455,7 +1455,7 @@ doc_solution(DocInfo& doc_info) // Output solid solution //----------------------- - sprintf(filename,"%s/solid_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/solid_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Solid_mesh_pt->output(some_file,npts); @@ -1464,7 +1464,7 @@ doc_solution(DocInfo& doc_info) // Output fluid boundaries //------------------------ - sprintf(filename,"%s/fluid_boundaries%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/fluid_boundaries%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Fluid_mesh_pt->output_boundaries(some_file); @@ -1473,7 +1473,7 @@ doc_solution(DocInfo& doc_info) // Output fluid solution //----------------------- - sprintf(filename,"%s/fluid_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/fluid_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Fluid_mesh_pt->output(some_file,npts); @@ -1482,7 +1482,7 @@ doc_solution(DocInfo& doc_info) // Output fsi traction //-------------------- - sprintf(filename,"%s/fsi_traction%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/fsi_traction%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Solid_fsi_traction_mesh_pt->output(some_file,npts); @@ -1490,7 +1490,7 @@ doc_solution(DocInfo& doc_info) // Output fsi traction //-------------------- - sprintf(filename,"%s/solid_traction%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/solid_traction%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Solid_traction_mesh_pt->output(some_file,npts); @@ -1499,7 +1499,7 @@ doc_solution(DocInfo& doc_info) // Output Lagrange multipliers //---------------------------- - sprintf(filename,"%s/lagrange%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/lagrange%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Lagrange_multiplier_mesh_pt->output(some_file,npts); diff --git a/demo_drivers/interaction/pseudo_solid_collapsible_tube/pseudo_solid_collapsible_tube_work.cc b/demo_drivers/interaction/pseudo_solid_collapsible_tube/pseudo_solid_collapsible_tube_work.cc index 415e348655c9..9eef1edf9da5 100644 --- a/demo_drivers/interaction/pseudo_solid_collapsible_tube/pseudo_solid_collapsible_tube_work.cc +++ b/demo_drivers/interaction/pseudo_solid_collapsible_tube/pseudo_solid_collapsible_tube_work.cc @@ -899,7 +899,7 @@ PseudoElasticCollapsibleChannelProblem() //Doc boundary coordinates in fluid char filename[100]; - sprintf(filename,"RESLT/fluid_boundary_coordinates.dat"); + snprintf(filename, sizeof(filename), "RESLT/fluid_boundary_coordinates.dat"); Multi_domain_functions::Doc_boundary_coordinate_file.open(filename); // Setup FSI: Pass ID of fluid FSI boundary and associated @@ -1381,7 +1381,7 @@ doc_solid_boundary_coordinates() //Doc boundary coordinates in fluid char filename[100]; - sprintf(filename,"RESLT/solid_boundary_coordinates.dat"); + snprintf(filename, sizeof(filename), "RESLT/solid_boundary_coordinates.dat"); std::ofstream the_file(filename); // Loop over traction elements @@ -1447,7 +1447,7 @@ doc_solution(DocInfo& doc_info) // Output solid boundaries //------------------------ - sprintf(filename,"%s/solid_boundaries%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/solid_boundaries%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Solid_mesh_pt->output_boundaries(some_file); @@ -1456,7 +1456,7 @@ doc_solution(DocInfo& doc_info) // Output solid solution //----------------------- - sprintf(filename,"%s/solid_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/solid_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Solid_mesh_pt->output(some_file,npts); @@ -1465,7 +1465,7 @@ doc_solution(DocInfo& doc_info) // Output fluid boundaries //------------------------ - sprintf(filename,"%s/fluid_boundaries%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/fluid_boundaries%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Fluid_mesh_pt->output_boundaries(some_file); @@ -1474,7 +1474,7 @@ doc_solution(DocInfo& doc_info) // Output fluid solution //----------------------- - sprintf(filename,"%s/fluid_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/fluid_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Fluid_mesh_pt->output(some_file,npts); @@ -1483,7 +1483,7 @@ doc_solution(DocInfo& doc_info) // Output fsi traction //-------------------- - sprintf(filename,"%s/fsi_traction%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/fsi_traction%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Solid_fsi_traction_mesh_pt->output(some_file,npts); @@ -1491,7 +1491,7 @@ doc_solution(DocInfo& doc_info) // Output fsi traction //-------------------- - sprintf(filename,"%s/solid_traction%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/solid_traction%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Solid_traction_mesh_pt->output(some_file,npts); @@ -1500,7 +1500,7 @@ doc_solution(DocInfo& doc_info) // Output Lagrange multipliers //---------------------------- - sprintf(filename,"%s/lagrange%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/lagrange%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Lagrange_multiplier_mesh_pt->output(some_file,npts); diff --git a/demo_drivers/interaction/pseudo_solid_fsi_channel_with_leaflet/fsi_channel_with_leaflet_precond.cc b/demo_drivers/interaction/pseudo_solid_fsi_channel_with_leaflet/fsi_channel_with_leaflet_precond.cc index b161d2cf51da..7f95fc98e3b1 100644 --- a/demo_drivers/interaction/pseudo_solid_fsi_channel_with_leaflet/fsi_channel_with_leaflet_precond.cc +++ b/demo_drivers/interaction/pseudo_solid_fsi_channel_with_leaflet/fsi_channel_with_leaflet_precond.cc @@ -973,14 +973,14 @@ void FSIChannelWithLeafletProblem::doc_solution(DocInfo& doc_info) npts=5; // Output fluid solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); some_file.close(); // Output wall solution - sprintf(filename,"%s/wall_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/wall_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Wall_mesh_pt->output(some_file,npts); @@ -992,7 +992,7 @@ void FSIChannelWithLeafletProblem::doc_solution(DocInfo& doc_info) // Output fluid elements on fluid mesh boundary 4 (associated with // the "front") unsigned bound=4; - sprintf(filename,"%s/bulk_boundary_elements_front_%i.dat", + snprintf(filename, sizeof(filename), "%s/bulk_boundary_elements_front_%i.dat", doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); @@ -1008,7 +1008,7 @@ void FSIChannelWithLeafletProblem::doc_solution(DocInfo& doc_info) // Output fluid elements on fluid mesh boundary 5 (associated with // the "back") bound=5; - sprintf(filename,"%s/bulk_boundary_elements_back_%i.dat", + snprintf(filename, sizeof(filename), "%s/bulk_boundary_elements_back_%i.dat", doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); @@ -1022,7 +1022,7 @@ void FSIChannelWithLeafletProblem::doc_solution(DocInfo& doc_info) // Output normal vector on wall elements - sprintf(filename,"%s/wall_normal_%i.dat", + snprintf(filename, sizeof(filename), "%s/wall_normal_%i.dat", doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); @@ -1123,10 +1123,10 @@ int main(int argc, char **argv) std::ofstream output_stream; char filename[1000]; #ifdef OOMPH_HAS_MPI - sprintf(filename,"%s/OUTPUT_STEADY.%i",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/OUTPUT_STEADY.%i",doc_info.directory().c_str(), MPI_Helpers::communicator_pt()->my_rank()); #else - sprintf(filename,"%s/OUTPUT_STEADY.%i",doc_info.directory().c_str(),0); + snprintf(filename, sizeof(filename), "%s/OUTPUT_STEADY.%i",doc_info.directory().c_str(),0); #endif output_stream.open(filename); @@ -1177,10 +1177,10 @@ int main(int argc, char **argv) // Define processor-labeled output file for all on-screen stuff output_stream.close(); #ifdef OOMPH_HAS_MPI - sprintf(filename,"%s/OUTPUT_UNSTEADY.%i",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/OUTPUT_UNSTEADY.%i",doc_info.directory().c_str(), MPI_Helpers::communicator_pt()->my_rank()); #else - sprintf(filename,"%s/OUTPUT_UNSTEADY.%i",doc_info.directory().c_str(),0); + snprintf(filename, sizeof(filename), "%s/OUTPUT_UNSTEADY.%i",doc_info.directory().c_str(),0); #endif output_stream.open(filename); oomph_info.stream_pt() = &output_stream; diff --git a/demo_drivers/interaction/turek_flag/turek_flag.cc b/demo_drivers/interaction/turek_flag/turek_flag.cc index 86740dd612f1..10915f8060b0 100644 --- a/demo_drivers/interaction/turek_flag/turek_flag.cc +++ b/demo_drivers/interaction/turek_flag/turek_flag.cc @@ -1022,14 +1022,14 @@ void TurekProblem::doc_solution( unsigned n_plot = 5; // Output solid solution - sprintf(filename,"%s/solid_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/solid_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); solid_mesh_pt()->output(some_file,n_plot); some_file.close(); // Output fluid solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); fluid_mesh_pt()->output(some_file,n_plot); @@ -1037,7 +1037,7 @@ void TurekProblem::doc_solution( //Output the traction - sprintf(filename,"%s/traction%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/traction%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); // Loop over the traction meshes diff --git a/demo_drivers/interaction/unsteady_vmtk_fsi/unsteady_vmtk_fsi.cc b/demo_drivers/interaction/unsteady_vmtk_fsi/unsteady_vmtk_fsi.cc index 81cb54b1c982..e7a974e0047d 100644 --- a/demo_drivers/interaction/unsteady_vmtk_fsi/unsteady_vmtk_fsi.cc +++ b/demo_drivers/interaction/unsteady_vmtk_fsi/unsteady_vmtk_fsi.cc @@ -868,7 +868,7 @@ UnstructuredFSIProblem::UnstructuredFSIProblem() //Doc boundary coordinates in fluid char filename[100]; - sprintf(filename,"RESLT/fluid_boundary_coordinates%i.dat",i); + snprintf(filename, sizeof(filename), "RESLT/fluid_boundary_coordinates%i.dat",i); Multi_domain_functions::Doc_boundary_coordinate_file.open(filename); // Setup FSI: Pass ID of fluid FSI boundary and associated @@ -1123,7 +1123,7 @@ doc_solid_boundary_coordinates(const unsigned& i) //Doc boundary coordinates in fluid char filename[100]; - sprintf(filename,"RESLT/solid_boundary_coordinates%i.dat",i); + snprintf(filename, sizeof(filename), "RESLT/solid_boundary_coordinates%i.dat",i); std::ofstream the_file(filename); // Loop over traction elements @@ -1194,7 +1194,7 @@ doc_solution(DocInfo& doc_info) // Output solid boundaries //------------------------ - sprintf(filename,"%s/solid_boundaries%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/solid_boundaries%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Solid_mesh_pt->output_boundaries(some_file); @@ -1203,7 +1203,7 @@ doc_solution(DocInfo& doc_info) // Output solid solution //----------------------- - sprintf(filename,"%s/solid_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/solid_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Solid_mesh_pt->output(some_file,npts); @@ -1212,7 +1212,7 @@ doc_solution(DocInfo& doc_info) // Output fluid boundaries //------------------------ - sprintf(filename,"%s/fluid_boundaries%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/fluid_boundaries%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Fluid_mesh_pt->output_boundaries(some_file); @@ -1221,7 +1221,7 @@ doc_solution(DocInfo& doc_info) // Output fluid solution //----------------------- - sprintf(filename,"%s/fluid_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/fluid_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Fluid_mesh_pt->output(some_file,npts); @@ -1230,7 +1230,7 @@ doc_solution(DocInfo& doc_info) // Output fsi traction //-------------------- - sprintf(filename,"%s/fsi_traction%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/fsi_traction%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); unsigned n=nsolid_fsi_boundary(); diff --git a/demo_drivers/interaction/unstructured_adaptive_fsi/unstructured_adaptive_2d_fsi.cc b/demo_drivers/interaction/unstructured_adaptive_fsi/unstructured_adaptive_2d_fsi.cc index 168ec67c2e35..cee043007e21 100644 --- a/demo_drivers/interaction/unstructured_adaptive_fsi/unstructured_adaptive_2d_fsi.cc +++ b/demo_drivers/interaction/unstructured_adaptive_fsi/unstructured_adaptive_2d_fsi.cc @@ -897,14 +897,14 @@ doc_solution(DocInfo& doc_info) // Output solution //---------------- - sprintf(filename,"%s/solid_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/solid_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Solid_mesh_pt->output(some_file,npts); some_file.close(); //---------------- - sprintf(filename,"%s/fluid_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/fluid_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Fluid_mesh_pt->output(some_file,npts); diff --git a/demo_drivers/interaction/unstructured_fsi/unstructured_two_d_fsi.cc b/demo_drivers/interaction/unstructured_fsi/unstructured_two_d_fsi.cc index 284f5157f9a6..c5b7f6d867f9 100644 --- a/demo_drivers/interaction/unstructured_fsi/unstructured_two_d_fsi.cc +++ b/demo_drivers/interaction/unstructured_fsi/unstructured_two_d_fsi.cc @@ -755,7 +755,7 @@ doc_solution(DocInfo& doc_info) npts=5; // Output fluid solution - sprintf(filename,"%s/fluid_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/fluid_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Fluid_mesh_pt->output(some_file,npts); @@ -763,7 +763,7 @@ doc_solution(DocInfo& doc_info) // Output solid solution - sprintf(filename,"%s/solid_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/solid_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Solid_mesh_pt->output(some_file,npts); diff --git a/demo_drivers/interaction/unstructured_three_d_fsi/unstructured_three_d_fsi.cc b/demo_drivers/interaction/unstructured_three_d_fsi/unstructured_three_d_fsi.cc index d3e7cb14bb0f..c6159f83601d 100644 --- a/demo_drivers/interaction/unstructured_three_d_fsi/unstructured_three_d_fsi.cc +++ b/demo_drivers/interaction/unstructured_three_d_fsi/unstructured_three_d_fsi.cc @@ -72,7 +72,7 @@ class MySolidTetgenMesh : public virtual TetgenMesh, unsigned nb=this->nboundary(); for (unsigned b=0;btemplate setup_boundary_coordinates(b,some_file); some_file.close(); @@ -131,7 +131,7 @@ class FluidTetMesh : public virtual TetgenMesh, unsigned nb=this->nboundary(); for (unsigned b=0;btemplate setup_boundary_coordinates(b,switch_normal,some_file); some_file.close(); @@ -679,7 +679,7 @@ UnstructuredFSIProblem::UnstructuredFSIProblem() //Doc boundary coordinates in fluid char filename[100]; - sprintf(filename,"RESLT/fluid_boundary_coordinates%i.dat",i); + snprintf(filename, sizeof(filename), "RESLT/fluid_boundary_coordinates%i.dat",i); Multi_domain_functions::Doc_boundary_coordinate_file.open(filename); // Setup FSI: Pass ID of fluid FSI boundary and associated @@ -880,7 +880,7 @@ doc_solid_boundary_coordinates(const unsigned& i) //Doc boundary coordinates in fluid char filename[100]; - sprintf(filename,"RESLT/solid_boundary_coordinates%i.dat",i); + snprintf(filename, sizeof(filename), "RESLT/solid_boundary_coordinates%i.dat",i); std::ofstream the_file(filename); // Loop over traction elements @@ -944,7 +944,7 @@ doc_solution(DocInfo& doc_info) // Output solid boundaries //------------------------ - sprintf(filename,"%s/solid_boundaries%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/solid_boundaries%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Solid_mesh_pt->output_boundaries(some_file); @@ -953,7 +953,7 @@ doc_solution(DocInfo& doc_info) // Output solid solution //----------------------- - sprintf(filename,"%s/solid_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/solid_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Solid_mesh_pt->output(some_file,npts); @@ -962,7 +962,7 @@ doc_solution(DocInfo& doc_info) // Output fluid boundaries //------------------------ - sprintf(filename,"%s/fluid_boundaries%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/fluid_boundaries%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Fluid_mesh_pt->output_boundaries(some_file); @@ -971,7 +971,7 @@ doc_solution(DocInfo& doc_info) // Output fluid solution //----------------------- - sprintf(filename,"%s/fluid_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/fluid_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Fluid_mesh_pt->output(some_file,npts); @@ -980,7 +980,7 @@ doc_solution(DocInfo& doc_info) // Output fsi traction //-------------------- - sprintf(filename,"%s/fsi_traction%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/fsi_traction%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); unsigned n=nsolid_fsi_boundary(); diff --git a/demo_drivers/interaction/vmtk_fsi/vmtk_fsi.cc b/demo_drivers/interaction/vmtk_fsi/vmtk_fsi.cc index 0f4a4f3d2cae..0703ecc87bb5 100644 --- a/demo_drivers/interaction/vmtk_fsi/vmtk_fsi.cc +++ b/demo_drivers/interaction/vmtk_fsi/vmtk_fsi.cc @@ -72,7 +72,7 @@ class MySolidTetgenMesh : public virtual TetgenMesh, unsigned nb=this->nboundary(); for (unsigned b=0;btemplate setup_boundary_coordinates(b,some_file); some_file.close(); @@ -131,7 +131,7 @@ class MyFluidTetMesh : public virtual TetgenMesh, unsigned nb=this->nboundary(); for (unsigned b=0;btemplate setup_boundary_coordinates (b,switch_normal,some_file); @@ -681,7 +681,7 @@ UnstructuredFSIProblem::UnstructuredFSIProblem() //Doc boundary coordinates in fluid char filename[100]; - sprintf(filename,"RESLT/fluid_boundary_coordinates%i.dat",i); + snprintf(filename, sizeof(filename), "RESLT/fluid_boundary_coordinates%i.dat",i); Multi_domain_functions::Doc_boundary_coordinate_file.open(filename); // Setup FSI: Pass ID of fluid FSI boundary and associated @@ -882,7 +882,7 @@ doc_solid_boundary_coordinates(const unsigned& i) //Doc boundary coordinates in fluid char filename[100]; - sprintf(filename,"RESLT/solid_boundary_coordinates%i.dat",i); + snprintf(filename, sizeof(filename), "RESLT/solid_boundary_coordinates%i.dat",i); std::ofstream the_file(filename); // Loop over traction elements @@ -946,7 +946,7 @@ doc_solution(DocInfo& doc_info) // Output solid boundaries //------------------------ - sprintf(filename,"%s/solid_boundaries%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/solid_boundaries%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Solid_mesh_pt->output_boundaries(some_file); @@ -955,7 +955,7 @@ doc_solution(DocInfo& doc_info) // Output solid solution //----------------------- - sprintf(filename,"%s/solid_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/solid_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Solid_mesh_pt->output(some_file,npts); @@ -964,7 +964,7 @@ doc_solution(DocInfo& doc_info) // Output fluid boundaries //------------------------ - sprintf(filename,"%s/fluid_boundaries%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/fluid_boundaries%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Fluid_mesh_pt->output_boundaries(some_file); @@ -973,7 +973,7 @@ doc_solution(DocInfo& doc_info) // Output fluid solution //----------------------- - sprintf(filename,"%s/fluid_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/fluid_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Fluid_mesh_pt->output(some_file,npts); @@ -982,7 +982,7 @@ doc_solution(DocInfo& doc_info) // Output fsi traction //-------------------- - sprintf(filename,"%s/fsi_traction%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/fsi_traction%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); unsigned n=nsolid_fsi_boundary(); diff --git a/demo_drivers/linear_elasticity/periodic_load/periodic_load.cc b/demo_drivers/linear_elasticity/periodic_load/periodic_load.cc index 724120b0d5c6..04d91e40de58 100644 --- a/demo_drivers/linear_elasticity/periodic_load/periodic_load.cc +++ b/demo_drivers/linear_elasticity/periodic_load/periodic_load.cc @@ -253,13 +253,13 @@ void PeriodicLoadProblem::doc_solution(DocInfo& doc_info) unsigned npts=5; // Output solution - sprintf(filename,"%s/soln.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/soln.dat",doc_info.directory().c_str()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); some_file.close(); // Output exact solution - sprintf(filename,"%s/exact_soln.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/exact_soln.dat",doc_info.directory().c_str()); some_file.open(filename); Bulk_mesh_pt->output_fct(some_file,npts, Global_Parameters::exact_solution); @@ -268,7 +268,7 @@ void PeriodicLoadProblem::doc_solution(DocInfo& doc_info) // Doc error double error=0.0; double norm=0.0; - sprintf(filename,"%s/error.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/error.dat",doc_info.directory().c_str()); some_file.open(filename); Bulk_mesh_pt->compute_error(some_file, Global_Parameters::exact_solution, diff --git a/demo_drivers/linear_elasticity/periodic_load/refineable_periodic_load.cc b/demo_drivers/linear_elasticity/periodic_load/refineable_periodic_load.cc index a3cab7f3713c..71626bbec77f 100644 --- a/demo_drivers/linear_elasticity/periodic_load/refineable_periodic_load.cc +++ b/demo_drivers/linear_elasticity/periodic_load/refineable_periodic_load.cc @@ -346,13 +346,13 @@ void RefineablePeriodicLoadProblem::doc_solution(DocInfo& doc_info) unsigned npts=5; // Output solution - sprintf(filename,"%s/soln.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/soln.dat",doc_info.directory().c_str()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); some_file.close(); // Output exact solution - sprintf(filename,"%s/exact_soln.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/exact_soln.dat",doc_info.directory().c_str()); some_file.open(filename); Bulk_mesh_pt->output_fct(some_file,npts, Global_Parameters::exact_solution); @@ -361,7 +361,7 @@ void RefineablePeriodicLoadProblem::doc_solution(DocInfo& doc_info) // Doc error double error=0.0; double norm=0.0; - sprintf(filename,"%s/error.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/error.dat",doc_info.directory().c_str()); some_file.open(filename); Bulk_mesh_pt->compute_error(some_file, Global_Parameters::exact_solution, diff --git a/demo_drivers/linear_solvers/HypreSolver_test.cc b/demo_drivers/linear_solvers/HypreSolver_test.cc index 4e46aefec68d..ca0d8d04585c 100644 --- a/demo_drivers/linear_solvers/HypreSolver_test.cc +++ b/demo_drivers/linear_solvers/HypreSolver_test.cc @@ -271,7 +271,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info) // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -280,7 +280,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info) // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output_fct(some_file,npts,TanhSolnForPoisson::get_exact_u); @@ -289,7 +289,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info) // Doc error and return of the square of the L2 error //--------------------------------------------------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->compute_error(some_file,TanhSolnForPoisson::get_exact_u, @@ -329,7 +329,7 @@ int main(int argc, char **argv) // File to report the number of Newton iterations ofstream conv_file; char filename[100]; - sprintf(filename,"%s/conv.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/conv.dat",doc_info.directory().c_str()); conv_file.open(filename); // Test the Hypre linear solvers diff --git a/demo_drivers/linear_solvers/TrilinosSolver_test.cc b/demo_drivers/linear_solvers/TrilinosSolver_test.cc index c37df29d32c5..7cc11a16e042 100644 --- a/demo_drivers/linear_solvers/TrilinosSolver_test.cc +++ b/demo_drivers/linear_solvers/TrilinosSolver_test.cc @@ -270,7 +270,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info) // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -278,7 +278,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info) // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output_fct(some_file,npts,TanhSolnForPoisson::get_exact_u); @@ -287,7 +287,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info) // Doc error and return of the square of the L2 error //--------------------------------------------------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->compute_error(some_file,TanhSolnForPoisson::get_exact_u, @@ -340,7 +340,7 @@ int main(int argc, char **argv) // File to report the number of Newton iterations ofstream conv_file; char filename[100]; - sprintf(filename,"%s/conv.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/conv.dat",doc_info.directory().c_str()); conv_file.open(filename); diff --git a/demo_drivers/linear_solvers/adv_diff_iterative_linear_solver_tester.cc b/demo_drivers/linear_solvers/adv_diff_iterative_linear_solver_tester.cc index 608aa10cbdb3..d4850872939d 100644 --- a/demo_drivers/linear_solvers/adv_diff_iterative_linear_solver_tester.cc +++ b/demo_drivers/linear_solvers/adv_diff_iterative_linear_solver_tester.cc @@ -353,7 +353,7 @@ doc_solution(DocInfo& doc_info) // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); @@ -361,7 +361,7 @@ doc_solution(DocInfo& doc_info) // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output_fct(some_file,npts,TanhSolnForAdvectionDiffusion::get_exact_u); @@ -371,7 +371,7 @@ doc_solution(DocInfo& doc_info) // Doc error and return of the square of the L2 error //--------------------------------------------------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->compute_error(some_file,TanhSolnForAdvectionDiffusion::get_exact_u, diff --git a/demo_drivers/linear_solvers/direct_solver_test.cc b/demo_drivers/linear_solvers/direct_solver_test.cc index 615f8fd0a898..062b68fbaa88 100644 --- a/demo_drivers/linear_solvers/direct_solver_test.cc +++ b/demo_drivers/linear_solvers/direct_solver_test.cc @@ -233,21 +233,21 @@ void OneDPoissonProblem::doc_solution(DocInfo& doc) npts=5; // Output solution with specified number of plot points per element - sprintf(filename,"%s/soln%i.dat",doc.directory().c_str(),doc.number()); + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc.directory().c_str(),doc.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); some_file.close(); // Output exact solution at much higher resolution (so we can // see how well the solutions agree between nodal points) - sprintf(filename,"%s/exact_soln%i.dat",doc.directory().c_str(),doc.number()); + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc.directory().c_str(),doc.number()); some_file.open(filename); mesh_pt()->output_fct(some_file,20*npts,FishSolnOneDPoisson::get_exact_u); some_file.close(); // Doc pointwise error and compute norm of error and of the solution double error,norm; - sprintf(filename,"%s/error%i.dat",doc.directory().c_str(),doc.number()); + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc.directory().c_str(),doc.number()); some_file.open(filename); mesh_pt()->compute_error(some_file,FishSolnOneDPoisson::get_exact_u, error,norm); diff --git a/demo_drivers/linear_solvers/driven_cavity.cc b/demo_drivers/linear_solvers/driven_cavity.cc index 94e89e57a8d1..5aadf5394282 100644 --- a/demo_drivers/linear_solvers/driven_cavity.cc +++ b/demo_drivers/linear_solvers/driven_cavity.cc @@ -383,7 +383,7 @@ void RectangularDrivenCavityProblem::doc_solution(DocInfo& doc_info) npts=5; // Output solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); diff --git a/demo_drivers/linear_solvers/driven_cavity_with_simple_lsc_preconditioner.cc b/demo_drivers/linear_solvers/driven_cavity_with_simple_lsc_preconditioner.cc index 540c562cd442..43eb2b8d16c2 100644 --- a/demo_drivers/linear_solvers/driven_cavity_with_simple_lsc_preconditioner.cc +++ b/demo_drivers/linear_solvers/driven_cavity_with_simple_lsc_preconditioner.cc @@ -997,7 +997,7 @@ void RectangularDrivenCavityProblem::doc_solution(DocInfo& doc_info) npts=5; // Output solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); diff --git a/demo_drivers/linear_solvers/serial_mumps_test.cc b/demo_drivers/linear_solvers/serial_mumps_test.cc index 5472f65315e0..afae9ccf2273 100644 --- a/demo_drivers/linear_solvers/serial_mumps_test.cc +++ b/demo_drivers/linear_solvers/serial_mumps_test.cc @@ -219,21 +219,21 @@ void OneDPoissonProblem::doc_solution(DocInfo& doc) npts = 5; // Output solution with specified number of plot points per element - sprintf(filename, "%s/soln_serial_mumps.dat", doc.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/soln_serial_mumps.dat", doc.directory().c_str()); some_file.open(filename); mesh_pt()->output(some_file, npts); some_file.close(); // Output exact solution at much higher resolution (so we can // see how well the solutions agree between nodal points) - sprintf(filename, "%s/exact_soln.dat", doc.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/exact_soln.dat", doc.directory().c_str()); some_file.open(filename); mesh_pt()->output_fct(some_file, 20 * npts, FishSolnOneDPoisson::get_exact_u); some_file.close(); // Doc pointwise error and compute norm of error and of the solution double error, norm; - sprintf(filename, "%s/error.dat", doc.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/error.dat", doc.directory().c_str()); some_file.open(filename); mesh_pt()->compute_error( some_file, FishSolnOneDPoisson::get_exact_u, error, norm); diff --git a/demo_drivers/linear_solvers/two_d_linear_elasticity_with_simple_block_diagonal_preconditioner.cc b/demo_drivers/linear_solvers/two_d_linear_elasticity_with_simple_block_diagonal_preconditioner.cc index 7557cf6babe2..02b768793552 100644 --- a/demo_drivers/linear_solvers/two_d_linear_elasticity_with_simple_block_diagonal_preconditioner.cc +++ b/demo_drivers/linear_solvers/two_d_linear_elasticity_with_simple_block_diagonal_preconditioner.cc @@ -387,13 +387,13 @@ void PeriodicLoadProblem::doc_solution(DocInfo& doc_info) unsigned npts = 5; // Output solution - sprintf(filename, "%s/soln.dat", doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/soln.dat", doc_info.directory().c_str()); some_file.open(filename); Bulk_mesh_pt->output(some_file, npts); some_file.close(); // Output exact solution - sprintf(filename, "%s/exact_soln.dat", doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/exact_soln.dat", doc_info.directory().c_str()); some_file.open(filename); Bulk_mesh_pt->output_fct(some_file, npts, Global_Parameters::exact_solution); some_file.close(); @@ -401,7 +401,7 @@ void PeriodicLoadProblem::doc_solution(DocInfo& doc_info) // Doc error double error = 0.0; double norm = 0.0; - sprintf(filename, "%s/error.dat", doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/error.dat", doc_info.directory().c_str()); some_file.open(filename); Bulk_mesh_pt->compute_error( some_file, Global_Parameters::exact_solution, error, norm); diff --git a/demo_drivers/linear_solvers/two_d_multi_poisson.cc b/demo_drivers/linear_solvers/two_d_multi_poisson.cc index 7165beffaf20..d533cdbb8f95 100644 --- a/demo_drivers/linear_solvers/two_d_multi_poisson.cc +++ b/demo_drivers/linear_solvers/two_d_multi_poisson.cc @@ -438,7 +438,7 @@ void MultiPoissonProblem::doc_solution(DocInfo& doc_info) // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -447,7 +447,7 @@ void MultiPoissonProblem::doc_solution(DocInfo& doc_info) // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output_fct(some_file,npts,TanhSolnForMultiPoisson::get_exact_u); @@ -456,7 +456,7 @@ void MultiPoissonProblem::doc_solution(DocInfo& doc_info) // Doc error and return of the square of the L2 error //--------------------------------------------------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->compute_error(some_file,TanhSolnForMultiPoisson::get_exact_u, diff --git a/demo_drivers/linear_solvers/two_d_poisson_cg.cc b/demo_drivers/linear_solvers/two_d_poisson_cg.cc index 55e1ab6fd680..bffc32b43147 100644 --- a/demo_drivers/linear_solvers/two_d_poisson_cg.cc +++ b/demo_drivers/linear_solvers/two_d_poisson_cg.cc @@ -236,7 +236,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info) // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -245,7 +245,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info) // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output_fct(some_file,npts,TanhSolnForPoisson::get_exact_u); @@ -254,7 +254,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info) // Doc error and return of the square of the L2 error //--------------------------------------------------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->compute_error(some_file,TanhSolnForPoisson::get_exact_u, diff --git a/demo_drivers/linear_solvers/two_d_poisson_dense_lu.cc b/demo_drivers/linear_solvers/two_d_poisson_dense_lu.cc index 9bef4e5b28cc..75e149393a01 100644 --- a/demo_drivers/linear_solvers/two_d_poisson_dense_lu.cc +++ b/demo_drivers/linear_solvers/two_d_poisson_dense_lu.cc @@ -232,7 +232,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info) // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -241,7 +241,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info) // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output_fct(some_file,npts,TanhSolnForPoisson::get_exact_u); @@ -250,7 +250,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info) // Doc error and return of the square of the L2 error //--------------------------------------------------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->compute_error(some_file,TanhSolnForPoisson::get_exact_u, diff --git a/demo_drivers/linear_wave/two_d_linear_wave/two_d_linear_wave.cc b/demo_drivers/linear_wave/two_d_linear_wave/two_d_linear_wave.cc index e913124b423c..6490bf677167 100644 --- a/demo_drivers/linear_wave/two_d_linear_wave/two_d_linear_wave.cc +++ b/demo_drivers/linear_wave/two_d_linear_wave/two_d_linear_wave.cc @@ -418,7 +418,7 @@ void LinearWaveProblem::doc_solution(DocInfo& doc_info) // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -433,7 +433,7 @@ void LinearWaveProblem::doc_solution(DocInfo& doc_info) // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); oomph_info << " FILENAME: " << filename << std::endl; some_file.open(filename); @@ -444,7 +444,7 @@ void LinearWaveProblem::doc_solution(DocInfo& doc_info) // Doc error //---------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->compute_error(some_file, @@ -487,7 +487,7 @@ void LinearWaveProblem::unsteady_run() // Open trace file char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); Trace_file.open(filename); // Initialise time diff --git a/demo_drivers/linear_wave/two_d_linear_wave/two_d_linear_wave_flux.cc b/demo_drivers/linear_wave/two_d_linear_wave/two_d_linear_wave_flux.cc index cb6f613961b3..5815e1c7ba1a 100644 --- a/demo_drivers/linear_wave/two_d_linear_wave/two_d_linear_wave_flux.cc +++ b/demo_drivers/linear_wave/two_d_linear_wave/two_d_linear_wave_flux.cc @@ -470,7 +470,7 @@ void LinearWaveProblem::doc_solution(DocInfo& doc_info) // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); @@ -485,7 +485,7 @@ void LinearWaveProblem::doc_solution(DocInfo& doc_info) // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output_fct(some_file,npts,time_pt()->time(), @@ -495,7 +495,7 @@ void LinearWaveProblem::doc_solution(DocInfo& doc_info) // Doc error //---------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->compute_error(some_file, @@ -534,7 +534,7 @@ void LinearWaveProblem::unsteady_run() // Open trace file char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); Trace_file.open(filename); diff --git a/demo_drivers/linear_wave/two_d_linear_wave_adapt/two_d_linear_wave_adapt.cc b/demo_drivers/linear_wave/two_d_linear_wave_adapt/two_d_linear_wave_adapt.cc index 5fb418d3ce23..d62002663923 100644 --- a/demo_drivers/linear_wave/two_d_linear_wave_adapt/two_d_linear_wave_adapt.cc +++ b/demo_drivers/linear_wave/two_d_linear_wave_adapt/two_d_linear_wave_adapt.cc @@ -432,7 +432,7 @@ void LinearWaveProblem::doc_solution(DocInfo& doc_info) // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -448,7 +448,7 @@ void LinearWaveProblem::doc_solution(DocInfo& doc_info) // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output_fct(some_file,npts,time_pt()->time(), @@ -458,7 +458,7 @@ void LinearWaveProblem::doc_solution(DocInfo& doc_info) // Doc error //---------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->compute_error(some_file, @@ -494,7 +494,7 @@ void LinearWaveProblem::unsteady_run() // Open trace file char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); Trace_file.open(filename); // Initialise time diff --git a/demo_drivers/linearised_axisym_navier_stokes/counter_rotating_disks/counter_rotating_disks.cc b/demo_drivers/linearised_axisym_navier_stokes/counter_rotating_disks/counter_rotating_disks.cc index 91205849d6af..2cbfef6e440d 100644 --- a/demo_drivers/linearised_axisym_navier_stokes/counter_rotating_disks/counter_rotating_disks.cc +++ b/demo_drivers/linearised_axisym_navier_stokes/counter_rotating_disks/counter_rotating_disks.cc @@ -155,7 +155,7 @@ class BaseStateProblem : public Problem { // Open trace file char filename[256]; - sprintf(filename,"%s/base_trace_k%i_Re%4.2f.dat", + snprintf(filename, sizeof(filename), "%s/base_trace_k%i_Re%4.2f.dat", doc_info.directory().c_str(), GlobalPhysicalVariables::k, GlobalPhysicalVariables::Re_current); @@ -433,7 +433,7 @@ void BaseStateProblem::doc_solution(DocInfo &doc_info, const unsigned npts = 5; // Open solution output file - sprintf(filename,"%s/base_soln_k%i_Re%4.2f_soln%i.dat", + snprintf(filename, sizeof(filename), "%s/base_soln_k%i_Re%4.2f_soln%i.dat", doc_info.directory().c_str(), GlobalPhysicalVariables::k, GlobalPhysicalVariables::Re_current, @@ -522,7 +522,7 @@ class PerturbedStateProblem : public Problem { // Open trace file char filename[256]; - sprintf(filename,"%s/perturbed_trace_k%i_Re%4.2f.dat", + snprintf(filename, sizeof(filename), "%s/perturbed_trace_k%i_Re%4.2f.dat", doc_info.directory().c_str(), GlobalPhysicalVariables::k, GlobalPhysicalVariables::Re_current); @@ -828,7 +828,7 @@ doc_solution(DocInfo& doc_info,const bool& output_soln) const unsigned npts = 5; // Open solution output file - sprintf(filename,"%s/perturbed_soln_k%i_Re%4.2f_soln%i.dat", + snprintf(filename, sizeof(filename), "%s/perturbed_soln_k%i_Re%4.2f_soln%i.dat", doc_info.directory().c_str(), GlobalPhysicalVariables::k, GlobalPhysicalVariables::Re_current, @@ -891,7 +891,7 @@ class StabilityProblem // Set up stability problem trace files char filename[256]; - sprintf(filename,"%s/power_method_trace_k%i_Re%4.2f.dat", + snprintf(filename, sizeof(filename), "%s/power_method_trace_k%i_Re%4.2f.dat", doc_info.directory().c_str(), GlobalPhysicalVariables::k, GlobalPhysicalVariables::Re_current); @@ -1261,7 +1261,7 @@ int main(int argc, char* argv[]) // Create and initialise global trace file ofstream global_trace; char filename[256]; - sprintf(filename,"%s/global_trace_k%i.dat", + snprintf(filename, sizeof(filename), "%s/global_trace_k%i.dat", doc_info.directory().c_str(), GlobalPhysicalVariables::k); global_trace.open(filename); @@ -1428,7 +1428,7 @@ int main(int argc, char* argv[]) // Create and initialise global trace file ofstream global_trace; char filename[256]; - sprintf(filename,"%s/global_trace_k%i.dat", + snprintf(filename, sizeof(filename), "%s/global_trace_k%i.dat", doc_info.directory().c_str(), GlobalPhysicalVariables::k); global_trace.open(filename); diff --git a/demo_drivers/linearised_axisym_navier_stokes/counter_rotating_disks/counter_rotating_disks_ref.cc b/demo_drivers/linearised_axisym_navier_stokes/counter_rotating_disks/counter_rotating_disks_ref.cc index 0492b424da38..e28ab04fd0ca 100644 --- a/demo_drivers/linearised_axisym_navier_stokes/counter_rotating_disks/counter_rotating_disks_ref.cc +++ b/demo_drivers/linearised_axisym_navier_stokes/counter_rotating_disks/counter_rotating_disks_ref.cc @@ -172,7 +172,7 @@ class BaseStateProblem : public Problem { // Open trace file char filename[256]; - sprintf(filename,"%s/base_trace_k%i_Re%4.2f.dat", + snprintf(filename, sizeof(filename), "%s/base_trace_k%i_Re%4.2f.dat", doc_info.directory().c_str(), GlobalPhysicalVariables::k, GlobalPhysicalVariables::Re_current); @@ -458,7 +458,7 @@ void BaseStateProblem::doc_solution(DocInfo &doc_info, const unsigned npts = 5; // Open solution output file - sprintf(filename,"%s/base_soln_k%i_Re%4.2f_soln%i.dat", + snprintf(filename, sizeof(filename), "%s/base_soln_k%i_Re%4.2f_soln%i.dat", doc_info.directory().c_str(), GlobalPhysicalVariables::k, GlobalPhysicalVariables::Re_current, @@ -576,7 +576,7 @@ class PerturbedStateProblem : public Problem { // Open trace file char filename[256]; - sprintf(filename,"%s/perturbed_trace_k%i_Re%4.2f.dat", + snprintf(filename, sizeof(filename), "%s/perturbed_trace_k%i_Re%4.2f.dat", doc_info.directory().c_str(), GlobalPhysicalVariables::k, GlobalPhysicalVariables::Re_current); @@ -886,7 +886,7 @@ doc_solution(DocInfo& doc_info,const bool& output_soln) const unsigned npts = 5; // Open solution output file - sprintf(filename,"%s/perturbed_soln_k%i_Re%4.2f_soln%i.dat", + snprintf(filename, sizeof(filename), "%s/perturbed_soln_k%i_Re%4.2f_soln%i.dat", doc_info.directory().c_str(), GlobalPhysicalVariables::k, GlobalPhysicalVariables::Re_current, @@ -949,7 +949,7 @@ class StabilityProblem // Set up stability problem trace files char filename[256]; - sprintf(filename,"%s/power_method_trace_k%i_Re%4.2f.dat", + snprintf(filename, sizeof(filename), "%s/power_method_trace_k%i_Re%4.2f.dat", doc_info.directory().c_str(), GlobalPhysicalVariables::k, GlobalPhysicalVariables::Re_current); @@ -1324,7 +1324,7 @@ int main(int argc, char* argv[]) // Create and initialise global trace file ofstream global_trace; char filename[256]; - sprintf(filename,"%s/global_trace_k%i.dat", + snprintf(filename, sizeof(filename), "%s/global_trace_k%i.dat", doc_info.directory().c_str(), GlobalPhysicalVariables::k); global_trace.open(filename); @@ -1496,7 +1496,7 @@ int main(int argc, char* argv[]) // Create and initialise global trace file ofstream global_trace; char filename[256]; - sprintf(filename,"%s/global_trace_k%i.dat", + snprintf(filename, sizeof(filename), "%s/global_trace_k%i.dat", doc_info.directory().c_str(), GlobalPhysicalVariables::k); global_trace.open(filename); diff --git a/demo_drivers/linearised_axisym_navier_stokes/time_periodic_taylor_couette/time_periodic_taylor_couette.cc b/demo_drivers/linearised_axisym_navier_stokes/time_periodic_taylor_couette/time_periodic_taylor_couette.cc index a18ab0e3be12..10e65b91c860 100644 --- a/demo_drivers/linearised_axisym_navier_stokes/time_periodic_taylor_couette/time_periodic_taylor_couette.cc +++ b/demo_drivers/linearised_axisym_navier_stokes/time_periodic_taylor_couette/time_periodic_taylor_couette.cc @@ -168,7 +168,7 @@ class BaseStateProblem : public Problem { // Open trace file char filename1[256]; - sprintf(filename1,"%s/base_trace_epsilon%2.1f_Re%4.2f.dat", + snprintf(filename1, sizeof(filename1), "%s/base_trace_epsilon%2.1f_Re%4.2f.dat", doc_info.directory().c_str(), GlobalPhysicalVariables::Epsilon, GlobalPhysicalVariables::MMC_Re_current); @@ -461,7 +461,7 @@ void BaseStateProblem::doc_solution(DocInfo &doc_info, const unsigned npts = 2;//5; // Open solution output file - sprintf(filename,"%s/base_soln_epsilon%2.1f_Re%4.2f_soln%i.dat", + snprintf(filename, sizeof(filename), "%s/base_soln_epsilon%2.1f_Re%4.2f_soln%i.dat", doc_info.directory().c_str(), GlobalPhysicalVariables::Epsilon, GlobalPhysicalVariables::MMC_Re_current, @@ -552,7 +552,7 @@ class PerturbedStateProblem : public Problem { // Open trace file char filename[256]; - sprintf(filename,"%s/perturbed_trace_epsilon%2.1f_Re%4.2f.dat", + snprintf(filename, sizeof(filename), "%s/perturbed_trace_epsilon%2.1f_Re%4.2f.dat", doc_info.directory().c_str(), GlobalPhysicalVariables::Epsilon, GlobalPhysicalVariables::MMC_Re_current); @@ -830,7 +830,7 @@ doc_solution(DocInfo& doc_info,const bool& output_soln) const unsigned npts = 2;//5; // Open solution output file - sprintf(filename,"%s/perturbed_soln_epsilon%2.1f_Re%4.2f_soln%i.dat", + snprintf(filename, sizeof(filename), "%s/perturbed_soln_epsilon%2.1f_Re%4.2f_soln%i.dat", doc_info.directory().c_str(), GlobalPhysicalVariables::Epsilon, GlobalPhysicalVariables::MMC_Re_current, @@ -896,13 +896,13 @@ class StabilityProblem // Set up stability problem trace files char filename[256]; - sprintf(filename,"%s/periodic_base_flow_trace_epsilon%2.1f_Re%4.2f.dat", + snprintf(filename, sizeof(filename), "%s/periodic_base_flow_trace_epsilon%2.1f_Re%4.2f.dat", doc_info.directory().c_str(), GlobalPhysicalVariables::Epsilon, GlobalPhysicalVariables::MMC_Re_current); Trace_file_periodic_base_flow.open(filename); - sprintf(filename,"%s/power_method_trace_epsilon%2.1f_Re%4.2f.dat", + snprintf(filename, sizeof(filename), "%s/power_method_trace_epsilon%2.1f_Re%4.2f.dat", doc_info.directory().c_str(), GlobalPhysicalVariables::Epsilon, GlobalPhysicalVariables::MMC_Re_current); @@ -1744,7 +1744,7 @@ int main(int argc, char* argv[]) // Create and initialise global trace file ofstream global_trace; char filename[256]; - sprintf(filename,"%s/global_trace_epsilon%2.1f.dat", + snprintf(filename, sizeof(filename), "%s/global_trace_epsilon%2.1f.dat", doc_info.directory().c_str(), GlobalPhysicalVariables::Epsilon); global_trace.open(filename); @@ -1859,7 +1859,7 @@ int main(int argc, char* argv[]) // Create and initialise global trace file ofstream global_trace; char filename[256]; - sprintf(filename,"%s/global_trace_epsilon%2.1f.dat", + snprintf(filename, sizeof(filename), "%s/global_trace_epsilon%2.1f.dat", doc_info.directory().c_str(), GlobalPhysicalVariables::Epsilon); global_trace.open(filename); diff --git a/demo_drivers/linearised_free_surface_axisym_navier_stokes/two_layer_interface_nonaxisym_perturbations/two_layer_interface_nonaxisym_perturbations.cc b/demo_drivers/linearised_free_surface_axisym_navier_stokes/two_layer_interface_nonaxisym_perturbations/two_layer_interface_nonaxisym_perturbations.cc index cc9a4322560b..9858079da6bf 100644 --- a/demo_drivers/linearised_free_surface_axisym_navier_stokes/two_layer_interface_nonaxisym_perturbations/two_layer_interface_nonaxisym_perturbations.cc +++ b/demo_drivers/linearised_free_surface_axisym_navier_stokes/two_layer_interface_nonaxisym_perturbations/two_layer_interface_nonaxisym_perturbations.cc @@ -495,7 +495,7 @@ void BaseStateProblem::doc_solution( const unsigned npts_bulk = 2; // Open solution output file - sprintf(filename, + snprintf(filename, sizeof(filename), "%s/base_soln%i.dat", doc_info_pt->directory().c_str(), doc_info_pt->number()); @@ -567,7 +567,7 @@ class PerturbedStateProblem : public Problem { // Open trace file char filename[256]; - sprintf(filename, + snprintf(filename, sizeof(filename), "%s/perturbed_trace_k%i.dat", doc_info_pt->directory().c_str(), Azimuthal_mode_number); @@ -1316,7 +1316,7 @@ void PerturbedStateProblem:: const unsigned npts_surface = 5; // Open solution output file - sprintf(filename, + snprintf(filename, sizeof(filename), "%s/perturbed_k%i_soln%i.dat", doc_info_pt->directory().c_str(), Azimuthal_mode_number, @@ -1330,7 +1330,7 @@ void PerturbedStateProblem:: some_file.close(); // Open interface solution output file - sprintf(filename, + snprintf(filename, sizeof(filename), "%s/perturbation_to_interface_k%i_soln%i.dat", doc_info_pt->directory().c_str(), Azimuthal_mode_number, @@ -1355,7 +1355,7 @@ void PerturbedStateProblem:: some_file.close(); // Open interface solution output file - sprintf(filename, + snprintf(filename, sizeof(filename), "%s/combined_interface_position_k%i_soln%i.dat", doc_info_pt->directory().c_str(), Azimuthal_mode_number, @@ -1557,7 +1557,7 @@ int main(int argc, char* argv[]) // Create info file ofstream info_file; char info_filename[100]; - sprintf(info_filename, "%s/info.dat", doc_info_pt->directory().c_str()); + snprintf(info_filename, sizeof(info_filename), "%s/info.dat", doc_info_pt->directory().c_str()); info_file.open(info_filename); info_file.close(); diff --git a/demo_drivers/meshing/mesh_from_geompack/convert_geom_file.cc b/demo_drivers/meshing/mesh_from_geompack/convert_geom_file.cc index adc57774c4b7..34d19c566532 100644 --- a/demo_drivers/meshing/mesh_from_geompack/convert_geom_file.cc +++ b/demo_drivers/meshing/mesh_from_geompack/convert_geom_file.cc @@ -98,7 +98,7 @@ infile.close(); unsigned nn=0; char result[20]; - sprintf(result,"%s","mesh.quad"); + snprintf(result, sizeof(result), "%s","mesh.quad"); ofstream outfile(result,ios_base::out); outfile<<"QUAD"<<'\n'; for(unsigned i=0;i::doc_solution(DocInfo& doc_info) // Output boundaries //------------------ - sprintf(filename,"%s/boundaries.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/boundaries.dat",doc_info.directory().c_str()); some_file.open(filename); mesh_pt()->output_boundaries(some_file); some_file.close(); @@ -234,7 +234,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info) // Output solution //---------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -243,7 +243,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info) // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output_fct(some_file,npts,TanhSolnForPoisson::get_exact_u); @@ -253,7 +253,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info) // Doc error //---------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->compute_error(some_file,TanhSolnForPoisson::get_exact_u, diff --git a/demo_drivers/meshing/mesh_from_inline_triangle/mesh_from_inline_triangle.cc b/demo_drivers/meshing/mesh_from_inline_triangle/mesh_from_inline_triangle.cc index af954c48f425..72612766a47b 100644 --- a/demo_drivers/meshing/mesh_from_inline_triangle/mesh_from_inline_triangle.cc +++ b/demo_drivers/meshing/mesh_from_inline_triangle/mesh_from_inline_triangle.cc @@ -438,7 +438,7 @@ UnstructuredPoissonProblem::UnstructuredPoissonProblem() // Open trace file char filename[100]; - sprintf(filename,"RESLT/trace.dat"); + snprintf(filename, sizeof(filename), "RESLT/trace.dat"); Trace_file.open(filename); // Setup equation numbering scheme @@ -543,7 +543,7 @@ void UnstructuredPoissonProblem::doc_solution(const unsigned npts; npts=5; - sprintf(filename,"RESLT/soln%i.dat",Doc_info.number()); + snprintf(filename, sizeof(filename), "RESLT/soln%i.dat",Doc_info.number()); some_file.open(filename); this->My_mesh_pt->output(some_file,npts); some_file << "TEXT X = 22, Y = 92, CS=FRAME T = \"" @@ -552,14 +552,14 @@ void UnstructuredPoissonProblem::doc_solution(const // Output exact solution //---------------------- - sprintf(filename,"RESLT/exact_soln%i.dat",Doc_info.number()); + snprintf(filename, sizeof(filename), "RESLT/exact_soln%i.dat",Doc_info.number()); some_file.open(filename); My_mesh_pt->output_fct(some_file,npts,TanhSolnForPoisson::get_exact_u); some_file.close(); // Output boundaries //------------------ - sprintf(filename,"RESLT/boundaries%i.dat",Doc_info.number()); + snprintf(filename, sizeof(filename), "RESLT/boundaries%i.dat",Doc_info.number()); some_file.open(filename); My_mesh_pt->output_boundaries(some_file); some_file.close(); @@ -568,7 +568,7 @@ void UnstructuredPoissonProblem::doc_solution(const // Doc error and return of the square of the L2 error //--------------------------------------------------- double error,norm,dummy_error,zero_norm; - sprintf(filename,"RESLT/error%i.dat",Doc_info.number()); + snprintf(filename, sizeof(filename), "RESLT/error%i.dat",Doc_info.number()); some_file.open(filename); My_mesh_pt->compute_error(some_file,TanhSolnForPoisson::get_exact_u, error,norm); diff --git a/demo_drivers/meshing/mesh_from_inline_triangle/mesh_from_inline_triangle_no_adapt.cc b/demo_drivers/meshing/mesh_from_inline_triangle/mesh_from_inline_triangle_no_adapt.cc index 93a1c9542709..386a13425226 100644 --- a/demo_drivers/meshing/mesh_from_inline_triangle/mesh_from_inline_triangle_no_adapt.cc +++ b/demo_drivers/meshing/mesh_from_inline_triangle/mesh_from_inline_triangle_no_adapt.cc @@ -416,7 +416,7 @@ UnstructuredPoissonProblem::UnstructuredPoissonProblem() // Open trace file char filename[100]; - sprintf(filename,"RESLT/trace.dat"); + snprintf(filename, sizeof(filename), "RESLT/trace.dat"); Trace_file.open(filename); // Setup equation numbering scheme @@ -521,7 +521,7 @@ void UnstructuredPoissonProblem::doc_solution(const unsigned npts; npts=5; - sprintf(filename,"RESLT/soln%i.dat",Doc_info.number()); + snprintf(filename, sizeof(filename), "RESLT/soln%i.dat",Doc_info.number()); some_file.open(filename); this->My_mesh_pt->output(some_file,npts); some_file << "TEXT X = 22, Y = 92, CS=FRAME T = \"" @@ -530,14 +530,14 @@ void UnstructuredPoissonProblem::doc_solution(const // Output exact solution //---------------------- - sprintf(filename,"RESLT/exact_soln%i.dat",Doc_info.number()); + snprintf(filename, sizeof(filename), "RESLT/exact_soln%i.dat",Doc_info.number()); some_file.open(filename); My_mesh_pt->output_fct(some_file,npts,TanhSolnForPoisson::get_exact_u); some_file.close(); // Output boundaries //------------------ - sprintf(filename,"RESLT/boundaries%i.dat",Doc_info.number()); + snprintf(filename, sizeof(filename), "RESLT/boundaries%i.dat",Doc_info.number()); some_file.open(filename); My_mesh_pt->output_boundaries(some_file); some_file.close(); @@ -546,7 +546,7 @@ void UnstructuredPoissonProblem::doc_solution(const // Doc error and return of the square of the L2 error //--------------------------------------------------- double error,norm,dummy_error,zero_norm; - sprintf(filename,"RESLT/error%i.dat",Doc_info.number()); + snprintf(filename, sizeof(filename), "RESLT/error%i.dat",Doc_info.number()); some_file.open(filename); My_mesh_pt->compute_error(some_file,TanhSolnForPoisson::get_exact_u, error,norm); diff --git a/demo_drivers/meshing/mesh_from_inline_triangle_internal_boundaries/mesh_from_inline_triangle_internal_boundaries.cc b/demo_drivers/meshing/mesh_from_inline_triangle_internal_boundaries/mesh_from_inline_triangle_internal_boundaries.cc index 5545075fad56..405f544f6062 100644 --- a/demo_drivers/meshing/mesh_from_inline_triangle_internal_boundaries/mesh_from_inline_triangle_internal_boundaries.cc +++ b/demo_drivers/meshing/mesh_from_inline_triangle_internal_boundaries/mesh_from_inline_triangle_internal_boundaries.cc @@ -535,7 +535,7 @@ PoissonProblem(PoissonEquations<2>::PoissonSourceFctPt source_fct_pt) // Open trace file char filename[100]; - sprintf(filename,"RESLT/trace.dat"); + snprintf(filename, sizeof(filename), "RESLT/trace.dat"); Trace_file.open(filename); // Setup equation numbering scheme @@ -562,14 +562,14 @@ void PoissonProblem::doc_solution(DocInfo& doc_info) // Output boundaries //------------------ - sprintf(filename,"%s/boundaries.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/boundaries.dat",doc_info.directory().c_str()); some_file.open(filename); mesh_pt()->output_boundaries(some_file); some_file.close(); // Output solution //---------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -578,7 +578,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info) // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output_fct(some_file,npts,TanhSolnForPoisson::get_exact_u); @@ -588,7 +588,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info) // Doc error //---------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->compute_error(some_file,TanhSolnForPoisson::get_exact_u, diff --git a/demo_drivers/meshing/mesh_from_inline_triangle_internal_boundaries/mesh_from_inline_triangle_internal_boundaries_extra.cc b/demo_drivers/meshing/mesh_from_inline_triangle_internal_boundaries/mesh_from_inline_triangle_internal_boundaries_extra.cc index 5bc1ee777a9d..c892d0b0603b 100644 --- a/demo_drivers/meshing/mesh_from_inline_triangle_internal_boundaries/mesh_from_inline_triangle_internal_boundaries_extra.cc +++ b/demo_drivers/meshing/mesh_from_inline_triangle_internal_boundaries/mesh_from_inline_triangle_internal_boundaries_extra.cc @@ -560,7 +560,7 @@ PoissonProblem(PoissonEquations<2>::PoissonSourceFctPt source_fct_pt) // Open trace file char filename[100]; - sprintf(filename,"RESLT/trace.dat"); + snprintf(filename, sizeof(filename), "RESLT/trace.dat"); Trace_file.open(filename); // Setup equation numbering scheme @@ -587,14 +587,14 @@ void PoissonProblem::doc_solution(DocInfo& doc_info) // Output boundaries //------------------ - sprintf(filename,"%s/boundaries.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/boundaries.dat",doc_info.directory().c_str()); some_file.open(filename); mesh_pt()->output_boundaries(some_file); some_file.close(); // Output solution //---------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -603,7 +603,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info) // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output_fct(some_file,npts,TanhSolnForPoisson::get_exact_u); @@ -617,7 +617,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info) for (unsigned r=0;rnregion_element(r); @@ -632,7 +632,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info) // Doc error //---------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->compute_error(some_file,TanhSolnForPoisson::get_exact_u, diff --git a/demo_drivers/meshing/mesh_from_tetgen/mesh_from_tetgen_navier_stokes.cc b/demo_drivers/meshing/mesh_from_tetgen/mesh_from_tetgen_navier_stokes.cc index 75960ef53c04..605f2f6be0aa 100644 --- a/demo_drivers/meshing/mesh_from_tetgen/mesh_from_tetgen_navier_stokes.cc +++ b/demo_drivers/meshing/mesh_from_tetgen/mesh_from_tetgen_navier_stokes.cc @@ -118,7 +118,7 @@ NavierStokesProblem::NavierStokesProblem(DocInfo& doc_info, //Doc the boundaries ofstream some_file; char filename[100]; - sprintf(filename,"boundaries.dat"); + snprintf(filename, sizeof(filename), "boundaries.dat"); some_file.open(filename); mesh_pt()->output_boundaries(some_file); some_file.close(); @@ -213,7 +213,7 @@ void NavierStokesProblem::doc_solution() npts=5; // Output solution - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); diff --git a/demo_drivers/meshing/mesh_from_tetgen/mesh_from_tetgen_poisson.cc b/demo_drivers/meshing/mesh_from_tetgen/mesh_from_tetgen_poisson.cc index 31ed43e27b6d..fd6080071838 100644 --- a/demo_drivers/meshing/mesh_from_tetgen/mesh_from_tetgen_poisson.cc +++ b/demo_drivers/meshing/mesh_from_tetgen/mesh_from_tetgen_poisson.cc @@ -259,7 +259,7 @@ void PoissonProblem::doc_solution(const unsigned& nplot, // Doc local node numbering //------------------------- - sprintf(filename,"%s/node_numbering%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/node_numbering%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); FiniteElement* el_pt=mesh_pt()->finite_element_pt(0); @@ -277,7 +277,7 @@ void PoissonProblem::doc_solution(const unsigned& nplot, // Output boundaries //------------------ - sprintf(filename,"%s/boundaries%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/boundaries%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output_boundaries(some_file); @@ -286,7 +286,7 @@ void PoissonProblem::doc_solution(const unsigned& nplot, // Output solution //---------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,nplot); @@ -295,7 +295,7 @@ void PoissonProblem::doc_solution(const unsigned& nplot, // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output_fct(some_file,nplot,TanhSolnForPoisson::get_exact_u); @@ -304,7 +304,7 @@ void PoissonProblem::doc_solution(const unsigned& nplot, // Doc error //---------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->compute_error(some_file,TanhSolnForPoisson::get_exact_u, diff --git a/demo_drivers/meshing/mesh_from_triangle/mesh_from_triangle_navier_stokes.cc b/demo_drivers/meshing/mesh_from_triangle/mesh_from_triangle_navier_stokes.cc index 1137af118f62..a5bda24f4448 100644 --- a/demo_drivers/meshing/mesh_from_triangle/mesh_from_triangle_navier_stokes.cc +++ b/demo_drivers/meshing/mesh_from_triangle/mesh_from_triangle_navier_stokes.cc @@ -300,14 +300,14 @@ void FlowPastBoxProblem::doc_solution(DocInfo& doc_info) npts=5; // Output solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); some_file.close(); // Get norm of solution - sprintf(filename,"%s/norm%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/norm%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); double norm_soln=0.0; diff --git a/demo_drivers/meshing/mesh_from_triangle/mesh_from_triangle_poisson.cc b/demo_drivers/meshing/mesh_from_triangle/mesh_from_triangle_poisson.cc index f13805803a8d..a1e230abb89b 100644 --- a/demo_drivers/meshing/mesh_from_triangle/mesh_from_triangle_poisson.cc +++ b/demo_drivers/meshing/mesh_from_triangle/mesh_from_triangle_poisson.cc @@ -309,7 +309,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info) // Output boundaries //------------------ - sprintf(filename,"%s/boundaries.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/boundaries.dat",doc_info.directory().c_str()); some_file.open(filename); mesh_pt()->output_boundaries(some_file); some_file.close(); @@ -317,7 +317,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info) // Output solution //---------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -326,7 +326,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info) // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output_fct(some_file,npts,TanhSolnForPoisson::get_exact_u); @@ -336,7 +336,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info) // Doc error //---------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->compute_error(some_file,TanhSolnForPoisson::get_exact_u, @@ -347,7 +347,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info) // Get norm of solution - sprintf(filename,"%s/norm%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/norm%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); double norm_soln=0.0; diff --git a/demo_drivers/meshing/mesh_from_vmtk/create_fluid_and_solid_surface_mesh_from_fluid_xda_mesh.cc b/demo_drivers/meshing/mesh_from_vmtk/create_fluid_and_solid_surface_mesh_from_fluid_xda_mesh.cc index 441c665d08b7..14444e3add2e 100644 --- a/demo_drivers/meshing/mesh_from_vmtk/create_fluid_and_solid_surface_mesh_from_fluid_xda_mesh.cc +++ b/demo_drivers/meshing/mesh_from_vmtk/create_fluid_and_solid_surface_mesh_from_fluid_xda_mesh.cc @@ -765,9 +765,9 @@ int main() char fluid_filename[100]; char solid_filename[100]; - sprintf(xda_filename,"%s.xda", input_filename.c_str()); - sprintf(fluid_filename,"fluid_%s.poly", input_filename.c_str()); - sprintf(solid_filename,"solid_%s.poly", input_filename.c_str()); + snprintf(xda_filename, sizeof(xda_filename), "%s.xda", input_filename.c_str()); + snprintf(fluid_filename, sizeof(fluid_filename), "fluid_%s.poly", input_filename.c_str()); + snprintf(solid_filename, sizeof(solid_filename), "solid_%s.poly", input_filename.c_str()); create_fluid_and_solid_surface_mesh_from_fluid_xda_mesh( xda_filename, fluid_filename, solid_filename, d,do_multi_boundary_ids); diff --git a/demo_drivers/meshing/mesh_from_xfig_triangle/fig2poly.cc b/demo_drivers/meshing/mesh_from_xfig_triangle/fig2poly.cc index 05c1cea2ce3f..0605571d38cf 100644 --- a/demo_drivers/meshing/mesh_from_xfig_triangle/fig2poly.cc +++ b/demo_drivers/meshing/mesh_from_xfig_triangle/fig2poly.cc @@ -297,7 +297,7 @@ int main(int argc, char* argv[]) // Output points in pslg format //----------------------------- char filename[100]; - sprintf(filename,"%s.poly",argv[1]); + snprintf(filename, sizeof(filename), "%s.poly",argv[1]); ofstream poly_file(filename); { poly_file diff --git a/demo_drivers/meshing/mesh_from_xfig_triangle/mesh_from_xfig_navier_stokes.cc b/demo_drivers/meshing/mesh_from_xfig_triangle/mesh_from_xfig_navier_stokes.cc index 60165eaa346e..da04026c9a22 100644 --- a/demo_drivers/meshing/mesh_from_xfig_triangle/mesh_from_xfig_navier_stokes.cc +++ b/demo_drivers/meshing/mesh_from_xfig_triangle/mesh_from_xfig_navier_stokes.cc @@ -210,7 +210,7 @@ void FlowPastBoxProblem::doc_solution(DocInfo& doc_info) npts=5; // Output solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); diff --git a/demo_drivers/meshing/mesh_from_xfig_triangle/mesh_from_xfig_poisson.cc b/demo_drivers/meshing/mesh_from_xfig_triangle/mesh_from_xfig_poisson.cc index d03b0737eaf2..2400a27c47cb 100644 --- a/demo_drivers/meshing/mesh_from_xfig_triangle/mesh_from_xfig_poisson.cc +++ b/demo_drivers/meshing/mesh_from_xfig_triangle/mesh_from_xfig_poisson.cc @@ -258,7 +258,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info) // Output boundaries //------------------ - sprintf(filename,"%s/boundaries.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/boundaries.dat",doc_info.directory().c_str()); some_file.open(filename); mesh_pt()->output_boundaries(some_file); some_file.close(); @@ -266,7 +266,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info) // Output solution //---------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -279,7 +279,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info) // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output_fct(some_file,npts,TanhSolnForPoisson::get_exact_u); @@ -289,7 +289,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info) // Doc error //---------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->compute_error(some_file,TanhSolnForPoisson::get_exact_u, diff --git a/demo_drivers/meshing/quad_from_triangle_mesh/adaptive_moving_block_navier_stokes.cc b/demo_drivers/meshing/quad_from_triangle_mesh/adaptive_moving_block_navier_stokes.cc index 29e2393767a2..5951e7318da7 100644 --- a/demo_drivers/meshing/quad_from_triangle_mesh/adaptive_moving_block_navier_stokes.cc +++ b/demo_drivers/meshing/quad_from_triangle_mesh/adaptive_moving_block_navier_stokes.cc @@ -23,271 +23,271 @@ //LIC// The authors may be contacted at oomph-lib@maths.man.ac.uk. //LIC// //LIC//==================================================================== -//Driver for 2D moving block - -//Generic includes -#include "generic.h" -#include "navier_stokes.h" -#include "poisson.h" - -// Header -#include "meshes/quad_from_triangle_mesh.h" - -using namespace std; -using namespace oomph; - - -//////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////// - - -//==start_of_namespace============================== -/// Namespace for physical parameters -//================================================== -namespace Global_Physical_Variables -{ - - /// Reynolds number - double Re=50.0; - -} // end_of_namespace - - -//////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////// - - -//==start_of_problem_class============================================ -/// Moving block problem -//==================================================================== -template -class MovingBlockProblem : public Problem -{ - -public: - - /// Constructor - MovingBlockProblem(); - - /// Destructor (empty) - ~MovingBlockProblem(){} - - /// Fix pressure in element e at pressure dof pdof and set to pvalue - void fix_pressure(const unsigned &e,const unsigned &pdof,const double &pvalue) - { - // Cast to full element type and fix the pressure at that element - dynamic_cast(mesh_pt()->element_pt(e))->fix_pressure(pdof,pvalue); - } // end of fix_pressure - - /// Update the problem specs before solve. - /// Re-set velocity boundary conditions just to be on the safe side... - void actions_before_newton_solve() - { - // No flow along the boundaries - unsigned num_bound=mesh_pt()->nboundary(); - for(unsigned ibound=1;iboundnboundary_node(ibound); - for (unsigned inod=0;inodboundary_node_pt(ibound,inod)->set_value(i,0.0); - } - } - } - - // Setup vertical flow along boundary 1: - unsigned ibound=1; - unsigned num_nod=mesh_pt()->nboundary_node(ibound); - for (unsigned inod=0;inodboundary_node_pt(ibound,inod)->set_value(0,0.0); - mesh_pt()->boundary_node_pt(ibound,inod)->set_value(1,1.0); - } - - } // end_of_actions_before_newton_solve - - /// Update the after solve (empty) - void actions_after_newton_solve(){} - - /// After adaptation: Unpin pressure and pin redudant pressure dofs. - void actions_after_adapt() - { - // Unpin all pressure dofs - RefineableNavierStokesEquations<2>:: - unpin_all_pressure_dofs(mesh_pt()->element_pt()); - - // Pin redundant pressure dofs - RefineableNavierStokesEquations<2>:: - pin_redundant_nodal_pressures(mesh_pt()->element_pt()); - - // Now set the first pressure dof in the first element to 0.0 - fix_pressure(0,0,0.0); - } // end_of_actions_after_adapt - - /// Doc the solution - void doc_solution(DocInfo& doc_info); - -private: - - /// Pointer to the "bulk" mesh - MESH* Bulk_mesh_pt; - -}; // end_of_problem_class - - -//==start_of_constructor================================================== -/// Constructor for MovingBlock problem -//======================================================================== -template -MovingBlockProblem::MovingBlockProblem() -{ - // Set the maximum residuals value - Problem::Max_residuals=1000.0; - - // Convert arguments to strings that specify the input file names - string node_file_name("box_hole.1.node"); - string element_file_name("box_hole.1.ele"); - string poly_file_name("box_hole.1.poly"); - - // Create the bulk mesh - Bulk_mesh_pt=new MESH(node_file_name,element_file_name,poly_file_name); - - // Create/set error estimator - Bulk_mesh_pt->spatial_error_estimator_pt()=new Z2ErrorEstimator; - - // Choose error tolerances to force some uniform refinement - Bulk_mesh_pt->min_permitted_error()=4e-07; - Bulk_mesh_pt->max_permitted_error()=1e-06; - - // Create the main mesh - add_sub_mesh(Bulk_mesh_pt); - - // Build the entire mesh from its submeshes - build_global_mesh(); - - // Output the mesh (just to make sure everything looks good!) - unsigned npts=2; - std::ofstream outfile; - outfile.open("RESLT/mesh.dat"); - mesh_pt()->output(outfile,npts); - outfile.close(); - mesh_pt()->output_boundaries("RESLT/mesh_boundaries.dat"); - - // Set the boundary conditions for this problem: All nodes are - // free by default -- just pin the ones that have Dirichlet conditions - // here. - unsigned num_bound = mesh_pt()->nboundary(); - for(unsigned ibound=0;iboundnboundary_node(ibound); - for (unsigned inod=0;inodboundary_node_pt(ibound,inod)->pin(i); - } - } - } // end loop over boundaries - - - // Complete the build of all elements so they are fully functional: - - // Find number of elements in mesh - unsigned n_element = mesh_pt()->nelement(); - - // Loop over the elements to set up element-specific - // things that cannot be handled by constructor - for(unsigned e=0;e(mesh_pt()->element_pt(e)); - - // Set the Reynolds number - el_pt->re_pt() = &Global_Physical_Variables::Re; - } // end loop over elements - - // Now set the first pressure value in element 0 to 0.0 - fix_pressure(0,0,0.0); - - // Setup equation numbering scheme - cout <<"Number of equations: " << assign_eqn_numbers() << std::endl; - -} // end_of_constructor - - -//==start_of_doc_solution================================================= -/// Doc the solution -//======================================================================== -template -void MovingBlockProblem::doc_solution(DocInfo& doc_info) -{ - ofstream some_file; - char filename[100]; - - // Number of plot points - unsigned npts; - npts=2; - - // Output solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), - doc_info.number()); - some_file.open(filename); - mesh_pt()->output(some_file,npts); - some_file.close(); -} // end_of_doc_solution - - - - - -//////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////// - - - - - - - -//==start_of_main====================================================== -/// Driver for MovingBlock test problem -- test drive -/// with two different types of element. -//===================================================================== -int main() -{ - // Label for output - DocInfo doc_info; - - // Set output directory - doc_info.set_directory("RESLT"); - - // Step number - doc_info.number()=0; - - // Typedef the ELEMENT and MESH type - typedef RefineableQCrouzeixRaviartElement<2> ELEMENT; - typedef RefineableQuadFromTriangleMesh MESH; - - // Build the problem with QCrouzeixRaviartElements - MovingBlockProblem problem; - - std::cout << "Doing QCrouzeixRaviartElement<2>" << std::endl; - - // Maximum number of adaptations - unsigned max_adapt=2; - - // Solve the problem - problem.newton_solve(max_adapt); - - // Output the solution - problem.doc_solution(doc_info); - -} // end_of_main - +//Driver for 2D moving block + +//Generic includes +#include "generic.h" +#include "navier_stokes.h" +#include "poisson.h" + +// Header +#include "meshes/quad_from_triangle_mesh.h" + +using namespace std; +using namespace oomph; + + +//////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////// + + +//==start_of_namespace============================== +/// Namespace for physical parameters +//================================================== +namespace Global_Physical_Variables +{ + + /// Reynolds number + double Re=50.0; + +} // end_of_namespace + + +//////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////// + + +//==start_of_problem_class============================================ +/// Moving block problem +//==================================================================== +template +class MovingBlockProblem : public Problem +{ + +public: + + /// Constructor + MovingBlockProblem(); + + /// Destructor (empty) + ~MovingBlockProblem(){} + + /// Fix pressure in element e at pressure dof pdof and set to pvalue + void fix_pressure(const unsigned &e,const unsigned &pdof,const double &pvalue) + { + // Cast to full element type and fix the pressure at that element + dynamic_cast(mesh_pt()->element_pt(e))->fix_pressure(pdof,pvalue); + } // end of fix_pressure + + /// Update the problem specs before solve. + /// Re-set velocity boundary conditions just to be on the safe side... + void actions_before_newton_solve() + { + // No flow along the boundaries + unsigned num_bound=mesh_pt()->nboundary(); + for(unsigned ibound=1;iboundnboundary_node(ibound); + for (unsigned inod=0;inodboundary_node_pt(ibound,inod)->set_value(i,0.0); + } + } + } + + // Setup vertical flow along boundary 1: + unsigned ibound=1; + unsigned num_nod=mesh_pt()->nboundary_node(ibound); + for (unsigned inod=0;inodboundary_node_pt(ibound,inod)->set_value(0,0.0); + mesh_pt()->boundary_node_pt(ibound,inod)->set_value(1,1.0); + } + + } // end_of_actions_before_newton_solve + + /// Update the after solve (empty) + void actions_after_newton_solve(){} + + /// After adaptation: Unpin pressure and pin redudant pressure dofs. + void actions_after_adapt() + { + // Unpin all pressure dofs + RefineableNavierStokesEquations<2>:: + unpin_all_pressure_dofs(mesh_pt()->element_pt()); + + // Pin redundant pressure dofs + RefineableNavierStokesEquations<2>:: + pin_redundant_nodal_pressures(mesh_pt()->element_pt()); + + // Now set the first pressure dof in the first element to 0.0 + fix_pressure(0,0,0.0); + } // end_of_actions_after_adapt + + /// Doc the solution + void doc_solution(DocInfo& doc_info); + +private: + + /// Pointer to the "bulk" mesh + MESH* Bulk_mesh_pt; + +}; // end_of_problem_class + + +//==start_of_constructor================================================== +/// Constructor for MovingBlock problem +//======================================================================== +template +MovingBlockProblem::MovingBlockProblem() +{ + // Set the maximum residuals value + Problem::Max_residuals=1000.0; + + // Convert arguments to strings that specify the input file names + string node_file_name("box_hole.1.node"); + string element_file_name("box_hole.1.ele"); + string poly_file_name("box_hole.1.poly"); + + // Create the bulk mesh + Bulk_mesh_pt=new MESH(node_file_name,element_file_name,poly_file_name); + + // Create/set error estimator + Bulk_mesh_pt->spatial_error_estimator_pt()=new Z2ErrorEstimator; + + // Choose error tolerances to force some uniform refinement + Bulk_mesh_pt->min_permitted_error()=4e-07; + Bulk_mesh_pt->max_permitted_error()=1e-06; + + // Create the main mesh + add_sub_mesh(Bulk_mesh_pt); + + // Build the entire mesh from its submeshes + build_global_mesh(); + + // Output the mesh (just to make sure everything looks good!) + unsigned npts=2; + std::ofstream outfile; + outfile.open("RESLT/mesh.dat"); + mesh_pt()->output(outfile,npts); + outfile.close(); + mesh_pt()->output_boundaries("RESLT/mesh_boundaries.dat"); + + // Set the boundary conditions for this problem: All nodes are + // free by default -- just pin the ones that have Dirichlet conditions + // here. + unsigned num_bound = mesh_pt()->nboundary(); + for(unsigned ibound=0;iboundnboundary_node(ibound); + for (unsigned inod=0;inodboundary_node_pt(ibound,inod)->pin(i); + } + } + } // end loop over boundaries + + + // Complete the build of all elements so they are fully functional: + + // Find number of elements in mesh + unsigned n_element = mesh_pt()->nelement(); + + // Loop over the elements to set up element-specific + // things that cannot be handled by constructor + for(unsigned e=0;e(mesh_pt()->element_pt(e)); + + // Set the Reynolds number + el_pt->re_pt() = &Global_Physical_Variables::Re; + } // end loop over elements + + // Now set the first pressure value in element 0 to 0.0 + fix_pressure(0,0,0.0); + + // Setup equation numbering scheme + cout <<"Number of equations: " << assign_eqn_numbers() << std::endl; + +} // end_of_constructor + + +//==start_of_doc_solution================================================= +/// Doc the solution +//======================================================================== +template +void MovingBlockProblem::doc_solution(DocInfo& doc_info) +{ + ofstream some_file; + char filename[100]; + + // Number of plot points + unsigned npts; + npts=2; + + // Output solution + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), + doc_info.number()); + some_file.open(filename); + mesh_pt()->output(some_file,npts); + some_file.close(); +} // end_of_doc_solution + + + + + +//////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////// + + + + + + + +//==start_of_main====================================================== +/// Driver for MovingBlock test problem -- test drive +/// with two different types of element. +//===================================================================== +int main() +{ + // Label for output + DocInfo doc_info; + + // Set output directory + doc_info.set_directory("RESLT"); + + // Step number + doc_info.number()=0; + + // Typedef the ELEMENT and MESH type + typedef RefineableQCrouzeixRaviartElement<2> ELEMENT; + typedef RefineableQuadFromTriangleMesh MESH; + + // Build the problem with QCrouzeixRaviartElements + MovingBlockProblem problem; + + std::cout << "Doing QCrouzeixRaviartElement<2>" << std::endl; + + // Maximum number of adaptations + unsigned max_adapt=2; + + // Solve the problem + problem.newton_solve(max_adapt); + + // Output the solution + problem.doc_solution(doc_info); + +} // end_of_main + diff --git a/demo_drivers/meshing/quad_from_triangle_mesh/adaptive_unstructured_scattering_quad.cc b/demo_drivers/meshing/quad_from_triangle_mesh/adaptive_unstructured_scattering_quad.cc index cd02f4600917..0dbaa0eda6b1 100644 --- a/demo_drivers/meshing/quad_from_triangle_mesh/adaptive_unstructured_scattering_quad.cc +++ b/demo_drivers/meshing/quad_from_triangle_mesh/adaptive_unstructured_scattering_quad.cc @@ -611,7 +611,7 @@ void ScatteringProblem::doc_solution(DocInfo& // Compute/output the radiated power //---------------------------------- - sprintf(filename,"%s/power%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/power%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); @@ -629,7 +629,7 @@ void ScatteringProblem::doc_solution(DocInfo& // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); @@ -637,14 +637,14 @@ void ScatteringProblem::doc_solution(DocInfo& // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output_fct(some_file,npts,GlobalParameters::get_exact_u); some_file.close(); double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->compute_error(some_file,GlobalParameters::get_exact_u, @@ -664,11 +664,11 @@ void ScatteringProblem::doc_solution(DocInfo& // unsigned nstep=40; // for (unsigned i=0;i::UnstructuredSolidProblem() : // Open trace file char filename[100]; - sprintf(filename,"%s/trace.dat",Doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",Doc_info.directory().c_str()); Trace_file.open(filename); } //end constructor @@ -425,7 +425,7 @@ void UnstructuredSolidProblem::doc_solution() // Output solution //---------------- - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Solid_mesh_pt->output(some_file,npts); @@ -433,7 +433,7 @@ void UnstructuredSolidProblem::doc_solution() // Output traction //---------------- - sprintf(filename,"%s/traction%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/traction%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Traction_mesh_pt->output(some_file,npts); @@ -441,7 +441,7 @@ void UnstructuredSolidProblem::doc_solution() // Output boundaries //------------------ - sprintf(filename,"%s/boundaries.dat",Doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/boundaries.dat",Doc_info.directory().c_str()); some_file.open(filename); Solid_mesh_pt->output_boundaries(some_file); some_file.close(); diff --git a/demo_drivers/meshing/quad_from_triangle_mesh/unstructured_two_d_solid.cc b/demo_drivers/meshing/quad_from_triangle_mesh/unstructured_two_d_solid.cc index 07393498cb7e..d4bf7b766c83 100644 --- a/demo_drivers/meshing/quad_from_triangle_mesh/unstructured_two_d_solid.cc +++ b/demo_drivers/meshing/quad_from_triangle_mesh/unstructured_two_d_solid.cc @@ -379,7 +379,7 @@ UnstructuredSolidProblem::UnstructuredSolidProblem() // Open trace file char filename[100]; - sprintf(filename,"%s/trace.dat",Doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",Doc_info.directory().c_str()); Trace_file.open(filename); } //end constructor @@ -400,7 +400,7 @@ void UnstructuredSolidProblem::doc_solution() // Output solution //---------------- - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Solid_mesh_pt->output(some_file,npts); @@ -408,7 +408,7 @@ void UnstructuredSolidProblem::doc_solution() // Output traction //---------------- - sprintf(filename,"%s/traction%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/traction%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Traction_mesh_pt->output(some_file,npts); @@ -416,7 +416,7 @@ void UnstructuredSolidProblem::doc_solution() // Output boundaries //------------------ - sprintf(filename,"%s/boundaries.dat",Doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/boundaries.dat",Doc_info.directory().c_str()); some_file.open(filename); Solid_mesh_pt->output_boundaries(some_file); some_file.close(); diff --git a/demo_drivers/mpi/distribution/adaptive_driven_cavity/adaptive_driven_cavity.cc b/demo_drivers/mpi/distribution/adaptive_driven_cavity/adaptive_driven_cavity.cc index 3fbcfe26e42f..e7a0ff8dd490 100644 --- a/demo_drivers/mpi/distribution/adaptive_driven_cavity/adaptive_driven_cavity.cc +++ b/demo_drivers/mpi/distribution/adaptive_driven_cavity/adaptive_driven_cavity.cc @@ -244,7 +244,7 @@ void RefineableDrivenCavityProblem::doc_solution(DocInfo& doc_info) int my_rank=this->communicator_pt()->my_rank(); // Output solution - sprintf(filename,"%s/soln%i_on_proc%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i_on_proc%i.dat",doc_info.directory().c_str(), doc_info.number(),my_rank); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -301,7 +301,7 @@ int main(int argc, char **argv) // Write partition to disk std::ofstream output_file; char filename[100]; - sprintf(filename,"out_adaptive_cavity_1_partition.dat"); + snprintf(filename, sizeof(filename), "out_adaptive_cavity_1_partition.dat"); output_file.open(filename); for (unsigned e=0;enelement(); Vector element_partition(n_element); - sprintf(filename,"adaptive_cavity_2_partition.dat"); + snprintf(filename, sizeof(filename), "adaptive_cavity_2_partition.dat"); input_file.open(filename); std::string input_string; for (unsigned e=0;e::doc_solution( int my_rank=this->communicator_pt()->my_rank(); // Output solution - sprintf(filename,"%s/soln%i_on_proc%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i_on_proc%i.dat",Doc_info.directory().c_str(), Doc_info.number(),my_rank); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -280,7 +280,7 @@ void RefineableDrivenCavityProblem::doc_solution( // Output solution - sprintf(filename,"%s/soln_with_haloes%i_on_proc%i.dat", + snprintf(filename, sizeof(filename), "%s/soln_with_haloes%i_on_proc%i.dat", Doc_info.directory().c_str(), Doc_info.number(),my_rank); some_file.open(filename); @@ -295,7 +295,7 @@ void RefineableDrivenCavityProblem::doc_solution( mesh_pt()->doc_mesh_distribution(Doc_info); // Output boundaries - sprintf(filename,"%s/boundaries%i_on_proc%i.dat", + snprintf(filename, sizeof(filename), "%s/boundaries%i_on_proc%i.dat", Doc_info.directory().c_str(), Doc_info.number(),my_rank); some_file.open(filename); @@ -323,12 +323,12 @@ void RefineableDrivenCavityProblem::doc_solution( { - sprintf(filename,"%s/soln_non_halo_nodes%i_on_proc%i.dat", + snprintf(filename, sizeof(filename), "%s/soln_non_halo_nodes%i_on_proc%i.dat", Doc_info.directory().c_str(), Doc_info.number(),my_rank); some_file.open(filename); - sprintf(filename,"%s/ndof%i_on_proc%i.dat", + snprintf(filename, sizeof(filename), "%s/ndof%i_on_proc%i.dat", Doc_info.directory().c_str(), Doc_info.number(),my_rank); some_file2.open(filename); @@ -389,7 +389,7 @@ int main(int argc, char **argv) // Define processor-labeled output file for all on-screen stuff std::ofstream output_stream; char filename[100]; - sprintf(filename,"OUTPUT.%i",MPI_Helpers::communicator_pt()->my_rank()); + snprintf(filename, sizeof(filename), "OUTPUT.%i",MPI_Helpers::communicator_pt()->my_rank()); output_stream.open(filename); oomph_info.stream_pt() = &output_stream; OomphLibWarning::set_stream_pt(&output_stream); diff --git a/demo_drivers/mpi/distribution/airy_cantilever/airy_cantilever2.cc b/demo_drivers/mpi/distribution/airy_cantilever/airy_cantilever2.cc index 27c70eea7213..16e4e789186a 100644 --- a/demo_drivers/mpi/distribution/airy_cantilever/airy_cantilever2.cc +++ b/demo_drivers/mpi/distribution/airy_cantilever/airy_cantilever2.cc @@ -413,7 +413,7 @@ void CantileverProblem::doc_solution() // Output shape of and stress in deformed body //-------------------------------------------- - sprintf(filename,"%s/soln%i_on_proc%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i_on_proc%i.dat",Doc_info.directory().c_str(), Doc_info.number(),this->communicator_pt()->my_rank()); some_file.open(filename); mesh_pt()->output(some_file,n_plot); @@ -422,7 +422,7 @@ void CantileverProblem::doc_solution() // Output St. Venant solution //--------------------------- - sprintf(filename,"%s/exact_soln%i_on_proc%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i_on_proc%i.dat",Doc_info.directory().c_str(), Doc_info.number(),this->communicator_pt()->my_rank()); some_file.open(filename); @@ -526,16 +526,16 @@ void CantileverProblem::run_it(const unsigned& i_case) char dirname[100]; #ifdef REFINE - sprintf(dirname,"RESLT_refine%i",i_case); + snprintf(dirname, sizeof(dirname), "RESLT_refine%i",i_case); #else - sprintf(dirname,"RESLT_norefine%i",i_case); + snprintf(dirname, sizeof(dirname), "RESLT_norefine%i",i_case); #endif Doc_info.set_directory(dirname); // Open trace file char filename[100]; - sprintf(filename,"%s/trace_on_proc%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/trace_on_proc%i.dat",Doc_info.directory().c_str(), this->communicator_pt()->my_rank()); Trace_file.open(filename); @@ -650,7 +650,7 @@ int main(int argc, char **argv) // Get the partition from file unsigned n_partition=problem.mesh_pt()->nelement(); Vector element_partition(n_partition); - sprintf(filename,"airy_cantilever_%i_partition.dat",0+i*ncase); + snprintf(filename, sizeof(filename), "airy_cantilever_%i_partition.dat",0+i*ncase); input_file.open(filename); std::string input_string; for (unsigned e=0;enelement(); Vector element_partition(n_partition); - sprintf(filename,"airy_cantilever_%i_partition.dat",0+i*ncase); + snprintf(filename, sizeof(filename), "airy_cantilever_%i_partition.dat",0+i*ncase); input_file.open(filename); std::string input_string; for (unsigned e=0;enelement(); Vector element_partition(n_partition); - sprintf(filename,"airy_cantilever_%i_partition.dat",1+i*ncase); + snprintf(filename, sizeof(filename), "airy_cantilever_%i_partition.dat",1+i*ncase); input_file.open(filename); std::string input_string; for (unsigned e=0;enelement(); Vector element_partition(n_partition); - sprintf(filename,"airy_cantilever_%i_partition.dat",1+i*ncase); + snprintf(filename, sizeof(filename), "airy_cantilever_%i_partition.dat",1+i*ncase); input_file.open(filename); std::string input_string; for (unsigned e=0;enelement(); Vector element_partition(n_partition); - sprintf(filename,"airy_cantilever_%i_partition.dat",2+i*ncase); + snprintf(filename, sizeof(filename), "airy_cantilever_%i_partition.dat",2+i*ncase); input_file.open(filename); std::string input_string; for (unsigned e=0;enelement(); Vector element_partition(n_partition); - sprintf(filename,"airy_cantilever_%i_partition.dat",2+i*ncase); + snprintf(filename, sizeof(filename), "airy_cantilever_%i_partition.dat",2+i*ncase); input_file.open(filename); std::string input_string; for (unsigned e=0;enelement(); Vector element_partition(n_partition); - sprintf(filename,"airy_cantilever_%i_partition.dat",3+i*ncase); + snprintf(filename, sizeof(filename), "airy_cantilever_%i_partition.dat",3+i*ncase); input_file.open(filename); std::string input_string; for (unsigned e=0;enelement(); Vector element_partition(n_partition); - sprintf(filename,"airy_cantilever_%i_partition.dat",3+i*ncase); + snprintf(filename, sizeof(filename), "airy_cantilever_%i_partition.dat",3+i*ncase); input_file.open(filename); std::string input_string; for (unsigned e=0;enelement(); Vector element_partition(n_partition); - sprintf(filename,"airy_cantilever_%i_partition.dat",4+i*ncase); + snprintf(filename, sizeof(filename), "airy_cantilever_%i_partition.dat",4+i*ncase); input_file.open(filename); std::string input_string; for (unsigned e=0;enelement(); Vector element_partition(n_partition); - sprintf(filename,"airy_cantilever_%i_partition.dat",4+i*ncase); + snprintf(filename, sizeof(filename), "airy_cantilever_%i_partition.dat",4+i*ncase); input_file.open(filename); std::string input_string; for (unsigned e=0;e::solve_system() //Output data at each step //Create the filename, including the array index - /*sprintf(filename,"step%g_%g.dat",Length,Re); + /*snprintf(filename, sizeof(filename), "step%g_%g.dat",Length,Re); //Actually, write the data file.open(filename); mesh_pt()->output(file,5); diff --git a/demo_drivers/mpi/distribution/circular_driven_cavity/circular_driven_cavity.cc b/demo_drivers/mpi/distribution/circular_driven_cavity/circular_driven_cavity.cc index 1689250a791c..0df2d9e1b299 100644 --- a/demo_drivers/mpi/distribution/circular_driven_cavity/circular_driven_cavity.cc +++ b/demo_drivers/mpi/distribution/circular_driven_cavity/circular_driven_cavity.cc @@ -287,7 +287,7 @@ void QuarterCircleDrivenCavityProblem::doc_solution(DocInfo& doc_info) // Output solution - sprintf(filename,"%s/soln%i_on_proc%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i_on_proc%i.dat",doc_info.directory().c_str(), doc_info.number(),this->communicator_pt()->my_rank()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -359,7 +359,7 @@ int main(int argc, char **argv) // Get the partition to be used from file unsigned n_partition=problem.mesh_pt()->nelement(); Vector element_partition(n_partition); - sprintf(filename,"circular_cavity_1_partition.dat"); + snprintf(filename, sizeof(filename), "circular_cavity_1_partition.dat"); input_file.open(filename); std::string input_string; for (unsigned e=0;enelement(); Vector element_partition(n_partition); - sprintf(filename,"circular_cavity_2_partition.dat"); + snprintf(filename, sizeof(filename), "circular_cavity_2_partition.dat"); input_file.open(filename); std::string input_string; for (unsigned e=0;e::solve() //Open an output trace file char filename[100]; - sprintf(filename,"trace_on_proc%i.dat",this->communicator_pt()->my_rank()); + snprintf(filename, sizeof(filename), "trace_on_proc%i.dat",this->communicator_pt()->my_rank()); ofstream trace(filename); //Change in displacemenet @@ -668,7 +668,7 @@ void ShellProblem::solve() trace.close(); //Output the tube shape in the most strongly collapsed configuration - sprintf(filename,"final_shape_on_proc%i.dat", + snprintf(filename, sizeof(filename), "final_shape_on_proc%i.dat", this->communicator_pt()->my_rank()); ofstream file(filename); solid_mesh_pt()->output(file,5); @@ -703,7 +703,7 @@ void ShellProblem::solve() double ds = -0.5; //Open a different trace file - sprintf(filename,"trace_disp_on_proc%i.dat", + snprintf(filename, sizeof(filename), "trace_disp_on_proc%i.dat", this->communicator_pt()->my_rank()); trace.open(filename); //Take fifteen continuation steps diff --git a/demo_drivers/mpi/distribution/eigenproblem/harmonic.cc b/demo_drivers/mpi/distribution/eigenproblem/harmonic.cc index a2f8a5c3b6fd..cc242325102c 100644 --- a/demo_drivers/mpi/distribution/eigenproblem/harmonic.cc +++ b/demo_drivers/mpi/distribution/eigenproblem/harmonic.cc @@ -416,7 +416,7 @@ void HarmonicProblem::doc_solution(const unsigned& label) npts=5; // Output solution with specified number of plot points per element - sprintf(filename,"soln%i_on_proc%i.dat",label, + snprintf(filename, sizeof(filename), "soln%i_on_proc%i.dat",label, this->communicator_pt()->my_rank()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -514,7 +514,7 @@ solve(const unsigned& label) this->doc_solution(label); char filename[100]; - sprintf(filename,"eigenvalues%i_on_proc%i.dat",label, + snprintf(filename, sizeof(filename), "eigenvalues%i_on_proc%i.dat",label, this->communicator_pt()->my_rank()); //Open an output file for the sorted eigenvalues diff --git a/demo_drivers/mpi/distribution/fish_poisson/fish_poisson.cc b/demo_drivers/mpi/distribution/fish_poisson/fish_poisson.cc index 7ebf7225f38b..c0c5a3fb27da 100644 --- a/demo_drivers/mpi/distribution/fish_poisson/fish_poisson.cc +++ b/demo_drivers/mpi/distribution/fish_poisson/fish_poisson.cc @@ -184,7 +184,7 @@ void RefineableFishPoissonProblem::doc_solution(DocInfo& doc_info) npts=5; // Output solution - sprintf(filename,"%s/soln%i_on_proc%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i_on_proc%i.dat",doc_info.directory().c_str(), doc_info.number(),this->communicator_pt()->my_rank()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -263,7 +263,7 @@ void solve_with_incremental_adaptation() // Get the partition to be used from file unsigned n_partition=problem.mesh_pt()->nelement(); Vector element_partition(n_partition,0); - sprintf(filename,"fish_incremental_partition.dat"); + snprintf(filename, sizeof(filename), "fish_incremental_partition.dat"); input_file.open(filename); std::string input_string; for (unsigned e=0;enelement(); Vector element_partition(n_partition,0); - sprintf(filename,"fish_fully_automatic_partition.dat"); + snprintf(filename, sizeof(filename), "fish_fully_automatic_partition.dat"); input_file.open(filename); std::string input_string; for (unsigned e=0;enelement(); Vector element_partition(n_partition,0); - sprintf(filename,"fish_selective_partition.dat"); + snprintf(filename, sizeof(filename), "fish_selective_partition.dat"); input_file.open(filename); std::string input_string; for (unsigned e=0;e::doc_solution(DocInfo& doc_info) { - sprintf(filename,"%s/nodes%i_on_proc%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/nodes%i_on_proc%i.dat",doc_info.directory().c_str(), doc_info.number(),this->communicator_pt()->my_rank()); some_file.open(filename); unsigned nnod=mesh_pt()->nnode(); @@ -282,7 +282,7 @@ void RefineableDrivenCavityProblem::doc_solution(DocInfo& doc_info) // Output solution - sprintf(filename,"%s/soln%i_on_proc%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i_on_proc%i.dat",doc_info.directory().c_str(), doc_info.number(),my_rank); some_file.open(filename); mesh_pt()->output(some_file,npts); diff --git a/demo_drivers/mpi/distribution/hanging_node_reconciliation/hp_adaptive_driven_cavity.cc b/demo_drivers/mpi/distribution/hanging_node_reconciliation/hp_adaptive_driven_cavity.cc index bbb3d2afb1ec..41ce707015b3 100644 --- a/demo_drivers/mpi/distribution/hanging_node_reconciliation/hp_adaptive_driven_cavity.cc +++ b/demo_drivers/mpi/distribution/hanging_node_reconciliation/hp_adaptive_driven_cavity.cc @@ -285,7 +285,7 @@ void PRefineableDrivenCavityProblem::doc_solution(DocInfo& doc_info) { - sprintf(filename,"%s/nodes%i_on_proc%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/nodes%i_on_proc%i.dat",doc_info.directory().c_str(), doc_info.number(),this->communicator_pt()->my_rank()); some_file.open(filename); unsigned nnod=mesh_pt()->nnode(); @@ -313,7 +313,7 @@ void PRefineableDrivenCavityProblem::doc_solution(DocInfo& doc_info) // Output solution - sprintf(filename,"%s/soln%i_on_proc%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i_on_proc%i.dat",doc_info.directory().c_str(), doc_info.number(),my_rank); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -366,7 +366,7 @@ int main(int argc, char **argv) // Write partition to disk std::ofstream output_file; char filename[100]; - sprintf(filename,"out_hp_adaptive_cavity_partition.dat"); + snprintf(filename, sizeof(filename), "out_hp_adaptive_cavity_partition.dat"); output_file.open(filename); for (unsigned e=0;enelement(); Vector element_partition(n_element); - sprintf(filename,"hp_adaptive_cavity_partition.dat"); + snprintf(filename, sizeof(filename), "hp_adaptive_cavity_partition.dat"); input_file.open(filename); std::string input_string; for (unsigned e=0;e::doc_solution(DocInfo& doc_info) int my_rank=this->communicator_pt()->my_rank(); // Output solution - sprintf(filename,"%s/soln%i_on_proc%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i_on_proc%i.dat",doc_info.directory().c_str(), doc_info.number(),my_rank); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -336,7 +336,7 @@ int main(int argc, char **argv) // Write partition to disk std::ofstream output_file; char filename[100]; - sprintf(filename,"out_hp_adaptive_cavity_partition.dat"); + snprintf(filename, sizeof(filename), "out_hp_adaptive_cavity_partition.dat"); output_file.open(filename); for (unsigned e=0;enelement(); Vector element_partition(n_element); - sprintf(filename,"hp_adaptive_cavity_partition.dat"); + snprintf(filename, sizeof(filename), "hp_adaptive_cavity_partition.dat"); input_file.open(filename); std::string input_string; for (unsigned e=0;e::doc_solution(DocInfo& doc_info) // Output solution //----------------- - sprintf(filename,"%s/soln%i_on_proc%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i_on_proc%i.dat",doc_info.directory().c_str(), doc_info.number(),my_rank); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -307,7 +307,7 @@ void RefineableTwoDPoissonProblem::doc_solution(DocInfo& doc_info) // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i_on_proc%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i_on_proc%i.dat",doc_info.directory().c_str(), doc_info.number(),my_rank); some_file.open(filename); mesh_pt()->output_fct(some_file,npts,TanhSolnForPoisson::get_exact_u); @@ -316,7 +316,7 @@ void RefineableTwoDPoissonProblem::doc_solution(DocInfo& doc_info) // Doc error and return of the square of the L2 error //--------------------------------------------------- double error,norm; - sprintf(filename,"%s/error%i_on_proc%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i_on_proc%i.dat",doc_info.directory().c_str(), doc_info.number(),my_rank); some_file.open(filename); mesh_pt()->compute_error(some_file,TanhSolnForPoisson::get_exact_u, @@ -379,7 +379,7 @@ int main(int argc, char** argv) // Write partition to disk std::ofstream output_file; char filename[100]; - sprintf(filename,"out_hp_adaptive_poisson_partition.dat"); + snprintf(filename, sizeof(filename), "out_hp_adaptive_poisson_partition.dat"); output_file.open(filename); for (unsigned e=0;enelement(); Vector element_partition(n_element); - sprintf(filename,"hp_adaptive_poisson_partition.dat"); + snprintf(filename, sizeof(filename), "hp_adaptive_poisson_partition.dat"); input_file.open(filename); std::string input_string; for (unsigned e=0;e::doc_solution() // Output shape of deformed body //------------------------------ - sprintf(filename,"%s/soln%i_on_proc%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i_on_proc%i.dat",Doc_info.directory().c_str(), Doc_info.number(),this->communicator_pt()->my_rank()); some_file.open(filename); solid_mesh_pt()->output(some_file,n_plot); @@ -483,7 +483,7 @@ void PrescribedBoundaryDisplacementProblem::doc_solution() // Output Lagrange multipliers //---------------------------- - sprintf(filename,"%s/lagr%i_on_proc%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/lagr%i_on_proc%i.dat",Doc_info.directory().c_str(), Doc_info.number(),this->communicator_pt()->my_rank()); some_file.open(filename); @@ -560,7 +560,7 @@ int main(int argc, char* argv[]) // Get the partition from file Vector element_partition(n_partition); - sprintf(filename,"presc_displ_lagr_mult_partition.dat"); + snprintf(filename, sizeof(filename), "presc_displ_lagr_mult_partition.dat"); input_file.open(filename); std::string input_string; for (unsigned e=0;e::doc_solution() // Output nodes and number of values //---------------------------------- - sprintf(filename,"%s/nodes%i_on_proc%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/nodes%i_on_proc%i.dat",Doc_info.directory().c_str(), Doc_info.number(),this->communicator_pt()->my_rank()); some_file.open(filename); unsigned nnod=solid_mesh_pt()->nnode(); @@ -521,7 +521,7 @@ void PrescribedBoundaryDisplacementProblem::doc_solution() // Output shape of deformed body //------------------------------ - sprintf(filename,"%s/soln%i_on_proc%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i_on_proc%i.dat",Doc_info.directory().c_str(), Doc_info.number(),this->communicator_pt()->my_rank()); some_file.open(filename); solid_mesh_pt()->output(some_file,n_plot); @@ -529,7 +529,7 @@ void PrescribedBoundaryDisplacementProblem::doc_solution() // Output Lagrange multipliers //---------------------------- - sprintf(filename,"%s/lagr%i_on_proc%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/lagr%i_on_proc%i.dat",Doc_info.directory().c_str(), Doc_info.number(),this->communicator_pt()->my_rank()); some_file.open(filename); diff --git a/demo_drivers/mpi/distribution/restart/two_d_unsteady_heat_2adapt_load_balance.cc b/demo_drivers/mpi/distribution/restart/two_d_unsteady_heat_2adapt_load_balance.cc index 5f81f4cee195..36cddac8c29b 100644 --- a/demo_drivers/mpi/distribution/restart/two_d_unsteady_heat_2adapt_load_balance.cc +++ b/demo_drivers/mpi/distribution/restart/two_d_unsteady_heat_2adapt_load_balance.cc @@ -742,7 +742,7 @@ void RefineableUnsteadyHeatProblem::restart() // Open restart file from stem char filename[100]; - sprintf(filename,"%s_on_proc%i.dat",GlobalParameters::Restart_file.c_str(), + snprintf(filename, sizeof(filename), "%s_on_proc%i.dat",GlobalParameters::Restart_file.c_str(), this->communicator_pt()->my_rank()); restart_file_pt= new ifstream(filename,ios_base::in); if (restart_file_pt!=0) @@ -788,7 +788,7 @@ void RefineableUnsteadyHeatProblem::write_trace_file_header() if (communicator_pt()->my_rank()==0) { char filename[100]; - sprintf(filename,"%s/trace.dat",Doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",Doc_info.directory().c_str()); Trace_file.open(filename); Trace_file << "VARIABLES=\"time t\"," @@ -851,7 +851,7 @@ void RefineableUnsteadyHeatProblem::doc_solution(const // Output solution //----------------- - sprintf(filename,"%s/soln%i_on_proc%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i_on_proc%i.dat",Doc_info.directory().c_str(), Doc_info.number(),this->communicator_pt()->my_rank()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); @@ -880,7 +880,7 @@ void RefineableUnsteadyHeatProblem::doc_solution(const // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i_on_proc%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i_on_proc%i.dat",Doc_info.directory().c_str(), Doc_info.number(),this->communicator_pt()->my_rank()); some_file.open(filename); Bulk_mesh_pt->output_fct(some_file,npts,time_pt()->time(), @@ -905,7 +905,7 @@ void RefineableUnsteadyHeatProblem::doc_solution(const //---------- double error,norm; - sprintf(filename,"%s/error%i_on_proc%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i_on_proc%i.dat",Doc_info.directory().c_str(), Doc_info.number(),this->communicator_pt()->my_rank()); some_file.open(filename); Bulk_mesh_pt->compute_error(some_file, @@ -970,7 +970,7 @@ void RefineableUnsteadyHeatProblem::doc_solution(const // Plot wall posn //--------------- - sprintf(filename,"%s/Wall%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/Wall%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); @@ -986,7 +986,7 @@ void RefineableUnsteadyHeatProblem::doc_solution(const // Write restart file - sprintf(filename,"%s/restart%i_on_proc%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/restart%i_on_proc%i.dat",Doc_info.directory().c_str(), Doc_info.number(),this->communicator_pt()->my_rank()); some_file.open(filename); some_file.precision(20); @@ -1283,18 +1283,18 @@ int main(int argc, char* argv[]) if(!CommandLineArgs::command_line_flag_has_been_set("--restart_file")) { //First run - sprintf(doc_info_directory,"RESLT_load_balance_first_for_restart"); + snprintf(doc_info_directory, sizeof(doc_info_directory), "RESLT_load_balance_first_for_restart"); } else { //Restarting //cout << GlobalParameters::Restart_file.c_str() << endl; char filename[100]; - sprintf(filename,"%s",GlobalParameters::Restart_file.c_str()); + snprintf(filename, sizeof(filename), "%s",GlobalParameters::Restart_file.c_str()); char* step; step = strtok(filename,"/"); step = strtok(NULL,"/"); - sprintf(doc_info_directory,"RESLT_load_balance_first_restarted_from_step_%s",step); + snprintf(doc_info_directory, sizeof(doc_info_directory), "RESLT_load_balance_first_restarted_from_step_%s",step); //cout << doc_info_directory << endl; //exit(1); } @@ -1305,23 +1305,23 @@ int main(int argc, char* argv[]) if(!CommandLineArgs::command_line_flag_has_been_set("--restart_file")) { //First run - sprintf(doc_info_directory,"RESLT_prune_first_for_restart"); + snprintf(doc_info_directory, sizeof(doc_info_directory), "RESLT_prune_first_for_restart"); } else { //Restarting char filename[100]; - sprintf(filename,"%s",GlobalParameters::Restart_file.c_str()); + snprintf(filename, sizeof(filename), "%s",GlobalParameters::Restart_file.c_str()); char* step; step = strtok(filename,"/"); step = strtok(NULL,"/"); - sprintf(doc_info_directory,"RESLT_prune_first_restarted_from_step_%s",step); + snprintf(doc_info_directory, sizeof(doc_info_directory), "RESLT_prune_first_restarted_from_step_%s",step); } } } else { - sprintf(doc_info_directory,"RESLT"); + snprintf(doc_info_directory, sizeof(doc_info_directory), "RESLT"); } // Set doc_info directory @@ -1333,7 +1333,7 @@ int main(int argc, char* argv[]) // Define processor-labeled output file for all on-screen stuff std::ofstream output_stream; char filename[100]; - sprintf(filename,"%s/OUTPUT.%i", + snprintf(filename, sizeof(filename), "%s/OUTPUT.%i", problem.doc_info().directory().c_str(), MPI_Helpers::communicator_pt()->my_rank()); output_stream.open(filename); @@ -1389,7 +1389,7 @@ int main(int argc, char* argv[]) // Write partition to disk std::ofstream output_file; char filename[100]; - sprintf(filename,"%s/partitioning.dat",problem.doc_info().directory().c_str()); + snprintf(filename, sizeof(filename), "%s/partitioning.dat",problem.doc_info().directory().c_str()); output_file.open(filename); unsigned n=element_partition.size(); output_file << element_partition.size() << std::endl; @@ -1451,7 +1451,7 @@ int main(int argc, char* argv[]) // Write used partition to disk std::ofstream output_file; char filename[100]; - sprintf(filename,"%s/partitioning.dat",problem.doc_info().directory().c_str()); + snprintf(filename, sizeof(filename), "%s/partitioning.dat",problem.doc_info().directory().c_str()); output_file.open(filename); unsigned n_used=used_element_partition.size(); output_file << n_used << std::endl; diff --git a/demo_drivers/mpi/distribution/three_d_cantilever/three_d_cantilever.cc b/demo_drivers/mpi/distribution/three_d_cantilever/three_d_cantilever.cc index a803c25a310a..abcd38541cf6 100644 --- a/demo_drivers/mpi/distribution/three_d_cantilever/three_d_cantilever.cc +++ b/demo_drivers/mpi/distribution/three_d_cantilever/three_d_cantilever.cc @@ -621,7 +621,7 @@ void CantileverProblem::doc_solution() // Output shape of and stress in deformed body //-------------------------------------------- - sprintf(filename,"%s/soln%i_on_proc%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i_on_proc%i.dat",Doc_info.directory().c_str(), Doc_info.number(),this->communicator_pt()->my_rank()); some_file.open(filename); mesh_pt()->output(some_file,n_plot); @@ -665,16 +665,16 @@ void CantileverProblem::run_it(const unsigned& i_case) char dirname[100]; #ifdef REFINE - sprintf(dirname,"RESLT_refine%i",i_case); + snprintf(dirname, sizeof(dirname), "RESLT_refine%i",i_case); #else - sprintf(dirname,"RESLT_norefine%i",i_case); + snprintf(dirname, sizeof(dirname), "RESLT_norefine%i",i_case); #endif Doc_info.set_directory(dirname); // Open trace file char filename[100]; - sprintf(filename,"%s/trace_on_proc%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/trace_on_proc%i.dat",Doc_info.directory().c_str(), this->communicator_pt()->my_rank()); Trace_file.open(filename); @@ -780,7 +780,7 @@ int main(int argc, char **argv) // Get partition from file unsigned n_partition=problem.mesh_pt()->nelement(); Vector element_partition(n_partition); - sprintf(filename,"three_d_cantilever_%i_partition.dat",0+i*ncase); + snprintf(filename, sizeof(filename), "three_d_cantilever_%i_partition.dat",0+i*ncase); input_file.open(filename); std::string input_string; for (unsigned e=0;enelement(); Vector element_partition(n_partition); - sprintf(filename,"three_d_cantilever_%i_partition.dat",0+i*ncase); + snprintf(filename, sizeof(filename), "three_d_cantilever_%i_partition.dat",0+i*ncase); input_file.open(filename); std::string input_string; for (unsigned e=0;enelement(); Vector element_partition(n_partition); - sprintf(filename,"three_d_cantilever_%i_partition.dat",1+i*ncase); + snprintf(filename, sizeof(filename), "three_d_cantilever_%i_partition.dat",1+i*ncase); input_file.open(filename); std::string input_string; for (unsigned e=0;enelement(); Vector element_partition(n_partition); - sprintf(filename,"three_d_cantilever_%i_partition.dat",0+i*ncase); + snprintf(filename, sizeof(filename), "three_d_cantilever_%i_partition.dat",0+i*ncase); input_file.open(filename); std::string input_string; for (unsigned e=0;enelement(); Vector element_partition(n_partition); - sprintf(filename,"three_d_cantilever_%i_partition.dat",1+i*ncase); + snprintf(filename, sizeof(filename), "three_d_cantilever_%i_partition.dat",1+i*ncase); input_file.open(filename); std::string input_string; for (unsigned e=0;enelement(); Vector element_partition(n_partition); - sprintf(filename,"three_d_cantilever_%i_partition.dat",0+i*ncase); + snprintf(filename, sizeof(filename), "three_d_cantilever_%i_partition.dat",0+i*ncase); input_file.open(filename); std::string input_string; for (unsigned e=0;enelement(); Vector element_partition(n_partition); - sprintf(filename,"three_d_cantilever_%i_partition.dat",3+i*ncase); + snprintf(filename, sizeof(filename), "three_d_cantilever_%i_partition.dat",3+i*ncase); input_file.open(filename); std::string input_string; for (unsigned e=0;enelement(); Vector element_partition(n_partition); - sprintf(filename,"three_d_cantilever_%i_partition.dat",3+i*ncase); + snprintf(filename, sizeof(filename), "three_d_cantilever_%i_partition.dat",3+i*ncase); input_file.open(filename); std::string input_string; for (unsigned e=0;enelement(); Vector element_partition(n_partition); - sprintf(filename,"three_d_cantilever_%i_partition.dat",4+i*ncase); + snprintf(filename, sizeof(filename), "three_d_cantilever_%i_partition.dat",4+i*ncase); input_file.open(filename); std::string input_string; for (unsigned e=0;enelement(); Vector element_partition(n_partition); - sprintf(filename,"three_d_cantilever_%i_partition.dat",4+i*ncase); + snprintf(filename, sizeof(filename), "three_d_cantilever_%i_partition.dat",4+i*ncase); input_file.open(filename); std::string input_string; for (unsigned e=0;e::EntryFlowProblem(DocInfo& doc_info, //Doc the boundaries ofstream some_file; char filename[100]; - sprintf(filename,"boundaries.dat"); + snprintf(filename, sizeof(filename), "boundaries.dat"); some_file.open(filename); mesh_pt()->output_boundaries(some_file); some_file.close(); @@ -279,7 +279,7 @@ void EntryFlowProblem::doc_solution() npts=5; // Output solution - sprintf(filename,"%s/soln%i_on_proc%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i_on_proc%i.dat",Doc_info.directory().c_str(), Doc_info.number(),this->communicator_pt()->my_rank()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -379,7 +379,7 @@ int main(int argc, char* argv[]) // Get partition from file unsigned n_partition=problem.mesh_pt()->nelement(); Vector element_partition(n_partition,0); - sprintf(filename,"three_d_entry_flow_1_partition.dat"); + snprintf(filename, sizeof(filename), "three_d_entry_flow_1_partition.dat"); input_file.open(filename); std::string input_string; for (unsigned e=0;enelement(); Vector element_partition(n_partition,0); - sprintf(filename,"three_d_entry_flow_2_partition.dat"); + snprintf(filename, sizeof(filename), "three_d_entry_flow_2_partition.dat"); input_file.open(filename); std::string input_string; for (unsigned e=0;e::doc_solution() // Output shape of deformed body //------------------------------ - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); solid_mesh_pt()->output(some_file,n_plot); @@ -615,7 +615,7 @@ void PrescribedBoundaryDisplacementProblem::doc_solution() // Output Lagrange multipliers //---------------------------- - sprintf(filename,"%s/lagr%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/lagr%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); diff --git a/demo_drivers/mpi/distribution/two_d_poisson_flux_bc_adapt/two_d_poisson_flux_bc_adapt.cc b/demo_drivers/mpi/distribution/two_d_poisson_flux_bc_adapt/two_d_poisson_flux_bc_adapt.cc index 276bcfeee2fb..a1e2748b3bfe 100644 --- a/demo_drivers/mpi/distribution/two_d_poisson_flux_bc_adapt/two_d_poisson_flux_bc_adapt.cc +++ b/demo_drivers/mpi/distribution/two_d_poisson_flux_bc_adapt/two_d_poisson_flux_bc_adapt.cc @@ -455,7 +455,7 @@ void RefineableTwoMeshFluxPoissonProblem::doc_solution(DocInfo& doc_inf // Output solution with halo elements //----------------------------------- Bulk_mesh_pt->enable_output_of_halo_elements(); - sprintf(filename,"%s/soln_with_halo%i_on_proc%i.dat", + snprintf(filename, sizeof(filename), "%s/soln_with_halo%i_on_proc%i.dat", doc_info.directory().c_str(), doc_info.number(),this->communicator_pt()->my_rank()); some_file.open(filename); @@ -466,7 +466,7 @@ void RefineableTwoMeshFluxPoissonProblem::doc_solution(DocInfo& doc_inf // Output solution //----------------- - sprintf(filename,"%s/soln%i_on_proc%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i_on_proc%i.dat",doc_info.directory().c_str(), doc_info.number(),this->communicator_pt()->my_rank()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); @@ -474,7 +474,7 @@ void RefineableTwoMeshFluxPoissonProblem::doc_solution(DocInfo& doc_inf // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i_on_proc%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i_on_proc%i.dat",doc_info.directory().c_str(), doc_info.number(),this->communicator_pt()->my_rank()); some_file.open(filename); Bulk_mesh_pt->output_fct(some_file,npts,TanhSolnForPoisson::get_exact_u); @@ -484,7 +484,7 @@ void RefineableTwoMeshFluxPoissonProblem::doc_solution(DocInfo& doc_inf // Doc error and return of the square of the L2 error //--------------------------------------------------- double error,norm; - sprintf(filename,"%s/error%i_on_proc%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i_on_proc%i.dat",doc_info.directory().c_str(), doc_info.number(),this->communicator_pt()->my_rank()); some_file.open(filename); Bulk_mesh_pt->compute_error(some_file,TanhSolnForPoisson::get_exact_u, @@ -575,7 +575,7 @@ int main(int argc, char* argv[]) // Define processor-labeled output file for all on-screen stuff std::ofstream output_stream; char filename[100]; - sprintf(filename,"RESLT/OUTPUT.%i",MPI_Helpers::communicator_pt()->my_rank()); + snprintf(filename, sizeof(filename), "RESLT/OUTPUT.%i",MPI_Helpers::communicator_pt()->my_rank()); output_stream.open(filename); oomph_info.stream_pt() = &output_stream; OomphLibWarning::set_stream_pt(&output_stream); @@ -594,7 +594,7 @@ int main(int argc, char* argv[]) //Get the partition from file Vector element_partition(n_el); std::ifstream input_file; - sprintf(filename,"two_d_poisson_flux_partition.dat"); + snprintf(filename, sizeof(filename), "two_d_poisson_flux_partition.dat"); input_file.open(filename); std::string input_string; for (unsigned e=0;e::doc_solution(DocInfo& doc_info, // Output solution (be careful with the naming of the output files, // each file can be identified by the processor id // ---------------- - sprintf(filename,"%s/soln%i_proc%i.dat", + snprintf(filename, sizeof(filename), "%s/soln%i_proc%i.dat", doc_info.directory().c_str(), doc_info.number(), this->communicator_pt()->my_rank()); @@ -1073,7 +1073,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info, // Output exact solution (output files in parallel) //---------------- - sprintf(filename,"%s/exact_soln%i_proc%i.dat", + snprintf(filename, sizeof(filename), "%s/exact_soln%i_proc%i.dat", doc_info.directory().c_str(), doc_info.number(), this->communicator_pt()->my_rank()); @@ -1195,7 +1195,7 @@ read_custom_distribution_from_file(Vector &output_distribution) FILE *file_pt; // Store the file name char file_name[500]; - sprintf(file_name, "%s/input_distribution_%i.dat", + snprintf(file_name, sizeof(file_name), "%s/input_distribution_%i.dat", TestArguments::Folder_distribution_file.c_str(), my_rank); @@ -1280,7 +1280,7 @@ save_custom_distribution_to_file(Vector &input_distribution) // Char for the output file name char file_name[500]; // Set the name of the file - sprintf(file_name, "DISTRIBUTION/input_distribution_%i.dat", my_rank); + snprintf(file_name, sizeof(file_name), "DISTRIBUTION/input_distribution_%i.dat", my_rank); oomph_info << "Save custom distribution to file: " << file_name << std::endl; @@ -1449,7 +1449,7 @@ int main(int argc, char* argv[]) // Open the trace file (the name of the trace file is different for // each processor) char trace_filename[100]; - sprintf(trace_filename,"%s/trace_proc%i.dat", + snprintf(trace_filename, sizeof(trace_filename), "%s/trace_proc%i.dat", doc_info.directory().c_str(), my_rank); /// Trace file to document error and norm of solution @@ -1496,7 +1496,7 @@ int main(int argc, char* argv[]) // This show us the elements assigned to this processor (remember to // disable the output of halo elements) problem.mesh_pt()->disable_output_of_halo_elements(); - sprintf(file_initial_distributed_mesh, + snprintf(file_initial_distributed_mesh, sizeof(file_initial_distributed_mesh), "%s/output_initial_distributed_mesh_%i.dat", doc_info.directory().c_str(), my_rank); diff --git a/demo_drivers/mpi/distribution/two_d_unstructured_adaptive_poisson/unstructured_adaptive_mesh_two_outer_boundaries.cc b/demo_drivers/mpi/distribution/two_d_unstructured_adaptive_poisson/unstructured_adaptive_mesh_two_outer_boundaries.cc index d0b7fcbfbdbe..b05672e1fe6f 100644 --- a/demo_drivers/mpi/distribution/two_d_unstructured_adaptive_poisson/unstructured_adaptive_mesh_two_outer_boundaries.cc +++ b/demo_drivers/mpi/distribution/two_d_unstructured_adaptive_poisson/unstructured_adaptive_mesh_two_outer_boundaries.cc @@ -783,7 +783,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info, unsigned region_id = (unsigned)att; oomph_info << "attribute in reg: " << att << std::endl; - sprintf(filename,"%s/region%i_%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/region%i_%i.dat",doc_info.directory().c_str(), region_id,doc_info.number()); some_file.open(filename); @@ -820,7 +820,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info, // Output boundaries //------------------ - sprintf(filename,"%s/boundaries.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/boundaries.dat",doc_info.directory().c_str()); some_file.open(filename); mesh_pt()->output_boundaries(some_file); some_file.close(); @@ -828,7 +828,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info, // Output solution //---------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -837,7 +837,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info, // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output_fct(some_file,npts,TanhSolnForPoisson::get_exact_u); @@ -847,7 +847,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info, // Doc error //---------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->compute_error(some_file,TanhSolnForPoisson::get_exact_u, @@ -948,7 +948,7 @@ int main(int argc, char* argv[]) // Open trace file char trace_filename[100]; - sprintf(trace_filename,"%s/trace.dat", + snprintf(trace_filename, sizeof(trace_filename), "%s/trace.dat", doc_info.directory().c_str()); /// Trace file to document norm of solution diff --git a/demo_drivers/mpi/distribution/two_d_unstructured_adaptive_poisson/unstructured_adaptive_mesh_two_outer_boundaries_crossed.cc b/demo_drivers/mpi/distribution/two_d_unstructured_adaptive_poisson/unstructured_adaptive_mesh_two_outer_boundaries_crossed.cc index ff9901236ebe..115b4de08039 100644 --- a/demo_drivers/mpi/distribution/two_d_unstructured_adaptive_poisson/unstructured_adaptive_mesh_two_outer_boundaries_crossed.cc +++ b/demo_drivers/mpi/distribution/two_d_unstructured_adaptive_poisson/unstructured_adaptive_mesh_two_outer_boundaries_crossed.cc @@ -910,7 +910,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info, unsigned region_id = (unsigned)att; oomph_info << "attribute in reg: " << att << std::endl; - sprintf(filename,"%s/region%i_%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/region%i_%i.dat",doc_info.directory().c_str(), region_id,doc_info.number()); some_file.open(filename); @@ -947,7 +947,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info, // Output boundaries //------------------ - sprintf(filename,"%s/boundaries.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/boundaries.dat",doc_info.directory().c_str()); some_file.open(filename); mesh_pt()->output_boundaries(some_file); some_file.close(); @@ -955,7 +955,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info, // Output solution //---------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -964,7 +964,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info, // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output_fct(some_file,npts,TanhSolnForPoisson::get_exact_u); @@ -974,7 +974,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info, // Doc error //---------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->compute_error(some_file,TanhSolnForPoisson::get_exact_u, @@ -1076,7 +1076,7 @@ int main(int argc, char* argv[]) // Open trace file char trace_filename[100]; - sprintf(trace_filename,"%s/trace.dat", + snprintf(trace_filename, sizeof(trace_filename), "%s/trace.dat", doc_info.directory().c_str()); /// Trace file to document norm of solution diff --git a/demo_drivers/mpi/multi_domain/boussinesq_convection/multi_domain_boussinesq_convection.cc b/demo_drivers/mpi/multi_domain/boussinesq_convection/multi_domain_boussinesq_convection.cc index 5a9360f25d41..d508f43c3d7c 100644 --- a/demo_drivers/mpi/multi_domain/boussinesq_convection/multi_domain_boussinesq_convection.cc +++ b/demo_drivers/mpi/multi_domain/boussinesq_convection/multi_domain_boussinesq_convection.cc @@ -413,7 +413,7 @@ void ConvectionProblem::doc_solution() unsigned npts=5; // Output Navier-Stokes solution - sprintf(filename,"%s/fluid_soln%i_on_proc%i.dat", + snprintf(filename, sizeof(filename), "%s/fluid_soln%i_on_proc%i.dat", Doc_info.directory().c_str(), Doc_info.number(), this->communicator_pt()->my_rank()); @@ -422,7 +422,7 @@ void ConvectionProblem::doc_solution() some_file.close(); // Output advection diffusion solution - sprintf(filename,"%s/temperature_soln%i_on_proc%i.dat", + snprintf(filename, sizeof(filename), "%s/temperature_soln%i_on_proc%i.dat", Doc_info.directory().c_str(), Doc_info.number(), this->communicator_pt()->my_rank()); @@ -451,7 +451,7 @@ int main(int argc, char **argv) // Define processor-labeled output file for all on-screen stuff std::ofstream output_stream; char filename[100]; - sprintf(filename,"OUTPUT.%i",MPI_Helpers::communicator_pt()->my_rank()); + snprintf(filename, sizeof(filename), "OUTPUT.%i",MPI_Helpers::communicator_pt()->my_rank()); output_stream.open(filename); oomph_info.stream_pt() = &output_stream; OomphLibWarning::set_stream_pt(&output_stream); @@ -515,12 +515,12 @@ int main(int argc, char **argv) if (atoi(argv[2])==2) { oomph_info << "Using connected partitioning" << std::endl; - sprintf(filename,"multi_domain_boussinesq_partition_2.dat"); + snprintf(filename, sizeof(filename), "multi_domain_boussinesq_partition_2.dat"); } else { oomph_info << "Giving a mesh to each processor" << std::endl; - sprintf(filename,"multi_domain_boussinesq_partition.dat"); + snprintf(filename, sizeof(filename), "multi_domain_boussinesq_partition.dat"); } input_file.open(filename); oomph_info << "Opened: " << filename << std::endl; @@ -550,7 +550,7 @@ int main(int argc, char **argv) mesh_doc_info,report_stats); // Write used partition to disk - sprintf(filename,"RESLT/partitioning.dat"); + snprintf(filename, sizeof(filename), "RESLT/partitioning.dat"); output_file.open(filename); unsigned n_used=used_element_partition.size(); output_file << n_used << std::endl; diff --git a/demo_drivers/mpi/multi_domain/boussinesq_convection/multi_domain_ref_b_convection.cc b/demo_drivers/mpi/multi_domain/boussinesq_convection/multi_domain_ref_b_convection.cc index 4d71f405c199..30dd858065a6 100644 --- a/demo_drivers/mpi/multi_domain/boussinesq_convection/multi_domain_ref_b_convection.cc +++ b/demo_drivers/mpi/multi_domain/boussinesq_convection/multi_domain_ref_b_convection.cc @@ -459,14 +459,14 @@ void RefineableConvectionProblem::doc_solution() Doc_info.label()=""; // Output Navier-Stokes solution - sprintf(filename,"%s/fluid_soln%i_on_proc%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/fluid_soln%i_on_proc%i.dat",Doc_info.directory().c_str(), Doc_info.number(),this->communicator_pt()->my_rank()); some_file.open(filename); nst_mesh_pt()->output(some_file,npts); some_file.close(); // Output advection diffusion solution - sprintf(filename,"%s/temperature_soln%i_on_proc%i.dat", + snprintf(filename, sizeof(filename), "%s/temperature_soln%i_on_proc%i.dat", Doc_info.directory().c_str(), Doc_info.number(),this->communicator_pt()->my_rank()); some_file.open(filename); @@ -505,7 +505,7 @@ int main(int argc, char **argv) // Define processor-labeled output file for all on-screen stuff std::ofstream output_stream; char filename[100]; - sprintf(filename,"OUTPUT.%i",MPI_Helpers::communicator_pt()->my_rank()); + snprintf(filename, sizeof(filename), "OUTPUT.%i",MPI_Helpers::communicator_pt()->my_rank()); output_stream.open(filename); oomph_info.stream_pt() = &output_stream; OomphLibWarning::set_stream_pt(&output_stream); diff --git a/demo_drivers/mpi/multi_domain/boussinesq_convection/refineable_b_convection.cc b/demo_drivers/mpi/multi_domain/boussinesq_convection/refineable_b_convection.cc index 96a6b9221296..d1ce23b68ac9 100644 --- a/demo_drivers/mpi/multi_domain/boussinesq_convection/refineable_b_convection.cc +++ b/demo_drivers/mpi/multi_domain/boussinesq_convection/refineable_b_convection.cc @@ -333,7 +333,7 @@ void RefineableConvectionProblem::doc_solution() // Output solution //----------------- - sprintf(filename,"%s/soln%i_on_proc%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i_on_proc%i.dat",Doc_info.directory().c_str(), Doc_info.number(),this->communicator_pt()->my_rank()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -387,7 +387,7 @@ int main(int argc, char **argv) std::ifstream input_file; char filename[100]; - sprintf(filename,"refineable_b_convection_partition.dat"); + snprintf(filename, sizeof(filename), "refineable_b_convection_partition.dat"); input_file.open(filename); std::string input_string; for (unsigned e=0;e::doc_solution(DocInfo& doc_info, npts=5; // Output fluid solution - sprintf(filename,"%s/soln%i_on_proc%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i_on_proc%i.dat",doc_info.directory().c_str(), doc_info.number(),this->communicator_pt()->my_rank()); some_file.open(filename); Fluid_mesh_pt->output(some_file,npts); some_file.close(); // Output wall solution - sprintf(filename,"%s/wall_soln%i_on_proc%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/wall_soln%i_on_proc%i.dat",doc_info.directory().c_str(), doc_info.number(),this->communicator_pt()->my_rank()); some_file.open(filename); Wall_mesh_pt->output(some_file,npts); @@ -730,7 +730,7 @@ void FSIChannelWithLeafletProblem::doc_solution(DocInfo& doc_info, // Output fluid elements on fluid mesh boundary 4 (associated with // the "front") unsigned bound=4; - sprintf(filename,"%s/fluid_boundary_elements_front_%i_on_proc%i.dat", + snprintf(filename, sizeof(filename), "%s/fluid_boundary_elements_front_%i_on_proc%i.dat", doc_info.directory().c_str(), doc_info.number(),this->communicator_pt()->my_rank()); some_file.open(filename); @@ -746,7 +746,7 @@ void FSIChannelWithLeafletProblem::doc_solution(DocInfo& doc_info, // Output fluid elements on fluid mesh boundary 5 (associated with // the "back") bound=5; - sprintf(filename,"%s/fluid_boundary_elements_back_%i_on_proc%i.dat", + snprintf(filename, sizeof(filename), "%s/fluid_boundary_elements_back_%i_on_proc%i.dat", doc_info.directory().c_str(), doc_info.number(),this->communicator_pt()->my_rank()); some_file.open(filename); @@ -760,7 +760,7 @@ void FSIChannelWithLeafletProblem::doc_solution(DocInfo& doc_info, // Output normal vector on wall elements - sprintf(filename,"%s/wall_normal_%i_on_proc%i.dat", + snprintf(filename, sizeof(filename), "%s/wall_normal_%i_on_proc%i.dat", doc_info.directory().c_str(), doc_info.number(),this->communicator_pt()->my_rank()); some_file.open(filename); @@ -820,7 +820,7 @@ int main(int argc, char* argv[]) // Define processor-labeled output file for all on-screen stuff std::ofstream output_stream; char filename[1000]; - sprintf(filename,"OUTPUT.%i", + snprintf(filename, sizeof(filename), "OUTPUT.%i", MPI_Helpers::communicator_pt()->my_rank()); output_stream.open(filename); oomph_info.stream_pt() = &output_stream; @@ -860,7 +860,7 @@ int main(int argc, char* argv[]) ofstream trace; if (problem.communicator_pt()->my_rank()==0) { - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); trace.open(filename); } @@ -902,7 +902,7 @@ int main(int argc, char* argv[]) Vector in_element_partition(n_partition,0); // Get partition from file - sprintf(filename,"fsi_channel_with_leaflet_partition.dat"); + snprintf(filename, sizeof(filename), "fsi_channel_with_leaflet_partition.dat"); input_file.open(filename); std::string input_string; for (unsigned e=0;e::doc_solution(DocInfo& doc_info, npts=5; // Output fluid solution - sprintf(filename,"%s/new_soln%i_on_proc%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/new_soln%i_on_proc%i.dat",doc_info.directory().c_str(), doc_info.number(),this->communicator_pt()->my_rank()); some_file.open(filename); bulk_mesh_pt()->output(some_file,npts); @@ -724,7 +724,7 @@ void FSICollapsibleChannelProblem::doc_solution(DocInfo& doc_info, // Document the wall shape // NB the wall is on every processor so this is somewhat unnecessary I guess - sprintf(filename,"%s/new_beam%i_on_proc%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/new_beam%i_on_proc%i.dat",doc_info.directory().c_str(), doc_info.number(),this->communicator_pt()->my_rank()); some_file.open(filename); wall_mesh_pt()->output(some_file,npts); @@ -736,7 +736,7 @@ void FSICollapsibleChannelProblem::doc_solution(DocInfo& doc_info, unsigned nsteps=time_stepper_pt(1)->nprev_values(); for (unsigned t=0;t<=nsteps;t++) { - sprintf(filename,"%s/new_wall%i-%i_on_proc%i.dat", + snprintf(filename, sizeof(filename), "%s/new_wall%i-%i_on_proc%i.dat", doc_info.directory().c_str(), doc_info.number(),t,this->communicator_pt()->my_rank()); some_file.open(filename); @@ -987,7 +987,7 @@ int main(int argc, char* argv[]) // Define processor-labeled output file for all on-screen stuff std::ofstream output_stream; char filename[100]; - sprintf(filename,"OUTPUT.%i",MPI_Helpers::communicator_pt()->my_rank()); + snprintf(filename, sizeof(filename), "OUTPUT.%i",MPI_Helpers::communicator_pt()->my_rank()); output_stream.open(filename); oomph_info.stream_pt() = &output_stream; OomphLibWarning::set_stream_pt(&output_stream); @@ -1083,7 +1083,7 @@ int main(int argc, char* argv[]) // Open a trace file ofstream trace_file; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); trace_file.open(filename); // Output the initial condition @@ -1115,7 +1115,7 @@ int main(int argc, char* argv[]) // Get partition from file Vector element_partition(n_partition,0); - sprintf(filename,"fsi_collapsible_channel_partition.dat"); + snprintf(filename, sizeof(filename), "fsi_collapsible_channel_partition.dat"); input_file.open(filename); std::string input_string; for (unsigned e=0;ecommunicator_pt()->my_rank()); //Open the output file @@ -434,7 +434,7 @@ void FSIRingProblem::doc_solution(const unsigned& i, some_file.close(); // Output the wall mesh as well - sprintf(filename,"%s/new_wall_soln%i_on_proc%i.dat", + snprintf(filename, sizeof(filename), "%s/new_wall_soln%i_on_proc%i.dat", doc_info.directory().c_str(), doc_info.number(),this->communicator_pt()->my_rank()); //Open the output file @@ -873,7 +873,7 @@ void FSIRingProblem::dynamic_run() // Get partition from file unsigned n_partition=mesh_pt()->nelement(); Vector element_partition(n_partition); - sprintf(filename,"fsi_osc_ring_partition.dat"); + snprintf(filename, sizeof(filename), "fsi_osc_ring_partition.dat"); input_file.open(filename); std::string input_string; for (unsigned e=0;emy_rank()); + snprintf(filename, sizeof(filename), "OUTPUT.%i",MPI_Helpers::communicator_pt()->my_rank()); output_stream.open(filename); oomph_info.stream_pt() = &output_stream; OomphLibWarning::set_stream_pt(&output_stream); diff --git a/demo_drivers/mpi/multi_domain/pseudo_solid_collapsible_tube/pseudo_solid_collapsible_tube.cc b/demo_drivers/mpi/multi_domain/pseudo_solid_collapsible_tube/pseudo_solid_collapsible_tube.cc index 9a6825954eb6..42ff2b47333f 100644 --- a/demo_drivers/mpi/multi_domain/pseudo_solid_collapsible_tube/pseudo_solid_collapsible_tube.cc +++ b/demo_drivers/mpi/multi_domain/pseudo_solid_collapsible_tube/pseudo_solid_collapsible_tube.cc @@ -1728,10 +1728,10 @@ int main(int argc, char* argv[]) std::ofstream output_stream; char filename[1000]; #ifdef OOMPH_HAS_MPI - sprintf(filename,"%s/OUTPUT.%i",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/OUTPUT.%i",doc_info.directory().c_str(), MPI_Helpers::communicator_pt()->my_rank()); #else - sprintf(filename,"%s/OUTPUT.%i",doc_info.directory().c_str(),0); + snprintf(filename, sizeof(filename), "%s/OUTPUT.%i",doc_info.directory().c_str(),0); #endif output_stream.open(filename); diff --git a/demo_drivers/mpi/multi_domain/turek_flag/turek_flag.cc b/demo_drivers/mpi/multi_domain/turek_flag/turek_flag.cc index 08a23441ae82..817736608213 100644 --- a/demo_drivers/mpi/multi_domain/turek_flag/turek_flag.cc +++ b/demo_drivers/mpi/multi_domain/turek_flag/turek_flag.cc @@ -1340,14 +1340,14 @@ void TurekProblem::doc_solution( unsigned n_plot = 5; // Output solid solution - sprintf(filename,"%s/solid_soln%i_on_proc%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/solid_soln%i_on_proc%i.dat",doc_info.directory().c_str(), doc_info.number(),my_rank); some_file.open(filename); solid_mesh_pt()->output(some_file,n_plot); some_file.close(); // Output fluid solution - sprintf(filename,"%s/soln%i_on_proc%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i_on_proc%i.dat",doc_info.directory().c_str(), doc_info.number(),my_rank); some_file.open(filename); fluid_mesh_pt()->output(some_file,n_plot); @@ -1355,7 +1355,7 @@ void TurekProblem::doc_solution( //Output the traction - sprintf(filename,"%s/traction%i_on_proc%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/traction%i_on_proc%i.dat",doc_info.directory().c_str(), doc_info.number(),my_rank); some_file.open(filename); // Loop over the traction meshes @@ -1450,7 +1450,7 @@ int main(int argc, char* argv[]) ofstream trace_file; char filename[100]; doc_info.set_directory("RESLT_TUREK"); - sprintf(filename,"%s/trace_on_proc%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/trace_on_proc%i.dat",doc_info.directory().c_str(), problem.communicator_pt()->my_rank()); trace_file.open(filename); @@ -1496,7 +1496,7 @@ int main(int argc, char* argv[]) Vector in_element_partition(n_partition,0); // Get partition from file - sprintf(filename,"turek_flag_partition.dat"); + snprintf(filename, sizeof(filename), "turek_flag_partition.dat"); input_file.open(filename); std::string input_string; for (unsigned e=0;e::doc_solution( unsigned n_plot = 5; // Output solid solution - sprintf(filename,"%s/solid_soln%i_on_proc%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/solid_soln%i_on_proc%i.dat",doc_info.directory().c_str(), doc_info.number(),my_rank); some_file.open(filename); solid_mesh_pt()->output(some_file,n_plot); some_file.close(); // Output fluid solution - sprintf(filename,"%s/soln%i_on_proc%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i_on_proc%i.dat",doc_info.directory().c_str(), doc_info.number(),my_rank); some_file.open(filename); fluid_mesh_pt()->output(some_file,n_plot); @@ -1249,7 +1249,7 @@ void TurekProblem::doc_solution( //Output the traction - sprintf(filename,"%s/traction%i_on_proc%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/traction%i_on_proc%i.dat",doc_info.directory().c_str(), doc_info.number(),my_rank); some_file.open(filename); // Loop over the traction meshes @@ -1309,7 +1309,7 @@ int main(int argc, char* argv[]) // Define processor-labeled output file for all on-screen stuff std::ofstream output_stream; char filename[100]; - sprintf(filename,"RESLT_TUREK_LOAD_BALANCE/OUTPUT.%i", + snprintf(filename, sizeof(filename), "RESLT_TUREK_LOAD_BALANCE/OUTPUT.%i", MPI_Helpers::communicator_pt()->my_rank()); output_stream.open(filename); oomph_info.stream_pt() = &output_stream; @@ -1356,7 +1356,7 @@ int main(int argc, char* argv[]) DocInfo doc_info; ofstream trace_file; doc_info.set_directory("RESLT_TUREK_LOAD_BALANCE"); - sprintf(filename,"%s/trace_on_proc%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/trace_on_proc%i.dat",doc_info.directory().c_str(), problem.communicator_pt()->my_rank()); trace_file.open(filename); @@ -1403,7 +1403,7 @@ int main(int argc, char* argv[]) Vector in_element_partition(n_partition,0); // Get partition from file - sprintf(filename,"turek_flag_partition.dat"); + snprintf(filename, sizeof(filename), "turek_flag_partition.dat"); input_file.open(filename); std::string input_string; for (unsigned e=0;e::doc_solution(DocInfo& doc_info) // Output solution //----------------- - sprintf(filename,"%s/soln_trilinos_%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln_trilinos_%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -282,7 +282,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info) // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output_fct(some_file,npts,TanhSolnForPoisson::get_exact_u); @@ -291,7 +291,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info) // Doc error and return of the square of the L2 error //--------------------------------------------------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->compute_error(some_file,TanhSolnForPoisson::get_exact_u, @@ -349,7 +349,7 @@ int main(int argc, char **argv) // File to report the number of Newton iterations ofstream conv_file; char filename[100]; - sprintf(filename,"%s/conv.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/conv.dat",doc_info.directory().c_str()); conv_file.open(filename); diff --git a/demo_drivers/mpi/solvers/direct_solver_test.cc b/demo_drivers/mpi/solvers/direct_solver_test.cc index 77c99b1e3f44..275363e0a0e3 100644 --- a/demo_drivers/mpi/solvers/direct_solver_test.cc +++ b/demo_drivers/mpi/solvers/direct_solver_test.cc @@ -233,21 +233,21 @@ void OneDPoissonProblem::doc_solution(DocInfo& doc) npts=5; // Output solution with specified number of plot points per element - sprintf(filename,"%s/soln_direct_solver_%i.dat",doc.directory().c_str(),doc.number()); + snprintf(filename, sizeof(filename), "%s/soln_direct_solver_%i.dat",doc.directory().c_str(),doc.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); some_file.close(); // Output exact solution at much higher resolution (so we can // see how well the solutions agree between nodal points) - sprintf(filename,"%s/exact_soln%i.dat",doc.directory().c_str(),doc.number()); + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc.directory().c_str(),doc.number()); some_file.open(filename); mesh_pt()->output_fct(some_file,20*npts,FishSolnOneDPoisson::get_exact_u); some_file.close(); // Doc pointwise error and compute norm of error and of the solution double error,norm; - sprintf(filename,"%s/error%i.dat",doc.directory().c_str(),doc.number()); + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc.directory().c_str(),doc.number()); some_file.open(filename); mesh_pt()->compute_error(some_file,FishSolnOneDPoisson::get_exact_u, error,norm); @@ -425,7 +425,7 @@ int main(int argc, char **argv) char filename[100]; // Output solution with specified number of plot points per element - sprintf(filename,"RESLT/dummy_mumps.dat"); + snprintf(filename, sizeof(filename), "RESLT/dummy_mumps.dat"); some_file.open(filename); some_file << "dummy data for missing mumps\n"; some_file.close(); diff --git a/demo_drivers/mpi/solvers/driven_cavity.cc b/demo_drivers/mpi/solvers/driven_cavity.cc index 69f4a539454b..8046c6ffc392 100644 --- a/demo_drivers/mpi/solvers/driven_cavity.cc +++ b/demo_drivers/mpi/solvers/driven_cavity.cc @@ -392,7 +392,7 @@ void RectangularDrivenCavityProblem::doc_solution(DocInfo& doc_info) npts=5; // Output solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); diff --git a/demo_drivers/mpi/solvers/two_d_multi_poisson.cc b/demo_drivers/mpi/solvers/two_d_multi_poisson.cc index 8c662c9a9bc5..4097e65c4458 100644 --- a/demo_drivers/mpi/solvers/two_d_multi_poisson.cc +++ b/demo_drivers/mpi/solvers/two_d_multi_poisson.cc @@ -440,7 +440,7 @@ void MultiPoissonProblem::doc_solution(DocInfo& doc_info) #endif - sprintf(filename,"%s/iterative_solver_convergence.dat", + snprintf(filename, sizeof(filename), "%s/iterative_solver_convergence.dat", doc_info.directory().c_str()); some_file.open(filename); some_file << "Number of linear solver iterations: " @@ -450,7 +450,7 @@ void MultiPoissonProblem::doc_solution(DocInfo& doc_info) // Output solution //----------------- - sprintf(filename,"%s/soln%i_on_proc%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i_on_proc%i.dat",doc_info.directory().c_str(), doc_info.number(),my_rank); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -458,7 +458,7 @@ void MultiPoissonProblem::doc_solution(DocInfo& doc_info) // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i_on_proc%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i_on_proc%i.dat",doc_info.directory().c_str(), doc_info.number(),my_rank); some_file.open(filename); mesh_pt()->output_fct(some_file,npts,TanhSolnForMultiPoisson::get_exact_u); @@ -468,7 +468,7 @@ void MultiPoissonProblem::doc_solution(DocInfo& doc_info) // Doc error and return of the square of the L2 error //--------------------------------------------------- double error,norm; - sprintf(filename,"%s/error%i_on_proc%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i_on_proc%i.dat",doc_info.directory().c_str(), doc_info.number(),my_rank); some_file.open(filename); mesh_pt()->compute_error(some_file,TanhSolnForMultiPoisson::get_exact_u, @@ -570,7 +570,7 @@ int main(int argc, char* argv[]) // Read in partitioning from disk std::ifstream input_file; char filename[100]; - sprintf(filename,"multi_poisson_partition.dat"); + snprintf(filename, sizeof(filename), "multi_poisson_partition.dat"); input_file.open(filename); std::string input_string; for (unsigned e=0;e::doc_solution() // Output whole solution (this will output elements from one mesh //---------------------- followed by the other mesh at the moment...?) - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -543,7 +543,7 @@ void RefineableConvectionProblem::doc_solution() // Output whole solution (this will output elements from one mesh //---------------------- followed by the other mesh at the moment...?) - sprintf(filename,"%s/fluid_%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/fluid_%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); nst_mesh_pt()->output(some_file,npts); @@ -552,7 +552,7 @@ void RefineableConvectionProblem::doc_solution() // Output whole solution (this will output elements from one mesh //---------------------- followed by the other mesh at the moment...?) - sprintf(filename,"%s/temp_%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/temp_%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); adv_diff_mesh_pt()->output(some_file,npts); diff --git a/demo_drivers/multi_physics/3d_boussinesq_convection/3d_ref_b_convect.cc b/demo_drivers/multi_physics/3d_boussinesq_convection/3d_ref_b_convect.cc index a86f7aa5a97f..b1d35f3579a0 100644 --- a/demo_drivers/multi_physics/3d_boussinesq_convection/3d_ref_b_convect.cc +++ b/demo_drivers/multi_physics/3d_boussinesq_convection/3d_ref_b_convect.cc @@ -1701,7 +1701,7 @@ void RefineableConvectionProblem::doc_solution() // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); diff --git a/demo_drivers/multi_physics/axisym_heat_sphere/axisym_heat_sphere.cc b/demo_drivers/multi_physics/axisym_heat_sphere/axisym_heat_sphere.cc index bfac8e90e354..7437a6ac8ec5 100644 --- a/demo_drivers/multi_physics/axisym_heat_sphere/axisym_heat_sphere.cc +++ b/demo_drivers/multi_physics/axisym_heat_sphere/axisym_heat_sphere.cc @@ -591,7 +591,7 @@ int main() problem.newton_solve(max_adapt); //Open an output file - sprintf(filename,"soln_Re%g.dat", Global_Parameters::Re); + snprintf(filename, sizeof(filename), "soln_Re%g.dat", Global_Parameters::Re); //Doc result ofstream outfile(filename); problem.mesh_pt()->output(outfile,5); diff --git a/demo_drivers/multi_physics/axisym_heat_sphere/multi_domain_axisym_heat_sphere.cc b/demo_drivers/multi_physics/axisym_heat_sphere/multi_domain_axisym_heat_sphere.cc index 447ecc555022..3436679176ca 100644 --- a/demo_drivers/multi_physics/axisym_heat_sphere/multi_domain_axisym_heat_sphere.cc +++ b/demo_drivers/multi_physics/axisym_heat_sphere/multi_domain_axisym_heat_sphere.cc @@ -477,13 +477,13 @@ int main() problem.newton_solve(max_adapt); //Open an output file - sprintf(filename,"vel_soln_Re%g.dat", Global_Parameters::Re); + snprintf(filename, sizeof(filename), "vel_soln_Re%g.dat", Global_Parameters::Re); //Doc result ofstream outfile(filename); problem.nst_mesh_pt()->output(outfile,5); outfile.close(); - sprintf(filename,"conc_soln_Re%g.dat", Global_Parameters::Re); + snprintf(filename, sizeof(filename), "conc_soln_Re%g.dat", Global_Parameters::Re); outfile.open(filename); problem.adv_diff_mesh_pt()->output(outfile,5); outfile.close(); diff --git a/demo_drivers/multi_physics/b_convection_sphere/b_convection_sphere.cc b/demo_drivers/multi_physics/b_convection_sphere/b_convection_sphere.cc index 5156d45d9274..04f85887b0d4 100644 --- a/demo_drivers/multi_physics/b_convection_sphere/b_convection_sphere.cc +++ b/demo_drivers/multi_physics/b_convection_sphere/b_convection_sphere.cc @@ -594,7 +594,7 @@ int main() problem.newton_solve(max_adapt); //Open an output file - sprintf(filename,"soln_Re%g_Ra%g.dat", Global_Parameters::Re, + snprintf(filename, sizeof(filename), "soln_Re%g_Ra%g.dat", Global_Parameters::Re, Global_Parameters::Ra); //Doc result ofstream outfile(filename); diff --git a/demo_drivers/multi_physics/b_convection_sphere/multi_domain_b_convect_sph.cc b/demo_drivers/multi_physics/b_convection_sphere/multi_domain_b_convect_sph.cc index a267d82efc7a..ddfe245b6888 100644 --- a/demo_drivers/multi_physics/b_convection_sphere/multi_domain_b_convect_sph.cc +++ b/demo_drivers/multi_physics/b_convection_sphere/multi_domain_b_convect_sph.cc @@ -484,14 +484,14 @@ int main() problem.newton_solve(max_adapt); //Open an output file - sprintf(filename,"vel_soln_Re%g_Ra%g.dat", Global_Parameters::Re, + snprintf(filename, sizeof(filename), "vel_soln_Re%g_Ra%g.dat", Global_Parameters::Re, Global_Parameters::Ra); //Doc result ofstream outfile(filename); problem.nst_mesh_pt()->output(outfile,5); outfile.close(); - sprintf(filename,"conc_soln_Re%g_Ra%g.dat", Global_Parameters::Re, + snprintf(filename, sizeof(filename), "conc_soln_Re%g_Ra%g.dat", Global_Parameters::Re, Global_Parameters::Ra); outfile.open(filename); problem.adv_diff_mesh_pt()->output(outfile,5); diff --git a/demo_drivers/multi_physics/boussinesq_convection/boussinesq_convection.cc b/demo_drivers/multi_physics/boussinesq_convection/boussinesq_convection.cc index 6c355f8c8701..d7d4fdbcac32 100644 --- a/demo_drivers/multi_physics/boussinesq_convection/boussinesq_convection.cc +++ b/demo_drivers/multi_physics/boussinesq_convection/boussinesq_convection.cc @@ -298,7 +298,7 @@ void ConvectionProblem::doc_solution() // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); diff --git a/demo_drivers/multi_physics/boussinesq_convection/multi_domain_boussinesq_convection.cc b/demo_drivers/multi_physics/boussinesq_convection/multi_domain_boussinesq_convection.cc index acf97a13fab5..bd72b18f1bd2 100644 --- a/demo_drivers/multi_physics/boussinesq_convection/multi_domain_boussinesq_convection.cc +++ b/demo_drivers/multi_physics/boussinesq_convection/multi_domain_boussinesq_convection.cc @@ -394,14 +394,14 @@ void ConvectionProblem::doc_solution() unsigned npts=5; // Output Navier-Stokes solution - sprintf(filename,"%s/fluid_soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/fluid_soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); nst_mesh_pt()->output(some_file,npts); some_file.close(); // Output advection diffusion solution - sprintf(filename,"%s/temperature_soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/temperature_soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); adv_diff_mesh_pt()->output(some_file,npts); diff --git a/demo_drivers/multi_physics/boussinesq_convection/multi_domain_ref_b_convection.cc b/demo_drivers/multi_physics/boussinesq_convection/multi_domain_ref_b_convection.cc index 4c54249aeafe..c5ef97930a18 100644 --- a/demo_drivers/multi_physics/boussinesq_convection/multi_domain_ref_b_convection.cc +++ b/demo_drivers/multi_physics/boussinesq_convection/multi_domain_ref_b_convection.cc @@ -439,14 +439,14 @@ void RefineableConvectionProblem::doc_solution() unsigned npts=5; // Output Navier-Stokes solution - sprintf(filename,"%s/fluid_soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/fluid_soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); nst_mesh_pt()->output(some_file,npts); some_file.close(); // Output advection diffusion solution - sprintf(filename,"%s/temperature_soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/temperature_soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); adv_diff_mesh_pt()->output(some_file,npts); diff --git a/demo_drivers/multi_physics/boussinesq_convection/refineable_b_convection.cc b/demo_drivers/multi_physics/boussinesq_convection/refineable_b_convection.cc index 85ed64ecc37d..5fdac3dfb984 100644 --- a/demo_drivers/multi_physics/boussinesq_convection/refineable_b_convection.cc +++ b/demo_drivers/multi_physics/boussinesq_convection/refineable_b_convection.cc @@ -327,7 +327,7 @@ void RefineableConvectionProblem::doc_solution() // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); diff --git a/demo_drivers/multi_physics/double_diffusive_convection/dd_convection.cc b/demo_drivers/multi_physics/double_diffusive_convection/dd_convection.cc index 78a11dbfef54..c16ce5f91d83 100644 --- a/demo_drivers/multi_physics/double_diffusive_convection/dd_convection.cc +++ b/demo_drivers/multi_physics/double_diffusive_convection/dd_convection.cc @@ -346,7 +346,7 @@ void ConvectionProblem::doc_solution() // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); diff --git a/demo_drivers/multi_physics/double_diffusive_convection/multimesh_dd_convection.cc b/demo_drivers/multi_physics/double_diffusive_convection/multimesh_dd_convection.cc index dc2521f9f831..b4ddbbcdc459 100644 --- a/demo_drivers/multi_physics/double_diffusive_convection/multimesh_dd_convection.cc +++ b/demo_drivers/multi_physics/double_diffusive_convection/multimesh_dd_convection.cc @@ -1051,7 +1051,7 @@ void DDConvectionProblem::doc_solution() // Output whole solution (this will output elements from one mesh //---------------------- followed by the other mesh at the moment...?) - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); diff --git a/demo_drivers/multi_physics/double_diffusive_convection/multimesh_ref_dd_convection.cc b/demo_drivers/multi_physics/double_diffusive_convection/multimesh_ref_dd_convection.cc index 28c94a1fe3d9..7deec394f0f2 100644 --- a/demo_drivers/multi_physics/double_diffusive_convection/multimesh_ref_dd_convection.cc +++ b/demo_drivers/multi_physics/double_diffusive_convection/multimesh_ref_dd_convection.cc @@ -538,26 +538,26 @@ void RefineableDDConvectionProblem::doc_solution() // Output whole solution (this will output elements from one mesh //---------------------- followed by the other mesh at the moment...?) - /*sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + /*snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); some_file.close();*/ - sprintf(filename,"%s/nst_soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/nst_soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); nst_mesh_pt()->output(some_file,npts); some_file.close(); - sprintf(filename,"%s/temp_soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/temp_soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); temp_mesh_pt()->output(some_file,npts); some_file.close(); - sprintf(filename,"%s/conc_soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/conc_soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); conc_mesh_pt()->output(some_file,npts); diff --git a/demo_drivers/multi_physics/insoluble_surfactant/surfactant.cc b/demo_drivers/multi_physics/insoluble_surfactant/surfactant.cc index 0b21fce44a7f..69ca7bd84f84 100644 --- a/demo_drivers/multi_physics/insoluble_surfactant/surfactant.cc +++ b/demo_drivers/multi_physics/insoluble_surfactant/surfactant.cc @@ -1031,7 +1031,7 @@ void ConvectionProblem::doc_solution( // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); unsigned n_element = Bulk_mesh_pt->nelement(); @@ -1042,7 +1042,7 @@ void ConvectionProblem::doc_solution( some_file.close(); //Output the interface - sprintf(filename,"%s/int%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/int%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); diff --git a/demo_drivers/multi_physics/marangoni_convection/marangoni_convection.cc b/demo_drivers/multi_physics/marangoni_convection/marangoni_convection.cc index 058d6d588397..39d3e3d5dfbe 100644 --- a/demo_drivers/multi_physics/marangoni_convection/marangoni_convection.cc +++ b/demo_drivers/multi_physics/marangoni_convection/marangoni_convection.cc @@ -719,7 +719,7 @@ void ConvectionProblem::doc_solution() // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); diff --git a/demo_drivers/multi_physics/marangoni_convection/marangoni_convection_box.cc b/demo_drivers/multi_physics/marangoni_convection/marangoni_convection_box.cc index 23c6f2b46e0b..39110fe820cd 100644 --- a/demo_drivers/multi_physics/marangoni_convection/marangoni_convection_box.cc +++ b/demo_drivers/multi_physics/marangoni_convection/marangoni_convection_box.cc @@ -1029,7 +1029,7 @@ void ConvectionProblem::doc_solution() double angle = Global_Physical_Variables::Angle*180/Global_Physical_Variables::Pi; //The filename will have the angle appended here - sprintf(filename,"%s/soln%i_%g.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i_%g.dat",Doc_info.directory().c_str(), Doc_info.number(),angle); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); diff --git a/demo_drivers/multi_physics/rayleigh_instability_surfactant/3d_rayleigh_instability_surfactant.cc b/demo_drivers/multi_physics/rayleigh_instability_surfactant/3d_rayleigh_instability_surfactant.cc index 72d1ae83d5d3..181d703c598f 100644 --- a/demo_drivers/multi_physics/rayleigh_instability_surfactant/3d_rayleigh_instability_surfactant.cc +++ b/demo_drivers/multi_physics/rayleigh_instability_surfactant/3d_rayleigh_instability_surfactant.cc @@ -460,13 +460,13 @@ void InterfaceProblem::doc_solution(DocInfo& doc_info) // Output solution, bulk elements followed by surface elements - /*sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + /*snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); some_file.close();*/ //Change the file name and output surface in separate file - sprintf(filename,"%s/surface%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/surface%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Surface_mesh_pt->output(some_file,npts); @@ -511,7 +511,7 @@ void InterfaceProblem::unsteady_run(const unsigned& nstep) // Open trace file char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); Trace_file.open(filename); Trace_file << "VARIABLES=\"time\","; diff --git a/demo_drivers/multi_physics/rayleigh_instability_surfactant/rayleigh_instability_insoluble_surfactant.cc b/demo_drivers/multi_physics/rayleigh_instability_surfactant/rayleigh_instability_insoluble_surfactant.cc index 341d6df7aa25..eee84cba27e8 100644 --- a/demo_drivers/multi_physics/rayleigh_instability_surfactant/rayleigh_instability_insoluble_surfactant.cc +++ b/demo_drivers/multi_physics/rayleigh_instability_surfactant/rayleigh_instability_insoluble_surfactant.cc @@ -1113,7 +1113,7 @@ doc_solution(DocInfo &doc_info) const unsigned npts = 5; // Open solution output file - //sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + //snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), // doc_info.number()); //some_file.open(filename); @@ -1121,7 +1121,7 @@ doc_solution(DocInfo &doc_info) //Bulk_mesh_pt->output(some_file,npts); //some_file.close(); //Put interface in separate file - sprintf(filename,"%s/int%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/int%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Interface_mesh_pt->output(some_file,npts); @@ -1142,7 +1142,7 @@ doc_solution(DocInfo &doc_info) // some_file.close(); // Output solution to file in paraview format - //sprintf(filename,"%s/soln%i.vtu",doc_info.directory().c_str(), + //snprintf(filename, sizeof(filename), "%s/soln%i.vtu",doc_info.directory().c_str(), // doc_info.number()); //some_file.open(filename); //Bulk_mesh_pt->output_paraview(some_file,npts); @@ -1183,7 +1183,7 @@ unsteady_run(const double &t_max, const double &dt) // Open trace file char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); Trace_file.open(filename); // Initialise trace file @@ -1204,7 +1204,7 @@ unsteady_run(const double &t_max, const double &dt) // Open pvd file -- a wrapper for all the different // vtu output files plus information about continuous time // to facilitate animations in paraview - sprintf(filename,"%s/soln.pvd",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/soln.pvd",doc_info.directory().c_str()); Global_Physical_Variables::Pvd_file.open(filename); ParaviewHelper::write_pvd_header(Global_Physical_Variables::Pvd_file); diff --git a/demo_drivers/multi_physics/rayleigh_instability_surfactant/rayleigh_instability_soluble_surfactant.cc b/demo_drivers/multi_physics/rayleigh_instability_surfactant/rayleigh_instability_soluble_surfactant.cc index 2fc32fa31500..50bc2d809fe6 100644 --- a/demo_drivers/multi_physics/rayleigh_instability_surfactant/rayleigh_instability_soluble_surfactant.cc +++ b/demo_drivers/multi_physics/rayleigh_instability_surfactant/rayleigh_instability_soluble_surfactant.cc @@ -798,7 +798,7 @@ doc_solution(DocInfo &doc_info) const unsigned npts = 5; // Open solution output file -// sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), +// snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), // doc_info.number()); // some_file.open(filename); @@ -806,7 +806,7 @@ doc_solution(DocInfo &doc_info) // Bulk_mesh_pt->output(some_file,npts); // some_file.close(); //Put interface in separate file - sprintf(filename,"%s/int%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/int%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Interface_mesh_pt->output(some_file,npts); @@ -827,7 +827,7 @@ doc_solution(DocInfo &doc_info) // some_file.close(); // Output solution to file in paraview format - //sprintf(filename,"%s/soln%i.vtu",doc_info.directory().c_str(), + //snprintf(filename, sizeof(filename), "%s/soln%i.vtu",doc_info.directory().c_str(), // doc_info.number()); //some_file.open(filename); //Bulk_mesh_pt->output_paraview(some_file,npts); @@ -868,7 +868,7 @@ unsteady_run(const double &t_max, const double &dt) // Open trace file char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); Trace_file.open(filename); // Initialise trace file @@ -888,7 +888,7 @@ unsteady_run(const double &t_max, const double &dt) // Open pvd file -- a wrapper for all the different // vtu output files plus information about continuous time // to facilitate animations in paraview - //sprintf(filename,"%s/soln.pvd",doc_info.directory().c_str()); + //snprintf(filename, sizeof(filename), "%s/soln.pvd",doc_info.directory().c_str()); //Global_Physical_Variables::Pvd_file.open(filename); //ParaviewHelper::write_pvd_header(Global_Physical_Variables::Pvd_file); diff --git a/demo_drivers/multi_physics/soluble_surfactant/soluble_surfactant.cc b/demo_drivers/multi_physics/soluble_surfactant/soluble_surfactant.cc index adc4767ec6b3..7971af237b7e 100644 --- a/demo_drivers/multi_physics/soluble_surfactant/soluble_surfactant.cc +++ b/demo_drivers/multi_physics/soluble_surfactant/soluble_surfactant.cc @@ -1161,7 +1161,7 @@ void ConvectionProblem::doc_solution( // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); unsigned n_element = Bulk_mesh_pt->nelement(); @@ -1172,7 +1172,7 @@ void ConvectionProblem::doc_solution( some_file.close(); //Output the interface - sprintf(filename,"%s/int%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/int%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); diff --git a/demo_drivers/multi_physics/spherical_shell_convection/spherical_shell_convection.cc b/demo_drivers/multi_physics/spherical_shell_convection/spherical_shell_convection.cc index 2bbd64a28b16..9ca2d5145b32 100644 --- a/demo_drivers/multi_physics/spherical_shell_convection/spherical_shell_convection.cc +++ b/demo_drivers/multi_physics/spherical_shell_convection/spherical_shell_convection.cc @@ -331,7 +331,7 @@ void RefineableSphereConvectionProblem::doc_solution(DocInfo& doc_info) // Output solution //----------------- - sprintf(filename,"%s/soln%g_%g.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%g_%g.dat",doc_info.directory().c_str(), Global_Physical_Variables::Ra,this->time()); some_file.open(filename); mesh_pt()->output(some_file,npts); diff --git a/demo_drivers/multi_physics/thermal_fibre/thermal_fibre.cc b/demo_drivers/multi_physics/thermal_fibre/thermal_fibre.cc index ecb749c87c9c..61f62bde2701 100644 --- a/demo_drivers/multi_physics/thermal_fibre/thermal_fibre.cc +++ b/demo_drivers/multi_physics/thermal_fibre/thermal_fibre.cc @@ -556,7 +556,7 @@ doc_solution(DocInfo& doc_info) // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); diff --git a/demo_drivers/multi_physics/thermo/thermo.cc b/demo_drivers/multi_physics/thermo/thermo.cc index 8fcaa8049692..34cb272ec7dd 100644 --- a/demo_drivers/multi_physics/thermo/thermo.cc +++ b/demo_drivers/multi_physics/thermo/thermo.cc @@ -390,7 +390,7 @@ void ThermalProblem::doc_solution() // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); diff --git a/demo_drivers/multi_physics/two_layer_soluble_surfactant/refineable_two_layer_soluble_surfactant.cc b/demo_drivers/multi_physics/two_layer_soluble_surfactant/refineable_two_layer_soluble_surfactant.cc index 1e11efbf2ef7..d03646cdf8ea 100644 --- a/demo_drivers/multi_physics/two_layer_soluble_surfactant/refineable_two_layer_soluble_surfactant.cc +++ b/demo_drivers/multi_physics/two_layer_soluble_surfactant/refineable_two_layer_soluble_surfactant.cc @@ -1813,7 +1813,7 @@ void SurfactantProblem::doc_solution( // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); unsigned n_element = Bulk_mesh_pt->nelement(); @@ -1824,7 +1824,7 @@ void SurfactantProblem::doc_solution( some_file.close(); //Output the interface - sprintf(filename,"%s/int%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/int%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); diff --git a/demo_drivers/multi_physics/two_layer_soluble_surfactant/refineable_unstructured_two_layer_ss.cc b/demo_drivers/multi_physics/two_layer_soluble_surfactant/refineable_unstructured_two_layer_ss.cc index 637f264753da..a4aabb4e7251 100644 --- a/demo_drivers/multi_physics/two_layer_soluble_surfactant/refineable_unstructured_two_layer_ss.cc +++ b/demo_drivers/multi_physics/two_layer_soluble_surfactant/refineable_unstructured_two_layer_ss.cc @@ -1814,7 +1814,7 @@ void SurfactantProblem::doc_solution( // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); unsigned n_element = Bulk_mesh_pt->nelement(); @@ -1825,7 +1825,7 @@ void SurfactantProblem::doc_solution( some_file.close(); //Output the interface - sprintf(filename,"%s/int%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/int%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); diff --git a/demo_drivers/multi_physics/two_layer_soluble_surfactant/two_layer_soluble_surfactant.cc b/demo_drivers/multi_physics/two_layer_soluble_surfactant/two_layer_soluble_surfactant.cc index b0dd7fdb5257..812e44209e17 100644 --- a/demo_drivers/multi_physics/two_layer_soluble_surfactant/two_layer_soluble_surfactant.cc +++ b/demo_drivers/multi_physics/two_layer_soluble_surfactant/two_layer_soluble_surfactant.cc @@ -1115,7 +1115,7 @@ void SurfactantProblem::doc_solution( // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); unsigned n_element = Bulk_mesh_pt->nelement(); @@ -1126,7 +1126,7 @@ void SurfactantProblem::doc_solution( some_file.close(); //Output the interface - sprintf(filename,"%s/int%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/int%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); diff --git a/demo_drivers/multigrid/helmholtz_multigrid/structured_cubic_point_source.cc b/demo_drivers/multigrid/helmholtz_multigrid/structured_cubic_point_source.cc index 525543bde706..f23d399ddd1e 100644 --- a/demo_drivers/multigrid/helmholtz_multigrid/structured_cubic_point_source.cc +++ b/demo_drivers/multigrid/helmholtz_multigrid/structured_cubic_point_source.cc @@ -765,7 +765,7 @@ void PMLStructuredCubicHelmholtz::doc_solution() // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat", + snprintf(filename, sizeof(filename), "%s/soln%i.dat", GlobalParameters::Doc_info.directory().c_str(), GlobalParameters::Doc_info.number()); some_file.open(filename); @@ -774,7 +774,7 @@ void PMLStructuredCubicHelmholtz::doc_solution() // Ouput exact solution //--------------------- - sprintf(filename,"%s/exact_soln%i.dat", + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat", GlobalParameters::Doc_info.directory().c_str(), GlobalParameters::Doc_info.number()); some_file.open(filename); @@ -783,7 +783,7 @@ void PMLStructuredCubicHelmholtz::doc_solution() // Output coarse solution //----------------------- - sprintf(filename,"%s/coarse_soln%i.dat", + snprintf(filename, sizeof(filename), "%s/coarse_soln%i.dat", GlobalParameters::Doc_info.directory().c_str(), GlobalParameters::Doc_info.number()); some_file.open(filename); @@ -792,7 +792,7 @@ void PMLStructuredCubicHelmholtz::doc_solution() // Compute error //-------------- - sprintf(filename,"%s/error%i.dat", + snprintf(filename, sizeof(filename), "%s/error%i.dat", GlobalParameters::Doc_info.directory().c_str(), GlobalParameters::Doc_info.number()); some_file.open(filename); diff --git a/demo_drivers/multigrid/helmholtz_multigrid/unstructured_two_d_helmholtz.cc b/demo_drivers/multigrid/helmholtz_multigrid/unstructured_two_d_helmholtz.cc index 2c1b0e0f25ef..0fb743a302a8 100644 --- a/demo_drivers/multigrid/helmholtz_multigrid/unstructured_two_d_helmholtz.cc +++ b/demo_drivers/multigrid/helmholtz_multigrid/unstructured_two_d_helmholtz.cc @@ -923,7 +923,7 @@ void PMLHelmholtzMGProblem::doc_solution() // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat", + snprintf(filename, sizeof(filename), "%s/soln%i.dat", GlobalParameters::Doc_info.directory().c_str(), GlobalParameters::Doc_info.number()); some_file.open(filename); @@ -932,7 +932,7 @@ void PMLHelmholtzMGProblem::doc_solution() // Ouput exact solution //--------------------- - sprintf(filename,"%s/exact_soln%i.dat", + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat", GlobalParameters::Doc_info.directory().c_str(), GlobalParameters::Doc_info.number()); some_file.open(filename); @@ -944,7 +944,7 @@ void PMLHelmholtzMGProblem::doc_solution() { // Output solution within pml domains //----------------------------------- - sprintf(filename,"%s/pml_soln%i.dat", + snprintf(filename, sizeof(filename), "%s/pml_soln%i.dat", GlobalParameters::Doc_info.directory().c_str(), GlobalParameters::Doc_info.number()); some_file.open(filename); @@ -961,7 +961,7 @@ void PMLHelmholtzMGProblem::doc_solution() // Output coarse solution //----------------------- - sprintf(filename,"%s/coarse_soln%i.dat", + snprintf(filename, sizeof(filename), "%s/coarse_soln%i.dat", GlobalParameters::Doc_info.directory().c_str(), GlobalParameters::Doc_info.number()); some_file.open(filename); @@ -973,7 +973,7 @@ void PMLHelmholtzMGProblem::doc_solution() { // Output coarse solution within pml domains //------------------------------------------ - sprintf(filename,"%s/coarse_pml_soln%i.dat", + snprintf(filename, sizeof(filename), "%s/coarse_pml_soln%i.dat", GlobalParameters::Doc_info.directory().c_str(), GlobalParameters::Doc_info.number()); some_file.open(filename); @@ -994,7 +994,7 @@ void PMLHelmholtzMGProblem::doc_solution() // Doc error and solution norm //---------------------------- double error,norm; - sprintf(filename,"%s/error%i.dat", + snprintf(filename, sizeof(filename), "%s/error%i.dat", GlobalParameters::Doc_info.directory().c_str(), GlobalParameters::Doc_info.number()); some_file.open(filename); diff --git a/demo_drivers/multigrid/scalar_multigrid/two_d_poisson_tanh_flux_bc.cc b/demo_drivers/multigrid/scalar_multigrid/two_d_poisson_tanh_flux_bc.cc index 8b1f4c2f00e2..67e9239759e0 100644 --- a/demo_drivers/multigrid/scalar_multigrid/two_d_poisson_tanh_flux_bc.cc +++ b/demo_drivers/multigrid/scalar_multigrid/two_d_poisson_tanh_flux_bc.cc @@ -485,7 +485,7 @@ void FluxPoissonMGProblem::doc_solution(DocInfo& doc_info) // Output solution: //----------------- // Create the filename - sprintf(filename,"%s/soln%i.dat", + snprintf(filename, sizeof(filename), "%s/soln%i.dat", doc_info.directory().c_str(), doc_info.number()); @@ -501,7 +501,7 @@ void FluxPoissonMGProblem::doc_solution(DocInfo& doc_info) // Output exact solution: //----------------------- // Create the filename - sprintf(filename,"%s/exact_soln%i.dat", + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat", doc_info.directory().c_str(), doc_info.number()); @@ -526,7 +526,7 @@ void FluxPoissonMGProblem::doc_solution(DocInfo& doc_info) double soln=0.0; // Create the filename - sprintf(filename,"%s/error%i.dat", + snprintf(filename, sizeof(filename), "%s/error%i.dat", doc_info.directory().c_str(), doc_info.number()); diff --git a/demo_drivers/multigrid/scalar_multigrid/two_d_poisson_tanh_flux_bc_validate.cc b/demo_drivers/multigrid/scalar_multigrid/two_d_poisson_tanh_flux_bc_validate.cc index e125b43c975a..b08d86db66fe 100644 --- a/demo_drivers/multigrid/scalar_multigrid/two_d_poisson_tanh_flux_bc_validate.cc +++ b/demo_drivers/multigrid/scalar_multigrid/two_d_poisson_tanh_flux_bc_validate.cc @@ -634,7 +634,7 @@ void FluxPoissonMGProblem::doc_solution() // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat", + snprintf(filename, sizeof(filename), "%s/soln%i.dat", Global_Parameters::Doc_info.directory().c_str(), Global_Parameters::Doc_info.number()); some_file.open(filename); @@ -643,7 +643,7 @@ void FluxPoissonMGProblem::doc_solution() // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat", + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat", Global_Parameters::Doc_info.directory().c_str(), Global_Parameters::Doc_info.number()); some_file.open(filename); @@ -657,7 +657,7 @@ void FluxPoissonMGProblem::doc_solution() // properly deal with two different types of elements //--------------------------------------------------- double error,norm; - sprintf(filename,"%s/error%i.dat", + snprintf(filename, sizeof(filename), "%s/error%i.dat", Global_Parameters::Doc_info.directory().c_str(), Global_Parameters::Doc_info.number()); some_file.open(filename); diff --git a/demo_drivers/multigrid/scalar_multigrid/unit_cube_poisson.cc b/demo_drivers/multigrid/scalar_multigrid/unit_cube_poisson.cc index e4dc8f2bbe42..2d2409178696 100644 --- a/demo_drivers/multigrid/scalar_multigrid/unit_cube_poisson.cc +++ b/demo_drivers/multigrid/scalar_multigrid/unit_cube_poisson.cc @@ -381,7 +381,7 @@ void UnitCubePoissonMGProblem::doc_solution(DocInfo& doc_info) // Output solution: //----------------- // Create the filename - sprintf(filename,"%s/soln%i.dat", + snprintf(filename, sizeof(filename), "%s/soln%i.dat", doc_info.directory().c_str(), doc_info.number()); @@ -397,7 +397,7 @@ void UnitCubePoissonMGProblem::doc_solution(DocInfo& doc_info) // Output exact solution: //----------------------- // Create the filename - sprintf(filename,"%s/exact_soln%i.dat", + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat", doc_info.directory().c_str(), doc_info.number()); @@ -422,7 +422,7 @@ void UnitCubePoissonMGProblem::doc_solution(DocInfo& doc_info) double soln=0.0; // Create the filename - sprintf(filename,"%s/error%i.dat", + snprintf(filename, sizeof(filename), "%s/error%i.dat", doc_info.directory().c_str(), doc_info.number()); diff --git a/demo_drivers/multigrid/scalar_multigrid/unit_cube_poisson_validate.cc b/demo_drivers/multigrid/scalar_multigrid/unit_cube_poisson_validate.cc index 5b2c45070556..17a64e398b4a 100644 --- a/demo_drivers/multigrid/scalar_multigrid/unit_cube_poisson_validate.cc +++ b/demo_drivers/multigrid/scalar_multigrid/unit_cube_poisson_validate.cc @@ -525,7 +525,7 @@ void UnitCubePoissonMGProblem::doc_solution() // Output solution: //----------------- // Create the filename - sprintf(filename,"%s/soln%i.dat", + snprintf(filename, sizeof(filename), "%s/soln%i.dat", Global_Parameters::Doc_info.directory().c_str(), Global_Parameters::Doc_info.number()); @@ -541,7 +541,7 @@ void UnitCubePoissonMGProblem::doc_solution() // Output exact solution: //----------------------- // Create the filename - sprintf(filename,"%s/exact_soln%i.dat", + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat", Global_Parameters::Doc_info.directory().c_str(), Global_Parameters::Doc_info.number()); @@ -566,7 +566,7 @@ void UnitCubePoissonMGProblem::doc_solution() double soln=0.0; // Create the filename - sprintf(filename,"%s/error%i.dat", + snprintf(filename, sizeof(filename), "%s/error%i.dat", Global_Parameters::Doc_info.directory().c_str(), Global_Parameters::Doc_info.number()); diff --git a/demo_drivers/navier_stokes/adaptive_driven_cavity/adaptive_driven_cavity.cc b/demo_drivers/navier_stokes/adaptive_driven_cavity/adaptive_driven_cavity.cc index 3e088e8f2cb3..a5a5241a6864 100644 --- a/demo_drivers/navier_stokes/adaptive_driven_cavity/adaptive_driven_cavity.cc +++ b/demo_drivers/navier_stokes/adaptive_driven_cavity/adaptive_driven_cavity.cc @@ -227,7 +227,7 @@ void RefineableDrivenCavityProblem::doc_solution(DocInfo& doc_info) // Output solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); diff --git a/demo_drivers/navier_stokes/adaptive_interface/adaptive_interface.cc b/demo_drivers/navier_stokes/adaptive_interface/adaptive_interface.cc index 59e8f8e7784f..6b2cc634f7ad 100644 --- a/demo_drivers/navier_stokes/adaptive_interface/adaptive_interface.cc +++ b/demo_drivers/navier_stokes/adaptive_interface/adaptive_interface.cc @@ -1224,7 +1224,7 @@ void RefineableRotatingCylinderProblem::solve() << Bulk_mesh_pt->boundary_node_pt(2,0)->x(1) << std::endl; char file[100]; - sprintf(file,"step%i.dat",i); + snprintf(file, sizeof(file), "step%i.dat",i); filename.open(file); Bulk_mesh_pt->output(filename,5); Surface_mesh_pt->output(filename,5); diff --git a/demo_drivers/navier_stokes/bretherton/bretherton.cc b/demo_drivers/navier_stokes/bretherton/bretherton.cc index f19ded1ec2ff..be544912cd14 100644 --- a/demo_drivers/navier_stokes/bretherton/bretherton.cc +++ b/demo_drivers/navier_stokes/bretherton/bretherton.cc @@ -790,7 +790,7 @@ void BrethertonProblem::doc_solution(DocInfo& doc_info) // Output solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); @@ -798,7 +798,7 @@ void BrethertonProblem::doc_solution(DocInfo& doc_info) // Output boundaries - sprintf(filename,"%s/boundaries%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/boundaries%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output_boundaries(some_file); @@ -827,7 +827,7 @@ void BrethertonProblem::parameter_study(const unsigned& nsteps) // Open trace file char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); Trace_file.open(filename); Trace_file << "VARIABLES=\"Ca\","; diff --git a/demo_drivers/navier_stokes/channel_with_leaflet/channel_with_leaflet.cc b/demo_drivers/navier_stokes/channel_with_leaflet/channel_with_leaflet.cc index 14d5f5c00260..df649b9480a3 100644 --- a/demo_drivers/navier_stokes/channel_with_leaflet/channel_with_leaflet.cc +++ b/demo_drivers/navier_stokes/channel_with_leaflet/channel_with_leaflet.cc @@ -358,14 +358,14 @@ void ChannelWithLeafletProblem::doc_solution(DocInfo& doc_info) npts=5; // Output solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); some_file.close(); // Output boundaries - sprintf(filename,"%s/boundaries%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/boundaries%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output_boundaries(some_file); diff --git a/demo_drivers/navier_stokes/circular_driven_cavity/circular_driven_cavity.cc b/demo_drivers/navier_stokes/circular_driven_cavity/circular_driven_cavity.cc index 4c0b7950bf71..ad1debdc5abd 100644 --- a/demo_drivers/navier_stokes/circular_driven_cavity/circular_driven_cavity.cc +++ b/demo_drivers/navier_stokes/circular_driven_cavity/circular_driven_cavity.cc @@ -271,7 +271,7 @@ void QuarterCircleDrivenCavityProblem::doc_solution(DocInfo& doc_info) // Output solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); diff --git a/demo_drivers/navier_stokes/circular_driven_cavity/circular_driven_cavity2.cc b/demo_drivers/navier_stokes/circular_driven_cavity/circular_driven_cavity2.cc index 0b0c0769921a..301414b1e1d8 100644 --- a/demo_drivers/navier_stokes/circular_driven_cavity/circular_driven_cavity2.cc +++ b/demo_drivers/navier_stokes/circular_driven_cavity/circular_driven_cavity2.cc @@ -284,7 +284,7 @@ void QuarterCircleDrivenCavityProblem2::doc_solution(DocInfo& doc_info) // Output solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); diff --git a/demo_drivers/navier_stokes/collapsible_channel/collapsible_channel.cc b/demo_drivers/navier_stokes/collapsible_channel/collapsible_channel.cc index 9c69e15fa2e4..b5fd5adb857a 100644 --- a/demo_drivers/navier_stokes/collapsible_channel/collapsible_channel.cc +++ b/demo_drivers/navier_stokes/collapsible_channel/collapsible_channel.cc @@ -551,7 +551,7 @@ void CollapsibleChannelProblem:: doc_solution(DocInfo& doc_info, npts=5; // Output solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); bulk_mesh_pt()->output(some_file,npts); @@ -572,7 +572,7 @@ void CollapsibleChannelProblem:: doc_solution(DocInfo& doc_info, << std::endl; // Output wall shape - sprintf(filename,"%s/wall%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/wall%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); unsigned nplot=100; @@ -812,7 +812,7 @@ int main(int argc, char* argv[]) // Open a trace file ofstream trace_file; char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); trace_file.open(filename); // Build the problem with Crouzeix Raviart Elements diff --git a/demo_drivers/navier_stokes/collapsible_channel/collapsible_channel_algebraic.cc b/demo_drivers/navier_stokes/collapsible_channel/collapsible_channel_algebraic.cc index a973ae342091..d9c8db462ab3 100644 --- a/demo_drivers/navier_stokes/collapsible_channel/collapsible_channel_algebraic.cc +++ b/demo_drivers/navier_stokes/collapsible_channel/collapsible_channel_algebraic.cc @@ -581,7 +581,7 @@ void CollapsibleChannelProblem:: doc_solution(DocInfo& doc_info, npts=5; // Output solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); bulk_mesh_pt()->output(some_file,npts); @@ -602,7 +602,7 @@ void CollapsibleChannelProblem:: doc_solution(DocInfo& doc_info, << std::endl; // Output wall shape - sprintf(filename,"%s/wall%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/wall%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); unsigned nplot=100; @@ -844,7 +844,7 @@ int main(int argc, char* argv[]) // Open a trace file ofstream trace_file; char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); trace_file.open(filename); diff --git a/demo_drivers/navier_stokes/curved_pipe/curved_pipe.cc b/demo_drivers/navier_stokes/curved_pipe/curved_pipe.cc index 94d0b0f31f84..950487600b65 100644 --- a/demo_drivers/navier_stokes/curved_pipe/curved_pipe.cc +++ b/demo_drivers/navier_stokes/curved_pipe/curved_pipe.cc @@ -294,7 +294,7 @@ void SteadyCurvedTubeProblem::doc_solution() //Need high precision for large radii of curvature //some_file.precision(10); // Output solution labelled by the Reynolds number - sprintf(filename,"%s/soln_Re%g.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln_Re%g.dat",Doc_info.directory().c_str(), Global_Physical_Variables::Re); some_file.open(filename); mesh_pt()->output(some_file,npts); diff --git a/demo_drivers/navier_stokes/curved_pipe/helical_pipe.cc b/demo_drivers/navier_stokes/curved_pipe/helical_pipe.cc index 7841e2179d04..0ba99c6c8340 100644 --- a/demo_drivers/navier_stokes/curved_pipe/helical_pipe.cc +++ b/demo_drivers/navier_stokes/curved_pipe/helical_pipe.cc @@ -309,7 +309,7 @@ void SteadyHelicalProblem::doc_solution() //Need high precision for large radii of curvature //some_file.precision(10); // Output solution - sprintf(filename,"%s/soln_Re%g.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln_Re%g.dat",Doc_info.directory().c_str(), Global_Physical_Variables::Re); some_file.open(filename); mesh_pt()->output(some_file,npts); diff --git a/demo_drivers/navier_stokes/driven_cavity/driven_cavity.cc b/demo_drivers/navier_stokes/driven_cavity/driven_cavity.cc index eb286f8b7ac9..9250e4a54e00 100644 --- a/demo_drivers/navier_stokes/driven_cavity/driven_cavity.cc +++ b/demo_drivers/navier_stokes/driven_cavity/driven_cavity.cc @@ -214,7 +214,7 @@ void RectangularDrivenCavityProblem::doc_solution(DocInfo& doc_info) npts=5; // Output solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); diff --git a/demo_drivers/navier_stokes/falling_jet/falling_jet.cc b/demo_drivers/navier_stokes/falling_jet/falling_jet.cc index 17adfb4ed0d7..4cc63ed4e10d 100644 --- a/demo_drivers/navier_stokes/falling_jet/falling_jet.cc +++ b/demo_drivers/navier_stokes/falling_jet/falling_jet.cc @@ -360,7 +360,7 @@ EntryFlowProblem::EntryFlowProblem(DocInfo& doc_info, //Doc the boundaries /*ofstream some_file; char filename[100]; - sprintf(filename,"boundaries.dat"); + snprintf(filename, sizeof(filename), "boundaries.dat"); some_file.open(filename); mesh_pt()->output_boundaries(some_file); some_file.close();*/ @@ -561,7 +561,7 @@ void EntryFlowProblem::doc_solution() npts=5; // Output solution - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); //Only output the bulk elements, because the surface elements are diff --git a/demo_drivers/navier_stokes/flow_past_oscillating_cylinder/flow_past_oscillating_cylinder.cc b/demo_drivers/navier_stokes/flow_past_oscillating_cylinder/flow_past_oscillating_cylinder.cc index da9caefa47b5..0ae48dd97307 100644 --- a/demo_drivers/navier_stokes/flow_past_oscillating_cylinder/flow_past_oscillating_cylinder.cc +++ b/demo_drivers/navier_stokes/flow_past_oscillating_cylinder/flow_past_oscillating_cylinder.cc @@ -888,14 +888,14 @@ void FlowAroundCylinderProblem::doc_solution(const bool& in_unsteady) if (in_unsteady) { // Output solution - sprintf(filename,"%s/unsteady%i.dat", + snprintf(filename, sizeof(filename), "%s/unsteady%i.dat", GlobalParameters::Doc_info.directory().c_str(), GlobalParameters::Doc_info.number()); } else { // Output solution - sprintf(filename,"%s/soln%i.dat", + snprintf(filename, sizeof(filename), "%s/soln%i.dat", GlobalParameters::Doc_info.directory().c_str(), GlobalParameters::Doc_info.number()); } diff --git a/demo_drivers/navier_stokes/flux_control/flux_control.cc b/demo_drivers/navier_stokes/flux_control/flux_control.cc index 545ce2436f7d..0d080333f90c 100644 --- a/demo_drivers/navier_stokes/flux_control/flux_control.cc +++ b/demo_drivers/navier_stokes/flux_control/flux_control.cc @@ -832,7 +832,7 @@ void CollapsibleChannelProblem::doc_solution(DocInfo& doc_info, npts=5; // Output solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); bulk_mesh_pt()->output(some_file,npts); @@ -853,7 +853,7 @@ void CollapsibleChannelProblem::doc_solution(DocInfo& doc_info, << std::endl; // Output wall shape - sprintf(filename,"%s/wall%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/wall%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); unsigned nplot=100; @@ -1450,7 +1450,7 @@ unsteady_run(string directory_for_data, double nstep, const bool& validation_run // Open a trace file ofstream trace_file; char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); trace_file.open(filename); // Number of timesteps per period diff --git a/demo_drivers/navier_stokes/free_surface_rotation/free_surface_rotation.cc b/demo_drivers/navier_stokes/free_surface_rotation/free_surface_rotation.cc index 7357a14a22d3..41b8b036757e 100644 --- a/demo_drivers/navier_stokes/free_surface_rotation/free_surface_rotation.cc +++ b/demo_drivers/navier_stokes/free_surface_rotation/free_surface_rotation.cc @@ -504,7 +504,7 @@ FreeSurfaceRotationProblem::FreeSurfaceRotationProblem(DocInfo& doc_inf //Doc the boundaries ofstream some_file; char filename[100]; - sprintf(filename,"boundaries.dat"); + snprintf(filename, sizeof(filename), "boundaries.dat"); some_file.open(filename); mesh_pt()->output_boundaries(some_file); some_file.close(); @@ -641,7 +641,7 @@ void FreeSurfaceRotationProblem::doc_solution() npts=5; // Output solution - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); diff --git a/demo_drivers/navier_stokes/hp_adaptive_driven_cavity/circular_driven_cavity_hp_adapt.cc b/demo_drivers/navier_stokes/hp_adaptive_driven_cavity/circular_driven_cavity_hp_adapt.cc index a7cfbd2898fe..95cccb507b01 100644 --- a/demo_drivers/navier_stokes/hp_adaptive_driven_cavity/circular_driven_cavity_hp_adapt.cc +++ b/demo_drivers/navier_stokes/hp_adaptive_driven_cavity/circular_driven_cavity_hp_adapt.cc @@ -315,7 +315,7 @@ void QuarterCircleDrivenCavityProblem::doc_solution(DocInfo& doc_info) // Output solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); diff --git a/demo_drivers/navier_stokes/hp_adaptive_driven_cavity/hp_adaptive_driven_cavity.cc b/demo_drivers/navier_stokes/hp_adaptive_driven_cavity/hp_adaptive_driven_cavity.cc index 4946f1b0068a..d5dc540ac4b5 100644 --- a/demo_drivers/navier_stokes/hp_adaptive_driven_cavity/hp_adaptive_driven_cavity.cc +++ b/demo_drivers/navier_stokes/hp_adaptive_driven_cavity/hp_adaptive_driven_cavity.cc @@ -265,7 +265,7 @@ void PRefineableDrivenCavityProblem::doc_solution(DocInfo& doc_info) // Output solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); diff --git a/demo_drivers/navier_stokes/jeffery_orbit/jeffery_orbit.cc b/demo_drivers/navier_stokes/jeffery_orbit/jeffery_orbit.cc index 7f84f76d4b95..9c71d1d81195 100644 --- a/demo_drivers/navier_stokes/jeffery_orbit/jeffery_orbit.cc +++ b/demo_drivers/navier_stokes/jeffery_orbit/jeffery_orbit.cc @@ -1121,13 +1121,13 @@ void UnstructuredImmersedEllipseProblem::doc_solution( // Output solution and projection files if(!project) { - sprintf(filename,"%s/soln%i.dat", + snprintf(filename, sizeof(filename), "%s/soln%i.dat", this->Doc_info.directory().c_str(), this->Doc_info.number()); } else { - sprintf(filename,"%s/proj%i.dat", + snprintf(filename, sizeof(filename), "%s/proj%i.dat", this->Doc_info.directory().c_str(), this->Doc_info.number()-1); } @@ -1155,7 +1155,7 @@ void UnstructuredImmersedEllipseProblem::doc_solution( if(project) return; //Output the boundary only if not projecting - sprintf(filename,"%s/int%i.dat", + snprintf(filename, sizeof(filename), "%s/int%i.dat", this->Doc_info.directory().c_str(), this->Doc_info.number()); some_file.open(filename); diff --git a/demo_drivers/navier_stokes/navier_stokes_with_singularity/adaptive_driven_cavity.cc b/demo_drivers/navier_stokes/navier_stokes_with_singularity/adaptive_driven_cavity.cc index d7963dd45100..d6e021ab9bfc 100644 --- a/demo_drivers/navier_stokes/navier_stokes_with_singularity/adaptive_driven_cavity.cc +++ b/demo_drivers/navier_stokes/navier_stokes_with_singularity/adaptive_driven_cavity.cc @@ -313,14 +313,14 @@ void RefineableDrivenCavityProblem::doc_solution(DocInfo& doc_info) // Output solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); some_file.close(); // Output solution - sprintf(filename,"%s/coarse_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/coarse_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); npts=2; @@ -329,7 +329,7 @@ void RefineableDrivenCavityProblem::doc_solution(DocInfo& doc_info) // Output perturbation solution //----------------------------- - sprintf(filename,"%s/perturbation_soln_two_term%i.dat", + snprintf(filename, sizeof(filename), "%s/perturbation_soln_two_term%i.dat", doc_info.directory().c_str(), doc_info.number()); PerturbationSolution::N_terms_for_plot=2; @@ -341,7 +341,7 @@ void RefineableDrivenCavityProblem::doc_solution(DocInfo& doc_info) // Output perturbation solution //----------------------------- - sprintf(filename,"%s/perturbation_soln_one_term%i.dat", + snprintf(filename, sizeof(filename), "%s/perturbation_soln_one_term%i.dat", doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); @@ -354,7 +354,7 @@ void RefineableDrivenCavityProblem::doc_solution(DocInfo& doc_info) // Output first-order perturbation solution (Stokes) //-------------------------------------------------- - sprintf(filename,"%s/first_order_perturbation%i.dat", + snprintf(filename, sizeof(filename), "%s/first_order_perturbation%i.dat", doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); @@ -367,7 +367,7 @@ void RefineableDrivenCavityProblem::doc_solution(DocInfo& doc_info) // Output second-order perturbation solution (Stokes) //-------------------------------------------------- - sprintf(filename,"%s/second_order_perturbation%i.dat", + snprintf(filename, sizeof(filename), "%s/second_order_perturbation%i.dat", doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); @@ -379,11 +379,11 @@ void RefineableDrivenCavityProblem::doc_solution(DocInfo& doc_info) // Do line plots - sprintf(filename,"%s/line_plot%i.dat", + snprintf(filename, sizeof(filename), "%s/line_plot%i.dat", doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); - sprintf(filename,"%s/second_order_perturbation_line_plot%i.dat", + snprintf(filename, sizeof(filename), "%s/second_order_perturbation_line_plot%i.dat", doc_info.directory().c_str(), doc_info.number()); some_file2.open(filename); diff --git a/demo_drivers/navier_stokes/navier_stokes_with_singularity/driven_cavity.cc b/demo_drivers/navier_stokes/navier_stokes_with_singularity/driven_cavity.cc index f6f4742f90cd..74a824ac0068 100644 --- a/demo_drivers/navier_stokes/navier_stokes_with_singularity/driven_cavity.cc +++ b/demo_drivers/navier_stokes/navier_stokes_with_singularity/driven_cavity.cc @@ -1518,14 +1518,14 @@ void RectangularDrivenCavityProblem::doc_solution(DocInfo& doc_info) npts=10; // 100; // Output solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Navier_stokes_mesh_pt->output(some_file,npts); some_file.close(); // Output coarse solution - sprintf(filename,"%s/coarse_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/coarse_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); unsigned npts_coarse=2; @@ -1535,7 +1535,7 @@ void RectangularDrivenCavityProblem::doc_solution(DocInfo& doc_info) // Output perturbation solution //----------------------------- - sprintf(filename,"%s/perturbation_soln_two_term%i.dat", + snprintf(filename, sizeof(filename), "%s/perturbation_soln_two_term%i.dat", doc_info.directory().c_str(), doc_info.number()); PerturbationSolution::N_terms_for_plot=2; @@ -1547,7 +1547,7 @@ void RectangularDrivenCavityProblem::doc_solution(DocInfo& doc_info) // Output perturbation solution //----------------------------- - sprintf(filename,"%s/perturbation_soln_one_term%i.dat", + snprintf(filename, sizeof(filename), "%s/perturbation_soln_one_term%i.dat", doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); @@ -1560,7 +1560,7 @@ void RectangularDrivenCavityProblem::doc_solution(DocInfo& doc_info) // Output first-order perturbation solution (Stokes) //-------------------------------------------------- - sprintf(filename,"%s/first_order_perturbation%i.dat", + snprintf(filename, sizeof(filename), "%s/first_order_perturbation%i.dat", doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); @@ -1573,7 +1573,7 @@ void RectangularDrivenCavityProblem::doc_solution(DocInfo& doc_info) // Output second-order perturbation solution (Stokes) //-------------------------------------------------- - sprintf(filename,"%s/second_order_perturbation%i.dat", + snprintf(filename, sizeof(filename), "%s/second_order_perturbation%i.dat", doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); @@ -1585,11 +1585,11 @@ void RectangularDrivenCavityProblem::doc_solution(DocInfo& doc_info) // Do line plots - sprintf(filename,"%s/line_plot%i.dat", + snprintf(filename, sizeof(filename), "%s/line_plot%i.dat", doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); - sprintf(filename,"%s/second_order_perturbation_line_plot%i.dat", + snprintf(filename, sizeof(filename), "%s/second_order_perturbation_line_plot%i.dat", doc_info.directory().c_str(), doc_info.number()); some_file2.open(filename); @@ -1657,7 +1657,7 @@ void RectangularDrivenCavityProblem::doc_solution(DocInfo& doc_info) // Output exact solution //---------------------- - sprintf(filename,"%s/exact_couette_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_couette_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Navier_stokes_mesh_pt->output_fct(some_file,npts, @@ -1669,7 +1669,7 @@ void RectangularDrivenCavityProblem::doc_solution(DocInfo& doc_info) // // Doc error // //---------- // double error,norm; -// sprintf(filename,"%s/couette_error%i.dat", +// snprintf(filename, sizeof(filename), "%s/couette_error%i.dat", // doc_info.directory().c_str(), // doc_info.number()); // some_file.open(filename); @@ -1686,7 +1686,7 @@ void RectangularDrivenCavityProblem::doc_solution(DocInfo& doc_info) //---------- double error=0.0; double norm=0.0; - sprintf(filename,"%s/couette_error_with_pressure%i.dat", + snprintf(filename, sizeof(filename), "%s/couette_error_with_pressure%i.dat", doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); @@ -1711,7 +1711,7 @@ void RectangularDrivenCavityProblem::doc_solution(DocInfo& doc_info) error=0.0; norm=0.0; - sprintf(filename,"%s/couette_error_with_pressure%i.dat", + snprintf(filename, sizeof(filename), "%s/couette_error_with_pressure%i.dat", doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); diff --git a/demo_drivers/navier_stokes/osc_ellipse/osc_quarter_ellipse.cc b/demo_drivers/navier_stokes/osc_ellipse/osc_quarter_ellipse.cc index 6f26b2d66503..87b17bac5e32 100644 --- a/demo_drivers/navier_stokes/osc_ellipse/osc_quarter_ellipse.cc +++ b/demo_drivers/navier_stokes/osc_ellipse/osc_quarter_ellipse.cc @@ -474,7 +474,7 @@ void OscEllipseProblem::doc_solution(DocInfo& doc_info) // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -503,7 +503,7 @@ void OscEllipseProblem::doc_solution(DocInfo& doc_info) // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output_fct(some_file,npts,time_pt()->time(), @@ -513,7 +513,7 @@ void OscEllipseProblem::doc_solution(DocInfo& doc_info) // Doc error //---------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->compute_error(some_file, @@ -531,7 +531,7 @@ void OscEllipseProblem::doc_solution(DocInfo& doc_info) // Plot wall posn //--------------- - sprintf(filename,"%s/Wall%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/Wall%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); diff --git a/demo_drivers/navier_stokes/osc_ring/osc_ring_alg.cc b/demo_drivers/navier_stokes/osc_ring/osc_ring_alg.cc index 9b58c011a72a..266044a0a937 100644 --- a/demo_drivers/navier_stokes/osc_ring/osc_ring_alg.cc +++ b/demo_drivers/navier_stokes/osc_ring/osc_ring_alg.cc @@ -1085,7 +1085,7 @@ void OscRingNStProblem::doc_solution(DocInfo& doc_info) // Output solution on fluid mesh //------------------------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); //some_file.precision(20); some_file.open(filename); @@ -1100,7 +1100,7 @@ void OscRingNStProblem::doc_solution(DocInfo& doc_info) // Plot wall posn //--------------- - sprintf(filename,"%s/Wall%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/Wall%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); @@ -1118,7 +1118,7 @@ void OscRingNStProblem::doc_solution(DocInfo& doc_info) // Doc Sarah's asymptotic solution //-------------------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); fluid_mesh_pt()->output_fct(some_file,npts, @@ -1241,7 +1241,7 @@ void OscRingNStProblem::doc_solution(DocInfo& doc_info) } // Output fluid solution on coarse mesh - sprintf(filename,"%s/coarse_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/coarse_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); nelem=coarse_mesh_pt->nelement(); @@ -1253,7 +1253,7 @@ void OscRingNStProblem::doc_solution(DocInfo& doc_info) some_file.close(); // Write restart file - sprintf(filename,"%s/restart%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/restart%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); dump_it(some_file,doc_info); @@ -1286,7 +1286,7 @@ void OscRingNStProblem::doc_solution_historic( // Output solution on fluid mesh //------------------------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); //some_file.precision(20); some_file.open(filename); @@ -1301,7 +1301,7 @@ void OscRingNStProblem::doc_solution_historic( // Plot wall posn //--------------- - sprintf(filename,"%s/Wall%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/Wall%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); @@ -1319,7 +1319,7 @@ void OscRingNStProblem::doc_solution_historic( // Doc Sarah's asymptotic solution //-------------------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); fluid_mesh_pt()->output_fct(some_file,npts, @@ -1482,7 +1482,7 @@ void OscRingNStProblem::doc_solution_historic( } // Output fluid solution on coarse mesh - sprintf(filename,"%s/coarse_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/coarse_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); nelem=coarse_mesh_pt->nelement(); @@ -1561,7 +1561,7 @@ void OscRingNStProblem::unsteady_run( // Open trace file char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); Trace_file.open(filename); //Use constant timestep for entire simulation diff --git a/demo_drivers/navier_stokes/osc_ring/osc_ring_macro.cc b/demo_drivers/navier_stokes/osc_ring/osc_ring_macro.cc index 507e67e8ff62..ac70fa33b352 100644 --- a/demo_drivers/navier_stokes/osc_ring/osc_ring_macro.cc +++ b/demo_drivers/navier_stokes/osc_ring/osc_ring_macro.cc @@ -959,7 +959,7 @@ void OscRingNStProblem::doc_solution(DocInfo& doc_info) // Output solution on fluid mesh //------------------------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); //some_file.precision(20); some_file.open(filename); @@ -974,7 +974,7 @@ void OscRingNStProblem::doc_solution(DocInfo& doc_info) // Plot wall posn //--------------- - sprintf(filename,"%s/Wall%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/Wall%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); @@ -992,7 +992,7 @@ void OscRingNStProblem::doc_solution(DocInfo& doc_info) // Doc Sarah's asymptotic solution //-------------------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output_fct(some_file,npts, @@ -1115,7 +1115,7 @@ void OscRingNStProblem::doc_solution(DocInfo& doc_info) } // Output fluid solution on coarse mesh - sprintf(filename,"%s/coarse_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/coarse_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); nelem=coarse_mesh_pt->nelement(); @@ -1127,7 +1127,7 @@ void OscRingNStProblem::doc_solution(DocInfo& doc_info) some_file.close(); // Write restart file - sprintf(filename,"%s/restart%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/restart%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); dump_it(some_file); @@ -1193,7 +1193,7 @@ void OscRingNStProblem::unsteady_run( // Open trace file char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); Trace_file.open(filename); //Use constant timestep for entire simulation diff --git a/demo_drivers/navier_stokes/rayleigh_channel/rayleigh_channel.cc b/demo_drivers/navier_stokes/rayleigh_channel/rayleigh_channel.cc index 00f194411a83..3cbcbfe0bb80 100644 --- a/demo_drivers/navier_stokes/rayleigh_channel/rayleigh_channel.cc +++ b/demo_drivers/navier_stokes/rayleigh_channel/rayleigh_channel.cc @@ -338,7 +338,7 @@ void RayleighProblem::doc_solution(DocInfo& doc_info) unsigned npts=5; // Output solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -358,7 +358,7 @@ void RayleighProblem::doc_solution(DocInfo& doc_info) // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output_fct(some_file,npts,time_pt()->time(), @@ -368,7 +368,7 @@ void RayleighProblem::doc_solution(DocInfo& doc_info) // Doc error //---------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->compute_error(some_file, @@ -419,7 +419,7 @@ void RayleighProblem::unsteady_run(DocInfo& doc_info) // Open trace file char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); Trace_file.open(filename); // Write tecplot header for trace file diff --git a/demo_drivers/navier_stokes/rayleigh_traction_channel/rayleigh_traction_channel.cc b/demo_drivers/navier_stokes/rayleigh_traction_channel/rayleigh_traction_channel.cc index ad0bcb34b6dd..5e6fd7ab8a84 100644 --- a/demo_drivers/navier_stokes/rayleigh_traction_channel/rayleigh_traction_channel.cc +++ b/demo_drivers/navier_stokes/rayleigh_traction_channel/rayleigh_traction_channel.cc @@ -347,7 +347,7 @@ void RayleighTractionProblem::doc_solution(DocInfo& doc_inf // Output solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); @@ -367,7 +367,7 @@ void RayleighTractionProblem::doc_solution(DocInfo& doc_inf // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output_fct(some_file,npts,time_pt()->time(), @@ -377,7 +377,7 @@ void RayleighTractionProblem::doc_solution(DocInfo& doc_inf // Doc error //---------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->compute_error(some_file, @@ -460,7 +460,7 @@ void RayleighTractionProblem::unsteady_run(DocInfo& doc_inf // Open trace file char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); Trace_file.open(filename); // initialise Trace file diff --git a/demo_drivers/navier_stokes/schur_complement_preconditioner/three_d_fp.cc b/demo_drivers/navier_stokes/schur_complement_preconditioner/three_d_fp.cc index 1a142362d9cf..093e52ccf55f 100644 --- a/demo_drivers/navier_stokes/schur_complement_preconditioner/three_d_fp.cc +++ b/demo_drivers/navier_stokes/schur_complement_preconditioner/three_d_fp.cc @@ -664,7 +664,7 @@ void FpTestProblem::doc_solution(DocInfo& doc_info) npts=5; // Output solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); diff --git a/demo_drivers/navier_stokes/schur_complement_preconditioner/two_d_fp.cc b/demo_drivers/navier_stokes/schur_complement_preconditioner/two_d_fp.cc index 34b93b8953bc..854d4e05104c 100644 --- a/demo_drivers/navier_stokes/schur_complement_preconditioner/two_d_fp.cc +++ b/demo_drivers/navier_stokes/schur_complement_preconditioner/two_d_fp.cc @@ -568,7 +568,7 @@ void FpTestProblem::doc_solution(DocInfo& doc_info) npts=5; // Output solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); diff --git a/demo_drivers/navier_stokes/single_layer_free_surface/elastic_single_layer.cc b/demo_drivers/navier_stokes/single_layer_free_surface/elastic_single_layer.cc index 1828fe024662..7a09fdb85ab0 100644 --- a/demo_drivers/navier_stokes/single_layer_free_surface/elastic_single_layer.cc +++ b/demo_drivers/navier_stokes/single_layer_free_surface/elastic_single_layer.cc @@ -452,7 +452,7 @@ void InterfaceProblem::doc_solution(DocInfo &doc_info) const unsigned npts = 5; // Open solution output file - sprintf(filename,"%s/soln%i.dat", + snprintf(filename, sizeof(filename), "%s/soln%i.dat", doc_info.directory().c_str(),doc_info.number()); some_file.open(filename); @@ -463,7 +463,7 @@ void InterfaceProblem::doc_solution(DocInfo &doc_info) some_file.close(); // Open interface solution output file - sprintf(filename,"%s/interface_soln%i.dat", + snprintf(filename, sizeof(filename), "%s/interface_soln%i.dat", doc_info.directory().c_str(),doc_info.number()); some_file.open(filename); @@ -505,7 +505,7 @@ unsteady_run(const double &t_max, const double &dt) // Open trace file char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); Trace_file.open(filename); // Initialise trace file diff --git a/demo_drivers/navier_stokes/single_layer_free_surface/spine_single_layer.cc b/demo_drivers/navier_stokes/single_layer_free_surface/spine_single_layer.cc index 1ee1f9658d33..12c57f58f472 100644 --- a/demo_drivers/navier_stokes/single_layer_free_surface/spine_single_layer.cc +++ b/demo_drivers/navier_stokes/single_layer_free_surface/spine_single_layer.cc @@ -407,7 +407,7 @@ void InterfaceProblem::doc_solution(DocInfo &doc_info) const unsigned npts = 5; // Open solution output file - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); @@ -450,7 +450,7 @@ unsteady_run(const double &t_max, const double &dt) // Open trace file char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); Trace_file.open(filename); // Initialise trace file diff --git a/demo_drivers/navier_stokes/space_time_flow_past_oscillating_cylinder/space_time_oscillating_cylinder.cc b/demo_drivers/navier_stokes/space_time_flow_past_oscillating_cylinder/space_time_oscillating_cylinder.cc index 912f50dbdab5..aff563480481 100644 --- a/demo_drivers/navier_stokes/space_time_flow_past_oscillating_cylinder/space_time_oscillating_cylinder.cc +++ b/demo_drivers/navier_stokes/space_time_flow_past_oscillating_cylinder/space_time_oscillating_cylinder.cc @@ -2007,7 +2007,7 @@ void NavierStokesProblem::doc_solution(const bool& doc_spacetime_soln) // Output solution: //----------------- // Create the filename suffix - sprintf(filename,"%s/soln%i", + snprintf(filename, sizeof(filename), "%s/soln%i", GlobalParameters::Doc_info.directory().c_str(), GlobalParameters::Doc_info.number()); diff --git a/demo_drivers/navier_stokes/spine_channel/simple_spine_channel.cc b/demo_drivers/navier_stokes/spine_channel/simple_spine_channel.cc index 1b34b31cab8b..39872b311cae 100644 --- a/demo_drivers/navier_stokes/spine_channel/simple_spine_channel.cc +++ b/demo_drivers/navier_stokes/spine_channel/simple_spine_channel.cc @@ -638,7 +638,7 @@ void ChannelSpineFlowProblem::doc_solution(DocInfo& doc_info) unsigned npts=5; // Output solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -740,7 +740,7 @@ int main() // unsigned npts=5; // // Output solution -// sprintf(filename,"%s/mesh_update%i.dat",doc_info.directory().c_str(), +// snprintf(filename, sizeof(filename), "%s/mesh_update%i.dat",doc_info.directory().c_str(), // count); // count++; @@ -752,7 +752,7 @@ int main() // node_pt->node_update(); // // Output solution // some_file.open(filename); -// sprintf(filename,"%s/mesh_update%i.dat",doc_info.directory().c_str(), +// snprintf(filename, sizeof(filename), "%s/mesh_update%i.dat",doc_info.directory().c_str(), // count); // count++; // mesh_pt->output(some_file,npts); diff --git a/demo_drivers/navier_stokes/spine_channel/spine_channel.cc b/demo_drivers/navier_stokes/spine_channel/spine_channel.cc index 116251043b9f..3a8eb75961e2 100644 --- a/demo_drivers/navier_stokes/spine_channel/spine_channel.cc +++ b/demo_drivers/navier_stokes/spine_channel/spine_channel.cc @@ -489,7 +489,7 @@ void ChannelSpineFlowProblem::doc_solution(DocInfo& doc_info) unsigned npts=5; // Output solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -610,7 +610,7 @@ void doc_sparse_node_update() unsigned npts=5; // Output solution - sprintf(filename,"%s/mesh_update%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/mesh_update%i.dat",doc_info.directory().c_str(), count); count++; @@ -625,7 +625,7 @@ void doc_sparse_node_update() node_pt->node_update(); // Output solution some_file.open(filename); - sprintf(filename,"%s/mesh_update%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/mesh_update%i.dat",doc_info.directory().c_str(), count); count++; mesh_pt->output(some_file,npts); diff --git a/demo_drivers/navier_stokes/spine_channel/spine_channel2.cc b/demo_drivers/navier_stokes/spine_channel/spine_channel2.cc index 74b55b6a2e42..25c53a7c72bd 100644 --- a/demo_drivers/navier_stokes/spine_channel/spine_channel2.cc +++ b/demo_drivers/navier_stokes/spine_channel/spine_channel2.cc @@ -506,7 +506,7 @@ void SpikedChannelSpineFlowProblem::doc_solution(DocInfo& doc_info) unsigned npts=5; // Output solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); diff --git a/demo_drivers/navier_stokes/static_cap/static_single_layer.cc b/demo_drivers/navier_stokes/static_cap/static_single_layer.cc index dda8be499ae7..e81d2213d602 100644 --- a/demo_drivers/navier_stokes/static_cap/static_single_layer.cc +++ b/demo_drivers/navier_stokes/static_cap/static_single_layer.cc @@ -427,7 +427,7 @@ void CapProblem::parameter_study(const string& dir_name) // Open trace file char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); Trace_file.open(filename); Trace_file << "VARIABLES=\"aprescribed\","; Trace_file << "\"hleft\",\"hright\","; @@ -471,7 +471,7 @@ void CapProblem::doc_solution(DocInfo& doc_info) //Output domain - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); @@ -931,7 +931,7 @@ void PseudoSolidCapProblem::parameter_study(const string& dir_name) // Open trace file char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); Trace_file.open(filename); Trace_file << "VARIABLES=\"aprescribed\","; Trace_file << "\"hleft\",\"hright\","; @@ -974,7 +974,7 @@ void PseudoSolidCapProblem::doc_solution(DocInfo& doc_info) unsigned npts=5; //Output domain - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); diff --git a/demo_drivers/navier_stokes/static_cap/static_two_layer.cc b/demo_drivers/navier_stokes/static_cap/static_two_layer.cc index 587c3f6b6df2..197d86fa5d9c 100644 --- a/demo_drivers/navier_stokes/static_cap/static_two_layer.cc +++ b/demo_drivers/navier_stokes/static_cap/static_two_layer.cc @@ -343,7 +343,7 @@ void CapProblem::parameter_study() // Open trace file char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); Trace_file.open(filename); Trace_file << "VARIABLES=\"aprescribed\","; Trace_file << "\"hleft\",\"hright\","; @@ -396,7 +396,7 @@ void CapProblem::doc_solution(DocInfo& doc_info) //Output domain - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); @@ -1141,7 +1141,7 @@ void PseudoSolidCapProblem::parameter_study(const string& dir_name) // Open trace file char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); Trace_file.open(filename); Trace_file << "VARIABLES=\"aprescribed\","; Trace_file << "\"hleft\",\"hright\","; @@ -1190,7 +1190,7 @@ void PseudoSolidCapProblem::doc_solution(DocInfo& doc_info) unsigned npts=5; //Output domain - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); diff --git a/demo_drivers/navier_stokes/three_d_bretherton/three_d_breth.cc b/demo_drivers/navier_stokes/three_d_bretherton/three_d_breth.cc index 63bed3bcc9ed..b7cc8706149c 100644 --- a/demo_drivers/navier_stokes/three_d_bretherton/three_d_breth.cc +++ b/demo_drivers/navier_stokes/three_d_bretherton/three_d_breth.cc @@ -657,7 +657,7 @@ ThreeDimBethertonProblem::ThreeDimBethertonProblem() //Open trace file char filename[100]; - sprintf(filename,"RESLT/trace.dat"); + snprintf(filename, sizeof(filename), "RESLT/trace.dat"); Trace_file.open(filename); Trace_file << "VARIABLES="; Trace_file << "\"Ca\",\t \"Bo\", \t \"Alpha\", \t \"m\", \t \"pbubble\", \t \"rh_top\", \t \"rd_top\", \t \"rh_middle\", \t \"rd_bottom\", \t \"rh_bottom\",\t \"lambda\" "; @@ -851,7 +851,7 @@ void ThreeDimBethertonProblem::doc_solution(DocInfo& doc_info) mesh_pt()->node_update(); // Output solution - sprintf(filename,"%s/soln%i.dat", + snprintf(filename, sizeof(filename), "%s/soln%i.dat", doc_info.directory().c_str(),doc_info.number()); some_file.open(filename); unsigned n_bulk = mesh_pt()->nbulk(); @@ -877,7 +877,7 @@ int main(int argc,char *argv[]) // Set output directory char name_dir[20]; - sprintf(name_dir,"RESLT"); + snprintf(name_dir, sizeof(name_dir), "RESLT"); doc_info.set_directory(name_dir); doc_info.number()=0; diff --git a/demo_drivers/navier_stokes/three_d_entry_flow/full_tube.cc b/demo_drivers/navier_stokes/three_d_entry_flow/full_tube.cc index ab42ffda1898..89bfb8c6272e 100644 --- a/demo_drivers/navier_stokes/three_d_entry_flow/full_tube.cc +++ b/demo_drivers/navier_stokes/three_d_entry_flow/full_tube.cc @@ -288,7 +288,7 @@ void SteadyTubeProblem::doc_solution() //Need high precision for large radii of curvature //some_file.precision(10); // Output solution labelled by the Reynolds number - sprintf(filename,"%s/soln_Re%g.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln_Re%g.dat",Doc_info.directory().c_str(), Global_Physical_Variables::Re); some_file.open(filename); mesh_pt()->output(some_file,npts); diff --git a/demo_drivers/navier_stokes/three_d_entry_flow/three_d_entry_flow.cc b/demo_drivers/navier_stokes/three_d_entry_flow/three_d_entry_flow.cc index 465061b8dc6e..9d64ec3eaa47 100644 --- a/demo_drivers/navier_stokes/three_d_entry_flow/three_d_entry_flow.cc +++ b/demo_drivers/navier_stokes/three_d_entry_flow/three_d_entry_flow.cc @@ -160,7 +160,7 @@ EntryFlowProblem::EntryFlowProblem(DocInfo& doc_info, //Doc the boundaries ofstream some_file; char filename[100]; - sprintf(filename,"boundaries.dat"); + snprintf(filename, sizeof(filename), "boundaries.dat"); some_file.open(filename); mesh_pt()->output_boundaries(some_file); some_file.close(); @@ -279,7 +279,7 @@ void EntryFlowProblem::doc_solution() npts=5; // Output solution - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); diff --git a/demo_drivers/navier_stokes/three_d_free_surface/3d_free_surface.cc b/demo_drivers/navier_stokes/three_d_free_surface/3d_free_surface.cc index b7a915a3bc29..8fe70beb027c 100644 --- a/demo_drivers/navier_stokes/three_d_free_surface/3d_free_surface.cc +++ b/demo_drivers/navier_stokes/three_d_free_surface/3d_free_surface.cc @@ -291,7 +291,7 @@ void InterfaceProblem::doc_solution(DocInfo& doc_info) // Output solution, bulk elements followed by surface elements - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); @@ -341,7 +341,7 @@ void InterfaceProblem::unsteady_run(const unsigned& nstep) // Open trace file char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); Trace_file.open(filename); Trace_file << "VARIABLES=\"time\","; @@ -632,7 +632,7 @@ doc_solution(DocInfo& doc_info) // Output solution, bulk elements followed by surface elements - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); @@ -689,7 +689,7 @@ void ElasticInterfaceProblem::unsteady_run(const unsigned& // Open trace file char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); Trace_file.open(filename); Trace_file << "VARIABLES=\"time\","; diff --git a/demo_drivers/navier_stokes/three_d_static_cap/3d_static_cap.cc b/demo_drivers/navier_stokes/three_d_static_cap/3d_static_cap.cc index 06789ba7e6ab..39cca453b5d4 100644 --- a/demo_drivers/navier_stokes/three_d_static_cap/3d_static_cap.cc +++ b/demo_drivers/navier_stokes/three_d_static_cap/3d_static_cap.cc @@ -472,7 +472,7 @@ FreeSurfaceRotationProblem(DocInfo& doc_info, //Doc the boundaries /*ofstream some_file; char filename[100]; - sprintf(filename,"boundaries.dat"); + snprintf(filename, sizeof(filename), "boundaries.dat"); some_file.open(filename); Bulk_mesh_pt->output_boundaries(some_file); some_file.close();*/ @@ -711,7 +711,7 @@ void FreeSurfaceRotationProblem::doc_solution() npts=5; // Output solution - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); unsigned n_element = Bulk_mesh_pt->nbulk(); diff --git a/demo_drivers/navier_stokes/three_d_static_cap/3d_static_cap_elastic.cc b/demo_drivers/navier_stokes/three_d_static_cap/3d_static_cap_elastic.cc index 809769b8853d..f780c422addd 100644 --- a/demo_drivers/navier_stokes/three_d_static_cap/3d_static_cap_elastic.cc +++ b/demo_drivers/navier_stokes/three_d_static_cap/3d_static_cap_elastic.cc @@ -583,7 +583,7 @@ void SolidFreeSurfaceRotationProblem::doc_solution() npts=5; // Output solution - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); unsigned n_element = Bulk_mesh_pt->nbulk(); diff --git a/demo_drivers/navier_stokes/turek_flag_non_fsi/turek_flag_non_fsi.cc b/demo_drivers/navier_stokes/turek_flag_non_fsi/turek_flag_non_fsi.cc index a9b0875354a0..dbdfbeffa848 100644 --- a/demo_drivers/navier_stokes/turek_flag_non_fsi/turek_flag_non_fsi.cc +++ b/demo_drivers/navier_stokes/turek_flag_non_fsi/turek_flag_non_fsi.cc @@ -555,7 +555,7 @@ void TurekNonFSIProblem::doc_solution(DocInfo& doc_info) npts=5; // Output solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); diff --git a/demo_drivers/navier_stokes/two_layer_interface/elastic_two_layer_interface.cc b/demo_drivers/navier_stokes/two_layer_interface/elastic_two_layer_interface.cc index 94286189ffcf..68e9caa9e913 100644 --- a/demo_drivers/navier_stokes/two_layer_interface/elastic_two_layer_interface.cc +++ b/demo_drivers/navier_stokes/two_layer_interface/elastic_two_layer_interface.cc @@ -690,7 +690,7 @@ void InterfaceProblem::doc_solution(DocInfo &doc_info) const unsigned npts = 5; // Open solution output file - sprintf(filename,"%s/soln%i.dat", + snprintf(filename, sizeof(filename), "%s/soln%i.dat", doc_info.directory().c_str(),doc_info.number()); some_file.open(filename); @@ -701,7 +701,7 @@ void InterfaceProblem::doc_solution(DocInfo &doc_info) some_file.close(); // Open interface solution output file - sprintf(filename,"%s/interface_soln%i.dat", + snprintf(filename, sizeof(filename), "%s/interface_soln%i.dat", doc_info.directory().c_str(),doc_info.number()); some_file.open(filename); @@ -743,7 +743,7 @@ unsteady_run(const double &t_max, const double &dt) // Open trace file char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); Trace_file.open(filename); // Initialise trace file diff --git a/demo_drivers/navier_stokes/two_layer_interface/refineable_two_layer_interface.cc b/demo_drivers/navier_stokes/two_layer_interface/refineable_two_layer_interface.cc index 7d25260178ab..f9629c6faa04 100644 --- a/demo_drivers/navier_stokes/two_layer_interface/refineable_two_layer_interface.cc +++ b/demo_drivers/navier_stokes/two_layer_interface/refineable_two_layer_interface.cc @@ -999,7 +999,7 @@ void TwoLayerInterfaceProblem::doc_solution(const std::string& comment) const unsigned npts = 5; // Open solution output file - sprintf(filename,"%s/soln%i.dat", + snprintf(filename, sizeof(filename), "%s/soln%i.dat", Problem_Parameter::Doc_info.directory().c_str(), Problem_Parameter::Doc_info.number()); some_file.open(filename); @@ -1011,7 +1011,7 @@ void TwoLayerInterfaceProblem::doc_solution(const std::string& comment) some_file.close(); // Open interface solution output file - sprintf(filename,"%s/interface_soln%i.dat", + snprintf(filename, sizeof(filename), "%s/interface_soln%i.dat", Problem_Parameter::Doc_info.directory().c_str(), Problem_Parameter::Doc_info.number()); some_file.open(filename); @@ -1109,7 +1109,7 @@ int main(int argc, char **argv) // Open trace file char filename[100]; - sprintf(filename,"%s/trace.dat",Problem_Parameter::Doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",Problem_Parameter::Doc_info.directory().c_str()); Problem_Parameter::Trace_file.open(filename); // Initialise trace file diff --git a/demo_drivers/navier_stokes/two_layer_interface/spine_two_layer_interface.cc b/demo_drivers/navier_stokes/two_layer_interface/spine_two_layer_interface.cc index 1eb37b64028b..83ea8d0a3057 100644 --- a/demo_drivers/navier_stokes/two_layer_interface/spine_two_layer_interface.cc +++ b/demo_drivers/navier_stokes/two_layer_interface/spine_two_layer_interface.cc @@ -430,7 +430,7 @@ void InterfaceProblem::doc_solution(DocInfo &doc_info) const unsigned npts = 5; // Open solution output file - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); @@ -473,7 +473,7 @@ unsteady_run(const double &t_max, const double &dt) // Open trace file char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); Trace_file.open(filename); // Initialise trace file diff --git a/demo_drivers/navier_stokes/unstructured_adaptive_3d_ALE/uns_adapt_3d.cc b/demo_drivers/navier_stokes/unstructured_adaptive_3d_ALE/uns_adapt_3d.cc index f8068b09130e..d10dd3fc76c8 100644 --- a/demo_drivers/navier_stokes/unstructured_adaptive_3d_ALE/uns_adapt_3d.cc +++ b/demo_drivers/navier_stokes/unstructured_adaptive_3d_ALE/uns_adapt_3d.cc @@ -779,7 +779,7 @@ void FallingBlockProblem::doc_solution(const unsigned& nplot, // Doc local node numbering //------------------------- - sprintf(filename,"%s/node_numbering%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/node_numbering%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); FiniteElement* el_pt=mesh_pt()->finite_element_pt(0); @@ -797,7 +797,7 @@ void FallingBlockProblem::doc_solution(const unsigned& nplot, // Output boundaries //------------------ - sprintf(filename,"%s/boundaries%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/boundaries%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output_boundaries(some_file); @@ -806,7 +806,7 @@ void FallingBlockProblem::doc_solution(const unsigned& nplot, // Output solution //---------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,nplot); diff --git a/demo_drivers/navier_stokes/unstructured_adaptive_3d_ALE/uns_adapt_3d_fs.cc b/demo_drivers/navier_stokes/unstructured_adaptive_3d_ALE/uns_adapt_3d_fs.cc index 17e6257d3059..b04e483dcf59 100644 --- a/demo_drivers/navier_stokes/unstructured_adaptive_3d_ALE/uns_adapt_3d_fs.cc +++ b/demo_drivers/navier_stokes/unstructured_adaptive_3d_ALE/uns_adapt_3d_fs.cc @@ -148,7 +148,7 @@ template // Convert to a *char required by the triangulate function char tetswitches[100]; - sprintf(tetswitches,"%s",input_string_stream.str().c_str()); + snprintf(tetswitches, sizeof(tetswitches), "%s",input_string_stream.str().c_str()); // Build triangulateio refined object tetrahedralize(tetswitches, tetgen_input_pt, this->Tetgenio_pt); @@ -2128,7 +2128,7 @@ void RisingBubbleProblem::doc_solution(const unsigned& nplot, // Doc local node numbering //------------------------- - sprintf(filename,"%s/node_numbering%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/node_numbering%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); FiniteElement* el_pt=Fluid_mesh_pt->finite_element_pt(0); @@ -2149,7 +2149,7 @@ void RisingBubbleProblem::doc_solution(const unsigned& nplot, // Output boundaries //------------------ - sprintf(filename,"%s/surface%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/surface%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Free_surface_mesh_pt->output(some_file,nplot); @@ -2160,7 +2160,7 @@ void RisingBubbleProblem::doc_solution(const unsigned& nplot, // Output solution //---------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Fluid_mesh_pt->output(some_file,nplot); diff --git a/demo_drivers/navier_stokes/unstructured_adaptive_ALE/unstructured_adaptive_ALE.cc b/demo_drivers/navier_stokes/unstructured_adaptive_ALE/unstructured_adaptive_ALE.cc index 974120299899..efe530d83c56 100644 --- a/demo_drivers/navier_stokes/unstructured_adaptive_ALE/unstructured_adaptive_ALE.cc +++ b/demo_drivers/navier_stokes/unstructured_adaptive_ALE/unstructured_adaptive_ALE.cc @@ -1067,7 +1067,7 @@ void UnstructuredFluidProblem::doc_boundary_coordinates() unsigned npoints = 5; // Output solution and projection files - sprintf(filename,"RESLT/inner_hole_boundary_from_geom_obj.dat"); + snprintf(filename, sizeof(filename), "RESLT/inner_hole_boundary_from_geom_obj.dat"); some_file.open(filename); //Initialize zeta and r @@ -1289,13 +1289,13 @@ void UnstructuredFluidProblem::doc_solution( // Output solution and projection files if(!project) { - sprintf(filename,"%s/soln%i.dat", + snprintf(filename, sizeof(filename), "%s/soln%i.dat", Problem_Parameter::Doc_info.directory().c_str(), Problem_Parameter::Doc_info.number()); } else { - sprintf(filename,"%s/proj%i.dat", + snprintf(filename, sizeof(filename), "%s/proj%i.dat", Problem_Parameter::Doc_info.directory().c_str(), Problem_Parameter::Doc_info.number()-1); } diff --git a/demo_drivers/navier_stokes/unstructured_adaptive_fs/adaptive_bubble_in_channel.cc b/demo_drivers/navier_stokes/unstructured_adaptive_fs/adaptive_bubble_in_channel.cc index 48e3046428c9..694258dc7ac3 100644 --- a/demo_drivers/navier_stokes/unstructured_adaptive_fs/adaptive_bubble_in_channel.cc +++ b/demo_drivers/navier_stokes/unstructured_adaptive_fs/adaptive_bubble_in_channel.cc @@ -1160,7 +1160,7 @@ void BubbleInChannelProblem::doc_solution(const std::string& comment) ofstream some_file; char filename[100]; - sprintf(filename,"%s/soln%i.dat", + snprintf(filename, sizeof(filename), "%s/soln%i.dat", Problem_Parameter::Doc_info.directory().c_str(), Problem_Parameter::Doc_info.number()); @@ -1197,7 +1197,7 @@ void BubbleInChannelProblem::doc_solution(const std::string& comment) // Output boundaries - sprintf(filename,"%s/boundaries%i.dat", + snprintf(filename, sizeof(filename), "%s/boundaries%i.dat", Problem_Parameter::Doc_info.directory().c_str(), Problem_Parameter::Doc_info.number()); some_file.open(filename); diff --git a/demo_drivers/navier_stokes/unstructured_adaptive_fs/adaptive_drop_in_channel.cc b/demo_drivers/navier_stokes/unstructured_adaptive_fs/adaptive_drop_in_channel.cc index 5e33ca7592b5..f5797dcbd482 100644 --- a/demo_drivers/navier_stokes/unstructured_adaptive_fs/adaptive_drop_in_channel.cc +++ b/demo_drivers/navier_stokes/unstructured_adaptive_fs/adaptive_drop_in_channel.cc @@ -1196,7 +1196,7 @@ void DropInChannelProblem::doc_solution(const std::string& comment) ofstream some_file; char filename[100]; - sprintf(filename,"%s/soln%i.dat", + snprintf(filename, sizeof(filename), "%s/soln%i.dat", Problem_Parameter::Doc_info.directory().c_str(), Problem_Parameter::Doc_info.number()); @@ -1231,7 +1231,7 @@ void DropInChannelProblem::doc_solution(const std::string& comment) some_file.close(); // Output boundaries - sprintf(filename,"%s/boundaries%i.dat", + snprintf(filename, sizeof(filename), "%s/boundaries%i.dat", Problem_Parameter::Doc_info.directory().c_str(), Problem_Parameter::Doc_info.number()); some_file.open(filename); diff --git a/demo_drivers/navier_stokes/unstructured_fluid/unstructured_two_d_fluid.cc b/demo_drivers/navier_stokes/unstructured_fluid/unstructured_two_d_fluid.cc index 364eaff2c618..f00834e6b375 100644 --- a/demo_drivers/navier_stokes/unstructured_fluid/unstructured_two_d_fluid.cc +++ b/demo_drivers/navier_stokes/unstructured_fluid/unstructured_two_d_fluid.cc @@ -346,7 +346,7 @@ void UnstructuredFluidProblem::doc_solution(DocInfo& doc_info) npts=5; // Output solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); fluid_mesh_pt()->output(some_file,npts); diff --git a/demo_drivers/navier_stokes/unstructured_three_d_fluid/unstructured_three_d_fluid.cc b/demo_drivers/navier_stokes/unstructured_three_d_fluid/unstructured_three_d_fluid.cc index d16bf66e4479..db5f04899573 100644 --- a/demo_drivers/navier_stokes/unstructured_three_d_fluid/unstructured_three_d_fluid.cc +++ b/demo_drivers/navier_stokes/unstructured_three_d_fluid/unstructured_three_d_fluid.cc @@ -393,7 +393,7 @@ void UnstructuredFluidProblem::doc_solution(DocInfo& doc_info) // Output fluid solution - sprintf(filename,"%s/fluid_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/fluid_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Fluid_mesh_pt->output(some_file,npts); diff --git a/demo_drivers/navier_stokes/vmtk_fluid/vmtk_fluid.cc b/demo_drivers/navier_stokes/vmtk_fluid/vmtk_fluid.cc index 5c8ac6fb0de4..f664596f6571 100644 --- a/demo_drivers/navier_stokes/vmtk_fluid/vmtk_fluid.cc +++ b/demo_drivers/navier_stokes/vmtk_fluid/vmtk_fluid.cc @@ -405,7 +405,7 @@ void UnstructuredFluidProblem::doc_solution(DocInfo& doc_info) // Output fluid solution - sprintf(filename,"%s/fluid_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/fluid_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Fluid_mesh_pt->output(some_file,npts); diff --git a/demo_drivers/navier_stokes/vorticity_smoother/vorticity_smoother_validation.cc b/demo_drivers/navier_stokes/vorticity_smoother/vorticity_smoother_validation.cc index 3c8aed2eb419..ebf40258d7ea 100644 --- a/demo_drivers/navier_stokes/vorticity_smoother/vorticity_smoother_validation.cc +++ b/demo_drivers/navier_stokes/vorticity_smoother/vorticity_smoother_validation.cc @@ -460,8 +460,8 @@ void VorticityRecoveryProblem::check_smoothed_vorticity( ofstream some_file; char filename[10000]; - sprintf( - filename, "%s/vorticity_convergence.dat", doc_info.directory().c_str()); + snprintf( + filename, sizeof(filename), "%s/vorticity_convergence.dat", doc_info.directory().c_str()); some_file.open(filename); some_file << "VARIABLES=\"nel\",\"sqrt(1/nel)\","; if (el_pt->nvorticity_derivatives_to_recover() >= 1) @@ -602,8 +602,8 @@ void VorticityRecoveryProblem::doc_solution( unsigned npts = 2; // Create the file name - sprintf( - filename, "%s/soln%i.dat", doc_info.directory().c_str(), doc_info.number()); + snprintf( + filename, sizeof(filename), "%s/soln%i.dat", doc_info.directory().c_str(), doc_info.number()); // Open a file with the chosen file name some_file.open(filename); @@ -616,7 +616,7 @@ void VorticityRecoveryProblem::doc_solution( // Output analytical vorticity and derivatives -- uses fake // (zero) data for velocities and pressure - sprintf(filename, + snprintf(filename, sizeof(filename), "%s/analytical_vorticity_and_indicator%i.dat", doc_info.directory().c_str(), doc_info.number()); diff --git a/demo_drivers/optimisation/C_style_output/c_style_output.cc b/demo_drivers/optimisation/C_style_output/c_style_output.cc index 6b64e1b5f7d1..09f6a037f5f3 100644 --- a/demo_drivers/optimisation/C_style_output/c_style_output.cc +++ b/demo_drivers/optimisation/C_style_output/c_style_output.cc @@ -200,7 +200,7 @@ void output_both_versions(const string& file_root, Mesh* mesh_pt, doc_info.set_directory("RESLT_C_style"); // Output solution - sprintf(filename,"%s/%s.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/%s.dat",doc_info.directory().c_str(), file_root.c_str()); FILE* file_pt = fopen(filename,"w"); clock_t t_start = clock(); @@ -221,7 +221,7 @@ void output_both_versions(const string& file_root, Mesh* mesh_pt, doc_info.set_directory("RESLT_Cpp_style"); // Output solution - sprintf(filename,"%s/%s.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/%s.dat",doc_info.directory().c_str(), file_root.c_str()); some_file.open(filename); clock_t t_start = clock(); diff --git a/demo_drivers/optimisation/disable_ALE/navier_stokes/ray_circ_cavity_adapt.cc b/demo_drivers/optimisation/disable_ALE/navier_stokes/ray_circ_cavity_adapt.cc index a85ac90c7885..be6a94fd1a1c 100644 --- a/demo_drivers/optimisation/disable_ALE/navier_stokes/ray_circ_cavity_adapt.cc +++ b/demo_drivers/optimisation/disable_ALE/navier_stokes/ray_circ_cavity_adapt.cc @@ -437,7 +437,7 @@ void RayleighProblem::doc_solution(DocInfo& doc_info) unsigned npts=5; // Output solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -457,7 +457,7 @@ void RayleighProblem::doc_solution(DocInfo& doc_info) // // Output exact solution // //---------------------- -// sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), +// snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), // doc_info.number()); // some_file.open(filename); // mesh_pt()->output_fct(some_file,npts,time_pt()->time(), @@ -467,7 +467,7 @@ void RayleighProblem::doc_solution(DocInfo& doc_info) // // Doc error // //---------- // double error,norm; -// sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), +// snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), // doc_info.number()); // some_file.open(filename); // mesh_pt()->compute_error(some_file, @@ -518,7 +518,7 @@ void RayleighProblem::unsteady_run(DocInfo& doc_info) // // Open trace file // char filename[100]; -// sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); +// snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); // Trace_file.open(filename); // // Write tecplot header for trace file diff --git a/demo_drivers/optimisation/disable_ALE/navier_stokes/rayleigh_channel.cc b/demo_drivers/optimisation/disable_ALE/navier_stokes/rayleigh_channel.cc index 1c469dadbc0d..82e557f87aeb 100644 --- a/demo_drivers/optimisation/disable_ALE/navier_stokes/rayleigh_channel.cc +++ b/demo_drivers/optimisation/disable_ALE/navier_stokes/rayleigh_channel.cc @@ -363,7 +363,7 @@ void RayleighProblem::doc_solution(DocInfo& doc_info) unsigned npts=5; // Output solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -383,7 +383,7 @@ void RayleighProblem::doc_solution(DocInfo& doc_info) // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output_fct(some_file,npts,time_pt()->time(), @@ -393,7 +393,7 @@ void RayleighProblem::doc_solution(DocInfo& doc_info) // Doc error //---------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->compute_error(some_file, @@ -444,7 +444,7 @@ void RayleighProblem::unsteady_run(DocInfo& doc_info) // Open trace file char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); Trace_file.open(filename); // Write tecplot header for trace file diff --git a/demo_drivers/optimisation/disable_ALE/unsteady_heat/two_d_unsteady_heat.cc b/demo_drivers/optimisation/disable_ALE/unsteady_heat/two_d_unsteady_heat.cc index 05ca8b8f504b..ce96fa9ad8c5 100644 --- a/demo_drivers/optimisation/disable_ALE/unsteady_heat/two_d_unsteady_heat.cc +++ b/demo_drivers/optimisation/disable_ALE/unsteady_heat/two_d_unsteady_heat.cc @@ -362,7 +362,7 @@ doc_solution(DocInfo& doc_info,ofstream& trace_file) // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -382,7 +382,7 @@ doc_solution(DocInfo& doc_info,ofstream& trace_file) // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output_fct(some_file,npts,time_pt()->time(), @@ -392,7 +392,7 @@ doc_solution(DocInfo& doc_info,ofstream& trace_file) // Doc error //---------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->compute_error(some_file, @@ -465,7 +465,7 @@ void run_it(const bool& use_ale) // Open a trace file ofstream trace_file; char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); trace_file.open(filename); trace_file << "VARIABLES=\"time\",\"uFE\"," << "\"uexact\",\"norm of error\",\"norm of solution\"" diff --git a/demo_drivers/optimisation/disable_ALE/unsteady_heat/two_d_unsteady_heat_adapt.cc b/demo_drivers/optimisation/disable_ALE/unsteady_heat/two_d_unsteady_heat_adapt.cc index ebf04233fda5..b6daa6999daa 100644 --- a/demo_drivers/optimisation/disable_ALE/unsteady_heat/two_d_unsteady_heat_adapt.cc +++ b/demo_drivers/optimisation/disable_ALE/unsteady_heat/two_d_unsteady_heat_adapt.cc @@ -331,7 +331,7 @@ RefineableUnsteadyHeatProblem::RefineableUnsteadyHeatProblem( // Open trace file char filename[100]; - sprintf(filename,"%s/trace.dat",Doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",Doc_info.directory().c_str()); Trace_file.open(filename); Trace_file << "VARIABLES=\"time t\",\"uFE\",\"uexact\"," @@ -716,7 +716,7 @@ void RefineableUnsteadyHeatProblem::doc_solution() // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); @@ -745,7 +745,7 @@ void RefineableUnsteadyHeatProblem::doc_solution() // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output_fct(some_file,npts,time_pt()->time(), @@ -769,7 +769,7 @@ void RefineableUnsteadyHeatProblem::doc_solution() // Doc error //---------- double error,norm; - sprintf(filename,"%s/error%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Bulk_mesh_pt->compute_error(some_file, @@ -807,7 +807,7 @@ void RefineableUnsteadyHeatProblem::doc_solution() // Plot wall posn //--------------- - sprintf(filename,"%s/Wall%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/Wall%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); @@ -821,7 +821,7 @@ void RefineableUnsteadyHeatProblem::doc_solution() some_file.close(); // Write restart file - sprintf(filename,"%s/restart%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/restart%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); dump_it(some_file); diff --git a/demo_drivers/optimisation/fsi_jacobian_approximation/fsi_jacobian_approximation.cc b/demo_drivers/optimisation/fsi_jacobian_approximation/fsi_jacobian_approximation.cc index 983edc6de397..872c64b9ab7f 100644 --- a/demo_drivers/optimisation/fsi_jacobian_approximation/fsi_jacobian_approximation.cc +++ b/demo_drivers/optimisation/fsi_jacobian_approximation/fsi_jacobian_approximation.cc @@ -784,14 +784,14 @@ void FSICollapsibleChannelProblem:: doc_solution(DocInfo& doc_info, npts=5; // Output fluid solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); bulk_mesh_pt()->output(some_file,npts); some_file.close(); // Document the wall shape - sprintf(filename,"%s/beam%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/beam%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); wall_mesh_pt()->output(some_file,npts); @@ -1073,7 +1073,7 @@ int main(int argc, char* argv[]) // Open a trace file ofstream trace_file; char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); trace_file.open(filename); // Output the initial solution diff --git a/demo_drivers/optimisation/linear_vs_nonlinear/two_d_poisson.cc b/demo_drivers/optimisation/linear_vs_nonlinear/two_d_poisson.cc index 56781756adbd..ff6b548dcc53 100644 --- a/demo_drivers/optimisation/linear_vs_nonlinear/two_d_poisson.cc +++ b/demo_drivers/optimisation/linear_vs_nonlinear/two_d_poisson.cc @@ -266,7 +266,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info) clock_t t_start = clock(); // Do output - sprintf(filename,"%s/soln%i.cpp_style.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.cpp_style.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -289,7 +289,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info) clock_t t_start = clock(); // Do output - sprintf(filename,"%s/soln%i.c_style.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.c_style.dat",doc_info.directory().c_str(), doc_info.number()); FILE* file_pt = fopen(filename,"w"); mesh_pt()->output(file_pt,npts); @@ -306,7 +306,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info) // Doc error and return of the square of the L2 error //--------------------------------------------------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->compute_error(some_file,TanhSolnForPoisson::get_exact_u, diff --git a/demo_drivers/optimisation/sparse_assemble/sparse_assemble_test.cc b/demo_drivers/optimisation/sparse_assemble/sparse_assemble_test.cc index 33039aa82804..d84d00a6d6b9 100644 --- a/demo_drivers/optimisation/sparse_assemble/sparse_assemble_test.cc +++ b/demo_drivers/optimisation/sparse_assemble/sparse_assemble_test.cc @@ -248,7 +248,7 @@ void RectangularDrivenCavityProblem::doc_solution(DocInfo& doc_info) npts=5; // Output solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -377,7 +377,7 @@ void RectangularDrivenCavityProblem::compare_assembly_strategies( { ofstream matrix_file; char filename[100]; - sprintf(filename,"matrix%i.dat",method); + snprintf(filename, sizeof(filename), "matrix%i.dat",method); matrix_file.open(filename); matrix.sparse_indexed_output(matrix_file); matrix_file.close(); diff --git a/demo_drivers/optimisation/stored_shape_fcts/two_d_poisson_stored_shape_fcts.cc b/demo_drivers/optimisation/stored_shape_fcts/two_d_poisson_stored_shape_fcts.cc index 7b4f273a87f3..8f672b50f679 100644 --- a/demo_drivers/optimisation/stored_shape_fcts/two_d_poisson_stored_shape_fcts.cc +++ b/demo_drivers/optimisation/stored_shape_fcts/two_d_poisson_stored_shape_fcts.cc @@ -262,7 +262,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info) unsigned npts=5; // Do output - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); FILE* file_pt = fopen(filename,"w"); mesh_pt()->output(file_pt,npts); @@ -270,7 +270,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info) // Doc error and return of the square of the L2 error double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->compute_error(some_file,TanhSolnForPoisson::get_exact_u, diff --git a/demo_drivers/optimisation/use_coarse_base_meshes/two_d_poisson_adapt.cc b/demo_drivers/optimisation/use_coarse_base_meshes/two_d_poisson_adapt.cc index 321bae428f37..05374515644c 100644 --- a/demo_drivers/optimisation/use_coarse_base_meshes/two_d_poisson_adapt.cc +++ b/demo_drivers/optimisation/use_coarse_base_meshes/two_d_poisson_adapt.cc @@ -367,7 +367,7 @@ void RefineablePoissonProblem::doc_solution(DocInfo& doc_info) clock_t t_start = clock(); // Do output - sprintf(filename,"%s/soln%i.cpp_style.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.cpp_style.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -389,7 +389,7 @@ void RefineablePoissonProblem::doc_solution(DocInfo& doc_info) clock_t t_start = clock(); // Do output - sprintf(filename,"%s/soln%i.c_style.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.c_style.dat",doc_info.directory().c_str(), doc_info.number()); FILE* file_pt = fopen(filename,"w"); mesh_pt()->output(file_pt,npts); @@ -408,7 +408,7 @@ void RefineablePoissonProblem::doc_solution(DocInfo& doc_info) // Doc error and return of the square of the L2 error //--------------------------------------------------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->compute_error(some_file,TanhSolnForPoisson::get_exact_u, diff --git a/demo_drivers/pml_fourier_decomposed_helmholtz/oscillating_sphere/oscillating_sphere.cc b/demo_drivers/pml_fourier_decomposed_helmholtz/oscillating_sphere/oscillating_sphere.cc index fbabbfdfc0be..aeb8ec245d1d 100644 --- a/demo_drivers/pml_fourier_decomposed_helmholtz/oscillating_sphere/oscillating_sphere.cc +++ b/demo_drivers/pml_fourier_decomposed_helmholtz/oscillating_sphere/oscillating_sphere.cc @@ -987,7 +987,7 @@ doc_solution(DocInfo& doc_info) // Compute/output the radiated power //---------------------------------- - sprintf(filename,"%s/power%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/power%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); @@ -1006,7 +1006,7 @@ doc_solution(DocInfo& doc_info) // Output solution within the bulk mesh //------------------------------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); @@ -1014,7 +1014,7 @@ doc_solution(DocInfo& doc_info) // Output solution within pml domains //----------------------------------- - sprintf(filename,"%s/pml_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/pml_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); PML_top_mesh_pt->output(some_file,npts); @@ -1027,7 +1027,7 @@ doc_solution(DocInfo& doc_info) // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output_fct(some_file,npts,ProblemParameters::get_exact_u); @@ -1037,7 +1037,7 @@ doc_solution(DocInfo& doc_info) // Doc error and return of the square of the L2 error //--------------------------------------------------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->compute_error(some_file,ProblemParameters::get_exact_u, @@ -1048,7 +1048,7 @@ doc_solution(DocInfo& doc_info) cout << "\nNorm of error : " << sqrt(error) << std::endl; cout << "Norm of solution: " << sqrt(norm) << std::endl << std::endl; - sprintf(filename,"%s/int_error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/int_error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); // Doc L2 error and norm of solution diff --git a/demo_drivers/pml_helmholtz/scattering/unstructured_two_d_helmholtz.cc b/demo_drivers/pml_helmholtz/scattering/unstructured_two_d_helmholtz.cc index 3fcf62e6e77c..802734a6b12a 100644 --- a/demo_drivers/pml_helmholtz/scattering/unstructured_two_d_helmholtz.cc +++ b/demo_drivers/pml_helmholtz/scattering/unstructured_two_d_helmholtz.cc @@ -462,7 +462,7 @@ void PMLProblem::doc_solution(DocInfo& doc_info) // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); @@ -470,7 +470,7 @@ void PMLProblem::doc_solution(DocInfo& doc_info) // Output coarse solution //----------------------- - sprintf(filename,"%s/coarse_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/coarse_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); unsigned npts_coarse=2; @@ -480,7 +480,7 @@ void PMLProblem::doc_solution(DocInfo& doc_info) // Output solution within pml domains //----------------------------------- - sprintf(filename,"%s/pml_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/pml_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); PML_top_mesh_pt->output(some_file,npts); @@ -506,7 +506,7 @@ void PMLProblem::doc_solution(DocInfo& doc_info) // unsigned nstep=40; // for (unsigned i=0;i::doc_solution(DocInfo& doc_info) // Compute/output the radiated power //---------------------------------- - sprintf(filename,"%s/power%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/power%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); @@ -668,7 +668,7 @@ void PMLProblem::doc_solution(DocInfo& doc_info) // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); @@ -676,14 +676,14 @@ void PMLProblem::doc_solution(DocInfo& doc_info) // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output_fct(some_file,npts,GlobalParameters::get_exact_u); some_file.close(); double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->compute_error(some_file,GlobalParameters::get_exact_u, @@ -696,7 +696,7 @@ void PMLProblem::doc_solution(DocInfo& doc_info) // Output PML layers //----------------- - sprintf(filename,"%s/pml_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/pml_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); PML_right_mesh_pt->output(some_file,npts); @@ -721,7 +721,7 @@ void PMLProblem::doc_solution(DocInfo& doc_info) // unsigned nstep=40; // for (unsigned i=0;i::doc_solution(DocInfo& doc_info) // Output displacement field //-------------------------- - sprintf(filename,"%s/soln_bulk%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln_bulk%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Solid_mesh_pt->output(some_file,n_plot); some_file.close(); - sprintf(filename,"%s/soln_pml_right%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln_pml_right%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); PML_right_mesh_pt->output(some_file,n_plot); some_file.close(); - sprintf(filename,"%s/soln_pml_top%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln_pml_top%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); PML_top_mesh_pt->output(some_file,n_plot); some_file.close(); - sprintf(filename,"%s/soln_pml_left%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln_pml_left%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); PML_left_mesh_pt->output(some_file,n_plot); some_file.close(); - sprintf(filename,"%s/soln_pml_bottom%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln_pml_bottom%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); PML_bottom_mesh_pt->output(some_file,n_plot); some_file.close(); - sprintf(filename,"%s/soln_pml_top_right%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln_pml_top_right%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); PML_top_right_mesh_pt->output(some_file,n_plot); some_file.close(); - sprintf(filename,"%s/soln_pml_top_left%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln_pml_top_left%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); PML_top_left_mesh_pt->output(some_file,n_plot); some_file.close(); - sprintf(filename,"%s/soln_pml_bottom_right%i.dat", + snprintf(filename, sizeof(filename), "%s/soln_pml_bottom_right%i.dat", Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); PML_bottom_right_mesh_pt->output(some_file,n_plot); some_file.close(); - sprintf(filename,"%s/soln_pml_bottom_left%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln_pml_bottom_left%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); PML_bottom_left_mesh_pt->output(some_file,n_plot); @@ -694,7 +694,7 @@ void ElasticAnnulusProblem::doc_solution(DocInfo& doc_info) // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Solid_mesh_pt->output_fct(some_file,n_plot,Global_Parameters::exact_u); @@ -703,7 +703,7 @@ void ElasticAnnulusProblem::doc_solution(DocInfo& doc_info) // Doc error and return of the square of the L2 error //--------------------------------------------------- double error,norm; - sprintf(filename,"%s/error_and_norm%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error_and_norm%i.dat",Doc_info.directory().c_str(), Doc_info.number()); Solid_mesh_pt->compute_error(some_file,Global_Parameters::exact_u, error,norm); @@ -717,14 +717,14 @@ void ElasticAnnulusProblem::doc_solution(DocInfo& doc_info) cout << "Norm of exact solution: " << sqrt(norm) << endl; // Output runtime (wall clock time) in s in a file - sprintf(filename,"%s/wall_clock_time%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/wall_clock_time%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); some_file << Global_Parameters::T_end-Global_Parameters::T_start << std::endl; some_file.close(); // Output number of degrees of freedom in a file - sprintf(filename,"%s/ndof%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/ndof%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); some_file << this->ndof() << std::endl; @@ -732,7 +732,7 @@ void ElasticAnnulusProblem::doc_solution(DocInfo& doc_info) // Output norm of solution (to allow validation of solution even // if triangle generates a slightly different mesh) - sprintf(filename,"%s/elast_soln_norm%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/elast_soln_norm%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); double norm_soln=0.0; diff --git a/demo_drivers/pml_time_harmonic_linear_elasticity/time_harmonic_elasticity_driver_source.cc b/demo_drivers/pml_time_harmonic_linear_elasticity/time_harmonic_elasticity_driver_source.cc index 6ce2733edd79..3e45b2bd998d 100644 --- a/demo_drivers/pml_time_harmonic_linear_elasticity/time_harmonic_elasticity_driver_source.cc +++ b/demo_drivers/pml_time_harmonic_linear_elasticity/time_harmonic_elasticity_driver_source.cc @@ -414,77 +414,77 @@ void ElasticAnnulusProblem::doc_solution(DocInfo& doc_info) // Output displacement field //-------------------------- - sprintf(filename,"%s/soln_bulk%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln_bulk%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Solid_mesh_pt->output(some_file,n_plot); some_file.close(); - sprintf(filename,"%s/soln_pml_right%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln_pml_right%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); PML_right_mesh_pt->output(some_file,n_plot); some_file.close(); - sprintf(filename,"%s/soln_pml_top%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln_pml_top%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); PML_top_mesh_pt->output(some_file,n_plot); some_file.close(); - sprintf(filename,"%s/soln_pml_left%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln_pml_left%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); PML_left_mesh_pt->output(some_file,n_plot); some_file.close(); - sprintf(filename,"%s/soln_pml_bottom%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln_pml_bottom%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); PML_bottom_mesh_pt->output(some_file,n_plot); some_file.close(); - sprintf(filename,"%s/soln_pml_top_right%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln_pml_top_right%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); PML_top_right_mesh_pt->output(some_file,n_plot); some_file.close(); - sprintf(filename,"%s/soln_pml_top_left%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln_pml_top_left%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); PML_top_left_mesh_pt->output(some_file,n_plot); some_file.close(); - sprintf(filename,"%s/soln_pml_bottom_right%i.dat", + snprintf(filename, sizeof(filename), "%s/soln_pml_bottom_right%i.dat", Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); PML_bottom_right_mesh_pt->output(some_file,n_plot); some_file.close(); - sprintf(filename,"%s/soln_pml_bottom_left%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln_pml_bottom_left%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); PML_bottom_left_mesh_pt->output(some_file,n_plot); some_file.close(); // Output runtime (wall clock time) in s in a file - sprintf(filename,"%s/wall_clock_time%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/wall_clock_time%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); some_file << Global_Parameters::T_end-Global_Parameters::T_start << std::endl; some_file.close(); // Output number of degrees of freedom in a file - sprintf(filename,"%s/ndof%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/ndof%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); some_file << this->ndof() << std::endl; some_file.close(); // Output norm of solution - sprintf(filename,"%s/elast_soln_norm%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/elast_soln_norm%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); double norm_soln=0.0; diff --git a/demo_drivers/poisson/eighth_sphere_poisson/eighth_sphere_poisson.cc b/demo_drivers/poisson/eighth_sphere_poisson/eighth_sphere_poisson.cc index 21ebf7b6dd78..2669dbbca14c 100644 --- a/demo_drivers/poisson/eighth_sphere_poisson/eighth_sphere_poisson.cc +++ b/demo_drivers/poisson/eighth_sphere_poisson/eighth_sphere_poisson.cc @@ -280,7 +280,7 @@ void EighthSpherePoissonProblem::doc_solution(DocInfo& doc_info) // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -289,7 +289,7 @@ void EighthSpherePoissonProblem::doc_solution(DocInfo& doc_info) // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output_fct(some_file,npts,TanhSolnForPoisson::get_exact_u); @@ -299,7 +299,7 @@ void EighthSpherePoissonProblem::doc_solution(DocInfo& doc_info) // Doc error //---------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->compute_error(some_file,TanhSolnForPoisson::get_exact_u, diff --git a/demo_drivers/poisson/eighth_sphere_poisson_hp_adapt/eighth_sphere_poisson_hp_adapt.cc b/demo_drivers/poisson/eighth_sphere_poisson_hp_adapt/eighth_sphere_poisson_hp_adapt.cc index a5c16564f8c6..a1e553b27aec 100644 --- a/demo_drivers/poisson/eighth_sphere_poisson_hp_adapt/eighth_sphere_poisson_hp_adapt.cc +++ b/demo_drivers/poisson/eighth_sphere_poisson_hp_adapt/eighth_sphere_poisson_hp_adapt.cc @@ -302,7 +302,7 @@ void EighthSpherePoissonProblem::doc_solution(DocInfo& doc_info) // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -313,7 +313,7 @@ void EighthSpherePoissonProblem::doc_solution(DocInfo& doc_info) // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output_fct(some_file,npts,TanhSolnForPoisson::get_exact_u); @@ -323,7 +323,7 @@ void EighthSpherePoissonProblem::doc_solution(DocInfo& doc_info) // Doc error //---------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->compute_error(some_file,TanhSolnForPoisson::get_exact_u, diff --git a/demo_drivers/poisson/elastic_poisson/elastic_poisson.cc b/demo_drivers/poisson/elastic_poisson/elastic_poisson.cc index e914010d1cd6..e47e7ff24d68 100644 --- a/demo_drivers/poisson/elastic_poisson/elastic_poisson.cc +++ b/demo_drivers/poisson/elastic_poisson/elastic_poisson.cc @@ -335,7 +335,7 @@ RefineableFishPoissonProblem::RefineableFishPoissonProblem( // Open trace file char filename[100]; - sprintf(filename,"%s/trace.dat",directory_name.c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",directory_name.c_str()); Trace_file.open(filename); Trace_file @@ -490,7 +490,7 @@ void RefineableFishPoissonProblem::doc_solution() // Output solution - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); fish_mesh_pt()->output(some_file,npts); diff --git a/demo_drivers/poisson/fish_poisson/fish_poisson.cc b/demo_drivers/poisson/fish_poisson/fish_poisson.cc index ca079906e8fc..e184582e1250 100644 --- a/demo_drivers/poisson/fish_poisson/fish_poisson.cc +++ b/demo_drivers/poisson/fish_poisson/fish_poisson.cc @@ -169,7 +169,7 @@ void RefineableFishPoissonProblem::doc_solution(DocInfo& doc_info) npts=5; // Output solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); diff --git a/demo_drivers/poisson/fish_poisson/fish_poisson_no_adapt.cc b/demo_drivers/poisson/fish_poisson/fish_poisson_no_adapt.cc index 277d654cd8d5..b9fe683926d6 100644 --- a/demo_drivers/poisson/fish_poisson/fish_poisson_no_adapt.cc +++ b/demo_drivers/poisson/fish_poisson/fish_poisson_no_adapt.cc @@ -165,21 +165,21 @@ void FishPoissonProblem::doc_solution(DocInfo& doc_info) // Output solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); some_file.close(); // Output solution - sprintf(filename,"%s/soln_nodes%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln_nodes%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,4); some_file.close(); // Output solution - sprintf(filename,"%s/soln_fine%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln_fine%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,20*npts); @@ -187,7 +187,7 @@ void FishPoissonProblem::doc_solution(DocInfo& doc_info) // Output boundaries - sprintf(filename,"%s/boundaries%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/boundaries%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output_boundaries(some_file); diff --git a/demo_drivers/poisson/fish_poisson2/fish_poisson_adapt.cc b/demo_drivers/poisson/fish_poisson2/fish_poisson_adapt.cc index 79ec8451eaf0..0e014221fe41 100644 --- a/demo_drivers/poisson/fish_poisson2/fish_poisson_adapt.cc +++ b/demo_drivers/poisson/fish_poisson2/fish_poisson_adapt.cc @@ -168,7 +168,7 @@ void RefineableFishPoissonProblem::doc_solution(DocInfo& doc_info) npts=5; // Output solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); diff --git a/demo_drivers/poisson/fish_poisson2/fish_poisson_no_adapt.cc b/demo_drivers/poisson/fish_poisson2/fish_poisson_no_adapt.cc index 859c389af166..86c3e5a2b1b6 100644 --- a/demo_drivers/poisson/fish_poisson2/fish_poisson_no_adapt.cc +++ b/demo_drivers/poisson/fish_poisson2/fish_poisson_no_adapt.cc @@ -163,7 +163,7 @@ void FishPoissonProblem::doc_solution(DocInfo& doc_info) npts=5; // Output solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); diff --git a/demo_drivers/poisson/fish_poisson2/fish_poisson_node_update.cc b/demo_drivers/poisson/fish_poisson2/fish_poisson_node_update.cc index ba5220903e97..c041a1969925 100644 --- a/demo_drivers/poisson/fish_poisson2/fish_poisson_node_update.cc +++ b/demo_drivers/poisson/fish_poisson2/fish_poisson_node_update.cc @@ -167,14 +167,14 @@ void RefineableFishPoissonProblem::doc_solution(DocInfo& doc_info) npts=5; // Output solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); some_file.close(); // Output boundaries - sprintf(filename,"%s/boundaries%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/boundaries%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output_boundaries(some_file); diff --git a/demo_drivers/poisson/fish_poisson2/fish_poisson_simple_adapt.cc b/demo_drivers/poisson/fish_poisson2/fish_poisson_simple_adapt.cc index 96371c29312f..9c32513cc076 100644 --- a/demo_drivers/poisson/fish_poisson2/fish_poisson_simple_adapt.cc +++ b/demo_drivers/poisson/fish_poisson2/fish_poisson_simple_adapt.cc @@ -210,7 +210,7 @@ void SimpleRefineableFishPoissonProblem::doc_solution(DocInfo& doc_info npts=5; // Output solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); diff --git a/demo_drivers/poisson/one_d_poisson_adapt/one_d_poisson_adapt.cc b/demo_drivers/poisson/one_d_poisson_adapt/one_d_poisson_adapt.cc index 11341d8ebd7f..c80c6c6daab8 100644 --- a/demo_drivers/poisson/one_d_poisson_adapt/one_d_poisson_adapt.cc +++ b/demo_drivers/poisson/one_d_poisson_adapt/one_d_poisson_adapt.cc @@ -233,7 +233,7 @@ void RefineableOneDPoissonProblem::doc_solution(DocInfo& doc_info) // Output solution // --------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -241,7 +241,7 @@ void RefineableOneDPoissonProblem::doc_solution(DocInfo& doc_info) // Output exact solution // --------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output_fct(some_file,npts,ArcTanSolnForPoisson::get_exact_u); @@ -250,7 +250,7 @@ void RefineableOneDPoissonProblem::doc_solution(DocInfo& doc_info) // Doc error and return of the square of the L2 error // -------------------------------------------------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->compute_error(some_file,ArcTanSolnForPoisson::get_exact_u, diff --git a/demo_drivers/poisson/one_d_poisson_hp_adapt/one_d_poisson_hp_adapt.cc b/demo_drivers/poisson/one_d_poisson_hp_adapt/one_d_poisson_hp_adapt.cc index 01c633b47c0b..de12ecaf669f 100644 --- a/demo_drivers/poisson/one_d_poisson_hp_adapt/one_d_poisson_hp_adapt.cc +++ b/demo_drivers/poisson/one_d_poisson_hp_adapt/one_d_poisson_hp_adapt.cc @@ -1933,7 +1933,7 @@ void PRefineableOneDPoissonProblem::doc_solution(DocInfo& doc_info) // Output solution // --------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -1941,7 +1941,7 @@ void PRefineableOneDPoissonProblem::doc_solution(DocInfo& doc_info) // Output exact solution // --------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output_fct(some_file,npts,ArcTanSolnForPoisson::get_exact_u); @@ -1950,7 +1950,7 @@ void PRefineableOneDPoissonProblem::doc_solution(DocInfo& doc_info) // Doc error and return of the square of the L2 error // -------------------------------------------------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->compute_error(some_file,ArcTanSolnForPoisson::get_exact_u, diff --git a/demo_drivers/poisson/poisson_with_singularity/two_d_poisson.cc b/demo_drivers/poisson/poisson_with_singularity/two_d_poisson.cc index aea5f517c14b..b7de3c28eb46 100644 --- a/demo_drivers/poisson/poisson_with_singularity/two_d_poisson.cc +++ b/demo_drivers/poisson/poisson_with_singularity/two_d_poisson.cc @@ -818,7 +818,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info) // Output solution with few plot points //------------------------------------- npts=5; - sprintf(filename,"%s/soln_coarse%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln_coarse%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Poisson_mesh_pt->output(some_file,npts); @@ -827,7 +827,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info) // Output solution with lots of plot points //----------------------------------------- npts=5; - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Poisson_mesh_pt->output(some_file,npts); @@ -835,7 +835,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info) // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Poisson_mesh_pt->output_fct(some_file,npts,Global_parameters::get_exact_u); @@ -844,7 +844,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info) // Doc error and return of the square of the L2 error //--------------------------------------------------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Poisson_mesh_pt->compute_error(some_file,Global_parameters::get_exact_u, diff --git a/demo_drivers/poisson/spectral/one_d_spectral.cc b/demo_drivers/poisson/spectral/one_d_spectral.cc index d608a3416816..87507259e638 100644 --- a/demo_drivers/poisson/spectral/one_d_spectral.cc +++ b/demo_drivers/poisson/spectral/one_d_spectral.cc @@ -217,21 +217,21 @@ void OneDPoissonProblem::doc_solution(const unsigned& label) npts=5; // Output solution with specified number of plot points per element - sprintf(filename,"soln%i.dat",label); + snprintf(filename, sizeof(filename), "soln%i.dat",label); some_file.open(filename); mesh_pt()->output(some_file,npts); some_file.close(); // Output exact solution at much higher resolution (so we can // see how well the solutions agree between nodal points) - sprintf(filename,"exact_soln%i.dat",label); + snprintf(filename, sizeof(filename), "exact_soln%i.dat",label); some_file.open(filename); mesh_pt()->output_fct(some_file,20*npts,FishSolnOneDPoisson::get_exact_u); some_file.close(); // Doc pointwise error and compute norm of error and of the solution double error,norm; - sprintf(filename,"error%i.dat",label); + snprintf(filename, sizeof(filename), "error%i.dat",label); some_file.open(filename); mesh_pt()->compute_error(some_file,FishSolnOneDPoisson::get_exact_u, error,norm); diff --git a/demo_drivers/poisson/spectral/three_d_spectral_adapt.cc b/demo_drivers/poisson/spectral/three_d_spectral_adapt.cc index d33f061ed121..88567321ea7b 100644 --- a/demo_drivers/poisson/spectral/three_d_spectral_adapt.cc +++ b/demo_drivers/poisson/spectral/three_d_spectral_adapt.cc @@ -288,7 +288,7 @@ void EighthSpherePoissonProblem::doc_solution(DocInfo& doc_info) // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -297,7 +297,7 @@ void EighthSpherePoissonProblem::doc_solution(DocInfo& doc_info) // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output_fct(some_file,npts,TanhSolnForPoisson::get_exact_u); @@ -307,7 +307,7 @@ void EighthSpherePoissonProblem::doc_solution(DocInfo& doc_info) // Doc error //---------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->compute_error(some_file,TanhSolnForPoisson::get_exact_u, diff --git a/demo_drivers/poisson/spectral/two_d_spectral_adapt.cc b/demo_drivers/poisson/spectral/two_d_spectral_adapt.cc index 4353d990468a..baba0d1fd090 100644 --- a/demo_drivers/poisson/spectral/two_d_spectral_adapt.cc +++ b/demo_drivers/poisson/spectral/two_d_spectral_adapt.cc @@ -308,7 +308,7 @@ void RefineablePoissonProblem::doc_solution(DocInfo& doc_info) // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -317,7 +317,7 @@ void RefineablePoissonProblem::doc_solution(DocInfo& doc_info) // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output_fct(some_file,npts,TanhSolnForPoisson::get_exact_u); @@ -326,7 +326,7 @@ void RefineablePoissonProblem::doc_solution(DocInfo& doc_info) // Doc error and return of the square of the L2 error //--------------------------------------------------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->compute_error(some_file,TanhSolnForPoisson::get_exact_u, diff --git a/demo_drivers/poisson/two_d_poisson/two_d_poisson.cc b/demo_drivers/poisson/two_d_poisson/two_d_poisson.cc index f38d96c916e6..787a5a56d0f7 100644 --- a/demo_drivers/poisson/two_d_poisson/two_d_poisson.cc +++ b/demo_drivers/poisson/two_d_poisson/two_d_poisson.cc @@ -229,7 +229,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info) // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -238,7 +238,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info) // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output_fct(some_file,npts,TanhSolnForPoisson::get_exact_u); @@ -247,7 +247,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info) // Doc error and return of the square of the L2 error //--------------------------------------------------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->compute_error(some_file,TanhSolnForPoisson::get_exact_u, diff --git a/demo_drivers/poisson/two_d_poisson/two_d_poisson2.cc b/demo_drivers/poisson/two_d_poisson/two_d_poisson2.cc index 9dd646e3f669..2f0234ea5176 100644 --- a/demo_drivers/poisson/two_d_poisson/two_d_poisson2.cc +++ b/demo_drivers/poisson/two_d_poisson/two_d_poisson2.cc @@ -232,7 +232,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info) // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -241,7 +241,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info) // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output_fct(some_file,npts,TanhSolnForPoisson::get_exact_u); @@ -250,7 +250,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info) // Doc error and return of the square of the L2 error //--------------------------------------------------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->compute_error(some_file,TanhSolnForPoisson::get_exact_u, diff --git a/demo_drivers/poisson/two_d_poisson/two_d_poisson_compare_solvers.cc b/demo_drivers/poisson/two_d_poisson/two_d_poisson_compare_solvers.cc index 0027a9297b93..2976a724dde4 100644 --- a/demo_drivers/poisson/two_d_poisson/two_d_poisson_compare_solvers.cc +++ b/demo_drivers/poisson/two_d_poisson/two_d_poisson_compare_solvers.cc @@ -272,7 +272,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info) // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -281,7 +281,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info) // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output_fct(some_file,npts,TanhSolnForPoisson::get_exact_u); @@ -290,7 +290,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info) // Doc error and return of the square of the L2 error //--------------------------------------------------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->compute_error(some_file,TanhSolnForPoisson::get_exact_u, diff --git a/demo_drivers/poisson/two_d_poisson_adapt/two_d_poisson_adapt.cc b/demo_drivers/poisson/two_d_poisson_adapt/two_d_poisson_adapt.cc index e17c405ceadc..458ba860c86b 100644 --- a/demo_drivers/poisson/two_d_poisson_adapt/two_d_poisson_adapt.cc +++ b/demo_drivers/poisson/two_d_poisson_adapt/two_d_poisson_adapt.cc @@ -287,7 +287,7 @@ void RefineablePoissonProblem::doc_solution(DocInfo& doc_info) // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -296,7 +296,7 @@ void RefineablePoissonProblem::doc_solution(DocInfo& doc_info) // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output_fct(some_file,npts,TanhSolnForPoisson::get_exact_u); @@ -305,7 +305,7 @@ void RefineablePoissonProblem::doc_solution(DocInfo& doc_info) // Doc error and return of the square of the L2 error //--------------------------------------------------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->compute_error(some_file,TanhSolnForPoisson::get_exact_u, diff --git a/demo_drivers/poisson/two_d_poisson_flux_bc/two_d_poisson_flux_bc.cc b/demo_drivers/poisson/two_d_poisson_flux_bc/two_d_poisson_flux_bc.cc index ef528102e0a8..933d6d9273c8 100644 --- a/demo_drivers/poisson/two_d_poisson_flux_bc/two_d_poisson_flux_bc.cc +++ b/demo_drivers/poisson/two_d_poisson_flux_bc/two_d_poisson_flux_bc.cc @@ -305,7 +305,7 @@ void FluxPoissonProblem::doc_solution(DocInfo& doc_info) // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -313,7 +313,7 @@ void FluxPoissonProblem::doc_solution(DocInfo& doc_info) // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); for(unsigned e=0;e::doc_solution(DocInfo& doc_info) // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); @@ -298,7 +298,7 @@ void TwoMeshFluxPoissonProblem::doc_solution(DocInfo& doc_info) // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output_fct(some_file,npts,TanhSolnForPoisson::get_exact_u); @@ -308,7 +308,7 @@ void TwoMeshFluxPoissonProblem::doc_solution(DocInfo& doc_info) // Doc error and return of the square of the L2 error //--------------------------------------------------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->compute_error(some_file,TanhSolnForPoisson::get_exact_u, diff --git a/demo_drivers/poisson/two_d_poisson_flux_bc_adapt/two_d_poisson_flux_bc_adapt.cc b/demo_drivers/poisson/two_d_poisson_flux_bc_adapt/two_d_poisson_flux_bc_adapt.cc index 7a7b0c1508f5..479bb7c2ab6d 100644 --- a/demo_drivers/poisson/two_d_poisson_flux_bc_adapt/two_d_poisson_flux_bc_adapt.cc +++ b/demo_drivers/poisson/two_d_poisson_flux_bc_adapt/two_d_poisson_flux_bc_adapt.cc @@ -428,7 +428,7 @@ void RefineableTwoMeshFluxPoissonProblem::doc_solution(DocInfo& doc_inf // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); @@ -436,7 +436,7 @@ void RefineableTwoMeshFluxPoissonProblem::doc_solution(DocInfo& doc_inf // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output_fct(some_file,npts,TanhSolnForPoisson::get_exact_u); @@ -446,7 +446,7 @@ void RefineableTwoMeshFluxPoissonProblem::doc_solution(DocInfo& doc_inf // Doc error and return of the square of the L2 error //--------------------------------------------------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->compute_error(some_file,TanhSolnForPoisson::get_exact_u, diff --git a/demo_drivers/poisson/two_d_poisson_hp_adapt/two_d_poisson_hp_adapt.cc b/demo_drivers/poisson/two_d_poisson_hp_adapt/two_d_poisson_hp_adapt.cc index 814111c77c17..13e7bcc1b75c 100644 --- a/demo_drivers/poisson/two_d_poisson_hp_adapt/two_d_poisson_hp_adapt.cc +++ b/demo_drivers/poisson/two_d_poisson_hp_adapt/two_d_poisson_hp_adapt.cc @@ -292,7 +292,7 @@ void RefineableTwoDPoissonProblem::doc_solution(DocInfo& doc_info) // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -301,7 +301,7 @@ void RefineableTwoDPoissonProblem::doc_solution(DocInfo& doc_info) // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output_fct(some_file,npts,TanhSolnForPoisson::get_exact_u); @@ -310,7 +310,7 @@ void RefineableTwoDPoissonProblem::doc_solution(DocInfo& doc_info) // Doc error and return of the square of the L2 error //--------------------------------------------------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->compute_error(some_file,TanhSolnForPoisson::get_exact_u, diff --git a/demo_drivers/polar_navier_stokes/jeffery_hamel/jeffery_hamel.cc b/demo_drivers/polar_navier_stokes/jeffery_hamel/jeffery_hamel.cc index 6cd33598a523..50874c968295 100644 --- a/demo_drivers/polar_navier_stokes/jeffery_hamel/jeffery_hamel.cc +++ b/demo_drivers/polar_navier_stokes/jeffery_hamel/jeffery_hamel.cc @@ -562,7 +562,7 @@ void PolarNSProblem::output_streamfunction(DocInfo &doc_info,bool eigen stream_problem.doc_solution(doc_info); //Select output file char file_name[100]; - sprintf(file_name,"my_streamfunction%i.dat",doc_info.number()); + snprintf(file_name, sizeof(file_name), "my_streamfunction%i.dat",doc_info.number()); stream_problem.my_output(201,81,false,file_name); } //End of output_streamfunction @@ -733,7 +733,7 @@ void PolarNSProblem::doc_solution(DocInfo& doc_info) npts=3; // Output solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); header( some_file ); diff --git a/demo_drivers/polar_navier_stokes/jeffery_hamel/streamfunction_include.h b/demo_drivers/polar_navier_stokes/jeffery_hamel/streamfunction_include.h index 6da7da42546a..ebbfa027898b 100644 --- a/demo_drivers/polar_navier_stokes/jeffery_hamel/streamfunction_include.h +++ b/demo_drivers/polar_navier_stokes/jeffery_hamel/streamfunction_include.h @@ -577,7 +577,7 @@ void StreamfunctionProblem::doc_solution(DocInfo& doc_info) // Output solution //----------------- - sprintf(filename,"%s/streamfunction%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/streamfunction%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); header(some_file); diff --git a/demo_drivers/reaction_diffusion/one_d_act_inhibit/one_d_act_inhibit.cc b/demo_drivers/reaction_diffusion/one_d_act_inhibit/one_d_act_inhibit.cc index d4487139007b..61dade3cac14 100644 --- a/demo_drivers/reaction_diffusion/one_d_act_inhibit/one_d_act_inhibit.cc +++ b/demo_drivers/reaction_diffusion/one_d_act_inhibit/one_d_act_inhibit.cc @@ -262,7 +262,7 @@ void RefineableOneDAdvectionDiffusionReactionProblem::timestep( { unsigned i=0; char file1[100]; - sprintf(file1,"step%i.dat",i+1); + snprintf(file1, sizeof(file1), "step%i.dat",i+1); ofstream out1(file1); mesh_pt()->output(out1,5); out1.close(); @@ -280,7 +280,7 @@ void RefineableOneDAdvectionDiffusionReactionProblem::timestep( unsteady_newton_solve(dt,max_adapt,first); //Output the result char file1[100]; - sprintf(file1,"step%i.dat",i+1); + snprintf(file1, sizeof(file1), "step%i.dat",i+1); ofstream out1(file1); mesh_pt()->output(out1,5); out1.close(); diff --git a/demo_drivers/reaction_diffusion/two_d_act_inhibit/two_d_act_inhibit.cc b/demo_drivers/reaction_diffusion/two_d_act_inhibit/two_d_act_inhibit.cc index 8725e5b518ad..b040ca485ac4 100644 --- a/demo_drivers/reaction_diffusion/two_d_act_inhibit/two_d_act_inhibit.cc +++ b/demo_drivers/reaction_diffusion/two_d_act_inhibit/two_d_act_inhibit.cc @@ -229,8 +229,8 @@ void ActivatorInhibitorProblem::timestep(const double &dt, { unsteady_newton_solve(dt); char file1[100]; - // sprintf(file1,"step%g.dat",time_pt()->time()); - sprintf(file1,"step%i.dat",i+1); + // snprintf(file1, sizeof(file1), "step%g.dat",time_pt()->time()); + snprintf(file1, sizeof(file1), "step%i.dat",i+1); ofstream out1(file1); mesh_pt()->output(out1,5); out1.close(); diff --git a/demo_drivers/reaction_diffusion/two_d_act_inhibit_adapt/two_d_act_inhibit_adapt.cc b/demo_drivers/reaction_diffusion/two_d_act_inhibit_adapt/two_d_act_inhibit_adapt.cc index 56ddf40b790c..40df859bc936 100644 --- a/demo_drivers/reaction_diffusion/two_d_act_inhibit_adapt/two_d_act_inhibit_adapt.cc +++ b/demo_drivers/reaction_diffusion/two_d_act_inhibit_adapt/two_d_act_inhibit_adapt.cc @@ -270,7 +270,7 @@ void RefineableActivatorInhibitorProblem::timestep( { unsigned i=0; char file1[100]; - sprintf(file1,"step%i.dat",i+1); + snprintf(file1, sizeof(file1), "step%i.dat",i+1); ofstream out1(file1); mesh_pt()->output(out1,5); out1.close(); @@ -285,7 +285,7 @@ void RefineableActivatorInhibitorProblem::timestep( { unsteady_newton_solve(dt,max_adapt,first); char file1[100]; - sprintf(file1,"step%i.dat",i+1); + snprintf(file1, sizeof(file1), "step%i.dat",i+1); ofstream out1(file1); mesh_pt()->output(out1,5); out1.close(); diff --git a/demo_drivers/reaction_diffusion/unstructured_two_d_act_inhibit/unstructured_two_d_act_inhibit.cc b/demo_drivers/reaction_diffusion/unstructured_two_d_act_inhibit/unstructured_two_d_act_inhibit.cc index aa08dbf7736f..227a003d35c9 100644 --- a/demo_drivers/reaction_diffusion/unstructured_two_d_act_inhibit/unstructured_two_d_act_inhibit.cc +++ b/demo_drivers/reaction_diffusion/unstructured_two_d_act_inhibit/unstructured_two_d_act_inhibit.cc @@ -378,7 +378,7 @@ void RefineableActivatorInhibitorProblem::timestep( { unsigned i=0; char file1[100]; - sprintf(file1,"step%i.dat",i+1); + snprintf(file1, sizeof(file1), "step%i.dat",i+1); ofstream out1(file1); mesh_pt()->output(out1,5); out1.close(); @@ -396,7 +396,7 @@ void RefineableActivatorInhibitorProblem::timestep( { unsteady_newton_solve(dt,max_adapt,first); char file1[100]; - sprintf(file1,"step%i.dat",i+1); + snprintf(file1, sizeof(file1), "step%i.dat",i+1); ofstream out1(file1); mesh_pt()->output(out1,5); out1.close(); diff --git a/demo_drivers/shell/clamped_or_pinned_shell/clamped_or_pinned_shell.cc b/demo_drivers/shell/clamped_or_pinned_shell/clamped_or_pinned_shell.cc index 0ad97665133b..a8497a141382 100644 --- a/demo_drivers/shell/clamped_or_pinned_shell/clamped_or_pinned_shell.cc +++ b/demo_drivers/shell/clamped_or_pinned_shell/clamped_or_pinned_shell.cc @@ -444,7 +444,7 @@ void ShellProblem::solve(string& dir_name) doc_info.set_directory(dir_name); //Open an output trace file - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); ofstream trace_file(filename); trace_file << "VARIABLES=\"p_e_x_t\",\"R_1\",\"R_2\"" << std::endl; trace_file << "ZONE" << std::endl; @@ -467,7 +467,7 @@ void ShellProblem::solve(string& dir_name) //Output the tube shape - sprintf(filename,"%s/shell%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/shell%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); for (unsigned e=0;e::solve(string& dir_name) some_file.close(); //Output the Lagrange multipliers - sprintf(filename,"%s/lagrange_multiplier%i.dat", + snprintf(filename, sizeof(filename), "%s/lagrange_multiplier%i.dat", doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); diff --git a/demo_drivers/shell/oscillating_shell/oscillating_shell.cc b/demo_drivers/shell/oscillating_shell/oscillating_shell.cc index ba16c12788e8..f250b2b2bf52 100644 --- a/demo_drivers/shell/oscillating_shell/oscillating_shell.cc +++ b/demo_drivers/shell/oscillating_shell/oscillating_shell.cc @@ -507,7 +507,7 @@ void ShellProblem::doc_solution(DocInfo& doc_info, //Output the tube shape - sprintf(filename,"%s/shell%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/shell%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); for (unsigned e=0;e::doc_solution(DocInfo& doc_info, some_file.close(); // //Output the Lagrange multipliers -// sprintf(filename,"%s/lagrange_multiplier%i.dat", +// snprintf(filename, sizeof(filename), "%s/lagrange_multiplier%i.dat", // doc_info.directory().c_str(), // doc_info.number()); // some_file.open(filename); @@ -554,7 +554,7 @@ void ShellProblem::run_it() doc_info.set_directory("RESLT"); //Open an output trace file - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); ofstream trace_file(filename); trace_file << "VARIABLES=\"time\",\"R_1\",\"R_2\",\"rate of work of load\",\"E_p_o_t\",\"E_k_i_n\",\"E_k_i_n + E_p_o_t\",\"p_c_o_s\"" << std::endl; trace_file << "ZONE" << std::endl; diff --git a/demo_drivers/shell/plate/plate.cc b/demo_drivers/shell/plate/plate.cc index eaceaf18ff9a..b7870bdf544a 100644 --- a/demo_drivers/shell/plate/plate.cc +++ b/demo_drivers/shell/plate/plate.cc @@ -572,7 +572,7 @@ int main(int argc, char* argv[]) doc_info.set_directory("RESLT"); //Open an output trace file - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); ofstream trace_file(filename); trace_file << "VARIABLES=\"p_e_x_t\",\"z_ctrl\"" << std::endl; trace_file << "ZONE" << std::endl; @@ -625,7 +625,7 @@ int main(int argc, char* argv[]) //Output the shape - sprintf(filename,"%s/plate%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/plate%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); problem.mesh_pt()->output(some_file,15); diff --git a/demo_drivers/solid/airy_cantilever/airy_cantilever.cc b/demo_drivers/solid/airy_cantilever/airy_cantilever.cc index c30458b83a22..f06f685e5032 100644 --- a/demo_drivers/solid/airy_cantilever/airy_cantilever.cc +++ b/demo_drivers/solid/airy_cantilever/airy_cantilever.cc @@ -358,7 +358,7 @@ CantileverProblem::CantileverProblem() // Open trace file char filename[100]; - sprintf(filename,"%s/trace.dat",Doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",Doc_info.directory().c_str()); Trace_file.open(filename); @@ -503,7 +503,7 @@ void CantileverProblem::doc_solution() // Output shape of and stress in deformed body //-------------------------------------------- - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); solid_mesh_pt()->output(some_file,n_plot); @@ -512,7 +512,7 @@ void CantileverProblem::doc_solution() // Output St. Venant solution //--------------------------- - sprintf(filename,"%s/exact_soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); diff --git a/demo_drivers/solid/airy_cantilever/airy_cantilever2.cc b/demo_drivers/solid/airy_cantilever/airy_cantilever2.cc index 99c04cfcc3ee..430ee221ce69 100644 --- a/demo_drivers/solid/airy_cantilever/airy_cantilever2.cc +++ b/demo_drivers/solid/airy_cantilever/airy_cantilever2.cc @@ -573,7 +573,7 @@ void CantileverProblem::doc_solution() // Output shape of and stress in deformed body //-------------------------------------------- - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); solid_mesh_pt()->output(some_file,n_plot); @@ -582,7 +582,7 @@ void CantileverProblem::doc_solution() // Output St. Venant solution //--------------------------- - sprintf(filename,"%s/exact_soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); @@ -680,16 +680,16 @@ void CantileverProblem::run_it(const unsigned& i_case) char dirname[100]; #ifdef REFINE - sprintf(dirname,"RESLT_refine%i",i_case); + snprintf(dirname, sizeof(dirname), "RESLT_refine%i",i_case); #else - sprintf(dirname,"RESLT_norefine%i",i_case); + snprintf(dirname, sizeof(dirname), "RESLT_norefine%i",i_case); #endif Doc_info.set_directory(dirname); // Open trace file char filename[100]; - sprintf(filename,"%s/trace.dat",Doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",Doc_info.directory().c_str()); Trace_file.open(filename); diff --git a/demo_drivers/solid/compressed_square/compressed_square.cc b/demo_drivers/solid/compressed_square/compressed_square.cc index 60fbaa934131..99f891c7c154 100644 --- a/demo_drivers/solid/compressed_square/compressed_square.cc +++ b/demo_drivers/solid/compressed_square/compressed_square.cc @@ -290,7 +290,7 @@ void CompressedSquareProblem::doc_solution(const bool& incompress) unsigned n_plot = 5; // Output shape of and stress in deformed body - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,n_plot); @@ -305,7 +305,7 @@ void CompressedSquareProblem::doc_solution(const bool& incompress) // Output exact solution for linear elasticity // ------------------------------------------- - sprintf(filename,"%s/exact_soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); unsigned nelem=mesh_pt()->nelement(); @@ -382,12 +382,12 @@ void CompressedSquareProblem::run_it(const int& i_case, // Set output directory char dirname[100]; - sprintf(dirname,"RESLT%i",i_case); + snprintf(dirname, sizeof(dirname), "RESLT%i",i_case); Doc_info.set_directory(dirname); // Open trace file char filename[100]; - sprintf(filename,"%s/trace.dat",Doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",Doc_info.directory().c_str()); Trace_file.open(filename); diff --git a/demo_drivers/solid/disk_compression/disk_compression.cc b/demo_drivers/solid/disk_compression/disk_compression.cc index a67a8a42d1bb..0bf7ea30cc3a 100644 --- a/demo_drivers/solid/disk_compression/disk_compression.cc +++ b/demo_drivers/solid/disk_compression/disk_compression.cc @@ -310,7 +310,7 @@ void StaticDiskCompressionProblem::doc_solution(DocInfo& doc_info) unsigned npts = 5; // Output shape of deformed body - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Solid_mesh_pt->output(some_file,npts); @@ -360,7 +360,7 @@ void StaticDiskCompressionProblem::parameter_study( DocInfo doc_info; char dirname[100]; - sprintf(dirname,"RESLT%i",case_number); + snprintf(dirname, sizeof(dirname), "RESLT%i",case_number); // Set output directory doc_info.set_directory(dirname); @@ -370,7 +370,7 @@ void StaticDiskCompressionProblem::parameter_study( // Open trace file char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); Trace_file.open(filename); //Parameter incrementation diff --git a/demo_drivers/solid/disk_oscillation/disk_oscillation.cc b/demo_drivers/solid/disk_oscillation/disk_oscillation.cc index 98feb0647505..59bee6514419 100644 --- a/demo_drivers/solid/disk_oscillation/disk_oscillation.cc +++ b/demo_drivers/solid/disk_oscillation/disk_oscillation.cc @@ -564,7 +564,7 @@ void DiskOscillationProblem::doc_solution( // Output shape of deformed body //------------------------------ - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -607,12 +607,12 @@ void DiskOscillationProblem::doc_solution( unsigned nelem=mesh_pt()->nboundary_element(0); // Open files - sprintf(filename,"%s/displ_along_line%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/displ_along_line%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); ofstream some_file2; - sprintf(filename,"%s/exact_displ_along_line%i.dat", + snprintf(filename, sizeof(filename), "%s/exact_displ_along_line%i.dat", doc_info.directory().c_str(), doc_info.number()); some_file2.open(filename); @@ -676,11 +676,11 @@ void DiskOscillationProblem::doc_solution( unsigned nelem=mesh_pt()->nelement(); // Open files - sprintf(filename,"%s/displ%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/displ%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); - sprintf(filename,"%s/exact_displ%i.dat", + snprintf(filename, sizeof(filename), "%s/exact_displ%i.dat", doc_info.directory().c_str(), doc_info.number()); some_file2.open(filename); @@ -761,7 +761,7 @@ void DiskOscillationProblem::run(const unsigned& nstep) // Open trace file char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); Trace_file.open(filename); // Initialise time diff --git a/demo_drivers/solid/prescribed_displ_lagr_mult/prescribed_displ_lagr_mult.cc b/demo_drivers/solid/prescribed_displ_lagr_mult/prescribed_displ_lagr_mult.cc index 47365354295c..540bb9348d27 100644 --- a/demo_drivers/solid/prescribed_displ_lagr_mult/prescribed_displ_lagr_mult.cc +++ b/demo_drivers/solid/prescribed_displ_lagr_mult/prescribed_displ_lagr_mult.cc @@ -444,7 +444,7 @@ void PrescribedBoundaryDisplacementProblem::doc_solution() // Output shape of deformed body //------------------------------ - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); solid_mesh_pt()->output(some_file,n_plot); @@ -452,7 +452,7 @@ void PrescribedBoundaryDisplacementProblem::doc_solution() // Output Lagrange multipliers //---------------------------- - sprintf(filename,"%s/lagr%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/lagr%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); diff --git a/demo_drivers/solid/prescribed_displ_lagr_mult/prescribed_displ_lagr_mult2.cc b/demo_drivers/solid/prescribed_displ_lagr_mult/prescribed_displ_lagr_mult2.cc index 08251e360e0e..e3d54638c22a 100644 --- a/demo_drivers/solid/prescribed_displ_lagr_mult/prescribed_displ_lagr_mult2.cc +++ b/demo_drivers/solid/prescribed_displ_lagr_mult/prescribed_displ_lagr_mult2.cc @@ -281,7 +281,7 @@ void PrescribedBoundaryDisplacementProblem::doc_solution() // Output shape of deformed body //------------------------------ - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); solid_mesh_pt()->output(some_file,n_plot); diff --git a/demo_drivers/solid/prescribed_displ_lagr_mult/prescribed_displ_lagr_mult_precond.cc b/demo_drivers/solid/prescribed_displ_lagr_mult/prescribed_displ_lagr_mult_precond.cc index 2b380b7b7000..49f7cc42d7c4 100644 --- a/demo_drivers/solid/prescribed_displ_lagr_mult/prescribed_displ_lagr_mult_precond.cc +++ b/demo_drivers/solid/prescribed_displ_lagr_mult/prescribed_displ_lagr_mult_precond.cc @@ -671,7 +671,7 @@ void PrescribedBoundaryDisplacementProblem::doc_solution() // Output shape of deformed body //------------------------------ - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); solid_mesh_pt()->output(some_file,n_plot); @@ -679,7 +679,7 @@ void PrescribedBoundaryDisplacementProblem::doc_solution() // Output Lagrange multipliers //---------------------------- - sprintf(filename,"%s/lagr%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/lagr%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); diff --git a/demo_drivers/solid/pseudo_solid_collapsible_channel/pseudo_solid_collapsible_channel.cc b/demo_drivers/solid/pseudo_solid_collapsible_channel/pseudo_solid_collapsible_channel.cc index b5dd202fc59b..f261d1715909 100644 --- a/demo_drivers/solid/pseudo_solid_collapsible_channel/pseudo_solid_collapsible_channel.cc +++ b/demo_drivers/solid/pseudo_solid_collapsible_channel/pseudo_solid_collapsible_channel.cc @@ -675,7 +675,7 @@ void CollapsibleChannelProblem:: doc_solution(DocInfo& doc_info, npts=5; // Output solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); bulk_mesh_pt()->output(some_file,npts); @@ -695,7 +695,7 @@ void CollapsibleChannelProblem:: doc_solution(DocInfo& doc_info, << std::endl; // Output wall shape - sprintf(filename,"%s/wall%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/wall%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); unsigned nplot=100; @@ -1033,7 +1033,7 @@ int main(int argc, char* argv[]) // Open a trace file ofstream trace_file; char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); trace_file.open(filename); // Build the problem with Crouzeix Raviart Elements diff --git a/demo_drivers/solid/shock_disk/shock_disk.cc b/demo_drivers/solid/shock_disk/shock_disk.cc index 0c0dcc5e0aec..23c0d836c6b9 100644 --- a/demo_drivers/solid/shock_disk/shock_disk.cc +++ b/demo_drivers/solid/shock_disk/shock_disk.cc @@ -480,7 +480,7 @@ void DiskShockWaveProblem::doc_solution() // Output shape of deformed body ofstream some_file; char filename[100]; - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); solid_mesh_pt()->output(some_file,npts); @@ -489,7 +489,7 @@ void DiskShockWaveProblem::doc_solution() // Output traction unsigned nel=traction_mesh_pt()->nelement(); - sprintf(filename,"%s/traction%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/traction%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Vector unit_normal(2); @@ -526,7 +526,7 @@ void DiskShockWaveProblem::doc_solution() unsigned nelem=solid_mesh_pt()->nboundary_element(0); // Open files - sprintf(filename,"%s/displ%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/displ%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); @@ -584,7 +584,7 @@ void DiskShockWaveProblem::doc_solution() // SolidHelpers::doc_2D_principal_stress(Doc_info,solid_mesh_pt()); // // Write restart file -// sprintf(filename,"%s/restart%i.dat",Doc_info.directory().c_str(), +// snprintf(filename, sizeof(filename), "%s/restart%i.dat",Doc_info.directory().c_str(), // Doc_info.number()); // some_file.open(filename); // dump_it(some_file); @@ -624,17 +624,17 @@ void DiskShockWaveProblem::doc_displ_and_veloc( // Open file if (stage==-1) { - sprintf(filename,"%s/displ_and_veloc_before%i.dat", + snprintf(filename, sizeof(filename), "%s/displ_and_veloc_before%i.dat", Doc_info.directory().c_str(),Doc_info.number()); } else if (stage==1) { - sprintf(filename,"%s/displ_and_veloc_after%i.dat", + snprintf(filename, sizeof(filename), "%s/displ_and_veloc_after%i.dat", Doc_info.directory().c_str(),Doc_info.number()); } else { - sprintf(filename,"%s/displ_and_veloc%i.dat", + snprintf(filename, sizeof(filename), "%s/displ_and_veloc%i.dat", Doc_info.directory().c_str(),Doc_info.number()); } some_file.open(filename); @@ -725,7 +725,7 @@ void DiskShockWaveProblem::run( // Define output directory char dirname[100]; - sprintf(dirname,"RESLT%i",case_number); + snprintf(dirname, sizeof(dirname), "RESLT%i",case_number); Doc_info.set_directory(dirname); // Step number @@ -733,7 +733,7 @@ void DiskShockWaveProblem::run( // Open trace file char filename[100]; - sprintf(filename,"%s/trace.dat",Doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",Doc_info.directory().c_str()); Trace_file.open(filename); // Set up trace nodes as the nodes on boundary 1 (=curved boundary) in diff --git a/demo_drivers/solid/simple_shear/refineable_simple_shear.cc b/demo_drivers/solid/simple_shear/refineable_simple_shear.cc index 9807819bafd0..e3fc8c0f49e7 100644 --- a/demo_drivers/solid/simple_shear/refineable_simple_shear.cc +++ b/demo_drivers/solid/simple_shear/refineable_simple_shear.cc @@ -288,13 +288,13 @@ void SimpleShearProblem::doc_solution(DocInfo& doc_info) unsigned npts = 5; // Output shape of deformed body - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); some_file.close(); - sprintf(filename,"%s/stress%i.dat", doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/stress%i.dat", doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); //Output the appropriate stress at the centre of each element diff --git a/demo_drivers/solid/simple_shear/simple_shear.cc b/demo_drivers/solid/simple_shear/simple_shear.cc index 5625c71ab124..6831d75e6b2a 100644 --- a/demo_drivers/solid/simple_shear/simple_shear.cc +++ b/demo_drivers/solid/simple_shear/simple_shear.cc @@ -255,13 +255,13 @@ void SimpleShearProblem::doc_solution(DocInfo& doc_info) unsigned npts = 5; // Output shape of deformed body - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); some_file.close(); - sprintf(filename,"%s/stress%i.dat", doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/stress%i.dat", doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); //Output the appropriate stress at the centre of each element diff --git a/demo_drivers/solid/static_fish/static_fish.cc b/demo_drivers/solid/static_fish/static_fish.cc index 9827a0759374..129c9fa2ba04 100644 --- a/demo_drivers/solid/static_fish/static_fish.cc +++ b/demo_drivers/solid/static_fish/static_fish.cc @@ -334,7 +334,7 @@ void ElasticFishProblem::doc_solution(DocInfo& doc_info) unsigned npts = 5; // Output shape of deformed body - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); diff --git a/demo_drivers/solid/three_d_cantilever/three_d_cantilever.cc b/demo_drivers/solid/three_d_cantilever/three_d_cantilever.cc index 73f659670dcc..9ad316d88955 100644 --- a/demo_drivers/solid/three_d_cantilever/three_d_cantilever.cc +++ b/demo_drivers/solid/three_d_cantilever/three_d_cantilever.cc @@ -363,7 +363,7 @@ void CantileverProblem::doc_solution() unsigned n_plot = 5; // Output shape of deformed body - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,n_plot); @@ -390,9 +390,9 @@ void CantileverProblem::run_tests(const unsigned& i_case, char dirname[100]; #ifdef REFINE - sprintf(dirname,"RESLT_refine%i",i_case); + snprintf(dirname, sizeof(dirname), "RESLT_refine%i",i_case); #else - sprintf(dirname,"RESLT_norefine%i",i_case); + snprintf(dirname, sizeof(dirname), "RESLT_norefine%i",i_case); #endif // Prepare output diff --git a/demo_drivers/solid/three_d_prescribed_displ_lagr_mult/three_d_prescribed_displ_lagr_mult.cc b/demo_drivers/solid/three_d_prescribed_displ_lagr_mult/three_d_prescribed_displ_lagr_mult.cc index e224fa7f8ce3..428342d5d7fa 100644 --- a/demo_drivers/solid/three_d_prescribed_displ_lagr_mult/three_d_prescribed_displ_lagr_mult.cc +++ b/demo_drivers/solid/three_d_prescribed_displ_lagr_mult/three_d_prescribed_displ_lagr_mult.cc @@ -660,7 +660,7 @@ void PrescribedBoundaryDisplacementProblem::doc_solution() // Output shape of deformed body //------------------------------ - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); solid_mesh_pt()->output(some_file,n_plot); @@ -668,7 +668,7 @@ void PrescribedBoundaryDisplacementProblem::doc_solution() // Output Lagrange multipliers //---------------------------- - sprintf(filename,"%s/lagr%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/lagr%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); diff --git a/demo_drivers/solid/three_d_traction/three_d_traction.cc b/demo_drivers/solid/three_d_traction/three_d_traction.cc index 80567ca38465..d84de5823a78 100644 --- a/demo_drivers/solid/three_d_traction/three_d_traction.cc +++ b/demo_drivers/solid/three_d_traction/three_d_traction.cc @@ -413,7 +413,7 @@ void BlockCompressionProblem::doc_solution(DocInfo& doc_info) unsigned npts = 5; // Output shape of deformed body - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Solid_mesh_pt->output(some_file,npts); @@ -423,7 +423,7 @@ void BlockCompressionProblem::doc_solution(DocInfo& doc_info) // Output traction //---------------- - sprintf(filename,"%s/traction%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/traction%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Traction_mesh_pt->output(some_file,npts); diff --git a/demo_drivers/solid/unstructured_adaptive_solid/unstructured_adaptive_solid.cc b/demo_drivers/solid/unstructured_adaptive_solid/unstructured_adaptive_solid.cc index 52b165bbe0e3..3f56e7c70713 100644 --- a/demo_drivers/solid/unstructured_adaptive_solid/unstructured_adaptive_solid.cc +++ b/demo_drivers/solid/unstructured_adaptive_solid/unstructured_adaptive_solid.cc @@ -279,7 +279,7 @@ void UnstructuredSolidProblem::doc_solution(DocInfo& doc_info) // Output solution //---------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Solid_mesh_pt->output(some_file,npts); @@ -287,7 +287,7 @@ void UnstructuredSolidProblem::doc_solution(DocInfo& doc_info) // Output traction //---------------- - sprintf(filename,"%s/traction%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/traction%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Traction_mesh_pt->output(some_file,npts); @@ -295,7 +295,7 @@ void UnstructuredSolidProblem::doc_solution(DocInfo& doc_info) // Output boundaries //------------------ - sprintf(filename,"%s/boundaries.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/boundaries.dat",doc_info.directory().c_str()); some_file.open(filename); Solid_mesh_pt->output_boundaries(some_file); some_file.close(); diff --git a/demo_drivers/solid/unstructured_solid/unstructured_three_d_solid.cc b/demo_drivers/solid/unstructured_solid/unstructured_three_d_solid.cc index e4c40ed0146e..00c0297e632c 100644 --- a/demo_drivers/solid/unstructured_solid/unstructured_three_d_solid.cc +++ b/demo_drivers/solid/unstructured_solid/unstructured_three_d_solid.cc @@ -311,7 +311,7 @@ void UnstructuredSolidProblem::doc_solution(DocInfo& doc_info) // Output boundaries //------------------ - sprintf(filename,"%s/boundaries%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/boundaries%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Solid_mesh_pt->output_boundaries(some_file); @@ -320,7 +320,7 @@ void UnstructuredSolidProblem::doc_solution(DocInfo& doc_info) // Output solution //---------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Solid_mesh_pt->output(some_file,npts); @@ -329,7 +329,7 @@ void UnstructuredSolidProblem::doc_solution(DocInfo& doc_info) // Output traction //---------------- - sprintf(filename,"%s/traction%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/traction%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Traction_mesh_pt->output(some_file,npts); diff --git a/demo_drivers/solid/unstructured_solid/unstructured_two_d_solid.cc b/demo_drivers/solid/unstructured_solid/unstructured_two_d_solid.cc index ee77018c7d00..e00ef41e64ec 100644 --- a/demo_drivers/solid/unstructured_solid/unstructured_two_d_solid.cc +++ b/demo_drivers/solid/unstructured_solid/unstructured_two_d_solid.cc @@ -295,7 +295,7 @@ void UnstructuredSolidProblem::doc_solution(DocInfo& doc_info) // Output solution //---------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Solid_mesh_pt->output(some_file,npts); @@ -303,7 +303,7 @@ void UnstructuredSolidProblem::doc_solution(DocInfo& doc_info) // Output traction //---------------- - sprintf(filename,"%s/traction%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/traction%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Traction_mesh_pt->output(some_file,npts); @@ -311,7 +311,7 @@ void UnstructuredSolidProblem::doc_solution(DocInfo& doc_info) // Output boundaries //------------------ - sprintf(filename,"%s/boundaries.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/boundaries.dat",doc_info.directory().c_str()); some_file.open(filename); Solid_mesh_pt->output_boundaries(some_file); some_file.close(); diff --git a/demo_drivers/solid/unstructured_three_d_solid/unstructured_three_d_solid.cc b/demo_drivers/solid/unstructured_three_d_solid/unstructured_three_d_solid.cc index 22301e5c5675..d6276dba4fb4 100644 --- a/demo_drivers/solid/unstructured_three_d_solid/unstructured_three_d_solid.cc +++ b/demo_drivers/solid/unstructured_three_d_solid/unstructured_three_d_solid.cc @@ -349,7 +349,7 @@ void UnstructuredSolidProblem::doc_solution(DocInfo& doc_info) // Output solid solution //----------------------- - sprintf(filename,"%s/solid_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/solid_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Solid_mesh_pt->output(some_file,npts); @@ -358,7 +358,7 @@ void UnstructuredSolidProblem::doc_solution(DocInfo& doc_info) // Output traction //---------------- - sprintf(filename,"%s/traction%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/traction%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); unsigned n=Solid_traction_boundary_id.size(); diff --git a/demo_drivers/spherical_advection_diffusion/eluting_sphere/eluting_sphere.cc b/demo_drivers/spherical_advection_diffusion/eluting_sphere/eluting_sphere.cc index 5794517725e5..787e5e11b72b 100644 --- a/demo_drivers/spherical_advection_diffusion/eluting_sphere/eluting_sphere.cc +++ b/demo_drivers/spherical_advection_diffusion/eluting_sphere/eluting_sphere.cc @@ -243,7 +243,7 @@ void EultingSphereProblem::doc_solution(DocInfo& doc_info) // Output solution //----------------- - sprintf(filename,"%s/soln%g.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%g.dat",doc_info.directory().c_str(), Global_Physical_Variables::Pe); some_file.open(filename); mesh_pt()->output(some_file,npts); diff --git a/demo_drivers/spherical_advection_diffusion/eluting_sphere/eluting_sphere_adapt.cc b/demo_drivers/spherical_advection_diffusion/eluting_sphere/eluting_sphere_adapt.cc index 1b46cc16b78d..36c0c7093df6 100644 --- a/demo_drivers/spherical_advection_diffusion/eluting_sphere/eluting_sphere_adapt.cc +++ b/demo_drivers/spherical_advection_diffusion/eluting_sphere/eluting_sphere_adapt.cc @@ -244,7 +244,7 @@ void RefineableElutingSphereProblem::doc_solution(DocInfo& doc_info) // Output solution //----------------- - sprintf(filename,"%s/soln%g.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%g.dat",doc_info.directory().c_str(), Global_Physical_Variables::Pe); some_file.open(filename); mesh_pt()->output(some_file,npts); diff --git a/demo_drivers/spherical_navier_stokes/spherical_couette/spherical_couette.cc b/demo_drivers/spherical_navier_stokes/spherical_couette/spherical_couette.cc index fb6eda28e5b5..a5103bde8c13 100644 --- a/demo_drivers/spherical_navier_stokes/spherical_couette/spherical_couette.cc +++ b/demo_drivers/spherical_navier_stokes/spherical_couette/spherical_couette.cc @@ -450,7 +450,7 @@ void RefineableSphericalCouetteProblem::doc_solution(DocInfo& doc_info, // Output solution //----------------- - sprintf(filename,"%s/soln%g.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%g.dat",doc_info.directory().c_str(), Global_Physical_Variables::Re); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -525,7 +525,7 @@ int main() // Open a trace file ofstream trace_file; char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); trace_file.open(filename); // Over-ride the maximum and minimum permitted errors diff --git a/demo_drivers/spherical_navier_stokes/spin_up/refineable_spin_up.cc b/demo_drivers/spherical_navier_stokes/spin_up/refineable_spin_up.cc index 7cce3864cdae..b17f260b69bd 100644 --- a/demo_drivers/spherical_navier_stokes/spin_up/refineable_spin_up.cc +++ b/demo_drivers/spherical_navier_stokes/spin_up/refineable_spin_up.cc @@ -435,7 +435,7 @@ void RefineableSphericalSpinUpProblem::doc_solution(DocInfo& doc_info, // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -491,7 +491,7 @@ int main() // Open a trace file ofstream trace_file; char filename[100]; - sprintf(filename,"%s/trace0.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace0.dat",doc_info.directory().c_str()); trace_file.open(filename); trace_file << "time " << "u " << "v " << "w " << std::endl; diff --git a/demo_drivers/spherical_navier_stokes/spin_up/refineable_spin_up_cyl.cc b/demo_drivers/spherical_navier_stokes/spin_up/refineable_spin_up_cyl.cc index dff2bad4c314..c5f7255acba6 100644 --- a/demo_drivers/spherical_navier_stokes/spin_up/refineable_spin_up_cyl.cc +++ b/demo_drivers/spherical_navier_stokes/spin_up/refineable_spin_up_cyl.cc @@ -403,7 +403,7 @@ void RefineableSphericalSpinUpProblem::doc_solution(DocInfo& doc_info, // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -461,7 +461,7 @@ int main() // Open a trace file ofstream trace_file; char filename[100]; - sprintf(filename,"%s/trace0.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace0.dat",doc_info.directory().c_str()); trace_file.open(filename); trace_file << "time " << "u " << "v " << "w " << std::endl; diff --git a/demo_drivers/spherical_navier_stokes/spin_up/spin_up.cc b/demo_drivers/spherical_navier_stokes/spin_up/spin_up.cc index e97cc8db8e48..ee2c4dd1a3b9 100644 --- a/demo_drivers/spherical_navier_stokes/spin_up/spin_up.cc +++ b/demo_drivers/spherical_navier_stokes/spin_up/spin_up.cc @@ -364,7 +364,7 @@ void SphericalSpinUpProblem::doc_solution(DocInfo& doc_info, // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -402,7 +402,7 @@ void SphericalSpinUpProblem::timestep(const double &dt, // Open a trace file std::ofstream trace_file; char filename[100]; - sprintf(filename,"%s/time_trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/time_trace.dat",doc_info.directory().c_str()); trace_file.open(filename); trace_file << "time " << "u " << "v " << "w " << std::endl; diff --git a/demo_drivers/spherical_navier_stokes/spin_up/spin_up_cyl.cc b/demo_drivers/spherical_navier_stokes/spin_up/spin_up_cyl.cc index 3fbc138129d1..3bd866975b4a 100644 --- a/demo_drivers/spherical_navier_stokes/spin_up/spin_up_cyl.cc +++ b/demo_drivers/spherical_navier_stokes/spin_up/spin_up_cyl.cc @@ -372,7 +372,7 @@ void SphericalSpinUpProblem::doc_solution(DocInfo& doc_info, std::ofstr // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -409,7 +409,7 @@ void SphericalSpinUpProblem::timestep(const double &dt, // Open a trace file std::ofstream trace_file; char filename[100]; - sprintf(filename,"%s/time_trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/time_trace.dat",doc_info.directory().c_str()); trace_file.open(filename); trace_file << "time " << "u " << "v " << "w " << std::endl; diff --git a/demo_drivers/spherical_navier_stokes/steady_rot/steady_rot.cc b/demo_drivers/spherical_navier_stokes/steady_rot/steady_rot.cc index 8a15e4d400d7..fa2d2631a20b 100644 --- a/demo_drivers/spherical_navier_stokes/steady_rot/steady_rot.cc +++ b/demo_drivers/spherical_navier_stokes/steady_rot/steady_rot.cc @@ -299,7 +299,7 @@ void SphericalSteadyRotationProblem::parameter_study( // Output solution //----------------- - sprintf(filename,"soln_%s_%ix%i_%g.dat", + snprintf(filename, sizeof(filename), "soln_%s_%ix%i_%g.dat", output_dir.c_str(),Nr,Ntheta,Global_Physical_Variables::Re); some_file.open(filename); mesh_pt()->output(some_file,npts); diff --git a/demo_drivers/steady_axisym_advection_diffusion/steady_axisym_advection_diffusion/steady_axisym_advection_diffusion.cc b/demo_drivers/steady_axisym_advection_diffusion/steady_axisym_advection_diffusion/steady_axisym_advection_diffusion.cc index 2e53b45669d3..f666687dcbaa 100644 --- a/demo_drivers/steady_axisym_advection_diffusion/steady_axisym_advection_diffusion/steady_axisym_advection_diffusion.cc +++ b/demo_drivers/steady_axisym_advection_diffusion/steady_axisym_advection_diffusion/steady_axisym_advection_diffusion.cc @@ -402,7 +402,7 @@ doc_solution(DocInfo& doc_info) // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); @@ -410,7 +410,7 @@ doc_solution(DocInfo& doc_info) // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output_fct(some_file, @@ -421,7 +421,7 @@ doc_solution(DocInfo& doc_info) // Doc error and return of the square of the L2 error //--------------------------------------------------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->compute_error(some_file, diff --git a/demo_drivers/time_harmonic_fourier_decomposed_linear_elasticity/cylinder/cylinder.cc b/demo_drivers/time_harmonic_fourier_decomposed_linear_elasticity/cylinder/cylinder.cc index 819db3657b8d..3631b9efae68 100644 --- a/demo_drivers/time_harmonic_fourier_decomposed_linear_elasticity/cylinder/cylinder.cc +++ b/demo_drivers/time_harmonic_fourier_decomposed_linear_elasticity/cylinder/cylinder.cc @@ -324,13 +324,13 @@ doc_solution(DocInfo& doc_info) unsigned npts=5; // Output solution - sprintf(filename,"%s/soln.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/soln.dat",doc_info.directory().c_str()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); some_file.close(); // Output exact solution - sprintf(filename,"%s/exact_soln.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/exact_soln.dat",doc_info.directory().c_str()); some_file.open(filename); Bulk_mesh_pt->output_fct(some_file,npts, Global_Parameters::exact_solution); @@ -339,7 +339,7 @@ doc_solution(DocInfo& doc_info) // Doc error double error=0.0; double norm=0.0; - sprintf(filename,"%s/error.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/error.dat",doc_info.directory().c_str()); some_file.open(filename); Bulk_mesh_pt->compute_error(some_file, Global_Parameters::exact_solution, diff --git a/demo_drivers/time_harmonic_fourier_decomposed_linear_elasticity/cylinder/pressure_loaded_cylinder.cc b/demo_drivers/time_harmonic_fourier_decomposed_linear_elasticity/cylinder/pressure_loaded_cylinder.cc index 3ff19dc20db6..2a12e8e4fbae 100644 --- a/demo_drivers/time_harmonic_fourier_decomposed_linear_elasticity/cylinder/pressure_loaded_cylinder.cc +++ b/demo_drivers/time_harmonic_fourier_decomposed_linear_elasticity/cylinder/pressure_loaded_cylinder.cc @@ -422,14 +422,14 @@ doc_solution(DocInfo& doc_info) unsigned npts=5; // Output solution - sprintf(filename,"%s/soln.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/soln.dat",doc_info.directory().c_str()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); some_file.close(); // Output norm of solution (to allow validation of solution even // if triangle generates a slightly different mesh) - sprintf(filename,"%s/norm.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/norm.dat",doc_info.directory().c_str()); some_file.open(filename); double norm=0.0; unsigned nel=Bulk_mesh_pt->nelement(); diff --git a/demo_drivers/time_harmonic_fourier_decomposed_linear_elasticity/cylinder/unstructured_cylinder.cc b/demo_drivers/time_harmonic_fourier_decomposed_linear_elasticity/cylinder/unstructured_cylinder.cc index 87f5bd509cc0..4c2a7e1c8a6f 100644 --- a/demo_drivers/time_harmonic_fourier_decomposed_linear_elasticity/cylinder/unstructured_cylinder.cc +++ b/demo_drivers/time_harmonic_fourier_decomposed_linear_elasticity/cylinder/unstructured_cylinder.cc @@ -474,13 +474,13 @@ doc_solution(DocInfo& doc_info) unsigned npts=10; // Output solution - sprintf(filename,"%s/soln.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/soln.dat",doc_info.directory().c_str()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); some_file.close(); // Output exact solution - sprintf(filename,"%s/exact_soln.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/exact_soln.dat",doc_info.directory().c_str()); some_file.open(filename); Bulk_mesh_pt->output_fct(some_file,npts, Global_Parameters::exact_solution); @@ -489,7 +489,7 @@ doc_solution(DocInfo& doc_info) // Doc error double error=0.0; double norm=0.0; - sprintf(filename,"%s/error.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/error.dat",doc_info.directory().c_str()); some_file.open(filename); Bulk_mesh_pt->compute_error(some_file, Global_Parameters::exact_solution, @@ -503,7 +503,7 @@ doc_solution(DocInfo& doc_info) // Output norm of solution (to allow validation of solution even // if triangle generates a slightly different mesh) - sprintf(filename,"%s/norm.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/norm.dat",doc_info.directory().c_str()); some_file.open(filename); some_file << norm << std::endl; some_file.close(); diff --git a/demo_drivers/time_harmonic_linear_elasticity/elastic_annulus/time_harmonic_elastic_annulus.cc b/demo_drivers/time_harmonic_linear_elasticity/elastic_annulus/time_harmonic_elastic_annulus.cc index 8a8c85888d6c..fcd551745504 100644 --- a/demo_drivers/time_harmonic_linear_elasticity/elastic_annulus/time_harmonic_elastic_annulus.cc +++ b/demo_drivers/time_harmonic_linear_elasticity/elastic_annulus/time_harmonic_elastic_annulus.cc @@ -610,7 +610,7 @@ void AnnularDiskProblem::doc_solution() // Output displacement field //-------------------------- - sprintf(filename,"%s/elast_soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/elast_soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Solid_mesh_pt->output(some_file,n_plot); @@ -619,7 +619,7 @@ void AnnularDiskProblem::doc_solution() // Output traction elements //------------------------- - sprintf(filename,"%s/traction_soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/traction_soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Traction_mesh_pt->output(some_file,n_plot); @@ -627,7 +627,7 @@ void AnnularDiskProblem::doc_solution() // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Solid_mesh_pt->output_fct(some_file,n_plot,Global_Parameters::exact_u); diff --git a/demo_drivers/time_harmonic_linear_elasticity/elastic_annulus/unstructured_time_harmonic_elastic_annulus.cc b/demo_drivers/time_harmonic_linear_elasticity/elastic_annulus/unstructured_time_harmonic_elastic_annulus.cc index 068e1295ec5b..0a362f8d327b 100644 --- a/demo_drivers/time_harmonic_linear_elasticity/elastic_annulus/unstructured_time_harmonic_elastic_annulus.cc +++ b/demo_drivers/time_harmonic_linear_elasticity/elastic_annulus/unstructured_time_harmonic_elastic_annulus.cc @@ -761,7 +761,7 @@ void RingWithTRibProblem::doc_solution() // Output displacement field //-------------------------- - sprintf(filename,"%s/elast_soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/elast_soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Solid_mesh_pt->output(some_file,n_plot); @@ -769,7 +769,7 @@ void RingWithTRibProblem::doc_solution() // Output traction elements //------------------------- - sprintf(filename,"%s/traction_soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/traction_soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Traction_mesh_pt->output(some_file,n_plot); @@ -780,7 +780,7 @@ void RingWithTRibProblem::doc_solution() unsigned nreg=Solid_mesh_pt->nregion(); for (unsigned r=0;rnregion_element(r); @@ -794,7 +794,7 @@ void RingWithTRibProblem::doc_solution() // Output norm of solution (to allow validation of solution even // if triangle generates a slightly different mesh) - sprintf(filename,"%s/norm%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/norm%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); double norm=0.0; diff --git a/demo_drivers/unsteady_heat/space_time_two_d_unsteady_heat/test_equal_order_galerkin.cc b/demo_drivers/unsteady_heat/space_time_two_d_unsteady_heat/test_equal_order_galerkin.cc index d5d7cd933538..f38538a198f1 100644 --- a/demo_drivers/unsteady_heat/space_time_two_d_unsteady_heat/test_equal_order_galerkin.cc +++ b/demo_drivers/unsteady_heat/space_time_two_d_unsteady_heat/test_equal_order_galerkin.cc @@ -896,7 +896,7 @@ void UnsteadyHeatProblem::doc_solution(const bool& doc_error) if (GlobalParameters::Apply_time_periodic_boundary_conditions) { // Output the (numerically) approximated solution - sprintf(filename,"%s/soln%s%i.dat", + snprintf(filename, sizeof(filename), "%s/soln%s%i.dat", GlobalParameters::Doc_info.directory().c_str(), filename_suffix.c_str(), GlobalParameters::Doc_info.number()); @@ -905,7 +905,7 @@ void UnsteadyHeatProblem::doc_solution(const bool& doc_error) else { // Output the (numerically) approximated solution - sprintf(filename,"%s/soln_ic%i.dat", + snprintf(filename, sizeof(filename), "%s/soln_ic%i.dat", GlobalParameters::Doc_info.directory().c_str(), GlobalParameters::Doc_info.number()); } @@ -923,7 +923,7 @@ void UnsteadyHeatProblem::doc_solution(const bool& doc_error) // Output exact solution //---------------------- // Output the exact solution - sprintf(filename,"%s/exact_soln%i.dat", + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat", GlobalParameters::Doc_info.directory().c_str(), GlobalParameters::Doc_info.number()); @@ -949,7 +949,7 @@ void UnsteadyHeatProblem::doc_solution(const bool& doc_error) double norm=0.0, error=0.0; // Output the error - sprintf(filename,"%s/error%s%i.dat", + snprintf(filename, sizeof(filename), "%s/error%s%i.dat", GlobalParameters::Doc_info.directory().c_str(), filename_suffix.c_str(), GlobalParameters::Doc_info.number()); diff --git a/demo_drivers/unsteady_heat/space_time_two_d_unsteady_heat/test_equal_order_galerkin_petrov.cc b/demo_drivers/unsteady_heat/space_time_two_d_unsteady_heat/test_equal_order_galerkin_petrov.cc index e31955eabf74..273e7befeecb 100644 --- a/demo_drivers/unsteady_heat/space_time_two_d_unsteady_heat/test_equal_order_galerkin_petrov.cc +++ b/demo_drivers/unsteady_heat/space_time_two_d_unsteady_heat/test_equal_order_galerkin_petrov.cc @@ -1214,7 +1214,7 @@ void UnsteadyHeatProblem::doc_solution(const bool& doc_error) if (GlobalParameters::Apply_time_periodic_boundary_conditions) { // Output the (numerically) approximated solution - sprintf(filename,"%s/soln%s%i.dat", + snprintf(filename, sizeof(filename), "%s/soln%s%i.dat", GlobalParameters::Doc_info.directory().c_str(), filename_suffix.c_str(), GlobalParameters::Doc_info.number()); @@ -1223,7 +1223,7 @@ void UnsteadyHeatProblem::doc_solution(const bool& doc_error) else { // Output the (numerically) approximated solution - sprintf(filename,"%s/soln_ic%i.dat", + snprintf(filename, sizeof(filename), "%s/soln_ic%i.dat", GlobalParameters::Doc_info.directory().c_str(), GlobalParameters::Doc_info.number()); } @@ -1241,7 +1241,7 @@ void UnsteadyHeatProblem::doc_solution(const bool& doc_error) // Output exact solution //---------------------- // Output the exact solution - sprintf(filename,"%s/exact_soln%i.dat", + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat", GlobalParameters::Doc_info.directory().c_str(), GlobalParameters::Doc_info.number()); @@ -1267,7 +1267,7 @@ void UnsteadyHeatProblem::doc_solution(const bool& doc_error) double norm=0.0, error=0.0; // Output the error - sprintf(filename,"%s/error%s%i.dat", + snprintf(filename, sizeof(filename), "%s/error%s%i.dat", GlobalParameters::Doc_info.directory().c_str(), filename_suffix.c_str(), GlobalParameters::Doc_info.number()); diff --git a/demo_drivers/unsteady_heat/space_time_two_d_unsteady_heat/test_mixed_order_galerkin_petrov.cc b/demo_drivers/unsteady_heat/space_time_two_d_unsteady_heat/test_mixed_order_galerkin_petrov.cc index c7ce29f5134b..bb92c9649011 100644 --- a/demo_drivers/unsteady_heat/space_time_two_d_unsteady_heat/test_mixed_order_galerkin_petrov.cc +++ b/demo_drivers/unsteady_heat/space_time_two_d_unsteady_heat/test_mixed_order_galerkin_petrov.cc @@ -1283,7 +1283,7 @@ void UnsteadyHeatProblem::doc_solution(const bool& doc_error) if (GlobalParameters::Apply_time_periodic_boundary_conditions) { // Output the (numerically) approximated solution - sprintf(filename,"%s/soln%s%i.dat", + snprintf(filename, sizeof(filename), "%s/soln%s%i.dat", GlobalParameters::Doc_info.directory().c_str(), filename_suffix.c_str(), GlobalParameters::Doc_info.number()); @@ -1292,7 +1292,7 @@ void UnsteadyHeatProblem::doc_solution(const bool& doc_error) else { // Output the (numerically) approximated solution - sprintf(filename,"%s/soln_ic%i.dat", + snprintf(filename, sizeof(filename), "%s/soln_ic%i.dat", GlobalParameters::Doc_info.directory().c_str(), GlobalParameters::Doc_info.number()); } @@ -1310,7 +1310,7 @@ void UnsteadyHeatProblem::doc_solution(const bool& doc_error) // Output exact solution //---------------------- // Output the exact solution - sprintf(filename,"%s/exact_soln%i.dat", + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat", GlobalParameters::Doc_info.directory().c_str(), GlobalParameters::Doc_info.number()); @@ -1336,7 +1336,7 @@ void UnsteadyHeatProblem::doc_solution(const bool& doc_error) double norm=0.0, error=0.0; // Output the error - sprintf(filename,"%s/error%s%i.dat", + snprintf(filename, sizeof(filename), "%s/error%s%i.dat", GlobalParameters::Doc_info.directory().c_str(), filename_suffix.c_str(), GlobalParameters::Doc_info.number()); diff --git a/demo_drivers/unsteady_heat/two_d_unsteady_heat/two_d_unsteady_heat.cc b/demo_drivers/unsteady_heat/two_d_unsteady_heat/two_d_unsteady_heat.cc index 06e5033940b6..01e5142ec4b4 100644 --- a/demo_drivers/unsteady_heat/two_d_unsteady_heat/two_d_unsteady_heat.cc +++ b/demo_drivers/unsteady_heat/two_d_unsteady_heat/two_d_unsteady_heat.cc @@ -342,7 +342,7 @@ doc_solution(DocInfo& doc_info,ofstream& trace_file) // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -362,7 +362,7 @@ doc_solution(DocInfo& doc_info,ofstream& trace_file) // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output_fct(some_file,npts,time_pt()->time(), @@ -372,7 +372,7 @@ doc_solution(DocInfo& doc_info,ofstream& trace_file) // Doc error //---------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->compute_error(some_file, @@ -430,7 +430,7 @@ int main() // Open a trace file ofstream trace_file; char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); trace_file.open(filename); trace_file << "VARIABLES=\"time\",\"uFE\"," << "\"uexact\",\"norm of error\",\"norm of solution\"" diff --git a/demo_drivers/unsteady_heat/two_d_unsteady_heat/two_d_unsteady_heat_restarted.cc b/demo_drivers/unsteady_heat/two_d_unsteady_heat/two_d_unsteady_heat_restarted.cc index 7b3ef5a43738..b3fea4ccd1fd 100644 --- a/demo_drivers/unsteady_heat/two_d_unsteady_heat/two_d_unsteady_heat_restarted.cc +++ b/demo_drivers/unsteady_heat/two_d_unsteady_heat/two_d_unsteady_heat_restarted.cc @@ -420,7 +420,7 @@ doc_solution(DocInfo& doc_info,ofstream& trace_file) // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -440,7 +440,7 @@ doc_solution(DocInfo& doc_info,ofstream& trace_file) // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output_fct(some_file,npts,time_pt()->time(), @@ -450,7 +450,7 @@ doc_solution(DocInfo& doc_info,ofstream& trace_file) // Doc error //---------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->compute_error(some_file, @@ -478,7 +478,7 @@ doc_solution(DocInfo& doc_info,ofstream& trace_file) // Write restart file - sprintf(filename,"%s/restart%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/restart%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); dump_it(some_file); @@ -551,7 +551,7 @@ int main(int argc, char* argv[]) // Open a trace file ofstream trace_file; char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); trace_file.open(filename); trace_file << "VARIABLES=\"time\",\"uFE\"," << "\"uexact\",\"norm of error\",\"norm of solution\"" diff --git a/demo_drivers/unsteady_heat/two_d_unsteady_heat_2adapt/two_d_unsteady_heat_2adapt.cc b/demo_drivers/unsteady_heat/two_d_unsteady_heat_2adapt/two_d_unsteady_heat_2adapt.cc index 0eb011f9c83b..1fbe78bbf717 100644 --- a/demo_drivers/unsteady_heat/two_d_unsteady_heat_2adapt/two_d_unsteady_heat_2adapt.cc +++ b/demo_drivers/unsteady_heat/two_d_unsteady_heat_2adapt/two_d_unsteady_heat_2adapt.cc @@ -724,7 +724,7 @@ void RefineableUnsteadyHeatProblem::write_trace_file_header() { // Open trace file char filename[100]; - sprintf(filename,"%s/trace.dat",Doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",Doc_info.directory().c_str()); Trace_file.open(filename); Trace_file << "VARIABLES=\"time t\"," @@ -777,7 +777,7 @@ void RefineableUnsteadyHeatProblem::doc_solution() // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); @@ -806,7 +806,7 @@ void RefineableUnsteadyHeatProblem::doc_solution() // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output_fct(some_file,npts,time_pt()->time(), @@ -830,7 +830,7 @@ void RefineableUnsteadyHeatProblem::doc_solution() // Doc error //---------- double error,norm; - sprintf(filename,"%s/error%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Bulk_mesh_pt->compute_error(some_file, @@ -870,7 +870,7 @@ void RefineableUnsteadyHeatProblem::doc_solution() // Plot wall posn //--------------- - sprintf(filename,"%s/Wall%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/Wall%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); @@ -884,7 +884,7 @@ void RefineableUnsteadyHeatProblem::doc_solution() some_file.close(); // Write restart file - sprintf(filename,"%s/restart%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/restart%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); dump_it(some_file); diff --git a/demo_drivers/unsteady_heat/two_d_unsteady_heat_ALE/two_d_unsteady_heat_ALE.cc b/demo_drivers/unsteady_heat/two_d_unsteady_heat_ALE/two_d_unsteady_heat_ALE.cc index 7e4939fac862..fa03277877d1 100644 --- a/demo_drivers/unsteady_heat/two_d_unsteady_heat_ALE/two_d_unsteady_heat_ALE.cc +++ b/demo_drivers/unsteady_heat/two_d_unsteady_heat_ALE/two_d_unsteady_heat_ALE.cc @@ -322,7 +322,7 @@ RefineableUnsteadyHeatProblem::RefineableUnsteadyHeatProblem( // Open trace file char filename[100]; - sprintf(filename,"%s/trace.dat",Doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",Doc_info.directory().c_str()); Trace_file.open(filename); Trace_file << "VARIABLES=\"time t\",\"uFE\",\"uexact\"," @@ -726,7 +726,7 @@ void RefineableUnsteadyHeatProblem::doc_solution() // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); @@ -755,7 +755,7 @@ void RefineableUnsteadyHeatProblem::doc_solution() // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output_fct(some_file,npts,time_pt()->time(), @@ -779,7 +779,7 @@ void RefineableUnsteadyHeatProblem::doc_solution() // Doc error //---------- double error,norm; - sprintf(filename,"%s/error%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Bulk_mesh_pt->compute_error(some_file, @@ -817,7 +817,7 @@ void RefineableUnsteadyHeatProblem::doc_solution() // Plot wall posn //--------------- - sprintf(filename,"%s/Wall%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/Wall%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); @@ -831,7 +831,7 @@ void RefineableUnsteadyHeatProblem::doc_solution() some_file.close(); // Write restart file - sprintf(filename,"%s/restart%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/restart%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); dump_it(some_file); diff --git a/demo_drivers/unsteady_heat/two_d_unsteady_heat_adapt/two_d_unsteady_heat_adapt.cc b/demo_drivers/unsteady_heat/two_d_unsteady_heat_adapt/two_d_unsteady_heat_adapt.cc index 87974076136a..12a38f6fb1b5 100644 --- a/demo_drivers/unsteady_heat/two_d_unsteady_heat_adapt/two_d_unsteady_heat_adapt.cc +++ b/demo_drivers/unsteady_heat/two_d_unsteady_heat_adapt/two_d_unsteady_heat_adapt.cc @@ -294,7 +294,7 @@ RefineableUnsteadyHeatProblem::RefineableUnsteadyHeatProblem( // Open trace file char filename[100]; - sprintf(filename,"%s/trace.dat",Doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",Doc_info.directory().c_str()); Trace_file.open(filename); Trace_file << "VARIABLES=\"time t\",\"uFE\",\"uexact\"," @@ -671,7 +671,7 @@ void RefineableUnsteadyHeatProblem::doc_solution() // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); @@ -700,7 +700,7 @@ void RefineableUnsteadyHeatProblem::doc_solution() // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output_fct(some_file,npts,time_pt()->time(), @@ -724,7 +724,7 @@ void RefineableUnsteadyHeatProblem::doc_solution() // Doc error //---------- double error,norm; - sprintf(filename,"%s/error%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); Bulk_mesh_pt->compute_error(some_file, @@ -762,7 +762,7 @@ void RefineableUnsteadyHeatProblem::doc_solution() // Plot wall posn //--------------- - sprintf(filename,"%s/Wall%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/Wall%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); @@ -776,7 +776,7 @@ void RefineableUnsteadyHeatProblem::doc_solution() some_file.close(); // Write restart file - sprintf(filename,"%s/restart%i.dat",Doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/restart%i.dat",Doc_info.directory().c_str(), Doc_info.number()); some_file.open(filename); dump_it(some_file); diff --git a/demo_drivers/unsteady_heat/two_d_unsteady_heat_t_adapt/two_d_unsteady_heat_t_adapt.cc b/demo_drivers/unsteady_heat/two_d_unsteady_heat_t_adapt/two_d_unsteady_heat_t_adapt.cc index fa346ea3a371..0108365dd44e 100644 --- a/demo_drivers/unsteady_heat/two_d_unsteady_heat_t_adapt/two_d_unsteady_heat_t_adapt.cc +++ b/demo_drivers/unsteady_heat/two_d_unsteady_heat_t_adapt/two_d_unsteady_heat_t_adapt.cc @@ -443,7 +443,7 @@ doc_solution(DocInfo& doc_info,ofstream& trace_file) // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -475,7 +475,7 @@ doc_solution(DocInfo& doc_info,ofstream& trace_file) // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output_fct(some_file,npts,time_pt()->time(), @@ -496,7 +496,7 @@ doc_solution(DocInfo& doc_info,ofstream& trace_file) // Doc error //---------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->compute_error(some_file, @@ -525,7 +525,7 @@ doc_solution(DocInfo& doc_info,ofstream& trace_file) // Write restart file - sprintf(filename,"%s/restart%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/restart%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); dump_it(some_file); @@ -631,7 +631,7 @@ int main(int argc, char* argv[]) // Open a trace file ofstream trace_file; char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); trace_file.open(filename); trace_file << "VARIABLES=\"time\",\"dt\",\"uFE\"," << "\"uexact\",\"norm of error\",\"norm of solution\"" diff --git a/demo_drivers/womersley/one_d_womersley/one_d_womersley.cc b/demo_drivers/womersley/one_d_womersley/one_d_womersley.cc index 1f3950fa2c18..71f8ee7d4c5a 100644 --- a/demo_drivers/womersley/one_d_womersley/one_d_womersley.cc +++ b/demo_drivers/womersley/one_d_womersley/one_d_womersley.cc @@ -830,7 +830,7 @@ void CollapsibleChannelProblem::doc_solution(DocInfo& doc_info, npts=5; // Output solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); bulk_mesh_pt()->output(some_file,npts); @@ -851,7 +851,7 @@ void CollapsibleChannelProblem::doc_solution(DocInfo& doc_info, << std::endl; // Output wall shape - sprintf(filename,"%s/wall%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/wall%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); unsigned nplot=100; @@ -1443,7 +1443,7 @@ unsteady_run(string directory_for_data, double nstep, const bool& validation_run // Open a trace file ofstream trace_file; char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); trace_file.open(filename); // Number of timesteps per period diff --git a/demo_drivers/womersley/two_d_womersley/two_d_womersley.cc b/demo_drivers/womersley/two_d_womersley/two_d_womersley.cc index ec4a8e8e80a2..d9e81868e1a9 100644 --- a/demo_drivers/womersley/two_d_womersley/two_d_womersley.cc +++ b/demo_drivers/womersley/two_d_womersley/two_d_womersley.cc @@ -171,7 +171,7 @@ class RectangularWomersleyImpedanceTube : // Open a trace file ofstream trace_file; char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); trace_file.open(filename); @@ -281,7 +281,7 @@ class RectangularWomersleyImpedanceTube : // unsigned npts; // npts=5; -// sprintf(filename,"%s/navier_stokes_soln%i.dat", +// snprintf(filename, sizeof(filename), "%s/navier_stokes_soln%i.dat", // doc_info.directory().c_str(), // doc_info.number()); // some_file.open(filename); @@ -326,7 +326,7 @@ class RectangularWomersleyImpedanceTube : doc_solution(doc_info,trace_file,xi_hi[0]); // // Output Navier Stokes "solution" -// sprintf(filename,"%s/navier_stokes_soln%i.dat", +// snprintf(filename, sizeof(filename), "%s/navier_stokes_soln%i.dat", // doc_info.directory().c_str(), // doc_info.number()); // some_file.open(filename); @@ -370,7 +370,7 @@ class RectangularWomersleyImpedanceTube : // Open a trace file ofstream trace_file; char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); trace_file.open(filename); // Choose simulation interval and timestep @@ -504,7 +504,7 @@ void run_prescribed_flux() // Open a trace file ofstream trace_file; char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); trace_file.open(filename); // Choose simulation interval and timestep @@ -626,7 +626,7 @@ void run_prescribed_pressure_gradient() // Open a trace file ofstream trace_file; char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); trace_file.open(filename); // Choose simulation interval and timestep diff --git a/demo_drivers/young_laplace/barrel.cc b/demo_drivers/young_laplace/barrel.cc index e35d86664a13..0d34c67635e3 100644 --- a/demo_drivers/young_laplace/barrel.cc +++ b/demo_drivers/young_laplace/barrel.cc @@ -306,7 +306,7 @@ void YoungLaplaceProblem::doc_solution(DocInfo& doc_info, //--------------------- ofstream some_file; char filename[100]; - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -330,7 +330,7 @@ int main() //Open a trace file ofstream trace_file; char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); trace_file.open(filename); // Write kappa, exact kappa and height values diff --git a/demo_drivers/young_laplace/refineable_t_junction.cc b/demo_drivers/young_laplace/refineable_t_junction.cc index 90c723722e38..6eb97f3f20fb 100644 --- a/demo_drivers/young_laplace/refineable_t_junction.cc +++ b/demo_drivers/young_laplace/refineable_t_junction.cc @@ -445,7 +445,7 @@ void RefineableYoungLaplaceProblem::doc_solution(DocInfo& doc_info, ofstream some_file; char filename[100]; //YoungLaplaceEquations::Output_meniscus_and_spines=false; - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); @@ -455,20 +455,20 @@ void RefineableYoungLaplaceProblem::doc_solution(DocInfo& doc_info, //--------------------- ofstream tangent_file; - sprintf(filename,"%s/tangent_to_contact_line%i.dat", + snprintf(filename, sizeof(filename), "%s/tangent_to_contact_line%i.dat", doc_info.directory().c_str(), doc_info.number()); tangent_file.open(filename); ofstream normal_file; - sprintf(filename,"%s/normal_to_contact_line%i.dat", + snprintf(filename, sizeof(filename), "%s/normal_to_contact_line%i.dat", doc_info.directory().c_str(), doc_info.number()); normal_file.open(filename); ofstream contact_angle_file; - sprintf(filename,"%s/contact_angle%i.dat", + snprintf(filename, sizeof(filename), "%s/contact_angle%i.dat", doc_info.directory().c_str(), doc_info.number()); contact_angle_file.open(filename); @@ -554,7 +554,7 @@ int main() // Open a trace file char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); trace_file.open(filename); // Tecplot header for trace file: kappa and height value diff --git a/demo_drivers/young_laplace/refineable_young_laplace.cc b/demo_drivers/young_laplace/refineable_young_laplace.cc index 36a992cc13b6..e8a60d572903 100644 --- a/demo_drivers/young_laplace/refineable_young_laplace.cc +++ b/demo_drivers/young_laplace/refineable_young_laplace.cc @@ -438,7 +438,7 @@ void RefineableYoungLaplaceProblem::doc_solution(DocInfo& doc_info, ofstream some_file; char filename[100]; //YoungLaplaceEquations::Output_meniscus_and_spines=false; - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); @@ -453,20 +453,20 @@ void RefineableYoungLaplaceProblem::doc_solution(DocInfo& doc_info, { ofstream tangent_file; - sprintf(filename,"%s/tangent_to_contact_line%i.dat", + snprintf(filename, sizeof(filename), "%s/tangent_to_contact_line%i.dat", doc_info.directory().c_str(), doc_info.number()); tangent_file.open(filename); ofstream normal_file; - sprintf(filename,"%s/normal_to_contact_line%i.dat", + snprintf(filename, sizeof(filename), "%s/normal_to_contact_line%i.dat", doc_info.directory().c_str(), doc_info.number()); normal_file.open(filename); ofstream contact_angle_file; - sprintf(filename,"%s/contact_angle%i.dat", + snprintf(filename, sizeof(filename), "%s/contact_angle%i.dat", doc_info.directory().c_str(), doc_info.number()); contact_angle_file.open(filename); @@ -558,7 +558,7 @@ void run_it(const string& output_directory) // Open a trace file char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); trace_file.open(filename); // Write kappa, exact kappa if exists and height values diff --git a/demo_drivers/young_laplace/spherical_cap_in_cylinder.cc b/demo_drivers/young_laplace/spherical_cap_in_cylinder.cc index 33163c274796..b79a8afa5223 100644 --- a/demo_drivers/young_laplace/spherical_cap_in_cylinder.cc +++ b/demo_drivers/young_laplace/spherical_cap_in_cylinder.cc @@ -271,7 +271,7 @@ void RefineableYoungLaplaceProblem::doc_solution(DocInfo& doc_info, //--------------------- ofstream some_file; char filename[100]; - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); Bulk_mesh_pt->output(some_file,npts); @@ -321,7 +321,7 @@ int main(int argc, char* argv[]) //Open a trace file char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); trace_file.open(filename); trace_file diff --git a/demo_drivers/young_laplace/young_laplace.cc b/demo_drivers/young_laplace/young_laplace.cc index 91a269be4537..1f9726699941 100644 --- a/demo_drivers/young_laplace/young_laplace.cc +++ b/demo_drivers/young_laplace/young_laplace.cc @@ -360,7 +360,7 @@ void YoungLaplaceProblem::doc_solution(DocInfo& doc_info, //--------------------- ofstream some_file; char filename[100]; - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); for(unsigned i=0;i::doc_solution(DocInfo& doc_info, { ofstream tangent_file; - sprintf(filename,"%s/tangent_to_contact_line%i.dat", + snprintf(filename, sizeof(filename), "%s/tangent_to_contact_line%i.dat", doc_info.directory().c_str(), doc_info.number()); tangent_file.open(filename); ofstream normal_file; - sprintf(filename,"%s/normal_to_contact_line%i.dat", + snprintf(filename, sizeof(filename), "%s/normal_to_contact_line%i.dat", doc_info.directory().c_str(), doc_info.number()); normal_file.open(filename); ofstream contact_angle_file; - sprintf(filename,"%s/contact_angle%i.dat", + snprintf(filename, sizeof(filename), "%s/contact_angle%i.dat", doc_info.directory().c_str(), doc_info.number()); contact_angle_file.open(filename); @@ -493,7 +493,7 @@ void run_it(const string& output_directory) //Open a trace file char filename[100]; - sprintf(filename,"%s/trace.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/trace.dat",doc_info.directory().c_str()); trace_file.open(filename); // Write kappa, exact kappa if exists and height values diff --git a/doc/poisson/two_d_poisson_flux_bc/two_d_poisson_flux_bc.txt b/doc/poisson/two_d_poisson_flux_bc/two_d_poisson_flux_bc.txt index e5a68919d12b..f4833dc08dcc 100644 --- a/doc/poisson/two_d_poisson_flux_bc/two_d_poisson_flux_bc.txt +++ b/doc/poisson/two_d_poisson_flux_bc/two_d_poisson_flux_bc.txt @@ -305,7 +305,7 @@ additional difficulties in refineable problems and we shall demonstrate // Doc error and return of the square of the L2 error //--------------------------------------------------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->compute_error(some_file,TanhSolnForPoisson::get_exact_u, diff --git a/external_src/oomph_gklib_from_metis_from_parmetis_4.0.3/csr.c b/external_src/oomph_gklib_from_metis_from_parmetis_4.0.3/csr.c index a19d793bdcec..ea040dd30e1f 100644 --- a/external_src/oomph_gklib_from_metis_from_parmetis_4.0.3/csr.c +++ b/external_src/oomph_gklib_from_metis_from_parmetis_4.0.3/csr.c @@ -445,7 +445,7 @@ gk_csr_t *gk_csr_Read(char *filename, int format, int readvals, int numbering) if (fmt > 111) gk_errexit(SIGERR, "Cannot read this type of file format [fmt=%zu]!\n", fmt); - sprintf(fmtstr, "%03zu", fmt%1000); + snprintf(fmtstr, sizeof(fmtstr), "%03zu", fmt%1000); readsizes = (fmtstr[0] == '1'); readwgts = (fmtstr[1] == '1'); readvals = (fmtstr[2] == '1'); diff --git a/external_src/oomph_gklib_from_metis_from_parmetis_4.0.3/fs.c b/external_src/oomph_gklib_from_metis_from_parmetis_4.0.3/fs.c index 35e4b97b2916..02d05f400810 100644 --- a/external_src/oomph_gklib_from_metis_from_parmetis_4.0.3/fs.c +++ b/external_src/oomph_gklib_from_metis_from_parmetis_4.0.3/fs.c @@ -208,7 +208,7 @@ int gk_mkpath(char *pathname) { char tmp[2048]; - sprintf(tmp, "mkdir -p %s", pathname); + snprintf(tmp, sizeof(tmp), "mkdir -p %s", pathname); return system(tmp); } @@ -220,6 +220,6 @@ int gk_rmpath(char *pathname) { char tmp[2048]; - sprintf(tmp, "rm -r %s", pathname); + snprintf(tmp, sizeof(tmp), "rm -r %s", pathname); return system(tmp); } diff --git a/external_src/oomph_gklib_from_metis_from_parmetis_4.0.3/graph.c b/external_src/oomph_gklib_from_metis_from_parmetis_4.0.3/graph.c index 209581865e4d..ff00404cb6c7 100644 --- a/external_src/oomph_gklib_from_metis_from_parmetis_4.0.3/graph.c +++ b/external_src/oomph_gklib_from_metis_from_parmetis_4.0.3/graph.c @@ -115,7 +115,7 @@ gk_graph_t *gk_graph_Read(char *filename, int format, int isfewgts, if (fmt > 111) gk_errexit(SIGERR, "Cannot read this type of file format [fmt=%zu]!\n", fmt); - sprintf(fmtstr, "%03zu", fmt%1000); + snprintf(fmtstr, sizeof(fmtstr), "%03zu", fmt%1000); readsizes = (fmtstr[0] == '1'); readwgts = (fmtstr[1] == '1'); readvals = (fmtstr[2] == '1'); diff --git a/external_src/oomph_gklib_from_metis_from_parmetis_4.0.3/io.c b/external_src/oomph_gklib_from_metis_from_parmetis_4.0.3/io.c index caaedcb59c03..d395fe72d80a 100644 --- a/external_src/oomph_gklib_from_metis_from_parmetis_4.0.3/io.c +++ b/external_src/oomph_gklib_from_metis_from_parmetis_4.0.3/io.c @@ -30,7 +30,7 @@ FILE *gk_fopen(char *fname, char *mode, const char *msg) if (fp != NULL) return fp; - sprintf(errmsg,"file: %s, mode: %s, [%s]", fname, mode, msg); + snprintf(errmsg, sizeof(errmsg), "file: %s, mode: %s, [%s]", fname, mode, msg); perror(errmsg); errexit("Failed on gk_fopen()\n"); diff --git a/external_src/oomph_parmetis_4.0.3/node_refine.c b/external_src/oomph_parmetis_4.0.3/node_refine.c index 13c1227bb0df..3923070f72f8 100644 --- a/external_src/oomph_parmetis_4.0.3/node_refine.c +++ b/external_src/oomph_parmetis_4.0.3/node_refine.c @@ -511,7 +511,7 @@ void KWayNodeRefine_Greedy(ctrl_t *ctrl, graph_t *graph, idx_t npasses, real_t u ctrl->comm); graph->mincut = gpwgts[2*nparts-1]; - sprintf(title, "\tTotalSep [%"PRIDX"]", c); + snprintf(title, sizeof(title), "\tTotalSep [%"PRIDX"]", c); IFSET(ctrl->dbglvl, DBG_REFINEINFO, PrintNodeBalanceInfo(ctrl, nparts, gpwgts, badmaxpwgt, title)); diff --git a/external_src/oomph_superlu_6.0.1/slu_util.h b/external_src/oomph_superlu_6.0.1/slu_util.h index 897e229d3b5a..4778097a9eb1 100644 --- a/external_src/oomph_superlu_6.0.1/slu_util.h +++ b/external_src/oomph_superlu_6.0.1/slu_util.h @@ -63,7 +63,7 @@ at the top-level directory. #define ABORT(err_msg) \ { char msg[256];\ - sprintf(msg,"%s at line %d in file %s\n",err_msg,__LINE__, __FILE__);\ + snprintf(msg, sizeof(msg), "%s at line %d in file %s\n",err_msg,__LINE__, __FILE__);\ USER_ABORT(msg); } diff --git a/external_src/oomph_superlu_dist_3.0/util_dist.h b/external_src/oomph_superlu_dist_3.0/util_dist.h index f35457f070d2..a87294a94e0d 100644 --- a/external_src/oomph_superlu_dist_3.0/util_dist.h +++ b/external_src/oomph_superlu_dist_3.0/util_dist.h @@ -20,7 +20,7 @@ #define ABORT(err_msg) \ { char msg[256];\ - sprintf(msg,"%s at line %d in file %s\n",err_msg,__LINE__, __FILE__);\ + snprintf(msg, sizeof(msg), "%s at line %d in file %s\n",err_msg,__LINE__, __FILE__);\ USER_ABORT(msg); } diff --git a/external_src/oomph_superlu_dist_8.2.1/sec_structs.c b/external_src/oomph_superlu_dist_8.2.1/sec_structs.c index ce2bc7adf266..7cf495d5a2f4 100644 --- a/external_src/oomph_superlu_dist_8.2.1/sec_structs.c +++ b/external_src/oomph_superlu_dist_8.2.1/sec_structs.c @@ -519,12 +519,12 @@ void SCT_print3D(gridinfo3d_t *grid3d, SCT_t* SCT) for (int i = maxLvl-1; i >-1; --i) { /* code */ - sprintf( funName, "Grid-%d Factor:Level-%d ", grid3d->zscp.Iam, + snprintf( funName, sizeof( funName), "Grid-%d Factor:Level-%d ", grid3d->zscp.Iam, (int) maxLvl-1-i); DistPrint(funName, SCT->tFactor3D[i], "Seconds", grid); - // sprintf( funName, "SchurCU:Level-%d ", maxLvl-1-i); + // snprintf( funName, sizeof( funName), "SchurCU:Level-%d ", maxLvl-1-i); // DistPrint(funName, SCT->tSchCompUdt3d[i], "Seconds", grid); - // sprintf( funName, "PanelFact:Level-%d ", maxLvl-1-i); + // snprintf( funName, sizeof( funName), "PanelFact:Level-%d ", maxLvl-1-i); // DistPrint(funName, SCT->tFactor3D[i]-SCT->tSchCompUdt3d[i], "Seconds", grid); } @@ -550,12 +550,12 @@ void treeImbalance3D(gridinfo3d_t *grid3d, SCT_t* SCT) double tavg = tsum /(grid3d->zscp.Np>>i); double lLmb = 100*(tmax-tavg)/tavg; - sprintf( funName, "Imbalance Factor:Level-%d ", (int) maxLvl-1-i); + snprintf( funName, sizeof( funName), "Imbalance Factor:Level-%d ", (int) maxLvl-1-i); if(!grid3d->zscp.Iam) DistPrint(funName, lLmb, "Seconds", grid); - // sprintf( funName, "SchurCU:Level-%d ", maxLvl-1-i); + // snprintf( funName, sizeof( funName), "SchurCU:Level-%d ", maxLvl-1-i); // DistPrint(funName, SCT->tSchCompUdt3d[i], "Seconds", grid); - // sprintf( funName, "PanelFact:Level-%d ", maxLvl-1-i); + // snprintf( funName, sizeof( funName), "PanelFact:Level-%d ", maxLvl-1-i); // DistPrint(funName, SCT->tFactor3D[i]-SCT->tSchCompUdt3d[i], "Seconds", grid); } diff --git a/external_src/oomph_superlu_dist_8.2.1/util_dist.h b/external_src/oomph_superlu_dist_8.2.1/util_dist.h index 037be18f8b6c..afed7e60257c 100644 --- a/external_src/oomph_superlu_dist_8.2.1/util_dist.h +++ b/external_src/oomph_superlu_dist_8.2.1/util_dist.h @@ -37,7 +37,7 @@ at the top-level directory. #define ABORT(err_msg) \ { char msg[256];\ - sprintf(msg,"%s at line %d in file %s\n",err_msg,__LINE__, __FILE__);\ + snprintf(msg, sizeof(msg), "%s at line %d in file %s\n",err_msg,__LINE__, __FILE__);\ USER_ABORT(msg); } diff --git a/external_src/oomph_tetgen/tetgen.cxx b/external_src/oomph_tetgen/tetgen.cxx index a9c668d19549..df9f00abb9ae 100644 --- a/external_src/oomph_tetgen/tetgen.cxx +++ b/external_src/oomph_tetgen/tetgen.cxx @@ -2186,7 +2186,7 @@ void tetgenio::save_nodes(char* filebasename) char outmtrfilename[FILENAMESIZE]; int i, j; - sprintf(outnodefilename, "%s.node", filebasename); + snprintf(outnodefilename, sizeof(outnodefilename), "%s.node", filebasename); printf("Saving nodes to %s\n", outnodefilename); fout = fopen(outnodefilename, "w"); fprintf(fout, "%d %d %d %d\n", numberofpoints, mesh_dim, @@ -2212,7 +2212,7 @@ void tetgenio::save_nodes(char* filebasename) // If the point metrics exist, output them to a .mtr file. if ((numberofpointmtrs > 0) && (pointmtrlist != (REAL *) NULL)) { - sprintf(outmtrfilename, "%s.mtr", filebasename); + snprintf(outmtrfilename, sizeof(outmtrfilename), "%s.mtr", filebasename); printf("Saving metrics to %s\n", outmtrfilename); fout = fopen(outmtrfilename, "w"); fprintf(fout, "%d %d\n", numberofpoints, numberofpointmtrs); @@ -2238,7 +2238,7 @@ void tetgenio::save_elements(char* filebasename) char outelefilename[FILENAMESIZE]; int i, j; - sprintf(outelefilename, "%s.ele", filebasename); + snprintf(outelefilename, sizeof(outelefilename), "%s.ele", filebasename); printf("Saving elements to %s\n", outelefilename); fout = fopen(outelefilename, "w"); if (mesh_dim == 3) { @@ -2285,7 +2285,7 @@ void tetgenio::save_faces(char* filebasename) char outfacefilename[FILENAMESIZE]; int i; - sprintf(outfacefilename, "%s.face", filebasename); + snprintf(outfacefilename, sizeof(outfacefilename), "%s.face", filebasename); printf("Saving faces to %s\n", outfacefilename); fout = fopen(outfacefilename, "w"); fprintf(fout, "%d %d\n", numberoftrifaces, @@ -2314,7 +2314,7 @@ void tetgenio::save_edges(char* filebasename) char outedgefilename[FILENAMESIZE]; int i; - sprintf(outedgefilename, "%s.edge", filebasename); + snprintf(outedgefilename, sizeof(outedgefilename), "%s.edge", filebasename); printf("Saving edges to %s\n", outedgefilename); fout = fopen(outedgefilename, "w"); fprintf(fout, "%d %d\n", numberofedges, edgemarkerlist != NULL ? 1 : 0); @@ -2342,7 +2342,7 @@ void tetgenio::save_neighbors(char* filebasename) char outneighborfilename[FILENAMESIZE]; int i; - sprintf(outneighborfilename, "%s.neigh", filebasename); + snprintf(outneighborfilename, sizeof(outneighborfilename), "%s.neigh", filebasename); printf("Saving neighbors to %s\n", outneighborfilename); fout = fopen(outneighborfilename, "w"); fprintf(fout, "%d %d\n", numberoftetrahedra, mesh_dim + 1); @@ -2377,7 +2377,7 @@ void tetgenio::save_poly(char* filebasename) char outpolyfilename[FILENAMESIZE]; int i, j, k; - sprintf(outpolyfilename, "%s.poly", filebasename); + snprintf(outpolyfilename, sizeof(outpolyfilename), "%s.poly", filebasename); printf("Saving poly to %s\n", outpolyfilename); fout = fopen(outpolyfilename, "w"); @@ -3076,7 +3076,7 @@ bool tetgenbehavior::parse_commandline(int argc, char **argv) workstring[increment] = '%'; workstring[increment + 1] = 'd'; workstring[increment + 2] = '\0'; - sprintf(outfilename, workstring, meshnumber + 1); + snprintf(outfilename, sizeof(outfilename), workstring, meshnumber + 1); } // Additional input file name has the end ".a". strcpy(addinfilename, infilename); @@ -34338,13 +34338,13 @@ void tetgenmesh::qualitystatistics() shortest, longest); printf(" Smallest aspect ratio: %9.5g | Largest aspect ratio: %9.5g\n", smallestratio, biggestratio); - sprintf(sbuf, "%.17g", biggestfaangle); + snprintf(sbuf, sizeof(sbuf), "%.17g", biggestfaangle); if (strlen(sbuf) > 8) { sbuf[8] = '\0'; } printf(" Smallest facangle: %14.5g | Largest facangle: %s\n", smallestfaangle, sbuf); - sprintf(sbuf, "%.17g", biggestdiangle); + snprintf(sbuf, sizeof(sbuf), "%.17g", biggestdiangle); if (strlen(sbuf) > 8) { sbuf[8] = '\0'; } diff --git a/external_src/oomph_tetgen_1.6/tetgen.cxx b/external_src/oomph_tetgen_1.6/tetgen.cxx index 899a47b6c337..ade1afc39cf7 100644 --- a/external_src/oomph_tetgen_1.6/tetgen.cxx +++ b/external_src/oomph_tetgen_1.6/tetgen.cxx @@ -2503,7 +2503,7 @@ void tetgenio::save_nodes(const char *filebasename) char outmtrfilename[FILENAMESIZE]; int i, j; - sprintf(outnodefilename, "%s.node", filebasename); + snprintf(outnodefilename, sizeof(outnodefilename), "%s.node", filebasename); printf("Saving nodes to %s\n", outnodefilename); fout = fopen(outnodefilename, "w"); fprintf(fout, "%d %d %d %d\n", numberofpoints, mesh_dim, @@ -2529,7 +2529,7 @@ void tetgenio::save_nodes(const char *filebasename) // If the point metrics exist, output them to a .mtr file. if ((numberofpointmtrs > 0) && (pointmtrlist != (REAL *) NULL)) { - sprintf(outmtrfilename, "%s.mtr", filebasename); + snprintf(outmtrfilename, sizeof(outmtrfilename), "%s.mtr", filebasename); printf("Saving metrics to %s\n", outmtrfilename); fout = fopen(outmtrfilename, "w"); fprintf(fout, "%d %d\n", numberofpoints, numberofpointmtrs); @@ -2555,7 +2555,7 @@ void tetgenio::save_elements(const char* filebasename) char outelefilename[FILENAMESIZE]; int i, j; - sprintf(outelefilename, "%s.ele", filebasename); + snprintf(outelefilename, sizeof(outelefilename), "%s.ele", filebasename); printf("Saving elements to %s\n", outelefilename); fout = fopen(outelefilename, "w"); if (mesh_dim == 3) { @@ -2602,7 +2602,7 @@ void tetgenio::save_faces(const char* filebasename) char outfacefilename[FILENAMESIZE]; int i; - sprintf(outfacefilename, "%s.face", filebasename); + snprintf(outfacefilename, sizeof(outfacefilename), "%s.face", filebasename); printf("Saving faces to %s\n", outfacefilename); fout = fopen(outfacefilename, "w"); fprintf(fout, "%d %d\n", numberoftrifaces, @@ -2631,7 +2631,7 @@ void tetgenio::save_edges(char* filebasename) char outedgefilename[FILENAMESIZE]; int i; - sprintf(outedgefilename, "%s.edge", filebasename); + snprintf(outedgefilename, sizeof(outedgefilename), "%s.edge", filebasename); printf("Saving edges to %s\n", outedgefilename); fout = fopen(outedgefilename, "w"); fprintf(fout, "%d %d\n", numberofedges, edgemarkerlist != NULL ? 1 : 0); @@ -2659,7 +2659,7 @@ void tetgenio::save_neighbors(char* filebasename) char outneighborfilename[FILENAMESIZE]; int i; - sprintf(outneighborfilename, "%s.neigh", filebasename); + snprintf(outneighborfilename, sizeof(outneighborfilename), "%s.neigh", filebasename); printf("Saving neighbors to %s\n", outneighborfilename); fout = fopen(outneighborfilename, "w"); fprintf(fout, "%d %d\n", numberoftetrahedra, mesh_dim + 1); @@ -2694,7 +2694,7 @@ void tetgenio::save_poly(const char *filebasename) char outpolyfilename[FILENAMESIZE]; int i, j, k; - sprintf(outpolyfilename, "%s.poly", filebasename); + snprintf(outpolyfilename, sizeof(outpolyfilename), "%s.poly", filebasename); printf("Saving poly to %s\n", outpolyfilename); fout = fopen(outpolyfilename, "w"); @@ -2792,7 +2792,7 @@ void tetgenio::save_faces2smesh(char* filebasename) char outsmeshfilename[FILENAMESIZE]; int i, j; - sprintf(outsmeshfilename, "%s.smesh", filebasename); + snprintf(outsmeshfilename, sizeof(outsmeshfilename), "%s.smesh", filebasename); printf("Saving faces to %s\n", outsmeshfilename); fout = fopen(outsmeshfilename, "w"); @@ -3782,7 +3782,7 @@ bool tetgenbehavior::parse_commandline(int argc, char **argv) workstring[increment] = '%'; workstring[increment + 1] = 'd'; workstring[increment + 2] = '\0'; - sprintf(outfilename, workstring, meshnumber + 1); + snprintf(outfilename, sizeof(outfilename), workstring, meshnumber + 1); } // Additional input file name has the end ".a". strcpy(addinfilename, infilename); @@ -32989,13 +32989,13 @@ void tetgenmesh::qualitystatistics() shortest, longest); printf(" Smallest asp.ratio: %13.5g | Largest asp.ratio: %13.5g\n", smallestratio, biggestratio); - sprintf(sbuf, "%.17g", biggestfaangle); + snprintf(sbuf, sizeof(sbuf), "%.17g", biggestfaangle); if (strlen(sbuf) > 8) { sbuf[8] = '\0'; } printf(" Smallest facangle: %14.5g | Largest facangle: %s\n", smallestfaangle, sbuf); - sprintf(sbuf, "%.17g", biggestdiangle); + snprintf(sbuf, sizeof(sbuf), "%.17g", biggestdiangle); if (strlen(sbuf) > 8) { sbuf[8] = '\0'; } @@ -35820,7 +35820,7 @@ void tetgenmesh::outmesh2vtk(char* ofilename, int mesh_idx) if (ofilename != (char *) NULL && ofilename[0] != '\0') { //strcpy(vtkfilename, ofilename); - sprintf(vtkfilename, "%s.%d.vtk", ofilename, mesh_idx); + snprintf(vtkfilename, sizeof(vtkfilename), "%s.%d.vtk", ofilename, mesh_idx); } else if (b->outfilename[0] != '\0') { strcpy(vtkfilename, b->outfilename); strcat(vtkfilename, ".vtk"); @@ -35929,7 +35929,7 @@ void tetgenmesh::out_surfmesh_vtk(char* ofilename, int mesh_idx) if (ofilename != (char *) NULL && ofilename[0] != '\0') { //strcpy(vtkfilename, ofilename); - sprintf(vtkfilename, "%s.%d.vtk", ofilename, mesh_idx); + snprintf(vtkfilename, sizeof(vtkfilename), "%s.%d.vtk", ofilename, mesh_idx); } else if (b->outfilename[0] != '\0') { strcpy(vtkfilename, b->outfilename); strcat(vtkfilename, ".surf.vtk"); diff --git a/external_src/oomph_triangle/triangle.c b/external_src/oomph_triangle/triangle.c index 3f486c181d96..49ad737b7f76 100644 --- a/external_src/oomph_triangle/triangle.c +++ b/external_src/oomph_triangle/triangle.c @@ -3628,7 +3628,7 @@ struct behavior *b; workstring[increment] = '%'; workstring[increment + 1] = 'd'; workstring[increment + 2] = '\0'; - sprintf(b->outnodefilename, workstring, meshnumber + 1); + snprintf(b->outnodefilename, sizeof(b->outnodefilename), workstring, meshnumber + 1); strcpy(b->outpolyfilename, b->outnodefilename); strcpy(b->outelefilename, b->outnodefilename); strcpy(b->edgefilename, b->outnodefilename); diff --git a/external_src/oomph_zlib/gzlib.c b/external_src/oomph_zlib/gzlib.c index 55da46a453fd..97e2053f7d9a 100644 --- a/external_src/oomph_zlib/gzlib.c +++ b/external_src/oomph_zlib/gzlib.c @@ -62,7 +62,7 @@ char ZLIB_INTERNAL *gz_strwinerror(error) LocalFree(msgbuf); } else { - sprintf(buf, "unknown win32 error (%ld)", error); + snprintf(buf, sizeof(buf), "unknown win32 error (%ld)", error); } SetLastError(lasterr); @@ -297,7 +297,7 @@ gzFile ZEXPORT gzdopen(fd, mode) #if !defined(NO_snprintf) && !defined(NO_vsnprintf) (void)snprintf(path, 7 + 3 * sizeof(int), "", fd); #else - sprintf(path, "", fd); /* for debugging */ + snprintf(path, sizeof(path), "", fd); /* for debugging */ #endif gz = gz_open(path, fd, mode); free(path); diff --git a/external_src/oomph_zlib/gzwrite.c b/external_src/oomph_zlib/gzwrite.c index eb8a0e5893ff..d3430cd8d548 100644 --- a/external_src/oomph_zlib/gzwrite.c +++ b/external_src/oomph_zlib/gzwrite.c @@ -426,11 +426,11 @@ int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) next[state->size - 1] = 0; #ifdef NO_vsnprintf # ifdef HAS_vsprintf_void - (void)vsprintf(next, format, va); + (void)vsnprintf(next, sizeof(next), format, va); for (len = 0; len < state->size; len++) if (next[len] == 0) break; # else - len = vsprintf(next, format, va); + len = vsnprintf(next, sizeof(next), format, va); # endif #else # ifdef HAS_vsnprintf_void @@ -520,13 +520,13 @@ int ZEXPORTVA gzprintf(file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, next[state->size - 1] = 0; #ifdef NO_snprintf # ifdef HAS_sprintf_void - sprintf(next, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, + snprintf(next, sizeof(next), format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); for (len = 0; len < size; len++) if (next[len] == 0) break; # else - len = sprintf(next, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, + len = snprintf(next, sizeof(next), format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); # endif #else diff --git a/external_src/oomph_zlib/zlib.h b/external_src/oomph_zlib/zlib.h index 953cb5012dc2..f3fdd4bab5e7 100644 --- a/external_src/oomph_zlib/zlib.h +++ b/external_src/oomph_zlib/zlib.h @@ -1475,7 +1475,7 @@ ZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...)); that this limit is not exceeded. If it is exceeded, then gzprintf() will return an error (0) with nothing written. In this case, there may also be a buffer overflow with unpredictable consequences, which is possible only if - zlib was compiled with the insecure functions sprintf() or vsprintf(), + zlib was compiled with the insecure functions snprintf() or vsprintf(), sizeof() or vsprintf()), because the secure snprintf() or vsnprintf() functions were not available. This can be determined using zlibCompileFlags(). */ diff --git a/self_test/line_visualiser/adaptive_driven_cavity.cc b/self_test/line_visualiser/adaptive_driven_cavity.cc index b501d99d0fb6..1e8342b3f256 100644 --- a/self_test/line_visualiser/adaptive_driven_cavity.cc +++ b/self_test/line_visualiser/adaptive_driven_cavity.cc @@ -275,7 +275,7 @@ void RefineableDrivenCavityProblem::doc_solution(DocInfo& doc_info) // Output solution -- only output line visualiser solution because // that's all we care about here - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); LV_pt->output(some_file); diff --git a/self_test/locate_zeta/locate_zeta_tester.cc b/self_test/locate_zeta/locate_zeta_tester.cc index 28f6a5a715c5..657e553362fb 100644 --- a/self_test/locate_zeta/locate_zeta_tester.cc +++ b/self_test/locate_zeta/locate_zeta_tester.cc @@ -311,7 +311,7 @@ void RefineablePoissonProblem::doc_solution(DocInfo& doc_info) // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -320,7 +320,7 @@ void RefineablePoissonProblem::doc_solution(DocInfo& doc_info) // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output_fct(some_file,npts,GlobalParameters::get_exact_u); @@ -329,7 +329,7 @@ void RefineablePoissonProblem::doc_solution(DocInfo& doc_info) // Doc error and return of the square of the L2 error //--------------------------------------------------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->compute_error(some_file,GlobalParameters::get_exact_u, diff --git a/self_test/locate_zeta/locate_zeta_tester_3d.cc b/self_test/locate_zeta/locate_zeta_tester_3d.cc index 391f8e9fc5b3..b926408a7c85 100644 --- a/self_test/locate_zeta/locate_zeta_tester_3d.cc +++ b/self_test/locate_zeta/locate_zeta_tester_3d.cc @@ -276,7 +276,7 @@ void EighthSpherePoissonProblem::doc_solution(DocInfo& doc_info) // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -285,7 +285,7 @@ void EighthSpherePoissonProblem::doc_solution(DocInfo& doc_info) // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output_fct(some_file,npts,TanhSolnForPoisson::get_exact_u); @@ -295,7 +295,7 @@ void EighthSpherePoissonProblem::doc_solution(DocInfo& doc_info) // Doc error //---------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->compute_error(some_file,TanhSolnForPoisson::get_exact_u, diff --git a/self_test/locate_zeta/locate_zeta_tester_tetgen.cc b/self_test/locate_zeta/locate_zeta_tester_tetgen.cc index f49c88c8b740..b7ebdcd138b5 100644 --- a/self_test/locate_zeta/locate_zeta_tester_tetgen.cc +++ b/self_test/locate_zeta/locate_zeta_tester_tetgen.cc @@ -261,7 +261,7 @@ void PoissonProblem::doc_solution(const unsigned& nplot, // Doc local node numbering //------------------------- - sprintf(filename,"%s/node_numbering%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/node_numbering%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); FiniteElement* el_pt=mesh_pt()->finite_element_pt(0); @@ -279,7 +279,7 @@ void PoissonProblem::doc_solution(const unsigned& nplot, // Output boundaries //------------------ - sprintf(filename,"%s/boundaries%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/boundaries%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output_boundaries(some_file); @@ -288,7 +288,7 @@ void PoissonProblem::doc_solution(const unsigned& nplot, // Output solution //---------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,nplot); @@ -297,7 +297,7 @@ void PoissonProblem::doc_solution(const unsigned& nplot, // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output_fct(some_file,nplot,TanhSolnForPoisson::get_exact_u); @@ -306,7 +306,7 @@ void PoissonProblem::doc_solution(const unsigned& nplot, // Doc error //---------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->compute_error(some_file,TanhSolnForPoisson::get_exact_u, @@ -366,7 +366,7 @@ void PoissonProblem::doc_solution(const unsigned& nplot, el_pt->node_pt(9)->x(1)=0.5; el_pt->node_pt(9)->x(2)=0.5; - sprintf(filename,"RESLT/nodes0.dat"); + snprintf(filename, sizeof(filename), "RESLT/nodes0.dat"); some_file.open(filename); unsigned nnod=el_pt->nnode(); for (unsigned j=0;j::doc_solution(const unsigned& nplot, } some_file.close(); - sprintf(filename,"RESLT/element0.dat"); + snprintf(filename, sizeof(filename), "RESLT/element0.dat"); some_file.open(filename); el_pt->output(some_file,nplot); some_file.close(); @@ -387,7 +387,7 @@ void PoissonProblem::doc_solution(const unsigned& nplot, Vector s(3); Vector s_orig(3); - sprintf(filename,"RESLT/sample_points_in_element0.dat"); + snprintf(filename, sizeof(filename), "RESLT/sample_points_in_element0.dat"); some_file.open(filename); // Tecplot header info diff --git a/self_test/locate_zeta/locate_zeta_tester_triangle.cc b/self_test/locate_zeta/locate_zeta_tester_triangle.cc index 004b3248014d..5c8cb248043e 100644 --- a/self_test/locate_zeta/locate_zeta_tester_triangle.cc +++ b/self_test/locate_zeta/locate_zeta_tester_triangle.cc @@ -439,7 +439,7 @@ UnstructuredPoissonProblem::UnstructuredPoissonProblem() // Open trace file char filename[100]; - sprintf(filename,"RESLT/trace.dat"); + snprintf(filename, sizeof(filename), "RESLT/trace.dat"); Trace_file.open(filename); // Setup equation numbering scheme @@ -544,7 +544,7 @@ void UnstructuredPoissonProblem::doc_solution(const unsigned npts; npts=5; - sprintf(filename,"RESLT/soln%i.dat",Doc_info.number()); + snprintf(filename, sizeof(filename), "RESLT/soln%i.dat",Doc_info.number()); some_file.open(filename); this->My_mesh_pt->output(some_file,npts); some_file << "TEXT X = 22, Y = 92, CS=FRAME T = \"" @@ -553,14 +553,14 @@ void UnstructuredPoissonProblem::doc_solution(const // Output exact solution //---------------------- - sprintf(filename,"RESLT/exact_soln%i.dat",Doc_info.number()); + snprintf(filename, sizeof(filename), "RESLT/exact_soln%i.dat",Doc_info.number()); some_file.open(filename); My_mesh_pt->output_fct(some_file,npts,TanhSolnForPoisson::get_exact_u); some_file.close(); // Output boundaries //------------------ - sprintf(filename,"RESLT/boundaries%i.dat",Doc_info.number()); + snprintf(filename, sizeof(filename), "RESLT/boundaries%i.dat",Doc_info.number()); some_file.open(filename); My_mesh_pt->output_boundaries(some_file); some_file.close(); @@ -569,7 +569,7 @@ void UnstructuredPoissonProblem::doc_solution(const // Doc error and return of the square of the L2 error //--------------------------------------------------- double error,norm,dummy_error,zero_norm; - sprintf(filename,"RESLT/error%i.dat",Doc_info.number()); + snprintf(filename, sizeof(filename), "RESLT/error%i.dat",Doc_info.number()); some_file.open(filename); My_mesh_pt->compute_error(some_file,TanhSolnForPoisson::get_exact_u, error,norm); @@ -612,7 +612,7 @@ void UnstructuredPoissonProblem::doc_solution(const el_pt->node_pt(5)->x(0)=0.0; el_pt->node_pt(5)->x(1)=0.5; - sprintf(filename,"RESLT/element0.dat"); + snprintf(filename, sizeof(filename), "RESLT/element0.dat"); some_file.open(filename); el_pt->output(some_file,nplot); some_file.close(); @@ -621,7 +621,7 @@ void UnstructuredPoissonProblem::doc_solution(const Vector s(2); Vector s_orig(2); - sprintf(filename,"RESLT/sample_points_in_element0.dat"); + snprintf(filename, sizeof(filename), "RESLT/sample_points_in_element0.dat"); some_file.open(filename); // Tecplot header info diff --git a/self_test/matrix_matrix_multiply/matrix_multiply_test.cc b/self_test/matrix_matrix_multiply/matrix_multiply_test.cc index b5bfbc701995..94df03fb7d50 100644 --- a/self_test/matrix_matrix_multiply/matrix_multiply_test.cc +++ b/self_test/matrix_matrix_multiply/matrix_multiply_test.cc @@ -229,7 +229,7 @@ void RectangularDrivenCavityProblem::doc_solution(DocInfo& doc_info) npts=5; // Output solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); diff --git a/self_test/mpi/generic_mpi/generic_mpi_test.cc b/self_test/mpi/generic_mpi/generic_mpi_test.cc index 9d3094b9960f..f0a8a59078b0 100644 --- a/self_test/mpi/generic_mpi/generic_mpi_test.cc +++ b/self_test/mpi/generic_mpi/generic_mpi_test.cc @@ -270,7 +270,7 @@ int main(int argc, char* argv[]) // Define processor-labeled output file for all on-screen stuff std::ofstream output_stream; char filename[100]; - sprintf(filename,"OUTPUT.%i",MPI_Helpers::communicator_pt()->my_rank()); + snprintf(filename, sizeof(filename), "OUTPUT.%i",MPI_Helpers::communicator_pt()->my_rank()); output_stream.open(filename); oomph_info.stream_pt() = &output_stream; OomphLibWarning::set_stream_pt(&output_stream); diff --git a/self_test/mpi/line_visualiser/adaptive_driven_cavity.cc b/self_test/mpi/line_visualiser/adaptive_driven_cavity.cc index d79ad4ef22a5..332a206dafb9 100644 --- a/self_test/mpi/line_visualiser/adaptive_driven_cavity.cc +++ b/self_test/mpi/line_visualiser/adaptive_driven_cavity.cc @@ -294,7 +294,7 @@ void RefineableDrivenCavityProblem::doc_solution(DocInfo& doc_info) // Output solution, only output Line Visualsier as it's all we're // interested - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); LV_pt->output(some_file); @@ -350,7 +350,7 @@ int main(int argc, char **argv) // Write partition to disk std::ofstream output_file; char filename[100]; - sprintf(filename,"out_adaptive_cavity_1_partition.dat"); + snprintf(filename, sizeof(filename), "out_adaptive_cavity_1_partition.dat"); output_file.open(filename); for (unsigned e=0;enelement(); Vector element_partition(n_element); - sprintf(filename,"adaptive_cavity_2_partition.dat"); + snprintf(filename, sizeof(filename), "adaptive_cavity_2_partition.dat"); input_file.open(filename); std::string input_string; for (unsigned e=0;e::doc_solution(DocInfo& doc_info) // Output boundaries //------------------ - sprintf(filename,"%s/boundaries%i_on_proc%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/boundaries%i_on_proc%i.dat",doc_info.directory().c_str(), doc_info.number(),this->communicator_pt()->my_rank()); some_file.open(filename); mesh_pt()->output_boundaries(some_file); @@ -274,7 +274,7 @@ void ThreeDPoissonProblem::doc_solution(DocInfo& doc_info) // Output solution //----------------- - sprintf(filename,"%s/soln%i_on_proc%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i_on_proc%i.dat",doc_info.directory().c_str(), doc_info.number(),this->communicator_pt()->my_rank()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -283,7 +283,7 @@ void ThreeDPoissonProblem::doc_solution(DocInfo& doc_info) // // Output exact solution // //---------------------- -// sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), +// snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), // doc_info.number()); // some_file.open(filename); // mesh_pt()->output_fct(some_file,npts,TanhSolnForPoisson::get_exact_u); @@ -400,7 +400,7 @@ void parallel_test(const unsigned& n_refine_first, // Get partition from file unsigned n_partition=problem_pt->mesh_pt()->nelement(); Vector element_partition(n_partition,0); - sprintf(filename,"three_d_mesh_dist_partition.dat"); + snprintf(filename, sizeof(filename), "three_d_mesh_dist_partition.dat"); input_file.open(filename); std::string input_string; for (unsigned e=0;edistribute(element_partition,doc_info,report_stats); // out_element_partition); -// sprintf(filename,"out_three_d_mesh_dist_partition.dat"); +// snprintf(filename, sizeof(filename), "out_three_d_mesh_dist_partition.dat"); // output_file.open(filename); // for (unsigned e=0;e::doc_solution(DocInfo& doc_info) unsigned npts=5; // Output solution - sprintf(filename,"%s/soln%i_on_proc%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i_on_proc%i.dat",doc_info.directory().c_str(), doc_info.number(),this->communicator_pt()->my_rank()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -381,7 +381,7 @@ void parallel_test(const unsigned& n_refine_first, // Get the partition to be used from file unsigned n_partition=problem_pt->mesh_pt()->nelement(); Vector element_partition(n_partition); - sprintf(filename,"two_d_mesh_dist_partition.dat"); + snprintf(filename, sizeof(filename), "two_d_mesh_dist_partition.dat"); input_file.open(filename); std::string input_string; for (unsigned e=0;edistribute(element_partition, doc_info,report_stats); - sprintf(filename,"out_two_d_mesh_dist_partition.dat"); + snprintf(filename, sizeof(filename), "out_two_d_mesh_dist_partition.dat"); output_file.open(filename); for (unsigned e=0;e::doc_solution(DocInfo& doc_info, npts=5; // Output solution - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -458,7 +458,7 @@ void DrivenCavityProblem::run(unsigned& next_istep) // Open trace file char filename[100]; - sprintf(filename,"%s/trace%i.dat",doc_info.directory().c_str(),next_istep); + snprintf(filename, sizeof(filename), "%s/trace%i.dat",doc_info.directory().c_str(),next_istep); trace_file.open(filename); trace_file << "# Driven cavity validation " << std::endl; trace_file << "# # of nodes along element edge " diff --git a/self_test/poisson/convergence_tests/q_convergence_2d.cc b/self_test/poisson/convergence_tests/q_convergence_2d.cc index 5504bc53c9b8..577d162e3677 100644 --- a/self_test/poisson/convergence_tests/q_convergence_2d.cc +++ b/self_test/poisson/convergence_tests/q_convergence_2d.cc @@ -222,14 +222,14 @@ void PoissonProblem::doc_solution(DocInfo& doc_info, { // Output boundaries //------------------ - sprintf(filename,"%s/boundaries.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/boundaries.dat",doc_info.directory().c_str()); some_file.open(filename); mesh_pt()->output_boundaries(some_file); some_file.close(); // Output solution //---------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -237,7 +237,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info, // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output_fct(some_file,npts,TanhSolnForPoisson::get_exact_u); @@ -247,7 +247,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info, // Doc error //---------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->compute_error(some_file,TanhSolnForPoisson::get_exact_u, diff --git a/self_test/poisson/convergence_tests/q_convergence_3d.cc b/self_test/poisson/convergence_tests/q_convergence_3d.cc index 30e1e8f5bfb0..3af490194587 100644 --- a/self_test/poisson/convergence_tests/q_convergence_3d.cc +++ b/self_test/poisson/convergence_tests/q_convergence_3d.cc @@ -282,14 +282,14 @@ ostream& convergence_file) // Output boundaries //------------------ - sprintf(filename,"%s/boundaries.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/boundaries.dat",doc_info.directory().c_str()); some_file.open(filename); mesh_pt()->output_boundaries(some_file); some_file.close(); // Output solution //----------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -298,7 +298,7 @@ ostream& convergence_file) // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output_fct(some_file,npts,TanhSolnForPoisson::get_exact_u); @@ -309,7 +309,7 @@ ostream& convergence_file) // Doc error //---------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->compute_error(some_file,TanhSolnForPoisson::get_exact_u, diff --git a/self_test/poisson/convergence_tests/t_convergence_2d.cc b/self_test/poisson/convergence_tests/t_convergence_2d.cc index c37e3a1856be..278f525cb5d2 100644 --- a/self_test/poisson/convergence_tests/t_convergence_2d.cc +++ b/self_test/poisson/convergence_tests/t_convergence_2d.cc @@ -223,14 +223,14 @@ void PoissonProblem::doc_solution(DocInfo& doc_info, { // Output boundaries //------------------ - sprintf(filename,"%s/boundaries.dat",doc_info.directory().c_str()); + snprintf(filename, sizeof(filename), "%s/boundaries.dat",doc_info.directory().c_str()); some_file.open(filename); mesh_pt()->output_boundaries(some_file); some_file.close(); // Output solution //---------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -238,7 +238,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info, // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output_fct(some_file,npts,TanhSolnForPoisson::get_exact_u); @@ -248,7 +248,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info, // Doc error //---------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->compute_error(some_file,TanhSolnForPoisson::get_exact_u, diff --git a/self_test/poisson/convergence_tests/t_convergence_3d.cc b/self_test/poisson/convergence_tests/t_convergence_3d.cc index c8764492cf9d..b77c4963ec31 100644 --- a/self_test/poisson/convergence_tests/t_convergence_3d.cc +++ b/self_test/poisson/convergence_tests/t_convergence_3d.cc @@ -279,7 +279,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info, // Doc local node numbering //------------------------- - sprintf(filename,"%s/node_numbering%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/node_numbering%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); FiniteElement* el_pt=mesh_pt()->finite_element_pt(0); @@ -297,7 +297,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info, // Output mesh //------------ - sprintf(filename,"%s/mesh%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/mesh%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file); @@ -305,7 +305,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info, // Output boundaries //------------------ - sprintf(filename,"%s/boundaries%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/boundaries%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output_boundaries(some_file); @@ -313,7 +313,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info, // Output solution //---------------- - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -321,7 +321,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info, // Output exact solution //---------------------- - sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output_fct(some_file,npts,TanhSolnForPoisson::get_exact_u); @@ -331,7 +331,7 @@ void PoissonProblem::doc_solution(DocInfo& doc_info, // Doc error //---------- double error,norm; - sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->compute_error(some_file,TanhSolnForPoisson::get_exact_u, diff --git a/self_test/poisson/face_tests/q_faces_2d.cc b/self_test/poisson/face_tests/q_faces_2d.cc index 1ecd79dc0016..50182747222d 100644 --- a/self_test/poisson/face_tests/q_faces_2d.cc +++ b/self_test/poisson/face_tests/q_faces_2d.cc @@ -189,7 +189,7 @@ QFaceTestProblem(const unsigned& h_power) : H_power(h_power) string filestem = FileStem()(); //Output for the errors on each face char error_file[100]; - sprintf(error_file,"%s_errors.dat",filestem.c_str()); + snprintf(error_file, sizeof(error_file), "%s_errors.dat",filestem.c_str()); ofstream output_error(error_file); //Construct face elements on all the boundaries @@ -223,7 +223,7 @@ QFaceTestProblem(const unsigned& h_power) : H_power(h_power) Vector x(2), n(2), N(2); //Open a filename with a unique name for each different element type char filename[100]; - sprintf(filename,"%s_normals%i.dat",filestem.c_str(),b); + snprintf(filename, sizeof(filename), "%s_normals%i.dat",filestem.c_str(),b); ofstream output(filename); //Loop over the face elements diff --git a/self_test/poisson/face_tests/q_faces_3d.cc b/self_test/poisson/face_tests/q_faces_3d.cc index a3b97eb8e4d7..793b75611754 100644 --- a/self_test/poisson/face_tests/q_faces_3d.cc +++ b/self_test/poisson/face_tests/q_faces_3d.cc @@ -209,7 +209,7 @@ QFaceTestProblem(const unsigned& h_power) : H_power(h_power) string filestem = FileStem()(); //Output for the errors on each face char error_file[100]; - sprintf(error_file,"%s_errors.dat",filestem.c_str()); + snprintf(error_file, sizeof(error_file), "%s_errors.dat",filestem.c_str()); ofstream output_error(error_file); //Construct face elements on all the boundaries @@ -241,7 +241,7 @@ QFaceTestProblem(const unsigned& h_power) : H_power(h_power) Vector x(3), n(3), N(3),s(2); //Open a filename with a unique name for each different element type char filename[100]; - sprintf(filename,"%s_normals%i.dat",filestem.c_str(),b); + snprintf(filename, sizeof(filename), "%s_normals%i.dat",filestem.c_str(),b); ofstream output(filename); //Now loop over the face elements diff --git a/self_test/poisson/face_tests/t_faces_2d.cc b/self_test/poisson/face_tests/t_faces_2d.cc index abeb1925ab14..4e9161f8e383 100644 --- a/self_test/poisson/face_tests/t_faces_2d.cc +++ b/self_test/poisson/face_tests/t_faces_2d.cc @@ -258,7 +258,7 @@ TriangleFaceTestProblem(const unsigned& h_power,const bool &permute) : string filestem = FileStem()(); //Output for the errors on each face char error_file[100]; - sprintf(error_file,"%s_errors_%i.dat",filestem.c_str(),permute); + snprintf(error_file, sizeof(error_file), "%s_errors_%i.dat",filestem.c_str(),permute); ofstream output_error(error_file); if(permute) {std::cout << "Permuted Nodes" << std::endl;} @@ -290,7 +290,7 @@ TriangleFaceTestProblem(const unsigned& h_power,const bool &permute) : Vector n(2); Vector N(2); char filename[100]; - sprintf(filename,"%s_normals%i_%i.dat", + snprintf(filename, sizeof(filename), "%s_normals%i_%i.dat", filestem.c_str(),b,permute); ofstream output(filename); for(std::list::iterator it=faces_on_boundary[b].begin(); diff --git a/self_test/poisson/face_tests/t_faces_3d.cc b/self_test/poisson/face_tests/t_faces_3d.cc index f38bdd896b65..115723370489 100644 --- a/self_test/poisson/face_tests/t_faces_3d.cc +++ b/self_test/poisson/face_tests/t_faces_3d.cc @@ -382,7 +382,7 @@ TFaceTestProblem(const unsigned& h_power, const unsigned &rotate, //Create an output file char filename[100]; - sprintf(filename,"%s_normals%i_%i.dat",filestem.c_str(),b,rotate); + snprintf(filename, sizeof(filename), "%s_normals%i_%i.dat",filestem.c_str(),b,rotate); ofstream output(filename); output << flux_element_pt->tecplot_zone_string(n_pts); double local_error = 0.0; @@ -476,7 +476,7 @@ TFaceTestProblem(const unsigned& h_power, const unsigned &rotate, Vector s(2); char filename[100]; - sprintf(filename,"%s_normals%i.dat",filestem.c_str(),b); + snprintf(filename, sizeof(filename), "%s_normals%i.dat",filestem.c_str(),b); ofstream output(filename); for(std::list::iterator it=faces_on_boundary[b].begin(); it!=faces_on_boundary[b].end();++it) diff --git a/self_test/poisson/octree_test/octree_test.cc b/self_test/poisson/octree_test/octree_test.cc index ad3b42569026..99af31ba97a9 100644 --- a/self_test/poisson/octree_test/octree_test.cc +++ b/self_test/poisson/octree_test/octree_test.cc @@ -875,11 +875,11 @@ void TestPoissonProblem::doc_solution(DocInfo& doc_info) npts=5; // Doc orientation of the root elements - sprintf(filename,"%s/orientation%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/orientation%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); - sprintf(filename,"%s/root_elements%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/root_elements%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file2.open(filename); @@ -941,7 +941,7 @@ void TestPoissonProblem::doc_solution(DocInfo& doc_info) // Output solution //----------------- //mesh_pt()->sort_elements(); - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); diff --git a/self_test/poisson/tree_rotation_tests/tree_2d.cc b/self_test/poisson/tree_rotation_tests/tree_2d.cc index 9077cf3e0628..0df440eb721c 100644 --- a/self_test/poisson/tree_rotation_tests/tree_2d.cc +++ b/self_test/poisson/tree_rotation_tests/tree_2d.cc @@ -642,7 +642,7 @@ void TestRefineablePoissonProblem::doc_solution(DocInfo& doc_info) unsigned npts=5; // Output the nodes - //sprintf(filename,"%s/nodes%i.dat",doc_info.directory().c_str(), + //snprintf(filename, sizeof(filename), "%s/nodes%i.dat",doc_info.directory().c_str(), // doc_info.number()); //some_file.open(filename); // { @@ -659,7 +659,7 @@ void TestRefineablePoissonProblem::doc_solution(DocInfo& doc_info) // Output solution //----------------- this->mesh_pt()->sort_elements(); - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -668,7 +668,7 @@ void TestRefineablePoissonProblem::doc_solution(DocInfo& doc_info) // Output exact solution //---------------------- - //sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), + //snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), // doc_info.number()); //some_file.open(filename); //mesh_pt()->output_fct(some_file,npts,TanhSolnForPoisson::get_exact_u); @@ -677,7 +677,7 @@ void TestRefineablePoissonProblem::doc_solution(DocInfo& doc_info) // Doc error and return of the square of the L2 error //--------------------------------------------------- //double error,norm; - //sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), + //snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), // doc_info.number()); //some_file.open(filename); //mesh_pt()->compute_error(some_file,TanhSolnForPoisson::get_exact_u, @@ -697,7 +697,7 @@ template void run_test(const unsigned &i) { char dirname[100]; - sprintf(dirname,"RESLT%i",i); + snprintf(dirname, sizeof(dirname), "RESLT%i",i); // Create label for output //------------------------ diff --git a/self_test/poisson/tree_rotation_tests/tree_3d.cc b/self_test/poisson/tree_rotation_tests/tree_3d.cc index 083ff906633e..437154ef106b 100644 --- a/self_test/poisson/tree_rotation_tests/tree_3d.cc +++ b/self_test/poisson/tree_rotation_tests/tree_3d.cc @@ -833,7 +833,7 @@ void TestPoissonProblem::doc_solution(DocInfo& doc_info) // Output solution //----------------- mesh_pt()->sort_elements(); - sprintf(filename,"%s/soln%i.dat",doc_info.directory().c_str(), + snprintf(filename, sizeof(filename), "%s/soln%i.dat",doc_info.directory().c_str(), doc_info.number()); some_file.open(filename); mesh_pt()->output(some_file,npts); @@ -842,7 +842,7 @@ void TestPoissonProblem::doc_solution(DocInfo& doc_info) // Output exact solution //---------------------- -// sprintf(filename,"%s/exact_soln%i.dat",doc_info.directory().c_str(), +// snprintf(filename, sizeof(filename), "%s/exact_soln%i.dat",doc_info.directory().c_str(), // doc_info.number()); // some_file.open(filename); // mesh_pt()->output_fct(some_file,npts,TanhSolnForPoisson::get_exact_u); @@ -852,7 +852,7 @@ void TestPoissonProblem::doc_solution(DocInfo& doc_info) // // Doc error // //---------- // double error,norm; -// sprintf(filename,"%s/error%i.dat",doc_info.directory().c_str(), +// snprintf(filename, sizeof(filename), "%s/error%i.dat",doc_info.directory().c_str(), // doc_info.number()); // some_file.open(filename); // mesh_pt()->compute_error(some_file,TanhSolnForPoisson::get_exact_u, @@ -869,7 +869,7 @@ template void run_test(const unsigned &i) { char dirname[100]; - sprintf(dirname,"RESLT%i",i); + snprintf(dirname, sizeof(dirname), "RESLT%i",i); // Create label for output //------------------------ diff --git a/src/generic/extruded_domain.cc b/src/generic/extruded_domain.cc index ff72b1916c0e..7abdc84463c7 100644 --- a/src/generic/extruded_domain.cc +++ b/src/generic/extruded_domain.cc @@ -99,7 +99,7 @@ namespace oomph unsigned n_pts=20; // Create the file name - sprintf(filename,"RESLT/extruded_element%i.dat",i); + snprintf(filename, sizeof(filename), "RESLT/extruded_element%i.dat",i); // Open a file with the created filename some_file.open(filename); diff --git a/src/generic/hypre_solver.cc b/src/generic/hypre_solver.cc index 1ad5f83afbc3..0b44b9c807a3 100644 --- a/src/generic/hypre_solver.cc +++ b/src/generic/hypre_solver.cc @@ -449,13 +449,13 @@ namespace oomph // set level for ILU(k) args[n_args++] = "-level"; char level_value[10]; - sprintf(level_value, "%d", level); + snprintf(level_value, sizeof(level_value), "%d", level); args[n_args++] = level_value; // // set drop tol for ILU(k) factorization // args[n_args++] = "-sparseA"; // char droptol[20]; - // sprintf(droptol,"%f",drop_tol); + // snprintf(droptol, sizeof(droptol), "%f",drop_tol); // args[n_args++] = droptol; // // set ILUT factorization if required diff --git a/src/generic/multi_domain.tpp b/src/generic/multi_domain.tpp index fd8a7b8666cd..59f00ed5ede0 100644 --- a/src/generic/multi_domain.tpp +++ b/src/generic/multi_domain.tpp @@ -1418,7 +1418,10 @@ namespace oomph outfile.close(); } - sprintf(filename, "missing_coords%s.dat", modifier.str().c_str()); + snprintf(filename, + sizeof(filename), + "missing_coords%s.dat", + modifier.str().c_str()); outfile.open(filename); unsigned n = External_element_located.size(); error_stream << "Number of unlocated elements " << n << std::endl; diff --git a/src/generic/mumps_solver.cc b/src/generic/mumps_solver.cc index 04d0a65e86fa..ac70ea5dcda4 100644 --- a/src/generic/mumps_solver.cc +++ b/src/generic/mumps_solver.cc @@ -116,7 +116,8 @@ namespace oomph Mumps_struc_pt->ICNTL(4) = 2; // Write matrix - // sprintf(Mumps_struc_pt->write_problem,"/work/e173/e173/mheil/matrix"); + // snprintf(Mumps_struc_pt->write_problem, + // sizeof(Mumps_struc_pt->write_problem), "/work/e173/e173/mheil/matrix"); // Assembled matrix (rather than element-by_element) Mumps_struc_pt->ICNTL(5) = 0; diff --git a/src/generic/problem.cc b/src/generic/problem.cc index ceef7506f175..f82b0850c850 100644 --- a/src/generic/problem.cc +++ b/src/generic/problem.cc @@ -13323,13 +13323,14 @@ namespace oomph // //--------------------------------------------------------- // std::ofstream some_file; // char filename[100]; - // sprintf(filename,"read_mesh%i_on_proc%i.dat",m, + // snprintf(filename, sizeof(filename), "read_mesh%i_on_proc%i.dat",m, // this->communicator_pt()->my_rank()); // some_file.open(filename); // mesh_pt(m)->output(some_file); // some_file.close(); - // sprintf(filename,"read_mesh%i_with_haloes_on_proc%i.dat",m, + // snprintf(filename, sizeof(filename), + // "read_mesh%i_with_haloes_on_proc%i.dat",m, // this->communicator_pt()->my_rank()); // mesh_pt(m)->enable_output_of_halo_elements(); // some_file.open(filename); @@ -13338,7 +13339,8 @@ namespace oomph // some_file.close(); // oomph_info << "Doced mesh " << m << " before reading\n"; - // sprintf(filename,"read_nodes_mesh%i_on_proc%i.dat",m, + // snprintf(filename, sizeof(filename), + // "read_nodes_mesh%i_on_proc%i.dat",m, // this->communicator_pt()->my_rank()); // some_file.open(filename); // unsigned nnod=mesh_pt(m)->nnode(); diff --git a/src/generic/refineable_mesh.cc b/src/generic/refineable_mesh.cc index c20a450b744e..dcce5790cce8 100644 --- a/src/generic/refineable_mesh.cc +++ b/src/generic/refineable_mesh.cc @@ -2754,13 +2754,13 @@ namespace oomph { char filename[100]; std::ofstream some_file; - sprintf(filename,"sync_hanging_node_crash_mesh_proc%i.dat", - my_rank); + snprintf(filename, sizeof(filename), + "sync_hanging_node_crash_mesh_proc%i.dat", my_rank); some_file.open(filename); this->output(some_file); some_file.close(); - sprintf(filename, + snprintf(filename, sizeof(filename), "sync_hanging_node_crash_mesh_with_haloes_proc%i.dat", my_rank); some_file.open(filename); diff --git a/src/generic/tet_mesh.cc b/src/generic/tet_mesh.cc index fc3ae1879cdb..df5aa5b18c35 100644 --- a/src/generic/tet_mesh.cc +++ b/src/generic/tet_mesh.cc @@ -784,7 +784,8 @@ namespace oomph some_element_is_inverted = true; char filename[100]; std::ofstream some_file; - sprintf(filename, "overly_distorted_element%i.dat", count); + snprintf( + filename, sizeof(filename), "overly_distorted_element%i.dat", count); some_file.open(filename); unsigned nnod_1d = el_pt->nnode_1d(); el_pt->output(some_file, nnod_1d); @@ -806,7 +807,10 @@ namespace oomph } // Plot - sprintf(filename, "orig_overly_distorted_element%i.dat", count); + snprintf(filename, + sizeof(filename), + "orig_overly_distorted_element%i.dat", + count); some_file.open(filename); el_pt->output(some_file, nnod_1d); some_file.close(); diff --git a/src/generic/triangle_mesh.cc b/src/generic/triangle_mesh.cc index 2cb363230fa0..7c19b3fa04fe 100644 --- a/src/generic/triangle_mesh.cc +++ b/src/generic/triangle_mesh.cc @@ -224,7 +224,8 @@ namespace oomph std::ofstream outfile; char filename[100]; - sprintf(filename, "Triangulateio_object_%s.dat", s.c_str()); + snprintf( + filename, sizeof(filename), "Triangulateio_object_%s.dat", s.c_str()); outfile.open(filename); outfile << "# Triangulateio object values:\n\n" << std::endl; @@ -273,7 +274,7 @@ namespace oomph std::ofstream nodefile; char nodename[100]; - sprintf(nodename, "file_%s.1.node", s.c_str()); + snprintf(nodename, sizeof(nodename), "file_%s.1.node", s.c_str()); nodefile.open(nodename); nodefile << triangle.numberofpoints << " 2 " << triangle.numberofpointattributes << " 0" << std::endl; @@ -376,7 +377,7 @@ namespace oomph std::ofstream elefile; char elename[100]; - sprintf(elename, "file_%s.1.ele", s.c_str()); + snprintf(elename, sizeof(elename), "file_%s.1.ele", s.c_str()); elefile.open(elename); elefile << triangle.numberoftriangles << " 3 0" << std::endl; for (int j = 0; j < triangle.numberoftriangles * 3; j += 3) diff --git a/src/meshes/quad_from_triangle_mesh.h b/src/meshes/quad_from_triangle_mesh.h index a5fff937eb5e..9d0762b0d55c 100644 --- a/src/meshes/quad_from_triangle_mesh.h +++ b/src/meshes/quad_from_triangle_mesh.h @@ -468,7 +468,10 @@ namespace oomph // Convert the Input string in *char required by the triangulate function char triswitches[100]; - sprintf(triswitches, "%s", input_string_stream.str().c_str()); + snprintf(triswitches, + sizeof(triswitches), + "%s", + input_string_stream.str().c_str()); // Build the mesh using triangulate function triangulate(triswitches, &triangulate_io, &triangulate_out, 0); diff --git a/src/meshes/refineable_tetgen_mesh.h b/src/meshes/refineable_tetgen_mesh.h index 03b836c7ceb7..7178a5593c76 100644 --- a/src/meshes/refineable_tetgen_mesh.h +++ b/src/meshes/refineable_tetgen_mesh.h @@ -130,7 +130,10 @@ namespace oomph // Convert to a *char char tetswitches[100]; - sprintf(tetswitches, "%s", input_string_stream.str().c_str()); + snprintf(tetswitches, + sizeof(tetswitches), + "%s", + input_string_stream.str().c_str()); // Build triangulateio refined object tetrahedralize(tetswitches, tetgen_input_pt, this->Tetgenio_pt); diff --git a/src/meshes/refineable_tetgen_mesh.tpp b/src/meshes/refineable_tetgen_mesh.tpp index d77888c721dc..68e9f743575c 100644 --- a/src/meshes/refineable_tetgen_mesh.tpp +++ b/src/meshes/refineable_tetgen_mesh.tpp @@ -781,7 +781,7 @@ namespace oomph std::ofstream target_sizes_file; char filename[100]; - sprintf(filename, "target_sizes%i.dat", iter); + snprintf(filename, sizeof(filename), "target_sizes%i.dat", iter); if (output_target_sizes) { target_sizes_file.open(filename); diff --git a/src/meshes/tetgen_mesh.h b/src/meshes/tetgen_mesh.h index 1626e5baf732..7dcc2b4f23e3 100644 --- a/src/meshes/tetgen_mesh.h +++ b/src/meshes/tetgen_mesh.h @@ -368,7 +368,8 @@ namespace oomph // Now convert to a C-style string char tetswitches[100]; - sprintf(tetswitches, "%s", input_string.str().c_str()); + snprintf( + tetswitches, sizeof(tetswitches), "%s", input_string.str().c_str()); // Make a new tetgen representation this->Tetgenio_exists = true; diff --git a/src/meshes/triangle_mesh.h b/src/meshes/triangle_mesh.h index 26d0a71425f9..5875b9e807e6 100644 --- a/src/meshes/triangle_mesh.h +++ b/src/meshes/triangle_mesh.h @@ -782,7 +782,10 @@ namespace oomph // Convert to a *char required by the triangulate function char triswitches[100]; - sprintf(triswitches, "%s", input_string_stream.str().c_str()); + snprintf(triswitches, + sizeof(triswitches), + "%s", + input_string_stream.str().c_str()); // Create a boolean to decide whether or not to use attributes. // The value of this will only be changed in build_triangulateio @@ -1285,7 +1288,10 @@ namespace oomph // Convert the Input string in *char required by the triangulate function char triswitches[100]; - sprintf(triswitches, "%s", input_string_stream.str().c_str()); + snprintf(triswitches, + sizeof(triswitches), + "%s", + input_string_stream.str().c_str()); // Build the mesh using triangulate function triangulate(triswitches, &triangulate_io, &Triangulateio, 0); @@ -2329,7 +2335,10 @@ namespace oomph // Convert to a *char required by the triangulate function char triswitches[100]; - sprintf(triswitches, "%s", input_string_stream.str().c_str()); + snprintf(triswitches, + sizeof(triswitches), + "%s", + input_string_stream.str().c_str()); // Build triangulateio refined object triangulate(triswitches, &triangle_refine, &this->Triangulateio, 0);