37 #include "navier_stokes.h" 40 #include "fluid_interface.h" 43 #include "meshes/single_layer_spine_mesh.h" 47 using namespace oomph;
86 template<
class ELEMENT,
class TIMESTEPPER>
96 const double &l_x,
const double &h);
102 void set_initial_condition();
105 void set_boundary_conditions();
108 void doc_solution(DocInfo &doc_info);
111 void unsteady_run(
const double &t_max,
const double &dt);
117 Mesh* Surface_mesh_pt;
127 Bulk_mesh_pt->node_update();
138 void deform_free_surface(
const double &epsilon,
const unsigned &n_periods);
153 template<
class ELEMENT,
class TIMESTEPPER>
156 const double &l_x,
const double& h) : Lx(l_x)
160 add_time_stepper_pt(
new TIMESTEPPER);
165 new SingleLayerSpineMesh<ELEMENT>(n_x,n_y,l_x,h,
true,time_stepper_pt());
170 Surface_mesh_pt =
new Mesh;
173 for(
unsigned i=0;i<n_x;i++)
177 FiniteElement *interface_element_pt =
178 new SpineLineFluidInterfaceElement<ELEMENT>(
179 Bulk_mesh_pt->finite_element_pt(n_x*(n_y-1)+i),2);
182 this->Surface_mesh_pt->add_element_pt(interface_element_pt);
185 add_sub_mesh(Bulk_mesh_pt);
186 add_sub_mesh(Surface_mesh_pt);
200 const unsigned n_boundary = Bulk_mesh_pt->nboundary();
203 for(
unsigned b=0;b<n_boundary;b++)
206 const unsigned n_node = Bulk_mesh_pt->nboundary_node(b);
209 for(
unsigned n=0;n<n_node;n++)
215 Bulk_mesh_pt->boundary_node_pt(b,n)->pin(0);
216 Bulk_mesh_pt->boundary_node_pt(b,n)->pin(1);
223 Bulk_mesh_pt->boundary_node_pt(b,n)->pin(0);
233 const unsigned n_element_bulk = Bulk_mesh_pt->nelement();
236 for(
unsigned e=0;e<n_element_bulk;e++)
239 ELEMENT *el_pt =
dynamic_cast<ELEMENT*
>(Bulk_mesh_pt->element_pt(e));
256 Data* external_pressure_data_pt =
new Data(1);
259 external_pressure_data_pt->pin(0);
260 external_pressure_data_pt->set_value(0,1.31);
263 const unsigned n_interface_element = Surface_mesh_pt->nelement();
266 for(
unsigned e=0;e<n_interface_element;e++)
269 SpineLineFluidInterfaceElement<ELEMENT>* el_pt =
270 dynamic_cast<SpineLineFluidInterfaceElement<ELEMENT>*
> 271 (Surface_mesh_pt->element_pt(e));
280 el_pt->set_external_pressure_data(external_pressure_data_pt);
285 set_boundary_conditions();
288 cout <<
"Number of equations: " << assign_eqn_numbers() << std::endl;
300 template <
class ELEMENT,
class TIMESTEPPER>
304 const unsigned n_node = Bulk_mesh_pt->nnode();
307 for(
unsigned n=0;n<n_node;n++)
310 for(
unsigned i=0;i<2;i++)
313 Bulk_mesh_pt->node_pt(n)->set_value(i,0.0);
319 assign_initial_values_impulsive();
330 template <
class ELEMENT,
class TIMESTEPPER>
334 const unsigned n_boundary = Bulk_mesh_pt->nboundary();
337 for(
unsigned b=0;b<n_boundary;b++)
340 const unsigned n_node = Bulk_mesh_pt->nboundary_node(b);
343 for(
unsigned n=0;n<n_node;n++)
349 Bulk_mesh_pt->boundary_node_pt(b,n)->set_value(0,0.0);
355 Bulk_mesh_pt->boundary_node_pt(b,n)->set_value(1,0.0);
367 template <
class ELEMENT,
class TIMESTEPPER>
372 const unsigned n_spine = Bulk_mesh_pt->nspine();
375 for(
unsigned i=0;i<n_spine;i++)
378 double x_value = Bulk_mesh_pt->boundary_node_pt(0,i)->x(0);
381 Bulk_mesh_pt->spine_pt(i)->height() =
382 1.0 + epsilon*(cos(2.0*n_periods*MathematicalConstants::Pi*x_value/Lx));
386 Bulk_mesh_pt->node_update();
395 template<
class ELEMENT,
class TIMESTEPPER>
400 cout <<
"Time is now " << time_pt()->time() << std::endl;
404 Trace_file << time_pt()->time() <<
" " 405 << Bulk_mesh_pt->spine_pt(0)->height() <<
" " << std::endl;
411 const unsigned npts = 5;
414 sprintf(filename,
"%s/soln%i.dat",doc_info.directory().c_str(),
416 some_file.open(filename);
419 Bulk_mesh_pt->output(some_file,npts);
420 Surface_mesh_pt->output(some_file,npts);
432 template<
class ELEMENT,
class TIMESTEPPER>
438 const double epsilon = 0.1;
441 const unsigned n_periods = 1;
444 deform_free_surface(epsilon,n_periods);
450 doc_info.set_directory(
"RESLT");
457 sprintf(filename,
"%s/trace.dat",doc_info.directory().c_str());
458 Trace_file.open(filename);
461 Trace_file <<
"time, free surface height" << std::endl;
467 set_initial_condition();
470 const unsigned n_timestep = unsigned(t_max/dt);
473 doc_solution(doc_info);
479 for(
unsigned t=1;t<=n_timestep;t++)
482 cout <<
"\nTimestep " << t <<
" of " << n_timestep << std::endl;
485 unsteady_newton_solve(dt);
488 doc_solution(doc_info);
506 int main(
int argc,
char* argv[])
509 CommandLineArgs::setup(argc,argv);
519 const double dt = 0.0025;
522 if(CommandLineArgs::Argc>1) { t_max = 0.005; }
525 const unsigned n_x = 12;
528 const unsigned n_y = 12;
531 const double l_x = 1.0;
534 const double h = 1.0;
543 problem(n_x,n_y,l_x,h);
Vector< double > G(2)
Direction of gravity.
double St
Strouhal number.
SingleLayerSpineMesh< ELEMENT > * Bulk_mesh_pt
The bulk fluid mesh, complete with spines and update information.
void actions_before_newton_solve()
No actions required before solve step.
double ReSt
Womersley number (Reynolds x Strouhal, computed automatically)
~InterfaceProblem()
Destructor (empty)
double Re
Reynolds number.
void actions_after_newton_solve()
Update after solve can remain empty, because the update is performed automatically after every Newton...
void set_boundary_conditions()
Set boundary conditions.
void actions_before_newton_convergence_check()
Spine heights/lengths are unknowns in the problem so their values get corrected during each Newton st...
void set_initial_condition()
Set initial conditions.
InterfaceProblem(const unsigned &n_x, const unsigned &n_y, const double &l_x, const double &h)
Constructor for single fluid free surface problem.
void unsteady_run(const double &t_max, const double &dt)
Do unsteady run up to maximum time t_max with given timestep dt.
Namespace for physical parameters.
void deform_free_surface(const double &epsilon, const unsigned &n_periods)
Deform the mesh/free surface to a prescribed function.
double ReInvFr
Product of Reynolds number and inverse of Froude number.
int main(int argc, char *argv[])
Driver code for two-dimensional single fluid free surface problem.
void doc_solution(DocInfo &doc_info)
Document the solution.
double Ca
Capillary number.