# include # include # include "ppc_truss.h" # include "ppc_truss_io.h" # include "ppc_truss_to_eps.h" int main ( ); void timestamp ( ); /******************************************************************************/ int main ( ) /******************************************************************************/ /* Purpose: ppc_truss_test() tests ppc_truss(). Discussion: The program expects a truss file available as standard input. Licensing: This code is distributed under the MIT license. Modified: 12 June 2024 Author: Original C version by Rouben Rostamian. This version by John Burkardt. Reference: Rouben Rostamian, Programming Projects in C for Students of Engineering, Science, and Mathematics, SIAM, 2014, ISBN: 978-1-611973-49-5 */ { double h = 0.1; int maxevals = 50000; int result; double tol = 1.0e-03; struct truss *truss; timestamp ( ); printf ( "\n" ); printf ( "ppc_truss_test():\n" ); printf ( " ppc_truss() simulates a truss structure under stress.\n" ); /* Read the input file. */ printf ( " Read truss description file from standard input.\n" ); truss = read_truss ( stdin ); if ( truss == NULL ) { printf ( " Failure attempting to read truss description file.\n" ); return EXIT_FAILURE; } /* Plot the unloaded configuration. */ printf ( " Plot the unloaded configuration.\n" ); ppc_truss_to_eps ( truss, "initial.eps", TR_PLOT_WITH_LABELS ); /* Solve for the loaded configuration. */ printf ( " Solve for the loaded configuration.\n" ); result = solve_truss ( truss, h, tol, maxevals ); if ( ! result ) { printf ( " Failure solving for the loaded configuration.\n" ); free ( truss ); return EXIT_FAILURE; } /* Write the loaded configuration to a TDF. */ printf ( " Write the loaded configuration to a file.\n" ); write_truss ( truss, "cantilever_loaded.tdf" ); /* Plot the loaded configuration. */ printf ( " Plot the loaded configuration.\n" ); ppc_truss_to_eps ( truss, "final.eps", TR_PLOT_WITH_NO_LABELS ); /* Free memory. */ free_truss ( truss ); /* Terminate. */ printf ( "\n" ); printf ( "ppc_truss_test():\n" ); printf ( " Normal end of execution.\n" ); timestamp ( ); return EXIT_SUCCESS; } /******************************************************************************/ void timestamp ( ) /******************************************************************************/ /* Purpose: timestamp() prints the current YMDHMS date as a time stamp. Example: 17 June 2014 09:45:54 AM Licensing: This code is distributed under the MIT license. Modified: 01 May 2021 Author: John Burkardt */ { # define TIME_SIZE 40 static char time_buffer[TIME_SIZE]; const struct tm *tm; time_t now; now = time ( NULL ); tm = localtime ( &now ); strftime ( time_buffer, TIME_SIZE, "%d %B %Y %I:%M:%S %p", tm ); printf ( "%s\n", time_buffer ); return; # undef TIME_SIZE }