39 #include "meshes/simple_rectangular_quadmesh.h" 48 using namespace oomph;
55 template<
class ELEMENT>
57 public virtual SimpleRectangularQuadMesh<ELEMENT>,
58 public RefineableQuadMesh<ELEMENT>
68 const double &Lx,
const double &Ly,
69 TimeStepper* time_stepper_pt=
70 &Mesh::Default_TimeStepper) :
71 SimpleRectangularQuadMesh<ELEMENT>(Nx,Ny,Lx,Ly,time_stepper_pt)
77 this->setup_quadtree_forest();
104 u[0]=tanh(1.0-Alpha*(TanPhi*x[0]-x[1]));
110 source = 2.0*tanh(-1.0+Alpha*(TanPhi*x[0]-x[1]))*
111 (1.0-pow(tanh(-1.0+Alpha*(TanPhi*x[0]-x[1])),2.0))*
112 Alpha*Alpha*TanPhi*TanPhi+2.0*tanh(-1.0+Alpha*(TanPhi*x[0]-x[1]))*
113 (1.0-pow(tanh(-1.0+Alpha*(TanPhi*x[0]-x[1])),2.0))*Alpha*Alpha;
130 template<
class ELEMENT>
145 void actions_before_newton_solve();
152 void doc_solution(DocInfo& doc_info);
176 template<
class ELEMENT>
180 : Source_fct_pt(source_fct_pt)
202 mesh_pt()->spatial_error_estimator_pt()=
new Z2ErrorEstimator;
207 unsigned num_bound =
mesh_pt()->nboundary();
208 for(
unsigned ibound=0;ibound<num_bound;ibound++)
210 unsigned num_nod=
mesh_pt()->nboundary_node(ibound);
211 for (
unsigned inod=0;inod<num_nod;inod++)
213 mesh_pt()->boundary_node_pt(ibound,inod)->pin(0);
222 unsigned n_element =
mesh_pt()->nelement();
223 for(
unsigned i=0;i<n_element;i++)
226 ELEMENT *el_pt =
dynamic_cast<ELEMENT*
>(
mesh_pt()->element_pt(i));
233 cout <<
"Number of equations: " << assign_eqn_numbers() << std::endl;
244 template<
class ELEMENT>
248 unsigned num_bound =
mesh_pt()->nboundary();
251 for(
unsigned ibound=0;ibound<num_bound;ibound++)
254 unsigned num_nod=
mesh_pt()->nboundary_node(ibound);
257 for (
unsigned inod=0;inod<num_nod;inod++)
260 Node* nod_pt=
mesh_pt()->boundary_node_pt(ibound,inod);
272 nod_pt->set_value(0,u[0]);
282 template<
class ELEMENT>
294 sprintf(filename,
"%s/soln%i.dat",doc_info.directory().c_str(),
296 some_file.open(filename);
297 mesh_pt()->output(some_file,npts);
303 sprintf(filename,
"%s/exact_soln%i.dat",doc_info.directory().c_str(),
305 some_file.open(filename);
312 sprintf(filename,
"%s/error%i.dat",doc_info.directory().c_str(),
314 some_file.open(filename);
320 cout <<
"\nNorm of error : " << sqrt(error) << std::endl;
321 cout <<
"Norm of solution: " << sqrt(norm) << std::endl << std::endl;
349 doc_info.set_directory(
"RESLT");
356 cout <<
"\n\n\nProblem self-test ";
357 if (problem.self_test()==0)
359 cout <<
"passed: Problem can be solved." << std::endl;
363 throw OomphLibError(
"Self test failed",
364 OOMPH_CURRENT_FUNCTION,
365 OOMPH_EXCEPTION_LOCATION);
376 problem.newton_solve(4);
SimpleRefineableRectangularQuadMesh< ELEMENT > * mesh_pt()
Overloaded version of the Problem's access function to the mesh. Recasts the pointer to the base Mesh...
int main()
Driver code for 2D Poisson problem.
void actions_after_newton_solve()
Update the problem after solve (empty)
void get_exact_u(const Vector< double > &x, Vector< double > &u)
Exact solution as a Vector.
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...
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...
double Alpha
Parameter for steepness of "step".
~RefineablePoissonProblem()
Destructor (empty)
double TanPhi
Parameter for angle Phi of "step".
void actions_before_newton_solve()
Update the problem specs before solve: Reset boundary conditions to the values from the exact solutio...
Namespace for exact solution for Poisson equation with "sharp step".
void get_source(const Vector< double > &x, double &source)
Source function required to make the solution above an exact solution.
RefineablePoissonProblem(PoissonEquations< 2 >::PoissonSourceFctPt source_fct_pt)
Constructor: Pass pointer to source function.