38 #include "meshes/simple_rectangular_quadmesh.template.h"
42 using namespace oomph;
57 void get_exact_u(
const Vector<double>& x, Vector<double>& u)
85 template<
class ELEMENT>
111 PoissonEquations<2>::PoissonSourceFctPt Source_fct_pt;
121 template<
class ELEMENT>
123 PoissonProblem(PoissonEquations<2>::PoissonSourceFctPt source_fct_pt)
124 : Source_fct_pt(source_fct_pt)
142 Problem::mesh_pt() =
new SimpleRectangularQuadMesh<ELEMENT>(n_x,n_y,l_x,l_y);
147 unsigned num_bound = mesh_pt()->nboundary();
148 for(
unsigned ibound=0;ibound<num_bound;ibound++)
150 unsigned num_nod= mesh_pt()->nboundary_node(ibound);
151 for (
unsigned inod=0;inod<num_nod;inod++)
153 mesh_pt()->boundary_node_pt(ibound,inod)->pin(0);
162 unsigned n_element = mesh_pt()->nelement();
163 for(
unsigned i=0;i<n_element;i++)
166 ELEMENT *el_pt =
dynamic_cast<ELEMENT*
>(mesh_pt()->element_pt(i));
174 cout <<
"Number of equations: " << assign_eqn_numbers() << std::endl;
185 template<
class ELEMENT>
189 unsigned num_bound = mesh_pt()->nboundary();
192 for(
unsigned ibound=0;ibound<num_bound;ibound++)
195 unsigned num_nod=mesh_pt()->nboundary_node(ibound);
198 for (
unsigned inod=0;inod<num_nod;inod++)
201 Node* nod_pt=mesh_pt()->boundary_node_pt(ibound,inod);
213 nod_pt->set_value(0,u[0]);
223 template<
class ELEMENT>
235 sprintf(filename,
"%s/soln%i.dat",doc_info.directory().c_str(),
237 some_file.open(filename);
238 mesh_pt()->output(some_file,npts);
244 sprintf(filename,
"%s/exact_soln%i.dat",doc_info.directory().c_str(),
246 some_file.open(filename);
253 sprintf(filename,
"%s/error%i.dat",doc_info.directory().c_str(),
255 some_file.open(filename);
261 cout <<
"\nNorm of error : " << sqrt(error) << std::endl;
262 cout <<
"Norm of solution: " << sqrt(norm) << std::endl << std::endl;
290 doc_info.set_directory(
"RESLT");
297 cout <<
"\n\n\nProblem self-test ";
298 if (problem.self_test()==0)
300 cout <<
"passed: Problem can be solved." << std::endl;
304 throw OomphLibError(
"Self test failed",
305 OOMPH_CURRENT_FUNCTION,
306 OOMPH_EXCEPTION_LOCATION);
320 for (
unsigned istep=0;istep<nstep;istep++)
326 cout <<
"\n\nSolving for TanhSolnForPoisson::Alpha="
330 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 get_source(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.