35 #include "meshes/simple_rectangular_quadmesh.h"
44 using namespace oomph;
51 template<
class ELEMENT>
53 public virtual SimpleRectangularQuadMesh<ELEMENT>,
54 public RefineableQuadMesh<ELEMENT>
64 const double &Lx,
const double &Ly,
65 TimeStepper* time_stepper_pt=
66 &Mesh::Default_TimeStepper) :
67 SimpleRectangularQuadMesh<ELEMENT>(Nx,Ny,Lx,Ly,time_stepper_pt)
73 this->setup_quadtree_forest();
107 (1.0-pow(tanh(-1.0+
Alpha*(
TanPhi*x[0]-x[1])),2.0))*
126 template<
class ELEMENT>
141 void actions_before_newton_solve();
148 void doc_solution(DocInfo& doc_info);
172 template<
class ELEMENT>
176 : Source_fct_pt(source_fct_pt)
198 mesh_pt()->spatial_error_estimator_pt()=
new Z2ErrorEstimator;
203 unsigned num_bound =
mesh_pt()->nboundary();
204 for(
unsigned ibound=0;ibound<num_bound;ibound++)
206 unsigned num_nod=
mesh_pt()->nboundary_node(ibound);
207 for (
unsigned inod=0;inod<num_nod;inod++)
209 mesh_pt()->boundary_node_pt(ibound,inod)->pin(0);
218 unsigned n_element =
mesh_pt()->nelement();
219 for(
unsigned i=0;i<n_element;i++)
222 ELEMENT *el_pt =
dynamic_cast<ELEMENT*
>(
mesh_pt()->element_pt(i));
229 cout <<
"Number of equations: " << assign_eqn_numbers() << std::endl;
240 template<
class ELEMENT>
244 unsigned num_bound = mesh_pt()->nboundary();
247 for(
unsigned ibound=0;ibound<num_bound;ibound++)
250 unsigned num_nod=mesh_pt()->nboundary_node(ibound);
253 for (
unsigned inod=0;inod<num_nod;inod++)
256 Node* nod_pt=mesh_pt()->boundary_node_pt(ibound,inod);
268 nod_pt->set_value(0,u[0]);
278 template<
class ELEMENT>
290 sprintf(filename,
"%s/soln%i.dat",doc_info.directory().c_str(),
292 some_file.open(filename);
293 mesh_pt()->output(some_file,npts);
299 sprintf(filename,
"%s/exact_soln%i.dat",doc_info.directory().c_str(),
301 some_file.open(filename);
308 sprintf(filename,
"%s/error%i.dat",doc_info.directory().c_str(),
310 some_file.open(filename);
316 cout <<
"\nNorm of error : " << sqrt(error) << std::endl;
317 cout <<
"Norm of solution: " << sqrt(norm) << std::endl << std::endl;
345 doc_info.set_directory(
"RESLT");
352 cout <<
"\n\n\nProblem self-test ";
353 if (problem.self_test()==0)
355 cout <<
"passed: Problem can be solved." << std::endl;
359 throw OomphLibError(
"Self test failed",
360 OOMPH_CURRENT_FUNCTION,
361 OOMPH_EXCEPTION_LOCATION);
372 problem.newton_solve(4);
2D Poisson problem on rectangular domain, discretised with refineable 2D QPoisson elements....
RefineablePoissonProblem(PoissonEquations< 2 >::PoissonSourceFctPt source_fct_pt)
Constructor: Pass pointer to source function.
~RefineablePoissonProblem()
Destructor (empty)
void actions_before_newton_solve()
Update the problem specs before solve: Reset boundary conditions to the values from the exact solutio...
void doc_solution(DocInfo &doc_info)
Doc the solution. DocInfo object stores flags/labels for where the output gets written to.
PoissonEquations< 2 >::PoissonSourceFctPt Source_fct_pt
Pointer to source function.
void actions_after_newton_solve()
Update the problem after solve (empty)
SimpleRefineableRectangularQuadMesh< ELEMENT > * mesh_pt()
Overloaded version of the Problem's access function to the mesh. Recasts the pointer to the base Mesh...
Refineable equivalent of the SimpleRectangularQuadMesh. Refinement is performed by the QuadTree-based...
virtual ~SimpleRefineableRectangularQuadMesh()
Destructor: Empty.
SimpleRefineableRectangularQuadMesh(const unsigned &Nx, const unsigned &Ny, const double &Lx, const double &Ly, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Pass number of elements in the horizontal and vertical directions, and the corresponding dimensions....
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.