Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Removing OStringStream from various examples:

adaptivity_ex2
adaptivity_ex3
adjoints_ex1
adjoints_ex2
adjoints_ex3
adjoints_ex4
fem_system_ex1
miscellaneous_ex4
reduced_basis_ex2
reduced_basis_ex3
systems_of_equations_ex2
systems_of_equations_ex3
transient_ex1

Issue #22.
  • Loading branch information...
commit 4b40fb3b01ac531e3c7966efb64777fa964f4229 1 parent eae4ed5
@jwpeterson jwpeterson authored
View
34 examples/adaptivity/adaptivity_ex2/adaptivity_ex2.C
@@ -50,11 +50,6 @@
#include "libmesh/getpot.h"
-// Some (older) compilers do not offer full stream
-// functionality, \p OStringStream works around this.
-// Check example 9 for details.
-#include "libmesh/o_string_stream.h"
-
// This example will solve a linear transient system,
// so we need to include the \p TransientLinearImplicitSystem definition.
#include "libmesh/transient_system.h"
@@ -333,16 +328,22 @@ int main (int argc, char** argv)
// A pretty update message
std::cout << " Solving time step ";
- // As already seen in example 9, use a work-around
- // for missing stream functionality (of older compilers).
// Add a set of scope braces to enforce data locality.
{
- OStringStream out;
+ std::ostringstream out;
+
+ out << std::setw(2)
+ << std::right
+ << t_step
+ << ", time="
+ << std::fixed
+ << std::setw(6)
+ << std::setprecision(3)
+ << std::setfill('0')
+ << std::left
+ << system.time
+ << "...";
- OSSInt(out,2,t_step);
- out << ", time=";
- OSSRealzeroleft(out,6,3,system.time);
- out << "...";
std::cout << out.str() << std::endl;
}
@@ -423,10 +424,13 @@ int main (int argc, char** argv)
// Output every 10 timesteps to file.
if ( (t_step+1)%output_freq == 0)
{
- OStringStream file_name;
+ std::ostringstream file_name;
- file_name << "out.gmv.";
- OSSRealzeroright(file_name,3,0,t_step+1);
+ file_name << "out.gmv."
+ << std::setw(3)
+ << std::setfill('0')
+ << std::right
+ << t_step+1;
GMVIO(mesh).write_equation_systems (file_name.str(),
equation_systems);
View
5 examples/adaptivity/adaptivity_ex3/adaptivity_ex3.C
@@ -62,7 +62,6 @@
#include "libmesh/hp_singular.h"
#include "libmesh/mesh_generation.h"
#include "libmesh/mesh_modification.h"
-#include "libmesh/o_string_stream.h"
#include "libmesh/perf_log.h"
#include "libmesh/getpot.h"
#include "libmesh/exact_solution.h"
@@ -257,7 +256,7 @@ int main(int argc, char** argv)
// to a ExodusII-formatted plot file.
if (output_intermediate)
{
- OStringStream outfile;
+ std::ostringstream outfile;
outfile << "lshaped_" << r_step << ".e";
ExodusII_IO (mesh).write_equation_systems (outfile.str(),
equation_systems);
@@ -350,7 +349,7 @@ int main(int argc, char** argv)
}
// Write out the error distribution
- OStringStream ss;
+ std::ostringstream ss;
ss << r_step;
#ifdef LIBMESH_HAVE_EXODUS_API
std::string error_output = "error_"+ss.str()+".e";
View
15 examples/adjoints/adjoints_ex1/adjoints_ex1.C
@@ -50,6 +50,7 @@
// C++ includes
#include <iostream>
+#include <iomanip>
// General libMesh includes
#include "libmesh/equation_systems.h"
@@ -74,10 +75,6 @@
#include "libmesh/getpot.h"
#include "libmesh/gmv_io.h"
-// Some (older) compilers do not offer full stream
-// functionality, OStringStream works around this.
-#include "libmesh/o_string_stream.h"
-
// Local includes
#include "femparameters.h"
#include "L-shaped.h"
@@ -99,9 +96,13 @@ void write_output(EquationSystems &es,
MeshBase &mesh = es.get_mesh();
#ifdef LIBMESH_HAVE_GMV
- OStringStream file_name_gmv;
- file_name_gmv << solution_type << ".out.gmv.";
- OSSRealzeroright(file_name_gmv,2,0,a_step);
+ std::ostringstream file_name_gmv;
+ file_name_gmv << solution_type
+ << ".out.gmv."
+ << std::setw(2)
+ << std::setfill('0')
+ << std::right
+ << a_step;
GMVIO(mesh).write_equation_systems
(file_name_gmv.str(), es);
View
15 examples/adjoints/adjoints_ex2/adjoints_ex2.C
@@ -55,6 +55,7 @@
// C++ includes
#include <iostream>
+#include <iomanip>
// General libMesh includes
#include "libmesh/equation_systems.h"
@@ -82,10 +83,6 @@
#include "libmesh/getpot.h"
#include "libmesh/gmv_io.h"
-// Some (older) compilers do not offer full stream
-// functionality, OStringStream works around this.
-#include "libmesh/o_string_stream.h"
-
// Local includes
#include "femparameters.h"
#include "L-shaped.h"
@@ -109,9 +106,13 @@ void write_output(EquationSystems &es,
#ifdef LIBMESH_HAVE_GMV
- OStringStream file_name_gmv;
- file_name_gmv << solution_type << ".out.gmv.";
- OSSRealzeroright(file_name_gmv,2,0,a_step);
+ std::ostringstream file_name_gmv;
+ file_name_gmv << solution_type
+ << ".out.gmv."
+ << std::setw(2)
+ << std::setfill('0')
+ << std::right
+ << a_step;
GMVIO(mesh).write_equation_systems
(file_name_gmv.str(), es);
View
101 examples/adjoints/adjoints_ex3/adjoints_ex3.C
@@ -1,6 +1,7 @@
// C++ includes
#include <iostream>
#include <sys/time.h>
+#include <iomanip>
// Libmesh includes
#include "libmesh/equation_systems.h"
@@ -38,10 +39,6 @@
#include "libmesh/qoi_set.h"
#include "libmesh/weighted_patch_recovery_error_estimator.h"
-// Some (older) compilers do not offer full stream
-// functionality, OStringStream works around this.
-#include "libmesh/o_string_stream.h"
-
// Local includes
#include "coupled_system.h"
#include "domain.h"
@@ -102,12 +99,22 @@ std::string numbered_filename(unsigned int t_step, // The timestep count
std::string extension,
FEMParameters &param)
{
- OStringStream file_name;
- file_name << solution_type << ".out." << type << '.';
- OSSRealzeroright(file_name, 3, 0, t_step);
- file_name << '.' ;
- OSSRealzeroright(file_name, 2, 0, a_step);
- file_name << '.' << extension;
+ std::ostringstream file_name;
+ file_name << solution_type
+ << ".out."
+ << type
+ << '.'
+ << std::setw(3)
+ << std::setfill('0')
+ << std::right
+ << t_step
+ << '.'
+ << std::setw(2)
+ << std::setfill('0')
+ << std::right
+ << a_step
+ << '.'
+ << extension;
if (param.output_bz2)
file_name << ".bz2";
@@ -129,11 +136,18 @@ void write_output(EquationSystems &es,
#ifdef LIBMESH_HAVE_GMV
if (param.output_gmv)
{
- OStringStream file_name_gmv;
- file_name_gmv << solution_type << ".out.gmv.";
- OSSRealzeroright(file_name_gmv,3,0,t_step);
- file_name_gmv << '.' ;
- OSSRealzeroright(file_name_gmv,2,0,a_step);
+ std::ostringstream file_name_gmv;
+ file_name_gmv << solution_type
+ << ".out.gmv."
+ << std::setw(3)
+ << std::setfill('0')
+ << std::right
+ << t_step
+ << '.'
+ << std::setw(2)
+ << std::setfill('0')
+ << std::right
+ << a_step;
GMVIO(mesh).write_equation_systems
(file_name_gmv.str(), es);
@@ -143,12 +157,19 @@ void write_output(EquationSystems &es,
#ifdef LIBMESH_HAVE_TECPLOT_API
if (param.output_tecplot)
{
- OStringStream file_name_tecplot;
- file_name_tecplot << solution_type << ".out.";
- OSSRealzeroright(file_name_tecplot,3,0,t_step);
- file_name_tecplot << '.' ;
- OSSRealzeroright(file_name_tecplot,2,0,a_step);
- file_name_tecplot << ".plt";
+ std::ostringstream file_name_tecplot;
+ file_name_tecplot << solution_type
+ << ".out."
+ << std::setw(3)
+ << std::setfill('0')
+ << std::right
+ << t_step
+ << '.'
+ << std::setw(2)
+ << std::setfill('0')
+ << std::right
+ << a_step
+ << ".plt";
TecplotIO(mesh).write_equation_systems
(file_name_tecplot.str(), es);
@@ -293,12 +314,19 @@ void write_error(EquationSystems &,
#ifdef LIBMESH_HAVE_GMV
if (param.write_gmv_error)
{
- OStringStream error_gmv;
- error_gmv << "error.gmv.";
- OSSRealzeroright(error_gmv,3,0, a_number);
- error_gmv << ".";
- OSSRealzeroright(error_gmv,2,0, t_number);
- error_gmv << error_type;
+ std::ostringstream error_gmv;
+ error_gmv << "error.gmv."
+ << std::setw(3)
+ << std::setfill('0')
+ << std::right
+ << a_number
+ << "."
+ << std::setw(2)
+ << std::setfill('0')
+ << std::right
+ << t_number
+ << error_type;
+
error.plot_error(error_gmv.str(), es.get_mesh());
}
#endif
@@ -306,12 +334,19 @@ void write_error(EquationSystems &,
#ifdef LIBMESH_HAVE_TECPLOT_API
if (param.write_tecplot_error)
{
- OStringStream error_tecplot;
- error_tecplot << "error.plt.";
- OSSRealzeroright(error_tecplot,3,0, a_number);
- error_tecplot << ".";
- OSSRealzeroright(error_tecplot,2,0, t_number);
- error_tecplot << error_type;
+ std::ostringstream error_tecplot;
+ error_tecplot << "error.plt."
+ << std::setw(3)
+ << std::setfill('0')
+ << std::right
+ << a_number
+ << "."
+ << std::setw(2)
+ << std::setfill('0')
+ << std::right
+ << t_number
+ << error_type;
+
error.plot_error(error_tecplot.str(), es.get_mesh());
}
#endif
View
15 examples/adjoints/adjoints_ex4/adjoints_ex4.C
@@ -50,6 +50,7 @@
// C++ includes
#include <iostream>
+#include <iomanip>
// General libMesh includes
#include "libmesh/equation_systems.h"
@@ -70,10 +71,6 @@
#include "libmesh/getpot.h"
#include "libmesh/gmv_io.h"
-// Some (older) compilers do not offer full stream
-// functionality, OStringStream works around this.
-#include "libmesh/o_string_stream.h"
-
// Local includes
#include "femparameters.h"
#include "L-shaped.h"
@@ -95,9 +92,13 @@ void write_output(EquationSystems &es,
MeshBase &mesh = es.get_mesh();
#ifdef LIBMESH_HAVE_GMV
- OStringStream file_name_gmv;
- file_name_gmv << solution_type << ".out.gmv.";
- OSSRealzeroright(file_name_gmv,2,0,a_step);
+ std::ostringstream file_name_gmv;
+ file_name_gmv << solution_type
+ << ".out.gmv."
+ << std::setw(2)
+ << std::setfill('0')
+ << std::right
+ << a_step;
GMVIO(mesh).write_equation_systems
(file_name_gmv.str(), es);
View
18 examples/fem_system/fem_system_ex1/fem_system_ex1.C
@@ -22,6 +22,9 @@
// example 13 can be solved using the
// DifferentiableSystem class framework
+// C++ includes
+#include <iomanip>
+
// Basic include files
#include "libmesh/equation_systems.h"
#include "libmesh/error_vector.h"
@@ -33,10 +36,6 @@
#include "libmesh/mesh_refinement.h"
#include "libmesh/uniform_refinement_estimator.h"
-// Some (older) compilers do not offer full stream
-// functionality, OStringStream works around this.
-#include "libmesh/o_string_stream.h"
-
// The systems and solvers we may use
#include "naviersystem.h"
#include "libmesh/diff_solver.h"
@@ -294,12 +293,15 @@ int main (int argc, char** argv)
// Write out this timestep if we're requested to
if ((t_step+1)%write_interval == 0)
{
- OStringStream file_name;
+ std::ostringstream file_name;
// We write the file in the ExodusII format.
- file_name << "out_";
- OSSRealzeroright(file_name,3,0, t_step + 1);
- file_name << ".e";
+ file_name << "out_"
+ << std::setw(3)
+ << std::setfill('0')
+ << std::right
+ << t_step+1
+ << ".e";
ExodusII_IO(mesh).write_timestep(file_name.str(),
equation_systems,
View
5 examples/miscellaneous/miscellaneous_ex4/miscellaneous_ex4.C
@@ -60,11 +60,6 @@
#include "libmesh/getpot.h"
-// Some (older) compilers do not offer full stream
-// functionality, \p OStringStream works around this.
-// Check example 9 for details.
-#include "libmesh/o_string_stream.h"
-
// This example will solve a linear transient system,
// so we need to include the \p TransientLinearImplicitSystem definition.
#include "libmesh/transient_system.h"
View
1  examples/reduced_basis/reduced_basis_ex2/reduced_basis_ex2.C
@@ -53,7 +53,6 @@
#include "libmesh/equation_systems.h"
#include "libmesh/dof_map.h"
#include "libmesh/getpot.h"
-#include "libmesh/o_string_stream.h"
#include "libmesh/elem.h"
// local includes
View
1  examples/reduced_basis/reduced_basis_ex3/reduced_basis_ex3.C
@@ -31,7 +31,6 @@
#include "libmesh/equation_systems.h"
#include "libmesh/dof_map.h"
#include "libmesh/getpot.h"
-#include "libmesh/o_string_stream.h"
#include "libmesh/elem.h"
// local includes
View
15 examples/systems_of_equations/systems_of_equations_ex2/systems_of_equations_ex2.C
@@ -55,10 +55,6 @@
#include "libmesh/boundary_info.h"
#include "libmesh/utility.h"
-// Some (older) compilers do not offer full stream
-// functionality, OStringStream works around this.
-#include "libmesh/o_string_stream.h"
-
// For systems of equations the \p DenseSubMatrix
// and \p DenseSubVector provide convenient ways for
// assembling the element matrix and vector on a
@@ -262,12 +258,15 @@ int main (int argc, char** argv)
#ifdef LIBMESH_HAVE_EXODUS_API
if ((t_step+1)%write_interval == 0)
{
- OStringStream file_name;
+ std::ostringstream file_name;
// We write the file in the ExodusII format.
- file_name << "out_";
- OSSRealzeroright(file_name,3,0, t_step + 1);
- file_name << ".e";
+ file_name << "out_"
+ << std::setw(3)
+ << std::setfill('0')
+ << std::right
+ << t_step + 1
+ << ".e";
ExodusII_IO(mesh).write_equation_systems (file_name.str(),
equation_systems);
View
15 examples/systems_of_equations/systems_of_equations_ex3/systems_of_equations_ex3.C
@@ -46,10 +46,6 @@
#include "libmesh/boundary_info.h"
#include "libmesh/utility.h"
-// Some (older) compilers do not offer full stream
-// functionality, OStringStream works around this.
-#include "libmesh/o_string_stream.h"
-
// For systems of equations the \p DenseSubMatrix
// and \p DenseSubVector provide convenient ways for
// assembling the element matrix and vector on a
@@ -255,12 +251,15 @@ int main (int argc, char** argv)
#ifdef LIBMESH_HAVE_EXODUS_API
if ((t_step+1)%write_interval == 0)
{
- OStringStream file_name;
+ std::ostringstream file_name;
// We write the file in the ExodusII format.
- file_name << "out_";
- OSSRealzeroright(file_name,3,0, t_step + 1);
- file_name << ".e";
+ file_name << "out_"
+ << std::setw(3)
+ << std::setfill('0')
+ << std::right
+ << t_step + 1
+ << ".e";
ExodusII_IO(mesh).write_equation_systems (file_name.str(),
equation_systems);
View
35 examples/transient/transient_ex1/transient_ex1.C
@@ -45,10 +45,6 @@
#include "libmesh/dense_matrix.h"
#include "libmesh/dense_vector.h"
-// Some (older) compilers do not offer full stream
-// functionality, OStringStream works around this.
-#include "libmesh/o_string_stream.h"
-
// This example will solve a linear transient system,
// so we need to include the \p TransientLinearImplicitSystem definition.
#include "libmesh/linear_implicit_system.h"
@@ -196,12 +192,20 @@ int main (int argc, char** argv)
// We use additional curly braces here simply to enforce data
// locality.
{
- OStringStream out;
+ std::ostringstream out;
+
+ out << std::setw(2)
+ << std::right
+ << t_step
+ << ", time="
+ << std::fixed
+ << std::setw(6)
+ << std::setprecision(3)
+ << std::setfill('0')
+ << std::left
+ << system.time
+ << "...";
- OSSInt(out,2,t_step);
- out << ", time=";
- OSSRealzeroleft(out,6,3,system.time);
- out << "...";
std::cout << out.str() << std::endl;
}
@@ -224,11 +228,14 @@ int main (int argc, char** argv)
// Output evey 10 timesteps to file.
if ( (t_step+1)%10 == 0)
{
- OStringStream file_name;
-
- file_name << "out_";
- OSSRealzeroright(file_name,3,0,t_step+1);
- file_name << ".gmv";
+ std::ostringstream file_name;
+
+ file_name << "out_"
+ << std::setw(3)
+ << std::setfill('0')
+ << std::right
+ << t_step+1
+ << ".gmv";
GMVIO(mesh).write_equation_systems (file_name.str(),
equation_systems);
Please sign in to comment.
Something went wrong with that request. Please try again.