two_d_poisson_tanh_flux_bc_validate.cc File Reference
#include "generic.h"
#include "poisson.h"
#include "meshes/rectangular_quadmesh.h"

Classes

class  FluxPoissonMGProblem< ELEMENT, MESH >
 

Namespaces

 Global_Parameters
 Namespace for global parameters.
 
 Smoother_Factory_Function_Helper
 Returns a pointer to a smoother of the appropriate type.
 
 SolnForPoisson
 Namespace for exact solution for Poisson equation.
 

Functions

HelmholtzSmootherSmoother_Factory_Function_Helper::set_pre_smoother ()
 
HelmholtzSmootherSmoother_Factory_Function_Helper::set_post_smoother ()
 
void SolnForPoisson::get_exact_u (const Vector< double > &x, Vector< double > &u)
 Exact solution as a Vector. More...
 
void SolnForPoisson::source_function (const Vector< double > &x, double &source)
 Source function required to make the solution above an exact solution. More...
 
void SolnForPoisson::prescribed_flux_on_fixed_x_boundary (const Vector< double > &x, double &flux)
 Flux required by the exact solution on a boundary on which x is fixed. More...
 
int main (int argc, char **argv)
 

Variables

unsigned Global_Parameters::Nnode_1d =2
 The number of nodes in one direction (default=2) More...
 
unsigned Global_Parameters::Min_refinement_level =2
 The minimum level of uniform refinement. More...
 
unsigned Global_Parameters::Add_refinement_level =1
 The additional levels of uniform refinement. More...
 
unsigned Global_Parameters::N_adaptations =1
 The number of adaptations allowed by the Newton solver. More...
 
unsigned Global_Parameters::Use_adaptation_flag =0
 
unsigned Global_Parameters::Pre_smoother_flag =0
 
unsigned Global_Parameters::Post_smoother_flag =0
 
unsigned Global_Parameters::Linear_solver_flag =1
 
unsigned Global_Parameters::Output_management_flag =0
 
unsigned Global_Parameters::Doc_convergence_flag =0
 
DocInfo Global_Parameters::Doc_info
 DocInfo object used for documentation of the solution. More...
 
double SolnForPoisson::Alpha =4.0
 Parameter for steepness of "step". More...
 
double SolnForPoisson::TanPhi =1.0
 Parameter for angle Phi of "step". More...
 

Function Documentation

◆ main()

int main ( int argc  ,
char **  argv 
)

Demonstrate how to solve 2D Poisson problem with flux boundary conditions

