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

Classes

class  OneDPoissonProblem< ELEMENT >
 1D Poisson problem in unit interval. More...
 

Namespaces

 FishSolnOneDPoisson
 Namespace for fish-shaped solution of 1D Poisson equation.
 

Functions

void FishSolnOneDPoisson::get_exact_u (const Vector< double > &x, Vector< double > &u)
 Exact, fish-shaped solution as a 1D vector. More...
 
void FishSolnOneDPoisson::source_function (const Vector< double > &x, double &source)
 Source function required to make the fish shape an exact solution. More...
 
int main ()
 Driver for 1D Poisson problem. More...
 

Function Documentation

◆ main()

int main ( )

Driver for 1D Poisson problem.

///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////

258 {
259 
260  // Set up the problem:
261  // Solve a 1D Poisson problem using a source function that generates
262  // a fish shaped exact solution
263  unsigned n_element=40; //Number of elements
264  OneDPoissonProblem<QPoissonElement<1,4> > //Element type as template parameter
266 
267  // Check whether the problem can be solved
268  cout << "\n\n\nProblem self-test ";
269  if (problem.self_test()==0)
270  {
271  cout << "passed: Problem can be solved." << std::endl;
272  }
273  else
274  {
275  throw OomphLibError("failed!",
277  }
278 
279  // Set the sign of the source function:
280  cout << "\n\n\nSolving with negative sign:\n" << std::endl;
282 
283  // Solve the problem with this Sign
284  problem.newton_solve();
285 
286  //Output solution for this case (label output files with "0")
287  problem.doc_solution(0);
288 
289 
290  // Change the sign of the source function:
291  cout << "\n\n\nSolving with positive sign:\n" << std::endl;
293 
294  // Re-solve the problem with this Sign (boundary conditions get
295  // updated automatically when Problem::actions_before_newton_solve() is
296  // called.
297  problem.newton_solve();
298 
299  //Output solution for this case (label output files with "1")
300  problem.doc_solution(1);
301 
302 } // end of main
1D Poisson problem in unit interval.
Definition: linear_solvers/direct_solver_test.cc:81
Definition: oomph_definitions.h:222
int Sign
Definition: linear_solvers/direct_solver_test.cc:52
void source_function(const Vector< double > &x, double &source)
Source function required to make the fish shape an exact solution.
Definition: linear_solvers/direct_solver_test.cc:63
#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 OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, problem, FishSolnOneDPoisson::Sign, and FishSolnOneDPoisson::source_function().