35 #include "meshes/simple_rectangular_quadmesh.h"
39 using namespace oomph;
83 template<
class ELEMENT>
90 PoissonProblem(PoissonEquations<2>::PoissonSourceFctPt source_fct_pt);
97 void actions_before_newton_solve();
104 void doc_solution(DocInfo& doc_info);
119 template<
class ELEMENT>
121 PoissonProblem(PoissonEquations<2>::PoissonSourceFctPt source_fct_pt)
122 : Source_fct_pt(source_fct_pt)
139 Problem::mesh_pt() =
new SimpleRectangularQuadMesh<ELEMENT>(n_x,n_y,l_x,l_y);
144 unsigned n_bound = mesh_pt()->nboundary();
145 for(
unsigned i=0;i<n_bound;i++)
147 unsigned n_node = mesh_pt()->nboundary_node(i);
148 for (
unsigned n=0;n<n_node;n++)
150 mesh_pt()->boundary_node_pt(i,n)->pin(0);
159 unsigned n_element = mesh_pt()->nelement();
160 for(
unsigned i=0;i<n_element;i++)
163 ELEMENT *el_pt =
dynamic_cast<ELEMENT*
>(mesh_pt()->element_pt(i));
171 cout <<
"Number of equations: " << assign_eqn_numbers() << std::endl;
182 template<
class ELEMENT>
186 unsigned n_bound = mesh_pt()->nboundary();
189 for(
unsigned i=0;i<n_bound;i++)
192 unsigned n_node = mesh_pt()->nboundary_node(i);
195 for (
unsigned n=0;n<n_node;n++)
198 Node* nod_pt=mesh_pt()->boundary_node_pt(i,n);
210 nod_pt->set_value(0,u[0]);
220 template<
class ELEMENT>
232 sprintf(filename,
"%s/soln%i.dat",doc_info.directory().c_str(),
234 some_file.open(filename);
235 mesh_pt()->output(some_file,npts);
241 sprintf(filename,
"%s/exact_soln%i.dat",doc_info.directory().c_str(),
243 some_file.open(filename);
250 sprintf(filename,
"%s/error%i.dat",doc_info.directory().c_str(),
252 some_file.open(filename);
258 cout <<
"\nNorm of error : " << sqrt(error) << std::endl;
259 cout <<
"Norm of solution: " << sqrt(norm) << std::endl << std::endl;
287 doc_info.set_directory(
"RESLT");
294 cout <<
"\n\n\nProblem self-test ";
295 if (problem.self_test()==0)
297 cout <<
"passed: Problem can be solved." << std::endl;
301 throw OomphLibError(
"Self test failed",
302 OOMPH_CURRENT_FUNCTION,
303 OOMPH_EXCEPTION_LOCATION);
317 for (
unsigned istep=0;istep<nstep;istep++)
323 cout <<
"\n\nSolving for TanhSolnForPoisson::Alpha="
327 problem.newton_solve();
2D Poisson problem on rectangular domain, discretised with 2D QPoisson elements. The specific type of...
PoissonEquations< 2 >::PoissonSourceFctPt Source_fct_pt
Pointer to source function.
void actions_before_newton_solve()
Update the problem specs before solve: Reset boundary conditions to the values from the exact solutio...
void actions_after_newton_solve()
Update the problem after solve (empty)
PoissonProblem(PoissonEquations< 2 >::PoissonSourceFctPt source_fct_pt)
Constructor: Pass pointer to source function.
void doc_solution(DocInfo &doc_info)
Doc the solution. DocInfo object stores flags/labels for where the output gets written to.
~PoissonProblem()
Destructor (empty)
Namespace for exact solution for Poisson equation with "sharp step".
double TanPhi
Parameter for angle Phi of "step".
void source_function(const Vector< double > &x, double &source)
Source function required to make the solution above an exact solution.
double Alpha
Parameter for steepness of "step".
void get_exact_u(const Vector< double > &x, Vector< double > &u)
Exact solution as a Vector.
int main()
Driver code for 2D Poisson problem.