# include # include # include # include # include using namespace std; # include "minimal_surface_exact.hpp" int main ( ); double r8vec_norm_rms ( int n, double a[] ); void timestamp ( ); //****************************************************************************80 int main ( ) //****************************************************************************80 // // Purpose: // // minimal_surface_exact_test() tests minimal_surface_exact(). // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 02 June 2025 // // Author: // // John Burkardt // { double a; double b; double c; int i; int n = 5; double *R; long long int seed = 123456789LL; double *X; double *X1; double *Y; double *Y1; timestamp ( ); cout << "\n"; cout << "minimal_surface_exact_test():\n"; cout << " C++ version.\n"; cout << " Test minimal_surface_exact().\n"; srand48 ( seed ); X = new double[n]; X1 = new double[n]; Y = new double[n]; Y1 = new double[n]; for ( i = 0; i < n; i++ ) { X[i] = drand48 ( ); X1[i] = X[i] + 1.0; Y[i] = drand48 ( ); Y1[i] = Y[i] + 1.0; } a = 1.0; b = 2.0; c = 3.0; // // Linear solution. // cout << "\n"; cout << " Linear solution residual at random points:\n"; R = minimal_surface_linear_residual ( n, X, Y, a, b, c ); cout << " RMS residual norm = " << r8vec_norm_rms ( n, R ) << "\n"; delete [] R; // // Helicoid solution. // cout << "\n"; cout << " Helicoid solution residual at random points:\n"; R = minimal_surface_helicoid_residual ( n, X, Y ); cout << " RMS residual norm = " << r8vec_norm_rms ( n, R ) << "\n"; delete [] R; // // Catenoid solution. // cout << "\n"; cout << " Catenoid solution residual at random points:\n"; R = minimal_surface_catenoid_residual ( n, X1, Y1, a ); cout << " RMS residual norm = " << r8vec_norm_rms ( n, R ) << "\n"; delete [] R; // // Scherk solution. // cout << "\n"; cout << " Scherk solution residual at random points:\n"; R = minimal_surface_scherk_residual ( n, X, Y, a ); cout << " RMS residual norm = " << r8vec_norm_rms ( n, R ) << "\n"; delete [] R; delete [] X; delete [] X1; delete [] Y; delete [] Y1; // // Terminate. // cout << "\n"; cout << "minimal_surface_exact_test()\n"; cout << " Normal end of execution.\n"; cout << "\n"; timestamp ( ); return 0; } //****************************************************************************80 double r8vec_norm_rms ( int n, double a[] ) //****************************************************************************80 // // Purpose: // // r8vec_norm_rms() returns the RMS norm of an R8VEC. // // Discussion: // // An R8VEC is a vector of R8's. // // The vector RMS norm is defined as: // // R8VEC_RMS_NORM = sqrt ( sum ( 1 <= I <= N ) A(I)^2 / N ). // // Licensing: // // This code is distributed under the MIT license. // // Modified: // // 26 October 2011 // // Author: // // John Burkardt // // Input: // // int N, the number of entries in A. // // double A[N], the vector. // // Output: // // double R8VEC_NORM_RMS, the RMS norm of A. // { int i; double v; v = 0.0; if ( 0 < n ) { for ( i = 0; i < n; i++ ) { v = v + a[i] * a[i]; } v = sqrt ( v / ( double ) ( n ) ); } return v; } //****************************************************************************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: // // 19 March 2018 // // Author: // // John Burkardt // { # 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 }