309 this->Doc_info.set_directory(
"RESLT");
312 this->Norm_file.open(
"RESLT/norm.dat");
315 this->Cog_file.open(
"RESLT/cog_trace.dat");
318 this->Cog_exact_file.open(
"RESLT/cog_exact_trace.dat");
323 this->add_time_stepper_pt(
new BDF<2>);
326 this->add_time_stepper_pt(
new Newmark<2>);
335 Vector<TriangleMeshCurveSection*> boundary_segment_pt(4);
338 double half_length = 5.0;
339 double half_height = 2.5;
342 Vector<Vector<double> > bound_seg(2);
343 for(
unsigned i=0;i<2;i++) {bound_seg[i].resize(2);}
346 bound_seg[0][0]=-half_length;
347 bound_seg[0][1]=-half_height;
348 bound_seg[1][0]=-half_length;
349 bound_seg[1][1]=half_height;
352 unsigned bound_id = 0;
355 boundary_segment_pt[0] =
new TriangleMeshPolyLine(bound_seg,bound_id);
358 bound_seg[0][0]=-half_length;
359 bound_seg[0][1]=half_height;
360 bound_seg[1][0]=half_length;
361 bound_seg[1][1]=half_height;
367 boundary_segment_pt[1] =
new TriangleMeshPolyLine(bound_seg,bound_id);
370 bound_seg[0][0]=half_length;
371 bound_seg[0][1]=half_height;
372 bound_seg[1][0]=half_length;
373 bound_seg[1][1]=-half_height;
379 boundary_segment_pt[2] =
new TriangleMeshPolyLine(bound_seg,bound_id);
382 bound_seg[0][0]=half_length;
383 bound_seg[0][1]=-half_height;
384 bound_seg[1][0]=-half_length;
385 bound_seg[1][1]=-half_height;
391 boundary_segment_pt[3] =
new TriangleMeshPolyLine(bound_seg,bound_id);
394 Outer_boundary_polygon_pt =
new TriangleMeshPolygon(boundary_segment_pt);
400 Rigid_body_pt.resize(1);
401 Vector<TriangleMeshClosedCurve*> hole_pt(1);
405 double x_center = 0.0;
406 double y_center = 0.0;
409 GeomObject* temp_hole_pt =
new GeneralEllipse(x_center,y_center,A,B);
410 Rigid_body_pt[0] =
new ImmersedRigidBodyElement(temp_hole_pt,
411 this->time_stepper_pt(1));
414 Vector<TriangleMeshCurveSection*> curvilinear_boundary_pt(2);
417 double zeta_start=0.0;
418 double zeta_end=MathematicalConstants::Pi;
420 unsigned boundary_id=4;
421 curvilinear_boundary_pt[0]=
new TriangleMeshCurviLine(
422 Rigid_body_pt[0],zeta_start,zeta_end,nsegment,boundary_id);
425 zeta_start=MathematicalConstants::Pi;
426 zeta_end=2.0*MathematicalConstants::Pi;
429 curvilinear_boundary_pt[1]=
new TriangleMeshCurviLine(
430 Rigid_body_pt[0],zeta_start,zeta_end,
431 nsegment,boundary_id);
434 Vector<double> hole_coords(2);
437 Vector<TriangleMeshClosedCurve*> curvilinear_hole_pt(1);
439 new TriangleMeshClosedCurve(
440 curvilinear_boundary_pt,hole_coords);
447 TriangleMeshClosedCurve* closed_curve_pt=Outer_boundary_polygon_pt;
449 double uniform_element_area=1.0;
453 TriangleMeshParameters triangle_mesh_parameters(
457 triangle_mesh_parameters.internal_closed_curve_pt() =
461 triangle_mesh_parameters.element_area() =
462 uniform_element_area;
466 new RefineableSolidTriangleMesh<ELEMENT>(
467 triangle_mesh_parameters, this->time_stepper_pt());
470 Z2ErrorEstimator* error_estimator_pt=
new Z2ErrorEstimator;
471 Fluid_mesh_pt->spatial_error_estimator_pt()=error_estimator_pt;
474 Fluid_mesh_pt->max_permitted_error()=0.005;
475 Fluid_mesh_pt->min_permitted_error()=0.001;
476 Fluid_mesh_pt->max_element_size()=1.0;
477 Fluid_mesh_pt->min_element_size()=0.001;
480 if (CommandLineArgs::command_line_flag_has_been_set(
"--validation"))
482 Fluid_mesh_pt->min_element_size()=0.01;
488 complete_problem_setup();
491 ImmersedRigidBodyElement* rigid_element1_pt =
492 dynamic_cast<ImmersedRigidBodyElement*
>(Rigid_body_pt[0]);
493 rigid_element1_pt->initial_centre_of_mass(0) = x_center;
494 rigid_element1_pt->initial_centre_of_mass(1) = y_center;
495 rigid_element1_pt->mass_shape() = MathematicalConstants::Pi*A*B;
496 rigid_element1_pt->moment_of_inertia_shape() =
497 0.25*MathematicalConstants::Pi*A*B*(A*A + B*B);
503 rigid_element1_pt->pin_centre_of_mass_coordinate(0);
504 rigid_element1_pt->pin_centre_of_mass_coordinate(1);
507 Rigid_body_mesh_pt =
new Mesh;
508 Rigid_body_mesh_pt->add_element_pt(rigid_element1_pt);
511 Drag_mesh_pt.resize(1);
512 for(
unsigned m=0;m<1;m++) {Drag_mesh_pt[m] =
new Mesh;}
513 this->create_drag_elements();
516 rigid_element1_pt->set_drag_mesh(Drag_mesh_pt[0]);
524 Lagrange_multiplier_mesh_pt=
new SolidMesh;
525 create_lagrange_multiplier_elements();
532 this->add_sub_mesh(Fluid_mesh_pt);
535 this->add_sub_mesh(this->Lagrange_multiplier_mesh_pt);
537 this->add_sub_mesh(this->Rigid_body_mesh_pt);
540 this->build_global_mesh();
543 cout <<
"Number of equations: " << this->assign_eqn_numbers() << std::endl;
740 for(
unsigned ibound=0;ibound<4;ibound++)
744 if((ibound==0) || (ibound==2))
746 unsigned num_nod=this->Fluid_mesh_pt->nboundary_node(ibound);
747 for (
unsigned inod=0;inod<num_nod;inod++)
750 Node*
const nod_pt=this->Fluid_mesh_pt->boundary_node_pt(ibound,inod);
753 unsigned n_prev=nod_pt->time_stepper_pt()->nprev_values();
756 for(
unsigned t=0;t<=n_prev;t++)
758 nod_pt->set_value(t,1,0.0);
766 unsigned num_nod=this->Fluid_mesh_pt->nboundary_node(ibound);
767 for (
unsigned inod=0;inod<num_nod;inod++)
770 Node* nod_pt=this->Fluid_mesh_pt->boundary_node_pt(ibound,inod);
773 unsigned n_prev=nod_pt->time_stepper_pt()->nprev_values();
776 double y = nod_pt->x(1);
778 for(
unsigned t=0;t<=n_prev;t++)
781 double time_ = this->time_pt()->time(t);
788 double e1 = exp(-delta);
789 double a1 = 1.0 - (1.0 + delta + 0.5*delta*delta)*e1;
790 double b1 = (3.0 + 3.0*delta + delta*delta)*e1 - 3.0;
791 double c1 = 3.0 - (3.0 + 2.0*delta + 0.5*delta*delta)*e1;
793 if((time_ >= 0.0) & (time_ <= 1.0))
795 ramp = a1*time_*time_*time_
800 else if (time_ > 1.0)
802 ramp = 1.0 - exp(-delta*time_);
805 nod_pt->set_value(t,0,-y*ramp);
810 for (
unsigned t=0;t<=n_prev;t++)
812 nod_pt->set_value(t,1,0.0);
904 unsigned n_boundary = Fluid_mesh_pt->nboundary();
907 for(
unsigned b=0;b<n_boundary;b++)
910 GeomObject* boundary_geom_obj_pt =
911 Fluid_mesh_pt->boundary_geom_object_pt(b);
914 if(boundary_geom_obj_pt!=0)
917 unsigned n_element = Fluid_mesh_pt->nboundary_element(b);
920 for(
unsigned e=0;e<n_element;e++)
924 ELEMENT* bulk_elem_pt =
dynamic_cast<ELEMENT*
>(
925 Fluid_mesh_pt->boundary_element_pt(b,e));
928 int face_index = Fluid_mesh_pt->face_index_at_boundary(b,e);
933 ImposeDisplacementByLagrangeMultiplierElement<ELEMENT>* el_pt =
934 new ImposeDisplacementByLagrangeMultiplierElement<ELEMENT>(
935 bulk_elem_pt,face_index,b);
938 Lagrange_multiplier_mesh_pt->add_element_pt(el_pt);
943 el_pt->set_boundary_shape_geom_object_pt(
944 boundary_geom_obj_pt,b);
947 unsigned nnod=el_pt->nnode();
948 for(
unsigned j=0;j<nnod;j++)
950 Node* nod_pt = el_pt->node_pt(j);
954 unsigned n_bulk_value=el_pt->nbulk_value(j);
958 unsigned nval=nod_pt->nvalue();
961 for (
unsigned i=0;i<2;i++)
964 nod_pt->pin(n_bulk_value+2+i);
1013 unsigned n_rigid = Rigid_body_pt.size();
1016 unsigned n_boundary = Fluid_mesh_pt->nboundary();
1019 for(
unsigned r=0;r<n_rigid;r++)
1022 ImmersedRigidBodyElement* rigid_el_pt =
1023 dynamic_cast<ImmersedRigidBodyElement*
>(this->Rigid_body_pt[r]);
1026 for(
unsigned b=0;b<n_boundary;b++)
1029 if(
dynamic_cast<ImmersedRigidBodyElement*
>
1030 (Fluid_mesh_pt->boundary_geom_object_pt(b)) == rigid_el_pt)
1033 unsigned n_element = Fluid_mesh_pt->nboundary_element(b);
1036 for(
unsigned e=0;e<n_element;e++)
1040 ELEMENT* bulk_elem_pt =
dynamic_cast<ELEMENT*
>(
1041 Fluid_mesh_pt->boundary_element_pt(b,e));
1044 int face_index = Fluid_mesh_pt->face_index_at_boundary(b,e);
1049 NavierStokesSurfaceDragTorqueElement<ELEMENT>* el_pt =
1050 new NavierStokesSurfaceDragTorqueElement<ELEMENT>(
1051 bulk_elem_pt,face_index);
1054 Drag_mesh_pt[r]->add_element_pt(el_pt);
1058 for(
unsigned i=0;i<2;i++)
1059 {el_pt->centre_of_rotation(i) =
1060 rigid_el_pt->initial_centre_of_mass(i);}
1065 el_pt->set_translation_and_rotation(rigid_el_pt->geom_data_pt(0));
1107 const bool& project)
1110 oomph_info <<
"Docing step: " << this->Doc_info.number()
1124 snprintf(filename,
sizeof(filename),
"%s/soln%i.dat",
1125 this->Doc_info.directory().c_str(),
1126 this->Doc_info.number());
1130 snprintf(filename,
sizeof(filename),
"%s/proj%i.dat",
1131 this->Doc_info.directory().c_str(),
1132 this->Doc_info.number()-1);
1136 double square_of_l2_norm=0.0;
1137 unsigned nel=Fluid_mesh_pt->nelement();
1138 for (
unsigned e=0;e<nel;e++)
1141 dynamic_cast<ELEMENT*
>(this->Fluid_mesh_pt->element_pt(e))->
1142 square_of_l2_norm();
1145 std::cout <<
"Checking " << sqrt(square_of_l2_norm) <<
"\n";
1146 this->Norm_file << sqrt(square_of_l2_norm) <<
"\n";
1148 some_file.open(filename);
1149 some_file << dynamic_cast<ELEMENT*>(this->Fluid_mesh_pt->element_pt(0))
1150 ->variable_identifier();
1151 this->Fluid_mesh_pt->output(some_file,npts);
1158 snprintf(filename,
sizeof(filename),
"%s/int%i.dat",
1159 this->Doc_info.directory().c_str(),
1160 this->Doc_info.number());
1161 some_file.open(filename);
1162 this->Lagrange_multiplier_mesh_pt->output(some_file);
1166 this->Doc_info.number()++;
1169 dynamic_cast<ImmersedRigidBodyElement*
>(this->Rigid_body_pt[0])->
1170 output_centre_of_gravity(this->Cog_file);
1173 this->output_exact_solution(this->Cog_exact_file);