42 #include "meshes/geompack_mesh.h" 47 using namespace oomph;
65 u[0]=tanh(1.0-Alpha*(Beta*x[0]-x[1]));
72 u=tanh(1.0-Alpha*(Beta*x[0]-x[1]));
79 source = 2.0*tanh(-1.0+Alpha*(Beta*x[0]-x[1]))*
80 (1.0-pow(tanh(-1.0+Alpha*(Beta*x[0]-x[1])),2.0))*
81 Alpha*Alpha*Beta*Beta+2.0*tanh(-1.0+Alpha*(Beta*x[0]-x[1]))*
82 (1.0-pow(tanh(-1.0+Alpha*(Beta*x[0]-x[1])),2.0))*Alpha*Alpha;
96 template<
class ELEMENT>
104 PoissonProblem(PoissonEquations<2>::PoissonSourceFctPt source_fct_pt,
105 const string& mesh_file_name,
106 const string& curve_file_name);
115 unsigned num_bound = mesh_pt()->nboundary();
116 for(
unsigned ibound=0;ibound<num_bound;ibound++)
119 unsigned num_nod=mesh_pt()->nboundary_node(ibound);
120 for (
unsigned inod=0;inod<num_nod;inod++)
122 Node* nod_pt=mesh_pt()->boundary_node_pt(ibound,inod);
128 nod_pt->set_value(0,u);
145 void doc_solution(DocInfo& doc_info);
159 template<
class ELEMENT>
162 const string& mesh_file_name,
163 const string& curve_file_name)
164 : Source_fct_pt(source_fct_pt)
182 unsigned num_bound =
mesh_pt()->nboundary();
183 for(
unsigned ibound=0;ibound<num_bound;ibound++)
185 unsigned num_nod=
mesh_pt()->nboundary_node(ibound);
186 for (
unsigned inod=0;inod<num_nod;inod++)
188 mesh_pt()->boundary_node_pt(ibound,inod)->pin(0);
195 unsigned n_element =
mesh_pt()->nelement();
199 for(
unsigned i=0;i<n_element;i++)
202 ELEMENT* el_pt =
dynamic_cast<ELEMENT*
>(
mesh_pt()->element_pt(i));
209 cout <<
"Number of equations: " << assign_eqn_numbers() << std::endl;
218 template<
class ELEMENT>
233 sprintf(filename,
"%s/boundaries.dat",doc_info.directory().c_str());
234 some_file.open(filename);
235 mesh_pt()->output_boundaries(some_file);
241 sprintf(filename,
"%s/soln%i.dat",doc_info.directory().c_str(),
243 some_file.open(filename);
244 mesh_pt()->output(some_file,npts);
250 sprintf(filename,
"%s/exact_soln%i.dat",doc_info.directory().c_str(),
252 some_file.open(filename);
260 sprintf(filename,
"%s/error%i.dat",doc_info.directory().c_str(),
262 some_file.open(filename);
266 cout <<
"error: " << sqrt(error) << std::endl;
267 cout <<
"norm : " << sqrt(norm) << std::endl << std::endl;
287 int main(
int argc,
char* argv[])
290 CommandLineArgs::setup(argc,argv);
295 std::string error_message =
296 "Wrong number of command line arguments.\n";
298 "Must specify the following file names \n";
300 "filename.mh2 then filename.cs2\n";
302 throw OomphLibError(error_message,
303 OOMPH_CURRENT_FUNCTION,
304 OOMPH_EXCEPTION_LOCATION);
308 string mesh_file_name(argv[1]);
309 string curve_file_name(argv[2]);
314 mesh_file_name,curve_file_name);
320 doc_info.set_directory(
"RESLT");
323 problem.newton_solve();
int main(int argc, char *argv[])
Demonstrate how to solve Poisson problem.
~PoissonProblem()
Destructor (empty)
void actions_after_newton_solve()
Update the problem specs before solve (empty)
void doc_solution(DocInfo &doc_info)
Doc the solution.
void get_exact_u(const Vector< double > &x, Vector< double > &u)
Exact solution as a Vector.
GeompackQuadMesh< ELEMENT > * mesh_pt()
double Alpha
Parameter for steepness of step.
void actions_before_newton_solve()
Update the problem specs before solve: (Re)set boundary conditions.
PoissonEquations< 2 >::PoissonSourceFctPt Source_fct_pt
Pointer to source function.
PoissonProblem(PoissonEquations< 2 >::PoissonSourceFctPt source_fct_pt, const string &mesh_file_name, const string &curve_file_name)
Constructor.
void get_exact_u(const Vector< double > &x, double &u)
Exact solution as a scalar.
Namespace for exact solution for Poisson equation with sharp step.
double Beta
Parameter for angle of step.
Micky mouse Poisson problem.
void get_source(const Vector< double > &x, double &source)
Source function to make it an exact solution.