682 {
683  //------------------------
684  // Command line arguments
685  //------------------------
686  // Store command line arguments
687  CommandLineArgs::setup(argc,argv);
688 
689  // Choose the number of nodes in one direction of an element;
690  // Values of nnode_1d:
691  // 2: Bilinear interpolation
692  // 3: Biquadratic interpolation
693  // 4: Bicubic interpolation
695  "--nnode_1d",&Global_Parameters::Nnode_1d);
696 
697  // Choose the minimum level of uniform refinement
700 
701  // Choose the additional levels of uniform refinement
704 
705  // Choose the maximum number of adaptive refinements
707  "--n_adapt",&Global_Parameters::N_adaptations);
708 
709  // Choose how many additional levels of uniform refinement to use
712 
713  // Choose the pre-smoother
715  "--presmoother",&Global_Parameters::Pre_smoother_flag);
716 
717  // Choose the post-smoother
719  "--postsmoother",&Global_Parameters::Post_smoother_flag);
720 
721  // Choose the linear solver
723  "--linear_solver",&Global_Parameters::Linear_solver_flag);
724 
725  // Decide whether or not to suppress all or some of the MG solver output
728 
729  // Decide whether or not to display convergence information
732 
733  // Parse command line
735 
736  // Document what has been specified on the command line
738 
739  //--------------------------------
740  // Set the documentation directory
741  //--------------------------------
742  // Set output directory
744 
745  //--------------------
746  // Set up the problem
747  //--------------------
748  // Initialise a null pointer to the class Problem
749  Problem* problem_pt=0;
750 
751  // Set the problem pointer depending on the input (defaulted to nnode_1d=2)
753  {
754  // Using linear interpolation
755  typedef RefineableQPoissonElement<2,2> ELEMENT;
756 
757  // Typedef the mesh and template it by the chosen element type
759 
760  // Set the problem pointer
763  }
764  else if (Global_Parameters::Nnode_1d==3)
765  {
766  // Using quadratic interpolation
767  typedef RefineableQPoissonElement<2,3> ELEMENT;
768 
769  // Typedef the mesh and template it by the chosen element type
771 
772  // Set the problem pointer
775  }
776  else if (Global_Parameters::Nnode_1d==4)
777  {
778  // Using cubic interpolation
779  typedef RefineableQPoissonElement<2,4> ELEMENT;
780 
781  // Typedef the mesh and template it by the chosen element type
783 
784  // Set the problem pointer
787  }
788  else
789  {
790  // Throw an error otherwise
791  throw OomphLibError("nnode_1d can only be 2,3 or 4.",
794  }
795 
796  //-------------------
797  // Solve the problem!
798  //-------------------
799  // If the user wishes to use adaptive refinement then we use the
800  // Newton solver with a given argument to indicate how many
801  // adaptations can be done
803  {
804  // If the user did not choose to suppress everything
806  {
807  oomph_info << "\n====================Initial Refinement===================="
808  << std::endl;
809 
810 #ifndef PARANOID
811  // If PARANOID isn't enabled we need an extra line
812  oomph_info << std::endl;
813 #endif
814  }
815 
816  // Refine once at least otherwise the V-cycle only uses SuperLU and converges
817  // instantly
818  problem_pt->refine_uniformly();
819 
820  // Solve the problem
821  problem_pt->newton_solve();
822 
823  // Keep refining until the minimum refinement level is reached
824  for (unsigned i=0;i<Global_Parameters::N_adaptations;i++)
825  {
826  // Adapt the problem
827  problem_pt->adapt();
828 
829  // Solve the problem
830  problem_pt->newton_solve();
831  }
832  }
833  // If the user instead wishes to use uniform refinement
834  else
835  {
836  // Keep refining until the minimum refinement level is reached
837  for (unsigned i=0;i<Global_Parameters::Min_refinement_level;i++)
838  {
839  // If the user did not choose to suppress everything
841  {
842  oomph_info << "\n====================Initial Refinement====================\n"
843  << std::endl;
844  }
845 
846  // Add additional refinement
847  problem_pt->refine_uniformly();
848  }
849 
850  // Solve the problem
851  problem_pt->newton_solve();
852 
853  // Refine and solve until the additional refinements have been completed
854  for (unsigned i=0;i<Global_Parameters::Add_refinement_level;i++)
855  {
856  // If the user did not choose to suppress everything
858  {
859  oomph_info << "===================Additional Refinement==================\n"
860  << std::endl;
861  }
862 
863  // Add additional refinement
864  problem_pt->refine_uniformly();
865 
866  // Solve the problem
867  problem_pt->newton_solve();
868  }
869  } // if (Global_Parameters::Use_adaptation_flag)
870 
871  // Delete the problem pointer
872  delete problem_pt;
873 
874  // Make it a null pointer
875  problem_pt=0;
876 } // End of main
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Definition: two_d_poisson_tanh_flux_bc.cc:115
void set_directory(const std::string &directory)
Definition: oomph_utilities.cc:298
Definition: oomph_definitions.h:222
Definition: problem.h:151
void refine_uniformly(const Vector< unsigned > &nrefine_for_mesh)
Definition: problem.h:2575
void newton_solve()
Use Newton method to solve the problem.
Definition: problem.cc:8783
void adapt(unsigned &n_refined, unsigned &n_unrefined)
Definition: problem.cc:13666
Definition: refineable_poisson_elements.h:193
Definition: rectangular_quadmesh.template.h:326
void setup(Time *time_pt)
Create all GeomObjects needed to define the cylinder and the flag.
Definition: turek_flag_non_fsi.cc:277
unsigned Output_management_flag
Definition: two_d_poisson_tanh_flux_bc_validate.cc:88
unsigned Add_refinement_level
The additional levels of uniform refinement.
Definition: two_d_poisson_tanh_flux_bc_validate.cc:56
unsigned Post_smoother_flag
Definition: two_d_poisson_tanh_flux_bc_validate.cc:74
unsigned Use_adaptation_flag
Definition: two_d_poisson_tanh_flux_bc_validate.cc:64
DocInfo Doc_info
DocInfo object used for documentation of the solution.
Definition: two_d_poisson_tanh_flux_bc_validate.cc:97
unsigned N_adaptations
The number of adaptations allowed by the Newton solver.
Definition: two_d_poisson_tanh_flux_bc_validate.cc:59
unsigned Nnode_1d
The number of nodes in one direction (default=2)
Definition: two_d_poisson_tanh_flux_bc_validate.cc:50
unsigned Pre_smoother_flag
Definition: two_d_poisson_tanh_flux_bc_validate.cc:69
unsigned Linear_solver_flag
Definition: two_d_poisson_tanh_flux_bc_validate.cc:79
unsigned Doc_convergence_flag
Definition: two_d_poisson_tanh_flux_bc_validate.cc:94
unsigned Min_refinement_level
The minimum level of uniform refinement.
Definition: two_d_poisson_tanh_flux_bc_validate.cc:53
void source_function(const Vector< double > &x, double &source)
Source function required to make the solution above an exact solution.
Definition: two_d_poisson_tanh_flux_bc_validate.cc:186
void specify_command_line_flag(const std::string &command_line_flag, const std::string &doc)
Specify possible argument-free command line flag.
Definition: oomph_utilities.cc:451
void parse_and_assign(int argc, char *argv[], const bool &throw_on_unrecognised_args)
Definition: oomph_utilities.cc:760
void doc_specified_flags()
Document specified command line flags.
Definition: oomph_utilities.cc:610
OomphInfo oomph_info
Definition: oomph_definitions.cc:319
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61
#define OOMPH_CURRENT_FUNCTION
Definition: oomph_definitions.h:86

References oomph::Problem::adapt(), Global_Parameters::Add_refinement_level, Global_Parameters::Doc_convergence_flag, Global_Parameters::Doc_info, oomph::CommandLineArgs::doc_specified_flags(), i, Global_Parameters::Linear_solver_flag, Global_Parameters::Min_refinement_level, Global_Parameters::N_adaptations, oomph::Problem::newton_solve(), Global_Parameters::Nnode_1d, OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, oomph::oomph_info, Global_Parameters::Output_management_flag, oomph::CommandLineArgs::parse_and_assign(), Global_Parameters::Post_smoother_flag, Global_Parameters::Pre_smoother_flag, oomph::Problem::refine_uniformly(), oomph::DocInfo::set_directory(), Flag_definition::setup(), SolnForPoisson::source_function(), oomph::CommandLineArgs::specify_command_line_flag(), and Global_Parameters::Use_adaptation_flag.