32 #include "advection_diffusion.h"
35 #include "meshes/rectangular_quadmesh.h"
39 using namespace oomph;
78 void wind_function(
const Vector<double>& x, Vector<double>& wind)
80 wind[0]=sin(6.0*x[1]);
81 wind[1]=cos(6.0*x[0]);
95 template<
class ELEMENT>
103 AdvectionDiffusionEquations<2>::AdvectionDiffusionSourceFctPt source_fct_pt,
104 AdvectionDiffusionEquations<2>::AdvectionDiffusionWindFctPt wind_fct_pt);
118 void doc_solution(DocInfo& doc_info);
123 RefineableRectangularQuadMesh<ELEMENT>*
mesh_pt()
125 return dynamic_cast<RefineableRectangularQuadMesh<ELEMENT>*
>(
132 AdvectionDiffusionEquations<2>::AdvectionDiffusionSourceFctPt Source_fct_pt;
135 AdvectionDiffusionEquations<2>::AdvectionDiffusionWindFctPt Wind_fct_pt;
146 template<
class ELEMENT>
148 AdvectionDiffusionEquations<2>::AdvectionDiffusionSourceFctPt source_fct_pt,
149 AdvectionDiffusionEquations<2>::AdvectionDiffusionWindFctPt wind_fct_pt)
150 : Source_fct_pt(source_fct_pt), Wind_fct_pt(wind_fct_pt)
169 new RefineableRectangularQuadMesh<ELEMENT>(n_x,n_y,l_x,l_y);
172 mesh_pt()->spatial_error_estimator_pt()=
new Z2ErrorEstimator;
177 unsigned num_bound =
mesh_pt()->nboundary();
178 for(
unsigned ibound=0;ibound<num_bound;ibound++)
180 unsigned num_nod=
mesh_pt()->nboundary_node(ibound);
181 for (
unsigned inod=0;inod<num_nod;inod++)
183 mesh_pt()->boundary_node_pt(ibound,inod)->pin(0);
192 unsigned n_element =
mesh_pt()->nelement();
193 for(
unsigned i=0;i<n_element;i++)
196 ELEMENT *el_pt =
dynamic_cast<ELEMENT*
>(
mesh_pt()->element_pt(i));
209 cout <<
"Number of equations: " << assign_eqn_numbers() << std::endl;
217 template<
class ELEMENT>
221 unsigned num_bound = mesh_pt()->nboundary();
224 for(
unsigned ibound=0;ibound<num_bound;ibound++)
227 unsigned num_nod=mesh_pt()->nboundary_node(ibound);
230 for (
unsigned inod=0;inod<num_nod;inod++)
233 Node* nod_pt=mesh_pt()->boundary_node_pt(ibound,inod);
245 nod_pt->set_value(0,u[0]);
253 template<
class ELEMENT>
266 sprintf(filename,
"%s/soln%i.dat",doc_info.directory().c_str(),
268 some_file.open(filename);
269 mesh_pt()->output(some_file,npts);
295 doc_info.set_directory(
"RESLT");
302 cout <<
"\n\n\nProblem self-test ";
303 if (problem.self_test()==0)
305 cout <<
"passed: Problem can be solved." << std::endl;
309 throw OomphLibError(
"Self test failed",
310 OOMPH_CURRENT_FUNCTION,
311 OOMPH_EXCEPTION_LOCATION);
322 problem.
mesh_pt()->doc_adaptivity_targets(cout);
330 problem.newton_solve();
342 unsigned max_solve=4;
343 for (
unsigned isolve=0;isolve<max_solve;isolve++)
349 if ((problem.
mesh_pt()->nrefined() !=0)||
350 (problem.
mesh_pt()->nunrefined()!=0))
352 problem.newton_solve();
356 cout <<
"Mesh wasn't adapted --> we'll stop here" << std::endl;
/////////////////////////////////////////////////////////////////// /////////////////////////////////...
RefineableAdvectionDiffusionProblem(AdvectionDiffusionEquations< 2 >::AdvectionDiffusionSourceFctPt source_fct_pt, AdvectionDiffusionEquations< 2 >::AdvectionDiffusionWindFctPt wind_fct_pt)
Constructor: Pass pointer to source function.
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 exact solutio...
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.
void tanh_profile(const Vector< double > &x, Vector< double > &u)
Tanh profile for assignment of boundary conditons as a Vector.
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.
double Peclet
Peclet number.
void tanh_profile(const Vector< double > &x, double &u)
Tanh profile for assignment of boundary conditons as a Vector.
int main()
Driver code for 2D AdvectionDiffusion problem.