# include # include # include # include # include # include # include using namespace std; # include "wedge_grid.hpp" int main ( ); void test01 ( ); void test02 ( ); void timestamp ( ); //****************************************************************************80 int main ( ) //****************************************************************************80 // // Purpose: // // wedge_grid_test() tests wedge_grid(). // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 22 August 2014 // // Author: // // John Burkardt // { timestamp ( ); cout << "\n"; cout << "WEDGE_GRID_TEST():\n"; cout << " C++ version\n"; cout << " Test WEDGE_GRID().\n"; test01 ( ); test02 ( ); // // Terminate. // cout << "\n"; cout << "WEDGE_GRID_TEST():\n"; cout << " Normal end of execution.\n"; cout << "\n"; timestamp ( ); return 0; } //****************************************************************************80 void test01 ( ) //****************************************************************************80 // // Purpose: // // TEST01 tests WEDGE_GRID. // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 22 August 2014 // // Author: // // John Burkardt // { double *g; int j; int n = 5; int ng; string output_filename; ofstream output_unit; cout << "\n"; cout << "TEST01\n"; cout << " WEDGE_GRID can define a grid of points\n"; cout << " with N+1 points on a side\n"; cout << " over the interior of the unit wedge in 3D.\n"; cout << "\n"; cout << " Grid order N = " << n << "\n"; ng = wedge_grid_size ( n ); cout << " Grid count NG = " << ng << "\n"; g = wedge_grid ( n, ng ); cout << "\n"; cout << " J X Y Z\n"; cout << "\n"; for ( j = 0; j < ng; j++ ) { cout << setw(6) << j << " " << setw(14) << g[0+j*3] << " " << setw(14) << g[1+j*3] << " " << setw(14) << g[2+j*3] << "\n"; } output_filename = "wedge_grid.xy"; output_unit.open ( output_filename.c_str ( ) ); for ( j = 0; j < ng; j++ ) { output_unit << g[0+j*3] << " " << g[1+j*3] << " " << g[2+j*3] << "\n"; } output_unit.close ( ); cout << "\n"; cout << " Data written to '" << output_filename << "'\n"; delete [] g; return; } //****************************************************************************80 void test02 ( ) //****************************************************************************80 // // Purpose: // // TEST02 tests WEDGE_GRID_PLOT. // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 22 August 2014 // // Author: // // John Burkardt // { double *g; string header; int n = 5; int ng; cout << "\n"; cout << "TEST02\n"; cout << " WEDGE_GRID_PLOT can create GNUPLOT data files\n"; cout << " for displaying a wedge grid.\n"; cout << "\n"; cout << " Grid order N = " << n << "\n"; ng = wedge_grid_size ( n ); cout << " Grid count NG = " << ng << "\n"; g = wedge_grid ( n, ng ); header = "wedge"; wedge_grid_plot ( n, ng, g, header ); delete [] g; return; } //****************************************************************************80 void timestamp ( ) //****************************************************************************80 // // Purpose: // // TIMESTAMP prints the current YMDHMS date as a time stamp. // // Example: // // 31 May 2001 09:45:54 AM // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 08 July 2009 // // Author: // // John Burkardt // // Parameters: // // None // { # define TIME_SIZE 40 static char time_buffer[TIME_SIZE]; const struct std::tm *tm_ptr; std::time_t now; now = std::time ( NULL ); tm_ptr = std::localtime ( &now ); std::strftime ( time_buffer, TIME_SIZE, "%d %B %Y %I:%M:%S %p", tm_ptr ); std::cout << time_buffer << "\n"; return; # undef TIME_SIZE }