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x+N_y*N_y+N_z*
111 N_z))),2.0))*Alpha*Alpha*N_y*N_y/(N_x*N_x+N_y*N_y+N_z*N_z);
112 s4 = -2.0*tanh(Alpha*((x[0]-X_0)*N_x/sqrt(N_x*N_x+N_y*N_y+N_z*N_z)+(x[1]-
113 Y_0)*N_y/sqrt(N_x*N_x+N_y*N_y+N_z*N_z)+(x[2]-Z_0)*N_z/sqrt(N_x*N_x+N_y*N_y+N_z*
114 N_z)))*(1.0-pow(tanh(Alpha*((x[0]-X_0)*N_x/sqrt(N_x*N_x+N_y*N_y+N_z*N_z)+(x[1]-
115 Y_0)*N_y/sqrt(N_x*N_x+N_y*N_y+N_z*N_z)+(x[2]-Z_0)*N_z/sqrt(N_x*N_x+N_y*N_y+N_z*
116 N_z))),2.0))*Alpha*Alpha*N_z*N_z/(N_x*N_x+N_y*N_y+N_z*N_z);
131 template<
class ELEMENT>
139 PoissonProblem(PoissonEquations<3>::PoissonSourceFctPt source_fct_pt,
140 const string& node_file_name,
141 const string& element_file_name,
142 const string& face_file_name);
152 unsigned num_bound = mesh_pt()->nboundary();
153 for(
unsigned ibound=0;ibound<num_bound;ibound++)
156 unsigned num_nod=mesh_pt()->nboundary_node(ibound);
157 for (
unsigned inod=0;inod<num_nod;inod++)
159 Node* nod_pt=mesh_pt()->boundary_node_pt(ibound,inod);
166 nod_pt->set_value(0,u);
182 void doc_solution(
const unsigned& nplot, DocInfo& doc_info);
196 template<
class ELEMENT>
199 const string& node_file_name,
200 const string& element_file_name,
201 const string& face_file_name)
202 : Source_fct_pt(source_fct_pt)
219 unsigned num_bound =
mesh_pt()->nboundary();
220 for(
unsigned ibound=0;ibound<num_bound;ibound++)
222 unsigned num_nod=
mesh_pt()->nboundary_node(ibound);
223 for (
unsigned inod=0;inod<num_nod;inod++)
225 mesh_pt()->boundary_node_pt(ibound,inod)->pin(0);
232 unsigned n_element =
mesh_pt()->nelement();
236 for(
unsigned i=0;i<n_element;i++)
239 ELEMENT* el_pt =
dynamic_cast<ELEMENT*
>(
mesh_pt()->element_pt(i));
246 cout <<
"Number of equations: " << assign_eqn_numbers() << std::endl;
255 template<
class ELEMENT>
266 sprintf(filename,
"%s/node_numbering%i.dat",doc_info.directory().c_str(),
268 some_file.open(filename);
269 FiniteElement* el_pt=
mesh_pt()->finite_element_pt(0);
270 unsigned nnode=el_pt->nnode();
271 unsigned ndim=el_pt->node_pt(0)->ndim();
272 for (
unsigned j=0;j<nnode;j++)
274 for (
unsigned i=0;i<ndim;i++)
276 some_file << el_pt->node_pt(j)->x(i) <<
" " ;
278 some_file << j << std::endl;
284 sprintf(filename,
"%s/boundaries%i.dat",doc_info.directory().c_str(),
286 some_file.open(filename);
287 mesh_pt()->output_boundaries(some_file);
293 sprintf(filename,
"%s/soln%i.dat",doc_info.directory().c_str(),
295 some_file.open(filename);
296 mesh_pt()->output(some_file,nplot);
302 sprintf(filename,
"%s/exact_soln%i.dat",doc_info.directory().c_str(),
304 some_file.open(filename);
311 sprintf(filename,
"%s/error%i.dat",doc_info.directory().c_str(),
313 some_file.open(filename);
317 cout <<
"error: " << sqrt(error) << std::endl;
318 cout <<
"norm : " << sqrt(norm) << std::endl << std::endl;
328 int main(
int argc,
char* argv[])
332 CommandLineArgs::setup(argc,argv);
337 std::string error_message =
338 "Wrong number of command line arguments.\n";
340 "Must specify the following file names \n";
342 "filename.node then filename.ele then filename.face\n";
344 throw OomphLibError(error_message,
345 OOMPH_CURRENT_FUNCTION,
346 OOMPH_EXCEPTION_LOCATION);
350 string node_file_name(argv[1]);
351 string element_file_name(argv[2]);
352 string face_file_name(argv[3]);
359 doc_info.set_directory(
"RESLT");
369 node_file_name,element_file_name,face_file_name);
372 problem.newton_solve();
398 node_file_name,element_file_name,face_file_name);
401 problem.newton_solve();
double N_x
Orientation (non-normalised x-component of unit vector in direction of step plane) ...
TetgenMesh< ELEMENT > * mesh_pt()
double X_0
Orientation (x-coordinate of step plane)
~PoissonProblem()
Destructor (empty)
Driver for a 3D navier stokes flow with tetgen.
void actions_after_newton_solve()
Update the problem specs before solve (empty)
void get_exact_u(const Vector< double > &x, Vector< double > &u)
double Z_0
Orientation (z-coordinate of step plane)
double Alpha
Parameter for steepness of step.
Unstructured tet mesh based on output from Tetgen: http://wias-berlin.de/software/tetgen/.
void actions_before_newton_solve()
Update the problem specs before solve: (Re)set boundary conditions.
PoissonEquations< 3 >::PoissonSourceFctPt Source_fct_pt
Pointer to source function.
double Y_0
Orientation (y-coordinate of step plane)
double N_y
Orientation (non-normalised y-component of unit vector in direction of step plane) ...
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 N_z
Orientation (non-normalised z-component of unit vector in direction of step plane) ...
void doc_solution(const unsigned &nplot, DocInfo &doc_info)
Doc the solution.
Micky mouse Poisson problem.
PoissonProblem(PoissonEquations< 3 >::PoissonSourceFctPt source_fct_pt, const string &node_file_name, const string &element_file_name, const string &face_file_name)
Constructor.
void get_source(const Vector< double > &x, double &source)
Source function to make it an exact solution.
int main(int argc, char *argv[])
Demonstrate how to solve Poisson problem.