37 #include "meshes/triangle_mesh.h"
41 using namespace oomph;
73 source = 2.0*tanh(-1.0+
Alpha*(
Beta*x[0]-x[1]))*
74 (1.0-pow(tanh(-1.0+
Alpha*(
Beta*x[0]-x[1])),2.0))*
92 template<
class ELEMENT>
101 PoissonProblem(PoissonEquations<2>::PoissonSourceFctPt source_fct_pt,
102 const string& node_file_name,
103 const string& element_file_name,
104 const string& poly_file_name);
113 unsigned num_bound = mesh_pt()->nboundary();
114 for(
unsigned ibound=0;ibound<num_bound;ibound++)
117 unsigned num_nod=mesh_pt()->nboundary_node(ibound);
118 for (
unsigned inod=0;inod<num_nod;inod++)
120 Node* nod_pt=mesh_pt()->boundary_node_pt(ibound,inod);
126 nod_pt->set_value(0,u);
137 void actions_after_adapt();
155 void doc_solution(DocInfo& doc_info);
177 template<
class ELEMENT>
179 PoissonProblem(PoissonEquations<2>::PoissonSourceFctPt source_fct_pt,
180 const string& node_file_name,
181 const string& element_file_name,
182 const string& poly_file_name)
183 : Source_fct_pt(source_fct_pt)
217 unsigned num_bound =
mesh_pt()->nboundary();
218 for(
unsigned ibound=0;ibound<num_bound;ibound++)
220 unsigned num_nod=
mesh_pt()->nboundary_node(ibound);
221 for (
unsigned inod=0;inod<num_nod;inod++)
223 mesh_pt()->boundary_node_pt(ibound,inod)->pin(0);
230 unsigned n_element =
mesh_pt()->nelement();
234 for(
unsigned i=0;i<n_element;i++)
237 ELEMENT* el_pt =
dynamic_cast<ELEMENT*
>(
mesh_pt()->element_pt(i));
244 cout <<
"Number of equations: " << assign_eqn_numbers() << std::endl;
252 template<
class ELEMENT>
262 unsigned num_bound = mesh_pt()->nboundary();
263 for(
unsigned ibound=0;ibound<num_bound;ibound++)
265 unsigned num_nod= mesh_pt()->nboundary_node(ibound);
266 for (
unsigned inod=0;inod<num_nod;inod++)
268 mesh_pt()->boundary_node_pt(ibound,inod)->pin(0);
275 unsigned n_element = mesh_pt()->nelement();
279 for(
unsigned i=0;i<n_element;i++)
282 ELEMENT* el_pt =
dynamic_cast<ELEMENT*
>(mesh_pt()->element_pt(i));
285 el_pt->source_fct_pt() = Source_fct_pt;
289 cout <<
"Number of equations: " << assign_eqn_numbers() << std::endl;
297 template<
class ELEMENT>
312 sprintf(filename,
"%s/boundaries.dat",doc_info.directory().c_str());
313 some_file.open(filename);
314 mesh_pt()->output_boundaries(some_file);
320 sprintf(filename,
"%s/soln%i.dat",doc_info.directory().c_str(),
322 some_file.open(filename);
323 mesh_pt()->output(some_file,npts);
329 sprintf(filename,
"%s/exact_soln%i.dat",doc_info.directory().c_str(),
331 some_file.open(filename);
339 sprintf(filename,
"%s/error%i.dat",doc_info.directory().c_str(),
341 some_file.open(filename);
345 cout <<
"error: " << sqrt(error) << std::endl;
346 cout <<
"norm : " << sqrt(norm) << std::endl << std::endl;
350 sprintf(filename,
"%s/norm%i.dat",doc_info.directory().c_str(),
352 some_file.open(filename);
353 double norm_soln=0.0;
354 mesh_pt()->compute_norm(norm_soln);
355 some_file << sqrt(norm_soln) << std::endl;
356 cout <<
"Norm of computed solution: " << sqrt(norm_soln) << endl;
368 int main(
int argc,
char* argv[])
371 CommandLineArgs::setup(argc,argv);
376 std::string error_message =
377 "Wrong number of command line arguments.\n";
379 "Must specify the following file names \n";
381 "filename.node then filename.ele then filename.poly\n";
383 throw OomphLibError(error_message,
384 OOMPH_CURRENT_FUNCTION,
385 OOMPH_EXCEPTION_LOCATION);
389 const unsigned max_adapt = 3;
393 string node_file_name(argv[1]);
394 string element_file_name(argv[2]);
395 string poly_file_name(argv[3]);
401 doc_info.set_directory(
"RESLT");
407 cout << std::endl <<
"Cubic elements" << std::endl;
408 cout <<
"==============" << std::endl << std::endl;
417 problem.newton_solve();
431 cout << std::endl <<
"Quadratic elements" << std::endl;
432 cout <<
"===================" << std::endl << std::endl;
450 problem.newton_solve(max_adapt);
453 problem.newton_solve();
468 cout << std::endl <<
"Linear elements" << std::endl;
469 cout <<
"===============" << std::endl << std::endl;
487 problem.newton_solve(max_adapt);
490 problem.newton_solve();
Micky mouse Poisson problem.
PoissonEquations< 2 >::PoissonSourceFctPt Source_fct_pt
Pointer to source function.
void actions_before_newton_solve()
Update the problem specs before solve: (Re)set boundary conditions.
RefineableTriangleMesh< ELEMENT > * Bulk_mesh_pt
Pointer to the bulk mesh.
Z2ErrorEstimator * error_estimator_pt
Error estimator.
void actions_after_newton_solve()
Update the problem specs before solve (empty)
PoissonProblem(PoissonEquations< 2 >::PoissonSourceFctPt source_fct_pt, const string &node_file_name, const string &element_file_name, const string &poly_file_name)
Constructor: Pass pointer to source function and names of two triangle input files.
void doc_solution(DocInfo &doc_info)
Doc the solution.
RefineableTriangleMesh< ELEMENT > * mesh_pt()
Access function for the specific mesh.
~PoissonProblem()
Destructor (empty)
TriangleMesh< ELEMENT > * mesh_pt()
Access function for the specific mesh.
void actions_after_adapt()
Actions performed after the adaptation steps.
/////////////////////////////////////////////////////////////////// /////////////////////////////////...
///////////////////////////////////////////////////////////////////// ///////////////////////////////...
int main(int argc, char *argv[])
Demonstrate how to solve Poisson problem.
Namespace for exact solution for Poisson equation with sharp step.
double Beta
Parameter for angle of step.
void get_source(const Vector< double > &x, double &source)
Source function to make it an exact solution.
double Alpha
Parameter for steepness of step.
void get_exact_u(const Vector< double > &x, double &u)
Exact solution as a scalar.
void get_exact_u(const Vector< double > &x, Vector< double > &u)
Exact solution as a Vector.
////////////////////////////////////////////////////////////////////// //////////////////////////////...