one_d_poisson_hp_adapt.cc File Reference
#include "generic.h"
#include "poisson.h"
#include "meshes/one_d_mesh.h"

Classes

class  ModalPoissonEquations< DIM >
 
class  RefineableModalPoissonEquations< DIM >
 Refineable version of Poisson equations. More...
 
class  ModalPRefineableQElement< DIM >
 
class  ModalPRefineableQPoissonElement< DIM >
 
class  PRefineableOneDPoissonProblem< ELEMENT >
 

Namespaces

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

Functions

void ArcTanSolnForPoisson::get_exact_u (const Vector< double > &x, Vector< double > &u)
 Exact solution as a Vector. More...
 
void ArcTanSolnForPoisson::get_exact_gradient (const Vector< double > &x, Vector< double > &dudx)
 Exact gradient as a Vector. More...
 
void ArcTanSolnForPoisson::get_source (const Vector< double > &x, double &source)
 Source function required to make the solution above an exact solution. More...
 
int main ()
 Driver code for 1D Poisson problem. More...
 

Function Documentation

◆ main()

int main ( )

Driver code for 1D Poisson problem.

1972 {
1973  // Create label for output
1974  // -----------------------
1975  DocInfo doc_info;
1976 
1977  // Set output directory
1978  doc_info.set_directory("RESLT");
1979 
1980  // Step number
1981  doc_info.number()=0;
1982 
1983  // Choose a large value for the steepness of the "step"
1985 
1986 
1987  cout << "\n====================================\nNodal elements:\n" << endl;
1988 
1989  //Set up the problem
1990  //------------------
1991 
1992  // Create the problem with 1D three-node refineable elements from the
1993  // PRefineableQPoissonElement<1> family. Pass pointer to source function.
1995  nodal_problem(&ArcTanSolnForPoisson::get_source);
1996 
1997  // Check if we're ready to go:
1998  // ---------------------------
1999  cout << "\n\n\nProblem self-test ";
2000  if (nodal_problem.self_test()==0)
2001  {
2002  cout << "passed: Problem can be solved." << std::endl;
2003  }
2004  else
2005  {
2006  throw OomphLibError("Self test failed",
2009  }
2010 
2011  // Refine problem uniformly 2 times
2012  for(unsigned i=0;i<2;i++)
2013  {
2014  cout << "p_refining:" << endl;
2015  nodal_problem.p_refine_uniformly();
2016  }
2017  for(unsigned i=0;i<2;i++)
2018  {
2019  cout << "h_refining:" << endl;
2020  nodal_problem.refine_uniformly();
2021  }
2022 
2023  doc_info.number()=2;
2024  nodal_problem.newton_solve();
2025  nodal_problem.doc_solution(doc_info);
2026 
2027  nodal_problem.adapt();
2028  doc_info.number()=3;
2029  nodal_problem.newton_solve();
2030  nodal_problem.doc_solution(doc_info);
2031 
2032  nodal_problem.p_adapt();
2033  doc_info.number()=4;
2034  nodal_problem.newton_solve();
2035  nodal_problem.doc_solution(doc_info);
2036 
2037  nodal_problem.adapt();
2038  doc_info.number()=5;
2039  nodal_problem.newton_solve();
2040  nodal_problem.doc_solution(doc_info);
2041 
2042  nodal_problem.p_adapt();
2043  doc_info.number()=6;
2044  nodal_problem.newton_solve();
2045  nodal_problem.doc_solution(doc_info);
2046 
2047  nodal_problem.adapt();
2048  doc_info.number()=7;
2049  nodal_problem.newton_solve();
2050  nodal_problem.doc_solution(doc_info);
2051 
2052  nodal_problem.p_adapt();
2053  doc_info.number()=8;
2054  nodal_problem.newton_solve();
2055  nodal_problem.doc_solution(doc_info);
2056 
2057  doc_info.number()=0;
2058  nodal_problem.doc_solution(doc_info);
2059 
2060  cout << "\n====================================\nModal elements:\n" << endl;
2061 
2062  //Set up the problem
2063  //------------------
2064 
2065  // Create the problem with 1D three-node refineable elements from the
2066  // RefineableLinePoissonElement family. Pass pointer to source function.
2068  modal_problem(&ArcTanSolnForPoisson::get_source);
2069 
2070  // Check if we're ready to go:
2071  // ---------------------------
2072  cout << "\n\n\nProblem self-test ";
2073  if (modal_problem.self_test()==0)
2074  {
2075  cout << "passed: Problem can be solved." << std::endl;
2076  }
2077  else
2078  {
2079  throw OomphLibError("Self test failed",
2082  }
2083 
2084  // Refine problem uniformly 2 times
2085  for(unsigned i=0;i<2;i++)
2086  {
2087  cout << "p_refining:" << endl;
2088  modal_problem.p_refine_uniformly();
2089  }
2090  for(unsigned i=0;i<2;i++)
2091  {
2092  cout << "h_refining:" << endl;
2093  modal_problem.refine_uniformly();
2094  }
2095 
2096  doc_info.number()=2;
2097  modal_problem.newton_solve();
2098  modal_problem.doc_solution(doc_info);
2099 
2100  modal_problem.adapt();
2101  doc_info.number()=3;
2102  modal_problem.newton_solve();
2103  modal_problem.doc_solution(doc_info);
2104 
2105  modal_problem.p_adapt();
2106  doc_info.number()=4;
2107  modal_problem.newton_solve();
2108  modal_problem.doc_solution(doc_info);
2109 
2110  modal_problem.adapt();
2111  doc_info.number()=5;
2112  modal_problem.newton_solve();
2113  modal_problem.doc_solution(doc_info);
2114 
2115  modal_problem.p_adapt();
2116  doc_info.number()=6;
2117  modal_problem.newton_solve();
2118  modal_problem.doc_solution(doc_info);
2119 
2120  modal_problem.adapt();
2121  doc_info.number()=7;
2122  modal_problem.newton_solve();
2123  modal_problem.doc_solution(doc_info);
2124 
2125  modal_problem.p_adapt();
2126  doc_info.number()=8;
2127  modal_problem.newton_solve();
2128  modal_problem.doc_solution(doc_info);
2129 
2130  doc_info.number()=1;
2131  modal_problem.doc_solution(doc_info);
2132 
2133 } // End of main
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Definition: one_d_poisson_hp_adapt.cc:1777
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 Alpha
Parameter for steepness of "step".
Definition: one_d_poisson_adapt.cc:51
void get_source(const Vector< double > &x, double &source)
Source function required to make the solution above an exact solution.
Definition: one_d_poisson_adapt.cc:60
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61
#define OOMPH_CURRENT_FUNCTION
Definition: oomph_definitions.h:86

References oomph::Problem::adapt(), ArcTanSolnForPoisson::Alpha, PRefineableOneDPoissonProblem< ELEMENT >::doc_solution(), ArcTanSolnForPoisson::get_source(), i, oomph::Problem::newton_solve(), oomph::DocInfo::number(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, oomph::Problem::p_adapt(), oomph::Problem::p_refine_uniformly(), oomph::Problem::refine_uniformly(), oomph::Problem::self_test(), and oomph::DocInfo::set_directory().