optimisation/linear_vs_nonlinear/two_d_poisson.cc File Reference
#include "generic.h"
#include "poisson.h"
#include "meshes/simple_rectangular_quadmesh.h"

Classes

class  PoissonProblem< ELEMENT >
 Micky mouse Poisson problem. More...
 

Namespaces

 TanhSolnForPoisson
 Namespace for exact solution for Poisson equation with "sharp step".
 

Functions

void TanhSolnForPoisson::get_exact_u (const Vector< double > &x, Vector< double > &u)
 Exact solution as a Vector. More...
 
void TanhSolnForPoisson::source_function (const Vector< double > &x, double &source)
 Source function required to make the solution above an exact solution. More...
 
int main (int argc, char *argv[])
 Driver code for 2D Poisson problem. More...
 

Function Documentation

◆ main()

int main ( int argc  ,
char argv[] 
)

Driver code for 2D Poisson problem.

331 {
332 
333 
334  // Number of uniform refinements relative to a 2x2 base mesh
335  unsigned n_refine;
336 
337  // Get number of refinement levels from command line or use default
338  if (argc==1)
339  {
340  n_refine=5;
341  }
342  else if (argc==2)
343  {
344  n_refine=atoi(argv[1]);
345  }
346  else
347  {
348  std::string error_message =
349  "Wrong number of input arguments. The options are: \n";
350  error_message +=
351  "No args: Default number of refinements\n";
352  error_message +=
353  "One arg: Required number of refinements\n";
354 
355  throw OomphLibError(error_message,
358  }
359 
360  //Set up the problem
361  //------------------
362 
363  // Initialise timers
364  clock_t t_start = clock();
365 
366  // Create the problem with 2D nine-node elements from the
367  // QPoissonElement family. Pass pointer to source function
368  // and number of refinements required
371 
372  // Finish/doc timing
373  clock_t t_end = clock();
374  double total_time=double(t_end-t_start)/CLOCKS_PER_SEC;
375  cout << std::endl;
376  cout << "======================================================= " << std::endl;
377  cout << "Total time for Problem setup [sec]: " << total_time << std::endl;
378  cout << "======================================================= " << std::endl;
379  cout << std::endl;
380 
381  // Create label for output
382  //------------------------
383  DocInfo doc_info;
384 
385  // Set output directory
386  doc_info.set_directory("RESLT");
387 
388  // Step number
389  doc_info.number()=0;
390 
391 
392  // Set the orientation of the "step" to 45 degrees
394 
395  // Initial value for the steepness of the "step"
397 
398 
399  // Solve as linear and nonlinear problem
400  //--------------------------------------
401  problem.set_problem_is_nonlinear();
402 
403  unsigned nstep=2;
404  for (unsigned istep=0;istep<nstep;istep++)
405  {
406 
407  // Initialise timers
408  clock_t t_start = clock();
409 
410  if (problem.is_problem_nonlinear())
411  {
412  cout << std::endl << std::endl;
413  cout << "============================ " << std::endl;
414  cout << "Solving as nonlinear problem " << std::endl;
415  cout << "============================ " << std::endl;
416  cout << std::endl << std::endl;
417  }
418  else
419  {
420  cout << std::endl << std::endl;
421  cout << "============================ " << std::endl;
422  cout << "Solving as linear problem " << std::endl;
423  cout << "============================ " << std::endl;
424  cout << std::endl << std::endl;
425  }
426 
427 
428  // Solve the problem
429  problem.newton_solve();
430 
431  // Finish/doc timing
432  clock_t t_end = clock();
433  double total_time=double(t_end-t_start)/CLOCKS_PER_SEC;
434  cout << "======================================================= " << std::endl;
435  cout << "Total time for Newton solve [sec]: " << total_time << std::endl;
436  cout << "======================================================= " << std::endl;
437 
438  //Output the solution
439  problem.doc_solution(doc_info);
440 
441  //Increment counter for solutions
442  doc_info.number()++;
443 
444  // Next time around solve as linear problem
445  problem.set_problem_is_linear();
446 
447  }
448 
449 
450  // Give user a chance to check the memory usage
451  cout << std::endl << std::endl;
452  cout << "Execution is paused while problem is in core" << std::endl;
453  pause("Have a look at the memory usage now");
454 
455 
456 } //end of main
Micky mouse Poisson problem.
Definition: HypreSolver_test.cc:81
Definition: oomph_utilities.h:499
void set_directory(const std::string &directory)
Definition: oomph_utilities.cc:298
unsigned & number()
Number used (e.g.) for labeling output files.
Definition: oomph_utilities.h:554
Definition: oomph_definitions.h:222
double TanPhi
Parameter for angle Phi of "step".
Definition: HypreSolver_test.cc:51
void source_function(const Vector< double > &x, double &source)
Source function required to make the solution above an exact solution.
Definition: HypreSolver_test.cc:60
double Alpha
Parameter for steepness of step.
Definition: extrude_with_macro_element_representation.cc:185
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286
void pause(std::string message)
Pause and display message.
Definition: oomph_utilities.cc:1265
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61
#define OOMPH_CURRENT_FUNCTION
Definition: oomph_definitions.h:86
Constructor for SteadyAxisymAdvectionDiffusion problem
Definition: steady_axisym_advection_diffusion.cc:213

References TanhSolnForPoisson::Alpha, oomph::DocInfo::number(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, oomph::pause(), problem, oomph::DocInfo::set_directory(), TanhSolnForPoisson::source_function(), oomph::Global_string_for_annotation::string(), and TanhSolnForPoisson::TanPhi.