36 #include "meshes/simple_rectangular_quadmesh.h"
40 using namespace oomph;
74 double N[2] = {1.0, 0.0};
89 template<
class ELEMENT>
103 void doc_solution(DocInfo& doc_info);
110 void actions_before_newton_solve();
118 void create_flux_elements(
const unsigned &b, Mesh*
const &bulk_mesh_pt,
119 Mesh*
const &surface_mesh_pt);
138 template<
class ELEMENT>
141 : Source_fct_pt(source_fct_pt)
158 Bulk_mesh_pt=
new SimpleRectangularQuadMesh<ELEMENT>(n_x,n_y,l_x,l_y);
184 for(
unsigned b=0;b<n_bound;b++)
190 for (
unsigned n=0;n<n_node;n++)
203 for(
unsigned e=0;e<n_element;e++)
206 ELEMENT *el_pt =
dynamic_cast<ELEMENT*
>(
Bulk_mesh_pt->element_pt(e));
214 for(
unsigned e=0;e<n_element;e++)
217 PoissonFluxElement<ELEMENT> *el_pt =
218 dynamic_cast< PoissonFluxElement<ELEMENT>*
>(
222 el_pt->flux_fct_pt() =
227 cout <<
"Number of equations: " << assign_eqn_numbers() << std::endl;
238 template<
class ELEMENT>
242 unsigned n_bound = Bulk_mesh_pt->nboundary();
245 for(
unsigned i=0;i<n_bound;i++)
251 unsigned n_node = Bulk_mesh_pt->nboundary_node(i);
254 for (
unsigned n=0;n<n_node;n++)
257 Node* nod_pt=Bulk_mesh_pt->boundary_node_pt(i,n);
269 nod_pt->set_value(0,u[0]);
280 template<
class ELEMENT>
293 sprintf(filename,
"%s/soln%i.dat",doc_info.directory().c_str(),
295 some_file.open(filename);
296 Bulk_mesh_pt->output(some_file,npts);
301 sprintf(filename,
"%s/exact_soln%i.dat",doc_info.directory().c_str(),
303 some_file.open(filename);
311 sprintf(filename,
"%s/error%i.dat",doc_info.directory().c_str(),
313 some_file.open(filename);
319 cout <<
"\nNorm of error : " << sqrt(error) << std::endl;
320 cout <<
"Norm of solution: " << sqrt(norm) << std::endl << std::endl;
331 template<
class ELEMENT>
334 Mesh*
const &surface_mesh_pt)
337 unsigned n_element = bulk_mesh_pt->nboundary_element(b);
340 for(
unsigned e=0;e<n_element;e++)
343 ELEMENT* bulk_elem_pt =
dynamic_cast<ELEMENT*
>(
344 bulk_mesh_pt->boundary_element_pt(b,e));
347 int face_index = bulk_mesh_pt->face_index_at_boundary(b,e);
350 PoissonFluxElement<ELEMENT>* flux_element_pt =
new
351 PoissonFluxElement<ELEMENT>(bulk_elem_pt,face_index);
354 surface_mesh_pt->add_element_pt(flux_element_pt);
382 doc_info.set_directory(
"RESLT");
391 cout <<
"\n\n\nProblem self-test ";
392 if (problem.self_test()==0)
394 cout <<
"passed: Problem can be solved." << std::endl;
398 throw OomphLibError(
"Self test failed",
399 OOMPH_CURRENT_FUNCTION,
400 OOMPH_EXCEPTION_LOCATION);
413 for (
unsigned istep=0;istep<nstep;istep++)
418 cout <<
"\n\nSolving for TanhSolnForPoisson::Alpha="
422 problem.newton_solve();
2D Poisson problem on rectangular domain, discretised with 2D QPoisson elements. Flux boundary condit...
~TwoMeshFluxPoissonProblem()
Destructor (empty)
void actions_before_newton_solve()
Update the problem specs before solve: Reset boundary conditions to the values from the exact solutio...
PoissonEquations< 2 >::PoissonSourceFctPt Source_fct_pt
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.
void create_flux_elements(const unsigned &b, Mesh *const &bulk_mesh_pt, Mesh *const &surface_mesh_pt)
Create Poisson flux elements on boundary b of the Mesh pointed to by bulk_mesh_pt and add them to the...
Mesh * Surface_mesh_pt
Pointer to the "surface" mesh.
void actions_after_newton_solve()
Update the problem specs after solve (empty)
SimpleRectangularQuadMesh< ELEMENT > * Bulk_mesh_pt
Pointer to the "bulk" mesh.
TwoMeshFluxPoissonProblem(PoissonEquations< 2 >::PoissonSourceFctPt source_fct_pt)
Constructor: Pass pointer to source function.
Namespace for exact solution for Poisson equation with "sharp step".
void prescribed_flux_on_fixed_x_boundary(const Vector< double > &x, double &flux)
Flux required by the exact solution on a boundary on which x is fixed.
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()
Demonstrate how to solve 2D Poisson problem with flux boundary conditions, using two meshes.