39 #include "meshes/eighth_sphere_mesh.h"    43 using namespace oomph;
    80   u[0] = tanh(Alpha*((x[0]-X_0)*N_x/sqrt(N_x*N_x+N_y*N_y+N_z*N_z)+(x[1]-Y_0)*
    81                      N_y/sqrt(N_x*N_x+N_y*N_y+N_z*N_z)+(x[2]-Z_0)*
    82                      N_z/sqrt(N_x*N_x+N_y*N_y+N_z*N_z)));
    88   u = tanh(Alpha*((x[0]-X_0)*N_x/sqrt(N_x*N_x+N_y*N_y+N_z*N_z)+(x[1]-Y_0)*
    89                      N_y/sqrt(N_x*N_x+N_y*N_y+N_z*N_z)+(x[2]-Z_0)*
    90                      N_z/sqrt(N_x*N_x+N_y*N_y+N_z*N_z)));
   100   s1 = -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]-
   101 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*
   102 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]-
   103 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*
   104 N_z))),2.0))*Alpha*Alpha*N_x*N_x/(N_x*N_x+N_y*N_y+N_z*N_z);
   105       s3 = -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]-
   106 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*
   107 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]-
   108 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*
   109 N_z))),2.0))*Alpha*Alpha*N_y*N_y/(N_x*N_x+N_y*N_y+N_z*N_z);
   110       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]-
   111 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*
   112 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]-
   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))),2.0))*Alpha*Alpha*N_z*N_z/(N_x*N_x+N_y*N_y+N_z*N_z);
   134 template<
class ELEMENT>
   142   PoissonEquations<3>::PoissonSourceFctPt source_fct_pt);
   149  RefineableEighthSphereMesh<ELEMENT>* 
mesh_pt() 
   151    return dynamic_cast<RefineableEighthSphereMesh<ELEMENT>*
>(Problem::mesh_pt());
   162   unsigned num_bound = mesh_pt()->nboundary();
   163   for(
unsigned ibound=0;ibound<num_bound;ibound++)
   166     unsigned num_nod=mesh_pt()->nboundary_node(ibound);
   167    for (
unsigned inod=0;inod<num_nod;inod++)
   169      Node* nod_pt=mesh_pt()->boundary_node_pt(ibound,inod);
   176      nod_pt->set_value(0,u);
   182  void doc_solution(DocInfo& doc_info);
   198 template<
class ELEMENT>
   200    PoissonEquations<3>::PoissonSourceFctPt source_fct_pt) : 
   201          Source_fct_pt(source_fct_pt)
   210  Problem::mesh_pt() = 
new RefineableEighthSphereMesh<ELEMENT>(radius);
   213  Z2ErrorEstimator* error_estimator_pt=
new Z2ErrorEstimator;
   214  mesh_pt()->spatial_error_estimator_pt()=error_estimator_pt;
   217  if (CommandLineArgs::Argc>1)
   221    mesh_pt()->max_permitted_error()=0.7;
   222    mesh_pt()->min_permitted_error()=0.5;
   226    mesh_pt()->max_permitted_error()=0.01;
   227    mesh_pt()->min_permitted_error()=0.001;
   232  some_file.open(
"boundaries.dat");
   233  mesh_pt()->output_boundaries(some_file);
   239  unsigned num_bound = 
mesh_pt()->nboundary();
   240  for(
unsigned ibound=0;ibound<num_bound;ibound++)
   242    unsigned num_nod= 
mesh_pt()->nboundary_node(ibound);
   243    for (
unsigned inod=0;inod<num_nod;inod++)
   245      mesh_pt()->boundary_node_pt(ibound,inod)->pin(0); 
   251  unsigned n_element = 
mesh_pt()->nelement();
   255  for(
unsigned i=0;i<n_element;i++)
   258    ELEMENT *el_pt = 
dynamic_cast<ELEMENT*
>(
mesh_pt()->element_pt(i));
   265  cout <<
"Number of equations: " << assign_eqn_numbers() << std::endl; 
   274 template<
class ELEMENT>
   287  sprintf(filename,
"%s/soln%i.dat",doc_info.directory().c_str(),
   289  some_file.open(filename);
   290  mesh_pt()->output(some_file,npts);
   296  sprintf(filename,
"%s/exact_soln%i.dat",doc_info.directory().c_str(),
   298  some_file.open(filename);
   306  sprintf(filename,
"%s/error%i.dat",doc_info.directory().c_str(),
   308  some_file.open(filename);
   312  cout << 
"error: " << sqrt(error) << std::endl; 
   313  cout << 
"norm : " << sqrt(norm) << std::endl << std::endl;
   330 int main(
int argc, 
char *argv[]) 
   334  CommandLineArgs::setup(argc,argv);
   345  doc_info.set_directory(
"RESLT");
   351  cout << 
"Self test: " << problem.self_test() << std::endl;
   354  problem.newton_solve();
   365  if (CommandLineArgs::Argc>1)
   369    cout << 
"Only doing one adaptation for validation" << std::endl;
   377  for (
unsigned isolve=0;isolve<max_solve;isolve++)
   383    if ((problem.
mesh_pt()->nrefined()  !=0)||
   384        (problem.
mesh_pt()->nunrefined()!=0))
   386      problem.newton_solve();
   390      cout << 
"Mesh wasn't adapted --> we'll stop here" << std::endl;
 double N_x
Orientation (non-normalised x-component of unit vector in direction of step plane) ...
 
double X_0
Orientation (x-coordinate of step plane) 
 
Poisson problem in refineable eighth of a sphere mesh. 
 
void actions_before_newton_solve()
Update the problem specs before solve: Set Dirchlet boundary conditions from exact solution...
 
PoissonEquations< 3 >::PoissonSourceFctPt Source_fct_pt
Pointer to source function. 
 
void get_exact_u(const Vector< double > &x, Vector< double > &u)
 
double Z_0
Orientation (z-coordinate of step plane) 
 
~EighthSpherePoissonProblem()
Destructor: Empty. 
 
double Alpha
Parameter for steepness of step. 
 
void actions_after_newton_solve()
Update the problem specs after solve (empty) 
 
EighthSpherePoissonProblem(PoissonEquations< 3 >::PoissonSourceFctPt source_fct_pt)
Constructor: Pass pointer to source function. 
 
int main(int argc, char *argv[])
 
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. 
 
void doc_solution(DocInfo &doc_info)
Doc the solution. 
 
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) ...
 
RefineableEighthSphereMesh< ELEMENT > * mesh_pt()
Overload generic access function by one that returns a pointer to the specific mesh. 
 
void get_source(const Vector< double > &x, double &source)
Source function to make it an exact solution.