32 #include "advection_diffusion.h"
35 #include "meshes/rectangular_quadmesh.h"
39 using namespace oomph;
86 wind[0]=sin(6.0*x[1]);
87 wind[1]=cos(6.0*x[0]);
101 template<
class ELEMENT>
109 AdvectionDiffusionEquations<2>::AdvectionDiffusionSourceFctPt source_fct_pt,
110 AdvectionDiffusionEquations<2>::AdvectionDiffusionWindFctPt wind_fct_pt);
117 void actions_before_newton_solve();
138 RefineableRectangularQuadMesh<ELEMENT>*
mesh_pt()
140 return dynamic_cast<RefineableRectangularQuadMesh<ELEMENT>*
>(
150 AdvectionDiffusionEquations<2>::AdvectionDiffusionSourceFctPt
Source_fct_pt;
153 AdvectionDiffusionEquations<2>::AdvectionDiffusionWindFctPt
Wind_fct_pt;
163 template<
class ELEMENT>
165 AdvectionDiffusionEquations<2>::AdvectionDiffusionSourceFctPt source_fct_pt,
166 AdvectionDiffusionEquations<2>::AdvectionDiffusionWindFctPt wind_fct_pt)
167 : Source_fct_pt(source_fct_pt), Wind_fct_pt(wind_fct_pt)
189 new RefineableRectangularQuadMesh<ELEMENT>(n_x,n_y,l_x,l_y);
192 mesh_pt()->spatial_error_estimator_pt()=
new Z2ErrorEstimator;
197 unsigned num_bound =
mesh_pt()->nboundary();
198 for(
unsigned ibound=0;ibound<num_bound;ibound++)
200 unsigned num_nod=
mesh_pt()->nboundary_node(ibound);
201 for (
unsigned inod=0;inod<num_nod;inod++)
203 mesh_pt()->boundary_node_pt(ibound,inod)->pin(0);
212 unsigned n_element =
mesh_pt()->nelement();
213 for(
unsigned i=0;i<n_element;i++)
216 ELEMENT *el_pt =
dynamic_cast<ELEMENT*
>(
mesh_pt()->element_pt(i));
229 cout <<
"Number of equations: " << assign_eqn_numbers() << std::endl;
238 template<
class ELEMENT>
242 unsigned num_bound = mesh_pt()->nboundary();
245 for(
unsigned ibound=0;ibound<num_bound;ibound++)
248 unsigned num_nod=mesh_pt()->nboundary_node(ibound);
251 for (
unsigned inod=0;inod<num_nod;inod++)
254 Node* nod_pt=mesh_pt()->boundary_node_pt(ibound,inod);
266 nod_pt->set_value(0,u[0]);
276 template<
class ELEMENT>
288 sprintf(filename,
"%s/soln%i.dat",Doc_info.directory().c_str(),
290 some_file.open(filename);
291 mesh_pt()->output(some_file,npts);
296 sprintf(filename,
"%s/exact_soln%i.dat",Doc_info.directory().c_str(),
298 some_file.open(filename);
305 sprintf(filename,
"%s/error%i.dat",Doc_info.directory().c_str(),
307 some_file.open(filename);
313 cout <<
"\nNorm of error : " << sqrt(error) << std::endl;
314 cout <<
"Norm of solution: " << sqrt(norm) << std::endl << std::endl;
337 cout <<
"\n\n\nProblem self-test ";
338 if (problem.self_test()==0)
340 cout <<
"passed: Problem can be solved." << std::endl;
344 throw OomphLibError(
"Self test failed",
345 OOMPH_CURRENT_FUNCTION,
346 OOMPH_EXCEPTION_LOCATION);
356 problem.newton_solve(4);
/////////////////////////////////////////////////////////////////// /////////////////////////////////...
void actions_before_adapt()
Actions before adapt: Document the solution.
DocInfo Doc_info
DocInfo object.
RefineableAdvectionDiffusionProblem(AdvectionDiffusionEquations< 2 >::AdvectionDiffusionSourceFctPt source_fct_pt, AdvectionDiffusionEquations< 2 >::AdvectionDiffusionWindFctPt wind_fct_pt)
Constructor: Pass pointer to source and wind functions.
void doc_solution()
Doc the solution.
void actions_before_newton_solve()
Update the problem specs before solve: Reset boundary conditions to the values from the tanh solution...
AdvectionDiffusionEquations< 2 >::AdvectionDiffusionSourceFctPt Source_fct_pt
Pointer to source function.
void actions_after_newton_solve()
Update the problem after solve (empty)
AdvectionDiffusionEquations< 2 >::AdvectionDiffusionWindFctPt Wind_fct_pt
Pointer to wind function.
RefineableRectangularQuadMesh< ELEMENT > * mesh_pt()
Overloaded version of the problem's access function to the mesh. Recasts the pointer to the base Mesh...
~RefineableAdvectionDiffusionProblem()
Destructor. Empty.
Namespace for exact solution for AdvectionDiffusion equation with "sharp" step.
double TanPhi
Parameter for angle of step.
double Alpha
Parameter for steepness of step.
void source_function(const Vector< double > &x_vect, double &source)
Source function required to make the solution above an exact solution.
void wind_function(const Vector< double > &x, Vector< double > &wind)
Wind.
void get_exact_u(const Vector< double > &x, Vector< double > &u)
Exact solution as a Vector.
double Peclet
Peclet number.
void get_exact_u(const Vector< double > &x, double &u)
Exact solution as a scalar.
int main()
Driver code for 2D AdvectionDiffusion problem.