210FiniteElement::UnsteadyExactSolutionFctPt IC_fct_pt) : IC_Fct_pt(IC_fct_pt)
217 add_time_stepper_pt(
new BDF<4>);
224 double eps_buckl=0.1;
225 double ampl_ratio=-0.5;
230 Wall_pt=
new PseudoBucklingRingElement(eps_buckl,ampl_ratio,n_buckl,r_0,T,
236 double xi_hi=2.0*atan(1.0);
239 double fract_mid=0.5;
242 Fluid_mesh_pt=
new AlgebraicRefineableQuarterCircleSectorMesh<ELEMENT>(
243 Wall_pt,xi_lo,fract_mid,xi_hi,time_stepper_pt());
246 Z2ErrorEstimator* error_estimator_pt=
new Z2ErrorEstimator;
247 Fluid_mesh_pt->spatial_error_estimator_pt()=error_estimator_pt;
268 unsigned nnode=
fluid_mesh_pt()->finite_element_pt(0)->nnode();
274 unsigned nnode_1d=
dynamic_cast<ELEMENT*
>(
277 finite_element_pt(0)->node_pt(nnode_1d-1);
282 dynamic_cast<PseudoBucklingRingElement*
>(
Wall_pt)
284 ->element_pt(0)->internal_data_pt(0));
297 for (
unsigned inod=0;inod<num_nod;inod++)
311 for (
unsigned inod=0;inod<num_nod;inod++)
314 Node* node_pt=
fluid_mesh_pt()->boundary_node_pt(ibound,inod);
318 node_pt->set_auxiliary_node_update_fct_pt(
319 FSI_functions::apply_no_slip_on_moving_wall);
322 for (
unsigned i=0;i<2;i++)
333 for (
unsigned inod=0;inod<num_nod;inod++)
351 for(
unsigned i=0;i<n_element;i++)
354 ELEMENT *el_pt =
dynamic_cast<ELEMENT*
>(
fluid_mesh_pt()->element_pt(i));
363 cout <<
"Number of equations: " << assign_eqn_numbers() << std::endl;
406 dynamic_cast<PseudoBucklingRingElement*
>(Wall_pt)->set_R_0(1.0);
409 double backed_up_time=time_pt()->time();
416 Vector<double> soln(3);
420 unsigned num_nod = fluid_mesh_pt()->nnode();
423 int nprev_steps=time_stepper_pt()->nprev_values();
424 Vector<double> prev_time(nprev_steps+1);
425 for (
int itime=nprev_steps;itime>=0;itime--)
427 prev_time[itime]=time_pt()->time(
unsigned(itime));
432 for (
int itime=nprev_steps;itime>=0;itime--)
434 double time=prev_time[itime];
438 time_pt()->time()=time;
440 cout <<
"setting IC at time =" << time << std::endl;
445 fluid_mesh_pt()->node_update();
448 for (
unsigned jnod=0;jnod<num_nod;jnod++)
452 x[0]=fluid_mesh_pt()->node_pt(jnod)->x(0);
453 x[1]=fluid_mesh_pt()->node_pt(jnod)->x(1);
456 (*IC_Fct_pt)(time,x,soln);
459 for (
unsigned i=0;i<2;i++)
461 fluid_mesh_pt()->node_pt(jnod)->set_value(itime,i,soln[i]);
465 for (
unsigned i=0;i<2;i++)
467 fluid_mesh_pt()->node_pt(jnod)->x(itime,i)=x[i];
473 time_pt()->time()=backed_up_time;
489 cout <<
"Doc-ing step " << doc_info.number()
490 <<
" for time " << time_stepper_pt()->time_pt()->time() << std::endl;
502 snprintf(filename,
sizeof(filename),
"%s/soln%i.dat",doc_info.directory().c_str(),
505 some_file.open(filename);
506 unsigned nelem=fluid_mesh_pt()->nelement();
507 for (
unsigned ielem=0;ielem<nelem;ielem++)
509 dynamic_cast<ELEMENT*
>(fluid_mesh_pt()->element_pt(ielem))->
510 full_output(some_file,npts);
517 snprintf(filename,
sizeof(filename),
"%s/Wall%i.dat",doc_info.directory().c_str(),
519 some_file.open(filename);
522 Vector<double > xi_wall(1);
523 Vector<double > r_wall(2);
524 for (
unsigned iplot=0;iplot<nplot;iplot++)
526 xi_wall[0]=0.5*Pi*double(iplot)/double(nplot-1);
527 Wall_pt->position(xi_wall,r_wall);
528 some_file << r_wall[0] <<
" " << r_wall[1] << std::endl;
535 snprintf(filename,
sizeof(filename),
"%s/exact_soln%i.dat",doc_info.directory().c_str(),
537 some_file.open(filename);
538 fluid_mesh_pt()->output_fct(some_file,npts,
539 time_stepper_pt()->time_pt()->time(),
549 Vector<double> xi(1);
550 xi[0]=MathematicalConstants::Pi/2.0;
551 wall_pt()->position(xi,r);
560 double press_int=0.0;
563 nelem=fluid_mesh_pt()->nelement();
565 for (
unsigned ielem=0;ielem<nelem;ielem++)
567 area+=fluid_mesh_pt()->finite_element_pt(ielem)->size();
568 press_int+=
dynamic_cast<ELEMENT*
>(fluid_mesh_pt()->element_pt(ielem))
569 ->pressure_integral();
570 diss+=
dynamic_cast<ELEMENT*
>(fluid_mesh_pt()->element_pt(ielem))->
572 kin_en+=
dynamic_cast<ELEMENT*
>(fluid_mesh_pt()->element_pt(ielem))->
577 double global_kin=4.0*kin_en;
582 fluid_mesh_pt()->get_refinement_levels(min_level,max_level);
586 double time=time_pt()->time();
590 Vector<double> x_sarah(2);
591 Vector<double> soln_sarah(3);
592 x_sarah[0]=Sarah_veloc_trace_node_pt->x(0);
593 x_sarah[1]=Sarah_veloc_trace_node_pt->x(1);
597 Trace_file << time_pt()->time()
601 <<
" " <<
static_cast<PseudoBucklingRingElement*
>(Wall_pt)->r_0()
603 <<
" " << press_int/area
605 <<
" " << diss_asympt
606 <<
" " << Veloc_trace_node_pt->x(0)
607 <<
" " << Veloc_trace_node_pt->x(1)
608 <<
" " << Veloc_trace_node_pt->value(0)
609 <<
" " << Veloc_trace_node_pt->value(1)
610 <<
" " << fluid_mesh_pt()->nelement()
614 <<
" " << fluid_mesh_pt()->nrefinement_overruled()
615 <<
" " << fluid_mesh_pt()->max_error()
616 <<
" " << fluid_mesh_pt()->min_error()
617 <<
" " << fluid_mesh_pt()->max_permitted_error()
618 <<
" " << fluid_mesh_pt()->min_permitted_error()
619 <<
" " << fluid_mesh_pt()->max_keep_unrefined()
620 <<
" " << doc_info.number()
621 <<
" " << Sarah_veloc_trace_node_pt->x(0)
622 <<
" " << Sarah_veloc_trace_node_pt->x(1)
623 <<
" " << Sarah_veloc_trace_node_pt->value(0)
624 <<
" " << Sarah_veloc_trace_node_pt->value(1)
627 <<
" " << soln_sarah[0]
628 <<
" " << soln_sarah[1]
630 <<
static_cast<PseudoBucklingRingElement*
>(Wall_pt)->r_0()-1.0
638 Vector<Tree*> all_element_pt;
639 fluid_mesh_pt()->forest_pt()->
640 stick_all_tree_nodes_into_vector(all_element_pt);
643 Mesh* coarse_mesh_pt =
new Mesh();
647 nelem=all_element_pt.size();
648 for (
unsigned ielem=0;ielem<nelem;ielem++)
650 Tree* el_pt=all_element_pt[ielem];
651 if (el_pt->level()==min_level)
653 coarse_mesh_pt->add_element_pt(el_pt->object_pt());
658 snprintf(filename,
sizeof(filename),
"%s/coarse_soln%i.dat",doc_info.directory().c_str(),
660 some_file.open(filename);
661 nelem=coarse_mesh_pt->nelement();
662 for (
unsigned ielem=0;ielem<nelem;ielem++)
664 dynamic_cast<ELEMENT*
>(coarse_mesh_pt->element_pt(ielem))->
665 full_output(some_file,npts);
670 snprintf(filename,
sizeof(filename),
"%s/restart%i.dat",doc_info.directory().c_str(),
672 some_file.open(filename);
673 dump_it(some_file,doc_info);
732 const bool& restarted,
738 snprintf(filename,
sizeof(filename),
"%s/trace.dat",doc_info.directory().c_str());
739 Trace_file.open(filename);
755 fluid_mesh_pt()->max_permitted_error()= 0.5e-2;
756 fluid_mesh_pt()->min_permitted_error()= 0.5e-3;
759 fluid_mesh_pt()->min_refinement_level()=2;
762 fluid_mesh_pt()->max_refinement_level()=6;
766 fluid_mesh_pt()->max_keep_unrefined()=20;
770 unsigned min_refinement_level;
771 unsigned max_refinement_level;
772 fluid_mesh_pt()->get_refinement_levels(min_refinement_level,
773 max_refinement_level);
775 cout <<
"\n Initial mesh: min/max refinement levels: "
776 << min_refinement_level <<
" " << max_refinement_level << std::endl << std::endl;
779 fluid_mesh_pt()->doc_adaptivity_targets(cout);
782 write_trace_file_header();
785 doc_solution(doc_info);
789 doc_info.disable_doc();
800 time_pt()->time()-=time_pt()->dt();
809 double dt=time_pt()->dt();
810 unsteady_newton_solve(dt,max_adapt,first,shift);
813 doc_info.enable_doc();
816 doc_solution(doc_info);
823 for(
unsigned t=2;t<=ntsteps;t++)
827 doc_info.disable_doc();
831 unsteady_newton_solve(dt,max_adapt,first);
834 doc_info.enable_doc();
839 doc_solution(doc_info);
923int main(
int argc,
char* argv[])
927 CommandLineArgs::setup(argc,argv);
930 unsigned nstep_per_period=40;
934 unsigned nstep=nstep_per_period*nperiod;
935 double dt=1.0/double(nstep_per_period);
945 bool restarted=
false;
948 ifstream* restart_file_pt=0;
952 if (CommandLineArgs::Argc!=2)
954 cout <<
"No restart" << std::endl;
958 problem.refine_uniformly();
959 problem.refine_uniformly();
960 problem.refine_uniformly();
974 else if (CommandLineArgs::Argc==2)
979 restart_file_pt=
new ifstream(CommandLineArgs::Argv[1],ios_base::in);
980 if (restart_file_pt!=0)
982 cout <<
"Have opened " << CommandLineArgs::Argv[1] <<
983 " for restart. " << std::endl;
987 std::ostringstream error_stream;
988 error_stream <<
"ERROR while trying to open "
989 << CommandLineArgs::Argv[2]
990 <<
" for restart." << std::endl;
992 throw OomphLibError(error_stream.str(),
993 OOMPH_CURRENT_FUNCTION,
994 OOMPH_EXCEPTION_LOCATION);
997 problem.
restart(*restart_file_pt);
1002 if (CommandLineArgs::Argc==3)
1005 cout <<
"Only doing nstep steps for validation: " << nstep << std::endl;
1015 doc_info.set_directory(
"RESLT");
1025 if (CommandLineArgs::Argc==3)
1036 DocInfo restarted_doc_info;
1039 restarted_doc_info.set_directory(
"RESLT_restarted");
1042 restarted_doc_info.number()=0;
1045 restart_file_pt=
new ifstream(
"RESLT/restart2.dat");
1048 restarted_problem.
restart(*restart_file_pt);
1052 bool restarted=
true;
1053 restarted_problem.
unsteady_run(nstep,restarted,restarted_doc_info);