37 #include "meshes/tetgen_mesh.h"
41 using namespace oomph;
127 template<
class ELEMENT>
135 PoissonProblem(PoissonEquations<3>::PoissonSourceFctPt source_fct_pt,
136 const string& node_file_name,
137 const string& element_file_name,
138 const string& face_file_name);
148 unsigned num_bound = mesh_pt()->nboundary();
149 for(
unsigned ibound=0;ibound<num_bound;ibound++)
152 unsigned num_nod=mesh_pt()->nboundary_node(ibound);
153 for (
unsigned inod=0;inod<num_nod;inod++)
155 Node* nod_pt=mesh_pt()->boundary_node_pt(ibound,inod);
162 nod_pt->set_value(0,u);
178 void doc_solution(
const unsigned& nplot, DocInfo& doc_info);
192 template<
class ELEMENT>
194 PoissonProblem(PoissonEquations<3>::PoissonSourceFctPt source_fct_pt,
195 const string& node_file_name,
196 const string& element_file_name,
197 const string& face_file_name)
198 : Source_fct_pt(source_fct_pt)
215 unsigned num_bound =
mesh_pt()->nboundary();
216 for(
unsigned ibound=0;ibound<num_bound;ibound++)
218 unsigned num_nod=
mesh_pt()->nboundary_node(ibound);
219 for (
unsigned inod=0;inod<num_nod;inod++)
221 mesh_pt()->boundary_node_pt(ibound,inod)->pin(0);
228 unsigned n_element =
mesh_pt()->nelement();
232 for(
unsigned i=0;i<n_element;i++)
235 ELEMENT* el_pt =
dynamic_cast<ELEMENT*
>(
mesh_pt()->element_pt(i));
242 cout <<
"Number of equations: " << assign_eqn_numbers() << std::endl;
251 template<
class ELEMENT>
262 sprintf(filename,
"%s/node_numbering%i.dat",doc_info.directory().c_str(),
264 some_file.open(filename);
265 FiniteElement* el_pt=mesh_pt()->finite_element_pt(0);
266 unsigned nnode=el_pt->nnode();
267 unsigned ndim=el_pt->node_pt(0)->ndim();
268 for (
unsigned j=0;j<nnode;j++)
270 for (
unsigned i=0;i<ndim;i++)
272 some_file << el_pt->node_pt(j)->x(i) <<
" " ;
274 some_file << j << std::endl;
280 sprintf(filename,
"%s/boundaries%i.dat",doc_info.directory().c_str(),
282 some_file.open(filename);
283 mesh_pt()->output_boundaries(some_file);
289 sprintf(filename,
"%s/soln%i.dat",doc_info.directory().c_str(),
291 some_file.open(filename);
292 mesh_pt()->output(some_file,nplot);
298 sprintf(filename,
"%s/exact_soln%i.dat",doc_info.directory().c_str(),
300 some_file.open(filename);
307 sprintf(filename,
"%s/error%i.dat",doc_info.directory().c_str(),
309 some_file.open(filename);
313 cout <<
"error: " << sqrt(error) << std::endl;
314 cout <<
"norm : " << sqrt(norm) << std::endl << std::endl;
324 int main(
int argc,
char* argv[])
328 CommandLineArgs::setup(argc,argv);
333 std::string error_message =
334 "Wrong number of command line arguments.\n";
336 "Must specify the following file names \n";
338 "filename.node then filename.ele then filename.face\n";
340 throw OomphLibError(error_message,
341 OOMPH_CURRENT_FUNCTION,
342 OOMPH_EXCEPTION_LOCATION);
346 string node_file_name(argv[1]);
347 string element_file_name(argv[2]);
348 string face_file_name(argv[3]);
355 doc_info.set_directory(
"RESLT");
365 node_file_name,element_file_name,face_file_name);
368 problem.newton_solve();
394 node_file_name,element_file_name,face_file_name);
397 problem.newton_solve();
Micky mouse Poisson problem.
void actions_before_newton_solve()
Update the problem specs before solve: (Re)set boundary conditions.
void actions_after_newton_solve()
Update the problem specs before solve (empty)
void doc_solution(const unsigned &nplot, DocInfo &doc_info)
Doc the solution.
TetgenMesh< ELEMENT > * mesh_pt()
~PoissonProblem()
Destructor (empty)
PoissonEquations< 3 >::PoissonSourceFctPt Source_fct_pt
Pointer to source function.
PoissonProblem(PoissonEquations< 3 >::PoissonSourceFctPt source_fct_pt, const string &node_file_name, const string &element_file_name, const string &face_file_name)
Constructor.
Unstructured tet mesh based on output from Tetgen: http://wias-berlin.de/software/tetgen/.
int main(int argc, char *argv[])
Demonstrate how to solve Poisson problem.
Namespace for exact solution for Poisson equation with sharp step.
double N_y
Orientation (non-normalised y-component of unit vector in direction of step plane)
double Z_0
Orientation (z-coordinate of step plane)
double N_x
Orientation (non-normalised x-component of unit vector in direction of step plane)
double Y_0
Orientation (y-coordinate of step plane)
void get_source(const Vector< double > &x, double &source)
Source function to make it an exact solution.
double Alpha
Parameter for steepness of step.
double N_z
Orientation (non-normalised z-component of unit vector in direction of step plane)
void get_exact_u(const Vector< double > &x, double &u)
Exact solution as a scalar.
double X_0
Orientation (x-coordinate of step plane)
void get_exact_u(const Vector< double > &x, Vector< double > &u)
////////////////////////////////////////////////////////////////////// //////////////////////////////...