39 #include "meshes/simple_rectangular_quadmesh.h" 43 using namespace oomph;
61 u[0]=tanh(1.0-Alpha*(TanPhi*x[0]-x[1]));
67 source = 2.0*tanh(-1.0+Alpha*(TanPhi*x[0]-x[1]))*
68 (1.0-pow(tanh(-1.0+Alpha*(TanPhi*x[0]-x[1])),2.0))*
69 Alpha*Alpha*TanPhi*TanPhi+2.0*tanh(-1.0+Alpha*(TanPhi*x[0]-x[1]))*
70 (1.0-pow(tanh(-1.0+Alpha*(TanPhi*x[0]-x[1])),2.0))*Alpha*Alpha;
87 template<
class ELEMENT>
94 PoissonProblem(PoissonEquations<2>::PoissonSourceFctPt source_fct_pt);
101 void actions_before_newton_solve();
108 void doc_solution(DocInfo& doc_info);
123 template<
class ELEMENT>
126 : Source_fct_pt(source_fct_pt)
143 Problem::mesh_pt() =
new SimpleRectangularQuadMesh<ELEMENT>(n_x,n_y,l_x,l_y);
148 unsigned n_bound = mesh_pt()->nboundary();
149 for(
unsigned i=0;i<n_bound;i++)
151 unsigned n_node = mesh_pt()->nboundary_node(i);
152 for (
unsigned n=0;n<n_node;n++)
154 mesh_pt()->boundary_node_pt(i,n)->pin(0);
163 unsigned n_element = mesh_pt()->nelement();
164 for(
unsigned i=0;i<n_element;i++)
167 ELEMENT *el_pt =
dynamic_cast<ELEMENT*
>(mesh_pt()->element_pt(i));
175 cout <<
"Number of equations: " << assign_eqn_numbers() << std::endl;
186 template<
class ELEMENT>
190 unsigned n_bound = mesh_pt()->nboundary();
193 for(
unsigned i=0;i<n_bound;i++)
196 unsigned n_node = mesh_pt()->nboundary_node(i);
199 for (
unsigned n=0;n<n_node;n++)
202 Node* nod_pt=mesh_pt()->boundary_node_pt(i,n);
214 nod_pt->set_value(0,u[0]);
224 template<
class ELEMENT>
236 sprintf(filename,
"%s/soln%i.dat",doc_info.directory().c_str(),
238 some_file.open(filename);
239 mesh_pt()->output(some_file,npts);
245 sprintf(filename,
"%s/exact_soln%i.dat",doc_info.directory().c_str(),
247 some_file.open(filename);
254 sprintf(filename,
"%s/error%i.dat",doc_info.directory().c_str(),
256 some_file.open(filename);
262 cout <<
"\nNorm of error : " << sqrt(error) << std::endl;
263 cout <<
"Norm of solution: " << sqrt(norm) << std::endl << std::endl;
291 doc_info.set_directory(
"RESLT");
298 cout <<
"\n\n\nProblem self-test ";
299 if (problem.self_test()==0)
301 cout <<
"passed: Problem can be solved." << std::endl;
305 throw OomphLibError(
"Self test failed",
306 OOMPH_CURRENT_FUNCTION,
307 OOMPH_EXCEPTION_LOCATION);
321 for (
unsigned istep=0;istep<nstep;istep++)
327 cout <<
"\n\nSolving for TanhSolnForPoisson::Alpha=" 331 problem.newton_solve();
PoissonEquations< 2 >::PoissonSourceFctPt Source_fct_pt
Pointer to source function.
~PoissonProblem()
Destructor (empty)
void actions_after_newton_solve()
Update the problem after solve (empty)
void doc_solution(DocInfo &doc_info)
Doc the solution. DocInfo object stores flags/labels for where the output gets written to...
void get_exact_u(const Vector< double > &x, Vector< double > &u)
Exact solution as a Vector.
double Alpha
Parameter for steepness of "step".
void actions_before_newton_solve()
Update the problem specs before solve: Reset boundary conditions to the values from the exact solutio...
int main()
Driver code for 2D Poisson problem.
void source_function(const Vector< double > &x, double &source)
Source function required to make the solution above an exact solution.
double TanPhi
Parameter for angle Phi of "step".
Namespace for exact solution for Poisson equation with "sharp step".
PoissonProblem(PoissonEquations< 2 >::PoissonSourceFctPt source_fct_pt)
Constructor: Pass pointer to source function.