two_d_poisson_stored_shape_fcts.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.

360 {
361  // Number of uniform refinements relative to a 2x2 base mesh
362  unsigned n_refine;
363 
364  // Get number of refinement levels from command line or use default
365  if (argc==1)
366  {
367  n_refine=6; //5
368  }
369  else if (argc==2)
370  {
371  n_refine=atoi(argv[1]);
372  }
373  else
374  {
375  std::string error_message =
376  "Wrong number of input arguments. The options are: \n";
377  error_message +=
378  "No args: Default number of refinements\n";
379  error_message +=
380  "One arg: Required number of refinements\n";
381 
382  throw OomphLibError(error_message,
385  }
386 
387 
388  cout << sizeof(Shape) << std::endl;
389  cout << sizeof(DShape) << std::endl;
390  // Create label for output
391  //------------------------
392  DocInfo doc_info;
393 
394  // Set output directory
395  doc_info.set_directory("RESLT");
396 
397  // Step number
398  doc_info.number()=0;
399 
400 
401  // Set the orientation of the "step" to 45 degrees
403 
404  // Initial value for the steepness of the "step"
406 
407 
408 
409 
410  //Set up the problem with normal Poisson elements
411  //-----------------------------------------------
412  {
413  // Initialise timers
414  clock_t t_start = clock();
415 
416  // Create the problem with 2D nine-node elements from the
417  // QPoissonElement family. Pass pointer to source function
418  // and number of refinements required
421 
422  // Finish/doc timing
423  clock_t t_end = clock();
424  double total_time=double(t_end-t_start)/CLOCKS_PER_SEC;
425  cout << std::endl;
426  cout << "======================================================= " << std::endl;
427  cout << "Total time for Problem setup [sec]: " << total_time << std::endl;
428  cout << "======================================================= " << std::endl;
429  cout << std::endl;
430 
431  // Run problem
432  problem.run_it(doc_info);
433  }
434 
435 
436 
437  //Set up the problem with Poisson elements with storable shape fcts
438  //-----------------------------------------------------------------
439  {
440  // Initialise timers
441  clock_t t_start = clock();
442 
444  // Create the problem with 2D nine-node elements from the
445  // QPoissonElement family. Pass pointer to source function
446  // and number of refinements required
449 
450  // Finish/doc timing
451  clock_t t_end = clock();
452  double total_time=double(t_end-t_start)/CLOCKS_PER_SEC;
453  cout << std::endl;
454  cout << "================================================================= "
455  << std::endl;
456  cout << "Total time for Problem setup with storable shape fcts [sec]: "
457  << total_time << std::endl;
458  cout << "================================================================= "
459  << std::endl;
460  cout << std::endl;
461 
462  // Run problem with nothing stored (the default)
463  //----------------------------------------------
464  cout << "================================================================= "
465  << std::endl;
466  cout << "No shape functions actually stored "
467  << std::endl;
468  cout << "================================================================= "
469  << std::endl << std::endl;
470  problem.run_it(doc_info);
471 
472 
473 
474  // Store the derivatives w.r.t. to the Eulerian coordinates
475  //-------------------------------------------------------------
476  // Initialise timers
477  t_start = clock();
478  unsigned nelem=problem.mesh_pt()->nelement();
479  for (unsigned e=0;e<nelem;e++)
480  {
481  dynamic_cast<ELEMENT*>(problem.mesh_pt()->element_pt(e))
482  ->pre_compute_dshape_eulerian_at_knots();
483  }
484 
485  // Finish/doc timing
486  t_end = clock();
487  total_time=double(t_end-t_start)/CLOCKS_PER_SEC;
488  cout << std::endl;
489  cout << "================================================================= "
490  << std::endl;
491  cout << "Total time for pre-calculation of shape functions and derivatives "
492  << std::endl;
493  cout << total_time << " sec" << std::endl;
494  cout << "================================================================= "
495  << std::endl;
496  cout << std::endl;
497  //Now run the problem
498  problem.run_it(doc_info);
499 
500  // Set them all to refer to the first elements
501  //-------------------------------------------------------------
502  // Initialise timers
503  t_start = clock();
504  for (unsigned e=1;e<nelem;e++)
505  {
506  dynamic_cast<ELEMENT*>(problem.mesh_pt()->element_pt(e))
507  ->set_dshape_eulerian_stored_from_element(
508  dynamic_cast<ELEMENT*>(problem.mesh_pt()->element_pt(0)));
509  }
510  // Finish/doc timing
511  t_end = clock();
512  total_time=double(t_end-t_start)/CLOCKS_PER_SEC;
513  cout << std::endl;
514  cout << "================================================================= "
515  << std::endl;
516  cout << "Total time for assignment of shape functions and derivatives from "
517  << std::endl << "the first element: " << total_time << " sec" << std::endl;
518  cout << "================================================================= "
519  << std::endl;
520  cout << std::endl;
521 
522  problem.run_it(doc_info);
523  }
524 
525 
526 } //end of main
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Micky mouse Poisson problem.
Definition: HypreSolver_test.cc:81
Definition: shape.h:278
Definition: oomph_utilities.h:499
void set_directory(const std::string &directory)
Definition: oomph_utilities.cc:298
Definition: oomph_definitions.h:222
Definition: shape.h:76
Definition: stored_shape_function_elements.h:556
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
#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, e(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, problem, oomph::DocInfo::set_directory(), TanhSolnForPoisson::source_function(), oomph::Global_string_for_annotation::string(), and TanhSolnForPoisson::TanPhi.