36 #include "../include/free_surface.h"
37 #include "../include/restart_nonlinear_problem_diff.h"
38 #include "../include/restart_nonlinear_problem_alg.h"
44 #include <GeomPlate_BuildPlateSurface.hxx>
45 #include <GeomPlate_PointConstraint.hxx>
46 #include <GeomPlate_MakeApprox.hxx>
47 #include <Geom_Surface.hxx>
48 #include <BRepBuilderAPI_MakeFace.hxx>
49 #include <GeomPlate_Surface.hxx>
50 #include <BRepAdaptor_Curve.hxx>
72 prm.
set(
"Function expression",
"0");
80 prm.
set(
"Function expression",
"0");
88 prm.
set(
"Function expression",
"0");
95 prm.
set(
"Function expression",
"1; 1");
102 prm.
set(
"Function expression",
"1; 1; 1");
109 prm.
set(
"Function expression",
"0");
116 prm.
set(
"Function expression",
"0");
123 prm.
set(
"Function expression",
"0");
130 prm.
set(
"Function expression",
"0");
137 prm.
set(
"Function expression",
"0");
144 prm.
set(
"Function expression",
"0");
151 prm.
set(
"Function expression",
"0");
158 prm.
set(
"Function expression",
"0");
193 output_file_name = prm.
get(
"Output file name");
194 remeshing_period = prm.
get_double(
"Remeshing period");
195 dumping_period = prm.
get_double(
"Dumping period");
197 restore_filename = prm.
get(
"Restore from file");
198 initial_condition_from_dump = (restore_filename !=
"");
200 sync_bem_with_geometry = prm.
get_bool(
"Keep BEM in sync with geometry");
205 wind.parse_parameters(prm);
209 is_hull_x_translation_imposed = prm.
get_bool(
"Is x-translation imposed");
212 hull_x_axis_translation.parse_parameters(prm);
216 is_hull_y_translation_imposed = prm.
get_bool(
"Is y-translation imposed");
219 hull_y_axis_translation.parse_parameters(prm);
223 is_hull_z_translation_imposed = prm.
get_bool(
"Is z-translation imposed");
226 hull_z_axis_translation.parse_parameters(prm);
233 initial_wave_shape.parse_parameters(prm);
240 initial_wave_potential.parse_parameters(prm);
244 prm.
enter_subsection(std::string(
"Initial Wave Normal Potential Gradient ")+
247 initial_norm_potential_grad.parse_parameters(prm);
254 inflow_norm_potential_grad.parse_parameters(prm);
258 node_displacement_type = prm.
get(
"Node displacement type");
261 solver_control.parse_parameters(prm);
267 max_number_of_dofs = prm.
get_integer(
"Maximum number of dofs");
268 coarsening_fraction = prm.
get_double(
"Coarsening fraction");
269 refinement_fraction = prm.
get_double(
"Refinement fraction");
270 adaptive_ref_limit = prm.
get_double(
"Adaptive refinement limit");
281 dofs_number = comp_dom.vector_dh.n_dofs() +
282 comp_dom.dh.n_dofs() +
283 comp_dom.dh.n_dofs() +
287 DXDt_and_DphiDt_vector.reinit(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs());
293 compute_constraints(constraints, vector_constraints);
295 DphiDt_sparsity_pattern.reinit (comp_dom.dh.n_dofs(),
296 comp_dom.dh.n_dofs(),
297 comp_dom.dh.max_couplings_between_dofs());
298 vector_sparsity_pattern.reinit (comp_dom.vector_dh.n_dofs(),
299 comp_dom.vector_dh.n_dofs(),
300 comp_dom.vector_dh.max_couplings_between_dofs());
304 DphiDt_sparsity_pattern.compress();
307 vector_sparsity_pattern.compress();
310 working_map_points.reinit (comp_dom.vector_dh.n_dofs());
311 working_nodes_velocities.reinit(comp_dom.vector_dh.n_dofs());
312 nodes_pos_res.reinit(comp_dom.vector_dh.n_dofs());
313 nodes_ref_surf_dist.reinit(comp_dom.vector_dh.n_dofs());
314 nodes_diff_jac_x_delta.reinit(dofs_number);
315 nodes_alg_jac_x_delta.reinit(dofs_number);
316 dae_nonlin_residual.reinit(dofs_number);
317 dae_linear_step_residual.reinit(dofs_number);
318 current_sol.reinit(dofs_number);
319 current_sol_dot.reinit(dofs_number);
320 bem_residual.reinit(comp_dom.dh.n_dofs());
321 bem_phi.reinit(comp_dom.dh.n_dofs());
322 bem_dphi_dn.reinit(comp_dom.dh.n_dofs());
323 temp_src.reinit(comp_dom.vector_dh.n_dofs());
324 break_wave_press.reinit(comp_dom.dh.n_dofs());
326 rhs_evaluations_counter = 0;
336 initial_wave_shape.set_time(initial_time);
337 initial_wave_potential.set_time(initial_time);
338 initial_norm_potential_grad.set_time(initial_time);
339 inflow_norm_potential_grad.set_time(initial_time);
340 wind.set_time(initial_time);
347 if (is_hull_x_translation_imposed)
349 restart_hull_displacement(0) = hull_x_axis_translation.value(time);
350 dst(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+3) = restart_hull_displacement(0);
354 cout<<
"VELX: "<<vel<<endl;
355 dst(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()) = vel;
358 restart_hull_displacement(0) = 0.0;
360 if (is_hull_y_translation_imposed)
362 restart_hull_displacement(1) = hull_y_axis_translation.value(time);
363 dst(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+4) = restart_hull_displacement(1);
367 cout<<
"VELY: "<<vel<<endl;
368 dst(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+1) = vel;
371 restart_hull_displacement(1) = 0.0;
373 if (is_hull_z_translation_imposed)
375 restart_hull_displacement(2) = hull_z_axis_translation.value(time);
376 dst(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+5) = restart_hull_displacement(2);
377 double vel = ( hull_z_axis_translation.value(time+delta_t) -
378 hull_z_axis_translation.value(time+(-1.0*delta_t)) ) / 2.0 / delta_t(0);
380 cout<<
"VELZ: "<<vel<<endl;
381 dst(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+2) = vel;
384 restart_hull_displacement(2) = 0.0;
387 Point<3> quaternion_vect(0.0,0,0.0);
388 double quaternion_scalar = 1.0;
389 for (
unsigned int d=0; d<3; ++d)
391 dst(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+6+d) = init_omega(d);
392 dst(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+9+d) = quaternion_vect(d);
394 dst(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+12) = quaternion_scalar;
396 gp_Trsf curr_transf = comp_dom.boat_model.set_current_position(restart_hull_displacement,
400 restart_hull_location = curr_transf;
401 restart_transom_center_point = comp_dom.boat_model.CurrentPointCenterTransom;
402 restart_transom_left_point = comp_dom.boat_model.CurrentPointLeftTransom;
403 restart_transom_right_point = comp_dom.boat_model.CurrentPointRightTransom;
404 restart_transom_left_tangent = comp_dom.boat_model.current_left_transom_tangent;
405 restart_transom_right_tangent = comp_dom.boat_model.current_right_transom_tangent;
410 wind.vector_value(zero,instantWindValue);
412 for (
unsigned int i = 0; i < dim; i++)
413 Vinf(i) = instantWindValue(i);
414 std::cout<<std::endl<<
"Initial conditions: simulation time= "<<initial_time<<
" Vinf= ";
415 instantWindValue.
print(std::cout,4,
false,
true);
417 std::vector<Point<dim> > support_points(comp_dom.dh.n_dofs());
419 std::vector<Point<dim> > vector_support_points(comp_dom.vector_dh.n_dofs());
423 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
425 if ((comp_dom.flags[i] &
water) ||
427 comp_dom.map_points(3*i+2) = initial_wave_shape.value(vector_support_points[3*i]);
430 unsigned int j = dim-1;
432 if (!comp_dom.no_boat)
433 comp_dom.evaluate_ref_surf_distances(geom_res,
false);
438 for (
unsigned int i=0; i<comp_dom.vector_dh.n_dofs(); ++i)
440 comp_dom.map_points(i) -= geom_res(i);
443 if (!comp_dom.no_boat && comp_dom.boat_model.is_transom)
445 comp_dom.update_support_points();
447 double transom_draft = fabs(comp_dom.boat_model.CurrentPointCenterTransom(2));
448 double transom_aspect_ratio = (fabs(comp_dom.boat_model.CurrentPointLeftTransom(1))+
449 fabs(comp_dom.boat_model.CurrentPointRightTransom(1)))/transom_draft;
451 wind.set_time(100000000.0);
454 wind.vector_value(zero,instantWindValueTinf);
456 for (
unsigned int i = 0; i < dim; i++)
457 VinfTinf(i) = instantWindValueTinf(i);
458 wind.set_time(initial_time);
460 double FrT = sqrt(VinfTinf*VinfTinf)/sqrt(9.81*transom_draft);
461 double ReT = sqrt(9.81*pow(transom_draft,3.0))/1.307e-6;
462 double eta_dry = fmin(0.05*pow(FrT,2.834)*pow(transom_aspect_ratio,0.1352)*pow(ReT,0.01338),1.0);
468 cout<<
"FrT: "<<FrT<<
" Tar: "<<transom_aspect_ratio<<
" ReT: "<<ReT<<endl;
469 cout<<
"****eta_dry: "<<eta_dry<<endl;
472 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
474 if ( (comp_dom.support_points[i](1) < comp_dom.boat_model.CurrentPointRightTransom(1)) &&
475 (comp_dom.support_points[i](1) >= 0.0) &&
476 (comp_dom.support_points[i](0) > comp_dom.boat_model.CurrentPointCenterTransom(0)-fabs(comp_dom.boat_model.CurrentPointCenterTransom(2)) ) &&
477 (comp_dom.support_points[i](0) < comp_dom.boat_model.CurrentPointCenterTransom(0)+lh*fabs(comp_dom.boat_model.CurrentPointCenterTransom(2)) ) &&
478 (comp_dom.support_points[i](2) > 2.0*comp_dom.boat_model.CurrentPointCenterTransom(2)) )
480 Point <3> dP0 = comp_dom.support_points[i];
483 Handle(Geom_Plane) vertPlane =
new Geom_Plane(0.,1.,0.,-dP0(1));
484 vertPlane->Transform(comp_dom.boat_model.current_loc.Inverted());
485 Handle(Geom_Curve) curve = comp_dom.boat_model.right_transom_bspline;
487 GeomAPI_IntCS Intersector(curve, vertPlane);
488 int npoints = Intersector.NbPoints();
491 double minDistance=1e7;
492 for (
int j=0; j<npoints; ++j)
494 gp_Pnt int_point = Intersector.Point(j+1);
495 int_point.Transform(comp_dom.boat_model.current_loc);
498 if (dP0.
distance(inters) < minDistance)
505 if ( (comp_dom.support_points[i](0) > dP(0)+comp_dom.min_diameter/20.0) &&
506 (comp_dom.support_points[i](0) < dP(0)+lh*fabs(dP(2))+comp_dom.min_diameter/20.0) )
509 double mean_curvature;
512 comp_dom.boat_model.boat_surface_right->normal_projection_and_diff_forms(projection,
517 AssertThrow((dP.
distance(projection) < 1e-4*comp_dom.boat_model.boatWetLength),
ExcMessage(
"Normal projection for surface normal evaluation went wrong!"));
518 double transom_slope = -normal(0)/normal(2);
519 double a = -transom_slope/(lh*fabs(dP(2))) - 1/dP(2)/lh/lh;
520 double x = comp_dom.support_points[i](0)-dP(0);
521 comp_dom.initial_map_points(3*i+2) = a*x*x + transom_slope*x + dP(2);
522 comp_dom.map_points(3*i+2) = comp_dom.initial_map_points(3*i+2);
526 else if ( (comp_dom.support_points[i](1) > comp_dom.boat_model.CurrentPointLeftTransom(1)) &&
527 (comp_dom.support_points[i](1) < 0.0) &&
528 (comp_dom.support_points[i](0) > comp_dom.boat_model.CurrentPointCenterTransom(0)-fabs(comp_dom.boat_model.CurrentPointCenterTransom(2))) &&
529 (comp_dom.support_points[i](0) < comp_dom.boat_model.CurrentPointCenterTransom(0)+lh*fabs(comp_dom.boat_model.CurrentPointCenterTransom(2))) &&
530 (comp_dom.support_points[i](2) > 2.0*comp_dom.boat_model.CurrentPointCenterTransom(2)) )
532 Point <3> dP0 = comp_dom.support_points[i];
535 Handle(Geom_Plane) vertPlane =
new Geom_Plane(0.,1.,0.,-dP0(1));
536 vertPlane->Transform(comp_dom.boat_model.current_loc.Inverted());
537 Handle(Geom_Curve) curve = comp_dom.boat_model.left_transom_bspline;
539 GeomAPI_IntCS Intersector(curve, vertPlane);
540 int npoints = Intersector.NbPoints();
543 double minDistance=1e7;
544 for (
int j=0; j<npoints; ++j)
546 gp_Pnt int_point = Intersector.Point(j+1);
547 int_point.Transform(comp_dom.boat_model.current_loc);
550 if (dP0.
distance(inters) < minDistance)
556 if ( (comp_dom.support_points[i](0) > dP(0)+comp_dom.min_diameter/20.0) &&
557 (comp_dom.support_points[i](0) < dP(0)+lh*fabs(dP(2))+comp_dom.min_diameter/20.0) )
559 double mean_curvature;
562 comp_dom.boat_model.boat_surface_left->normal_projection_and_diff_forms(projection,
566 AssertThrow((dP.
distance(projection) < 1e-4*comp_dom.boat_model.boatWetLength),
ExcMessage(
"Normal projection for surface normal evaluation went wrong!"));
567 double transom_slope = -normal(0)/normal(2);
568 double a = -transom_slope/(lh*fabs(dP(2))) - 1/dP(2)/lh/lh;
569 double x = comp_dom.support_points[i](0)-dP(0);
570 comp_dom.initial_map_points(3*i+2) = a*x*x + transom_slope*x + dP(2);
571 comp_dom.map_points(3*i+2) = comp_dom.initial_map_points(3*i+2);
576 comp_dom.vector_constraints.distribute(comp_dom.initial_map_points);
577 comp_dom.vector_constraints.distribute(comp_dom.map_points);
584 double min_diameter = 1000000000;
585 FEValues<dim-1,dim> fe_v(*comp_dom.mapping, comp_dom.fe, *comp_dom.quadrature,
587 const unsigned int DphiDt_n_q_points = fe_v.n_quadrature_points;
589 cell = comp_dom.dh.begin_active(),
590 endc = comp_dom.dh.end();
592 for (; cell!=endc; ++cell)
594 if ((cell->material_id() == comp_dom.free_sur_ID1 ||
595 cell->material_id() == comp_dom.free_sur_ID2 ||
596 cell->material_id() == comp_dom.free_sur_ID3 ))
600 for (
unsigned int q=0; q<DphiDt_n_q_points; ++q)
604 min_diameter = fmin(min_diameter,2*sqrt(area/3.1415));
608 cout<<
"Min Diameter Corrected: "<<min_diameter<<endl;
610 std::vector<Point<dim> > displaced_support_points(comp_dom.dh.n_dofs());
613 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); i++)
615 dst(i+comp_dom.vector_dh.n_dofs()) = initial_wave_potential.value(displaced_support_points[i]);
619 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); i++)
621 dst(i+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()) =
622 initial_norm_potential_grad.value(displaced_support_points[i]);
642 comp_dom.surface_nodes = 0.0;
643 comp_dom.other_nodes = 1.0;
645 comp_dom.compute_normals_at_nodes(comp_dom.map_points);
646 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
648 if ((comp_dom.flags[i] &
water) || (comp_dom.flags[i] &
boat))
650 bem_dphi_dn(i) = -comp_dom.node_normals[i]*Vinf;
653 comp_dom.surface_nodes(i) = 0;
654 comp_dom.other_nodes(i) = 1;
655 std::set<unsigned int> duplicates = comp_dom.double_nodes_set[i];
659 for (std::set<unsigned int>::iterator pos = duplicates.begin(); pos !=duplicates.end(); pos++)
661 bem_bc += bem_dphi_dn(*pos)/duplicates.size();
663 bem_dphi_dn(i) = bem_bc;
667 (comp_dom.flags[i] &
inflow)
669 bem_dphi_dn(i) = inflow_norm_potential_grad.value(support_points[i]);
674 comp_dom.surface_nodes(i) = 1.0;
675 comp_dom.other_nodes(i) = 0.0;
682 bem.solve(bem_phi, bem_dphi_dn, bem_bc);
684 comp_dom.surface_nodes = surface_nodes_backup;
685 comp_dom.other_nodes = other_nodes_backup;
687 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
689 dst(i+comp_dom.vector_dh.n_dofs()) = bem_phi(i);
690 dst(i+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()) = bem_dphi_dn(i);
700 comp_dom.initial_map_points = comp_dom.map_points;
701 vector_constraints.distribute(comp_dom.map_points);
704 for (
unsigned int i=0; i<comp_dom.vector_dh.n_dofs(); ++i)
706 dst(i) = comp_dom.map_points(i);
711 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
713 if ( ((comp_dom.flags[i] &
boat) &&
717 dst(3*i) -= restart_hull_displacement(0);
718 dst(3*i+1) -= restart_hull_displacement(1);
719 dst(3*i+2) -= restart_hull_displacement(2);
728 std::vector<unsigned int> local_dof_indices (comp_dom.fe.dofs_per_cell);
730 cell = comp_dom.dh.begin_active(),
731 endc = comp_dom.dh.end();
733 for (; cell!=endc; ++cell)
735 cell->get_dof_indices(local_dof_indices);
736 if (cell->material_id() == comp_dom.wall_sur_ID1 ||
737 cell->material_id() == comp_dom.wall_sur_ID2 ||
738 cell->material_id() == comp_dom.wall_sur_ID3 )
739 for (
unsigned int j=0; j<comp_dom.fe.dofs_per_cell; ++j)
741 unsigned int id=local_dof_indices[j];
761 Point<3> Vhull(dst(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()),
762 dst(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+1),
763 dst(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+2));
764 dst(
id+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()) = -comp_dom.node_normals[
id]*(Vinf-Vhull);
770 max_x_coor_value = 0;
771 max_y_coor_value = 0;
772 max_z_coor_value = 0;
773 for (
unsigned int i=0; i < comp_dom.dh.n_dofs(); i++)
777 max_x_coor_value = std::max(max_x_coor_value,std::abs(displaced_support_points[i](0)));
778 max_y_coor_value = std::max(max_y_coor_value,std::abs(displaced_support_points[i](1)));
779 max_z_coor_value = std::max(max_z_coor_value,std::abs(displaced_support_points[i](2)));
782 DphiDt_sys_solution.reinit (comp_dom.dh.n_dofs());
783 DphiDt_sys_solution_2.reinit (comp_dom.dh.n_dofs());
784 DphiDt_sys_solution_3.reinit (comp_dom.dh.n_dofs());
785 break_wave_press.reinit (comp_dom.dh.n_dofs());
787 vector_sys_solution.reinit (comp_dom.vector_dh.n_dofs());
788 vector_sys_solution_2.reinit (comp_dom.vector_dh.n_dofs());
795 std::string filename = ( output_file_name +
"_" +
799 output_results(filename, 0, dst, dummy_sol_dot);
801 comp_dom.old_map_points = comp_dom.map_points;
802 comp_dom.rigid_motion_map_points = 0;
804 last_remesh_time = 0;
807 current_sol_dot = 0.0;
812 restart_flag =
false;
816 if (!comp_dom.no_boat && comp_dom.boat_model.is_transom)
818 double transom_wet_surface = 0;
819 std::vector<Point<3> > vertices;
820 std::vector<CellData<2> > cells;
821 for (
tria_it elem=comp_dom.tria.begin_active(); elem!= comp_dom.tria.end(); ++elem)
823 if ((elem->material_id() == comp_dom.wall_sur_ID1 ||
824 elem->material_id() == comp_dom.wall_sur_ID2 ||
825 elem->material_id() == comp_dom.wall_sur_ID3 ))
827 if (elem->at_boundary())
829 for (
unsigned int f=0; f<GeometryInfo<2>::faces_per_cell; ++f)
830 if ( elem->face(f)->boundary_id() == 32 ||
831 elem->face(f)->boundary_id() == 37 )
833 unsigned int index_0 = comp_dom.find_point_id(elem->face(f)->vertex(0),comp_dom.ref_points);
834 unsigned int index_1 = comp_dom.find_point_id(elem->face(f)->vertex(1),comp_dom.ref_points);
835 if (comp_dom.ref_points[3*index_1](1) < comp_dom.ref_points[3*index_0](1))
837 vertices.push_back(comp_dom.ref_points[3*index_0]);
838 vertices.push_back(comp_dom.ref_points[3*index_1]);
839 vertices.push_back(comp_dom.ref_points[3*index_1]+
840 -1.0*
Point<3>(0.0,0.0,comp_dom.ref_points[3*index_1](2)));
841 vertices.push_back(comp_dom.support_points[index_0]+
842 -1.0*
Point<3>(0.0,0.0,comp_dom.ref_points[3*index_0](2)));
843 cells.resize(cells.size()+1);
844 cells[cells.size()-1].vertices[0]=4*(cells.size()-1)+0;
845 cells[cells.size()-1].vertices[1]=4*(cells.size()-1)+1;
846 cells[cells.size()-1].vertices[2]=4*(cells.size()-1)+2;
847 cells[cells.size()-1].vertices[3]=4*(cells.size()-1)+3;
851 vertices.push_back(comp_dom.support_points[index_1]);
852 vertices.push_back(comp_dom.support_points[index_0]);
853 vertices.push_back(comp_dom.support_points[index_0]+
854 -1.0*
Point<3>(0.0,0.0,comp_dom.ref_points[3*index_0](2)));
855 vertices.push_back(comp_dom.support_points[index_1]+
856 -1.0*
Point<3>(0.0,0.0,comp_dom.ref_points[3*index_1](2)));
857 cells.resize(cells.size()+1);
858 cells[cells.size()-1].vertices[0]=4*(cells.size()-1)+0;
859 cells[cells.size()-1].vertices[1]=4*(cells.size()-1)+1;
860 cells[cells.size()-1].vertices[2]=4*(cells.size()-1)+2;
861 cells[cells.size()-1].vertices[3]=4*(cells.size()-1)+3;
873 transom_tria.create_triangulation_compatibility(vertices, cells, subcelldata );
874 FE_Q<dim-1,dim> transom_fe(1);
875 DoFHandler<dim-1,dim> transom_dh(transom_tria);
876 transom_dh.distribute_dofs(transom_fe);
878 FEValues<dim-1,dim> transom_fe_v(transom_fe, *comp_dom.quadrature,
879 update_values | update_gradients |
880 update_cell_normal_vectors |
881 update_quadrature_points |
884 const unsigned int transom_n_q_points = transom_fe_v.n_quadrature_points;
887 std::vector<double> transom_pressure_quad_values(transom_n_q_points);
888 for (
cell_it cell = transom_dh.begin_active(); cell!=transom_dh.end(); ++cell)
890 transom_fe_v.reinit(cell);
892 for (
unsigned int q=0; q<transom_n_q_points; ++q)
894 transom_wet_surface += 1 * transom_fe_v.JxW(q);
897 ref_transom_wet_surface = transom_wet_surface;
905 ref_cell_areas.reinit(comp_dom.tria.n_active_cells());
906 cell = comp_dom.dh.begin_active(),
907 endc = comp_dom.dh.end();
909 unsigned int count=0;
910 for (; cell!=endc; ++cell)
912 if ((cell->material_id() == comp_dom.wall_sur_ID1 ||
913 cell->material_id() == comp_dom.wall_sur_ID2 ||
914 cell->material_id() == comp_dom.wall_sur_ID3 ))
917 for (
unsigned int q=0; q<DphiDt_n_q_points; ++q)
919 ref_cell_areas(count) += 1.0 * fe_v.JxW(q);
925 cout<<
"££££2 "<<comp_dom.map_points[2067]<<endl;
940 const unsigned int step_number)
942 std::cout<<
"iteration: "<<step_number<<std::endl;
943 std::cout<<std::endl;
945 std::string filename = ( output_file_name +
"_" +
948 output_results(filename, current_time, solution, current_sol_dot);
950 ofstream waterLineFile;
951 waterLineFile.open ((output_file_name+
"_water_line.txt").c_str());
952 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
954 waterLineFile<<comp_dom.support_points[i]<<endl;
955 waterLineFile.close();
964 const unsigned int step_number,
967 std::cout<<
"t = "<<t<<
" TS = "<<step_number<<std::endl;
968 std::cout<<std::endl;
970 std::string filename = ( output_file_name +
"_" +
973 output_results(filename, t, solution, solution_dot);
975 ofstream waterLineFile;
976 waterLineFile.open ((output_file_name+
"_water_line.txt").c_str());
977 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
979 waterLineFile<<comp_dom.support_points[i]<<endl;
980 waterLineFile.close();
986 typedef std::pair<double,unsigned int>
mypair;
989 return l.first < r.first;
996 const unsigned int step_number,
1002 static unsigned int remeshing_counter = 1;
1003 static unsigned int dumping_counter = 1;
1005 if ( t>=dumping_period*dumping_counter )
1007 std::string fname = output_file_name +
"_dump_" +
1010 dump_solution(solution, solution_dot, fname);
1013 if ( t>=remeshing_period*remeshing_counter && comp_dom.dh.n_dofs() < max_number_of_dofs )
1015 ++remeshing_counter;
1016 std::cout<<
"Checking and updating mesh..."<<std::endl;
1020 Point<3> current_hull_displacement;
1021 Point<3> current_hull_displacement_dot;
1023 Point<3> current_hull_velocity_dot;
1024 Point<3> current_hull_ang_velocity;
1025 Point<3> current_hull_ang_velocity_dot;
1027 Point<3> current_hull_quat_vector_dot;
1028 for (
unsigned int k=0; k<3; ++k)
1030 current_hull_displacement(k) = solution(k+3+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs());
1031 current_hull_displacement_dot(k) = solution_dot(k+3+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs());
1032 current_hull_velocity(k) = solution(k+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs());
1033 current_hull_velocity_dot(k) = solution_dot(k+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs());
1034 current_hull_ang_velocity(k) = solution(k+6+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs());
1035 current_hull_ang_velocity_dot(k) = solution_dot(k+6+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs());
1036 current_hull_quat_vector(k) = solution(k+9+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs());
1037 current_hull_quat_vector_dot(k) = solution_dot(k+9+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs());
1039 double current_hull_quat_scalar = solution(12+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs());
1040 double current_hull_quat_scalar_dot = solution_dot(12+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs());
1042 restart_hull_displacement(0) = current_hull_displacement(0);
1043 restart_hull_displacement(1) = current_hull_displacement(1);
1044 restart_hull_displacement(2) = current_hull_displacement(2);
1045 restart_hull_quat_vector(0) = current_hull_quat_vector(0);
1046 restart_hull_quat_vector(1) = current_hull_quat_vector(1);
1047 restart_hull_quat_vector(2) = current_hull_quat_vector(2);
1048 restart_hull_quat_scalar = current_hull_quat_scalar;
1053 Vector<double> rigid_motion_velocities(comp_dom.vector_dh.n_dofs());
1057 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
1059 if ( ((comp_dom.flags[i] &
boat) &&
1067 gp_Pnt original_boat_mesh_point =
Pnt(
Point<3>(comp_dom.ref_points[3*i](0)+comp_dom.old_map_points(3*i),
1068 comp_dom.ref_points[3*i](1)+comp_dom.old_map_points(3*i+1),
1069 comp_dom.ref_points[3*i](2)+comp_dom.old_map_points(3*i+2)));
1070 gp_Pnt boat_mesh_point = original_boat_mesh_point;
1073 boat_mesh_point.Transform(restart_hull_location.Inverted());
1078 double s_x = restart_hull_displacement(0);
1079 double s_y = restart_hull_displacement(1);
1080 double s_z = restart_hull_displacement(2);
1081 double v_x = restart_hull_quat_vector(0);
1082 double v_y = restart_hull_quat_vector(1);
1083 double v_z = restart_hull_quat_vector(2);
1084 double s = restart_hull_quat_scalar;
1086 Point<3> ref_baricenter_pos(comp_dom.boat_model.reference_hull_baricenter(0),
1087 comp_dom.boat_model.reference_hull_baricenter(1),
1088 comp_dom.boat_model.reference_hull_baricenter(2));
1090 Point<3> baricenter_pos(s_x+comp_dom.boat_model.reference_hull_baricenter(0),
1091 s_y+comp_dom.boat_model.reference_hull_baricenter(1),
1092 s_z+comp_dom.boat_model.reference_hull_baricenter(2));
1094 Point<3> RotMatRow1(1-2*v_y*v_y-2*v_z*v_z, 2*v_x*v_y-2*s*v_z, 2*v_x*v_z+2*s*v_y);
1095 Point<3> RotMatRow2(2*v_x*v_y+2*s*v_z, 1-2*v_x*v_x-2*v_z*v_z, 2*v_y*v_z-2*s*v_x);
1096 Point<3> RotMatRow3(2*v_x*v_z-2*s*v_y, 2*v_y*v_z+2*s*v_x, 1-2*v_y*v_y-2*v_x*v_x);
1098 Point<3> ref_point_pos(boat_mesh_point.X(),boat_mesh_point.Y(),boat_mesh_point.Z());
1099 Point<3> rigid_lin_displ(s_x,s_y,s_z);
1100 Point<3> target_point_pos(RotMatRow1*(ref_point_pos+(-1.0)*ref_baricenter_pos),
1101 RotMatRow2*(ref_point_pos+(-1.0)*ref_baricenter_pos),
1102 RotMatRow3*(ref_point_pos+(-1.0)*ref_baricenter_pos));
1103 target_point_pos += baricenter_pos;
1108 comp_dom.rigid_motion_map_points(3*i) = target_point_pos(0)-ref_point_pos(0);
1109 comp_dom.rigid_motion_map_points(3*i+1) = target_point_pos(1)-ref_point_pos(1);
1110 comp_dom.rigid_motion_map_points(3*i+2) = target_point_pos(2)-ref_point_pos(2);
1112 rigid_motion_velocities(3*i) = current_hull_velocity(0)+
1113 current_hull_ang_velocity(1)*(target_point_pos(2)-baricenter_pos(2))-
1114 current_hull_ang_velocity(2)*(target_point_pos(1)-baricenter_pos(1));
1115 rigid_motion_velocities(3*i+1) = current_hull_velocity(1)+
1116 current_hull_ang_velocity(2)*(target_point_pos(0)-baricenter_pos(0))-
1117 current_hull_ang_velocity(0)*(target_point_pos(2)-baricenter_pos(2));
1118 rigid_motion_velocities(3*i+2) = current_hull_velocity(2)+
1119 current_hull_ang_velocity(0)*(target_point_pos(1)-baricenter_pos(1))-
1120 current_hull_ang_velocity(1)*(target_point_pos(0)-baricenter_pos(0));
1134 restart_hull_location = comp_dom.boat_model.set_current_position(restart_hull_displacement,
1135 restart_hull_quat_scalar,
1136 restart_hull_quat_vector);
1137 restart_transom_center_point = comp_dom.boat_model.CurrentPointCenterTransom;
1138 restart_transom_left_point = comp_dom.boat_model.CurrentPointLeftTransom;
1139 restart_transom_right_point = comp_dom.boat_model.CurrentPointRightTransom;
1140 restart_transom_left_tangent = comp_dom.boat_model.current_left_transom_tangent;
1141 restart_transom_right_tangent = comp_dom.boat_model.current_right_transom_tangent;
1148 DoFHandler<dim-1, dim> &vector_dh = comp_dom.vector_dh;
1150 std::vector<Point<dim> > support_points(comp_dom.dh.n_dofs());
1154 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
1156 for (
unsigned int j=0; j<dim; ++j)
1157 disp_vector(i*dim+j) = support_points[i][j];
1165 std::vector<Point<3> > old_points(dh.n_dofs());
1166 old_points = support_points;
1169 comp_dom.compute_curvatures(curvatures);
1172 Vector<float> estimated_error_per_cell(tria.n_active_cells());
1179 for (
unsigned int i=0; i<dh.n_dofs(); ++i)
1180 if (comp_dom.flags[i] &
water)
1181 elevations(i) = displacements(3*i+2);
1199 estimated_error_per_cell);
1212 estimated_error_per_cell);
1216 double max_boat_error = 0;
1217 double max_other_error = 0;
1218 unsigned int counter=0;
1219 for (
cell_it elem=dh.begin_active(); elem!= dh.end(); ++elem)
1221 if ((elem->material_id() == comp_dom.wall_sur_ID1 ||
1222 elem->material_id() == comp_dom.wall_sur_ID2 ||
1223 elem->material_id() == comp_dom.wall_sur_ID3 ))
1225 max_boat_error = fmax(max_boat_error,estimated_error_per_cell(counter));
1228 max_other_error = fmax(max_other_error,estimated_error_per_cell(counter));
1233 for (
cell_it elem=dh.begin_active(); elem!= dh.end(); ++elem)
1235 if ((elem->material_id() == comp_dom.wall_sur_ID1 ||
1236 elem->material_id() == comp_dom.wall_sur_ID2 ||
1237 elem->material_id() == comp_dom.wall_sur_ID3 ))
1238 estimated_error_per_cell(counter) /= fmax(max_boat_error,1e-6);
1240 estimated_error_per_cell(counter) /= fmax(max_other_error,1e-6);
1248 Vector<double> positions_x(comp_dom.dh.n_dofs());
1249 Vector<double> positions_y(comp_dom.dh.n_dofs());
1250 Vector<double> positions_z(comp_dom.dh.n_dofs());
1251 Vector<double> positions_dot_x(comp_dom.dh.n_dofs());
1252 Vector<double> positions_dot_y(comp_dom.dh.n_dofs());
1253 Vector<double> positions_dot_z(comp_dom.dh.n_dofs());
1255 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
1257 positions_x(i) = solution(3*i+0)+comp_dom.rigid_motion_map_points(3*i+0)+comp_dom.ref_points[3*i](0);
1258 positions_y(i) = solution(3*i+1)+comp_dom.rigid_motion_map_points(3*i+1)+comp_dom.ref_points[3*i](1);
1259 positions_z(i) = solution(3*i+2)+comp_dom.rigid_motion_map_points(3*i+2)+comp_dom.ref_points[3*i](2);
1260 positions_dot_x(i) = solution_dot(3*i+0)+rigid_motion_velocities(3*i+0);
1261 positions_dot_y(i) = solution_dot(3*i+1)+rigid_motion_velocities(3*i+1);
1262 positions_dot_z(i) = solution_dot(3*i+2)+rigid_motion_velocities(3*i+2);
1266 std::vector<Vector<double> > all_in;
1267 all_in.push_back((Vector<double>)Phi);
1268 all_in.push_back((Vector<double>)Phi_dot);
1269 all_in.push_back((Vector<double>)dphi_dn);
1270 all_in.push_back((Vector<double>)dphi_dn_dot);
1271 all_in.push_back(positions_x);
1272 all_in.push_back(positions_y);
1273 all_in.push_back(positions_z);
1274 all_in.push_back(positions_dot_x);
1275 all_in.push_back(positions_dot_y);
1276 all_in.push_back(positions_dot_z);
1280 estimated_error_per_cell,
1281 refinement_fraction,
1282 coarsening_fraction,
1283 max_number_of_dofs);
1291 FEValues<dim-1,dim> fe_v(*comp_dom.mapping, comp_dom.fe, *comp_dom.quadrature,
1293 const unsigned int n_q_points = fe_v.n_quadrature_points;
1294 Vector<double> cell_diameters(comp_dom.tria.n_active_cells());
1296 cell = comp_dom.dh.begin_active(),
1297 endc = comp_dom.dh.end();
1300 for (; cell!=endc; ++cell)
1303 for (
unsigned int q=0; q<n_q_points; ++q)
1305 cell_diameters(counter) += fe_v.JxW(q);
1307 cell_diameters(counter) = 2*sqrt(cell_diameters(counter)/3.1415);
1312 if (comp_dom.n_cycles == 0)
1314 for (
cell_it elem=dh.begin_active(); elem!= dh.end(); ++elem)
1316 if (cell_diameters(counter)*8.0/2.0 < comp_dom.min_diameter)
1317 elem->clear_refine_flag();
1319 if (fabs(elem->center()(0)) > 20.0)
1320 elem->clear_refine_flag();
1322 if ((elem->material_id() != comp_dom.wall_sur_ID1) &&
1323 (elem->material_id() != comp_dom.wall_sur_ID2) &&
1324 (elem->material_id() != comp_dom.wall_sur_ID3) &&
1325 (elem->material_id() != comp_dom.free_sur_ID1) &&
1326 (elem->material_id() != comp_dom.free_sur_ID2) &&
1327 (elem->material_id() != comp_dom.free_sur_ID3))
1329 elem->clear_refine_flag();
1330 elem->clear_coarsen_flag();
1333 if ((elem->material_id() == comp_dom.free_sur_ID1 ||
1334 elem->material_id() == comp_dom.free_sur_ID2 ||
1335 elem->material_id() == comp_dom.free_sur_ID3 ))
1337 if ((elem->center().distance(
Point<3>(0.0,0.0,0.0)) > 10.0) &&
1338 elem->at_boundary() )
1339 elem->clear_refine_flag();
1340 elem->clear_coarsen_flag();
1346 typename std::map<tria_it, tria_it>::iterator it;
1347 for (it = comp_dom.boat_to_water_edge_cells.begin();
1348 it != comp_dom.boat_to_water_edge_cells.end(); ++it)
1350 if ( it->first->refine_flag_set() &&
1351 !it->second->refine_flag_set() )
1353 for (
unsigned int i=0; i<it->second->parent()->n_children(); ++i)
1355 it->second->parent()->child(i)->clear_coarsen_flag();
1356 it->second->set_refine_flag();
1358 else if ( it->second->refine_flag_set() &&
1359 !it->first->refine_flag_set() )
1361 for (
unsigned int i=0; i<it->first->parent()->n_children(); ++i)
1363 it->first->parent()->child(i)->clear_coarsen_flag();
1364 it->first->set_refine_flag();
1366 else if ( it->first->coarsen_flag_set() &&
1367 !it->second->coarsen_flag_set() )
1369 for (
unsigned int i=0; i<it->first->parent()->n_children(); ++i)
1371 it->first->parent()->child(i)->clear_coarsen_flag();
1373 else if ( it->second->coarsen_flag_set() &&
1374 !it->first->coarsen_flag_set() )
1376 for (
unsigned int i=0; i<it->second->parent()->n_children(); ++i)
1378 it->second->parent()->child(i)->clear_coarsen_flag();
1383 for (
cell_it elem=dh.begin_active(); elem!= dh.end(); ++elem)
1386 if (cell_diameters(counter)/(adaptive_ref_limit) < comp_dom.min_diameter)
1388 elem->clear_refine_flag();
1391 if (fabs(elem->center()(0)) > comp_dom.boat_model.boatWetLength*5.0)
1392 elem->clear_refine_flag();
1394 if ((elem->material_id() == comp_dom.wall_sur_ID1 ||
1395 elem->material_id() == comp_dom.wall_sur_ID2 ||
1396 elem->material_id() == comp_dom.wall_sur_ID3 ))
1398 elem->clear_refine_flag();
1399 elem->clear_coarsen_flag();
1402 if ((elem->material_id() == comp_dom.free_sur_ID1 ||
1403 elem->material_id() == comp_dom.free_sur_ID2 ||
1404 elem->material_id() == comp_dom.free_sur_ID3 ))
1406 if (elem->at_boundary())
1409 for (
unsigned int f=0; f<GeometryInfo<2>::faces_per_cell; ++f)
1410 if ( elem->face(f)->boundary_id() == 40 ||
1411 elem->face(f)->boundary_id() == 41 ||
1412 elem->face(f)->boundary_id() == 26 ||
1413 elem->face(f)->boundary_id() == 27 ||
1414 elem->face(f)->boundary_id() == 28 ||
1415 elem->face(f)->boundary_id() == 29
1429 elem->clear_refine_flag();
1430 elem->clear_coarsen_flag();
1436 elem->clear_refine_flag();
1437 elem->clear_coarsen_flag();
1445 tria.prepare_coarsening_and_refinement();
1446 soltrans.prepare_for_coarsening_and_refinement(all_in);
1450 tria.execute_coarsening_and_refinement();
1453 dh.distribute_dofs(comp_dom.fe);
1454 vector_dh.distribute_dofs(comp_dom.vector_fe);
1455 comp_dom.map_points.reinit(vector_dh.n_dofs());
1456 comp_dom.smoothing_map_points.reinit(vector_dh.n_dofs());
1457 comp_dom.old_map_points.reinit(vector_dh.n_dofs());
1458 comp_dom.rigid_motion_map_points.reinit(vector_dh.n_dofs());
1459 comp_dom.initial_map_points.reinit(vector_dh.n_dofs());
1460 comp_dom.ref_points.resize(vector_dh.n_dofs());
1462 comp_dom.vector_dh, comp_dom.ref_points);
1463 comp_dom.generate_double_nodes_set();
1466 compute_constraints(constraints, vector_constraints);
1469 this->dofs_number = vector_dh.n_dofs()+dh.n_dofs()+dh.n_dofs()+13;
1473 std::cout<<
"Total number of dofs after refinement: "<<dh.n_dofs()<<std::endl;
1476 Vector<double> new_curvatures(vector_dh.n_dofs());
1478 Vector<double> new_Phi(dh.n_dofs());
1479 Vector<double> new_Phi_dot(dh.n_dofs());
1484 Vector<double> new_positions_x(dh.n_dofs());
1485 Vector<double> new_positions_y(dh.n_dofs());
1486 Vector<double> new_positions_z(dh.n_dofs());
1487 Vector<double> new_positions_dot_x(dh.n_dofs());
1488 Vector<double> new_positions_dot_y(dh.n_dofs());
1489 Vector<double> new_positions_dot_z(dh.n_dofs());
1491 std::vector<Vector<double> > all_out;
1492 all_out.push_back(new_Phi);
1493 all_out.push_back(new_Phi_dot);
1494 all_out.push_back(new_dphi_dn);
1495 all_out.push_back(new_dphi_dn_dot);
1496 all_out.push_back(new_positions_x);
1497 all_out.push_back(new_positions_y);
1498 all_out.push_back(new_positions_z);
1499 all_out.push_back(new_positions_dot_x);
1500 all_out.push_back(new_positions_dot_y);
1501 all_out.push_back(new_positions_dot_z);
1503 soltrans.interpolate(all_in, all_out);
1505 solution.
reinit(dofs_number);
1506 solution_dot.
reinit(dofs_number);
1508 constraints.distribute(all_out[0]);
1509 constraints.distribute(all_out[1]);
1510 constraints.distribute(all_out[2]);
1511 constraints.distribute(all_out[3]);
1512 constraints.distribute(all_out[4]);
1513 constraints.distribute(all_out[5]);
1514 constraints.distribute(all_out[6]);
1515 constraints.distribute(all_out[7]);
1516 constraints.distribute(all_out[8]);
1517 constraints.distribute(all_out[9]);
1520 rigid_motion_velocities.reinit(comp_dom.vector_dh.n_dofs());
1524 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
1526 if ( ((comp_dom.flags[i] &
boat) &&
1534 gp_Pnt original_boat_mesh_point =
Pnt(
Point<3>(comp_dom.ref_points[3*i](0)+comp_dom.old_map_points(3*i),
1535 comp_dom.ref_points[3*i](1)+comp_dom.old_map_points(3*i+1),
1536 comp_dom.ref_points[3*i](2)+comp_dom.old_map_points(3*i+2)));
1537 gp_Pnt boat_mesh_point = original_boat_mesh_point;
1540 boat_mesh_point.Transform(restart_hull_location.Inverted());
1545 double s_x = restart_hull_displacement(0);
1546 double s_y = restart_hull_displacement(1);
1547 double s_z = restart_hull_displacement(2);
1548 double v_x = restart_hull_quat_vector(0);
1549 double v_y = restart_hull_quat_vector(1);
1550 double v_z = restart_hull_quat_vector(2);
1551 double s = restart_hull_quat_scalar;
1553 Point<3> ref_baricenter_pos(comp_dom.boat_model.reference_hull_baricenter(0),
1554 comp_dom.boat_model.reference_hull_baricenter(1),
1555 comp_dom.boat_model.reference_hull_baricenter(2));
1557 Point<3> baricenter_pos(s_x+comp_dom.boat_model.reference_hull_baricenter(0),
1558 s_y+comp_dom.boat_model.reference_hull_baricenter(1),
1559 s_z+comp_dom.boat_model.reference_hull_baricenter(2));
1561 Point<3> RotMatRow1(1-2*v_y*v_y-2*v_z*v_z, 2*v_x*v_y-2*s*v_z, 2*v_x*v_z+2*s*v_y);
1562 Point<3> RotMatRow2(2*v_x*v_y+2*s*v_z, 1-2*v_x*v_x-2*v_z*v_z, 2*v_y*v_z-2*s*v_x);
1563 Point<3> RotMatRow3(2*v_x*v_z-2*s*v_y, 2*v_y*v_z+2*s*v_x, 1-2*v_y*v_y-2*v_x*v_x);
1565 Point<3> ref_point_pos(boat_mesh_point.X(),boat_mesh_point.Y(),boat_mesh_point.Z());
1566 Point<3> rigid_lin_displ(s_x,s_y,s_z);
1567 Point<3> target_point_pos(RotMatRow1*(ref_point_pos+(-1.0)*ref_baricenter_pos),
1568 RotMatRow2*(ref_point_pos+(-1.0)*ref_baricenter_pos),
1569 RotMatRow3*(ref_point_pos+(-1.0)*ref_baricenter_pos));
1570 target_point_pos += baricenter_pos;
1575 comp_dom.rigid_motion_map_points(3*i) = target_point_pos(0)-ref_point_pos(0);
1576 comp_dom.rigid_motion_map_points(3*i+1) = target_point_pos(1)-ref_point_pos(1);
1577 comp_dom.rigid_motion_map_points(3*i+2) = target_point_pos(2)-ref_point_pos(2);
1579 rigid_motion_velocities(3*i) = current_hull_velocity(0)+
1580 current_hull_ang_velocity(1)*(target_point_pos(2)-baricenter_pos(2))-
1581 current_hull_ang_velocity(2)*(target_point_pos(1)-baricenter_pos(1));
1582 rigid_motion_velocities(3*i+1) = current_hull_velocity(1)+
1583 current_hull_ang_velocity(2)*(target_point_pos(0)-baricenter_pos(0))-
1584 current_hull_ang_velocity(0)*(target_point_pos(2)-baricenter_pos(2));
1585 rigid_motion_velocities(3*i+2) = current_hull_velocity(2)+
1586 current_hull_ang_velocity(0)*(target_point_pos(1)-baricenter_pos(1))-
1587 current_hull_ang_velocity(1)*(target_point_pos(0)-baricenter_pos(0));
1602 for (
unsigned int i=0; i<dh.n_dofs(); ++i)
1604 solution(3*i+0) = all_out[4](i)-comp_dom.rigid_motion_map_points(3*i)-comp_dom.ref_points[3*i](0);
1605 solution(3*i+1) = all_out[5](i)-comp_dom.rigid_motion_map_points(3*i+1)-comp_dom.ref_points[3*i](1);
1606 solution(3*i+2) = all_out[6](i)-comp_dom.rigid_motion_map_points(3*i+2)-comp_dom.ref_points[3*i](2);
1607 solution_dot(3*i+0) = all_out[7](i)-rigid_motion_velocities(3*i);
1608 solution_dot(3*i+1) = all_out[8](i)-rigid_motion_velocities(3*i+1);
1609 solution_dot(3*i+2) = all_out[9](i)-rigid_motion_velocities(3*i+2);
1610 solution(i+vector_dh.n_dofs()) = all_out[0](i);
1611 solution_dot(i+vector_dh.n_dofs()) = all_out[1](i);
1612 solution(i+vector_dh.n_dofs()+dh.n_dofs()) = all_out[2](i);
1613 solution_dot(i+vector_dh.n_dofs()+dh.n_dofs()) = all_out[3](i);
1617 for (
unsigned int k=0; k<3; ++k)
1619 solution(k+vector_dh.n_dofs()+dh.n_dofs()+dh.n_dofs()) = current_hull_velocity(k);
1620 solution_dot(k+vector_dh.n_dofs()+dh.n_dofs()+dh.n_dofs()) = current_hull_velocity_dot(k);
1621 solution(k+3+vector_dh.n_dofs()+dh.n_dofs()+dh.n_dofs()) = current_hull_displacement(k);
1622 solution_dot(k+3+vector_dh.n_dofs()+dh.n_dofs()+dh.n_dofs()) = current_hull_displacement_dot(k);
1623 solution(k+6+vector_dh.n_dofs()+dh.n_dofs()+dh.n_dofs()) = current_hull_ang_velocity(k);
1624 solution_dot(k+6+vector_dh.n_dofs()+dh.n_dofs()+dh.n_dofs()) = current_hull_ang_velocity_dot(k);
1625 solution(k+9+vector_dh.n_dofs()+dh.n_dofs()+dh.n_dofs()) = current_hull_quat_vector(k);
1626 solution_dot(k+9+vector_dh.n_dofs()+dh.n_dofs()+dh.n_dofs()) = current_hull_quat_vector_dot(k);
1628 solution(12+vector_dh.n_dofs()+dh.n_dofs()+dh.n_dofs()) = current_hull_quat_scalar;
1629 solution_dot(12+vector_dh.n_dofs()+dh.n_dofs()+dh.n_dofs()) = current_hull_quat_scalar_dot;
1633 for (
unsigned int i=0; i<vector_dh.n_dofs(); ++i)
1635 comp_dom.map_points(i) = solution(i)+comp_dom.rigid_motion_map_points(i);
1640 DXDt_and_DphiDt_vector.
reinit(vector_dh.n_dofs()+dh.n_dofs());
1642 DphiDt_sparsity_pattern.reinit (comp_dom.dh.n_dofs(),
1643 comp_dom.dh.n_dofs(),
1644 comp_dom.dh.max_couplings_between_dofs());
1645 vector_sparsity_pattern.reinit (comp_dom.vector_dh.n_dofs(),
1646 comp_dom.vector_dh.n_dofs(),
1647 comp_dom.vector_dh.max_couplings_between_dofs());
1650 DphiDt_sparsity_pattern.compress();
1653 vector_sparsity_pattern.compress();
1655 working_map_points.reinit (comp_dom.vector_dh.n_dofs());
1656 working_nodes_velocities.reinit(comp_dom.vector_dh.n_dofs());
1657 nodes_pos_res.reinit(comp_dom.vector_dh.n_dofs());
1658 nodes_ref_surf_dist.reinit(comp_dom.vector_dh.n_dofs());
1659 nodes_diff_jac_x_delta.reinit(dofs_number);
1660 nodes_alg_jac_x_delta.reinit(dofs_number);
1661 dae_nonlin_residual.reinit(dofs_number);
1662 dae_linear_step_residual.reinit(dofs_number);
1663 current_sol.reinit(dofs_number);
1664 current_sol_dot.reinit(dofs_number);
1665 bem_residual.reinit (comp_dom.dh.n_dofs());
1666 bem_phi.reinit(comp_dom.dh.n_dofs());
1667 bem_dphi_dn.reinit(comp_dom.dh.n_dofs());
1668 temp_src.reinit(comp_dom.vector_dh.n_dofs());
1669 break_wave_press.reinit(comp_dom.dh.n_dofs());
1676 support_points.resize(dh.n_dofs());
1677 DoFTools::map_dofs_to_support_points<2, 3>( *comp_dom.mapping, dh, support_points);
1678 std::vector<bool> new_boundary_dofs(vector_dh.n_dofs());
1679 std::vector< bool > comp_sel(3,
true);
1681 for (
unsigned int i=0; i<dh.n_dofs(); ++i)
1682 for (
unsigned int j=0; j<old_points.
size(); ++j)
1683 if (old_points[j].distance(support_points[i]) < 1e-5)
1685 new_boundary_dofs[3*i] = 1;
1686 new_boundary_dofs[3*i+1] = 1;
1687 new_boundary_dofs[3*i+2] = 1;
1691 for (
unsigned int i=0; i<comp_dom.vector_dh.n_dofs(); ++i)
1693 comp_dom.map_points(i) = solution(i)+comp_dom.rigid_motion_map_points(i);
1698 make_edges_conformal(solution, solution_dot, t, step_number, h);
1699 make_edges_conformal(solution, solution_dot, t, step_number, h);
1700 remove_transom_hanging_nodes(solution, solution_dot, t, step_number, h);
1701 make_edges_conformal(solution, solution_dot, t, step_number, h);
1702 make_edges_conformal(solution, solution_dot, t, step_number, h);
1706 for (
unsigned int k=0; k<3; ++k)
1708 solution(k+vector_dh.n_dofs()+dh.n_dofs()+dh.n_dofs()) = current_hull_velocity(k);
1709 solution_dot(k+vector_dh.n_dofs()+dh.n_dofs()+dh.n_dofs()) = current_hull_velocity_dot(k);
1710 solution(k+3+vector_dh.n_dofs()+dh.n_dofs()+dh.n_dofs()) = current_hull_displacement(k);
1711 solution_dot(k+3+vector_dh.n_dofs()+dh.n_dofs()+dh.n_dofs()) = current_hull_displacement_dot(k);
1712 solution(k+6+vector_dh.n_dofs()+dh.n_dofs()+dh.n_dofs()) = current_hull_ang_velocity(k);
1713 solution_dot(k+6+vector_dh.n_dofs()+dh.n_dofs()+dh.n_dofs()) = current_hull_ang_velocity_dot(k);
1714 solution(k+9+vector_dh.n_dofs()+dh.n_dofs()+dh.n_dofs()) = current_hull_quat_vector(k);
1715 solution_dot(k+9+vector_dh.n_dofs()+dh.n_dofs()+dh.n_dofs()) = current_hull_quat_vector_dot(k);
1717 solution(12+vector_dh.n_dofs()+dh.n_dofs()+dh.n_dofs()) = current_hull_quat_scalar;
1718 solution_dot(12+vector_dh.n_dofs()+dh.n_dofs()+dh.n_dofs()) = current_hull_quat_scalar_dot;
1723 if (!comp_dom.no_boat)
1724 comp_dom.evaluate_ref_surf_distances(nodes_ref_surf_dist,
false);
1725 comp_dom.map_points -= nodes_ref_surf_dist;
1726 comp_dom.update_support_points();
1727 for (
unsigned int i=0; i<comp_dom.vector_dh.n_dofs(); ++i)
1729 solution(i) = comp_dom.map_points(i)-comp_dom.rigid_motion_map_points(i);
1742 for (
unsigned smooth_id=0; smooth_id<comp_dom.line_smoothers.size(); ++smooth_id)
1744 Vector<double> &old_lengths = comp_dom.line_smoothers[smooth_id]->get_lengths_before_smoothing();
1745 Vector<double> &new_lengths = comp_dom.line_smoothers[smooth_id]->get_lengths_after_smoothing();
1746 std::vector<unsigned int> &indices = comp_dom.line_smoothers[smooth_id]->get_node_indices();
1747 Vector<double> old_potentials(old_lengths.
size());
1748 Vector<double> old_vx(old_lengths.
size());
1749 Vector<double> old_vy(old_lengths.
size());
1751 for (
unsigned int i=0; i<old_lengths.
size(); ++i)
1753 old_potentials(i) = solution(indices[i]+vector_dh.n_dofs());
1754 old_vx(i) = solution_dot(3*indices[i]);
1755 old_vy(i) = solution_dot(3*indices[i]+1);
1761 for (
unsigned int i=1; i<old_lengths.
size()-1; ++i)
1763 unsigned int jj=1000000;
1764 for (
unsigned int j=1; j<old_lengths.
size(); ++j)
1766 if (new_lengths(i) < old_lengths(j))
1772 double fraction = (new_lengths(i)-old_lengths(jj-1))/(old_lengths(jj)-old_lengths(jj-1));
1773 solution(indices[i]+vector_dh.n_dofs()) = old_potentials(jj-1)+(old_potentials(jj)-old_potentials(jj-1))*fraction;
1780 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
1782 if ( (!(comp_dom.flags[i] &
near_boat)==0) &&
1785 solution_dot(3*i) = 0;
1786 solution_dot(3*i+1) = 0;
1792 if (!comp_dom.no_boat && comp_dom.boat_model.is_transom)
1794 comp_dom.update_support_points();
1795 double transom_draft = fabs(comp_dom.boat_model.CurrentPointCenterTransom(2));
1798 double transom_aspect_ratio = (fabs(comp_dom.boat_model.CurrentPointLeftTransom(1))+
1799 fabs(comp_dom.boat_model.CurrentPointRightTransom(1)))/transom_draft;
1801 wind.set_time(100000000.0);
1802 Vector<double> instantWindValueTinf(dim);
1804 wind.vector_value(zero,instantWindValueTinf);
1806 for (
unsigned int i = 0; i < dim; i++)
1807 VinfTinf(i) = instantWindValueTinf(i);
1808 wind.set_time(initial_time);
1810 double FrT = sqrt(VinfTinf*VinfTinf)/sqrt(9.81*transom_draft);
1811 double ReT = sqrt(9.81*pow(transom_draft,3.0))/1.307e-6;
1812 double eta_dry = fmin(0.05*pow(FrT,2.834)*pow(transom_aspect_ratio,0.1352)*pow(ReT,0.01338),1.0);
1819 cout<<
"****eta_dry: "<<eta_dry<<endl;
1822 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
1824 comp_dom.initial_map_points(3*i+2) = 0.0;
1827 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
1829 if ( (comp_dom.support_points[i](1) < comp_dom.boat_model.PointRightTransom(1)) &&
1830 (comp_dom.support_points[i](1) >= 0.0) &&
1831 (comp_dom.support_points[i](0) > comp_dom.boat_model.PointCenterTransom(0)-fabs(comp_dom.boat_model.PointCenterTransom(2)) ) &&
1832 (comp_dom.support_points[i](0) < comp_dom.boat_model.PointCenterTransom(0)+lh*fabs(comp_dom.boat_model.PointCenterTransom(2)) ) &&
1833 (comp_dom.support_points[i](2) > 2.0*comp_dom.boat_model.CurrentPointCenterTransom(2)) )
1835 Point <3> dP0 = comp_dom.support_points[i];
1838 Handle(Geom_Plane) vertPlane =
new Geom_Plane(0.,1.,0.,-dP0(1));
1839 vertPlane->Transform(comp_dom.boat_model.current_loc.Inverted());
1840 Handle(Geom_Curve) curve = comp_dom.boat_model.right_transom_bspline;
1842 GeomAPI_IntCS Intersector(curve, vertPlane);
1843 int npoints = Intersector.NbPoints();
1846 double minDistance=1e7;
1847 for (
int j=0; j<npoints; ++j)
1849 gp_Pnt int_point = Intersector.Point(j+1);
1850 int_point.Transform(comp_dom.boat_model.current_loc);
1853 if (dP0.
distance(inters) < minDistance)
1855 minDistance = dP0.
distance(inters);
1860 if ( (comp_dom.ref_points[i](0) > dP(0)+comp_dom.min_diameter/20.0) &&
1861 (comp_dom.ref_points[i](0) < dP(0)+lh*fabs(dP(2))+comp_dom.min_diameter/20.0) )
1863 double mean_curvature;
1866 comp_dom.boat_model.boat_surface_right->normal_projection_and_diff_forms(projection,
1871 AssertThrow((dP.
distance(projection) < 1e-4*comp_dom.boat_model.boatWetLength),
ExcMessage(
"Normal projection for surface normal evaluation went wrong!"));
1872 double transom_slope = -normal(0)/normal(2);
1873 double a = -transom_slope/(lh*fabs(dP(2))) - 1/dP(2)/lh/lh;
1874 double x = comp_dom.support_points[i](0)-dP(0);
1875 comp_dom.initial_map_points(3*i+2) = a*x*x + transom_slope*x + dP(2);
1880 else if ( (comp_dom.support_points[i](1) > comp_dom.boat_model.PointLeftTransom(1)) &&
1881 (comp_dom.support_points[i](1) < 0.0) &&
1882 (comp_dom.support_points[i](0) > comp_dom.boat_model.PointCenterTransom(0)-fabs(comp_dom.boat_model.PointCenterTransom(2))) &&
1883 (comp_dom.support_points[i](0) < comp_dom.boat_model.PointCenterTransom(0)+lh*fabs(comp_dom.boat_model.PointCenterTransom(2))) &&
1884 (comp_dom.support_points[i](2) > 2.0*comp_dom.boat_model.CurrentPointCenterTransom(2)) )
1886 Point <3> dP0 = comp_dom.support_points[i];
1889 Handle(Geom_Plane) vertPlane =
new Geom_Plane(0.,1.,0.,-dP0(1));
1890 vertPlane->Transform(comp_dom.boat_model.current_loc.Inverted());
1891 Handle(Geom_Curve) curve = comp_dom.boat_model.left_transom_bspline;
1893 GeomAPI_IntCS Intersector(curve, vertPlane);
1894 int npoints = Intersector.NbPoints();
1897 double minDistance=1e7;
1898 for (
int j=0; j<npoints; ++j)
1900 gp_Pnt int_point = Intersector.Point(j+1);
1901 int_point.Transform(comp_dom.boat_model.current_loc);
1904 if (dP0.
distance(inters) < minDistance)
1906 minDistance = dP0.
distance(inters);
1910 if ( (comp_dom.ref_points[i](0) > dP(0)+comp_dom.min_diameter/20.0) &&
1911 (comp_dom.ref_points[i](0) < dP(0)+lh*fabs(dP(2))+comp_dom.min_diameter/20.0) )
1913 double mean_curvature;
1916 comp_dom.boat_model.boat_surface_left->normal_projection_and_diff_forms(projection,
1921 AssertThrow((dP.
distance(projection) < 1e-4*comp_dom.boat_model.boatWetLength),
ExcMessage(
"Normal projection for surface normal evaluation went wrong!"));
1922 double transom_slope = -normal(0)/normal(2);
1923 double a = -transom_slope/(lh*fabs(dP(2))) - 1/dP(2)/lh/lh;
1924 double x = comp_dom.support_points[i](0)-dP(0);
1925 comp_dom.initial_map_points(3*i+2) = a*x*x + transom_slope*x + dP(2);
1930 comp_dom.vector_constraints.distribute(comp_dom.initial_map_points);
1935 for (
unsigned int i=0; i<comp_dom.vector_dh.n_dofs(); ++i)
1937 solution(i) = comp_dom.map_points(i)-comp_dom.rigid_motion_map_points(i);
1943 Vector<double> instantWindValue(dim);
1945 wind.vector_value(zero,instantWindValue);
1947 for (
unsigned int i = 0; i < dim; i++)
1948 Vinf(i) = instantWindValue(i);
1949 Point<dim> Vh(0.0,0.0,0.01*2*dealii::numbers::PI*cos(2*dealii::numbers::PI*t));
1951 for (
unsigned int i=0; i<dh.n_dofs(); ++i)
1953 if ( comp_dom.flags[i] &
boat )
1955 solution(i+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()) = comp_dom.node_normals[i]*(Vh-Vinf);
1958 differential_components();
1961 current_sol = solution;
1962 current_sol_dot = solution_dot;
1963 last_remesh_time = t;
1964 comp_dom.old_map_points = comp_dom.map_points;
1965 comp_dom.rigid_motion_map_points = 0;
1968 prepare_restart(t, solution, solution_dot,
true);
1974 if (!comp_dom.no_boat && comp_dom.boat_model.is_transom)
1976 double transom_wet_surface = 0;
1977 std::vector<Point<3> > vertices;
1978 std::vector<CellData<2> > cells;
1979 for (
tria_it elem=comp_dom.tria.begin_active(); elem!= comp_dom.tria.end(); ++elem)
1981 if ((elem->material_id() == comp_dom.wall_sur_ID1 ||
1982 elem->material_id() == comp_dom.wall_sur_ID2 ||
1983 elem->material_id() == comp_dom.wall_sur_ID3 ))
1985 if (elem->at_boundary())
1987 for (
unsigned int f=0; f<GeometryInfo<2>::faces_per_cell; ++f)
1988 if ( elem->face(f)->boundary_id() == 32 ||
1989 elem->face(f)->boundary_id() == 37 )
1991 unsigned int index_0 = comp_dom.find_point_id(elem->face(f)->vertex(0),comp_dom.ref_points);
1992 unsigned int index_1 = comp_dom.find_point_id(elem->face(f)->vertex(1),comp_dom.ref_points);
1993 if (comp_dom.ref_points[3*index_1](1) < comp_dom.ref_points[3*index_0](1))
1995 vertices.push_back(comp_dom.ref_points[3*index_0]);
1996 vertices.push_back(comp_dom.ref_points[3*index_1]);
1997 vertices.push_back(comp_dom.ref_points[3*index_1]+
1998 -1.0*
Point<3>(0.0,0.0,comp_dom.ref_points[3*index_1](2)));
1999 vertices.push_back(comp_dom.support_points[index_0]+
2000 -1.0*
Point<3>(0.0,0.0,comp_dom.ref_points[3*index_0](2)));
2001 cells.resize(cells.size()+1);
2002 cells[cells.size()-1].vertices[0]=4*(cells.size()-1)+0;
2003 cells[cells.size()-1].vertices[1]=4*(cells.size()-1)+1;
2004 cells[cells.size()-1].vertices[2]=4*(cells.size()-1)+2;
2005 cells[cells.size()-1].vertices[3]=4*(cells.size()-1)+3;
2009 vertices.push_back(comp_dom.support_points[index_1]);
2010 vertices.push_back(comp_dom.support_points[index_0]);
2011 vertices.push_back(comp_dom.support_points[index_0]+
2012 -1.0*
Point<3>(0.0,0.0,comp_dom.ref_points[3*index_0](2)));
2013 vertices.push_back(comp_dom.support_points[index_1]+
2014 -1.0*
Point<3>(0.0,0.0,comp_dom.ref_points[3*index_1](2)));
2015 cells.resize(cells.size()+1);
2016 cells[cells.size()-1].vertices[0]=4*(cells.size()-1)+0;
2017 cells[cells.size()-1].vertices[1]=4*(cells.size()-1)+1;
2018 cells[cells.size()-1].vertices[2]=4*(cells.size()-1)+2;
2019 cells[cells.size()-1].vertices[3]=4*(cells.size()-1)+3;
2031 transom_tria.create_triangulation_compatibility(vertices, cells, subcelldata );
2032 FE_Q<dim-1,dim> transom_fe(1);
2033 DoFHandler<dim-1,dim> transom_dh(transom_tria);
2034 transom_dh.distribute_dofs(transom_fe);
2036 FEValues<dim-1,dim> transom_fe_v(transom_fe, *comp_dom.quadrature,
2037 update_values | update_gradients |
2038 update_cell_normal_vectors |
2039 update_quadrature_points |
2042 const unsigned int transom_n_q_points = transom_fe_v.n_quadrature_points;
2045 std::vector<double> transom_pressure_quad_values(transom_n_q_points);
2046 for (
cell_it cell = transom_dh.begin_active(); cell!=transom_dh.
end(); ++cell)
2048 transom_fe_v.reinit(cell);
2050 for (
unsigned int q=0; q<transom_n_q_points; ++q)
2052 transom_wet_surface += 1 * transom_fe_v.JxW(q);
2055 ref_transom_wet_surface = transom_wet_surface;
2061 const unsigned int DphiDt_n_q_points = fe_v.n_quadrature_points;
2062 ref_cell_areas.reinit(comp_dom.tria.n_active_cells());
2063 cell = comp_dom.dh.begin_active(),
2064 endc = comp_dom.dh.
end();
2066 unsigned int count=0;
2067 for (; cell!=endc; ++cell)
2069 if ((cell->material_id() == comp_dom.wall_sur_ID1 ||
2070 cell->material_id() == comp_dom.wall_sur_ID2 ||
2071 cell->material_id() == comp_dom.wall_sur_ID3 ))
2074 for (
unsigned int q=0; q<DphiDt_n_q_points; ++q)
2076 ref_cell_areas(count) += 1.0 * fe_v.JxW(q);
2086 std::cout<<
"...done checking and updating mesh"<<std::endl;
2094 else if ( (t>=remeshing_period*remeshing_counter && comp_dom.dh.n_dofs() > max_number_of_dofs) )
2097 current_sol = solution;
2098 current_sol_dot = solution_dot;
2109 FEValues<dim-1,dim> fe_v(*comp_dom.mapping, comp_dom.fe, *comp_dom.quadrature,
2111 const unsigned int DphiDt_n_q_points = fe_v.n_quadrature_points;
2115 cell = comp_dom.dh.begin_active(),
2116 endc = comp_dom.dh.
end();
2118 unsigned int count=0;
2120 double min_ratio =1.0;
2121 for (; cell!=endc; ++cell)
2123 if ((cell->material_id() == comp_dom.wall_sur_ID1 ||
2124 cell->material_id() == comp_dom.wall_sur_ID2 ||
2125 cell->material_id() == comp_dom.wall_sur_ID3 ))
2128 for (
unsigned int q=0; q<DphiDt_n_q_points; ++q)
2130 cell_areas(count) += 1.0 * fe_v.JxW(q);
2133 min_ratio = fmin(min_ratio,cell_areas(count)/ref_cell_areas(count));
2134 if (cell_areas(count)/ref_cell_areas(count) < 0.5)
2141 cout<<
"Min Areas Ratio For Smoothing: "<<min_ratio<<endl;
2146 Point<3> current_hull_displacement;
2147 Point<3> current_hull_displacement_dot;
2149 Point<3> current_hull_velocity_dot;
2150 Point<3> current_hull_ang_velocity;
2151 Point<3> current_hull_ang_velocity_dot;
2153 Point<3> current_hull_quat_vector_dot;
2154 for (
unsigned int k=0; k<3; ++k)
2156 current_hull_displacement(k) = solution(k+3+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs());
2157 current_hull_displacement_dot(k) = solution_dot(k+3+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs());
2158 current_hull_velocity(k) = solution(k+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs());
2159 current_hull_velocity_dot(k) = solution_dot(k+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs());
2160 current_hull_ang_velocity(k) = solution(k+6+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs());
2161 current_hull_ang_velocity_dot(k) = solution_dot(k+6+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs());
2162 current_hull_quat_vector(k) = solution(k+9+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs());
2163 current_hull_quat_vector_dot(k) = solution_dot(k+9+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs());
2165 double current_hull_quat_scalar = solution(12+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs());
2166 double current_hull_quat_scalar_dot = solution_dot(12+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs());
2168 restart_hull_displacement(0) = current_hull_displacement(0);
2169 restart_hull_displacement(1) = current_hull_displacement(1);
2170 restart_hull_displacement(2) = current_hull_displacement(2);
2171 restart_hull_quat_vector(0) = current_hull_quat_vector(0);
2172 restart_hull_quat_vector(1) = current_hull_quat_vector(1);
2173 restart_hull_quat_vector(2) = current_hull_quat_vector(2);
2174 restart_hull_quat_scalar = current_hull_quat_scalar;
2178 Vector<double> rigid_motion_velocities(comp_dom.vector_dh.n_dofs());
2179 restart_hull_location = comp_dom.boat_model.set_current_position(restart_hull_displacement,
2180 restart_hull_quat_scalar,
2181 restart_hull_quat_vector);
2187 nodes_ref_surf_dist = 0.0;
2188 if (!comp_dom.no_boat)
2189 comp_dom.evaluate_ref_surf_distances(nodes_ref_surf_dist,
true);
2190 differential_components();
2191 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
2192 if ( ((comp_dom.flags[i] &
boat) &&
2196 for (
unsigned int d=0; d<3; ++d)
2198 comp_dom.map_points(3*i+d) -= nodes_ref_surf_dist(3*i+d);
2199 comp_dom.old_map_points(3*i+d) = comp_dom.map_points(3*i+d);
2201 if (constraints.is_constrained(i))
2202 for (
unsigned int d=0; d<3; ++d)
2203 solution(i) = comp_dom.map_points(i);
2206 gp_Pnt original_boat_mesh_point =
Pnt(
Point<3>(comp_dom.ref_points[3*i](0)+comp_dom.old_map_points(3*i),
2207 comp_dom.ref_points[3*i](1)+comp_dom.old_map_points(3*i+1),
2208 comp_dom.ref_points[3*i](2)+comp_dom.old_map_points(3*i+2)));
2209 gp_Pnt boat_mesh_point = original_boat_mesh_point;
2212 boat_mesh_point.Transform(restart_hull_location.Inverted());
2213 Point<3> rigid_displ =
Pnt(boat_mesh_point)+(-1.0*
Pnt(original_boat_mesh_point));
2214 for (
unsigned int d=0; d<3; ++d)
2215 comp_dom.rigid_motion_map_points(3*i+d) = rigid_displ(d);
2216 for (
unsigned int d=0; d<3; ++d)
2217 solution(3*i+d) = comp_dom.map_points(3*i+d)-comp_dom.rigid_motion_map_points(3*i+d);
2223 current_sol = solution;
2224 current_sol_dot = solution_dot;
2228 prepare_restart(t, solution, solution_dot,
false);
2231 ref_cell_areas = 0.0;
2232 cell = comp_dom.dh.begin_active(),
2233 endc = comp_dom.dh.end();
2235 unsigned int count=0;
2236 for (; cell!=endc; ++cell)
2238 if ((cell->material_id() == comp_dom.wall_sur_ID1 ||
2239 cell->material_id() == comp_dom.wall_sur_ID2 ||
2240 cell->material_id() == comp_dom.wall_sur_ID3 ))
2243 for (
unsigned int q=0; q<DphiDt_n_q_points; ++q)
2245 ref_cell_areas(count) += 1.0 * fe_v.JxW(q);
2277 const unsigned int step_number,
2280 std::cout<<
"Restoring mesh conformity..."<<std::endl;
2292 double hull_quat_scal;
2293 double hull_quat_scal_dot;
2294 for (
unsigned int d=0; d<3; ++d)
2296 hull_lin_vel(d) = solution(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+d);
2297 hull_lin_displ(d) = solution(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+3+d);
2298 hull_lin_vel_dot(d) = solution_dot(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+d);
2299 hull_lin_displ_dot(d) = solution_dot(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+3+d);
2300 hull_ang_vel(d) = solution(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+6+d);
2301 hull_ang_vel_dot(d) = solution_dot(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+6+d);
2302 hull_quat_vect(d) = solution(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+9+d);
2303 hull_quat_vect_dot(d) = solution_dot(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+9+d);
2305 hull_quat_scal = solution(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+12);
2306 hull_quat_scal_dot = solution_dot(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+12);
2308 cout<<
"*Hull Rigid Displacement: "<<hull_lin_displ<<endl;
2309 cout<<
"*Hull Rigid Velocity: "<<hull_lin_vel<<endl;
2310 cout<<
"*Hull Angualr Velocity: "<<hull_lin_vel<<endl;
2313 Vector<double> rigid_motion_velocities(comp_dom.vector_dh.n_dofs());
2317 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
2319 if ( ((comp_dom.flags[i] &
boat) &&
2327 gp_Pnt original_boat_mesh_point =
Pnt(
Point<3>(comp_dom.ref_points[3*i](0)+comp_dom.old_map_points(3*i),
2328 comp_dom.ref_points[3*i](1)+comp_dom.old_map_points(3*i+1),
2329 comp_dom.ref_points[3*i](2)+comp_dom.old_map_points(3*i+2)));
2330 gp_Pnt boat_mesh_point = original_boat_mesh_point;
2333 boat_mesh_point.Transform(restart_hull_location.Inverted());
2338 double s_x = hull_lin_displ(0);
2339 double s_y = hull_lin_displ(1);
2340 double s_z = hull_lin_displ(2);
2341 double v_x = hull_quat_vect(0);
2342 double v_y = hull_quat_vect(1);
2343 double v_z = hull_quat_vect(2);
2344 double s = hull_quat_scal;
2346 Point<3> ref_baricenter_pos(comp_dom.boat_model.reference_hull_baricenter(0),
2347 comp_dom.boat_model.reference_hull_baricenter(1),
2348 comp_dom.boat_model.reference_hull_baricenter(2));
2350 Point<3> baricenter_pos(s_x+comp_dom.boat_model.reference_hull_baricenter(0),
2351 s_y+comp_dom.boat_model.reference_hull_baricenter(1),
2352 s_z+comp_dom.boat_model.reference_hull_baricenter(2));
2354 Point<3> RotMatRow1(1-2*v_y*v_y-2*v_z*v_z, 2*v_x*v_y-2*s*v_z, 2*v_x*v_z+2*s*v_y);
2355 Point<3> RotMatRow2(2*v_x*v_y+2*s*v_z, 1-2*v_x*v_x-2*v_z*v_z, 2*v_y*v_z-2*s*v_x);
2356 Point<3> RotMatRow3(2*v_x*v_z-2*s*v_y, 2*v_y*v_z+2*s*v_x, 1-2*v_y*v_y-2*v_x*v_x);
2358 Point<3> ref_point_pos(boat_mesh_point.X(),boat_mesh_point.Y(),boat_mesh_point.Z());
2359 Point<3> rigid_lin_displ(s_x,s_y,s_z);
2360 Point<3> target_point_pos(RotMatRow1*(ref_point_pos+(-1.0)*ref_baricenter_pos),
2361 RotMatRow2*(ref_point_pos+(-1.0)*ref_baricenter_pos),
2362 RotMatRow3*(ref_point_pos+(-1.0)*ref_baricenter_pos));
2363 target_point_pos += baricenter_pos;
2368 comp_dom.rigid_motion_map_points(3*i) = target_point_pos(0)-ref_point_pos(0);
2369 comp_dom.rigid_motion_map_points(3*i+1) = target_point_pos(1)-ref_point_pos(1);
2370 comp_dom.rigid_motion_map_points(3*i+2) = target_point_pos(2)-ref_point_pos(2);
2372 rigid_motion_velocities(3*i) = hull_lin_vel(0)+
2373 hull_ang_vel(1)*(target_point_pos(2)-baricenter_pos(2))-
2374 hull_ang_vel(2)*(target_point_pos(1)-baricenter_pos(1));
2375 rigid_motion_velocities(3*i+1) = hull_lin_vel(1)+
2376 hull_ang_vel(2)*(target_point_pos(0)-baricenter_pos(0))-
2377 hull_ang_vel(0)*(target_point_pos(2)-baricenter_pos(2));
2378 rigid_motion_velocities(3*i+2) = hull_lin_vel(2)+
2379 hull_ang_vel(0)*(target_point_pos(1)-baricenter_pos(1))-
2380 hull_ang_vel(1)*(target_point_pos(0)-baricenter_pos(0));
2399 DoFHandler<dim-1, dim> &vector_dh = comp_dom.vector_dh;
2402 std::vector<Point<dim> > support_points(dh.n_dofs());
2412 std::vector<Point<3> > old_points(dh.n_dofs());
2413 old_points = support_points;
2416 comp_dom.surface_smoother->compute_curvatures(curvatures);
2420 std::vector<Point<3> > ref_points(dh.n_dofs());
2424 for (
unsigned int i=0; i<dh.n_dofs(); ++i)
2426 if ((comp_dom.flags[i] &
edge) &&
2427 (comp_dom.double_nodes_set[i].size() == 1) )
2431 std::vector<Point<3> > nodes(2);
2432 for (
unsigned int kk=0; kk<2; ++kk)
2435 for (
unsigned int f=0; f<GeometryInfo<2>::faces_per_cell; ++f)
2437 if (cell->face(f)->at_boundary())
2439 if (ref_points[i].distance(cell->face(f)->vertex(0)) <tol)
2440 nodes[kk] = cell->face(f)->vertex(1);
2441 else if (ref_points[i].distance(cell->face(f)->vertex(1)) <tol)
2442 nodes[kk] = cell->face(f)->vertex(0);
2447 Point<3> parent_face_center = 0.5*(nodes[0]+nodes[1]);
2450 for (
unsigned int f=0; f<GeometryInfo<2>::faces_per_cell; ++f)
2451 if (cell1->face(f)->at_boundary())
2453 for (
typename std::set<tria_it>::iterator jt=comp_dom.edge_cells.begin(); jt != comp_dom.edge_cells.end(); ++jt)
2454 for (
unsigned int d=0; d<GeometryInfo<2>::faces_per_cell; ++d)
2455 if ((*jt)->face(d)->at_boundary())
2456 if ( parent_face_center.
distance((*jt)->face(d)->center()) < tol)
2459 if ((d==0) || (d==1))
2470 Vector<double> positions_x(comp_dom.dh.n_dofs());
2471 Vector<double> positions_y(comp_dom.dh.n_dofs());
2472 Vector<double> positions_z(comp_dom.dh.n_dofs());
2473 Vector<double> positions_dot_x(comp_dom.dh.n_dofs());
2474 Vector<double> positions_dot_y(comp_dom.dh.n_dofs());
2475 Vector<double> positions_dot_z(comp_dom.dh.n_dofs());
2477 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
2479 positions_x(i) = solution(3*i+0)+comp_dom.rigid_motion_map_points(3*i+0)+comp_dom.ref_points[3*i](0);
2480 positions_y(i) = solution(3*i+1)+comp_dom.rigid_motion_map_points(3*i+1)+comp_dom.ref_points[3*i](1);
2481 positions_z(i) = solution(3*i+2)+comp_dom.rigid_motion_map_points(3*i+2)+comp_dom.ref_points[3*i](2);
2482 positions_dot_x(i) = solution_dot(3*i+0);
2483 positions_dot_y(i) = solution_dot(3*i+1);
2484 positions_dot_z(i) = solution_dot(3*i+2);
2487 std::vector<Vector<double> > all_in;
2488 all_in.push_back((Vector<double>)Phi);
2489 all_in.push_back((Vector<double>)Phi_dot);
2490 all_in.push_back((Vector<double>)dphi_dn);
2491 all_in.push_back((Vector<double>)dphi_dn_dot);
2492 all_in.push_back(positions_x);
2493 all_in.push_back(positions_y);
2494 all_in.push_back(positions_z);
2495 all_in.push_back(positions_dot_x);
2496 all_in.push_back(positions_dot_y);
2497 all_in.push_back(positions_dot_z);
2499 tria.prepare_coarsening_and_refinement();
2500 soltrans.prepare_for_coarsening_and_refinement(all_in);
2505 tria.execute_coarsening_and_refinement();
2506 dh.distribute_dofs(comp_dom.fe);
2507 vector_dh.distribute_dofs(comp_dom.vector_fe);
2508 comp_dom.map_points.reinit(vector_dh.n_dofs());
2509 comp_dom.smoothing_map_points.reinit(vector_dh.n_dofs());
2510 comp_dom.old_map_points.reinit(vector_dh.n_dofs());
2511 comp_dom.rigid_motion_map_points.reinit(vector_dh.n_dofs());
2512 comp_dom.initial_map_points.reinit(vector_dh.n_dofs());
2513 comp_dom.ref_points.resize(vector_dh.n_dofs());
2514 DoFTools::map_dofs_to_support_points<2,3>(StaticMappingQ1<2,3>::mapping,
2515 comp_dom.vector_dh, comp_dom.ref_points);
2516 comp_dom.generate_double_nodes_set();
2518 compute_constraints(constraints, vector_constraints);
2520 dofs_number = vector_dh.n_dofs()+dh.n_dofs()+dh.n_dofs()+13;
2522 std::cout<<
"Total number of dofs after restoring edges conformity: "<<dh.n_dofs()<<std::endl;
2525 Vector<double> new_Phi(dh.n_dofs());
2526 Vector<double> new_Phi_dot(dh.n_dofs());
2531 Vector<double> new_positions_x(dh.n_dofs());
2532 Vector<double> new_positions_y(dh.n_dofs());
2533 Vector<double> new_positions_z(dh.n_dofs());
2534 Vector<double> new_positions_dot_x(dh.n_dofs());
2535 Vector<double> new_positions_dot_y(dh.n_dofs());
2536 Vector<double> new_positions_dot_z(dh.n_dofs());
2538 std::vector<Vector<double> > all_out;
2539 all_out.push_back(new_Phi);
2540 all_out.push_back(new_Phi_dot);
2541 all_out.push_back(new_dphi_dn);
2542 all_out.push_back(new_dphi_dn_dot);
2543 all_out.push_back(new_positions_x);
2544 all_out.push_back(new_positions_y);
2545 all_out.push_back(new_positions_z);
2546 all_out.push_back(new_positions_dot_x);
2547 all_out.push_back(new_positions_dot_y);
2548 all_out.push_back(new_positions_dot_z);
2550 soltrans.interpolate(all_in, all_out);
2552 solution.
reinit(dofs_number);
2553 solution_dot.
reinit(dofs_number);
2556 constraints.distribute(all_out[0]);
2557 constraints.distribute(all_out[1]);
2558 constraints.distribute(all_out[2]);
2559 constraints.distribute(all_out[3]);
2560 constraints.distribute(all_out[4]);
2561 constraints.distribute(all_out[5]);
2562 constraints.distribute(all_out[6]);
2563 constraints.distribute(all_out[7]);
2564 constraints.distribute(all_out[8]);
2565 constraints.distribute(all_out[9]);
2570 rigid_motion_velocities.reinit(comp_dom.vector_dh.n_dofs());
2575 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
2577 if ( ((comp_dom.flags[i] &
boat) &&
2585 gp_Pnt original_boat_mesh_point =
Pnt(
Point<3>(comp_dom.ref_points[3*i](0)+comp_dom.old_map_points(3*i),
2586 comp_dom.ref_points[3*i](1)+comp_dom.old_map_points(3*i+1),
2587 comp_dom.ref_points[3*i](2)+comp_dom.old_map_points(3*i+2)));
2588 gp_Pnt boat_mesh_point = original_boat_mesh_point;
2591 boat_mesh_point.Transform(restart_hull_location.Inverted());
2596 double s_x = hull_lin_displ(0);
2597 double s_y = hull_lin_displ(1);
2598 double s_z = hull_lin_displ(2);
2599 double v_x = hull_quat_vect(0);
2600 double v_y = hull_quat_vect(1);
2601 double v_z = hull_quat_vect(2);
2602 double s = hull_quat_scal;
2604 Point<3> ref_baricenter_pos(comp_dom.boat_model.reference_hull_baricenter(0),
2605 comp_dom.boat_model.reference_hull_baricenter(1),
2606 comp_dom.boat_model.reference_hull_baricenter(2));
2608 Point<3> baricenter_pos(s_x+comp_dom.boat_model.reference_hull_baricenter(0),
2609 s_y+comp_dom.boat_model.reference_hull_baricenter(1),
2610 s_z+comp_dom.boat_model.reference_hull_baricenter(2));
2612 Point<3> RotMatRow1(1-2*v_y*v_y-2*v_z*v_z, 2*v_x*v_y-2*s*v_z, 2*v_x*v_z+2*s*v_y);
2613 Point<3> RotMatRow2(2*v_x*v_y+2*s*v_z, 1-2*v_x*v_x-2*v_z*v_z, 2*v_y*v_z-2*s*v_x);
2614 Point<3> RotMatRow3(2*v_x*v_z-2*s*v_y, 2*v_y*v_z+2*s*v_x, 1-2*v_y*v_y-2*v_x*v_x);
2616 Point<3> ref_point_pos(boat_mesh_point.X(),boat_mesh_point.Y(),boat_mesh_point.Z());
2617 Point<3> rigid_lin_displ(s_x,s_y,s_z);
2618 Point<3> target_point_pos(RotMatRow1*(ref_point_pos+(-1.0)*ref_baricenter_pos),
2619 RotMatRow2*(ref_point_pos+(-1.0)*ref_baricenter_pos),
2620 RotMatRow3*(ref_point_pos+(-1.0)*ref_baricenter_pos));
2621 target_point_pos += baricenter_pos;
2626 comp_dom.rigid_motion_map_points(3*i) = target_point_pos(0)-ref_point_pos(0);
2627 comp_dom.rigid_motion_map_points(3*i+1) = target_point_pos(1)-ref_point_pos(1);
2628 comp_dom.rigid_motion_map_points(3*i+2) = target_point_pos(2)-ref_point_pos(2);
2630 rigid_motion_velocities(3*i) = hull_lin_vel(0)+
2631 hull_ang_vel(1)*(target_point_pos(2)-baricenter_pos(2))-
2632 hull_ang_vel(2)*(target_point_pos(1)-baricenter_pos(1));
2633 rigid_motion_velocities(3*i+1) = hull_lin_vel(1)+
2634 hull_ang_vel(2)*(target_point_pos(0)-baricenter_pos(0))-
2635 hull_ang_vel(0)*(target_point_pos(2)-baricenter_pos(2));
2636 rigid_motion_velocities(3*i+2) = hull_lin_vel(2)+
2637 hull_ang_vel(0)*(target_point_pos(1)-baricenter_pos(1))-
2638 hull_ang_vel(1)*(target_point_pos(0)-baricenter_pos(0));
2654 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
2656 solution(3*i+0) = all_out[4](i)-comp_dom.rigid_motion_map_points(3*i)-comp_dom.ref_points[3*i](0);
2657 solution(3*i+1) = all_out[5](i)-comp_dom.rigid_motion_map_points(3*i+1)-comp_dom.ref_points[3*i](1);
2658 solution(3*i+2) = all_out[6](i)-comp_dom.rigid_motion_map_points(3*i+2)-comp_dom.ref_points[3*i](2);
2659 solution_dot(3*i+0) = all_out[7](i)-rigid_motion_velocities(3*i);
2660 solution_dot(3*i+1) = all_out[8](i)-rigid_motion_velocities(3*i+1);
2661 solution_dot(3*i+2) = all_out[9](i)-rigid_motion_velocities(3*i+2);
2662 solution(i+vector_dh.n_dofs()) = all_out[0](i);
2663 solution_dot(i+vector_dh.n_dofs()) = all_out[1](i);
2664 solution(i+vector_dh.n_dofs()+dh.n_dofs()) = all_out[2](i);
2665 solution_dot(i+vector_dh.n_dofs()+dh.n_dofs()) = all_out[3](i);
2668 for (
unsigned int k=0; k<3; ++k)
2670 solution(k+3+vector_dh.n_dofs()+dh.n_dofs()+dh.n_dofs()) = hull_lin_displ(k);
2671 solution_dot(k+3+vector_dh.n_dofs()+dh.n_dofs()+dh.n_dofs()) = hull_lin_displ_dot(k);
2672 solution(k+vector_dh.n_dofs()+dh.n_dofs()+dh.n_dofs()) = hull_lin_vel(k);
2673 solution_dot(k+vector_dh.n_dofs()+dh.n_dofs()+dh.n_dofs()) = hull_lin_vel_dot(k);
2674 solution(k+6+vector_dh.n_dofs()+dh.n_dofs()+dh.n_dofs()) = hull_ang_vel(k);
2675 solution_dot(k+6+vector_dh.n_dofs()+dh.n_dofs()+dh.n_dofs()) = hull_ang_vel_dot(k);
2676 solution(k+9+vector_dh.n_dofs()+dh.n_dofs()+dh.n_dofs()) = hull_quat_vect(k);
2677 solution_dot(k+9+vector_dh.n_dofs()+dh.n_dofs()+dh.n_dofs()) = hull_quat_vect_dot(k);
2679 solution(12+vector_dh.n_dofs()+dh.n_dofs()+dh.n_dofs()) = hull_quat_scal;
2680 solution_dot(12+vector_dh.n_dofs()+dh.n_dofs()+dh.n_dofs()) = hull_quat_scal_dot;
2683 DXDt_and_DphiDt_vector.
reinit(vector_dh.n_dofs()+dh.n_dofs());
2685 DphiDt_sparsity_pattern.reinit (dh.n_dofs(),
2687 dh.max_couplings_between_dofs());
2688 vector_sparsity_pattern.reinit (vector_dh.n_dofs(),
2690 vector_dh.max_couplings_between_dofs());
2693 DphiDt_sparsity_pattern.compress();
2696 vector_sparsity_pattern.compress();
2698 working_map_points.reinit(comp_dom.vector_dh.n_dofs());
2699 working_nodes_velocities.reinit(comp_dom.vector_dh.n_dofs());
2700 nodes_pos_res.reinit(comp_dom.vector_dh.n_dofs());
2701 nodes_ref_surf_dist.reinit(comp_dom.vector_dh.n_dofs());
2702 nodes_diff_jac_x_delta.reinit(dofs_number);
2703 nodes_alg_jac_x_delta.reinit(dofs_number);
2704 dae_nonlin_residual.reinit(dofs_number);
2705 dae_linear_step_residual.reinit(dofs_number);
2706 current_sol.reinit(dofs_number);
2707 current_sol_dot.reinit(dofs_number);
2708 bem_residual.reinit(comp_dom.dh.n_dofs());
2709 bem_phi.reinit(comp_dom.dh.n_dofs());
2710 bem_dphi_dn.reinit(comp_dom.dh.n_dofs());
2711 temp_src.reinit(comp_dom.vector_dh.n_dofs());
2712 break_wave_press.reinit(comp_dom.dh.n_dofs());
2718 support_points.resize(dh.n_dofs());
2719 DoFTools::map_dofs_to_support_points<2, 3>( *comp_dom.mapping, dh, support_points);
2720 std::vector<bool> new_boundary_dofs(vector_dh.n_dofs());
2721 std::vector< bool > comp_sel(3,
true);
2723 for (
unsigned int i=0; i<dh.n_dofs(); ++i)
2724 for (
unsigned int j=0; j<old_points.size(); ++j)
2725 if (old_points[j].distance(support_points[i]) < 1e-5)
2727 new_boundary_dofs[3*i] = 1;
2728 new_boundary_dofs[3*i+1] = 1;
2729 new_boundary_dofs[3*i+2] = 1;
2733 for (
unsigned int i=0; i<comp_dom.vector_dh.n_dofs(); ++i)
2735 comp_dom.map_points(i) = solution(i)+comp_dom.rigid_motion_map_points(i);
2740 if (!comp_dom.no_boat)
2741 comp_dom.evaluate_ref_surf_distances(nodes_ref_surf_dist,
false);
2742 comp_dom.map_points -= nodes_ref_surf_dist;
2743 for (
unsigned int i=0; i<comp_dom.vector_dh.n_dofs(); ++i)
2745 solution(i) = comp_dom.map_points(i)-comp_dom.rigid_motion_map_points(i);
2753 for (
unsigned smooth_id=0; smooth_id<comp_dom.line_smoothers.size(); ++smooth_id)
2755 Vector<double> &old_lengths = comp_dom.line_smoothers[smooth_id]->get_lengths_before_smoothing();
2756 Vector<double> &new_lengths = comp_dom.line_smoothers[smooth_id]->get_lengths_after_smoothing();
2757 std::vector<unsigned int> &indices = comp_dom.line_smoothers[smooth_id]->get_node_indices();
2758 Vector<double> old_potentials(old_lengths.
size());
2759 Vector<double> old_vx(old_lengths.
size());
2760 Vector<double> old_vy(old_lengths.
size());
2762 for (
unsigned int i=0; i<old_lengths.
size(); ++i)
2764 old_potentials(i) = solution(indices[i]+vector_dh.n_dofs());
2765 old_vx(i) = solution_dot(3*indices[i]);
2766 old_vy(i) = solution_dot(3*indices[i]+1);
2772 for (
unsigned int i=1; i<old_lengths.
size()-1; ++i)
2774 unsigned int jj=1000000;
2775 for (
unsigned int j=1; j<old_lengths.
size(); ++j)
2777 if (new_lengths(i) < old_lengths(j))
2783 double fraction = (new_lengths(i)-old_lengths(jj-1))/(old_lengths(jj)-old_lengths(jj-1));
2784 solution(indices[i]+vector_dh.n_dofs()) = old_potentials(jj-1)+(old_potentials(jj)-old_potentials(jj-1))*fraction;
2791 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
2793 if ( (!(comp_dom.flags[i] &
near_boat)==0) &&
2796 solution_dot(3*i) = 0;
2797 solution_dot(3*i+1) = 0;
2804 std::cout<<
"...Done restoring mesh conformity"<<std::endl;
2813 const unsigned int step_number,
2816 std::cout<<
"Removing hanging nodes from transom stern..."<<std::endl;
2826 double hull_quat_scal;
2827 double hull_quat_scal_dot;
2828 for (
unsigned int d=0; d<3; ++d)
2830 hull_lin_vel(d) = solution(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+d);
2831 hull_lin_displ(d) = solution(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+3+d);
2832 hull_lin_vel_dot(d) = solution_dot(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+d);
2833 hull_lin_displ_dot(d) = solution_dot(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+3+d);
2834 hull_ang_vel(d) = solution(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+6+d);
2835 hull_ang_vel_dot(d) = solution_dot(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+6+d);
2836 hull_quat_vect(d) = solution(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+9+d);
2837 hull_quat_vect_dot(d) = solution_dot(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+9+d);
2839 hull_quat_scal = solution(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+12);
2840 hull_quat_scal_dot = solution_dot(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+12);
2842 cout<<
"*Hull Rigid Displacement: "<<hull_lin_displ<<endl;
2843 cout<<
"*Hull Rigid Velocity: "<<hull_lin_vel<<endl;
2844 cout<<
"*Hull Angualr Velocity: "<<hull_lin_vel<<endl;
2847 Vector<double> rigid_motion_velocities(comp_dom.vector_dh.n_dofs());
2851 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
2853 if ( ((comp_dom.flags[i] &
boat) &&
2861 gp_Pnt original_boat_mesh_point =
Pnt(
Point<3>(comp_dom.ref_points[3*i](0)+comp_dom.old_map_points(3*i),
2862 comp_dom.ref_points[3*i](1)+comp_dom.old_map_points(3*i+1),
2863 comp_dom.ref_points[3*i](2)+comp_dom.old_map_points(3*i+2)));
2864 gp_Pnt boat_mesh_point = original_boat_mesh_point;
2867 boat_mesh_point.Transform(restart_hull_location.Inverted());
2872 double s_x = hull_lin_displ(0);
2873 double s_y = hull_lin_displ(1);
2874 double s_z = hull_lin_displ(2);
2875 double v_x = hull_quat_vect(0);
2876 double v_y = hull_quat_vect(1);
2877 double v_z = hull_quat_vect(2);
2878 double s = hull_quat_scal;
2880 Point<3> ref_baricenter_pos(comp_dom.boat_model.reference_hull_baricenter(0),
2881 comp_dom.boat_model.reference_hull_baricenter(1),
2882 comp_dom.boat_model.reference_hull_baricenter(2));
2884 Point<3> baricenter_pos(s_x+comp_dom.boat_model.reference_hull_baricenter(0),
2885 s_y+comp_dom.boat_model.reference_hull_baricenter(1),
2886 s_z+comp_dom.boat_model.reference_hull_baricenter(2));
2888 Point<3> RotMatRow1(1-2*v_y*v_y-2*v_z*v_z, 2*v_x*v_y-2*s*v_z, 2*v_x*v_z+2*s*v_y);
2889 Point<3> RotMatRow2(2*v_x*v_y+2*s*v_z, 1-2*v_x*v_x-2*v_z*v_z, 2*v_y*v_z-2*s*v_x);
2890 Point<3> RotMatRow3(2*v_x*v_z-2*s*v_y, 2*v_y*v_z+2*s*v_x, 1-2*v_y*v_y-2*v_x*v_x);
2892 Point<3> ref_point_pos(boat_mesh_point.X(),boat_mesh_point.Y(),boat_mesh_point.Z());
2893 Point<3> rigid_lin_displ(s_x,s_y,s_z);
2894 Point<3> target_point_pos(RotMatRow1*(ref_point_pos+(-1.0)*ref_baricenter_pos),
2895 RotMatRow2*(ref_point_pos+(-1.0)*ref_baricenter_pos),
2896 RotMatRow3*(ref_point_pos+(-1.0)*ref_baricenter_pos));
2897 target_point_pos += baricenter_pos;
2902 comp_dom.rigid_motion_map_points(3*i) = target_point_pos(0)-ref_point_pos(0);
2903 comp_dom.rigid_motion_map_points(3*i+1) = target_point_pos(1)-ref_point_pos(1);
2904 comp_dom.rigid_motion_map_points(3*i+2) = target_point_pos(2)-ref_point_pos(2);
2906 rigid_motion_velocities(3*i) = hull_lin_vel(0)+
2907 hull_ang_vel(1)*(target_point_pos(2)-baricenter_pos(2))-
2908 hull_ang_vel(2)*(target_point_pos(1)-baricenter_pos(1));
2909 rigid_motion_velocities(3*i+1) = hull_lin_vel(1)+
2910 hull_ang_vel(2)*(target_point_pos(0)-baricenter_pos(0))-
2911 hull_ang_vel(0)*(target_point_pos(2)-baricenter_pos(2));
2912 rigid_motion_velocities(3*i+2) = hull_lin_vel(2)+
2913 hull_ang_vel(0)*(target_point_pos(1)-baricenter_pos(1))-
2914 hull_ang_vel(1)*(target_point_pos(0)-baricenter_pos(0));
2932 DoFHandler<dim-1, dim> &vector_dh = comp_dom.vector_dh;
2935 std::vector<Point<dim> > support_points(dh.n_dofs());
2945 std::vector<Point<3> > old_points(dh.n_dofs());
2946 old_points = support_points;
2949 comp_dom.surface_smoother->compute_curvatures(curvatures);
2953 std::vector<Point<3> > ref_points(dh.n_dofs());
2956 unsigned int refinedCellCounter = 1;
2958 while (refinedCellCounter)
2960 refinedCellCounter = 0;
2961 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
2967 std::vector<cell_it> cells = comp_dom.dof_to_elems[i];
2968 for (
unsigned int k=0; k<cells.size(); ++k)
2971 for (
unsigned int j=0; j<GeometryInfo<2>::faces_per_cell; ++j)
2974 if (cells[k]->neighbor_index(j) != -1)
2975 if ( cells[k]->neighbor(j)->at_boundary() &&
2976 (cells[k]->neighbor_is_coarser(j) || cells[k]->refine_flag_set() ) &&
2977 !(cells[k]->neighbor(j)->refine_flag_set()) )
2980 cells[k]->neighbor(j)->set_refine_flag();
2981 refinedCellCounter++;
2992 Vector<double> positions_x(comp_dom.dh.n_dofs());
2993 Vector<double> positions_y(comp_dom.dh.n_dofs());
2994 Vector<double> positions_z(comp_dom.dh.n_dofs());
2995 Vector<double> positions_dot_x(comp_dom.dh.n_dofs());
2996 Vector<double> positions_dot_y(comp_dom.dh.n_dofs());
2997 Vector<double> positions_dot_z(comp_dom.dh.n_dofs());
2999 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
3001 positions_x(i) = solution(3*i+0)+comp_dom.rigid_motion_map_points(3*i+0)+comp_dom.ref_points[3*i](0);
3002 positions_y(i) = solution(3*i+1)+comp_dom.rigid_motion_map_points(3*i+1)+comp_dom.ref_points[3*i](1);
3003 positions_z(i) = solution(3*i+2)+comp_dom.rigid_motion_map_points(3*i+2)+comp_dom.ref_points[3*i](2);
3004 positions_dot_x(i) = solution_dot(3*i+0);
3005 positions_dot_y(i) = solution_dot(3*i+1);
3006 positions_dot_z(i) = solution_dot(3*i+2);
3009 std::vector<Vector<double> > all_in;
3010 all_in.push_back((Vector<double>)Phi);
3011 all_in.push_back((Vector<double>)Phi_dot);
3012 all_in.push_back((Vector<double>)dphi_dn);
3013 all_in.push_back((Vector<double>)dphi_dn_dot);
3014 all_in.push_back(positions_x);
3015 all_in.push_back(positions_y);
3016 all_in.push_back(positions_z);
3017 all_in.push_back(positions_dot_x);
3018 all_in.push_back(positions_dot_y);
3019 all_in.push_back(positions_dot_z);
3021 tria.prepare_coarsening_and_refinement();
3022 soltrans.prepare_for_coarsening_and_refinement(all_in);
3027 tria.execute_coarsening_and_refinement();
3028 dh.distribute_dofs(comp_dom.fe);
3029 vector_dh.distribute_dofs(comp_dom.vector_fe);
3030 comp_dom.map_points.reinit(vector_dh.n_dofs());
3031 comp_dom.smoothing_map_points.reinit(vector_dh.n_dofs());
3032 comp_dom.old_map_points.reinit(vector_dh.n_dofs());
3033 comp_dom.rigid_motion_map_points.reinit(vector_dh.n_dofs());
3034 comp_dom.initial_map_points.reinit(vector_dh.n_dofs());
3035 comp_dom.ref_points.resize(vector_dh.n_dofs());
3036 DoFTools::map_dofs_to_support_points<2,3>(StaticMappingQ1<2,3>::mapping,
3037 comp_dom.vector_dh, comp_dom.ref_points);
3038 comp_dom.generate_double_nodes_set();
3040 compute_constraints(constraints, vector_constraints);
3042 dofs_number = vector_dh.n_dofs()+dh.n_dofs()+dh.n_dofs()+13;
3044 std::cout<<
"Total number of dofs after fixing transom stern: "<<dh.n_dofs()<<std::endl;
3047 Vector<double> new_Phi(dh.n_dofs());
3048 Vector<double> new_Phi_dot(dh.n_dofs());
3053 Vector<double> new_positions_x(dh.n_dofs());
3054 Vector<double> new_positions_y(dh.n_dofs());
3055 Vector<double> new_positions_z(dh.n_dofs());
3056 Vector<double> new_positions_dot_x(dh.n_dofs());
3057 Vector<double> new_positions_dot_y(dh.n_dofs());
3058 Vector<double> new_positions_dot_z(dh.n_dofs());
3060 std::vector<Vector<double> > all_out;
3061 all_out.push_back(new_Phi);
3062 all_out.push_back(new_Phi_dot);
3063 all_out.push_back(new_dphi_dn);
3064 all_out.push_back(new_dphi_dn_dot);
3065 all_out.push_back(new_positions_x);
3066 all_out.push_back(new_positions_y);
3067 all_out.push_back(new_positions_z);
3068 all_out.push_back(new_positions_dot_x);
3069 all_out.push_back(new_positions_dot_y);
3070 all_out.push_back(new_positions_dot_z);
3072 soltrans.interpolate(all_in, all_out);
3074 solution.
reinit(dofs_number);
3075 solution_dot.
reinit(dofs_number);
3078 constraints.distribute(all_out[0]);
3079 constraints.distribute(all_out[1]);
3080 constraints.distribute(all_out[2]);
3081 constraints.distribute(all_out[3]);
3082 constraints.distribute(all_out[4]);
3083 constraints.distribute(all_out[5]);
3084 constraints.distribute(all_out[6]);
3085 constraints.distribute(all_out[7]);
3086 constraints.distribute(all_out[8]);
3087 constraints.distribute(all_out[9]);
3091 rigid_motion_velocities.reinit(comp_dom.vector_dh.n_dofs());
3095 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
3097 if ( ((comp_dom.flags[i] &
boat) &&
3105 gp_Pnt original_boat_mesh_point =
Pnt(
Point<3>(comp_dom.ref_points[3*i](0)+comp_dom.old_map_points(3*i),
3106 comp_dom.ref_points[3*i](1)+comp_dom.old_map_points(3*i+1),
3107 comp_dom.ref_points[3*i](2)+comp_dom.old_map_points(3*i+2)));
3108 gp_Pnt boat_mesh_point = original_boat_mesh_point;
3111 boat_mesh_point.Transform(restart_hull_location.Inverted());
3116 double s_x = hull_lin_displ(0);
3117 double s_y = hull_lin_displ(1);
3118 double s_z = hull_lin_displ(2);
3119 double v_x = hull_quat_vect(0);
3120 double v_y = hull_quat_vect(1);
3121 double v_z = hull_quat_vect(2);
3122 double s = hull_quat_scal;
3124 Point<3> ref_baricenter_pos(comp_dom.boat_model.reference_hull_baricenter(0),
3125 comp_dom.boat_model.reference_hull_baricenter(1),
3126 comp_dom.boat_model.reference_hull_baricenter(2));
3128 Point<3> baricenter_pos(s_x+comp_dom.boat_model.reference_hull_baricenter(0),
3129 s_y+comp_dom.boat_model.reference_hull_baricenter(1),
3130 s_z+comp_dom.boat_model.reference_hull_baricenter(2));
3132 Point<3> RotMatRow1(1-2*v_y*v_y-2*v_z*v_z, 2*v_x*v_y-2*s*v_z, 2*v_x*v_z+2*s*v_y);
3133 Point<3> RotMatRow2(2*v_x*v_y+2*s*v_z, 1-2*v_x*v_x-2*v_z*v_z, 2*v_y*v_z-2*s*v_x);
3134 Point<3> RotMatRow3(2*v_x*v_z-2*s*v_y, 2*v_y*v_z+2*s*v_x, 1-2*v_y*v_y-2*v_x*v_x);
3136 Point<3> ref_point_pos(boat_mesh_point.X(),boat_mesh_point.Y(),boat_mesh_point.Z());
3137 Point<3> rigid_lin_displ(s_x,s_y,s_z);
3138 Point<3> target_point_pos(RotMatRow1*(ref_point_pos+(-1.0)*ref_baricenter_pos),
3139 RotMatRow2*(ref_point_pos+(-1.0)*ref_baricenter_pos),
3140 RotMatRow3*(ref_point_pos+(-1.0)*ref_baricenter_pos));
3141 target_point_pos += baricenter_pos;
3146 comp_dom.rigid_motion_map_points(3*i) = target_point_pos(0)-ref_point_pos(0);
3147 comp_dom.rigid_motion_map_points(3*i+1) = target_point_pos(1)-ref_point_pos(1);
3148 comp_dom.rigid_motion_map_points(3*i+2) = target_point_pos(2)-ref_point_pos(2);
3150 rigid_motion_velocities(3*i) = hull_lin_vel(0)+
3151 hull_ang_vel(1)*(target_point_pos(2)-baricenter_pos(2))-
3152 hull_ang_vel(2)*(target_point_pos(1)-baricenter_pos(1));
3153 rigid_motion_velocities(3*i+1) = hull_lin_vel(1)+
3154 hull_ang_vel(2)*(target_point_pos(0)-baricenter_pos(0))-
3155 hull_ang_vel(0)*(target_point_pos(2)-baricenter_pos(2));
3156 rigid_motion_velocities(3*i+2) = hull_lin_vel(2)+
3157 hull_ang_vel(0)*(target_point_pos(1)-baricenter_pos(1))-
3158 hull_ang_vel(1)*(target_point_pos(0)-baricenter_pos(0));
3173 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
3175 solution(3*i+0) = all_out[4](i)-comp_dom.rigid_motion_map_points(3*i)-comp_dom.ref_points[3*i](0);
3176 solution(3*i+1) = all_out[5](i)-comp_dom.rigid_motion_map_points(3*i+1)-comp_dom.ref_points[3*i](1);
3177 solution(3*i+2) = all_out[6](i)-comp_dom.rigid_motion_map_points(3*i+2)-comp_dom.ref_points[3*i](2);
3178 solution_dot(3*i+0) = all_out[7](i);
3179 solution_dot(3*i+1) = all_out[8](i);
3180 solution_dot(3*i+2) = all_out[9](i);
3181 solution(i+vector_dh.n_dofs()) = all_out[0](i);
3182 solution_dot(i+vector_dh.n_dofs()) = all_out[1](i);
3183 solution(i+vector_dh.n_dofs()+dh.n_dofs()) = all_out[2](i);
3184 solution_dot(i+vector_dh.n_dofs()+dh.n_dofs()) = all_out[3](i);
3187 for (
unsigned int k=0; k<3; ++k)
3189 solution(k+3+vector_dh.n_dofs()+dh.n_dofs()+dh.n_dofs()) = hull_lin_displ(k);
3190 solution_dot(k+3+vector_dh.n_dofs()+dh.n_dofs()+dh.n_dofs()) = hull_lin_displ_dot(k);
3191 solution(k+vector_dh.n_dofs()+dh.n_dofs()+dh.n_dofs()) = hull_lin_vel(k);
3192 solution_dot(k+vector_dh.n_dofs()+dh.n_dofs()+dh.n_dofs()) = hull_lin_vel_dot(k);
3193 solution(k+6+vector_dh.n_dofs()+dh.n_dofs()+dh.n_dofs()) = hull_ang_vel(k);
3194 solution_dot(k+6+vector_dh.n_dofs()+dh.n_dofs()+dh.n_dofs()) = hull_ang_vel_dot(k);
3195 solution(k+9+vector_dh.n_dofs()+dh.n_dofs()+dh.n_dofs()) = hull_quat_vect(k);
3196 solution_dot(k+9+vector_dh.n_dofs()+dh.n_dofs()+dh.n_dofs()) = hull_quat_vect_dot(k);
3198 solution(12+vector_dh.n_dofs()+dh.n_dofs()+dh.n_dofs()) = hull_quat_scal;
3199 solution_dot(12+vector_dh.n_dofs()+dh.n_dofs()+dh.n_dofs()) = hull_quat_scal_dot;
3203 DXDt_and_DphiDt_vector.
reinit(vector_dh.n_dofs()+dh.n_dofs());
3205 DphiDt_sparsity_pattern.reinit (dh.n_dofs(),
3207 dh.max_couplings_between_dofs());
3208 vector_sparsity_pattern.reinit (vector_dh.n_dofs(),
3210 vector_dh.max_couplings_between_dofs());
3213 DphiDt_sparsity_pattern.compress();
3216 vector_sparsity_pattern.compress();
3218 working_map_points.reinit(comp_dom.vector_dh.n_dofs());
3219 working_nodes_velocities.reinit(comp_dom.vector_dh.n_dofs());
3220 nodes_pos_res.reinit(comp_dom.vector_dh.n_dofs());
3221 nodes_ref_surf_dist.reinit(comp_dom.vector_dh.n_dofs());
3222 nodes_diff_jac_x_delta.reinit(dofs_number);
3223 nodes_alg_jac_x_delta.reinit(dofs_number);
3224 dae_nonlin_residual.reinit(dofs_number);
3225 dae_linear_step_residual.reinit(dofs_number);
3226 current_sol.reinit(dofs_number);
3227 current_sol_dot.reinit(dofs_number);
3228 bem_residual.reinit(comp_dom.dh.n_dofs());
3229 bem_phi.reinit(comp_dom.dh.n_dofs());
3230 bem_dphi_dn.reinit(comp_dom.dh.n_dofs());
3231 temp_src.reinit(comp_dom.vector_dh.n_dofs());
3232 break_wave_press.reinit(comp_dom.dh.n_dofs());
3238 support_points.resize(dh.n_dofs());
3239 DoFTools::map_dofs_to_support_points<2, 3>( *comp_dom.mapping, dh, support_points);
3240 std::vector<bool> new_boundary_dofs(vector_dh.n_dofs());
3241 std::vector< bool > comp_sel(3,
true);
3243 for (
unsigned int i=0; i<dh.n_dofs(); ++i)
3244 for (
unsigned int j=0; j<old_points.size(); ++j)
3245 if (old_points[j].distance(support_points[i]) < 1e-5)
3247 new_boundary_dofs[3*i] = 1;
3248 new_boundary_dofs[3*i+1] = 1;
3249 new_boundary_dofs[3*i+2] = 1;
3252 for (
unsigned int i=0; i<comp_dom.vector_dh.n_dofs(); ++i)
3254 comp_dom.map_points(i) = solution(i)+comp_dom.rigid_motion_map_points(i);
3260 if (!comp_dom.no_boat)
3261 comp_dom.evaluate_ref_surf_distances(nodes_ref_surf_dist,
false);
3262 comp_dom.map_points -= nodes_ref_surf_dist;
3263 for (
unsigned int i=0; i<comp_dom.vector_dh.n_dofs(); ++i)
3265 solution(i) = comp_dom.map_points(i)-comp_dom.rigid_motion_map_points(i);
3275 for (
unsigned smooth_id=0; smooth_id<comp_dom.line_smoothers.size(); ++smooth_id)
3277 Vector<double> &old_lengths = comp_dom.line_smoothers[smooth_id]->get_lengths_before_smoothing();
3278 Vector<double> &new_lengths = comp_dom.line_smoothers[smooth_id]->get_lengths_after_smoothing();
3279 std::vector<unsigned int> &indices = comp_dom.line_smoothers[smooth_id]->get_node_indices();
3280 Vector<double> old_potentials(old_lengths.
size());
3281 Vector<double> old_vx(old_lengths.
size());
3282 Vector<double> old_vy(old_lengths.
size());
3284 for (
unsigned int i=0; i<old_lengths.
size(); ++i)
3286 old_potentials(i) = solution(indices[i]+vector_dh.n_dofs());
3287 old_vx(i) = solution_dot(3*indices[i]);
3288 old_vy(i) = solution_dot(3*indices[i]+1);
3294 for (
unsigned int i=1; i<old_lengths.
size()-1; ++i)
3296 unsigned int jj=1000000;
3297 for (
unsigned int j=1; j<old_lengths.
size(); ++j)
3299 if (new_lengths(i) < old_lengths(j))
3305 double fraction = (new_lengths(i)-old_lengths(jj-1))/(old_lengths(jj)-old_lengths(jj-1));
3306 solution(indices[i]+vector_dh.n_dofs()) = old_potentials(jj-1)+(old_potentials(jj)-old_potentials(jj-1))*fraction;
3313 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
3315 if ( (!(comp_dom.flags[i] &
near_boat)==0) &&
3318 solution_dot(3*i) = 0;
3319 solution_dot(3*i+1) = 0;
3326 std::cout<<
"...Done removing hanging nodes from transom stern"<<std::endl;
3333 std::cout<<
"Preparing interpolated solution for restart"<<std::endl;
3338 res.
reinit(sys_comp.size());
3350 for (
unsigned int i=0; i<comp_dom.vector_dh.n_dofs(); ++i)
3360 const VectorView<double> dphi_dn(comp_dom.dh.n_dofs(),y.
begin()+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs());
3361 const VectorView<double> dphi_dn_time_derivs(comp_dom.dh.n_dofs(),yp.
begin()+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs());
3371 for (
unsigned int d=0; d<3; ++d)
3373 hull_lin_vel(d) = y(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+d);
3374 hull_lin_displ(d) = y(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+3+d);
3375 hull_lin_vel_dot(d) = yp(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+d);
3376 hull_lin_displ_dot(d) = yp(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+3+d);
3377 hull_ang_vel(d) = y(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+6+d);
3378 hull_quat_vector(d) = y(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+9+d);
3379 hull_ang_vel_dot(d) = yp(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+6+d);
3380 hull_quat_vector_dot(d) = yp(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+9+d);
3382 double hull_quat_scalar = y(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+12);
3383 double hull_quat_scalar_dot = yp(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+12);
3385 cout<<
"*Hull Rigid Displacement: "<<hull_lin_displ<<endl;
3386 cout<<
"*Hull Rigid Velocity: "<<hull_lin_vel<<endl;
3387 cout<<
"*Hull Angular Velocity: "<<hull_ang_vel<<endl;
3389 for (
unsigned int d=0; d<3; ++d)
3391 yp(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+3+d) = hull_lin_vel(d);
3401 DphiDt_sys_rhs.reinit (comp_dom.dh.n_dofs());
3402 DphiDt_sys_rhs_2.reinit (comp_dom.dh.n_dofs());
3403 DphiDt_sys_rhs_3.reinit (comp_dom.dh.n_dofs());
3404 DphiDt_sys_rhs_4.reinit (comp_dom.dh.n_dofs());
3405 DphiDt_sys_matrix.reinit(DphiDt_sparsity_pattern);
3406 DphiDt_sys_matrix_2.reinit(DphiDt_sparsity_pattern);
3412 wind.vector_value(zero,instantWindValue);
3413 std::cout<<std::endl<<
"Simulation time= "<<t<<
" Vinf= ";
3414 instantWindValue.
print(std::cout,4,
false,
true);
3415 std::cout <<
"Ndofs ODE= " << y.
size();
3416 std::cout <<
" Ndofs BEM= " << comp_dom.dh.n_dofs();
3417 std::cout<<std::endl;
3421 wind.vector_value(
Point<3>(0.0,0.0,0.0),wind_value);
3423 for (
unsigned int i = 0; i < dim; i++)
3424 Vinf(i) = wind_value(i);
3426 cout<<
"Hull Rigid Displacement: "<<hull_lin_displ<<endl;
3427 cout<<
"Hull Rigid Velocity: "<<hull_lin_vel<<endl;
3434 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
3436 if ( ((comp_dom.flags[i] &
boat) &&
3444 gp_Pnt original_boat_mesh_point =
Pnt(
Point<3>(comp_dom.ref_points[3*i](0)+comp_dom.old_map_points(3*i),
3445 comp_dom.ref_points[3*i](1)+comp_dom.old_map_points(3*i+1),
3446 comp_dom.ref_points[3*i](2)+comp_dom.old_map_points(3*i+2)));
3447 gp_Pnt boat_mesh_point = original_boat_mesh_point;
3450 boat_mesh_point.Transform(restart_hull_location.Inverted());
3454 double s_x,s_y,s_z,v_x,v_y,v_z,s;
3456 s_x = hull_lin_displ(0);
3457 s_y = hull_lin_displ(1);
3458 s_z = hull_lin_displ(2);
3459 v_x = hull_quat_vector(0);
3460 v_y = hull_quat_vector(1);
3461 v_z = hull_quat_vector(2);
3462 s = hull_quat_scalar;
3464 Point<3> ref_baricenter_pos(comp_dom.boat_model.reference_hull_baricenter(0),
3465 comp_dom.boat_model.reference_hull_baricenter(1),
3466 comp_dom.boat_model.reference_hull_baricenter(2));
3468 Point<3> baricenter_pos(s_x+comp_dom.boat_model.reference_hull_baricenter(0),
3469 s_y+comp_dom.boat_model.reference_hull_baricenter(1),
3470 s_z+comp_dom.boat_model.reference_hull_baricenter(2));
3472 Point<3> RotMatRow1(1-2*v_y*v_y-2*v_z*v_z, 2*v_x*v_y-2*s*v_z, 2*v_x*v_z+2*s*v_y);
3473 Point<3> RotMatRow2(2*v_x*v_y+2*s*v_z, 1-2*v_x*v_x-2*v_z*v_z, 2*v_y*v_z-2*s*v_x);
3474 Point<3> RotMatRow3(2*v_x*v_z-2*s*v_y, 2*v_y*v_z+2*s*v_x, 1-2*v_y*v_y-2*v_x*v_x);
3476 Point<3> ref_point_pos(boat_mesh_point.X(),boat_mesh_point.Y(),boat_mesh_point.Z());
3477 Point<3> rigid_lin_displ(s_x,s_y,s_z);
3478 Point<3> target_point_pos(RotMatRow1*(ref_point_pos+(-1.0)*ref_baricenter_pos),
3479 RotMatRow2*(ref_point_pos+(-1.0)*ref_baricenter_pos),
3480 RotMatRow3*(ref_point_pos+(-1.0)*ref_baricenter_pos));
3481 target_point_pos += baricenter_pos;
3486 comp_dom.rigid_motion_map_points(3*i) = target_point_pos(0)-ref_point_pos(0);
3487 comp_dom.rigid_motion_map_points(3*i+1) = target_point_pos(1)-ref_point_pos(1);
3488 comp_dom.rigid_motion_map_points(3*i+2) = target_point_pos(2)-ref_point_pos(2);
3511 Vector<double> full_map_points(comp_dom.rigid_motion_map_points);
3512 full_map_points.
add(nodes_positions);
3513 comp_dom.update_mapping(full_map_points);
3514 comp_dom.update_support_points();
3518 working_map_points = comp_dom.map_points;
3526 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
3528 if ( !(comp_dom.flags[i] &
near_boat) &&
3529 (comp_dom.flags[i] &
water) &&
3530 (comp_dom.flags[i] &
edge) &&
3532 (!constraints.is_constrained(i)))
3534 working_map_points(3*i) = comp_dom.old_map_points(3*i);
3535 working_map_points(3*i+1) = comp_dom.old_map_points(3*i+1);
3538 working_map_points(3*i+2) = comp_dom.old_map_points(3*i+2);
3541 else if ( !(comp_dom.flags[i] &
near_water) &&
3542 (comp_dom.flags[i] &
boat) &&
3543 (!constraints.is_constrained(i)))
3545 working_map_points(3*i) = comp_dom.old_map_points(3*i);
3546 working_map_points(3*i+1) = comp_dom.old_map_points(3*i+1);
3547 working_map_points(3*i+2) = comp_dom.old_map_points(3*i+2);
3550 else if ( !(comp_dom.flags[i] & near_water) &&
3551 !(comp_dom.flags[i] &
water) &&
3552 !(comp_dom.flags[i] & boat) &&
3553 (!constraints.is_constrained(i)))
3555 working_map_points(3*i) = comp_dom.old_map_points(3*i);
3556 working_map_points(3*i+1) = comp_dom.old_map_points(3*i+1);
3557 working_map_points(3*i+2) = comp_dom.old_map_points(3*i+2);
3562 working_map_points(3*i) = comp_dom.old_map_points(3*i);
3563 working_map_points(3*i+1) = comp_dom.old_map_points(3*i+1);
3564 working_map_points(3*i+2) = comp_dom.old_map_points(3*i+2);
3571 double blend_factor = 0.0;
3578 if (t - last_remesh_time < 0.5*remeshing_period)
3579 blend_factor = sin(3.141592654*(t-last_remesh_time)/remeshing_period);
3585 std::cout<<
"blend_factor = "<<blend_factor<<std::endl;
3589 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
3591 if ( (comp_dom.flags[i] &
water) &&
3595 (comp_dom.moving_point_ids[3] != i) &&
3596 (comp_dom.moving_point_ids[4] != i) &&
3597 (comp_dom.moving_point_ids[5] != i) &&
3598 (comp_dom.moving_point_ids[6] != i) )
3602 double iges_curvature;
3603 Point<3> direction(comp_dom.iges_normals[i](0),comp_dom.iges_normals[i](1),0.0);
3605 if (fabs(comp_dom.old_iges_normals[i](0))<sqrt(3)/3*fabs(comp_dom.old_iges_normals[i](1)))
3611 comp_dom.boat_model.boat_water_line_right->assigned_axis_projection_and_diff_forms(proj_node,
3612 comp_dom.iges_normals[i],
3613 comp_dom.iges_mean_curvatures[i],
3614 comp_dom.support_points[i],
3621 if (fabs(comp_dom.old_iges_normals[i](0))<sqrt(3)/3*fabs(comp_dom.old_iges_normals[i](1)))
3623 working_map_points(3*i) = comp_dom.old_map_points(3*i);
3624 working_map_points(3*i+1) = proj_node(1) - comp_dom.ref_points[3*i](1);
3628 working_map_points(3*i) = proj_node(0) - comp_dom.ref_points[3*i](0);
3629 working_map_points(3*i+1) = comp_dom.old_map_points(3*i+1);
3631 working_map_points(3*i+2) = proj_node(2) - comp_dom.ref_points[3*i](2);
3642 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
3644 if ( (comp_dom.flags[i] &
water) &&
3648 (comp_dom.moving_point_ids[3] != i) &&
3649 (comp_dom.moving_point_ids[4] != i) &&
3650 (comp_dom.moving_point_ids[5] != i) &&
3651 (comp_dom.moving_point_ids[6] != i) )
3655 double iges_curvature;
3656 Point<3> direction(comp_dom.iges_normals[i](0),comp_dom.iges_normals[i](1),0.0);
3657 if (fabs(comp_dom.old_iges_normals[i](0))<sqrt(3)/3*fabs(comp_dom.old_iges_normals[i](1)))
3663 comp_dom.boat_model.boat_water_line_left->assigned_axis_projection_and_diff_forms(proj_node,
3664 comp_dom.iges_normals[i],
3665 comp_dom.iges_mean_curvatures[i],
3666 comp_dom.support_points[i],
3673 if (fabs(comp_dom.old_iges_normals[i](0))<sqrt(3)/3*fabs(comp_dom.old_iges_normals[i](1)))
3675 working_map_points(3*i) = comp_dom.old_map_points(3*i);
3676 working_map_points(3*i+1) = proj_node(1) - comp_dom.ref_points[3*i](1);
3680 working_map_points(3*i) = proj_node(0) - comp_dom.ref_points[3*i](0);
3681 working_map_points(3*i+1) = comp_dom.old_map_points(3*i+1);
3683 working_map_points(3*i+2) = proj_node(2) - comp_dom.ref_points[3*i](2);
3694 if (!comp_dom.no_boat)
3695 for (
unsigned int k=3; k<7; ++k)
3697 unsigned int i = comp_dom.moving_point_ids[k];
3699 Point <3> dP0 = comp_dom.support_points[i];
3702 Handle(Geom_Plane) horPlane =
new Geom_Plane(0.,0.,1.,-dP0(2));
3703 Handle(Geom_Curve) curve;
3704 TopLoc_Location L = comp_dom.boat_model.current_loc;
3705 TopLoc_Location L_inv = L.Inverted();
3706 horPlane->Transform(L_inv.Transformation());
3707 if (comp_dom.boat_model.is_transom)
3710 curve = comp_dom.boat_model.equiv_keel_bspline;
3712 curve = comp_dom.boat_model.left_transom_bspline;
3714 curve = comp_dom.boat_model.right_transom_bspline;
3718 curve = comp_dom.boat_model.equiv_keel_bspline;
3721 TopoDS_Edge
edge = BRepBuilderAPI_MakeEdge(curve);
3723 BRepAdaptor_Curve AC(edge);
3726 GeomAPI_IntCS Intersector(curve, horPlane);
3727 int npoints = Intersector.NbPoints();
3729 AssertThrow((npoints != 0),
ExcMessage(
"Keel or transom curve is not intersecting with horizontal plane!"));
3730 double minDistance=1e7;
3732 for (
int j=0; j<npoints; ++j)
3734 gp_Pnt int_point = Intersector.Point(j+1);
3735 int_point.Transform(L.Transformation());
3737 Intersector.Parameters(j+1,u,v,t);
3738 if (dP0.
distance(inters) < minDistance)
3740 minDistance = dP0.
distance(inters);
3777 working_map_points(3*i) = dP(0)-comp_dom.ref_points[3*i](0);
3778 working_map_points(3*i+1) = dP(1)-comp_dom.ref_points[3*i](1);
3779 working_map_points(3*i+2) = dP(2)-comp_dom.ref_points[3*i](2);
3780 comp_dom.edges_tangents[3*i] = V1.X();
3781 comp_dom.edges_tangents[3*i+1] = V1.Y();
3782 comp_dom.edges_tangents[3*i+2] = V1.Z();
3790 for (
unsigned int i=0; i<comp_dom.vector_dh.n_dofs(); ++i)
3792 if ( (comp_dom.vector_flags[i] &
water) &&
3793 (comp_dom.vector_flags[i] &
edge) )
3795 std::set<unsigned int> duplicates = comp_dom.vector_double_nodes_set[i];
3796 duplicates.erase(i);
3797 for (std::set<unsigned int>::iterator pos = duplicates.begin(); pos !=duplicates.end(); pos++)
3800 working_map_points(*pos) = working_map_points(i);
3806 vector_constraints.distribute(working_map_points);
3809 comp_dom.map_points = working_map_points;
3811 comp_dom.update_support_points();
3813 comp_dom.compute_normals_at_nodes(comp_dom.map_points);
3815 for (
unsigned int i=0; i<comp_dom.vector_dh.n_dofs(); ++i)
3817 y(i) = comp_dom.map_points(i)-comp_dom.rigid_motion_map_points(i);
3824 if (!comp_dom.no_boat && comp_dom.boat_model.is_transom)
3826 comp_dom.update_support_points();
3828 double transom_draft = fabs(comp_dom.boat_model.CurrentPointCenterTransom(2));
3829 double transom_aspect_ratio = (fabs(comp_dom.boat_model.CurrentPointLeftTransom(1))+
3830 fabs(comp_dom.boat_model.CurrentPointRightTransom(1)))/transom_draft;
3832 wind.set_time(100000000.0);
3835 wind.vector_value(zero,instantWindValueTinf);
3837 for (
unsigned int i = 0; i < dim; i++)
3838 VinfTinf(i) = instantWindValueTinf(i);
3839 wind.set_time(initial_time);
3841 double FrT = sqrt(VinfTinf*VinfTinf)/sqrt(9.81*transom_draft);
3842 double ReT = sqrt(9.81*pow(transom_draft,3.0))/1.307e-6;
3843 double eta_dry = fmin(0.05*pow(FrT,2.834)*pow(transom_aspect_ratio,0.1352)*pow(ReT,0.01338),1.0);
3849 cout<<FrT<<
" "<<transom_aspect_ratio<<
" "<<ReT<<endl;
3850 cout<<
"****eta_dry: "<<eta_dry<<endl;
3852 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
3854 comp_dom.initial_map_points(3*i+2) = 0.0;
3857 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
3859 if ( (comp_dom.support_points[i](1) < comp_dom.boat_model.CurrentPointRightTransom(1)) &&
3860 (comp_dom.support_points[i](1) >= 0.0) &&
3861 (comp_dom.support_points[i](0) > comp_dom.boat_model.CurrentPointCenterTransom(0)-fabs(comp_dom.boat_model.CurrentPointCenterTransom(2)) ) &&
3862 (comp_dom.support_points[3*i](0) < comp_dom.boat_model.CurrentPointCenterTransom(0)+lh*fabs(comp_dom.boat_model.CurrentPointCenterTransom(2)) ) &&
3863 (comp_dom.support_points[i](2) > 2.0*comp_dom.boat_model.CurrentPointCenterTransom(2)) )
3865 Point <3> dP0 = comp_dom.support_points[i];
3868 Handle(Geom_Plane) vertPlane =
new Geom_Plane(0.,1.,0.,-dP0(1));
3869 vertPlane->Transform(comp_dom.boat_model.current_loc.Inverted());
3870 Handle(Geom_Curve) curve = comp_dom.boat_model.right_transom_bspline;
3872 GeomAPI_IntCS Intersector(curve, vertPlane);
3873 int npoints = Intersector.NbPoints();
3876 double minDistance=1e7;
3877 for (
int j=0; j<npoints; ++j)
3879 gp_Pnt int_point = Intersector.Point(j+1);
3880 int_point.Transform(comp_dom.boat_model.current_loc);
3883 if (dP0.
distance(inters) < minDistance)
3885 minDistance = dP0.
distance(inters);
3890 if ( (comp_dom.support_points[i](0) > dP(0)+comp_dom.min_diameter/20.0) &&
3891 (comp_dom.support_points[i](0) < dP(0)+lh*fabs(dP(2))+comp_dom.min_diameter/20.0) )
3893 double mean_curvature;
3896 comp_dom.boat_model.boat_surface_right->normal_projection_and_diff_forms(projection,
3900 AssertThrow((dP.
distance(projection) < 1e-4*comp_dom.boat_model.boatWetLength),
ExcMessage(
"Normal projection for surface normal evaluation went wrong!"));
3901 double transom_slope = -normal(0)/normal(2);
3902 double a = -transom_slope/(lh*fabs(dP(2))) - 1/dP(2)/lh/lh;
3903 double x = comp_dom.support_points[i](0)-dP(0);
3904 comp_dom.initial_map_points(3*i+2) = a*x*x + transom_slope*x + dP(2);
3907 else if ( (comp_dom.support_points[i](1) > comp_dom.boat_model.CurrentPointLeftTransom(1)) &&
3908 (comp_dom.support_points[i](1) < 0.0) &&
3909 (comp_dom.support_points[i](0) > comp_dom.boat_model.CurrentPointCenterTransom(0)-fabs(comp_dom.boat_model.CurrentPointCenterTransom(2))) &&
3910 (comp_dom.support_points[i](0) < comp_dom.boat_model.CurrentPointCenterTransom(0)+lh*fabs(comp_dom.boat_model.CurrentPointCenterTransom(2))) &&
3911 (comp_dom.support_points[i](2) > 2.0*comp_dom.boat_model.CurrentPointCenterTransom(2)) )
3913 Point <3> dP0 = comp_dom.support_points[i];
3916 Handle(Geom_Plane) vertPlane =
new Geom_Plane(0.,1.,0.,-dP0(1));
3917 vertPlane->Transform(comp_dom.boat_model.current_loc.Inverted());
3918 Handle(Geom_Curve) curve = comp_dom.boat_model.left_transom_bspline;
3920 GeomAPI_IntCS Intersector(curve, vertPlane);
3921 int npoints = Intersector.NbPoints();
3924 double minDistance=1e7;
3925 for (
int j=0; j<npoints; ++j)
3927 gp_Pnt int_point = Intersector.Point(j+1);
3928 int_point.Transform(comp_dom.boat_model.current_loc);
3931 if (dP0.
distance(inters) < minDistance)
3933 minDistance = dP0.
distance(inters);
3937 if ( (comp_dom.support_points[i](0) > dP(0)+comp_dom.min_diameter/20.0) &&
3938 (comp_dom.support_points[i](0) < dP(0)+lh*fabs(dP(2))+comp_dom.min_diameter/20.0) )
3940 double mean_curvature;
3943 comp_dom.boat_model.boat_surface_left->normal_projection_and_diff_forms(projection,
3947 AssertThrow((dP.
distance(projection) < 1e-4*comp_dom.boat_model.boatWetLength),
ExcMessage(
"Normal projection for surface normal evaluation went wrong!"));
3948 double transom_slope = -normal(0)/normal(2);
3949 double a = -transom_slope/(lh*fabs(dP(2))) - 1/dP(2)/lh/lh;
3950 double x = comp_dom.support_points[i](0)-dP(0);
3951 comp_dom.initial_map_points(3*i+2) = a*x*x + transom_slope*x + dP(2);
3955 comp_dom.vector_constraints.distribute(comp_dom.initial_map_points);
3977 Vector<double> complete_potential_gradients(comp_dom.vector_dh.n_dofs());
3978 compute_potential_gradients(complete_potential_gradients,phi,dphi_dn);
3980 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
3982 if ( (comp_dom.flags[i] &
water) &&
3985 (comp_dom.moving_point_ids[3] != i) &&
3986 (comp_dom.moving_point_ids[4] != i) &&
3987 (comp_dom.moving_point_ids[5] != i) &&
3988 (comp_dom.moving_point_ids[6] != i) )
3990 Point<3> phi_gradient(complete_potential_gradients(3*i),complete_potential_gradients(3*i+1),complete_potential_gradients(3*i+2));
3991 Point<3> eta_gradient(-comp_dom.node_normals[i](0)/comp_dom.node_normals[i](2),-comp_dom.node_normals[i](1)/comp_dom.node_normals[i](2),0.0);
3992 double eta_dot = (phi_gradient(2)-eta_gradient*(Vinf+phi_gradient))/(1-eta_gradient(1)*comp_dom.iges_normals[i](2)/comp_dom.iges_normals[i](1));
3994 std::set <unsigned int> duplicates = comp_dom.vector_double_nodes_set[3*i+1];
3995 for (std::set <unsigned int>::iterator pos = duplicates.begin(); pos != duplicates.end(); ++pos)
3997 yp(*pos) = -eta_dot*comp_dom.iges_normals[i](2)/comp_dom.iges_normals[i](1);
4004 if (!comp_dom.no_boat)
4005 for (
unsigned int k=3; k<7; ++k)
4007 unsigned int i = comp_dom.moving_point_ids[k];
4008 Point<3> phi_gradient(complete_potential_gradients(3*i),complete_potential_gradients(3*i+1),complete_potential_gradients(3*i+2));
4009 Point<3> eta_gradient(-comp_dom.node_normals[i](0)/comp_dom.node_normals[i](2),-comp_dom.node_normals[i](1)/comp_dom.node_normals[i](2),0.0);
4010 Point<3> t(comp_dom.edges_tangents[3*i],comp_dom.edges_tangents[3*i+1],comp_dom.edges_tangents[3*i+2]);
4011 double eta_dot = (phi_gradient(2)-eta_gradient*(Vinf+phi_gradient))/(1.0-t(0)/t(2)-t(1)/t(2));
4012 std::set <unsigned int> duplicates = comp_dom.vector_double_nodes_set[3*i];
4013 for (std::set <unsigned int>::iterator pos = duplicates.begin(); pos != duplicates.end(); ++pos)
4015 yp(*pos) = eta_dot*t(0)/t(2);
4017 duplicates = comp_dom.vector_double_nodes_set[3*i+1];
4018 for (std::set <unsigned int>::iterator pos = duplicates.begin(); pos != duplicates.end(); ++pos)
4020 yp(*pos) = eta_dot*t(1)/t(2);
4032 std::vector<Point<3> > ref_vertices;
4033 std::vector<CellData<2> > ref_cells;
4036 ref_vertices.resize(4);
4037 ref_vertices[0](0)=-1.0;
4038 ref_vertices[0](1)=-1.0;
4039 ref_vertices[0](2)=0.0;
4040 ref_vertices[1](0)= 1.0;
4041 ref_vertices[1](1)=-1.0;
4042 ref_vertices[1](2)=0.0;
4043 ref_vertices[2](0)=-1.0;
4044 ref_vertices[2](1)= 1.0;
4045 ref_vertices[2](2)=0.0;
4046 ref_vertices[3](0)= 1.0;
4047 ref_vertices[3](1)= 1.0;
4048 ref_vertices[3](2)=0.0;
4050 ref_cells.resize(1);
4052 ref_cells[0].vertices[0]=0;
4053 ref_cells[0].vertices[1]=1;
4054 ref_cells[0].vertices[2]=3;
4055 ref_cells[0].vertices[3]=2;
4056 ref_cells[0].material_id = 1;
4068 update_values | update_gradients |
4069 update_cell_normal_vectors |
4070 update_quadrature_points |
4077 ref_fe_v.
reinit(ref_cell);
4083 DphiDt_sys_matrix = 0;
4084 DphiDt_sys_solution = 0;
4085 DphiDt_sys_solution_2 = 0;
4086 DphiDt_sys_solution_3 = 0;
4088 DphiDt_sys_rhs_2 = 0;
4089 DphiDt_sys_rhs_3 = 0;
4092 std::vector<double> eta_res(comp_dom.dh.n_dofs(),0.0);
4093 std::vector<double> phi_res(comp_dom.dh.n_dofs(),0.0);
4094 std::vector<double> dphi_dn_res(comp_dom.dh.n_dofs(),0.0);
4095 std::vector<double> x_smoothing_res(comp_dom.dh.n_dofs(),0.0);
4096 std::vector<double> y_smoothing_res(comp_dom.dh.n_dofs(),0.0);
4108 cell = comp_dom.dh.begin_active(),
4109 endc = comp_dom.dh.end();
4111 std::vector<fad_double> coors(3*dofs_per_cell,0.0);
4112 std::vector<fad_double> phis(dofs_per_cell,0.0);
4113 std::vector<fad_double> dphi_dns(dofs_per_cell,0.0);
4114 std::vector<fad_double> coors_dot(3*dofs_per_cell,0.0);
4115 std::vector<fad_double> phis_dot(dofs_per_cell,0.0);
4116 std::vector<fad_double> dphi_dns_dot(dofs_per_cell,0.0);
4117 std::vector<fad_double> x_displs(dofs_per_cell,0.0);
4118 std::vector<fad_double> y_displs(dofs_per_cell,0.0);
4120 std::vector<fad_double> loc_eta_res(dofs_per_cell,0.0);
4121 std::vector<fad_double> loc_phi_res(dofs_per_cell,0.0);
4122 std::vector<fad_double> loc_dphi_dn_res(dofs_per_cell,0.0);
4123 std::vector<fad_double> loc_x_smooth_res(dofs_per_cell,0.0);
4124 std::vector<fad_double> loc_y_smooth_res(dofs_per_cell,0.0);
4126 std::vector< std::vector<fad_double> > loc_stiffness_matrix(dofs_per_cell,std::vector<fad_double>(dofs_per_cell));
4127 std::vector< std::vector<fad_double> > loc_mass_matrix(dofs_per_cell,std::vector<fad_double>(dofs_per_cell));
4128 std::vector< std::vector<fad_double> > loc_supg_mass_matrix(dofs_per_cell,std::vector<fad_double>(dofs_per_cell));
4131 std::vector<unsigned int> local_dof_indices(dofs_per_cell);
4137 for (; cell!=endc; ++cell)
4149 local_DphiDt_matrix = 0;
4150 local_DphiDt_matrix_2 = 0;
4151 local_DphiDt_rhs = 0;
4152 local_DphiDt_rhs_2 = 0;
4153 local_DphiDt_rhs_3 = 0;
4155 cell->get_dof_indices(local_dof_indices);
4156 for (
unsigned int i=0; i<dofs_per_cell; ++i)
4160 loc_dphi_dn_res[i] = 0;
4161 loc_x_smooth_res[i] = 0;
4162 loc_y_smooth_res[i] = 0;
4163 for (
unsigned int j=0; j<dofs_per_cell; ++j)
4165 loc_mass_matrix[i][j] = 0;
4166 loc_supg_mass_matrix[i][j] = 0;
4167 loc_stiffness_matrix[i][j] = 0;
4172 for (
unsigned int i=0; i<dofs_per_cell; ++i)
4174 for (
unsigned int j=0; j<3; ++j)
4177 coors[3*i+j] = comp_dom.support_points[local_dof_indices[i]](j);
4178 coors[3*i+j].diff(3*i+j,10*dofs_per_cell);
4179 coors_dot[3*i+j] = nodes_velocities(3*local_dof_indices[i]+j);
4180 coors_dot[3*i+j].diff(3*i+j+5*dofs_per_cell,10*dofs_per_cell);
4185 for (
unsigned int i=0; i<dofs_per_cell; ++i)
4187 phis[i] = phi(local_dof_indices[i]);
4188 phis[i].diff(i+3*dofs_per_cell,10*dofs_per_cell);
4189 phis_dot[i] = phi_time_derivs(local_dof_indices[i]);
4190 phis_dot[i].diff(i+8*dofs_per_cell,10*dofs_per_cell);
4191 dphi_dns[i] = dphi_dn(local_dof_indices[i]);
4192 dphi_dns[i].diff(i+4*dofs_per_cell,10*dofs_per_cell);
4193 dphi_dns_dot[i] = dphi_dn_time_derivs(local_dof_indices[i]);
4194 dphi_dns_dot[i].diff(i+9*dofs_per_cell,10*dofs_per_cell);
4199 for (
unsigned int i=0; i<dofs_per_cell; ++i)
4201 x_displs[i] = coors[3*i] - comp_dom.ref_points[3*local_dof_indices[i]](0);
4202 y_displs[i] = coors[3*i+1] - comp_dom.ref_points[3*local_dof_indices[i]](1);
4209 for (
unsigned int i=0; i<dofs_per_cell; ++i)
4214 std::vector<fad_double> eta_dot_rhs_fun(n_q_points);
4215 std::vector<fad_double> phi_dot_rhs_fun(n_q_points);
4216 std::vector< Point<3,fad_double> > fluid_vel(n_q_points);
4217 std::vector<fad_double> q_JxW(n_q_points);
4220 for (
unsigned int q=0; q<n_q_points; ++q)
4232 for (
unsigned int i=0; i<dofs_per_cell; ++i)
4234 unsigned int index = local_dof_indices[i];
4249 u_deriv_pos(2)*v_deriv_pos(0)-u_deriv_pos(0)*v_deriv_pos(2),
4250 u_deriv_pos(0)*v_deriv_pos(1)-u_deriv_pos(1)*v_deriv_pos(0));
4254 q_normal/=q_jac_det;
4255 fad_double a = 1.0/((u_deriv_pos*u_deriv_pos)*(v_deriv_pos*v_deriv_pos)-(u_deriv_pos*v_deriv_pos)*(u_deriv_pos*v_deriv_pos));
4256 fad_double d11 = a*(u_deriv_pos(0)*v_deriv_pos*v_deriv_pos-v_deriv_pos(0)*u_deriv_pos*v_deriv_pos);
4257 fad_double d21 = a*(u_deriv_pos(1)*v_deriv_pos*v_deriv_pos-v_deriv_pos(1)*u_deriv_pos*v_deriv_pos);
4258 fad_double d31 = a*(u_deriv_pos(2)*v_deriv_pos*v_deriv_pos-v_deriv_pos(2)*u_deriv_pos*v_deriv_pos);
4259 fad_double d12 = a*(v_deriv_pos(0)*u_deriv_pos*u_deriv_pos-u_deriv_pos(0)*u_deriv_pos*v_deriv_pos);
4260 fad_double d22 = a*(v_deriv_pos(1)*u_deriv_pos*u_deriv_pos-u_deriv_pos(1)*u_deriv_pos*v_deriv_pos);
4261 fad_double d32 = a*(v_deriv_pos(2)*u_deriv_pos*u_deriv_pos-u_deriv_pos(2)*u_deriv_pos*v_deriv_pos);
4263 d21*u_deriv_phi+d22*v_deriv_phi,
4264 d31*u_deriv_phi+d32*v_deriv_phi);
4265 Point<3,fad_double> phi_surf_grad_corrected(phi_surf_grad(0) - phi_surf_grad(2)*q_normal(0)/q_normal(2),
4266 phi_surf_grad(1) - phi_surf_grad(2)*q_normal(1)/q_normal(2),
4275 fad_double fluid_vel_norm = fluid_vel[q].norm();
4276 if (fluid_vel_norm < 1e-3)
4277 fluid_vel_norm = -8.0e+05*pow(fluid_vel_norm,3.0) + 1.7e+03*pow(fluid_vel_norm,2.0) + 0.0001;
4279 for (
unsigned int i=0; i<dofs_per_cell; ++i)
4281 cell_diameter += pow(fluid_vel[q]*(
Point<3,fad_double>(coors[3*i],coors[3*i+1],coors[3*i+2])-center),2.0)/dofs_per_cell;
4283 cell_diameter = sqrt(cell_diameter)*2;
4285 eta_dot_rhs_fun[q] = phi_grad(2) + eta_grad*(q_nodes_vel-fluid_vel[q]);
4286 phi_dot_rhs_fun[q] = phi_grad*phi_grad/2 - g*q_eta + phi_surf_grad_corrected*(q_nodes_vel-fluid_vel[q]);
4287 q_JxW[q] = q_jac_det*ref_fe_v.
JxW(q);
4295 if (cell->material_id() == comp_dom.free_sur_ID1 ||
4296 cell->material_id() == comp_dom.free_sur_ID2 ||
4297 cell->material_id() == comp_dom.free_sur_ID3 )
4299 for (
unsigned int i=0; i<dofs_per_cell; ++i)
4305 N_i_surf_grad*fluid_vel[q]/fluid_vel_norm*cell_diameter/sqrt(2);
4306 loc_eta_res[i] -= eta_dot_rhs_fun[q]*N_i_supg*q_JxW[q];
4307 loc_phi_res[i] -= phi_dot_rhs_fun[q]*N_i_supg*q_JxW[q];
4310 local_DphiDt_rhs(i) += (phi_dot_rhs_fun[q]*N_i_supg*q_JxW[q]).val();
4311 local_DphiDt_rhs_2(i) += (eta_dot_rhs_fun[q]*N_i_supg*q_JxW[q]).val();
4327 for (
unsigned int j=0; j<dofs_per_cell; ++j)
4336 loc_stiffness_matrix[i][j] += N_i_surf_grad*N_j_surf_grad*q_JxW[q];
4344 if (cell->material_id() == comp_dom.wall_sur_ID1 ||
4345 cell->material_id() == comp_dom.wall_sur_ID2 ||
4346 cell->material_id() == comp_dom.wall_sur_ID3 )
4348 for (
unsigned int i=0; i<dofs_per_cell; ++i)
4358 for (
unsigned int j=0; j<dofs_per_cell; ++j)
4368 if (cell->material_id() != comp_dom.wall_sur_ID1 &&
4369 cell->material_id() != comp_dom.wall_sur_ID2 &&
4370 cell->material_id() != comp_dom.wall_sur_ID3 &&
4371 cell->material_id() != comp_dom.free_sur_ID1 &&
4372 cell->material_id() != comp_dom.free_sur_ID2 &&
4373 cell->material_id() != comp_dom.free_sur_ID3)
4375 for (
unsigned int i=0; i<dofs_per_cell; ++i)
4377 loc_dphi_dn_res[i] -= 0;
4381 local_DphiDt_rhs_3(i) += 0;
4383 for (
unsigned int j=0; j<dofs_per_cell; ++j)
4393 for (
unsigned int i=0; i<dofs_per_cell; ++i)
4399 N_i_surf_grad*fluid_vel[q]/fluid_vel_norm*cell_diameter/sqrt(2);
4400 for (
unsigned int j=0; j<dofs_per_cell; ++j)
4402 local_DphiDt_matrix.
add(i,j,ref_fe_v.
shape_value(j,q)*(N_i_supg*q_JxW[q]).val());
4410 for (
unsigned int i=0; i<dofs_per_cell; ++i)
4412 DphiDt_sys_rhs(local_dof_indices[i]) += local_DphiDt_rhs(i);
4413 DphiDt_sys_rhs_2(local_dof_indices[i]) += local_DphiDt_rhs_2(i);
4414 DphiDt_sys_rhs_3(local_dof_indices[i]) += local_DphiDt_rhs_3(i);
4415 for (
unsigned int j=0; j<dofs_per_cell; ++j)
4417 DphiDt_sys_matrix.add(local_dof_indices[i],local_dof_indices[j],local_DphiDt_matrix(i,j));
4418 DphiDt_sys_matrix_2.add(local_dof_indices[i],local_dof_indices[j],local_DphiDt_matrix_2(i,j));
4422 if (cell->material_id() == comp_dom.free_sur_ID1 ||
4423 cell->material_id() == comp_dom.free_sur_ID2 ||
4424 cell->material_id() == comp_dom.free_sur_ID3 )
4426 for (
unsigned int i=0; i<dofs_per_cell; ++i)
4428 for (
unsigned int j=0; j<dofs_per_cell; ++j)
4430 loc_eta_res[i] += loc_supg_mass_matrix[i][j]*coors_dot[3*j+2];
4431 loc_phi_res[i] += loc_supg_mass_matrix[i][j]*phis_dot[j];
4432 loc_x_smooth_res[i] += loc_stiffness_matrix[i][j]*(x_displs[j]-(1-blend_factor)*comp_dom.old_map_points(3*local_dof_indices[j]));
4433 loc_y_smooth_res[i] += loc_stiffness_matrix[i][j]*(y_displs[j]-(1-blend_factor)*comp_dom.old_map_points(3*local_dof_indices[j]+1));
4435 if ( !constraints.is_constrained(local_dof_indices[i]) &&
4437 !(comp_dom.flags[local_dof_indices[i]] &
near_inflow))
4439 unsigned int ii = local_dof_indices[i];
4440 eta_res[ii] += loc_eta_res[i].val();
4441 phi_res[ii] += loc_phi_res[i].val();
4444 if ( !(constraints.is_constrained(local_dof_indices[i])) &&
4445 !(comp_dom.flags[local_dof_indices[i]] &
edge) &&
4446 !(comp_dom.flags[local_dof_indices[i]] &
near_inflow))
4448 unsigned int ii = local_dof_indices[i];
4449 x_smoothing_res[ii] += loc_x_smooth_res[i].val();
4450 y_smoothing_res[ii] += loc_y_smooth_res[i].val();
4455 if (cell->material_id() != comp_dom.free_sur_ID1 &&
4456 cell->material_id() != comp_dom.free_sur_ID2 &&
4457 cell->material_id() != comp_dom.free_sur_ID3 )
4459 for (
unsigned int i=0; i<dofs_per_cell; ++i)
4461 unsigned int ii = local_dof_indices[i];
4462 for (
unsigned int j=0; j<dofs_per_cell; ++j)
4464 loc_dphi_dn_res[i] += loc_mass_matrix[i][j]*dphi_dns[j];
4466 if (!constraints.is_constrained(ii))
4468 dphi_dn_res[ii] += loc_dphi_dn_res[i].val();
4478 DphiDt_sys_matrix_copy.
reinit(DphiDt_sparsity_pattern);
4479 DphiDt_sys_matrix_copy.
copy_from(DphiDt_sys_matrix);
4486 constraints.condense(DphiDt_sys_matrix,DphiDt_sys_rhs);
4487 constraints.condense(DphiDt_sys_matrix_copy,DphiDt_sys_rhs_2);
4488 constraints.condense(DphiDt_sys_matrix_2,DphiDt_sys_rhs_3);
4496 DphiDt_direct_copy.
initialize(DphiDt_sys_matrix_copy);
4497 DphiDt_direct_2.
initialize(DphiDt_sys_matrix_2);
4499 DphiDt_direct.
vmult(DphiDt_sys_solution, DphiDt_sys_rhs);
4500 constraints.distribute(DphiDt_sys_solution);
4501 DphiDt_direct_copy.
vmult(DphiDt_sys_solution_2, DphiDt_sys_rhs_2);
4502 constraints.distribute(DphiDt_sys_solution_2);
4503 DphiDt_direct_2.
vmult(DphiDt_sys_solution_3, DphiDt_sys_rhs_3);
4504 constraints.distribute(DphiDt_sys_solution_3);
4507 DphiDt_sys_matrix.vmult(RES,DphiDt_sys_solution_2);
4509 RES.
add(DphiDt_sys_rhs_2);
4518 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); i++)
4520 if ( (comp_dom.flags[i] &
water) &&
4523 yp(3*i+2) = DphiDt_sys_solution_2(i);
4525 yp(i+comp_dom.vector_dh.n_dofs()) = DphiDt_sys_solution(i);
4530 y(i+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()) = DphiDt_sys_solution_3(i);
4538 std::map<unsigned int,unsigned int> &map_alg = rest_nonlin_prob_alg.
indices_map;
4540 for (std::map<unsigned int, unsigned int>::iterator it = map_alg.begin(); it != map_alg.end(); ++it)
4541 restart_prob_solution_alg(it->second) = y(it->first);
4542 restart_solver_alg.
solve(restart_prob_solution_alg,5);
4547 for (std::map<unsigned int, unsigned int>::iterator it = map_alg.begin(); it != map_alg.end(); ++it)
4549 y(it->first) = restart_prob_solution_alg(it->second);
4558 constraints.distribute(bem_phi);
4564 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); i++)
4566 if (comp_dom.flags[i] &
water)
4567 bem_bc(i) = bem_phi(i);
4570 if (comp_dom.flags[i] &
boat)
4571 bem_bc(i) = bem_dphi_dn(i);
4578 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
4582 comp_dom.surface_nodes(i) = 0;
4583 comp_dom.other_nodes(i) = 1;
4584 std::set<unsigned int> duplicates = comp_dom.double_nodes_set[i];
4585 duplicates.erase(i);
4587 jacobian_matrix.add(i,i,-1.0);
4588 for (std::set<unsigned int>::iterator pos = duplicates.begin(); pos !=duplicates.end(); pos++)
4590 bem_bc(i) += bem_dphi_dn(*pos)/duplicates.size();
4592 bem_dphi_dn(i) = bem_bc(i);
4602 bem.solve(bem_phi, bem_dphi_dn, bem_bc);
4612 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
4616 std::set<unsigned int> duplicates = comp_dom.double_nodes_set[i];
4617 duplicates.erase(i);
4618 bem_phi(i) = bem_phi(*duplicates.begin());
4624 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
4626 y(i+comp_dom.vector_dh.n_dofs()) = bem_phi(i);
4627 y(i+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()) = bem_dphi_dn(i);
4644 std::map<unsigned int,unsigned int> &map_diff = rest_nonlin_prob_diff.
indices_map;
4687 NewtonSolver restart_solver_diff(rest_nonlin_prob_diff);
4690 for (std::map<unsigned int, unsigned int>::iterator it = map_diff.begin(); it != map_diff.end(); ++it)
4691 restart_prob_solution_diff(it->second) = yp(it->first);
4692 restart_solver_diff.
solve(restart_prob_solution_diff,8);
4697 for (std::map<unsigned int, unsigned int>::iterator it = map_diff.begin(); it != map_diff.end(); ++it)
4699 yp(it->first) = restart_prob_solution_diff(it->second);
4741 std::cout<<
"... Done preparing interpolated solution for restart"<<std::endl;
4752 if (diameters.size() != n_dofs())
4754 diameters.
reinit(dofs_number);
4755 diameters.add(1000000);
4758 vector_cell = comp_dom.vector_dh.begin_active(),
4759 vector_endc = comp_dom.vector_dh.end();
4762 phi_cell = comp_dom.dh.begin_active(),
4763 phi_endc = comp_dom.dh.end();
4765 FEValues<dim-1,dim> fe_v(*comp_dom.mapping, comp_dom.fe, *comp_dom.quadrature,
4767 const unsigned int n_q_points = fe_v.n_quadrature_points;
4768 std::vector<unsigned int> vector_local_dof_indices(comp_dom.vector_fe.dofs_per_cell);
4769 std::vector<unsigned int> phi_local_dof_indices(comp_dom.fe.dofs_per_cell);
4771 for (; phi_cell!=phi_endc,vector_cell!=vector_endc; ++phi_cell,++vector_cell)
4775 phi_cell->get_dof_indices(phi_local_dof_indices);
4776 vector_cell->get_dof_indices(vector_local_dof_indices);
4777 for (
unsigned int i=0; i<comp_dom.vector_fe.dofs_per_cell; ++i)
4779 diameters(vector_local_dof_indices[i]) =
4780 fmin(diameters(vector_local_dof_indices[i]),vector_cell->diameter());
4782 for (
unsigned int i=0; i<comp_dom.fe.dofs_per_cell; ++i)
4784 diameters(phi_local_dof_indices[i]+comp_dom.vector_dh.n_dofs()) =
4785 fmin(diameters(phi_local_dof_indices[i]+comp_dom.vector_dh.n_dofs()),phi_cell->diameter());
4786 diameters(phi_local_dof_indices[i]+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()) =
4787 fmin(diameters(phi_local_dof_indices[i]+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()),phi_cell->diameter());
4802 nodes_alg_jac_x_delta=0;
4803 residual_and_jacobian(current_time,dst,current_sol,src_yy,nodes_alg_jac_x_delta,0.0,
false);
4806 dae_nonlin_residual = dst;
4807 dae_nonlin_residual*=-1;
4823 residual_and_jacobian(t,dst,src_yy,src_yp,nodes_alg_jac_x_delta,alpha,
false);
4826 dae_nonlin_residual = dst;
4827 dae_nonlin_residual*=-1;
4851 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
4853 pphi(i) = src(i+comp_dom.vector_dh.n_dofs());
4854 bem_pphi(i) = src(i+comp_dom.vector_dh.n_dofs());
4855 dpphi_dn(i) = src(i+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs());
4856 bem_dpphi_dn(i) = src(i+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs());
4863 constraints.distribute(bem_pphi);
4866 constraints.distribute(bem_dpphi_dn);
4869 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); i++)
4871 if (comp_dom.flags[i] &
water)
4872 bem_bc(i) = bem_pphi(i);
4874 bem_bc(i) = bem_dpphi_dn(i);
4877 bem.solve_system(bem_pphi, bem_dpphi_dn, bem_bc);
4879 jacobian_dot_matrix.vmult(dst,src);
4881 jacobian_matrix.vmult_add(dst,src);
4883 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
4886 (comp_dom.flags[i] &
water) )
4888 dst(i+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()) = dpphi_dn(i) - bem_dphi_dn(i);
4891 (!(comp_dom.flags[i] & water)) )
4893 dst(i+comp_dom.vector_dh.n_dofs()) = pphi(i) - bem_phi(i);
4911 jacobian(current_time,dst,current_sol,src_yy,src_copy,1e7);
4933 const VectorView<double> dphi_dn(comp_dom.dh.n_dofs(),src.
begin()+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs());
4936 constraints.distribute(bem_phi);
4939 constraints.distribute(bem_dphi_dn);
4942 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); i++)
4944 if (comp_dom.flags[i] &
water ||
4948 bem_bc(i) = dphi_dn(i);
4952 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
4956 comp_dom.surface_nodes(i) = 0;
4957 comp_dom.other_nodes(i) = 1;
4958 std::set<unsigned int> duplicates = comp_dom.double_nodes_set[i];
4959 duplicates.erase(i);
4961 for (std::set<unsigned int>::iterator pos = duplicates.begin(); pos !=duplicates.end(); pos++)
4963 bem_bc(i) += bem_dphi_dn(*pos)/duplicates.size();
4965 bem_dphi_dn(i) = bem_bc(i);
4970 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
4974 std::set<unsigned int> duplicates = comp_dom.double_nodes_set[i];
4975 duplicates.erase(i);
4976 unsigned int count=0;
4978 for (std::set<unsigned int>::iterator pos = duplicates.begin(); pos !=duplicates.end(); pos++)
4979 if (comp_dom.flags[*pos] &
pressure)
4982 for (std::set<unsigned int>::iterator pos = duplicates.begin(); pos !=duplicates.end(); pos++)
4984 if (comp_dom.flags[*pos] & pressure)
4986 bem_bc(i) += phi(*pos)/count;
4989 bem_phi(i) = bem_bc(i);
4993 bem.solve_system(bem_phi, bem_dphi_dn, bem_bc);
5011 jacobian_dot_matrix.vmult(dst,src);
5014 jacobian_matrix.vmult_add(dst,src);
5016 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
5018 if ( (!constraints.is_constrained(i)) &&
5019 ((comp_dom.flags[i] &
water) || (comp_dom.flags[i] &
pressure)) &&
5023 dst(i+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()) = bem_dphi_dn(i) - dphi_dn(i);
5025 else if ( (!constraints.is_constrained(i)) &&
5028 dst(i+comp_dom.vector_dh.n_dofs()) = bem_phi(i) - phi(i);
5030 else if ( (comp_dom.flags[i] & transom_on_water) )
5032 dst(i+comp_dom.vector_dh.n_dofs()) = bem_phi(i) - phi(i);
5038 dae_linear_step_residual = dae_nonlin_residual;
5039 dae_linear_step_residual.add(dst);
5041 cout<<
"Linear step residual: "<<dae_linear_step_residual.l2_norm()<<endl;
5047 static unsigned int jac_evals = 0;
5049 std::cout <<
"Jacobian matrix-vector product evaluations: " << jac_evals << std::endl;
5069 const bool is_jacobian)
5071 jacobian_matrix = 0;
5072 jacobian_dot_matrix = 0;
5074 static double old_time = -1000;
5093 const VectorView<double> dphi_dn(comp_dom.dh.n_dofs(),src_yy.
begin()+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs());
5094 const VectorView<double> dphi_dn_time_derivs(comp_dom.dh.n_dofs(),src_yp.
begin()+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs());
5104 for (
unsigned int d=0; d<3; ++d)
5106 hull_lin_vel(d) = src_yy(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+d);
5107 hull_lin_displ(d) = src_yy(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+3+d);
5108 hull_lin_vel_dot(d) = src_yp(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+d);
5109 hull_lin_displ_dot(d) = src_yp(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+3+d);
5110 hull_ang_vel(d) = src_yy(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+6+d);
5111 hull_quat_vector(d) = src_yy(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+9+d);
5112 hull_ang_vel_dot(d) = src_yp(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+6+d);
5113 hull_quat_vector_dot(d) = src_yp(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+9+d);
5115 double hull_quat_scalar = src_yy(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+12);
5116 double hull_quat_scalar_dot = src_yp(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+12);
5121 bool new_time_step =
false;
5125 new_time_step =
true;
5131 DphiDt_sys_rhs.
reinit (comp_dom.dh.n_dofs());
5132 DphiDt_sys_rhs_2.reinit (comp_dom.dh.n_dofs());
5133 DphiDt_sys_rhs_3.reinit (comp_dom.dh.n_dofs());
5134 DphiDt_sys_rhs_4.reinit (comp_dom.dh.n_dofs());
5135 DphiDt_sys_matrix.reinit(DphiDt_sparsity_pattern);
5136 DphiDt_sys_matrix_2.reinit(DphiDt_sparsity_pattern);
5147 inflow_norm_potential_grad.set_time(t);
5150 wind.vector_value(zero,instantWindValue);
5151 std::cout<<std::endl<<
"Simulation time= "<<t<<
" Vinf= ";
5152 instantWindValue.
print(std::cout,4,
false,
true);
5153 std::cout <<
"Ndofs ODE= " << dst.
size();
5154 std::cout <<
" Ndofs BEM= " << comp_dom.dh.n_dofs();
5155 std::cout<<std::endl;
5158 cout<<
"Hull Rigid Displacement: "<<hull_lin_displ<<endl;
5159 cout<<
"Restart Hull Rigid Displacement: "<<restart_hull_displacement<<endl;
5160 cout<<
"Hull Rigid Velocity: "<<hull_lin_vel<<endl;
5161 cout<<
"Hull Angular Velocity: "<<hull_ang_vel<<endl;
5165 for (
unsigned int i=0; i<comp_dom.vector_dh.n_dofs(); ++i)
5167 if (vector_constraints.is_constrained(i))
5169 jacobian_matrix.add(i,i,1.0);
5170 std::vector< std::pair< unsigned int, double > > entries = *vector_constraints.get_constraint_entries(i);
5171 for (
unsigned int k=0; k<entries.size(); ++k)
5175 jacobian_matrix.add(i,entries[k].first,-entries[k].second);
5181 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
5184 if (constraints.is_constrained(i))
5186 jacobian_matrix.add(i+comp_dom.vector_dh.n_dofs(),i+comp_dom.vector_dh.n_dofs(),-1.0);
5187 jacobian_matrix.add(i+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs(),i+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs(),-1.0);
5188 std::vector< std::pair< unsigned int, double > > entries = *constraints.get_constraint_entries(i);
5189 for (
unsigned int k=0; k<entries.size(); ++k)
5192 jacobian_matrix.add(i+comp_dom.vector_dh.n_dofs(),entries[k].first+comp_dom.vector_dh.n_dofs(),entries[k].second);
5193 jacobian_matrix.add(i+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs(),
5194 entries[k].first+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs(),entries[k].second);
5216 gp_Trsf reference_to_current_transformation = comp_dom.boat_model.set_current_position(hull_lin_displ,
5222 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
5224 if ( ((comp_dom.flags[i] &
boat) &&
5232 gp_Pnt original_boat_mesh_point =
Pnt(
Point<3>(comp_dom.ref_points[3*i](0)+comp_dom.old_map_points(3*i),
5233 comp_dom.ref_points[3*i](1)+comp_dom.old_map_points(3*i+1),
5234 comp_dom.ref_points[3*i](2)+comp_dom.old_map_points(3*i+2)));
5235 gp_Pnt boat_mesh_point = original_boat_mesh_point;
5238 boat_mesh_point.Transform(restart_hull_location.Inverted());
5244 s_x = hull_lin_displ(0);
5245 s_y = hull_lin_displ(1);
5246 s_z = hull_lin_displ(2);
5247 v_x = hull_quat_vector(0);
5248 v_y = hull_quat_vector(1);
5249 v_z = hull_quat_vector(2);
5250 s = hull_quat_scalar;
5261 comp_dom.boat_model.reference_hull_baricenter(1),
5262 comp_dom.boat_model.reference_hull_baricenter(2));
5265 s_y+comp_dom.boat_model.reference_hull_baricenter(1),
5266 s_z+comp_dom.boat_model.reference_hull_baricenter(2));
5268 Point<3,fad_double> RotMatRow1(1-2*v_y*v_y-2*v_z*v_z, 2*v_x*v_y-2*s*v_z, 2*v_x*v_z+2*s*v_y);
5269 Point<3,fad_double> RotMatRow2(2*v_x*v_y+2*s*v_z, 1-2*v_x*v_x-2*v_z*v_z, 2*v_y*v_z-2*s*v_x);
5270 Point<3,fad_double> RotMatRow3(2*v_x*v_z-2*s*v_y, 2*v_y*v_z+2*s*v_x, 1-2*v_y*v_y-2*v_x*v_x);
5272 Point<3,fad_double> ref_point_pos(boat_mesh_point.X(),boat_mesh_point.Y(),boat_mesh_point.Z());
5275 RotMatRow2*(ref_point_pos+(
fad_double(-1.0))*ref_baricenter_pos),
5276 RotMatRow3*(ref_point_pos+(
fad_double(-1.0))*ref_baricenter_pos));
5277 target_point_pos += baricenter_pos;
5283 comp_dom.rigid_motion_map_points(3*i) = target_point_pos(0).val()-ref_point_pos(0).val();
5284 comp_dom.rigid_motion_map_points(3*i+1) = target_point_pos(1).val()-ref_point_pos(1).val();
5285 comp_dom.rigid_motion_map_points(3*i+2) = target_point_pos(2).val()-ref_point_pos(2).val();
5304 Vector<double> full_map_points(comp_dom.rigid_motion_map_points);
5305 full_map_points.
add(nodes_positions);
5306 comp_dom.update_mapping(full_map_points);
5307 comp_dom.update_support_points();
5311 working_map_points = comp_dom.map_points;
5315 vector_constraints.distribute(working_map_points);
5320 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
5322 if ( !(comp_dom.flags[i] &
near_boat) &&
5323 (comp_dom.flags[i] &
water) &&
5324 (comp_dom.flags[i] &
edge) &&
5326 (!constraints.is_constrained(i)))
5328 working_map_points(3*i) = comp_dom.old_map_points(3*i);
5329 working_map_points(3*i+1) = comp_dom.old_map_points(3*i+1);
5330 jacobian_matrix.add(3*i,3*i,1.0);
5331 jacobian_matrix.add(3*i+1,3*i+1,1.0);
5334 working_map_points(3*i+2) = comp_dom.old_map_points(3*i+2);
5335 jacobian_matrix.set(3*i+2,3*i+2,1.0);
5339 else if ( !(comp_dom.flags[i] &
near_water) &&
5340 (comp_dom.flags[i] &
boat) &&
5341 (!constraints.is_constrained(i)))
5343 gp_Pnt original_boat_mesh_point =
Pnt(
Point<3>(comp_dom.ref_points[3*i](0)+comp_dom.old_map_points(3*i),
5344 comp_dom.ref_points[3*i](1)+comp_dom.old_map_points(3*i+1),
5345 comp_dom.ref_points[3*i](2)+comp_dom.old_map_points(3*i+2)));
5346 gp_Pnt boat_mesh_point = original_boat_mesh_point;
5349 boat_mesh_point.Transform(restart_hull_location.Inverted());
5350 Point<3,fad_double> ref_point_pos(boat_mesh_point.X(),boat_mesh_point.Y(),boat_mesh_point.Z());
5352 working_map_points(3*i) = ref_point_pos(0).val()-comp_dom.ref_points[3*i](0)+comp_dom.rigid_motion_map_points(3*i);
5353 working_map_points(3*i+1) = ref_point_pos(1).val()-comp_dom.ref_points[3*i](1)+comp_dom.rigid_motion_map_points(3*i+1);
5354 working_map_points(3*i+2) = ref_point_pos(2).val()-comp_dom.ref_points[3*i](2)+comp_dom.rigid_motion_map_points(3*i+2);
5355 jacobian_matrix.add(3*i,3*i,1.0);
5356 jacobian_matrix.add(3*i+1,3*i+1,1.0);
5357 jacobian_matrix.add(3*i+2,3*i+2,1.0);
5359 else if ( !(comp_dom.flags[i] & near_water) &&
5360 !(comp_dom.flags[i] &
water) &&
5361 !(comp_dom.flags[i] & boat) &&
5362 (!constraints.is_constrained(i)))
5364 working_map_points(3*i) = comp_dom.old_map_points(3*i);
5365 working_map_points(3*i+1) = comp_dom.old_map_points(3*i+1);
5366 working_map_points(3*i+2) = comp_dom.old_map_points(3*i+2);
5367 jacobian_matrix.add(3*i,3*i,1.0);
5368 jacobian_matrix.add(3*i+1,3*i+1,1.0);
5369 jacobian_matrix.add(3*i+2,3*i+2,1.0);
5374 gp_Pnt original_boat_mesh_point =
Pnt(
Point<3>(comp_dom.ref_points[3*i](0)+comp_dom.old_map_points(3*i),
5375 comp_dom.ref_points[3*i](1)+comp_dom.old_map_points(3*i+1),
5376 comp_dom.ref_points[3*i](2)+comp_dom.old_map_points(3*i+2)));
5377 gp_Pnt boat_mesh_point = original_boat_mesh_point;
5380 boat_mesh_point.Transform(restart_hull_location.Inverted());
5381 Point<3,fad_double> ref_point_pos(boat_mesh_point.X(),boat_mesh_point.Y(),boat_mesh_point.Z());
5383 working_map_points(3*i) = ref_point_pos(0).val()-comp_dom.ref_points[3*i](0)+comp_dom.rigid_motion_map_points(3*i);
5384 working_map_points(3*i+1) = ref_point_pos(1).val()-comp_dom.ref_points[3*i](1)+comp_dom.rigid_motion_map_points(3*i+1);
5385 working_map_points(3*i+2) = ref_point_pos(2).val()-comp_dom.ref_points[3*i](2)+comp_dom.rigid_motion_map_points(3*i+2);
5386 jacobian_matrix.add(3*i,3*i,1.0);
5387 jacobian_matrix.add(3*i+1,3*i+1,1.0);
5388 jacobian_matrix.add(3*i+2,3*i+2,1.0);
5400 double blend_factor = 0.0;
5407 if (t - last_remesh_time < 0.5*remeshing_period)
5408 blend_factor = sin(3.141592654*(t-last_remesh_time)/remeshing_period);
5412 std::cout<<
"blend_factor = "<<blend_factor<<std::endl;
5416 if (!comp_dom.no_boat)
5417 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
5421 s_x = hull_lin_displ(0);
5422 s_y = hull_lin_displ(1);
5423 s_z = hull_lin_displ(2);
5424 v_x = hull_quat_vector(0);
5425 v_y = hull_quat_vector(1);
5426 v_z = hull_quat_vector(2);
5427 s = hull_quat_scalar;
5438 comp_dom.boat_model.reference_hull_baricenter(1),
5439 comp_dom.boat_model.reference_hull_baricenter(2));
5443 s_y+comp_dom.boat_model.reference_hull_baricenter(1),
5444 s_z+comp_dom.boat_model.reference_hull_baricenter(2));
5446 Point<3,fad_double> RotMatRow1(1-2*v_y*v_y-2*v_z*v_z, 2*v_x*v_y-2*s*v_z, 2*v_x*v_z+2*s*v_y);
5447 Point<3,fad_double> RotMatRow2(2*v_x*v_y+2*s*v_z, 1-2*v_x*v_x-2*v_z*v_z, 2*v_y*v_z-2*s*v_x);
5448 Point<3,fad_double> RotMatRow3(2*v_x*v_z-2*s*v_y, 2*v_y*v_z+2*s*v_x, 1-2*v_y*v_y-2*v_x*v_x);
5450 if ( (comp_dom.flags[i] &
water) &&
5454 (comp_dom.moving_point_ids[3] != i) &&
5455 (comp_dom.moving_point_ids[4] != i) &&
5456 (comp_dom.moving_point_ids[5] != i) &&
5457 (comp_dom.moving_point_ids[6] != i) )
5462 double iges_curvature;
5463 Point<3> direction(comp_dom.iges_normals[i](0),comp_dom.iges_normals[i](1),0.0);
5466 if (fabs(comp_dom.old_iges_normals[i](0))<sqrt(3)/3*fabs(comp_dom.old_iges_normals[i](1)))
5472 comp_dom.boat_model.boat_water_line_right->assigned_axis_projection_and_diff_forms(proj_node,
5473 comp_dom.iges_normals[i],
5474 comp_dom.iges_mean_curvatures[i],
5475 comp_dom.support_points[i],
5481 if (fabs(comp_dom.old_iges_normals[i](0))<sqrt(3)/3*fabs(comp_dom.old_iges_normals[i](1)))
5483 working_map_points(3*i) = comp_dom.old_map_points(3*i);
5484 working_map_points(3*i+1) = proj_node(1) - comp_dom.ref_points[3*i](1);
5488 working_map_points(3*i) = proj_node(0) - comp_dom.ref_points[3*i](0);
5489 working_map_points(3*i+1) = comp_dom.old_map_points(3*i+1);
5491 working_map_points(3*i+2) = proj_node(2) - comp_dom.ref_points[3*i](2);
5495 gp_Pnt ref_point(proj_node(0),proj_node(1),proj_node(2));
5496 ref_point.Transform(reference_to_current_transformation.Inverted());
5497 gp_Vec curr_normal(comp_dom.iges_normals[i](0),comp_dom.iges_normals[i](1),comp_dom.iges_normals[i](2));
5498 gp_Dir ref_normal_dir(curr_normal);
5499 ref_normal_dir.Transform(reference_to_current_transformation.Inverted());
5504 RotMatRow2*(ref_point_pos+(
fad_double(-1.0))*ref_baricenter_pos),
5505 RotMatRow3*(ref_point_pos+(
fad_double(-1.0))*ref_baricenter_pos));
5506 target_point_pos += baricenter_pos;
5509 RotMatRow2*ref_normal,
5510 RotMatRow3*ref_normal);
5511 Point<3,fad_double> guessed_point(comp_dom.support_points[i](0),comp_dom.support_points[i](1),comp_dom.support_points[i](2));
5514 if (fabs(comp_dom.old_iges_normals[i](0))<sqrt(3)/3*fabs(comp_dom.old_iges_normals[i](1)))
5517 target_point_normal(0)/target_point_normal(1)*(guessed_point(0)-target_point_pos(0))+
5518 target_point_normal(2)/target_point_normal(1)*(guessed_point(2)-target_point_pos(2))-
5519 target_point_pos(1);
5520 jacobian_matrix.add(3*i,3*i,1.0);
5521 jacobian_matrix.add(3*i+1,3*i+1,1.0);
5522 jacobian_matrix.add(3*i+1,3*i+2,comp_dom.iges_normals[i](2)/comp_dom.iges_normals[i](1));
5523 jacobian_matrix.add(3*i+1,3*i,comp_dom.iges_normals[i](0)/comp_dom.iges_normals[i](1));
5524 for (
unsigned int d=0; d<3; ++d)
5525 jacobian_matrix.add(3*i+1,comp_dom.vector_dh.n_dofs()+
5526 comp_dom.dh.n_dofs()+
5527 comp_dom.dh.n_dofs()+
5528 3+d,residual.fastAccessDx(d));
5529 for (
unsigned int d=0; d<4; ++d)
5530 jacobian_matrix.add(3*i+1,comp_dom.vector_dh.n_dofs()+
5531 comp_dom.dh.n_dofs()+
5532 comp_dom.dh.n_dofs()+
5533 9+d,residual.fastAccessDx(3+d));
5538 target_point_normal(1)/target_point_normal(0)*(guessed_point(1)-target_point_pos(1))+
5539 target_point_normal(2)/target_point_normal(0)*(guessed_point(2)-target_point_pos(2))-
5540 target_point_pos(1);
5541 jacobian_matrix.add(3*i,3*i,1.0);
5542 jacobian_matrix.add(3*i,3*i+2,comp_dom.iges_normals[i](2)/comp_dom.iges_normals[i](0));
5543 jacobian_matrix.add(3*i,3*i+1,comp_dom.iges_normals[i](1)/comp_dom.iges_normals[i](0));
5544 jacobian_matrix.add(3*i+1,3*i+1,1.0);
5545 for (
unsigned int d=0; d<3; ++d)
5546 jacobian_matrix.add(3*i,comp_dom.vector_dh.n_dofs()+
5547 comp_dom.dh.n_dofs()+
5548 comp_dom.dh.n_dofs()+
5549 3+d,residual.fastAccessDx(d));
5550 for (
unsigned int d=0; d<4; ++d)
5551 jacobian_matrix.add(3*i,comp_dom.vector_dh.n_dofs()+
5552 comp_dom.dh.n_dofs()+
5553 comp_dom.dh.n_dofs()+
5554 9+d,residual.fastAccessDx(3+d));
5558 std::set<unsigned int> duplicates = comp_dom.double_nodes_set[i];
5559 for (std::set<unsigned int>::iterator pos = duplicates.begin(); pos !=duplicates.end(); pos++)
5561 comp_dom.iges_normals[*pos] = comp_dom.iges_normals[i];
5562 comp_dom.iges_mean_curvatures[*pos] = comp_dom.iges_mean_curvatures[i];
5568 if (!comp_dom.no_boat)
5569 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
5573 s_x = hull_lin_displ(0);
5574 s_y = hull_lin_displ(1);
5575 s_z = hull_lin_displ(2);
5576 v_x = hull_quat_vector(0);
5577 v_y = hull_quat_vector(1);
5578 v_z = hull_quat_vector(2);
5579 s = hull_quat_scalar;
5590 comp_dom.boat_model.reference_hull_baricenter(1),
5591 comp_dom.boat_model.reference_hull_baricenter(2));
5594 s_y+comp_dom.boat_model.reference_hull_baricenter(1),
5595 s_z+comp_dom.boat_model.reference_hull_baricenter(2));
5597 Point<3,fad_double> RotMatRow1(1-2*v_y*v_y-2*v_z*v_z, 2*v_x*v_y-2*s*v_z, 2*v_x*v_z+2*s*v_y);
5598 Point<3,fad_double> RotMatRow2(2*v_x*v_y+2*s*v_z, 1-2*v_x*v_x-2*v_z*v_z, 2*v_y*v_z-2*s*v_x);
5599 Point<3,fad_double> RotMatRow3(2*v_x*v_z-2*s*v_y, 2*v_y*v_z+2*s*v_x, 1-2*v_y*v_y-2*v_x*v_x);
5601 if ( (comp_dom.flags[i] &
water) &&
5605 (comp_dom.moving_point_ids[3] != i) &&
5606 (comp_dom.moving_point_ids[4] != i) &&
5607 (comp_dom.moving_point_ids[5] != i) &&
5608 (comp_dom.moving_point_ids[6] != i) )
5613 double iges_curvature;
5614 Point<3> direction(comp_dom.iges_normals[i](0),comp_dom.iges_normals[i](1),0.0);
5615 if (fabs(comp_dom.old_iges_normals[i](0))<sqrt(3)/3*fabs(comp_dom.old_iges_normals[i](1)))
5619 comp_dom.boat_model.boat_water_line_left->assigned_axis_projection_and_diff_forms(proj_node,
5620 comp_dom.iges_normals[i],
5621 comp_dom.iges_mean_curvatures[i],
5622 comp_dom.support_points[i],
5628 if (fabs(comp_dom.old_iges_normals[i](0))<sqrt(3)/3*fabs(comp_dom.old_iges_normals[i](1)))
5630 working_map_points(3*i) = comp_dom.old_map_points(3*i);
5631 working_map_points(3*i+1) = proj_node(1) - comp_dom.ref_points[3*i](1);
5635 working_map_points(3*i) = proj_node(0) - comp_dom.ref_points[3*i](0);
5636 working_map_points(3*i+1) = comp_dom.old_map_points(3*i+1);
5638 working_map_points(3*i+2) = proj_node(2) - comp_dom.ref_points[3*i](2);
5642 gp_Pnt ref_point(proj_node(0),proj_node(1),proj_node(2));
5643 ref_point.Transform(reference_to_current_transformation.Inverted());
5644 gp_Vec curr_normal(comp_dom.iges_normals[i](0),comp_dom.iges_normals[i](1),comp_dom.iges_normals[i](2));
5645 gp_Dir ref_normal_dir(curr_normal);
5646 ref_normal_dir.Transform(reference_to_current_transformation.Inverted());
5651 RotMatRow2*(ref_point_pos+(
fad_double(-1.0))*ref_baricenter_pos),
5652 RotMatRow3*(ref_point_pos+(
fad_double(-1.0))*ref_baricenter_pos));
5653 target_point_pos += baricenter_pos;
5656 RotMatRow2*ref_normal,
5657 RotMatRow3*ref_normal);
5658 Point<3,fad_double> guessed_point(comp_dom.support_points[i](0),comp_dom.support_points[i](1),comp_dom.support_points[i](2));
5660 if (fabs(comp_dom.old_iges_normals[i](0))<sqrt(3)/3*fabs(comp_dom.old_iges_normals[i](1)))
5663 target_point_normal(0)/target_point_normal(1)*(guessed_point(0)-target_point_pos(0))+
5664 target_point_normal(2)/target_point_normal(1)*(guessed_point(2)-target_point_pos(2))-
5665 target_point_pos(1);
5667 jacobian_matrix.add(3*i,3*i,1.0);
5668 jacobian_matrix.add(3*i+1,3*i+1,1.0);
5669 jacobian_matrix.add(3*i+1,3*i+2,comp_dom.iges_normals[i](2)/comp_dom.iges_normals[i](1));
5670 jacobian_matrix.add(3*i+1,3*i,comp_dom.iges_normals[i](0)/comp_dom.iges_normals[i](1));
5671 for (
unsigned int d=0; d<3; ++d)
5672 jacobian_matrix.add(3*i+1,comp_dom.vector_dh.n_dofs()+
5673 comp_dom.dh.n_dofs()+
5674 comp_dom.dh.n_dofs()+
5675 3+d,residual.fastAccessDx(d));
5676 for (
unsigned int d=0; d<4; ++d)
5677 jacobian_matrix.add(3*i+1,comp_dom.vector_dh.n_dofs()+
5678 comp_dom.dh.n_dofs()+
5679 comp_dom.dh.n_dofs()+
5680 9+d,residual.fastAccessDx(3+d));
5685 target_point_normal(1)/target_point_normal(0)*(guessed_point(1)-target_point_pos(1))+
5686 target_point_normal(2)/target_point_normal(0)*(guessed_point(2)-target_point_pos(2))-
5687 target_point_pos(1);
5688 jacobian_matrix.add(3*i,3*i,1.0);
5689 jacobian_matrix.add(3*i,3*i+2,comp_dom.iges_normals[i](2)/comp_dom.iges_normals[i](0));
5690 jacobian_matrix.add(3*i,3*i+1,comp_dom.iges_normals[i](1)/comp_dom.iges_normals[i](0));
5691 jacobian_matrix.add(3*i+1,3*i+1,1.0);
5692 for (
unsigned int d=0; d<3; ++d)
5693 jacobian_matrix.add(3*i,comp_dom.vector_dh.n_dofs()+
5694 comp_dom.dh.n_dofs()+
5695 comp_dom.dh.n_dofs()+
5696 3+d,residual.fastAccessDx(d));
5697 for (
unsigned int d=0; d<4; ++d)
5698 jacobian_matrix.add(3*i,comp_dom.vector_dh.n_dofs()+
5699 comp_dom.dh.n_dofs()+
5700 comp_dom.dh.n_dofs()+
5701 9+d,residual.fastAccessDx(3+d));
5706 std::set<unsigned int> duplicates = comp_dom.double_nodes_set[i];
5707 for (std::set<unsigned int>::iterator pos = duplicates.begin(); pos !=duplicates.end(); pos++)
5709 comp_dom.iges_normals[*pos] = comp_dom.iges_normals[i];
5710 comp_dom.iges_mean_curvatures[*pos] = comp_dom.iges_mean_curvatures[i];
5716 if (!comp_dom.no_boat)
5717 for (
unsigned int k=3; k<7; ++k)
5721 s_x = hull_lin_displ(0);
5722 s_y = hull_lin_displ(1);
5723 s_z = hull_lin_displ(2);
5724 v_x = hull_quat_vector(0);
5725 v_y = hull_quat_vector(1);
5726 v_z = hull_quat_vector(2);
5727 s = hull_quat_scalar;
5738 comp_dom.boat_model.reference_hull_baricenter(1),
5739 comp_dom.boat_model.reference_hull_baricenter(2));
5742 s_y+comp_dom.boat_model.reference_hull_baricenter(1),
5743 s_z+comp_dom.boat_model.reference_hull_baricenter(2));
5745 Point<3,fad_double> RotMatRow1(1-2*v_y*v_y-2*v_z*v_z, 2*v_x*v_y-2*s*v_z, 2*v_x*v_z+2*s*v_y);
5746 Point<3,fad_double> RotMatRow2(2*v_x*v_y+2*s*v_z, 1-2*v_x*v_x-2*v_z*v_z, 2*v_y*v_z-2*s*v_x);
5747 Point<3,fad_double> RotMatRow3(2*v_x*v_z-2*s*v_y, 2*v_y*v_z+2*s*v_x, 1-2*v_y*v_y-2*v_x*v_x);
5749 unsigned int i = comp_dom.moving_point_ids[k];
5752 Point <3> dP0 = comp_dom.support_points[i];
5755 Handle(Geom_Plane) horPlane =
new Geom_Plane(0.,0.,1.,-dP0(2));
5756 Handle(Geom_Curve) curve;
5757 TopLoc_Location L = comp_dom.boat_model.current_loc;
5758 TopLoc_Location L_inv = L.Inverted();
5762 horPlane->Transform(L_inv.Transformation());
5763 if (comp_dom.boat_model.is_transom)
5766 curve = comp_dom.boat_model.equiv_keel_bspline;
5768 curve = comp_dom.boat_model.left_transom_bspline;
5770 curve = comp_dom.boat_model.right_transom_bspline;
5774 curve = comp_dom.boat_model.equiv_keel_bspline;
5777 TopoDS_Edge
edge = BRepBuilderAPI_MakeEdge(curve);
5779 BRepAdaptor_Curve AC(edge);
5782 GeomAPI_IntCS Intersector(curve, horPlane);
5783 int npoints = Intersector.NbPoints();
5785 AssertThrow((npoints != 0),
ExcMessage(
"Keel or transom curve is not intersecting with horizontal plane!"));
5786 double minDistance=1e7;
5788 for (
int j=0; j<npoints; ++j)
5790 gp_Pnt int_point = Intersector.Point(j+1);
5791 int_point.Transform(L.Transformation());
5793 Intersector.Parameters(j+1,u,v,t);
5794 if (dP0.
distance(inters) < minDistance)
5796 minDistance = dP0.
distance(inters);
5836 working_map_points(3*i) = dP(0)-comp_dom.ref_points[3*i](0);
5837 working_map_points(3*i+1) = dP(1)-comp_dom.ref_points[3*i](1);
5838 working_map_points(3*i+2) = dP(2)-comp_dom.ref_points[3*i](2);
5839 comp_dom.edges_tangents[3*i] = V1.X();
5840 comp_dom.edges_tangents[3*i+1] = V1.Y();
5841 comp_dom.edges_tangents[3*i+2] = V1.Z();
5845 gp_Pnt ref_point(dP(0),dP(1),dP(2));
5846 ref_point.Transform(reference_to_current_transformation.Inverted());
5847 gp_Vec curr_tangent(V1.X(),V1.Y(),V1.Z());
5848 gp_Dir ref_tangent_dir(curr_tangent);
5849 ref_tangent_dir.Transform(reference_to_current_transformation.Inverted());
5854 RotMatRow2*(ref_point_pos+(
fad_double(-1.0))*ref_baricenter_pos),
5855 RotMatRow3*(ref_point_pos+(
fad_double(-1.0))*ref_baricenter_pos));
5856 target_point_pos += baricenter_pos;
5858 Point<3,fad_double> ref_tangent(ref_tangent_dir.X(),ref_tangent_dir.Y(),ref_tangent_dir.Z());
5860 RotMatRow2*ref_tangent,
5861 RotMatRow3*ref_tangent);
5863 Point<3,fad_double> guessed_point(comp_dom.support_points[i](0),comp_dom.support_points[i](1),comp_dom.support_points[i](2));
5866 target_point_tangent(0)/target_point_tangent(2)*(guessed_point(2)-target_point_pos(2)) -
5867 target_point_pos(0);
5869 target_point_tangent(1)/target_point_tangent(2)*(guessed_point(2)-target_point_pos(2)) -
5870 target_point_pos(1);
5876 jacobian_matrix.set(3*i,3*i,1.0);
5878 jacobian_matrix.set(3*i,3*i+2,-comp_dom.edges_tangents(3*i)/comp_dom.edges_tangents(3*i+2));
5880 for (
unsigned int d=0; d<3; ++d)
5881 jacobian_matrix.set(3*i,comp_dom.vector_dh.n_dofs()+
5882 comp_dom.dh.n_dofs()+
5883 comp_dom.dh.n_dofs()+
5884 3+d,residual_x.fastAccessDx(d));
5885 for (
unsigned int d=0; d<4; ++d)
5886 jacobian_matrix.set(3*i,comp_dom.vector_dh.n_dofs()+
5887 comp_dom.dh.n_dofs()+
5888 comp_dom.dh.n_dofs()+
5889 9+d,residual_x.fastAccessDx(3+d));
5890 jacobian_matrix.set(3*i+1,3*i+1,1.0);
5891 jacobian_matrix.set(3*i+1,3*i+2,-comp_dom.edges_tangents(3*i+1)/comp_dom.edges_tangents(3*i+2));
5892 for (
unsigned int d=0; d<3; ++d)
5893 jacobian_matrix.set(3*i+1,comp_dom.vector_dh.n_dofs()+
5894 comp_dom.dh.n_dofs()+
5895 comp_dom.dh.n_dofs()+
5896 3+d,residual_y.fastAccessDx(d));
5897 for (
unsigned int d=0; d<4; ++d)
5898 jacobian_matrix.set(3*i+1,comp_dom.vector_dh.n_dofs()+
5899 comp_dom.dh.n_dofs()+
5900 comp_dom.dh.n_dofs()+
5901 9+d,residual_y.fastAccessDx(3+d));
5909 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
5911 if ( (comp_dom.flags[i] &
water) &&
5912 (comp_dom.flags[i] &
edge) )
5916 s_x = hull_lin_displ(0);
5917 s_y = hull_lin_displ(1);
5918 s_z = hull_lin_displ(2);
5919 v_x = hull_quat_vector(0);
5920 v_y = hull_quat_vector(1);
5921 v_z = hull_quat_vector(2);
5922 s = hull_quat_scalar;
5934 map_x = nodes_positions(3*i);
5935 map_y = nodes_positions(3*i+1);
5936 map_z = nodes_positions(3*i+2);
5943 comp_dom.boat_model.reference_hull_baricenter(1),
5944 comp_dom.boat_model.reference_hull_baricenter(2));
5947 s_y+comp_dom.boat_model.reference_hull_baricenter(1),
5948 s_z+comp_dom.boat_model.reference_hull_baricenter(2));
5950 Point<3,fad_double> RotMatRow1(1-2*v_y*v_y-2*v_z*v_z, 2*v_x*v_y-2*s*v_z, 2*v_x*v_z+2*s*v_y);
5951 Point<3,fad_double> RotMatRow2(2*v_x*v_y+2*s*v_z, 1-2*v_x*v_x-2*v_z*v_z, 2*v_y*v_z-2*s*v_x);
5952 Point<3,fad_double> RotMatRow3(2*v_x*v_z-2*s*v_y, 2*v_y*v_z+2*s*v_x, 1-2*v_y*v_y-2*v_x*v_x);
5954 gp_Pnt original_boat_mesh_point =
Pnt(
Point<3>(comp_dom.ref_points[3*i](0)+comp_dom.old_map_points(3*i),
5955 comp_dom.ref_points[3*i](1)+comp_dom.old_map_points(3*i+1),
5956 comp_dom.ref_points[3*i](2)+comp_dom.old_map_points(3*i+2)));
5957 gp_Pnt boat_mesh_point = original_boat_mesh_point;
5960 boat_mesh_point.Transform(restart_hull_location.Inverted());
5962 Point<3,fad_double> pp_orig_ref(boat_mesh_point.X(),boat_mesh_point.Y(),boat_mesh_point.Z());
5965 RotMatRow2*(pp_orig_ref+(
fad_double(-1.0))*ref_baricenter_pos)+s_y-boat_mesh_point.Y()+map_y,
5966 RotMatRow3*(pp_orig_ref+(
fad_double(-1.0))*ref_baricenter_pos)+s_z-boat_mesh_point.Z()+map_z);
5969 std::set<unsigned int> duplicates = comp_dom.double_nodes_set[i];
5970 duplicates.erase(i);
5971 for (std::set<unsigned int>::iterator pos = duplicates.begin(); pos !=duplicates.end(); pos++)
5974 for (
unsigned int k=0; k<3; k++)
5976 working_map_points(3*(*pos)+k) = comp_dom.map_points(3*i+k);
5978 jacobian_matrix.add(3*(*pos)+k,3*(*pos)+k,1.0);
5982 for (
unsigned int d=0; d<3; d++)
5983 jacobian_matrix.add(3*(*pos)+k,3*i+d,-map_p_transf_ref(k).fastAccessDx(7+d));
5985 for (
unsigned int d=0; d<3; d++)
5986 jacobian_matrix.add(3*(*pos)+k,comp_dom.vector_dh.n_dofs()+
5987 comp_dom.dh.n_dofs()+
5988 comp_dom.dh.n_dofs()+3+d,-map_p_transf_ref(k).fastAccessDx(d));
5990 for (
unsigned int d=0; d<4; d++)
5991 jacobian_matrix.add(3*(*pos)+k,comp_dom.vector_dh.n_dofs()+
5992 comp_dom.dh.n_dofs()+
5993 comp_dom.dh.n_dofs()+9+d,-map_p_transf_ref(k).fastAccessDx(d+3));
5997 jacobian_matrix.add(3*(*pos)+k,3*i+k,-1.0);
6005 nodes_pos_res = working_map_points;
6007 nodes_pos_res.add(comp_dom.map_points);
6022 constraints.distribute(bem_phi);
6025 constraints.distribute(bem_dphi_dn);
6034 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); i++)
6036 if ((comp_dom.flags[i] &
water) ||
6040 bem_bc(i) = dphi_dn(i);
6044 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
6048 comp_dom.surface_nodes(i) = 0;
6049 comp_dom.other_nodes(i) = 1;
6050 std::set<unsigned int> duplicates = comp_dom.double_nodes_set[i];
6051 duplicates.erase(i);
6053 jacobian_matrix.add(i+comp_dom.dh.n_dofs()+comp_dom.vector_dh.n_dofs(),
6054 i+comp_dom.dh.n_dofs()+comp_dom.vector_dh.n_dofs(),
6056 for (std::set<unsigned int>::iterator pos = duplicates.begin(); pos !=duplicates.end(); pos++)
6058 bem_bc(i) += bem_dphi_dn(*pos)/duplicates.size();
6059 jacobian_matrix.add(i+comp_dom.dh.n_dofs()+comp_dom.vector_dh.n_dofs(),
6060 *pos+comp_dom.dh.n_dofs()+comp_dom.vector_dh.n_dofs(),
6061 1.0/duplicates.size());
6063 bem_dphi_dn(i) = bem_bc(i);
6067 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
6071 std::set<unsigned int> duplicates = comp_dom.double_nodes_set[i];
6072 duplicates.erase(i);
6074 unsigned int count=0;
6076 jacobian_matrix.add(i+comp_dom.vector_dh.n_dofs(),
6077 i+comp_dom.vector_dh.n_dofs(),
6079 for (std::set<unsigned int>::iterator pos = duplicates.begin(); pos !=duplicates.end(); pos++)
6080 if (comp_dom.flags[*pos] &
water)
6083 for (std::set<unsigned int>::iterator pos = duplicates.begin(); pos !=duplicates.end(); pos++)
6085 if (comp_dom.flags[*pos] & water)
6087 bem_bc(i) += phi(*pos)/count;
6089 jacobian_matrix.add(i+comp_dom.vector_dh.n_dofs(),
6090 *pos+comp_dom.vector_dh.n_dofs(),
6094 bem_phi(i) = bem_bc(i);
6099 if ( (sync_bem_with_geometry ==
true) || (new_time_step) )
6103 bem.solve(bem_phi, bem_dphi_dn, bem_bc);
6108 bem.solve_system(bem_phi, bem_dphi_dn, bem_bc);
6115 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
6117 if ( constraints.is_constrained(i))
6121 std::vector< std::pair< unsigned int, double > > entries = *constraints.get_constraint_entries(i);
6122 for (
unsigned int k=0; k<entries.size(); ++k)
6124 bem_phi(i) += entries[k].second*phi(entries[k].first);
6125 bem_dphi_dn(i) += entries[k].second*dphi_dn(entries[k].first);
6134 wind.vector_value(
Point<3>(0.0,0.0,0.0),wind_valuee);
6136 for (
unsigned int i = 0; i < dim; i++)
6137 Vinff(i) = wind_valuee(i);
6138 double eta_dryy = 1.0;
6139 if (!comp_dom.no_boat && comp_dom.boat_model.is_transom && sqrt(Vinff*Vinff) > 0.0)
6141 double transom_beamm = comp_dom.boat_model.CurrentPointRightTransom(1) - comp_dom.boat_model.CurrentPointLeftTransom(1);
6142 double transom_draftt = -comp_dom.boat_model.CurrentPointCenterTransom(2);
6143 double transom_aspect_ratioo = transom_beamm/transom_draftt;
6146 double FrTr = sqrt(Vinff*Vinff)/sqrt(9.81*transom_draftt);
6147 double ReTr = sqrt(9.81*pow(transom_draftt,3.0))/1.307e-6;
6148 eta_dryy = 0.05*pow(FrTr,2.834)*pow(transom_aspect_ratioo,0.1352)*pow(ReTr,0.01338);
6152 cout<<
"Current eta_dry: "<<eta_dryy<<endl;
6165 std::vector<Point<2> > ref_vertices;
6166 std::vector<CellData<2> > ref_cells;
6169 ref_vertices.resize(4);
6170 ref_vertices[0](0)= 0.0;
6171 ref_vertices[0](1)= 0.0;
6172 ref_vertices[1](0)= 1.0;
6173 ref_vertices[1](1)= 0.0;
6174 ref_vertices[2](0)= 0.0;
6175 ref_vertices[2](1)= 1.0;
6176 ref_vertices[3](0)= 1.0;
6177 ref_vertices[3](1)= 1.0;
6179 ref_cells.resize(1);
6181 ref_cells[0].vertices[0]=0;
6182 ref_cells[0].vertices[1]=1;
6183 ref_cells[0].vertices[2]=3;
6184 ref_cells[0].vertices[3]=2;
6185 ref_cells[0].material_id = 1;
6199 update_values | update_gradients |
6200 update_quadrature_points |
6209 ref_fe_v.
reinit(ref_cell);
6215 DphiDt_sys_matrix = 0;
6216 DphiDt_sys_solution = 0;
6217 DphiDt_sys_solution_2 = 0;
6218 DphiDt_sys_solution_3 = 0;
6220 DphiDt_sys_rhs_2 = 0;
6221 DphiDt_sys_rhs_3 = 0;
6222 DphiDt_sys_rhs_4 = 0;
6226 std::vector<double> eta_res(comp_dom.dh.n_dofs(),0.0);
6227 std::vector<double> phi_res(comp_dom.dh.n_dofs(),0.0);
6228 std::vector<double> dphi_dn_res(comp_dom.dh.n_dofs(),0.0);
6229 std::vector<double> x_smoothing_res(comp_dom.dh.n_dofs(),0.0);
6230 std::vector<double> y_smoothing_res(comp_dom.dh.n_dofs(),0.0);
6233 wind.vector_value(
Point<3>(0.0,0.0,0.0),wind_value);
6235 for (
unsigned int i = 0; i < dim; i++)
6236 Vinf(i) = wind_value(i);
6238 double amplitude = 0.02;
6239 double rho = 1025.1;
6242 if (comp_dom.no_boat)
6244 Fn = Vinf(0)/sqrt(max_z_coor_value*g);
6245 ref_height = amplitude;
6249 ref_height = fabs(comp_dom.boat_model.PointMidBot(2));
6250 Fn = Vinf(0)/sqrt(comp_dom.boat_model.boatWetLength*g);
6255 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
6260 double omega=2.4835;
6263 double time_factor = 1.0;
6264 double time_factor_deriv = 0.0;
6265 double ramp_length = 20.0;
6268 time_factor = 0.5*sin(3.141592654*(t)/ramp_length-3.141592654/2)+0.5;
6269 time_factor_deriv = 0.5*3.141592654/ramp_length*cos(3.141592654*(t)/ramp_length-3.141592654/2);
6271 double dphi_dt = omega*omega*a/k*cosh(k*(comp_dom.support_points[i](2)+h))/sinh(k*h)*cos(k*comp_dom.support_points[i](0)+omega*t)*time_factor +
6272 omega*a/k*cosh(k*(comp_dom.support_points[i](2)+h))/sinh(k*h)*sin(k*comp_dom.support_points[i](0)+omega*t)*time_factor_deriv;
6273 Point<3> grad_phi(omega*a*cosh(k*(comp_dom.support_points[i](2)+h))/sinh(k*h)*cos(k*comp_dom.support_points[i](0)+omega*t)*time_factor,
6275 omega*a*sinh(k*(comp_dom.support_points[i](2)+h))/sinh(k*h)*sin(k*comp_dom.support_points[i](0)+omega*t)*time_factor);
6279 ex_press(i) = ( -dphi_dt - 0.5*(grad_phi*grad_phi) -
6280 grad_phi(0)*instantWindValue(0)-grad_phi(1)*instantWindValue(1)-grad_phi(2)*instantWindValue(2) -
6281 comp_dom.support_points[i](2)*g ) * rho;
6294 cell = comp_dom.dh.begin_active(),
6295 endc = comp_dom.dh.end();
6297 std::vector<fad_double> ref_coors(3*dofs_per_cell);
6298 std::vector<fad_double> coors(3*dofs_per_cell);
6299 std::vector<fad_double> phis(dofs_per_cell);
6300 std::vector<fad_double> dphi_dns(dofs_per_cell);
6301 std::vector<fad_double> ref_coors_dot(3*dofs_per_cell);
6302 std::vector<fad_double> coors_dot(3*dofs_per_cell);
6303 std::vector<fad_double> phis_dot(dofs_per_cell);
6304 std::vector<fad_double> dphi_dns_dot(dofs_per_cell);
6305 std::vector<fad_double> x_displs(dofs_per_cell);
6306 std::vector<fad_double> y_displs(dofs_per_cell);
6308 std::vector<fad_double> hull_baricenter_displ(3);
6309 std::vector<fad_double> hull_baricenter_vel(3);
6310 std::vector<fad_double> hull_quaternion(4);
6311 std::vector<fad_double> hull_omega(3);
6313 std::vector<fad_double> loc_eta_res(dofs_per_cell);
6314 std::vector<fad_double> loc_phi_res(dofs_per_cell);
6315 std::vector<fad_double> loc_dphi_dn_res(dofs_per_cell);
6316 std::vector<fad_double> loc_x_smooth_res(dofs_per_cell);
6317 std::vector<fad_double> loc_y_smooth_res(dofs_per_cell);
6320 Point<3> pressure_force(0.0,0.0,0.0);
6321 Point<3> pressure_moment(0.0,0.0,0.0);
6323 std::vector< std::vector<fad_double> > loc_stiffness_matrix(dofs_per_cell);
6324 std::vector< std::vector<fad_double> > loc_mass_matrix(dofs_per_cell);
6325 std::vector< std::vector<fad_double> > loc_supg_mass_matrix(dofs_per_cell);
6327 for (
unsigned int i=0; i<dofs_per_cell; ++i)
6329 loc_stiffness_matrix[i].resize(dofs_per_cell);
6330 loc_mass_matrix[i].resize(dofs_per_cell);
6331 loc_supg_mass_matrix[i].resize(dofs_per_cell);
6334 std::vector<Point<dim> > initial_support_points(comp_dom.dh.n_dofs());
6335 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
6337 initial_support_points[i] =
Point<3>(comp_dom.ref_points[3*i](0)+comp_dom.initial_map_points(3*i),
6338 comp_dom.ref_points[3*i](1)+comp_dom.initial_map_points(3*i+1),
6339 comp_dom.ref_points[3*i](2)+comp_dom.initial_map_points(3*i+2));
6343 std::vector<unsigned int> local_dof_indices(dofs_per_cell);
6346 for (; cell!=endc; ++cell)
6360 local_DphiDt_matrix = 0;
6361 local_DphiDt_matrix_2 = 0;
6362 local_DphiDt_rhs = 0;
6363 local_DphiDt_rhs_2 = 0;
6364 local_DphiDt_rhs_3 = 0;
6365 local_DphiDt_rhs_4 = 0;
6370 cell->get_dof_indices(local_dof_indices);
6371 for (
unsigned int i=0; i<dofs_per_cell; ++i)
6375 loc_dphi_dn_res[i] = 0;
6376 loc_x_smooth_res[i] = 0;
6377 loc_y_smooth_res[i] = 0;
6378 for (
unsigned int j=0; j<dofs_per_cell; ++j)
6380 loc_mass_matrix[i][j] = 0;
6381 loc_supg_mass_matrix[i][j] = 0;
6382 loc_stiffness_matrix[i][j] = 0;
6406 for (
unsigned int j=0; j<3; ++j)
6408 hull_baricenter_vel[j] = hull_lin_vel(j);
6409 hull_baricenter_displ[j] = hull_lin_displ(j);
6410 hull_omega[j] = hull_ang_vel(j);
6411 hull_quaternion[j] = hull_quat_vector(j);
6412 hull_baricenter_vel[j].diff(10*dofs_per_cell+j,10*dofs_per_cell+13);
6413 hull_baricenter_displ[j].diff(10*dofs_per_cell+3+j,10*dofs_per_cell+13);
6414 hull_omega[j].diff(10*dofs_per_cell+6+j,10*dofs_per_cell+13);
6415 hull_quaternion[j].diff(10*dofs_per_cell+9+j,10*dofs_per_cell+13);
6417 hull_quaternion[3] = hull_quat_scalar;
6418 hull_quaternion[3].diff(10*dofs_per_cell+12,10*dofs_per_cell+13);
6421 comp_dom.boat_model.reference_hull_baricenter(1),
6422 comp_dom.boat_model.reference_hull_baricenter(2));
6424 Point<3,fad_double> baricenter_pos(hull_baricenter_displ[0]+comp_dom.boat_model.reference_hull_baricenter(0),
6425 hull_baricenter_displ[1]+comp_dom.boat_model.reference_hull_baricenter(1),
6426 hull_baricenter_displ[2]+comp_dom.boat_model.reference_hull_baricenter(2));
6428 Point<3,fad_double> RotMatRow1(1-2*hull_quaternion[1]*hull_quaternion[1]-2*hull_quaternion[2]*hull_quaternion[2],
6429 2*hull_quaternion[0]*hull_quaternion[1]-2*hull_quaternion[3]*hull_quaternion[2],
6430 2*hull_quaternion[0]*hull_quaternion[2]+2*hull_quaternion[3]*hull_quaternion[1]);
6431 Point<3,fad_double> RotMatRow2(2*hull_quaternion[0]*hull_quaternion[1]+2*hull_quaternion[3]*hull_quaternion[2],
6432 1-2*hull_quaternion[0]*hull_quaternion[0]-2*hull_quaternion[2]*hull_quaternion[2],
6433 2*hull_quaternion[1]*hull_quaternion[2]-2*hull_quaternion[3]*hull_quaternion[0]);
6434 Point<3,fad_double> RotMatRow3(2*hull_quaternion[0]*hull_quaternion[2]-2*hull_quaternion[3]*hull_quaternion[1],
6435 2*hull_quaternion[1]*hull_quaternion[2]+2*hull_quaternion[3]*hull_quaternion[0],
6436 1-2*hull_quaternion[1]*hull_quaternion[1]-2*hull_quaternion[0]*hull_quaternion[0]);
6439 for (
unsigned int i=0; i<dofs_per_cell; ++i)
6440 if ( ((comp_dom.flags[local_dof_indices[i]] &
boat) &&
6441 !(comp_dom.flags[local_dof_indices[i]] &
near_water) ) ||
6444 Point<3> reference_point_position(comp_dom.ref_points[3*local_dof_indices[i]](0)+
6445 comp_dom.map_points(3*local_dof_indices[i])-
6446 comp_dom.rigid_motion_map_points(3*local_dof_indices[i]),
6447 comp_dom.ref_points[3*local_dof_indices[i]](1)+
6448 comp_dom.map_points(3*local_dof_indices[i]+1)-
6449 comp_dom.rigid_motion_map_points(3*local_dof_indices[i]+1),
6450 comp_dom.ref_points[3*local_dof_indices[i]](2)+
6451 comp_dom.map_points(3*local_dof_indices[i]+2)-
6452 comp_dom.rigid_motion_map_points(3*local_dof_indices[i]+2));
6454 for (
unsigned int j=0; j<3; ++j)
6456 ref_coors[3*i+j] = reference_point_position(j);
6457 (ref_coors[3*i+j]).diff(3*i+j,10*dofs_per_cell+13);
6460 ref_coors_dot[3*i+j] = nodes_velocities(3*local_dof_indices[i]+j);
6461 (ref_coors_dot[3*i+j]).diff(3*i+j+5*dofs_per_cell,10*dofs_per_cell+13);
6466 RotMatRow2*(sacado_orig_point+(
fad_double(-1.0))*ref_baricenter_pos)+
6468 RotMatRow3*(sacado_orig_point+(
fad_double(-1.0))*ref_baricenter_pos)+
6480 gp_Pnt original_target_boat_mesh_point =
Pnt(
Point<3>(comp_dom.ref_points[3*local_dof_indices[i]](0)+comp_dom.old_map_points(3*i),
6481 comp_dom.ref_points[3*local_dof_indices[i]](1)+comp_dom.old_map_points(3*i+1),
6482 comp_dom.ref_points[3*local_dof_indices[i]](2)+comp_dom.old_map_points(3*i+2)));
6483 gp_Pnt target_boat_mesh_point = original_target_boat_mesh_point;
6486 target_boat_mesh_point.Transform(restart_hull_location.Inverted());
6487 Point<3,fad_double> target_ref_point(target_boat_mesh_point.X(),target_boat_mesh_point.Y(),target_boat_mesh_point.Z());
6490 RotMatRow2*(target_ref_point+(
fad_double(-1.0))*ref_baricenter_pos)+
6492 RotMatRow3*(target_ref_point+(
fad_double(-1.0))*ref_baricenter_pos)+
6497 Point<3,fad_double> sacado_non_rig_vel(ref_coors_dot[3*i],ref_coors_dot[3*i+1],ref_coors_dot[3*i+2]);
6498 Point<3,fad_double> sacado_rig_vel(hull_omega[1]*(sacado_target_point[2]-baricenter_pos(2))-
6499 hull_omega[2]*(sacado_target_point[1]-baricenter_pos(1))+hull_baricenter_vel[0],
6500 hull_omega[2]*(sacado_target_point[0]-baricenter_pos(0))-
6501 hull_omega[0]*(sacado_target_point[2]-baricenter_pos(2))+hull_baricenter_vel[1],
6502 hull_omega[0]*(sacado_target_point[1]-baricenter_pos(1))-
6503 hull_omega[1]*(sacado_target_point[0]-baricenter_pos(0))+hull_baricenter_vel[2]);
6510 for (
unsigned int j=0; j<3; ++j)
6512 coors[3*i+j] = sacado_curr_point(j);
6513 coors_dot[3*i+j] = sacado_non_rig_vel(j)+sacado_rig_vel(j);
6517 for (
unsigned int j=0; j<3; ++j)
6519 coors[3*i+j] = comp_dom.support_points[local_dof_indices[i]](j);
6520 (coors[3*i+j]).diff(3*i+j,10*dofs_per_cell+13);
6521 coors_dot[3*i+j] = nodes_velocities(3*local_dof_indices[i]+j);
6522 (coors_dot[3*i+j]).diff(3*i+j+5*dofs_per_cell,10*dofs_per_cell+13);
6524 for (
unsigned int i=0; i<dofs_per_cell; ++i)
6526 phis[i] = phi(local_dof_indices[i]);
6527 phis[i].diff(i+3*dofs_per_cell,10*dofs_per_cell+13);
6528 phis_dot[i] = phi_time_derivs(local_dof_indices[i]);
6529 phis_dot[i].diff(i+8*dofs_per_cell,10*dofs_per_cell+13);
6530 dphi_dns[i] = dphi_dn(local_dof_indices[i]);
6531 dphi_dns[i].diff(i+4*dofs_per_cell,10*dofs_per_cell+13);
6532 dphi_dns_dot[i] = dphi_dn_time_derivs(local_dof_indices[i]);
6533 dphi_dns_dot[i].diff(i+9*dofs_per_cell,10*dofs_per_cell+13);
6539 if (!comp_dom.no_boat && comp_dom.boat_model.is_transom && sqrt(Vinf*Vinf) > 0.0)
6541 gp_Pnt ref_left_transom_pnt =
Pnt(restart_transom_left_point);
6542 gp_Pnt ref_right_transom_pnt =
Pnt(restart_transom_right_point);
6543 gp_Pnt ref_center_transom_pnt =
Pnt(restart_transom_center_point);
6546 ref_left_transom_pnt.Transform(restart_hull_location.Inverted());
6547 ref_right_transom_pnt.Transform(restart_hull_location.Inverted());
6548 ref_center_transom_pnt.Transform(restart_hull_location.Inverted());
6549 Point<3,fad_double> ref_left_transom_point(ref_left_transom_pnt.X(),ref_left_transom_pnt.Y(),ref_left_transom_pnt.Z());
6550 Point<3,fad_double> ref_right_transom_point(ref_right_transom_pnt.X(),ref_right_transom_pnt.Y(),ref_right_transom_pnt.Z());
6551 Point<3,fad_double> ref_center_transom_point(ref_center_transom_pnt.X(),ref_center_transom_pnt.Y(),ref_center_transom_pnt.Z());
6553 RotMatRow1*(ref_left_transom_point+(
fad_double(-1.0))*ref_baricenter_pos),
6555 RotMatRow2*(ref_left_transom_point+(
fad_double(-1.0))*ref_baricenter_pos),
6557 RotMatRow3*(ref_left_transom_point+(
fad_double(-1.0))*ref_baricenter_pos));
6559 RotMatRow1*(ref_right_transom_point+(
fad_double(-1.0))*ref_baricenter_pos),
6561 RotMatRow2*(ref_right_transom_point+(
fad_double(-1.0))*ref_baricenter_pos),
6563 RotMatRow3*(ref_right_transom_point+(
fad_double(-1.0))*ref_baricenter_pos));
6565 RotMatRow1*(ref_center_transom_point+(
fad_double(-1.0))*ref_baricenter_pos),
6567 RotMatRow2*(ref_center_transom_point+(
fad_double(-1.0))*ref_baricenter_pos),
6569 RotMatRow3*(ref_center_transom_point+(
fad_double(-1.0))*ref_baricenter_pos));
6570 fad_double transom_beam = restart_transom_right_point(1) - restart_transom_left_point(1) +
6571 restart_transom_right_tangent(1)/restart_transom_right_tangent(2)*(curr_right_transom_point(2)-restart_transom_right_point(2))-
6572 restart_transom_left_tangent(1)/restart_transom_left_tangent(2)*(curr_left_transom_point(2)-restart_transom_left_point(2));
6573 fad_double transom_draft = -curr_center_transom_point(2);
6574 fad_double transom_aspect_ratio = transom_beam/transom_draft;
6577 fad_double FrT = sqrt(Vinf*Vinf)/sqrt(9.81*transom_draft);
6578 fad_double ReT = sqrt(9.81*pow(transom_draft,3.0))/1.307e-6;
6579 eta_dry = 0.05*pow(FrT,2.834)*pow(transom_aspect_ratio,0.1352)*pow(ReT,0.01338);
6580 if (eta_dry.val() > 1)
6582 if (cell == comp_dom.dh.begin_active())
6583 cout<<
"Sacado eta_dry: "<<eta_dry.val()<<endl;
6587 for (
unsigned int i=0; i<dofs_per_cell; ++i)
6589 x_displs[i] = coors[3*i] - comp_dom.ref_points[3*local_dof_indices[i]](0);
6590 y_displs[i] = coors[3*i+1] - comp_dom.ref_points[3*local_dof_indices[i]](1);
6596 for (
unsigned int i=0; i<dofs_per_cell; ++i)
6602 for (
unsigned int i=0; i<dofs_per_cell; ++i)
6604 fad_double dof_center_distance = sqrt( (center(0)-coors[3*i])*(center(0)-coors[3*i])+
6605 (center(1)-coors[3*i+1])*(center(1)-coors[3*i+1])+
6606 (center(2)-coors[3*i+2])*(center(2)-coors[3*i+2]) );
6607 cell_diameter += 2.0*(dof_center_distance)/dofs_per_cell;
6612 std::vector<fad_double> eta_dot_rhs_fun(n_q_points);
6613 std::vector<fad_double> phi_dot_rhs_fun(n_q_points);
6614 std::vector< Point<3,fad_double> > fluid_vel(n_q_points);
6615 std::vector<fad_double> q_JxW(n_q_points);
6618 for (
unsigned int q=0; q<n_q_points; ++q)
6634 for (
unsigned int i=0; i<dofs_per_cell; ++i)
6636 unsigned int index = local_dof_indices[i];
6658 if (fabs(cen(2)) > 1e-5 )
6660 q_init(0) += (hull_baricenter_displ[0]-
fad_double(restart_hull_displacement(0)));
6661 q_init(1) += (hull_baricenter_displ[1]-
fad_double(restart_hull_displacement(1)));
6662 q_init(2) += (hull_baricenter_displ[2]-
fad_double(restart_hull_displacement(2)));
6667 u_deriv_pos(2)*v_deriv_pos(0)-u_deriv_pos(0)*v_deriv_pos(2),
6668 u_deriv_pos(0)*v_deriv_pos(1)-u_deriv_pos(1)*v_deriv_pos(0));
6672 q_normal/=q_jac_det;
6673 fad_double a = 1.0/((u_deriv_pos*u_deriv_pos)*(v_deriv_pos*v_deriv_pos)-(u_deriv_pos*v_deriv_pos)*(u_deriv_pos*v_deriv_pos));
6674 fad_double d11 = a*(u_deriv_pos(0)*v_deriv_pos*v_deriv_pos-v_deriv_pos(0)*u_deriv_pos*v_deriv_pos);
6675 fad_double d21 = a*(u_deriv_pos(1)*v_deriv_pos*v_deriv_pos-v_deriv_pos(1)*u_deriv_pos*v_deriv_pos);
6676 fad_double d31 = a*(u_deriv_pos(2)*v_deriv_pos*v_deriv_pos-v_deriv_pos(2)*u_deriv_pos*v_deriv_pos);
6677 fad_double d12 = a*(v_deriv_pos(0)*u_deriv_pos*u_deriv_pos-u_deriv_pos(0)*u_deriv_pos*v_deriv_pos);
6678 fad_double d22 = a*(v_deriv_pos(1)*u_deriv_pos*u_deriv_pos-u_deriv_pos(1)*u_deriv_pos*v_deriv_pos);
6679 fad_double d32 = a*(v_deriv_pos(2)*u_deriv_pos*u_deriv_pos-u_deriv_pos(2)*u_deriv_pos*v_deriv_pos);
6681 d21*u_deriv_phi+d22*v_deriv_phi,
6682 d31*u_deriv_phi+d32*v_deriv_phi);
6683 Point<3,fad_double> phi_surf_grad_corrected(phi_surf_grad(0) - phi_surf_grad(2)*q_normal(0)/q_normal(2),
6684 phi_surf_grad(1) - phi_surf_grad(2)*q_normal(1)/q_normal(2),
6693 fad_double fluid_vel_norm = fluid_vel[q].norm();
6694 fad_double horiz_fluid_vel_norm = sqrt(pow(fluid_vel[q](0),2.0)+pow(fluid_vel[q](1),2.0));
6696 if (fluid_vel_norm < 1e-3)
6697 fluid_vel_norm = -8.0e+05*pow(fluid_vel_norm,3.0) + 1.7e+03*pow(fluid_vel_norm,2.0) + 0.0001;
6698 if (horiz_fluid_vel_norm < 1e-3)
6699 horiz_fluid_vel_norm = -8.0e+05*pow(horiz_fluid_vel_norm,3.0) + 1.7e+03*pow(horiz_fluid_vel_norm,2.0) + 0.0001;
6700 if (eta_grad_norm < 1e-3)
6701 eta_grad_norm = -8.0e+05*pow(eta_grad_norm,3.0) + 1.7e+03*pow(eta_grad_norm,2.0) + 0.0001;
6702 Point<3,fad_double> horiz_vel_unit_vect(fluid_vel[q](0)/horiz_fluid_vel_norm,fluid_vel[q](1)/horiz_fluid_vel_norm,0.0);
6710 fad_double breaking_wave_added_pressure = 0.0;
6711 if ( (cell->material_id() == comp_dom.free_sur_ID1 ||
6712 cell->material_id() == comp_dom.free_sur_ID2 ||
6713 cell->material_id() == comp_dom.free_sur_ID3 ))
6714 if (sqrt(q_eta*q_eta+eta_grad*eta_grad*pow(Fn,4.0))-0.1725*Fn*Fn > 0)
6721 breaking_wave_added_pressure = pow(sqrt(q_eta*q_eta+eta_grad*eta_grad*pow(Fn,4.0))-0.1725*Fn*Fn,2.0);
6727 if (q_eta+0.117*Fn*Fn < 0)
6729 else if (q_eta+0.117*Fn*Fn < 0.01)
6730 factor = pow(-1.0000e+04*pow(q_eta+0.117*Fn*Fn,3.0)+2.0000e+02*pow(q_eta+0.117*Fn*Fn,2.0),2.0);
6732 factor = 2.0*(q_eta+0.117*Fn*Fn);
6733 if (eta_grad*fluid_vel[q] > 0 )
6734 breaking_wave_added_pressure *= eta_grad*eta_grad*factor;
6736 breaking_wave_added_pressure *= eta_grad*eta_grad*factor*0.2;
6742 breaking_wave_added_pressure *= rho*g/ref_height/12.0*(fluid_vel[q]*eta_grad)/fluid_vel_norm/eta_grad_norm;
6809 transom_added_pressure = (1-eta_dry)*
fad_double(g*q_init(2));
6812 q_JxW[q] = q_jac_det*ref_fe_v.
JxW(q);
6830 if (cell->material_id() == comp_dom.free_sur_ID1 ||
6831 cell->material_id() == comp_dom.free_sur_ID2 ||
6832 cell->material_id() == comp_dom.free_sur_ID3 )
6837 fad_double Lx_boat = comp_dom.boat_model.boatWetLength;
6838 if (q_point(0).val() > Lx_boat*2.0)
6839 wave_damping_pressure = -
fad_double(1.0)*pow(q_point(0).val()-Lx_boat*2.0,2.0)/pow(Lx_boat*4.0,2.0)*q_dphi_dn;
6842 eta_grad*(q_nodes_vel-fluid_vel[q]);
6843 phi_dot_rhs_fun[q] = phi_grad*phi_grad/2 - q_point*gg + phi_surf_grad_corrected*(q_nodes_vel-fluid_vel[q])-
6844 breaking_wave_added_pressure +
6845 + (1-eta_dry)*
fad_double(g*q_init(2)) + wave_damping_pressure;
6850 for (
unsigned int i=0; i<dofs_per_cell; ++i)
6852 Point<3,fad_double> N_i_surf_grad(d11*ref_fe_v.
shape_grad(i,q)[0]+d12*ref_fe_v.
shape_grad(i,q)[1],
6856 N_i_surf_grad*fluid_vel[q]/fluid_vel_norm*cell_diameter/sqrt(2);
6857 loc_eta_res[i] -= eta_dot_rhs_fun[q]*N_i_supg*q_JxW[q];
6858 loc_phi_res[i] -= phi_dot_rhs_fun[q]*N_i_supg*q_JxW[q];
6861 local_DphiDt_rhs(i) += (phi_dot_rhs_fun[q]*N_i_supg*q_JxW[q]).val();
6862 local_DphiDt_rhs_2(i) += (eta_dot_rhs_fun[q]*N_i_supg*q_JxW[q]).val();
6871 for (
unsigned int j=0; j<dofs_per_cell; ++j)
6877 Point<3,fad_double> N_j_surf_grad(d11*ref_fe_v.
shape_grad(j,q)[0]+d12*ref_fe_v.
shape_grad(j,q)[1],
6880 loc_stiffness_matrix[i][j] += N_i_surf_grad*N_j_surf_grad*q_JxW[q];
6888 if (cell->material_id() == comp_dom.pressure_sur_ID )
6892 phi_dot_rhs_fun[q] = -q_ex_press/
fad_double(rho) + phi_grad*phi_grad/2 - q_point*gg +
6893 phi_grad*(q_nodes_vel-fluid_vel[q]);
6894 for (
unsigned int i=0; i<dofs_per_cell; ++i)
6900 N_i_surf_grad*fluid_vel[q]/fluid_vel_norm*cell_diameter/sqrt(2);
6901 loc_phi_res[i] -= phi_dot_rhs_fun[q]*N_i_supg*q_JxW[q];
6904 local_DphiDt_rhs(i) += (phi_dot_rhs_fun[q]*N_i_supg*q_JxW[q]).val();
6913 for (
unsigned int j=0; j<dofs_per_cell; ++j)
6922 loc_stiffness_matrix[i][j] += N_i_surf_grad*N_j_surf_grad*q_JxW[q];
6930 if (cell->material_id() == comp_dom.wall_sur_ID1 ||
6931 cell->material_id() == comp_dom.wall_sur_ID2 ||
6932 cell->material_id() == comp_dom.wall_sur_ID3 )
6935 fad_double dphi_dt = q_phi_dot - q_nodes_vel*phi_grad;
6941 fad_double local_pressure = -(
fad_double(rho)*(dphi_dt+q_point*gg+phi_grad*(phi_grad/2.0+VV_inf))*q_JxW[q]);
6942 loc_pressure_force += local_pressure*q_normal;
6944 Point<3,fad_double> q_mom((q_point(1)-baricenter_pos(1))*q_normal(2)-(q_point(2)-baricenter_pos(2))*q_normal(1),
6945 (q_point(2)-baricenter_pos(2))*q_normal(0)-(q_point(0)-baricenter_pos(0))*q_normal(2),
6946 (q_point(0)-baricenter_pos(0))*q_normal(1)-(q_point(1)-baricenter_pos(1))*q_normal(0));
6947 q_mom = q_mom*local_pressure;
6948 loc_pressure_moment+= q_mom;
6949 for (
unsigned int i=0; i<dofs_per_cell; ++i)
6951 loc_dphi_dn_res[i] -= (q_normal*(q_nodes_vel-VV_inf))*
6956 local_DphiDt_rhs_3(i) += (-(q_normal*(q_nodes_vel-VV_inf))*
6959 for (
unsigned int j=0; j<dofs_per_cell; ++j)
6969 if (cell->material_id() == comp_dom.inflow_sur_ID1 ||
6970 cell->material_id() == comp_dom.inflow_sur_ID2 )
6972 for (
unsigned int i=0; i<dofs_per_cell; ++i)
6981 loc_dphi_dn_res[i] -= -(inflow_norm_potential_grad.value(
Point<3>(q_point(0).val(),q_point(1).val(),q_point(2).val())))*
6986 local_DphiDt_rhs_3(i) += inflow_norm_potential_grad.value(
Point<3>(q_point(0).val(),q_point(1).val(),q_point(2).val()))*
6989 for (
unsigned int j=0; j<dofs_per_cell; ++j)
6999 if (cell->material_id() != comp_dom.wall_sur_ID1 &&
7000 cell->material_id() != comp_dom.wall_sur_ID2 &&
7001 cell->material_id() != comp_dom.wall_sur_ID3 &&
7002 cell->material_id() != comp_dom.free_sur_ID1 &&
7003 cell->material_id() != comp_dom.free_sur_ID2 &&
7004 cell->material_id() != comp_dom.free_sur_ID3 &&
7005 cell->material_id() != comp_dom.inflow_sur_ID1 &&
7006 cell->material_id() != comp_dom.inflow_sur_ID2 &&
7007 cell->material_id() != comp_dom.pressure_sur_ID)
7009 for (
unsigned int i=0; i<dofs_per_cell; ++i)
7011 loc_dphi_dn_res[i] -= 0;
7015 local_DphiDt_rhs_3(i) += 0;
7017 for (
unsigned int j=0; j<dofs_per_cell; ++j)
7027 for (
unsigned int i=0; i<dofs_per_cell; ++i)
7033 N_i_surf_grad*fluid_vel[q]/fluid_vel_norm*cell_diameter/sqrt(2);
7034 for (
unsigned int j=0; j<dofs_per_cell; ++j)
7036 local_DphiDt_matrix.
add(i,j,ref_fe_v.
shape_value(j,q)*(N_i_supg*q_JxW[q]).val());
7044 for (
unsigned int i=0; i<dofs_per_cell; ++i)
7046 DphiDt_sys_rhs(local_dof_indices[i]) += local_DphiDt_rhs(i);
7047 DphiDt_sys_rhs_2(local_dof_indices[i]) += local_DphiDt_rhs_2(i);
7048 DphiDt_sys_rhs_3(local_dof_indices[i]) += local_DphiDt_rhs_3(i);
7049 DphiDt_sys_rhs_4(local_dof_indices[i]) += local_DphiDt_rhs_4(i);
7050 for (
unsigned int j=0; j<dofs_per_cell; ++j)
7052 DphiDt_sys_matrix.add(local_dof_indices[i],local_dof_indices[j],local_DphiDt_matrix(i,j));
7053 DphiDt_sys_matrix_2.add(local_dof_indices[i],local_dof_indices[j],local_DphiDt_matrix_2(i,j));
7057 if (cell->material_id() == comp_dom.free_sur_ID1 ||
7058 cell->material_id() == comp_dom.free_sur_ID2 ||
7059 cell->material_id() == comp_dom.free_sur_ID3 )
7061 for (
unsigned int i=0; i<dofs_per_cell; ++i)
7067 for (
unsigned int j=0; j<dofs_per_cell; ++j)
7073 loc_eta_res[i] += loc_supg_mass_matrix[i][j]*coors_dot[3*j+2];
7074 loc_phi_res[i] += loc_supg_mass_matrix[i][j]*phis_dot[j];
7076 loc_x_smooth_res[i] += loc_stiffness_matrix[i][j]*(x_displs[j]-(1-blend_factor)*comp_dom.old_map_points(3*local_dof_indices[j]));
7077 loc_y_smooth_res[i] += loc_stiffness_matrix[i][j]*(y_displs[j]-(1-blend_factor)*comp_dom.old_map_points(3*local_dof_indices[j]+1));
7079 if ( !constraints.is_constrained(local_dof_indices[i]) &&
7082 unsigned int ii = local_dof_indices[i];
7083 if (!(comp_dom.flags[local_dof_indices[i]] &
near_inflow))
7084 eta_res[ii] += loc_eta_res[i].val();
7085 phi_res[ii] += loc_phi_res[i].val();
7087 for (
unsigned int j=0; j<dofs_per_cell; ++j)
7089 unsigned int jj = local_dof_indices[j];
7090 if (!(comp_dom.flags[local_dof_indices[i]] & near_inflow))
7092 for (
unsigned int k=0; k<dim; ++k)
7093 jacobian_matrix.add(3*ii+2,
7095 loc_eta_res[i].fastAccessDx(3*j+k));
7096 jacobian_matrix.add(3*ii+2,
7097 jj+comp_dom.vector_dh.n_dofs(),
7098 loc_eta_res[i].fastAccessDx(3*dofs_per_cell+j));
7099 jacobian_matrix.add(3*ii+2,
7100 jj+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs(),
7101 loc_eta_res[i].fastAccessDx(4*dofs_per_cell+j));
7103 for (
unsigned int k=0; k<dim; ++k)
7104 jacobian_matrix.add(ii+comp_dom.vector_dh.n_dofs(),
7106 loc_phi_res[i].fastAccessDx(3*j+k));
7107 jacobian_matrix.add(ii+comp_dom.vector_dh.n_dofs(),
7108 jj+comp_dom.vector_dh.n_dofs(),
7109 loc_phi_res[i].fastAccessDx(3*dofs_per_cell+j));
7110 jacobian_matrix.add(ii+comp_dom.vector_dh.n_dofs(),
7111 jj+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs(),
7112 loc_phi_res[i].fastAccessDx(4*dofs_per_cell+j));
7113 if (!(comp_dom.flags[local_dof_indices[i]] & near_inflow))
7115 for (
unsigned int k=0; k<dim; ++k)
7116 jacobian_dot_matrix.add(3*ii+2,
7118 loc_eta_res[i].fastAccessDx(5*dofs_per_cell+3*j+k));
7119 jacobian_dot_matrix.add(3*ii+2,
7120 jj+comp_dom.vector_dh.n_dofs(),
7121 loc_eta_res[i].fastAccessDx(8*dofs_per_cell+j));
7122 jacobian_dot_matrix.add(3*ii+2,
7123 jj+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs(),
7124 loc_eta_res[i].fastAccessDx(9*dofs_per_cell+j));
7126 for (
unsigned int k=0; k<dim; ++k)
7127 jacobian_dot_matrix.add(ii+comp_dom.vector_dh.n_dofs(),
7129 loc_phi_res[i].fastAccessDx(5*dofs_per_cell+3*j+k));
7130 jacobian_dot_matrix.add(ii+comp_dom.vector_dh.n_dofs(),
7131 jj+comp_dom.vector_dh.n_dofs(),
7132 loc_phi_res[i].fastAccessDx(8*dofs_per_cell+j));
7133 jacobian_dot_matrix.add(ii+comp_dom.vector_dh.n_dofs(),
7134 jj+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs(),
7135 loc_phi_res[i].fastAccessDx(9*dofs_per_cell+j));
7137 if (!(comp_dom.flags[local_dof_indices[i]] & near_inflow))
7139 for (
unsigned int k=0; k<dim; ++k)
7140 jacobian_matrix.add(3*ii+2,
7141 k+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7142 loc_eta_res[i].fastAccessDx(k+10*dofs_per_cell));
7143 for (
unsigned int k=0; k<dim; ++k)
7144 jacobian_matrix.add(3*ii+2,
7145 k+3+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7146 loc_eta_res[i].fastAccessDx(k+3+10*dofs_per_cell));
7147 for (
unsigned int k=0; k<dim; ++k)
7148 jacobian_matrix.add(3*ii+2,
7149 k+6+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7150 loc_eta_res[i].fastAccessDx(k+6+10*dofs_per_cell));
7151 for (
unsigned int k=0; k<4; ++k)
7152 jacobian_matrix.add(3*ii+2,
7153 k+9+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7154 loc_eta_res[i].fastAccessDx(k+9+10*dofs_per_cell));
7156 for (
unsigned int k=0; k<dim; ++k)
7157 jacobian_matrix.add(ii+comp_dom.vector_dh.n_dofs(),
7158 k+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7159 loc_phi_res[i].fastAccessDx(k+10*dofs_per_cell));
7160 for (
unsigned int k=0; k<dim; ++k)
7161 jacobian_matrix.add(ii+comp_dom.vector_dh.n_dofs(),
7162 k+3+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7163 loc_phi_res[i].fastAccessDx(k+3+10*dofs_per_cell));
7164 for (
unsigned int k=0; k<dim; ++k)
7165 jacobian_matrix.add(ii+comp_dom.vector_dh.n_dofs(),
7166 k+6+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7167 loc_phi_res[i].fastAccessDx(k+6+10*dofs_per_cell));
7168 for (
unsigned int k=0; k<4; ++k)
7169 jacobian_matrix.add(ii+comp_dom.vector_dh.n_dofs(),
7170 k+9+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7171 loc_phi_res[i].fastAccessDx(k+9+10*dofs_per_cell));
7174 if ( !(constraints.is_constrained(local_dof_indices[i])) &&
7175 !(comp_dom.flags[local_dof_indices[i]] &
edge) )
7177 unsigned int ii = local_dof_indices[i];
7180 x_smoothing_res[ii] += loc_x_smooth_res[i].val();
7181 y_smoothing_res[ii] += loc_y_smooth_res[i].val();
7182 for (
unsigned int j=0; j<dofs_per_cell; ++j)
7190 unsigned int jj = local_dof_indices[j];
7191 for (
unsigned int k=0; k<dim; ++k)
7192 jacobian_matrix.add(3*ii,
7194 loc_x_smooth_res[i].fastAccessDx(3*j+k));
7195 jacobian_matrix.add(3*ii,
7196 jj+comp_dom.vector_dh.n_dofs(),
7197 loc_x_smooth_res[i].fastAccessDx(3*dofs_per_cell+j));
7198 jacobian_matrix.add(3*ii,
7199 jj+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs(),
7200 loc_x_smooth_res[i].fastAccessDx(4*dofs_per_cell+j));
7203 for (
unsigned int k=0; k<dim; ++k)
7204 jacobian_matrix.add(3*ii+1,
7206 loc_y_smooth_res[i].fastAccessDx(3*j+k));
7207 jacobian_matrix.add(3*ii+1,
7208 jj+comp_dom.vector_dh.n_dofs(),
7209 loc_y_smooth_res[i].fastAccessDx(3*dofs_per_cell+j));
7210 jacobian_matrix.add(3*ii+1,
7211 jj+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs(),
7212 loc_y_smooth_res[i].fastAccessDx(4*dofs_per_cell+j));
7214 for (
unsigned int k=0; k<dim; ++k)
7215 jacobian_matrix.add(3*ii,
7216 k+3+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7217 loc_x_smooth_res[i].fastAccessDx(k+3+10*dofs_per_cell));
7218 for (
unsigned int k=0; k<4; ++k)
7219 jacobian_matrix.add(3*ii,
7220 k+9+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7221 loc_x_smooth_res[i].fastAccessDx(k+9+10*dofs_per_cell));
7222 for (
unsigned int k=0; k<dim; ++k)
7223 jacobian_matrix.add(3*ii+1,
7224 k+3+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7225 loc_y_smooth_res[i].fastAccessDx(k+3+10*dofs_per_cell));
7226 for (
unsigned int k=0; k<dim; ++k)
7227 jacobian_matrix.add(3*ii+1,
7228 k+9+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7229 loc_y_smooth_res[i].fastAccessDx(k+9+10*dofs_per_cell));
7233 if (cell->material_id() == comp_dom.pressure_sur_ID)
7235 for (
unsigned int i=0; i<dofs_per_cell; ++i)
7237 for (
unsigned int j=0; j<dofs_per_cell; ++j)
7239 loc_phi_res[i] += loc_supg_mass_matrix[i][j]*phis_dot[j];
7243 if ( !constraints.is_constrained(local_dof_indices[i]) &&
7244 !(comp_dom.flags[local_dof_indices[i]] &
near_water))
7246 unsigned int ii = local_dof_indices[i];
7247 phi_res[ii] += loc_phi_res[i].val();
7249 for (
unsigned int j=0; j<dofs_per_cell; ++j)
7251 unsigned int jj = local_dof_indices[j];
7263 for (
unsigned int k=0; k<dim; ++k)
7264 jacobian_matrix.add(ii+comp_dom.vector_dh.n_dofs(),
7266 loc_phi_res[i].fastAccessDx(3*j+k));
7267 jacobian_matrix.add(ii+comp_dom.vector_dh.n_dofs(),
7268 jj+comp_dom.vector_dh.n_dofs(),
7269 loc_phi_res[i].fastAccessDx(3*dofs_per_cell+j));
7270 jacobian_matrix.add(ii+comp_dom.vector_dh.n_dofs(),
7271 jj+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs(),
7272 loc_phi_res[i].fastAccessDx(4*dofs_per_cell+j));
7273 for (
unsigned int k=0; k<dim; ++k)
7274 jacobian_dot_matrix.add(ii+comp_dom.vector_dh.n_dofs(),
7276 loc_phi_res[i].fastAccessDx(5*dofs_per_cell+3*j+k));
7277 jacobian_dot_matrix.add(ii+comp_dom.vector_dh.n_dofs(),
7278 jj+comp_dom.vector_dh.n_dofs(),
7279 loc_phi_res[i].fastAccessDx(8*dofs_per_cell+j));
7280 jacobian_dot_matrix.add(ii+comp_dom.vector_dh.n_dofs(),
7281 jj+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs(),
7282 loc_phi_res[i].fastAccessDx(9*dofs_per_cell+j));
7288 if (cell->material_id() != comp_dom.free_sur_ID1 &&
7289 cell->material_id() != comp_dom.free_sur_ID2 &&
7290 cell->material_id() != comp_dom.free_sur_ID3 )
7293 if (cell->material_id() == comp_dom.wall_sur_ID1 ||
7294 cell->material_id() == comp_dom.wall_sur_ID2 ||
7295 cell->material_id() == comp_dom.wall_sur_ID3 )
7297 for (
unsigned int d=0; d<3; ++d)
7299 pressure_force(d)+=loc_pressure_force(d).val();
7300 pressure_moment(d)+=loc_pressure_moment(d).val();
7302 for (
unsigned int j=0; j<dofs_per_cell; ++j)
7304 unsigned int jj = local_dof_indices[j];
7306 if (is_hull_x_translation_imposed !=
true)
7308 for (
unsigned int d=0; d<3; ++d)
7309 jacobian_matrix.add(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7311 -loc_pressure_force(0).fastAccessDx(3*j+d));
7312 jacobian_matrix.add(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7313 comp_dom.vector_dh.n_dofs()+jj,
7314 -loc_pressure_force(0).fastAccessDx(j+3*dofs_per_cell));
7315 jacobian_matrix.add(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7316 comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+jj,
7317 -loc_pressure_force(0).fastAccessDx(j+4*dofs_per_cell));
7318 for (
unsigned int d=0; d<3; ++d)
7319 jacobian_dot_matrix.add(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7321 -loc_pressure_force(0).fastAccessDx(3*j+d+5*dofs_per_cell));
7322 jacobian_dot_matrix.add(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7323 comp_dom.vector_dh.n_dofs()+jj,
7324 -loc_pressure_force(0).fastAccessDx(j+8*dofs_per_cell));
7325 jacobian_dot_matrix.add(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7326 comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+jj,
7327 -loc_pressure_force(0).fastAccessDx(j+9*dofs_per_cell));
7329 if (is_hull_y_translation_imposed !=
true)
7331 for (
unsigned int d=0; d<3; ++d)
7332 jacobian_matrix.add(1+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7334 -loc_pressure_force(1).fastAccessDx(3*j+d));
7335 jacobian_matrix.add(1+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7336 comp_dom.vector_dh.n_dofs()+jj,
7337 -loc_pressure_force(1).fastAccessDx(j+3*dofs_per_cell));
7338 jacobian_matrix.add(1+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7339 comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+jj,
7340 -loc_pressure_force(1).fastAccessDx(j+4*dofs_per_cell));
7341 for (
unsigned int d=0; d<3; ++d)
7342 jacobian_dot_matrix.add(1+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7344 -loc_pressure_force(1).fastAccessDx(3*j+d+5*dofs_per_cell));
7345 jacobian_dot_matrix.add(1+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7346 comp_dom.vector_dh.n_dofs()+jj,
7347 -loc_pressure_force(1).fastAccessDx(j+8*dofs_per_cell));
7348 jacobian_dot_matrix.add(1+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7349 comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+jj,
7350 -loc_pressure_force(1).fastAccessDx(j+9*dofs_per_cell));
7352 if (is_hull_z_translation_imposed !=
true)
7354 for (
unsigned int d=0; d<3; ++d)
7355 jacobian_matrix.add(2+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7357 -loc_pressure_force(2).fastAccessDx(3*j+d));
7358 jacobian_matrix.add(2+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7359 comp_dom.vector_dh.n_dofs()+jj,
7360 -loc_pressure_force(2).fastAccessDx(j+3*dofs_per_cell));
7361 jacobian_matrix.add(2+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7362 comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+jj,
7363 -loc_pressure_force(2).fastAccessDx(j+4*dofs_per_cell));
7364 for (
unsigned int d=0; d<3; ++d)
7365 jacobian_dot_matrix.add(2+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7367 -loc_pressure_force(2).fastAccessDx(3*j+d+5*dofs_per_cell));
7368 jacobian_dot_matrix.add(2+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7369 comp_dom.vector_dh.n_dofs()+jj,
7370 -loc_pressure_force(2).fastAccessDx(j+8*dofs_per_cell));
7371 jacobian_dot_matrix.add(2+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7372 comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+jj,
7373 -loc_pressure_force(2).fastAccessDx(j+9*dofs_per_cell));
7403 for (
unsigned int d=0; d<3; ++d)
7404 jacobian_matrix.add(7+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7406 -loc_pressure_moment(1).fastAccessDx(3*j+d));
7407 jacobian_matrix.add(7+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7408 comp_dom.vector_dh.n_dofs()+jj,
7409 -loc_pressure_moment(1).fastAccessDx(j+3*dofs_per_cell));
7410 jacobian_matrix.add(7+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7411 comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+jj,
7412 -loc_pressure_moment(1).fastAccessDx(j+4*dofs_per_cell));
7413 for (
unsigned int d=0; d<3; ++d)
7414 jacobian_dot_matrix.add(7+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7416 -loc_pressure_moment(1).fastAccessDx(3*j+d+5*dofs_per_cell));
7417 jacobian_dot_matrix.add(7+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7418 comp_dom.vector_dh.n_dofs()+jj,
7419 -loc_pressure_moment(1).fastAccessDx(j+8*dofs_per_cell));
7420 jacobian_dot_matrix.add(7+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7421 comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+jj,
7422 -loc_pressure_moment(1).fastAccessDx(j+9*dofs_per_cell));
7451 if (is_hull_x_translation_imposed !=
true)
7454 for (
unsigned int d=0; d<3; ++d)
7455 jacobian_matrix.add(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7456 d+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7457 -loc_pressure_force(0).fastAccessDx(d+10*dofs_per_cell));
7458 for (
unsigned int d=0; d<3; ++d)
7459 jacobian_matrix.add(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7460 d+3+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7461 -loc_pressure_force(0).fastAccessDx(d+3+10*dofs_per_cell));
7462 for (
unsigned int d=0; d<3; ++d)
7463 jacobian_matrix.add(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7464 d+6+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7465 -loc_pressure_force(0).fastAccessDx(d+6+10*dofs_per_cell));
7466 for (
unsigned int d=0; d<4; ++d)
7467 jacobian_matrix.add(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7468 d+9+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7469 -loc_pressure_force(0).fastAccessDx(d+9+10*dofs_per_cell));
7471 if (is_hull_y_translation_imposed !=
true)
7473 for (
unsigned int d=0; d<3; ++d)
7474 jacobian_matrix.add(1+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7475 d+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7476 -loc_pressure_force(1).fastAccessDx(d+10*dofs_per_cell));
7477 for (
unsigned int d=0; d<3; ++d)
7478 jacobian_matrix.add(1+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7479 d+3+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7480 -loc_pressure_force(1).fastAccessDx(d+3+10*dofs_per_cell));
7481 for (
unsigned int d=0; d<3; ++d)
7482 jacobian_matrix.add(1+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7483 d+6+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7484 -loc_pressure_force(1).fastAccessDx(d+6+10*dofs_per_cell));
7485 for (
unsigned int d=0; d<4; ++d)
7486 jacobian_matrix.add(1+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7487 d+9+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7488 -loc_pressure_force(1).fastAccessDx(d+9+10*dofs_per_cell));
7490 if (is_hull_z_translation_imposed !=
true)
7492 for (
unsigned int d=0; d<3; ++d)
7493 jacobian_matrix.add(2+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7494 d+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7495 -loc_pressure_force(2).fastAccessDx(d+10*dofs_per_cell));
7496 for (
unsigned int d=0; d<3; ++d)
7497 jacobian_matrix.add(2+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7498 d+3+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7499 -loc_pressure_force(2).fastAccessDx(d+3+10*dofs_per_cell));
7500 for (
unsigned int d=0; d<3; ++d)
7501 jacobian_matrix.add(2+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7502 d+6+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7503 -loc_pressure_force(2).fastAccessDx(d+6+10*dofs_per_cell));
7504 for (
unsigned int d=0; d<4; ++d)
7505 jacobian_matrix.add(2+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7506 d+9+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7507 -loc_pressure_force(2).fastAccessDx(d+9+10*dofs_per_cell));
7533 for (
unsigned int d=0; d<3; ++d)
7534 jacobian_matrix.add(7+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7535 d+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7536 -loc_pressure_moment(1).fastAccessDx(d+10*dofs_per_cell));
7537 for (
unsigned int d=0; d<3; ++d)
7538 jacobian_matrix.add(7+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7539 d+3+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7540 -loc_pressure_moment(1).fastAccessDx(d+3+10*dofs_per_cell));
7541 for (
unsigned int d=0; d<3; ++d)
7542 jacobian_matrix.add(7+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7543 d+6+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7544 -loc_pressure_moment(1).fastAccessDx(d+6+10*dofs_per_cell));
7545 for (
unsigned int d=0; d<4; ++d)
7546 jacobian_matrix.add(7+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7547 d+9+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7548 -loc_pressure_moment(1).fastAccessDx(d+9+10*dofs_per_cell));
7573 for (
unsigned int i=0; i<dofs_per_cell; ++i)
7575 unsigned int ii = local_dof_indices[i];
7576 for (
unsigned int j=0; j<dofs_per_cell; ++j)
7578 loc_dphi_dn_res[i] += loc_mass_matrix[i][j]*dphi_dns[j];
7580 if (!constraints.is_constrained(ii))
7582 dphi_dn_res[ii] += loc_dphi_dn_res[i].val();
7584 for (
unsigned int j=0; j<dofs_per_cell; ++j)
7586 unsigned int jj = local_dof_indices[j];
7587 for (
unsigned int k=0; k<dim; ++k)
7588 jacobian_matrix.add(ii+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs(),
7590 loc_dphi_dn_res[i].fastAccessDx(3*j+k));
7591 for (
unsigned int k=0; k<dim; ++k)
7592 jacobian_dot_matrix.add(ii+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs(),
7594 loc_dphi_dn_res[i].fastAccessDx(5*dofs_per_cell+3*j+k));
7595 jacobian_matrix.add(ii+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs(),
7596 jj+comp_dom.vector_dh.n_dofs(),
7597 loc_dphi_dn_res[i].fastAccessDx(3*dofs_per_cell+j));
7598 jacobian_matrix.add(ii+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs(),
7599 jj+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs(),
7600 loc_dphi_dn_res[i].fastAccessDx(4*dofs_per_cell+j));
7602 for (
unsigned int k=0; k<dim; ++k)
7603 jacobian_matrix.add(ii+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs(),
7604 k+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7605 loc_dphi_dn_res[i].fastAccessDx(k+10*dofs_per_cell));
7606 for (
unsigned int k=0; k<dim; ++k)
7607 jacobian_matrix.add(ii+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs(),
7608 k+3+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7609 loc_dphi_dn_res[i].fastAccessDx(k+3+10*dofs_per_cell));
7610 for (
unsigned int k=0; k<dim; ++k)
7611 jacobian_matrix.add(ii+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs(),
7612 k+6+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7613 loc_dphi_dn_res[i].fastAccessDx(k+6+10*dofs_per_cell));
7614 for (
unsigned int k=0; k<4; ++k)
7615 jacobian_matrix.add(ii+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs(),
7616 k+9+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7617 loc_dphi_dn_res[i].fastAccessDx(k+9+10*dofs_per_cell));
7625 Point<3> hull_lin_vel_res(0.0,0.0,0.0);
7626 Point<3> hull_lin_displ_res(0.0,0.0,0.0);
7630 hull_lin_vel_res+= comp_dom.boat_model.boat_mass*hull_lin_vel_dot;
7632 for (
unsigned int d=0; d<3; ++d)
7633 jacobian_dot_matrix.add(d+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7634 d+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7635 comp_dom.boat_model.boat_mass);
7638 hull_lin_displ_res+= hull_lin_displ_dot - hull_lin_vel;
7639 for (
unsigned int d=0; d<3; ++d)
7641 jacobian_dot_matrix.
add(d+3+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7642 d+3+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7644 jacobian_matrix.add(d+3+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7645 d+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7651 cout<<
"The current pressure force is: "<<pressure_force<<endl;
7652 cout<<
"The current pressure moment is: "<<pressure_moment<<endl;
7653 if (is_hull_x_translation_imposed)
7658 double accel = ( hull_x_axis_translation.value(time+delta_t) -
7659 2*hull_x_axis_translation.value(time) +
7660 hull_x_axis_translation.value(time+(-1.0*delta_t)) ) / delta_t(0) / delta_t(0);
7661 cout<<
"********Test Laplacian x: "<<accel<<endl;
7662 hull_lin_vel_res(0)-= accel*comp_dom.boat_model.boat_mass;
7666 hull_lin_vel_res(0)-= pressure_force(0);
7669 if (is_hull_y_translation_imposed)
7674 double accel = ( hull_y_axis_translation.value(time+delta_t) -
7675 2*hull_y_axis_translation.value(time) +
7676 hull_y_axis_translation.value(time+(-1.0*delta_t)) ) / delta_t(0) / delta_t(0);
7677 cout<<
"********Test Laplacian y: "<<accel<<endl;
7678 hull_lin_vel_res(1)-= accel*comp_dom.boat_model.boat_mass;
7682 hull_lin_vel_res(1)-= pressure_force(1);
7685 if (is_hull_z_translation_imposed)
7690 double accel = ( hull_z_axis_translation.value(time+delta_t) -
7691 2*hull_z_axis_translation.value(time) +
7692 hull_z_axis_translation.value(time+(-1.0*delta_t)) ) / delta_t(0) / delta_t(0);
7694 cout<<
"********Test Laplacian z: "<<accel<<endl;
7695 hull_lin_vel_res(2)-= accel*comp_dom.boat_model.boat_mass;
7699 hull_lin_vel_res(2)-= pressure_force(2);
7700 hull_lin_vel_res(2)-= (-g*comp_dom.boat_model.boat_mass);
7701 cout<<
"************ "<<pressure_force(2)<<
" vs "<<-g *comp_dom.boat_model.boat_mass<<endl;
7706 fad_double omega_x,omega_y,omega_z,v_x,v_y,v_z,s;
7707 fad_double omega_x_dot,omega_y_dot,omega_z_dot,v_x_dot,v_y_dot,v_z_dot,s_dot;
7709 omega_x_dot = hull_ang_vel_dot(0);
7710 omega_y_dot = hull_ang_vel_dot(1);
7711 omega_z_dot = hull_ang_vel_dot(2);
7712 v_x_dot = hull_quat_vector_dot(0);
7713 v_y_dot = hull_quat_vector_dot(1);
7714 v_z_dot = hull_quat_vector_dot(2);
7715 s_dot = hull_quat_scalar_dot;
7716 omega_x = hull_ang_vel(0);
7717 omega_y = hull_ang_vel(1);
7718 omega_z = hull_ang_vel(2);
7719 v_x = hull_quat_vector(0);
7720 v_y = hull_quat_vector(1);
7721 v_z = hull_quat_vector(2);
7722 s = hull_quat_scalar;
7724 omega_x_dot.diff(0,14);
7725 omega_y_dot.diff(1,14);
7726 omega_z_dot.diff(2,14);
7739 Point<3,fad_double> RotMatRow1(1-2*v_y*v_y-2*v_z*v_z, 2*v_x*v_y-2*s*v_z, 2*v_x*v_z+2*s*v_y);
7740 Point<3,fad_double> RotMatRow2(2*v_x*v_y+2*s*v_z, 1-2*v_x*v_x-2*v_z*v_z, 2*v_y*v_z-2*s*v_x);
7741 Point<3,fad_double> RotMatRow3(2*v_x*v_z-2*s*v_y, 2*v_y*v_z+2*s*v_x, 1-2*v_y*v_y-2*v_x*v_x);
7746 Point<3,fad_double> servMatRow1(RotMatRow1*RelInertiaMatRow1, RotMatRow1*RelInertiaMatRow2, RotMatRow1*RelInertiaMatRow3);
7747 Point<3,fad_double> servMatRow2(RotMatRow2*RelInertiaMatRow1, RotMatRow2*RelInertiaMatRow2, RotMatRow2*RelInertiaMatRow3);
7748 Point<3,fad_double> servMatRow3(RotMatRow3*RelInertiaMatRow1, RotMatRow3*RelInertiaMatRow2, RotMatRow3*RelInertiaMatRow3);
7750 Point<3,fad_double> AbsInertiaMatRow1(servMatRow1*RotMatRow1, servMatRow1*RotMatRow2, servMatRow1*RotMatRow3);
7751 Point<3,fad_double> AbsInertiaMatRow2(servMatRow2*RotMatRow1, servMatRow2*RotMatRow2, servMatRow2*RotMatRow3);
7752 Point<3,fad_double> AbsInertiaMatRow3(servMatRow3*RotMatRow1, servMatRow3*RotMatRow2, servMatRow3*RotMatRow3);
7760 Point<3,fad_double> sservMatRow1(WMatRow1*AbsInertiaMatRow1, WMatRow1*AbsInertiaMatRow2, WMatRow1*AbsInertiaMatRow3);
7761 Point<3,fad_double> sservMatRow2(WMatRow2*AbsInertiaMatRow1, WMatRow2*AbsInertiaMatRow2, WMatRow2*AbsInertiaMatRow3);
7762 Point<3,fad_double> sservMatRow3(WMatRow3*AbsInertiaMatRow1, WMatRow3*AbsInertiaMatRow2, WMatRow3*AbsInertiaMatRow3);
7767 vv/=sqrt(v_x*v_x+v_y*v_y+v_z*v_z+s*s);
7769 fad_double ss = s/sqrt(v_x*v_x+v_y*v_y+v_z*v_z+s*s);
7774 Point<3,fad_double> rhs_quat_vect(ss*omega_x+WMatRow1*vv,ss*omega_y+WMatRow2*vv,ss*omega_z+WMatRow1*vv);
7786 Point<3,fad_double> hull_ang_vel_res(AbsInertiaMatRow1*omega_dot, AbsInertiaMatRow2*omega_dot, AbsInertiaMatRow3*omega_dot);
7787 hull_ang_vel_res = hull_ang_vel_res +
Point<3,fad_double>(sservMatRow1*omega,sservMatRow3*omega,sservMatRow3*omega);
7789 for (
unsigned int k=0; k<3; ++k)
7791 for (
unsigned int d=0; d<7; ++d)
7792 jacobian_dot_matrix.add(6+k+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7793 6+d+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7794 hull_ang_vel_res(k).fastAccessDx(d));
7795 for (
unsigned int d=0; d<7; ++d)
7796 jacobian_matrix.add(6+k+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7797 6+d+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7798 hull_ang_vel_res(k).fastAccessDx(7+d));
7806 cout<<
"Moment Fraction Considered: "<<(t<10.0? 0.0:(t<15.0? (t-10.0)/5.0:1.0))<<endl;
7807 hull_ang_vel_res(1) = hull_ang_vel_res(1) - pressure_moment(1);
7809 hull_quaternions_scal_res = s_dot + omega*vv/2.0;
7811 for (
unsigned int k=0; k<3; ++k)
7813 hull_quaternions_vect_res(k) = vv_dot(k) - rhs_quat_vect(k)/2.0;
7816 for (
unsigned int k=0; k<3; ++k)
7818 for (
unsigned int d=0; d<7; ++d)
7819 jacobian_dot_matrix.add(9+k+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7820 6+d+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7821 hull_quaternions_vect_res(k).fastAccessDx(d));
7822 for (
unsigned int d=0; d<7; ++d)
7823 jacobian_matrix.add(9+k+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7824 6+d+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7825 hull_quaternions_vect_res(k).fastAccessDx(7+d));
7827 for (
unsigned int d=0; d<7; ++d)
7828 jacobian_dot_matrix.add(12+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7829 6+d+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7830 hull_quaternions_scal_res.fastAccessDx(d));
7831 for (
unsigned int d=0; d<7; ++d)
7832 jacobian_matrix.add(12+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7833 6+d+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7834 hull_quaternions_scal_res.fastAccessDx(7+d));
7837 for (
unsigned int k=0; k<3; ++k)
7839 hull_rigid_modes_res(k) = hull_lin_vel_res(k);
7840 hull_rigid_modes_res(k+3) = hull_lin_displ_res(k);
7841 hull_rigid_modes_res(k+6) = hull_ang_vel_res(k).val();
7843 for (
unsigned int k=0; k<3; ++k)
7845 hull_rigid_modes_res(k+9) = hull_quaternions_vect_res(k).val();
7847 hull_rigid_modes_res(12) = hull_quaternions_scal_res.
val();
7867 DphiDt_sys_matrix_copy.
reinit(DphiDt_sparsity_pattern);
7868 DphiDt_sys_matrix_copy.
copy_from(DphiDt_sys_matrix);
7871 DphiDt_sys_matrix_copy_2.
reinit(DphiDt_sparsity_pattern);
7872 DphiDt_sys_matrix_copy_2.
copy_from(DphiDt_sys_matrix_2);
7874 constraints.condense(DphiDt_sys_matrix,DphiDt_sys_rhs);
7875 constraints.condense(DphiDt_sys_matrix_copy,DphiDt_sys_rhs_2);
7876 constraints.condense(DphiDt_sys_matrix_2,DphiDt_sys_rhs_3);
7877 constraints.condense(DphiDt_sys_matrix_copy_2,DphiDt_sys_rhs_4);
7886 DphiDt_direct_copy.
initialize(DphiDt_sys_matrix_copy);
7887 DphiDt_direct_copy_2.
initialize(DphiDt_sys_matrix_copy_2);
7888 DphiDt_direct_2.
initialize(DphiDt_sys_matrix_2);
7890 DphiDt_direct.
vmult(DphiDt_sys_solution, DphiDt_sys_rhs);
7891 constraints.distribute(DphiDt_sys_solution);
7895 DphiDt_direct_copy.
vmult(DphiDt_sys_solution_2, DphiDt_sys_rhs_2);
7896 constraints.distribute(DphiDt_sys_solution_2);
7897 DphiDt_direct_2.
vmult(DphiDt_sys_solution_3, DphiDt_sys_rhs_3);
7898 constraints.distribute(DphiDt_sys_solution_3);
7899 DphiDt_direct_copy_2.
vmult(break_wave_press, DphiDt_sys_rhs_4);
7900 constraints.distribute(break_wave_press);
7903 DphiDt_sys_matrix.vmult(RES,DphiDt_sys_solution_2);
7905 RES.
add(DphiDt_sys_rhs_2);
7957 double residual_counter_0 = 0;
7958 double residual_counter_1 = 0;
7959 double residual_counter_2 = 0;
7960 double residual_counter_3 = 0;
7961 double residual_counter_4 = 0;
7962 double residual_counter_5 = 0;
7963 double residual_counter_6 = 0;
7964 double residual_counter_7 = 0;
7965 double residual_counter_8 = 0;
7966 double residual_counter_9 = 0;
7967 double residual_counter_10 = 0;
7968 double residual_counter_11 = 0;
7969 double residual_counter_12 = 0;
7971 for (
unsigned int i=0; i<sys_comp.size(); ++i)
7972 switch ((
int) sys_comp(i))
7976 dst(i) = nodes_pos_res(i);
7979 residual_counter_0 += fabs(dst(i)*dst(i));
7982 dst(i) = eta_res[int((i-2)/3)];
7984 residual_counter_1 += fabs(dst(i)*dst(i));
7987 dst(i) = bem_phi(i-comp_dom.vector_dh.n_dofs()) - src_yy(i);
7989 residual_counter_2 += fabs(dst(i)*dst(i));
7992 dst(i) = phi_res[i-comp_dom.vector_dh.n_dofs()];
7995 residual_counter_3 += fabs(dst(i)*dst(i));
7999 dphi_dn_res[i-comp_dom.vector_dh.n_dofs()-comp_dom.dh.n_dofs()];
8002 residual_counter_4 += fabs(dst(i)*dst(i));
8005 dst(i) = bem_dphi_dn(i-comp_dom.vector_dh.n_dofs()-comp_dom.dh.n_dofs()) - src_yy(i);
8007 residual_counter_5 += fabs(dst(i)*dst(i));
8010 dst(i) = bem_phi(i-comp_dom.vector_dh.n_dofs()) - src_yy(i);
8012 residual_counter_6 += fabs(dst(i)*dst(i));
8015 dst(i) = bem_dphi_dn(i-comp_dom.vector_dh.n_dofs()-comp_dom.dh.n_dofs()) - src_yy(i);
8018 residual_counter_7 += fabs(dst(i)*dst(i));
8021 dst(i) = x_smoothing_res[int((i)/3)];
8024 residual_counter_8 += fabs(dst(i)*dst(i));
8027 dst(i) = y_smoothing_res[int((i-1)/3)];
8029 residual_counter_9 += fabs(dst(i)*dst(i));
8032 dst(i) = bem_phi(i-comp_dom.vector_dh.n_dofs()) - src_yy(i);
8034 residual_counter_10 += fabs(dst(i)*dst(i));
8038 dst(i) = hull_rigid_modes_res(i-comp_dom.vector_dh.n_dofs()-comp_dom.dh.n_dofs()-comp_dom.dh.n_dofs());
8040 residual_counter_11 += fabs(dst(i)*dst(i));
8046 std::cout <<
"Current total residual: " << dst.
l2_norm() << std::endl;
8047 std::cout <<
"Current generic algebraic coords residual: " << sqrt(residual_counter_0) << std::endl;
8048 std::cout <<
"Current differential coords residual: " << sqrt(residual_counter_1) << std::endl;
8049 std::cout <<
"Current algebraic potential residual: " << sqrt(residual_counter_2) << std::endl;
8050 std::cout <<
"Current differential potential residual: " << sqrt(residual_counter_3) << std::endl;
8051 std::cout <<
"Current algebraic potential normal gradient residual: " << sqrt(residual_counter_4) << std::endl;
8052 std::cout <<
"Current algebraic potential normal gradient hanging nodes residual: " << sqrt(residual_counter_5) << std::endl;
8053 std::cout <<
"Current algebraic potential hanging nodes residual: " << sqrt(residual_counter_6) << std::endl;
8054 std::cout <<
"Current algebraic potential normal gradient bem residual: " << sqrt(residual_counter_7) << std::endl;
8055 std::cout <<
"Current algebraic free surface coords x residual: " << sqrt(residual_counter_8) << std::endl;
8056 std::cout <<
"Current algebraic free surface coords y residual: " << sqrt(residual_counter_9) << std::endl;
8057 std::cout <<
"Current algebraic pressure/free surf phi residual: " << sqrt(residual_counter_10) << std::endl;
8058 std::cout <<
"Current differential rigid mode vel residual: " << sqrt(residual_counter_11) << std::endl;
8059 std::cout <<
"Current differential rigid mode displ residual: " << sqrt(residual_counter_12) << std::endl;
8060 static unsigned int res_evals = 0;
8062 std::cout <<
"Residual evaluations: " << res_evals << std::endl;
8078 jacobian_preconditioner_matrix.vmult(dst,src_copy);
8092 jacobian_prec(current_time,dst,src_yy,current_sol_dot,src,1e7);
8112 cout<<
"alpha (using) "<<alpha<<endl;
8114 prec_direct.
initialize(jacobian_preconditioner_matrix);
8115 prec_direct.
vmult(dst,src);
8118 jacobian_preconditioner_matrix.vmult(residual,dst);
8135 cout<<
"Inverting preconditioner"<<endl;
8144 setup_jacobian_prec(current_time,src_yy,current_sol_dot,0.0);
8155 cout<<
"alpha (building) "<<alpha<<endl;
8156 jacobian_preconditioner_matrix = 0;
8157 preconditioner_preconditioner_matrix = 0;
8159 for (
unsigned int i=0; i<this->n_dofs(); ++i)
8162 unsigned int j = col->column();
8165 jacobian_preconditioner_matrix.set(i,j,jacobian_matrix(i,j)+alpha*jacobian_dot_matrix(i,j));
8168 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
8170 if ( (!constraints.is_constrained(i)) &&
8171 ((comp_dom.flags[i] &
water) || (comp_dom.flags[i] &
pressure)) &&
8174 jacobian_preconditioner_matrix.set(i+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs(),
8175 i+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs(),
8179 else if ( (!constraints.is_constrained(i)) &&
8180 (!(comp_dom.flags[i] & water)) )
8182 jacobian_preconditioner_matrix.set(i+comp_dom.vector_dh.n_dofs(),
8183 i+comp_dom.vector_dh.n_dofs(),
8189 jacobian_preconditioner_matrix.set(i+comp_dom.vector_dh.n_dofs(),
8190 i+comp_dom.vector_dh.n_dofs(),
8198 cout<<
"Building preconditioner"<<endl;
8224 if (diff_comp.size() != this->n_dofs())
8227 diff_comp.
reinit(this->n_dofs());
8228 alg_comp.reinit(this->n_dofs());
8229 sys_comp.reinit(this->n_dofs());
8246 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
8248 if (comp_dom.vector_flags[3*i] &
water)
8254 if ( !(comp_dom.vector_flags[3*i] &
edge) )
8261 sys_comp(3*i+1) = 9;
8262 diff_comp(3*i+1) = 0;
8263 alg_comp(3*i+1) = 1;
8265 sys_comp(3*i+2) = 1;
8266 diff_comp(3*i+2) = 1;
8267 alg_comp(3*i+2) = 0;
8276 for (
unsigned int j=0; j<dim; ++j)
8278 sys_comp(3*i+j) = 0;
8279 diff_comp(3*i+j) = 0;
8280 alg_comp(3*i+j) = 1;
8290 sys_comp(3*i+1) = 0;
8291 diff_comp(3*i+1) = 0;
8292 alg_comp(3*i+1) = 1;
8294 sys_comp(3*i+2) = 1;
8295 diff_comp(3*i+2) = 1;
8296 alg_comp(3*i+2) = 0;
8303 for (
unsigned int j=0; j<dim-1; ++j)
8305 sys_comp(3*i+j) = 0;
8306 diff_comp(3*i+j) = 0;
8307 alg_comp(3*i+j) = 1;
8314 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
8316 if (comp_dom.flags[i] &
water)
8322 sys_comp(i+comp_dom.vector_dh.n_dofs()) = 2;
8323 diff_comp(i+comp_dom.vector_dh.n_dofs()) = 0;
8324 alg_comp(i+comp_dom.vector_dh.n_dofs()) = 1;
8328 diff_comp(i+comp_dom.vector_dh.n_dofs()) = 1;
8329 alg_comp(i+comp_dom.vector_dh.n_dofs()) = 0;
8330 sys_comp(i+comp_dom.vector_dh.n_dofs()) = 3;
8337 if ( comp_dom.flags[i] &
pressure )
8339 diff_comp(i+comp_dom.vector_dh.n_dofs()) = 1;
8340 alg_comp(i+comp_dom.vector_dh.n_dofs()) = 0;
8341 sys_comp(i+comp_dom.vector_dh.n_dofs()) = 3;
8345 diff_comp(i+comp_dom.vector_dh.n_dofs()) = 0;
8346 alg_comp(i+comp_dom.vector_dh.n_dofs()) = 1;
8347 sys_comp(i+comp_dom.vector_dh.n_dofs()) = 10;
8352 diff_comp(i+comp_dom.vector_dh.n_dofs()) = 0;
8353 alg_comp(i+comp_dom.vector_dh.n_dofs()) = 1;
8354 sys_comp(i+comp_dom.vector_dh.n_dofs()) = 2;
8360 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
8363 if (!(comp_dom.flags[i] &
water) && !(comp_dom.flags[i] &
pressure))
8366 if (constraints.is_constrained(i) )
8369 diff_comp(i+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()) = 0;
8370 alg_comp(i+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()) = 1;
8371 sys_comp(i+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()) = 5;
8376 diff_comp(i+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()) = 0;
8377 alg_comp(i+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()) = 1;
8378 sys_comp(i+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()) = 4;
8383 if (constraints.is_constrained(i) )
8386 diff_comp(i+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()) = 0;
8387 alg_comp(i+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()) = 1;
8388 sys_comp(i+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()) = 5;
8393 diff_comp(i+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()) = 0;
8394 alg_comp(i+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()) = 1;
8395 sys_comp(i+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()) = 7;
8402 for (
unsigned int i=0; i<comp_dom.vector_dh.n_dofs(); i++)
8404 if (vector_constraints.is_constrained(i))
8413 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); i++)
8415 if (constraints.is_constrained(i))
8417 diff_comp(i+comp_dom.vector_dh.n_dofs()) = 0;
8418 sys_comp(i+comp_dom.vector_dh.n_dofs()) = 6;
8419 alg_comp(i+comp_dom.vector_dh.n_dofs()) = 1;
8424 for (
unsigned int i=0; i<13; ++i)
8426 diff_comp(i+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()) = 1;
8427 sys_comp(i+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()) = 11;
8428 alg_comp(i+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()) = 0;
8432 std::vector<unsigned int> row_lengths(dofs_number);
8434 for (
unsigned int i=0; i<dofs_number; ++i)
8435 row_lengths[i] = 5*comp_dom.dh.max_couplings_between_dofs();
8437 row_lengths[comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()] = dofs_number;
8438 row_lengths[comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+1] = dofs_number;
8439 row_lengths[comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+2] = dofs_number;
8440 row_lengths[comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+3] = 2;
8441 row_lengths[comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+4] = 2;
8442 row_lengths[comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+5] = 2;
8443 row_lengths[comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+6] = dofs_number;
8444 row_lengths[comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+7] = dofs_number;
8445 row_lengths[comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+8] = dofs_number;
8446 row_lengths[comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+9] = 7;
8447 row_lengths[comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+10] = 7;
8448 row_lengths[comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+11] = 7;
8449 row_lengths[comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+12] = 7;
8460 jacobian_sparsity_pattern.reinit(dofs_number,
8465 cell = comp_dom.dh.begin_active(),
8466 endc = comp_dom.dh.end();
8468 const unsigned int dofs_per_cell = comp_dom.fe.dofs_per_cell;
8469 std::vector<unsigned int> local_dof_indices(dofs_per_cell);
8471 for (; cell!=endc; ++cell)
8473 cell->get_dof_indices(local_dof_indices);
8474 for (
unsigned int i=0; i<dofs_per_cell; ++i)
8476 unsigned int ii = local_dof_indices[i];
8479 std::set<unsigned int> duplicates = comp_dom.double_nodes_set[ii];
8480 jacobian_sparsity_pattern.add(3*ii,3*ii);
8481 jacobian_sparsity_pattern.add(3*ii+1,3*ii+1);
8482 jacobian_sparsity_pattern.add(3*ii+2,3*ii+2);
8483 for (std::set<unsigned int>::iterator pos = duplicates.begin(); pos!=duplicates.end(); ++pos)
8485 unsigned int jj=*pos;
8486 jacobian_sparsity_pattern.add(ii+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs(),jj+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs());
8490 for (
unsigned int j=0; j<dofs_per_cell; ++j)
8492 unsigned int jj = local_dof_indices[j];
8493 jacobian_sparsity_pattern.add(3*ii,3*jj);
8494 jacobian_sparsity_pattern.add(3*ii,3*jj+1);
8495 jacobian_sparsity_pattern.add(3*ii,3*jj+2);
8496 jacobian_sparsity_pattern.add(3*ii,jj+comp_dom.vector_dh.n_dofs());
8497 jacobian_sparsity_pattern.add(3*ii,jj+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs());
8499 jacobian_sparsity_pattern.add(3*ii+1,3*jj);
8500 jacobian_sparsity_pattern.add(3*ii+1,3*jj+1);
8501 jacobian_sparsity_pattern.add(3*ii+1,3*jj+2);
8502 jacobian_sparsity_pattern.add(3*ii+1,jj+comp_dom.vector_dh.n_dofs());
8503 jacobian_sparsity_pattern.add(3*ii+1,jj+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs());
8505 jacobian_sparsity_pattern.add(3*ii+2,3*jj);
8506 jacobian_sparsity_pattern.add(3*ii+2,3*jj+1);
8507 jacobian_sparsity_pattern.add(3*ii+2,3*jj+2);
8508 jacobian_sparsity_pattern.add(3*ii+2,jj+comp_dom.vector_dh.n_dofs());
8509 jacobian_sparsity_pattern.add(3*ii+2,jj+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs());
8511 jacobian_sparsity_pattern.add(ii+comp_dom.vector_dh.n_dofs(),3*jj);
8512 jacobian_sparsity_pattern.add(ii+comp_dom.vector_dh.n_dofs(),3*jj+1);
8513 jacobian_sparsity_pattern.add(ii+comp_dom.vector_dh.n_dofs(),3*jj+2);
8514 jacobian_sparsity_pattern.add(ii+comp_dom.vector_dh.n_dofs(),jj+comp_dom.vector_dh.n_dofs());
8515 jacobian_sparsity_pattern.add(ii+comp_dom.vector_dh.n_dofs(),jj+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs());
8517 jacobian_sparsity_pattern.add(ii+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs(),3*jj);
8518 jacobian_sparsity_pattern.add(ii+comp_dom.dh.n_dofs()+comp_dom.vector_dh.n_dofs(),3*jj+1);
8519 jacobian_sparsity_pattern.add(ii+comp_dom.dh.n_dofs()+comp_dom.vector_dh.n_dofs(),3*jj+2);
8520 jacobian_sparsity_pattern.add(ii+comp_dom.dh.n_dofs()+comp_dom.vector_dh.n_dofs(),jj+comp_dom.vector_dh.n_dofs());
8521 jacobian_sparsity_pattern.add(ii+comp_dom.dh.n_dofs()+comp_dom.vector_dh.n_dofs(),jj+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs());
8527 for (
unsigned int d=0; d<13; ++d)
8529 for (
unsigned int k=0; k<3; ++k)
8531 jacobian_sparsity_pattern.add(3*ii+k,d+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs());
8533 jacobian_sparsity_pattern.add(ii+comp_dom.vector_dh.n_dofs(),
8534 d+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs());
8535 jacobian_sparsity_pattern.add(ii+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs(),
8536 d+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs());
8541 for (
unsigned int i=0; i<comp_dom.vector_dh.n_dofs(); ++i)
8543 if (vector_constraints.is_constrained(i))
8545 jacobian_sparsity_pattern.add(i,i);
8546 std::vector< std::pair< unsigned int, double > > entries = *vector_constraints.get_constraint_entries(i);
8547 for (
unsigned int k=0; k<entries.size(); ++k)
8549 jacobian_sparsity_pattern.add(i,entries[k].first);
8554 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
8556 if (constraints.is_constrained(i))
8558 jacobian_sparsity_pattern.add(i+comp_dom.vector_dh.n_dofs(),i+comp_dom.vector_dh.n_dofs());
8559 jacobian_sparsity_pattern.add(i+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs(),i+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs());
8560 std::vector< std::pair< unsigned int, double > > entries = *constraints.get_constraint_entries(i);
8561 for (
unsigned int k=0; k<entries.size(); ++k)
8563 jacobian_sparsity_pattern.add(i+comp_dom.vector_dh.n_dofs(),entries[k].first+comp_dom.vector_dh.n_dofs());
8564 jacobian_sparsity_pattern.add(i+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs(),
8565 entries[k].first+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs());
8571 if (!comp_dom.no_boat)
8573 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
8575 if ( (comp_dom.flags[i] &
water) &&
8578 (comp_dom.moving_point_ids[0] != i) &&
8579 (comp_dom.moving_point_ids[1] != i) &&
8580 (comp_dom.moving_point_ids[2] != i) )
8584 jacobian_sparsity_pattern.add(3*i,3*i);
8585 jacobian_sparsity_pattern.add(3*i,3*i+1);
8586 jacobian_sparsity_pattern.add(3*i,3*i+2);
8587 jacobian_sparsity_pattern.add(3*i+1,3*i+1);
8588 jacobian_sparsity_pattern.add(3*i+1,3*i+2);
8589 jacobian_sparsity_pattern.add(3*i+1,3*i);
8594 for (
unsigned int k=0; k<3; ++k)
8596 unsigned int i = comp_dom.moving_point_ids[k];
8598 jacobian_sparsity_pattern.add(3*i,3*i);
8599 jacobian_sparsity_pattern.add(3*i,3*i+2);
8600 jacobian_sparsity_pattern.add(3*i+1,3*i+1);
8601 jacobian_sparsity_pattern.add(3*i+1,3*i+2);
8609 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
8611 if ( (comp_dom.flags[i] &
water) &&
8612 (comp_dom.flags[i] &
edge) )
8615 std::set<unsigned int> duplicates = comp_dom.double_nodes_set[i];
8616 duplicates.erase(i);
8617 for (std::set<unsigned int>::iterator pos = duplicates.begin(); pos !=duplicates.end(); pos++)
8619 for (
unsigned int k=0; k<3; ++k)
8621 jacobian_sparsity_pattern.add(3*(*pos)+k,3*(*pos)+k);
8624 for (
unsigned int d=0; d<3; ++d)
8625 jacobian_sparsity_pattern.add(3*(*pos)+k,3*i+d);
8626 for (
unsigned int d=0; d<3; ++d)
8627 jacobian_sparsity_pattern.add(3*(*pos)+k,comp_dom.vector_dh.n_dofs()+
8628 comp_dom.dh.n_dofs()+
8629 comp_dom.dh.n_dofs()+3+d);
8630 for (
unsigned int d=0; d<4; ++d)
8631 jacobian_sparsity_pattern.add(3*(*pos)+k,comp_dom.vector_dh.n_dofs()+
8632 comp_dom.dh.n_dofs()+
8633 comp_dom.dh.n_dofs()+9+d);
8637 jacobian_sparsity_pattern.add(3*(*pos)+k,3*i+k);
8646 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
8648 if ( (comp_dom.flags[i] &
pressure) &&
8652 std::set<unsigned int> duplicates = comp_dom.double_nodes_set[i];
8653 duplicates.erase(i);
8654 for (std::set<unsigned int>::iterator pos = duplicates.begin(); pos !=duplicates.end(); pos++)
8656 if (comp_dom.flags[*pos] &
water)
8658 jacobian_sparsity_pattern.add(comp_dom.vector_dh.n_dofs()+i,comp_dom.vector_dh.n_dofs()+ *pos);
8659 jacobian_sparsity_pattern.add(comp_dom.vector_dh.n_dofs()+i,comp_dom.vector_dh.n_dofs()+i);
8666 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
8668 if ( comp_dom.flags[i] &
boat )
8670 for (
unsigned int k=0; k<3; ++k)
8672 jacobian_sparsity_pattern.add(k+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
8674 jacobian_sparsity_pattern.add(k+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
8676 jacobian_sparsity_pattern.add(k+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
8678 jacobian_sparsity_pattern.add(k+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
8679 i+comp_dom.vector_dh.n_dofs());
8680 jacobian_sparsity_pattern.add(k+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
8681 i+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs());
8682 jacobian_sparsity_pattern.add(k+6+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
8684 jacobian_sparsity_pattern.add(k+6+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
8686 jacobian_sparsity_pattern.add(k+6+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
8688 jacobian_sparsity_pattern.add(k+6+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
8689 i+comp_dom.vector_dh.n_dofs());
8690 jacobian_sparsity_pattern.add(k+6+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
8691 i+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs());
8697 for (
unsigned int k=0; k<3; ++k)
8698 for (
unsigned int d=0; d<13; ++d)
8700 jacobian_sparsity_pattern.add(k+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
8701 d+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs());
8702 jacobian_sparsity_pattern.add(k+6+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
8703 d+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs());
8707 for (
unsigned int k=0; k<3; ++k)
8709 jacobian_sparsity_pattern.add(k+3+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
8710 k+3+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs());
8711 jacobian_sparsity_pattern.add(k+3+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
8712 k+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs());
8715 for (
unsigned int k=0; k<4; ++k)
8717 for (
unsigned int d=0; d<7; ++d)
8719 jacobian_sparsity_pattern.add(k+9+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
8720 d+6+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs());
8724 jacobian_sparsity_pattern.compress();
8725 jacobian_matrix.reinit(jacobian_sparsity_pattern);
8726 jacobian_dot_matrix.reinit(jacobian_sparsity_pattern);
8727 jacobian_preconditioner_matrix.reinit(jacobian_sparsity_pattern);
8728 preconditioner_preconditioner_matrix.reinit(jacobian_sparsity_pattern);
8753 cell = comp_dom.dh.begin_active(),
8754 endc = comp_dom.dh.end();
8756 comp_dom.surface_nodes.reinit(comp_dom.dh.n_dofs());
8757 comp_dom.other_nodes.reinit(comp_dom.dh.n_dofs());
8758 comp_dom.other_nodes.add(1);
8759 std::vector<unsigned int> dofs(comp_dom.fe.dofs_per_cell);
8761 for (; cell != endc; ++cell)
8763 if (cell->material_id() == comp_dom.free_sur_ID1 ||
8764 cell->material_id() == comp_dom.free_sur_ID2 ||
8765 cell->material_id() == comp_dom.free_sur_ID3)
8768 cell->get_dof_indices(dofs);
8769 for (
unsigned int i=0; i<comp_dom.fe.dofs_per_cell; ++i)
8771 comp_dom.surface_nodes(dofs[i]) = 1;
8772 comp_dom.other_nodes(dofs[i]) = 0;
8777 for (
unsigned int i=0; i<comp_dom.fe.dofs_per_cell; ++i)
8779 cell->get_dof_indices(dofs);
8785 cell = comp_dom.dh.begin_active();
8788 std::vector<Point<dim> > support_points(comp_dom.dh.n_dofs());
8791 const unsigned int dofs_per_cell = comp_dom.fe.dofs_per_cell;
8792 std::vector<unsigned int> local_dof_indices (dofs_per_cell);
8793 for (cell = comp_dom.dh.begin_active(); cell != endc; ++cell)
8795 cell->get_dof_indices(local_dof_indices);
8796 for (
unsigned int j=0; j<comp_dom.fe.dofs_per_cell; ++j)
8798 if (cell->material_id() != comp_dom.free_sur_ID1 &&
8799 cell->material_id() != comp_dom.free_sur_ID2 &&
8800 cell->material_id() != comp_dom.free_sur_ID3 )
8802 if (cell->material_id() == comp_dom.wall_sur_ID1 ||
8803 cell->material_id() == comp_dom.wall_sur_ID2 ||
8804 cell->material_id() == comp_dom.wall_sur_ID3)
8807 wind.vector_value(support_points[local_dof_indices[j]],wind_value);
8809 for (
unsigned int i = 0; i < dim; i++)
8810 Vinf(i) = wind_value(i);
8833 bem_bc(local_dof_indices[j]) = -comp_dom.node_normals[local_dof_indices[j]]*Vinf;
8834 dphi_dn(local_dof_indices[j]) = bem_bc(local_dof_indices[j]);
8837 else if (cell->material_id() == comp_dom.inflow_sur_ID1 ||
8838 cell->material_id() == comp_dom.inflow_sur_ID2 ||
8839 cell->material_id() == comp_dom.inflow_sur_ID3)
8841 bem_bc(local_dof_indices[j]) = inflow_norm_potential_grad.value(support_points[local_dof_indices[j]]);
8842 dphi_dn(local_dof_indices[j]) = inflow_norm_potential_grad.value(support_points[local_dof_indices[j]]);
8843 cout<<inflow_norm_potential_grad.value(support_points[local_dof_indices[j]])<<endl;
8847 bem_bc(local_dof_indices[j]) = 0;
8848 dphi_dn(local_dof_indices[j]) = 0;
8863 wind.vector_value(
Point<3>(0.0,0.0,0.0),wind_value);
8865 for (
unsigned int i = 0; i < dim; i++)
8866 Vinf(i) = wind_value(i);
8867 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
8871 comp_dom.surface_nodes(i) = 0;
8872 comp_dom.other_nodes(i) = 1;
8873 std::set<unsigned int> duplicates = comp_dom.double_nodes_set[i];
8874 duplicates.erase(i);
8876 for (std::set<unsigned int>::iterator pos = duplicates.begin(); pos !=duplicates.end(); pos++)
8877 bem_bc(i) += bem_dphi_dn(*pos)/duplicates.size();
8878 dphi_dn(i) = bem_bc(i);
8901 vector_constr.
clear();
8905 vector_constr.
close();
8907 std::vector<unsigned int> vector_dofs(comp_dom.vector_fe.dofs_per_cell);
8908 std::vector<Point<dim> > vector_support_points(comp_dom.vector_dh.n_dofs());
8911 DXDt_and_DphiDt_vector.reinit(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs());
8914 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); i++)
8916 elevations(i) = vector_support_points[dim*i](dim-1);
8924 DphiDt_sys_matrix.
reinit (DphiDt_sparsity_pattern);
8925 DphiDt_sys_matrix_2.reinit (DphiDt_sparsity_pattern);
8926 vector_sys_matrix.reinit (vector_sparsity_pattern);
8928 DphiDt_sys_solution.reinit (comp_dom.dh.n_dofs());
8929 DphiDt_sys_solution_2.reinit (comp_dom.dh.n_dofs());
8930 DphiDt_sys_solution_3.reinit (comp_dom.dh.n_dofs());
8931 break_wave_press.reinit (comp_dom.dh.n_dofs());
8932 vector_sys_solution.reinit (comp_dom.vector_dh.n_dofs());
8933 vector_sys_solution_2.reinit (comp_dom.vector_dh.n_dofs());
8935 DphiDt_sys_rhs.reinit (comp_dom.dh.n_dofs());
8936 DphiDt_sys_rhs_2.reinit (comp_dom.dh.n_dofs());
8937 DphiDt_sys_rhs_3.reinit (comp_dom.dh.n_dofs());
8938 DphiDt_sys_rhs_4.reinit (comp_dom.dh.n_dofs());
8939 vector_sys_rhs.reinit (comp_dom.vector_dh.n_dofs());
8940 vector_sys_rhs_2.reinit (comp_dom.vector_dh.n_dofs());
8942 FEValues<dim-1,dim> vector_fe_v(*comp_dom.mapping, comp_dom.vector_fe, *comp_dom.quadrature,
8943 update_values | update_gradients |
8944 update_cell_normal_vectors |
8945 update_quadrature_points |
8948 FEValues<dim-1,dim> fe_v(*comp_dom.mapping, comp_dom.fe, *comp_dom.quadrature,
8949 update_values | update_gradients |
8950 update_cell_normal_vectors |
8951 update_quadrature_points |
8954 const unsigned int DphiDt_n_q_points = fe_v.n_quadrature_points;
8955 const unsigned int DphiDt_dofs_per_cell = comp_dom.fe.dofs_per_cell;
8956 std::vector<unsigned int> DphiDt_local_dof_indices (DphiDt_dofs_per_cell);
8962 const unsigned int vector_n_q_points = vector_fe_v.n_quadrature_points;
8963 const unsigned int vector_dofs_per_cell = comp_dom.vector_fe.dofs_per_cell;
8964 std::vector<unsigned int> vector_local_dof_indices (vector_dofs_per_cell);
8973 std::vector< Tensor<1,dim> > vector_phi_surf_grads(DphiDt_n_q_points);
8974 std::vector< Tensor<1,dim> > vector_eta_surf_grads(DphiDt_n_q_points);
8975 std::vector<double> vector_phi_norm_grads(vector_n_q_points);
8976 std::vector<Vector<double> > quad_nodes_velocities(vector_n_q_points,
8979 std::vector< Tensor<1,dim> > DphiDt_phi_surf_grads(vector_n_q_points);
8980 std::vector< Tensor<1,dim> > DphiDt_eta_surf_grads(vector_n_q_points);
8981 std::vector<double> DphiDt_phi_norm_grads(DphiDt_n_q_points);
8986 vector_cell = comp_dom.vector_dh.begin_active(),
8987 vector_endc = comp_dom.vector_dh.end();
8990 cell = comp_dom.dh.begin_active(),
8991 endc = comp_dom.dh.end();
8995 std::vector<Point<dim> > support_points(comp_dom.dh.n_dofs());
8999 for (; cell!=endc,vector_cell!=vector_endc; ++cell,++vector_cell)
9003 vector_fe_v.reinit (vector_cell);
9005 local_DphiDt_matrix = 0;
9006 local_DphiDt_rhs = 0;
9007 local_DphiDt_rhs_2 = 0;
9008 local_vector_matrix = 0;
9009 local_vector_rhs = 0;
9010 local_vector_rhs_2 = 0;
9022 fe_v.get_function_gradients((
const Vector<double> &)phi, DphiDt_phi_surf_grads);
9023 fe_v.get_function_values(dphi_dn, DphiDt_phi_norm_grads);
9024 fe_v.get_function_gradients((
const Vector<double> &)phi, vector_phi_surf_grads);
9025 fe_v.get_function_gradients(elevations, vector_eta_surf_grads);
9026 fe_v.get_function_values(dphi_dn, vector_phi_norm_grads);
9027 vector_fe_v.get_function_values(nodes_velocities, quad_nodes_velocities);
9029 const std::vector<Point<dim> > &DphiDt_node_normals = fe_v.get_normal_vectors();
9030 const std::vector<Point<dim> > &DphiDt_node_positions = fe_v.get_quadrature_points();
9031 const std::vector<Point<dim> > &vector_node_normals = vector_fe_v.get_normal_vectors();
9032 const std::vector<Point<dim> > &vector_node_positions = vector_fe_v.get_quadrature_points();
9036 std::vector<Vector<double> > DphiDt_wind_values(DphiDt_n_q_points);
9037 for (
unsigned int q=0; q<DphiDt_n_q_points; ++q)
9039 DphiDt_wind_values[q].reinit(dim,
true);
9040 wind.vector_value(DphiDt_node_positions[q],DphiDt_wind_values[q]);
9042 std::vector<Vector<double> > vector_wind_values(DphiDt_n_q_points);
9043 for (
unsigned int q=0; q<vector_n_q_points; ++q)
9045 vector_wind_values[q].reinit(dim,
true);
9046 wind.vector_value(vector_node_positions[q], vector_wind_values[q]);
9049 unsigned int comp_i, comp_j;
9051 for (
unsigned int q=0; q<vector_n_q_points; ++q)
9053 Point<dim> gradient = vector_node_normals[q]*vector_phi_norm_grads[q] + vector_phi_surf_grads[q];
9058 double damping = nu_0 *
9059 pow((fmax(abs(vector_node_positions[q](0)),20)-20)/(31.169752-20),2) *
9060 vector_phi_norm_grads[q];
9067 for (
unsigned int i = 0; i < dim; i++)
9068 Vinf(i) = vector_wind_values[q](i);
9072 eta_grad = eta_grad + vector_eta_surf_grads[q];
9073 eta_grad(dim-1) = 0;
9075 double fluid_vel_norm = (gradient+Vinf).
norm();
9076 if (fluid_vel_norm < 1e-3)
9077 fluid_vel_norm = -8.0e+05*pow(fluid_vel_norm,3.0) + 1.7e+03*pow(fluid_vel_norm,2.0) + 0.0001;
9078 Point<dim> velocity_unit_vect = (gradient+Vinf)/fluid_vel_norm;
9080 const double delta = cell->diameter()/sqrt(2);
9081 for (
unsigned int i=0; i<vector_dofs_per_cell; ++i)
9083 double supg_shape_fun = 1.0*(delta)*vector_fe_v.shape_grad(i, q)*velocity_unit_vect;
9084 comp_i = comp_dom.vector_fe.system_to_component_index(i).first;
9085 for (
unsigned int j=0; j<vector_dofs_per_cell; ++j)
9087 comp_j = comp_dom.vector_fe.system_to_component_index(j).first;
9088 if (comp_i == comp_j)
9089 local_vector_matrix(i,j) += ( (vector_fe_v.shape_value(i, q)+supg_shape_fun)*
9090 vector_fe_v.shape_value(j, q) ) *
9094 if ( (cell->material_id() == comp_dom.free_sur_ID1 ||
9095 cell->material_id() == comp_dom.free_sur_ID2 ||
9096 cell->material_id() == comp_dom.free_sur_ID3 ) )
9098 Point<dim> u(quad_nodes_velocities[q](0),quad_nodes_velocities[q](1),quad_nodes_velocities[q](2));
9099 double dEta_dt = gradient[dim-1] + (u-gradient-Vinf)*eta_grad-damping;
9107 local_vector_rhs(i) += (vector_fe_v.shape_value(i, q)+supg_shape_fun) *
9108 u(comp_i) * vector_fe_v.JxW(q);
9109 local_vector_rhs_2(i) += (vector_fe_v.shape_value(i, q)+supg_shape_fun) *
9110 uu(comp_i) * vector_fe_v.JxW(q);
9114 local_vector_rhs(i) += (vector_fe_v.shape_value(i, q)+supg_shape_fun) *
9115 0 * vector_fe_v.JxW(q);
9116 local_vector_rhs_2(i) += (vector_fe_v.shape_value(i, q)+supg_shape_fun) *
9117 0 * vector_fe_v.JxW(q);
9122 vector_cell->get_dof_indices (vector_local_dof_indices);
9124 (local_vector_matrix,
9126 vector_local_dof_indices,
9131 (local_vector_rhs_2,
9132 vector_local_dof_indices,
9135 for (
unsigned int q=0; q<DphiDt_n_q_points; ++q)
9137 Point<dim> gradient = DphiDt_node_normals[q]*DphiDt_phi_norm_grads[q] + DphiDt_phi_surf_grads[q];
9139 for (
unsigned int i = 0; i < dim; i++)
9140 Vinf(i) = DphiDt_wind_values[q](i);
9143 eta_grad = eta_grad + vector_eta_surf_grads[q];
9144 eta_grad(dim-1) = 0;
9147 phi_surf_grad_corrected(0) = DphiDt_phi_surf_grads[q][0] -
9148 DphiDt_phi_surf_grads[q][2]*DphiDt_node_normals[q][0]/DphiDt_node_normals[q][2];
9149 phi_surf_grad_corrected(1) = DphiDt_phi_surf_grads[q][1] -
9150 DphiDt_phi_surf_grads[q][2]*DphiDt_node_normals[q][1]/DphiDt_node_normals[q][2];
9156 double fluid_vel_norm = (gradient+Vinf).
norm();
9157 if (fluid_vel_norm < 1e-3)
9158 fluid_vel_norm = -8.0e+05*pow(fluid_vel_norm,3.0) + 1.7e+03*pow(fluid_vel_norm,2.0) + 0.0001;
9159 Point<dim> velocity_unit_vect = (gradient+Vinf)/fluid_vel_norm;
9162 if (sqrt((eta_grad).square()) > 1e-3)
9163 eta_grad_unit_vect = (eta_grad)/sqrt((eta_grad).square());
9164 double Fr = sqrt((gradient+Vinf).square())/sqrt(g*comp_dom.Lx_boat);
9165 double eta = DphiDt_node_positions[q](dim-1);
9167 if ( (eta_grad*(gradient+Vinf) > 0) &&
9168 (sqrt(eta*eta+eta_grad.
square()*pow(Fr,4.0)) > 0.1725*Fr*Fr) &&
9169 (cell->material_id() == comp_dom.free_sur_ID1 ||
9170 cell->material_id() == comp_dom.free_sur_ID2 ||
9171 cell->material_id() == comp_dom.free_sur_ID3 ) )
9173 delta_p = 0.0*eta_grad.
square()/Fr/Fr*(velocity_unit_vect*eta_grad_unit_vect)*
9181 double damping = nu_0 *
9182 pow((fmax(abs(vector_node_positions[q](0)),20)-20)/(31.169752-20),2) *
9183 DphiDt_phi_norm_grads[q];
9189 const double delta = cell->diameter()/sqrt(2);
9190 for (
unsigned int i=0; i<DphiDt_dofs_per_cell; ++i)
9192 double supg_shape_fun = 1.0*(delta)*fe_v.shape_grad(i, q)*velocity_unit_vect;
9193 for (
unsigned int j=0; j<DphiDt_dofs_per_cell; ++j)
9194 local_DphiDt_matrix(i,j) += ((fe_v.shape_value (i, q)+supg_shape_fun) *
9195 fe_v.shape_value (j, q)) *
9197 if (cell->material_id() == comp_dom.free_sur_ID1 ||
9198 cell->material_id() == comp_dom.free_sur_ID2 ||
9199 cell->material_id() == comp_dom.free_sur_ID3 )
9201 Point<dim> u(quad_nodes_velocities[q](0),quad_nodes_velocities[q](1),quad_nodes_velocities[q](2));
9202 double dEta_dt = (gradient[dim-1]+(u - gradient - Vinf)*eta_grad-damping);
9207 local_DphiDt_rhs(i) += (fe_v.shape_value (i, q)+supg_shape_fun) *
9208 ((gradient * gradient)/2 - g*DphiDt_node_positions[q](dim-1) +
9209 phi_surf_grad_corrected*(u - gradient - Vinf) -
9210 damping - delta_p) *
9212 local_DphiDt_rhs_2(i) += (fe_v.shape_value (i, q)+supg_shape_fun) *
9221 local_DphiDt_rhs(i) += 0;
9226 cell->get_dof_indices (DphiDt_local_dof_indices);
9228 (local_DphiDt_matrix,
9230 DphiDt_local_dof_indices,
9235 (local_DphiDt_rhs_2,
9236 DphiDt_local_dof_indices,
9241 rhs_evaluations_counter++;
9276 std::vector<unsigned int> vector_dofs(comp_dom.vector_fe.dofs_per_cell);
9277 std::vector<Point<dim> > vector_support_points(comp_dom.vector_dh.n_dofs());
9280 vector_sys_matrix.reinit (vector_sparsity_pattern);
9281 Vector<double> complete_gradient_sys_rhs(comp_dom.vector_dh.n_dofs());
9284 FEValues<dim-1,dim> vector_fe_v(*comp_dom.mapping, comp_dom.vector_fe, *comp_dom.quadrature,
9285 update_values | update_gradients |
9286 update_cell_normal_vectors |
9287 update_quadrature_points |
9290 FEValues<dim-1,dim> fe_v(*comp_dom.mapping, comp_dom.fe, *comp_dom.quadrature,
9291 update_values | update_gradients |
9292 update_cell_normal_vectors |
9293 update_quadrature_points |
9297 const unsigned int vector_n_q_points = vector_fe_v.n_quadrature_points;
9298 const unsigned int vector_dofs_per_cell = comp_dom.vector_fe.dofs_per_cell;
9299 std::vector<unsigned int> vector_local_dof_indices (vector_dofs_per_cell);
9302 Vector<double> local_complete_gradient_rhs (vector_dofs_per_cell);
9304 std::vector< Tensor<1,dim> > vector_phi_surf_grads(vector_n_q_points);
9305 std::vector<double> vector_phi_norm_grads(vector_n_q_points);
9309 vector_cell = comp_dom.vector_dh.begin_active(),
9310 vector_endc = comp_dom.vector_dh.end();
9312 cell = comp_dom.dh.begin_active(),
9313 endc = comp_dom.dh.end();
9315 for (; cell!=endc,vector_cell!=vector_endc; ++cell,++vector_cell)
9319 vector_fe_v.
reinit (vector_cell);
9322 local_vector_matrix = 0;
9323 local_complete_gradient_rhs = 0;
9325 fe_v.get_function_gradients((
const Vector<double> &)phi, vector_phi_surf_grads);
9326 fe_v.get_function_values(dphi_dn, vector_phi_norm_grads);
9329 const std::vector<Point<dim> > &vector_node_normals = vector_fe_v.get_normal_vectors();
9330 const std::vector<Point<dim> > &vector_node_positions = vector_fe_v.get_quadrature_points();
9334 std::vector<Vector<double> > vector_wind_values(vector_n_q_points);
9335 for (
unsigned int q=0; q<vector_n_q_points; ++q)
9337 vector_wind_values[q].reinit(dim,
true);
9338 wind.vector_value(vector_node_positions[q], vector_wind_values[q]);
9341 unsigned int comp_i, comp_j;
9342 for (
unsigned int q=0; q<vector_n_q_points; ++q)
9344 Point<dim> gradient = vector_node_normals[q]*vector_phi_norm_grads[q] + vector_phi_surf_grads[q];
9346 for (
unsigned int i=0; i<vector_dofs_per_cell; ++i)
9348 comp_i = comp_dom.vector_fe.system_to_component_index(i).first;
9349 for (
unsigned int j=0; j<vector_dofs_per_cell; ++j)
9351 comp_j = comp_dom.vector_fe.system_to_component_index(j).first;
9352 if (comp_i == comp_j)
9354 local_vector_matrix(i,j) += ( (vector_fe_v.shape_value(i, q))*
9355 vector_fe_v.shape_value(j, q) ) *
9360 local_complete_gradient_rhs(i) += (vector_fe_v.shape_value(i, q)) *
9361 gradient(comp_i) * vector_fe_v.JxW(q);
9365 vector_cell->get_dof_indices (vector_local_dof_indices);
9366 vector_constraints.distribute_local_to_global
9367 (local_vector_matrix,
9368 local_complete_gradient_rhs,
9369 vector_local_dof_indices,
9371 complete_gradient_sys_rhs);
9377 vector_direct.
vmult(complete_potential_gradients,complete_gradient_sys_rhs);
9378 vector_constraints.distribute(complete_potential_gradients);
9380 for (
unsigned int i=0; i<comp_dom.vector_dh.n_dofs(); ++i)
9382 std::set <unsigned int> doubles = comp_dom.vector_double_nodes_set[i];
9383 if ( doubles.size() > 1 )
9385 double average = 0.0;
9386 for (std::set<unsigned int>::iterator pos=doubles.begin(); pos != doubles.end(); ++pos)
9388 average += complete_potential_gradients(*pos);
9390 average /= doubles.size();
9391 for (std::set<unsigned int>::iterator pos=doubles.begin(); pos != doubles.end(); ++pos)
9393 complete_potential_gradients(*pos) = average;
9398 vector_constraints.distribute(complete_potential_gradients);
9414 std::cout<<
"Computing pressure... "<<std::endl;
9417 double rho = 1025.1;
9419 comp_dom.update_support_points();
9420 press.
reinit(comp_dom.dh.n_dofs());
9423 comp_1.
reinit(comp_dom.dh.n_dofs());
9424 comp_2.
reinit(comp_dom.dh.n_dofs());
9425 comp_3.
reinit(comp_dom.dh.n_dofs());
9426 comp_4.
reinit(comp_dom.dh.n_dofs());
9436 DphiDt_sys_rhs.
reinit (comp_dom.dh.n_dofs());
9437 DphiDt_sys_matrix.reinit(DphiDt_sparsity_pattern);
9440 VectorView<double> dphi_dn(comp_dom.dh.n_dofs(),solution.
begin()+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs());
9448 for (
unsigned int d=0; d<3; ++d)
9450 hull_baricenter_vel(d) = solution(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+d);
9451 hull_baricenter_displ(d) = solution(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+3+d);
9452 hull_ang_vel(d) = solution(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+6+d);
9455 Point<3> baricenter_pos(hull_baricenter_displ(0)+comp_dom.boat_model.reference_hull_baricenter(0),
9456 hull_baricenter_displ(1)+comp_dom.boat_model.reference_hull_baricenter(1),
9457 hull_baricenter_displ(2)+comp_dom.boat_model.reference_hull_baricenter(2));
9463 for (
unsigned int i = 0; i < comp_dom.dh.n_dofs(); i++)
9465 v_x(i) = node_vels(i*dim)+hull_ang_vel(1)*(comp_dom.support_points[i](2)-baricenter_pos(2))-
9466 hull_ang_vel(2)*(comp_dom.support_points[i](1)-baricenter_pos(1))+hull_baricenter_vel(0);
9467 v_y(i) = node_vels(i*dim+1)+hull_ang_vel(2)*(comp_dom.support_points[i](0)-baricenter_pos(0))-
9468 hull_ang_vel(0)*(comp_dom.support_points[i](2)-baricenter_pos(2))+hull_baricenter_vel(1);
9469 v_z(i) = node_vels(i*dim+2)+hull_ang_vel(0)*(comp_dom.support_points[i](1)-baricenter_pos(1))-
9470 hull_ang_vel(1)*(comp_dom.support_points[i](0)-baricenter_pos(0))+hull_baricenter_vel(2);
9473 FEValues<dim-1,dim> fe_v(*comp_dom.mapping, comp_dom.fe, *comp_dom.quadrature,
9474 update_values | update_gradients |
9475 update_cell_normal_vectors |
9476 update_quadrature_points |
9479 const unsigned int DphiDt_n_q_points = fe_v.n_quadrature_points;
9480 const unsigned int DphiDt_dofs_per_cell = comp_dom.fe.dofs_per_cell;
9481 std::vector<unsigned int> DphiDt_local_dof_indices (DphiDt_dofs_per_cell);
9491 std::vector< Tensor<1,dim> > DphiDt_phi_surf_grads(DphiDt_n_q_points);
9492 std::vector<double> DphiDt_phi_norm_grads(DphiDt_n_q_points);
9494 std::vector<double> DphiDt_v_x_values(DphiDt_n_q_points);
9495 std::vector<double> DphiDt_v_y_values(DphiDt_n_q_points);
9496 std::vector<double> DphiDt_v_z_values(DphiDt_n_q_points);
9497 std::vector<double> DphiDt_DphiDt_values(DphiDt_n_q_points);
9500 cell = comp_dom.dh.begin_active(),
9501 endc = comp_dom.dh.end();
9506 for (; cell!=endc; ++cell)
9509 local_DphiDt_rhs = 0;
9510 local_DphiDt_matrix = 0;
9512 local_DphiDt_rhs_comp_1 = 0;
9513 local_DphiDt_rhs_comp_2 = 0;
9514 local_DphiDt_rhs_comp_3 = 0;
9515 local_DphiDt_rhs_comp_4 = 0;
9517 fe_v.get_function_gradients((
const Vector<double> &)phi, DphiDt_phi_surf_grads);
9518 fe_v.get_function_values((
const Vector<double> &)dphi_dn, DphiDt_phi_norm_grads);
9519 fe_v.get_function_values(v_x, DphiDt_v_x_values);
9520 fe_v.get_function_values(v_y, DphiDt_v_y_values);
9521 fe_v.get_function_values(v_z, DphiDt_v_z_values);
9522 fe_v.get_function_values((
const Vector<double> &)DphiDt, DphiDt_DphiDt_values);
9523 const std::vector<Point<dim> > &DphiDt_node_normals = fe_v.get_normal_vectors();
9524 const std::vector<Point<dim> > &DphiDt_node_positions = fe_v.get_quadrature_points();
9526 std::vector<Vector<double> > DphiDt_wind_values(DphiDt_n_q_points);
9527 for (
unsigned int q=0; q<DphiDt_n_q_points; ++q)
9529 DphiDt_wind_values[q].reinit(dim,
true);
9530 wind.vector_value(DphiDt_node_positions[q],DphiDt_wind_values[q]);
9534 for (
unsigned int q=0; q<DphiDt_n_q_points; ++q)
9536 Point<dim> gradient = DphiDt_node_normals[q]*DphiDt_phi_norm_grads[q] + DphiDt_phi_surf_grads[q];
9538 for (
unsigned int i = 0; i < dim; i++)
9539 Vinf(i) = DphiDt_wind_values[q](i);
9542 phi_surf_grad = phi_surf_grad + DphiDt_phi_surf_grads[q];
9543 phi_surf_grad(dim-1) = 0;
9546 node_vel_vect(0) = DphiDt_v_x_values[q];
9547 node_vel_vect(1) = DphiDt_v_y_values[q];
9548 node_vel_vect(2) = DphiDt_v_z_values[q];
9551 if (sqrt((gradient+Vinf).square()) > 1e-3)
9552 velocity_unit_vect = (gradient+Vinf)/sqrt((gradient+Vinf).square());
9554 double press = rho*((Vinf)*(Vinf))/2 -
9555 rho*((gradient+Vinf)*(gradient+Vinf))/2 -
9556 rho*g*DphiDt_node_positions[q](dim-1) -
9557 rho*(DphiDt_DphiDt_values[q]-node_vel_vect*gradient);
9558 double press2 = -rho*((Vinf)*(gradient))
9559 -rho*((gradient)*(gradient))/2
9560 -rho*g*DphiDt_node_positions[q](dim-1)
9561 -rho*(DphiDt_DphiDt_values[q]-node_vel_vect*gradient);
9570 for (
unsigned int i=0; i<DphiDt_dofs_per_cell; ++i)
9572 for (
unsigned int j=0; j<DphiDt_dofs_per_cell; ++j)
9573 local_DphiDt_matrix(i,j) += ((fe_v.shape_value (i, q)) *
9574 fe_v.shape_value (j, q)) *
9576 local_DphiDt_rhs(i) += (fe_v.shape_value (i, q)) *
9579 local_DphiDt_rhs_comp_1(i) += (fe_v.shape_value (i, q)) *
9580 (rho*((Vinf)*(Vinf))/2) *
9582 local_DphiDt_rhs_comp_2(i) += (fe_v.shape_value (i, q)) *
9583 (-rho*((gradient+Vinf)*(gradient+Vinf))/2) *
9585 local_DphiDt_rhs_comp_3(i) += (fe_v.shape_value (i, q)) *
9586 (-rho*g*DphiDt_node_positions[q](dim-1)) *
9588 local_DphiDt_rhs_comp_4(i) += (fe_v.shape_value (i, q)) *
9589 (-rho*(DphiDt_DphiDt_values[q]-node_vel_vect*phi_surf_grad)) *
9593 if ((cell->material_id() == comp_dom.wall_sur_ID1 ||
9594 cell->material_id() == comp_dom.wall_sur_ID2 ||
9595 cell->material_id() == comp_dom.wall_sur_ID3 ))
9597 press_force_test_1 += press*DphiDt_node_normals[q]*fe_v.JxW(q);
9598 press_force_test_2 += press2*DphiDt_node_normals[q]*fe_v.JxW(q);
9599 press_moment += press*
Point<3>((DphiDt_node_positions[q](1)-baricenter_pos(1))*DphiDt_node_normals[q](2)-
9600 (DphiDt_node_positions[q](2)-baricenter_pos(2))*DphiDt_node_normals[q](1),
9601 (DphiDt_node_positions[q](2)-baricenter_pos(2))*DphiDt_node_normals[q](0)-
9602 (DphiDt_node_positions[q](0)-baricenter_pos(0))*DphiDt_node_normals[q](2),
9603 (DphiDt_node_positions[q](0)-baricenter_pos(0))*DphiDt_node_normals[q](1)-
9604 (DphiDt_node_positions[q](1)-baricenter_pos(1))*DphiDt_node_normals[q](0))*fe_v.JxW(q);
9608 cell->get_dof_indices (DphiDt_local_dof_indices);
9609 constraints.distribute_local_to_global
9610 (local_DphiDt_matrix,
9612 DphiDt_local_dof_indices,
9616 constraints.distribute_local_to_global
9617 (local_DphiDt_rhs_comp_1,
9618 DphiDt_local_dof_indices,
9620 constraints.distribute_local_to_global
9621 (local_DphiDt_rhs_comp_2,
9622 DphiDt_local_dof_indices,
9624 constraints.distribute_local_to_global
9625 (local_DphiDt_rhs_comp_3,
9626 DphiDt_local_dof_indices,
9628 constraints.distribute_local_to_global
9629 (local_DphiDt_rhs_comp_4,
9630 DphiDt_local_dof_indices,
9639 pressure_direct.
initialize(DphiDt_sys_matrix);
9640 pressure_direct.
vmult(press, DphiDt_sys_rhs);
9641 constraints.distribute(press);
9643 pressure_direct.
vmult(comp_1, rhs_comp_1);
9644 constraints.distribute(comp_1);
9645 pressure_direct.
vmult(comp_2, rhs_comp_2);
9646 constraints.distribute(comp_2);
9647 pressure_direct.
vmult(comp_3, rhs_comp_3);
9648 constraints.distribute(comp_3);
9649 pressure_direct.
vmult(comp_4, rhs_comp_4);
9650 constraints.distribute(comp_4);
9653 Vector<double> complete_potential_gradients(comp_dom.vector_dh.n_dofs());
9654 compute_potential_gradients(complete_potential_gradients,phi,dphi_dn);
9660 wind.vector_value(zzero,instantVelValue);
9663 instantVelValue(2));
9665 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
9667 Point<3> gradient(complete_potential_gradients(3*i),
9668 complete_potential_gradients(3*i+1),
9669 complete_potential_gradients(3*i+2));
9670 Point<3> v(node_vels(3*i),node_vels(3*i+1),node_vels(3*i+2));
9671 press(i) = 0.5*rho*V_inf*V_inf -
9672 0.5*rho*(V_inf+gradient)*(V_inf+gradient) -
9673 rho*g*comp_dom.support_points[i](2) -
9674 rho*(DphiDt(i)-v*gradient);
9681 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
9683 iges_normals_x_values(i) = comp_dom.iges_normals[i](0);
9684 iges_normals_y_values(i) = comp_dom.iges_normals[i](1);
9685 iges_normals_z_values(i) = comp_dom.iges_normals[i](2);
9691 double wet_surface = 0;
9693 cell = comp_dom.dh.begin_active(),
9694 endc = comp_dom.dh.end();
9696 std::vector<double> pressure_quad_values(DphiDt_n_q_points);
9697 std::vector<double> n_x_quad_values(DphiDt_n_q_points);
9698 std::vector<double> n_y_quad_values(DphiDt_n_q_points);
9699 std::vector<double> n_z_quad_values(DphiDt_n_q_points);
9701 for (; cell!=endc; ++cell)
9703 if ((cell->material_id() == comp_dom.wall_sur_ID1 ||
9704 cell->material_id() == comp_dom.wall_sur_ID2 ||
9705 cell->material_id() == comp_dom.wall_sur_ID3 ))
9708 fe_v.get_function_values(press, pressure_quad_values);
9709 fe_v.get_function_values(iges_normals_x_values, n_x_quad_values);
9710 fe_v.get_function_values(iges_normals_y_values, n_y_quad_values);
9711 fe_v.get_function_values(iges_normals_z_values, n_z_quad_values);
9713 const std::vector<Point<dim> > &DphiDt_node_normals = fe_v.get_normal_vectors();
9714 for (
unsigned int q=0; q<DphiDt_n_q_points; ++q)
9716 Point<3> normal(n_x_quad_values[q],n_y_quad_values[q],n_z_quad_values[q]);
9718 Point<dim> local_press_force = pressure_quad_values[q]*DphiDt_node_normals[q];
9719 press_force += (local_press_force) * fe_v.JxW(q);
9720 wet_surface += 1.0 * fe_v.JxW(q);
9726 Point<3> break_press_force(0.0,0.0,0.0);
9727 for (
tria_it elem=comp_dom.tria.begin_active(); elem!= comp_dom.tria.end(); ++elem)
9729 if ((elem->material_id() == comp_dom.free_sur_ID1 ||
9730 elem->material_id() == comp_dom.free_sur_ID2 ||
9731 elem->material_id() == comp_dom.free_sur_ID3 ))
9733 if (elem->at_boundary())
9735 for (
unsigned int f=0; f<GeometryInfo<2>::faces_per_cell; ++f)
9737 if ( elem->face(f)->boundary_id() == 27 ||
9738 elem->face(f)->boundary_id() == 29 )
9740 std::vector<Point<3> > vertices(4);
9741 std::vector<CellData<2> > cells(1);
9744 unsigned int index_0 = comp_dom.find_point_id(elem->face(f)->vertex(0),comp_dom.ref_points);
9745 std::set<unsigned int> duplicates = comp_dom.double_nodes_set[index_0];
9746 for (std::set<unsigned int>::iterator pos = duplicates.begin(); pos !=duplicates.end(); pos++)
9749 if (comp_dom.flags[*pos] &
water)
9755 vertices[0] = comp_dom.support_points[index_0];
9756 pressure_vect(0) = fmax(break_wave_press(index_0),1e-4)*rho;
9758 unsigned int index_1 = comp_dom.find_point_id(elem->face(f)->vertex(1),comp_dom.ref_points);
9759 duplicates = comp_dom.double_nodes_set[index_1];
9760 for (std::set<unsigned int>::iterator pos = duplicates.begin(); pos !=duplicates.end(); pos++)
9763 if (comp_dom.flags[*pos] &
water)
9769 vertices[1] = comp_dom.support_points[index_1];
9770 pressure_vect(1) = fmax(break_wave_press(index_1),1e-4)*rho;
9772 Point<3> temp_point(vertices[0](0),vertices[0](1),vertices[0](2)+pressure_vect(0)/g/rho);
9774 if ( (comp_dom.moving_point_ids[3] != index_0) &&
9775 (comp_dom.moving_point_ids[4] != index_0) &&
9776 (comp_dom.moving_point_ids[5] != index_0) &&
9777 (comp_dom.moving_point_ids[6] != index_0) )
9781 comp_dom.boat_model.boat_water_line_left->axis_projection(vertices[2],temp_point);
9785 vertices[2] = vertices[0];
9786 temp_point =
Point<3>(vertices[1](0),vertices[1](1),vertices[1](2)+pressure_vect(1)/g/rho);
9788 if ( (comp_dom.moving_point_ids[3] != index_1) &&
9789 (comp_dom.moving_point_ids[4] != index_1) &&
9790 (comp_dom.moving_point_ids[5] != index_1) &&
9791 (comp_dom.moving_point_ids[6] != index_1) )
9795 comp_dom.boat_model.boat_water_line_left->axis_projection(vertices[3],temp_point);
9799 vertices[3] = vertices[1];
9802 pressure_vect(2) = 0.0;
9803 pressure_vect(3) = 0.0;
9804 if (vertices[1](0) < vertices[0](0))
9806 cells[0].vertices[0]=0;
9807 cells[0].vertices[1]=1;
9808 cells[0].vertices[2]=3;
9809 cells[0].vertices[3]=2;
9814 cells[0].vertices[0]=1;
9815 cells[0].vertices[1]=0;
9816 cells[0].vertices[2]=2;
9817 cells[0].vertices[3]=3;
9824 break_tria.create_triangulation_compatibility(vertices, cells, subcelldata );
9825 FE_Q<dim-1,dim> break_fe(1);
9827 break_dh.distribute_dofs(break_fe);
9829 FEValues<dim-1,dim> break_fe_v(break_fe, *comp_dom.quadrature,
9830 update_values | update_gradients |
9831 update_cell_normal_vectors |
9832 update_quadrature_points |
9835 const unsigned int break_n_q_points = break_fe_v.n_quadrature_points;
9836 std::vector<double> break_pressure_quad_values(break_n_q_points);
9837 cell_it cell = break_dh.begin_active();
9838 break_fe_v.reinit(cell);
9839 break_fe_v.get_function_values(pressure_vect, break_pressure_quad_values);
9840 const std::vector<Point<dim> > &break_node_normals = break_fe_v.get_normal_vectors();
9841 const std::vector<Point<dim> > &break_quad_nodes = break_fe_v.get_quadrature_points();
9843 for (
unsigned int q=0; q<break_n_q_points; ++q)
9845 Point<dim> local_press_force = break_pressure_quad_values[q]*break_node_normals[q];
9846 break_press_force += (local_press_force) * break_fe_v.JxW(q);
9853 if ( elem->face(f)->boundary_id() == 26 ||
9854 elem->face(f)->boundary_id() == 28 )
9856 std::vector<Point<3> > vertices(4);
9857 std::vector<CellData<2> > cells(1);
9860 unsigned int index_0 = comp_dom.find_point_id(elem->face(f)->vertex(0),comp_dom.ref_points);
9861 std::set<unsigned int> duplicates = comp_dom.double_nodes_set[index_0];
9862 for (std::set<unsigned int>::iterator pos = duplicates.begin(); pos !=duplicates.end(); pos++)
9865 if (comp_dom.flags[*pos] &
water)
9871 vertices[0] = comp_dom.support_points[index_0];
9872 pressure_vect(0) = fmax(break_wave_press(index_0),1e-4)*rho;
9874 unsigned int index_1 = comp_dom.find_point_id(elem->face(f)->vertex(1),comp_dom.ref_points);
9875 duplicates = comp_dom.double_nodes_set[index_1];
9876 for (std::set<unsigned int>::iterator pos = duplicates.begin(); pos !=duplicates.end(); pos++)
9879 if (comp_dom.flags[*pos] &
water)
9885 vertices[1] = comp_dom.support_points[index_1];
9886 pressure_vect(1) = fmax(break_wave_press(index_1),1e-4)*rho;
9887 Point<3> temp_point(vertices[0](0),vertices[0](1),vertices[0](2)+pressure_vect(0)/g/rho);
9889 if ( (comp_dom.moving_point_ids[3] != index_0) &&
9890 (comp_dom.moving_point_ids[4] != index_0) &&
9891 (comp_dom.moving_point_ids[5] != index_0) &&
9892 (comp_dom.moving_point_ids[6] != index_0) )
9896 comp_dom.boat_model.boat_water_line_right->axis_projection(vertices[2],temp_point);
9900 vertices[2] = vertices[0];
9901 temp_point =
Point<3>(vertices[1](0),vertices[1](1),vertices[1](2)+pressure_vect(1)/g/rho);
9902 if ( (comp_dom.moving_point_ids[3] != index_1) &&
9903 (comp_dom.moving_point_ids[4] != index_1) &&
9904 (comp_dom.moving_point_ids[5] != index_1) &&
9905 (comp_dom.moving_point_ids[6] != index_1) )
9909 comp_dom.boat_model.boat_water_line_right->axis_projection(vertices[3],temp_point);
9913 vertices[3] = vertices[1];
9915 pressure_vect(2) = 0.0;
9916 pressure_vect(3) = 0.0;
9917 if (vertices[1](0) > vertices[0](0))
9919 cells[0].vertices[0]=0;
9920 cells[0].vertices[1]=1;
9921 cells[0].vertices[2]=3;
9922 cells[0].vertices[3]=2;
9927 cells[0].vertices[0]=1;
9928 cells[0].vertices[1]=0;
9929 cells[0].vertices[2]=2;
9930 cells[0].vertices[3]=3;
9937 break_tria.create_triangulation_compatibility(vertices, cells, subcelldata );
9938 FE_Q<dim-1,dim> break_fe(1);
9940 break_dh.distribute_dofs(break_fe);
9941 FEValues<dim-1,dim> break_fe_v(break_fe, *comp_dom.quadrature,
9942 update_values | update_gradients |
9943 update_cell_normal_vectors |
9944 update_quadrature_points |
9947 const unsigned int break_n_q_points = break_fe_v.n_quadrature_points;
9948 std::vector<double> break_pressure_quad_values(break_n_q_points);
9949 cell_it cell = break_dh.begin_active();
9950 break_fe_v.reinit(cell);
9951 break_fe_v.get_function_values(pressure_vect, break_pressure_quad_values);
9952 const std::vector<Point<dim> > &break_node_normals = break_fe_v.get_normal_vectors();
9953 const std::vector<Point<dim> > &break_quad_nodes = break_fe_v.get_quadrature_points();
9955 for (
unsigned int q=0; q<break_n_q_points; ++q)
9957 Point<dim> local_press_force = break_pressure_quad_values[q]*break_node_normals[q];
9958 break_press_force += (local_press_force) * break_fe_v.JxW(q);
9977 wind.vector_value(zero,instantWindValue);
9978 double Vinf = instantWindValue(0);
9980 double transom_wet_surface = 0;
9982 if (!comp_dom.no_boat && comp_dom.boat_model.is_transom)
9986 double transom_draft = fabs(comp_dom.boat_model.CurrentPointCenterTransom(2));
9987 double transom_aspect_ratio = (fabs(comp_dom.boat_model.CurrentPointLeftTransom(1))+
9988 fabs(comp_dom.boat_model.CurrentPointRightTransom(1)))/transom_draft;
9989 double FrT = sqrt(Vinf*Vinf)/sqrt(9.81*transom_draft);
9990 double ReT = sqrt(9.81*pow(transom_draft,3.0))/1.307e-6;
9991 double eta_dry=fmin(0.05*pow(FrT,2.834)*pow(transom_aspect_ratio,0.1352)*pow(ReT,0.01338),1.0);
9993 cout<<
"eta_dry "<<eta_dry<<endl;
9994 std::vector<Point<3> > vertices;
9995 std::vector<CellData<2> > cells;
9996 std::vector<double> transom_pressure_vect;
9997 for (
tria_it elem=comp_dom.tria.begin_active(); elem!= comp_dom.tria.end(); ++elem)
9999 if ((elem->material_id() == comp_dom.wall_sur_ID1 ||
10000 elem->material_id() == comp_dom.wall_sur_ID2 ||
10001 elem->material_id() == comp_dom.wall_sur_ID3 ))
10003 if (elem->at_boundary())
10005 for (
unsigned int f=0; f<GeometryInfo<2>::faces_per_cell; ++f)
10006 if ( elem->face(f)->boundary_id() == 32 ||
10007 elem->face(f)->boundary_id() == 37 )
10009 unsigned int index_0 = comp_dom.find_point_id(elem->face(f)->vertex(0),comp_dom.ref_points);
10010 double pressure_0 = (1-eta_dry)*comp_dom.ref_points[3*index_0](2)*rho*g;
10011 unsigned int index_1 = comp_dom.find_point_id(elem->face(f)->vertex(1),comp_dom.ref_points);
10012 double pressure_1 = (1-eta_dry)*comp_dom.ref_points[3*index_1](2)*rho*g;
10013 if (comp_dom.ref_points[3*index_1](1) < comp_dom.ref_points[3*index_0](1))
10015 vertices.push_back(comp_dom.ref_points[3*index_0]);
10017 transom_pressure_vect.push_back(pressure_0);
10018 vertices.push_back(comp_dom.ref_points[3*index_1]);
10020 transom_pressure_vect.push_back(pressure_1);
10021 vertices.push_back(comp_dom.ref_points[3*index_1]+
10022 -1.0*
Point<3>(0.0,0.0,(1-eta_dry)*comp_dom.ref_points[3*index_1](2)));
10025 transom_pressure_vect.push_back(0.0);
10026 vertices.push_back(comp_dom.ref_points[3*index_0]+
10027 -1.0*
Point<3>(0.0,0.0,(1-eta_dry)*comp_dom.ref_points[3*index_0](2)));
10030 transom_pressure_vect.push_back(0.0);
10031 cells.resize(cells.size()+1);
10032 cells[cells.size()-1].vertices[0]=4*(cells.size()-1)+0;
10033 cells[cells.size()-1].vertices[1]=4*(cells.size()-1)+1;
10034 cells[cells.size()-1].vertices[2]=4*(cells.size()-1)+2;
10035 cells[cells.size()-1].vertices[3]=4*(cells.size()-1)+3;
10039 vertices.push_back(comp_dom.ref_points[3*index_1]);
10040 transom_pressure_vect.push_back(pressure_1);
10041 vertices.push_back(comp_dom.ref_points[3*index_0]);
10042 transom_pressure_vect.push_back(pressure_0);
10043 vertices.push_back(comp_dom.ref_points[3*index_0]+
10044 -1.0*
Point<3>(0.0,0.0,(1-eta_dry)*comp_dom.ref_points[3*index_0](2)));
10045 transom_pressure_vect.push_back(0.0);
10046 vertices.push_back(comp_dom.ref_points[3*index_1]+
10047 -1.0*
Point<3>(0.0,0.0,(1-eta_dry)*comp_dom.ref_points[3*index_1](2)));
10048 transom_pressure_vect.push_back(0.0);
10049 cells.resize(cells.size()+1);
10050 cells[cells.size()-1].vertices[0]=4*(cells.size()-1)+0;
10051 cells[cells.size()-1].vertices[1]=4*(cells.size()-1)+1;
10052 cells[cells.size()-1].vertices[2]=4*(cells.size()-1)+2;
10053 cells[cells.size()-1].vertices[3]=4*(cells.size()-1)+3;
10060 for (
unsigned int i=0; i<transom_pressure_vect.size(); ++i)
10062 transom_pressure(i) = transom_pressure_vect[i];
10070 transom_tria.create_triangulation_compatibility(vertices, cells, subcelldata );
10071 FE_Q<dim-1,dim> transom_fe(1);
10072 DoFHandler<dim-1,dim> transom_dh(transom_tria);
10073 transom_dh.distribute_dofs(transom_fe);
10075 FEValues<dim-1,dim> transom_fe_v(transom_fe, *comp_dom.quadrature,
10076 update_values | update_gradients |
10077 update_cell_normal_vectors |
10078 update_quadrature_points |
10079 update_JxW_values);
10081 const unsigned int transom_n_q_points = transom_fe_v.n_quadrature_points;
10086 std::vector<double> transom_pressure_quad_values(transom_n_q_points);
10087 for (
cell_it cell = transom_dh.begin_active(); cell!=transom_dh.end(); ++cell)
10089 transom_fe_v.reinit(cell);
10090 transom_fe_v.get_function_values(transom_pressure, transom_pressure_quad_values);
10091 const std::vector<Point<dim> > &transom_node_normals = transom_fe_v.get_normal_vectors();
10092 const std::vector<Point<dim> > &transom_quad_nodes = transom_fe_v.get_quadrature_points();
10093 for (
unsigned int q=0; q<transom_n_q_points; ++q)
10095 Point<dim> local_press_force = transom_pressure_quad_values[q]*transom_node_normals[q];
10096 transom_press_force += (local_press_force) * transom_fe_v.JxW(q);
10097 transom_wet_surface += 1 * transom_fe_v.JxW(q);
10105 transom_press_force =
Point<3>(0.0,0.0,0.0);
10106 transom_wet_surface = 0;
10114 dataout.add_data_vector(transom_pressure,
"transom_pressure");
10117 std::ofstream file(
"transom.vtu");
10118 dataout.write_vtu(file);
10125 double Re_l = fmax(1e-5,Vinf*comp_dom.Lx_boat/1.307e-6);
10127 double Cd = 0.075/(pow(log10(Re_l)-2., 2));
10128 double viscous_drag = 0.5*rho*Vinf*Vinf*comp_dom.boat_model.boatWetSurface*Cd;
10129 Point<3> visc_force(viscous_drag,0.0,0.0);
10131 std::string press_filename = ( output_file_name +
"_force.txt" );
10134 if ( fabs(t-initial_time) < 1e-5 )
10135 myfile.open (press_filename.c_str());
10137 myfile.open (press_filename.c_str(),ios::app);
10138 myfile << t <<
" "<<press_force<<
" "<<transom_press_force<<
" "<<visc_force<<
" "<<break_press_force<<
" "<<press_moment<<
" "<<wet_surface+transom_wet_surface<<
" "<<press_force_test_1<<
" "<<press_force_test_2<<
" \n";
10141 std::cout<<
"Total Force: "<<press_force-transom_press_force+visc_force+break_press_force<<std::endl;
10142 std::cout<<
"Pressure Force: "<<press_force<<std::endl;
10143 std::cout<<
"Breaking Wave Pressure Force: "<<break_press_force<<std::endl;
10144 std::cout<<
"Transom Pressure Force: "<<transom_press_force<<std::endl;
10145 std::cout<<
"Viscous Force: "<<visc_force<<std::endl;
10146 std::cout<<
"Pressure Moment: "<<press_moment<<std::endl;
10147 std::cout<<
"Wet Surface: "<<wet_surface<<
" Transom Wet Surface: "<<transom_wet_surface<<
" ("<<ref_transom_wet_surface<<
")"<<std::endl;
10149 double max_err = 0.0;
10150 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
10155 double omega=2.4835;
10158 double time_factor = 1.0;
10159 double time_factor_deriv = 0.0;
10160 double ramp_length = 20.0;
10163 time_factor = 0.5*sin(3.141592654*(t)/ramp_length-3.141592654/2)+0.5;
10164 time_factor_deriv = 0.5*3.141592654/ramp_length*cos(3.141592654*(t)/ramp_length-3.141592654/2);
10166 double dphi_dt = omega*omega*a/k*cosh(k*(comp_dom.support_points[i](2)+h))/sinh(k*h)*cos(k*comp_dom.support_points[i](0)+omega*t)*time_factor +
10167 omega*a/k*cosh(k*(comp_dom.support_points[i](2)+h))/sinh(k*h)*sin(k*comp_dom.support_points[i](0)+omega*t)*time_factor_deriv;
10168 Point<3> grad_phi(omega*a*cosh(k*(comp_dom.support_points[i](2)+h))/sinh(k*h)*cos(k*comp_dom.support_points[i](0)+omega*t)*time_factor,
10170 omega*a*sinh(k*(comp_dom.support_points[i](2)+h))/sinh(k*h)*sin(k*comp_dom.support_points[i](0)+omega*t)*time_factor);
10174 double ex_pressure = ( -dphi_dt - 0.5*(grad_phi*grad_phi) -
10175 grad_phi(0)*instantWindValue(0)-grad_phi(1)*instantWindValue(1)-grad_phi(2)*instantWindValue(2) -
10176 comp_dom.support_points[i](2)*g ) * rho;
10177 cout<<i<<
": P=("<<comp_dom.support_points[i]<<
") p_ex="<<ex_pressure<<
" vs p="<<press(i)<<
" err="<<fabs(ex_pressure-press(i))<<endl;
10178 max_err = fmax(fabs(ex_pressure-press(i)),max_err);
10181 cout<<
"Max Err: "<<max_err<<endl;
10207 std::cout<<
"...done computing pressure. "<<std::endl;
10222 VectorView<double> dphi_dn(comp_dom.dh.n_dofs(),solution.
begin()+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs());
10228 wind.vector_value(zero,instantWindValue);
10230 for (
unsigned int i = 0; i < dim; i++)
10231 Vinf(i) = instantWindValue(i);
10236 for (
unsigned int d=0; d<3; ++d)
10238 hull_lin_vel(d) = solution(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+d);
10239 hull_ang_vel(d) = solution(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+6+d);
10240 hull_lin_displ(d) = solution(comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs()+3+d);
10243 Point<3> baricenter_pos(hull_lin_displ(0)+comp_dom.boat_model.reference_hull_baricenter(0),
10244 hull_lin_displ(1)+comp_dom.boat_model.reference_hull_baricenter(1),
10245 hull_lin_displ(2)+comp_dom.boat_model.reference_hull_baricenter(2));
10259 Vector<double> complete_potential_gradients(comp_dom.vector_dh.n_dofs());
10260 compute_potential_gradients(complete_potential_gradients,phi,dphi_dn);
10262 for (
unsigned int i = 0; i < comp_dom.dh.n_dofs(); i++)
10264 fluid_vel_x(i) = complete_potential_gradients(i*dim)+Vinf(0);
10265 fluid_vel_y(i) = complete_potential_gradients(i*dim+1)+Vinf(1);
10266 fluid_vel_z(i) = complete_potential_gradients(i*dim+2)+Vinf(2);
10267 if ( ((comp_dom.flags[i] &
boat) &&
10272 Point<3> rig_vel(hull_ang_vel(1)*(comp_dom.support_points[i](2)-hull_lin_displ(2))-
10273 hull_ang_vel(2)*(comp_dom.support_points[i](1)-hull_lin_displ(1))+hull_lin_vel(0),
10274 hull_ang_vel(2)*(comp_dom.support_points[i](0)-hull_lin_displ(0))-
10275 hull_ang_vel(0)*(comp_dom.support_points[i](2)-hull_lin_displ(2))+hull_lin_vel(1),
10276 hull_ang_vel(0)*(comp_dom.support_points[i](1)-hull_lin_displ(1))-
10277 hull_ang_vel(1)*(comp_dom.support_points[i](0)-hull_lin_displ(0))+hull_lin_vel(2));
10279 nodes_vel_x(i) = nodes_vel(i*dim)+rig_vel(0);
10280 nodes_vel_y(i) = nodes_vel(i*dim+1)+rig_vel(1);
10281 nodes_vel_z(i) = nodes_vel(i*dim+2)+rig_vel(2);
10285 nodes_vel_x(i) = nodes_vel(i*dim);
10286 nodes_vel_y(i) = nodes_vel(i*dim+1);
10287 nodes_vel_z(i) = nodes_vel(i*dim+2);
10296 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); i++)
10298 elevations(i) = solution(dim*i+dim-1);
10306 compute_pressure(
pressure,comp_1,comp_2,comp_3,comp_4,t,solution,solution_dot);
10312 for (
unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
10314 iges_normals_x_values(i) = comp_dom.iges_normals[i](0);
10315 iges_normals_y_values(i) = comp_dom.iges_normals[i](1);
10316 iges_normals_z_values(i) = comp_dom.iges_normals[i](2);
10326 dataout.add_data_vector((
const Vector<double> &)phi_dot,
"phi_dot");
10327 dataout.add_data_vector(elevations,
"elevations");
10328 dataout.add_data_vector(
pressure,
"pressure");
10329 dataout.add_data_vector((
const Vector<double> &)dphi_dn,
"dphi_dn");
10330 dataout.add_data_vector(fluid_vel_x,
"fluid_vel_x");
10331 dataout.add_data_vector(fluid_vel_y,
"fluid_vel_y");
10332 dataout.add_data_vector(fluid_vel_z,
"fluid_vel_z");
10333 dataout.add_data_vector(nodes_vel_x,
"nodes_vel_x");
10334 dataout.add_data_vector(nodes_vel_y,
"nodes_vel_y");
10335 dataout.add_data_vector(nodes_vel_z,
"nodes_vel_z");
10338 dataout.add_data_vector(break_wave_press,
"break_wave_press");
10339 dataout.add_data_vector(comp_1,
"comp_1");
10340 dataout.add_data_vector(comp_2,
"comp_2");
10341 dataout.add_data_vector(comp_3,
"comp_3");
10342 dataout.add_data_vector(comp_4,
"comp_4");
10343 dataout.add_data_vector(iges_normals_x_values,
"iges_normals_x");
10344 dataout.add_data_vector(iges_normals_y_values,
"iges_normals_y");
10345 dataout.add_data_vector(iges_normals_z_values,
"iges_normals_z");
10351 dataout.build_patches(*comp_dom.mapping,
10352 comp_dom.vector_fe.degree,
10355 std::ofstream file(filename.c_str());
10357 dataout.write_vtu(file);
10360 std::string hull_motions_filename = ( output_file_name +
"_hull_motions.txt" );
10363 if ( fabs(t-initial_time) < 1e-5 )
10364 myfile.open (hull_motions_filename.c_str());
10366 myfile.open (hull_motions_filename.c_str(),ios::app);
10367 myfile << t <<
" "<<baricenter_pos<<
" "<<comp_dom.boat_model.yaw_angle<<
" "<<-comp_dom.boat_model.pitch_angle+comp_dom.boat_model.initial_trim<<
" "<<-comp_dom.boat_model.roll_angle<<
" "<<hull_lin_vel<<
" "<<hull_ang_vel<<
" \n";
10430 unsigned int n_points;
10434 infile.open(
"points.txt");
10437 if (!infile.is_open())
10439 cerr<<
"Opening failed"<<endl;
10444 infile >> n_points;
10446 std::vector< Point<3> > points(n_points,
Point<3>(0.0,0.0,0.0));
10447 std::vector< Point<3> > velocities(n_points,
Point<3>(0.0,0.0,0.0));
10449 unsigned int count = 0;
10450 while (!infile.eof())
10452 infile >> points[count](0) >> points[count](1) >> points[count](2);
10460 comp_dom.update_support_points();
10463 FEValues<dim-1,dim> fe_v(*comp_dom.mapping, comp_dom.fe, *comp_dom.quadrature,
10464 update_values | update_gradients |
10465 update_cell_normal_vectors |
10466 update_quadrature_points |
10467 update_JxW_values);
10470 const unsigned int n_q_points = fe_v.n_quadrature_points;
10471 const unsigned int dofs_per_cell = comp_dom.fe.dofs_per_cell;
10472 std::vector<unsigned int> local_dof_indices (dofs_per_cell);
10474 std::vector<double> q_phi(n_q_points);
10475 std::vector<double> q_dphi_dn(n_q_points);
10480 cell = comp_dom.dh.begin_active(),
10481 endc = comp_dom.dh.end();
10483 for (; cell!=endc; ++cell)
10487 fe_v.get_function_values(dphi_dn, q_dphi_dn);
10488 fe_v.get_function_values(phi, q_phi);
10489 const std::vector<Point<dim> > &quad_nodes = fe_v.get_quadrature_points();
10490 const std::vector<Point<dim> > &quad_nodes_normals = fe_v.get_normal_vectors();
10492 for (
unsigned int i=0; i<n_points; ++i)
10503 for (
unsigned int q=0; q<n_q_points; ++q)
10517 Point<dim> grad_G(G.fastAccessDx(0),G.fastAccessDx(1),G.fastAccessDx(2));
10518 Point<dim> grad_dG_dn(dG_dn.fastAccessDx(0),dG_dn.fastAccessDx(1),dG_dn.fastAccessDx(2));
10520 velocities[i] += (q_dphi_dn[q]*grad_G - q_phi[q]*grad_dG_dn)*fe_v.JxW(q);
10529 for (
unsigned int i=0; i<n_points; ++i)
10530 cout<<i<<
" P("<<points[i]<<
") grad_phi("<<velocities[i]<<
") "<<endl;
10533 myfile.open (
"velocities.txt");
10534 for (
unsigned int i=0; i<n_points; ++i)
10535 myfile<<velocities[i]<<endl;
10543 std::vector<Point<dim> > supp_points(comp_dom.vector_dh.n_dofs());
10545 comp_dom.vector_dh,
10580 const std::string fname)
const
10582 std::cout <<
"Dumping solution: " << fname << std::endl;
10583 std::ofstream ofile((fname+
"_y.dat").c_str());
10586 ofile.open((fname+
"_yp.dat").c_str());
10588 comp_dom.dump_tria(fname+
"_tria.dat");
10597 const std::string fname)
10599 std::cout <<
"Restoring solution: " << fname << std::endl;
10601 std::ifstream ifile((fname+
"_y.dat").c_str());
10604 ifile.open((fname+
"_yp.dat").c_str());
10607 comp_dom.restore_tria(fname+
"_tria.dat");
10608 comp_dom.update_mapping(y);
10617 for (
unsigned int i=0; i<comp_dom.vector_dh.n_dofs(); ++i)
10619 if (sys_comp(i) == 0)
10621 std::set<unsigned int> doubles = comp_dom.vector_double_nodes_set[i];
10622 for (std::set<unsigned int>::iterator it = doubles.begin() ; it != doubles.end(); it++ )
10625 comp_dom.map_points(i) = comp_dom.map_points(*it);
10632 comp_dom.full_mesh_treatment();
10633 vector_constraints.distribute(comp_dom.map_points);
10639 for (
unsigned int i=0; i<comp_dom.vector_dh.n_dofs(); ++i)
10641 if (sys_comp(i) == 0)
10643 std::set<unsigned int> doubles = comp_dom.vector_double_nodes_set[i];
10644 for (std::set<unsigned int>::iterator it = doubles.begin() ; it != doubles.end(); it++ )
10647 comp_dom.map_points(i) = comp_dom.map_points(*it);
10653 comp_dom.partial_mesh_treatment(blend_factor);
10654 vector_constraints.distribute(comp_dom.map_points);
void block_read(std::istream &in)
const Tensor< 1, spacedim > & shape_grad(const unsigned int function_no, const unsigned int quadrature_point) const
void refine_and_coarsen_fixed_number(Triangulation< dim, spacedim > &triangulation, const VectorType &criteria, const double top_fraction_of_cells, const double bottom_fraction_of_cells, const unsigned int max_n_cells=std::numeric_limits< unsigned int >::max())
void prepare_bem_vectors(double time, Vector< double > &bem_bc, Vector< double > &dphi_dn) const
real_type l2_norm() const
active_cell_iterator begin_active(const unsigned int level=0) const
virtual void output_step(Vector< double > &solution, const unsigned int step_number)
This function is called at the end of each iteration step for the newton solver.
#define AssertDimension(dim1, dim2)
void prepare_restart(const double t, Vector< double > &y, Vector< double > &yp, bool restart_flag=true)
Method to make sure residual is null at each (re)start of the computation.
virtual int residual(const double t, Vector< double > &dst, const Vector< double > &src_yy, const Vector< double > &src_yp)
For dae problems, we need a residual function.
static void declare_parameters(ParameterHandler ¶m)
Tensor< 1, dim, Type > & T(Point< dim, Type > &p)
void attach_dof_handler(const DoFHandlerType &)
void remove_transom_hanging_nodes(Vector< double > &solution, Vector< double > &solution_dot, const double t, const unsigned int step_number, const double h)
void set(const std::string &entry_name, const std::string &new_value)
void output_results(const std::string, const double t, const Vector< double > &solution, const Vector< double > &pressure)
ActiveSelector::active_cell_iterator active_cell_iterator
virtual int setup_jacobian_prec(const Vector< double > &src_yy)
Setup Jacobian preconditioner for Newton.
numbers::NumberTraits< double >::real_type distance(const Point< dim, double > &p) const
numbers::NumberTraits< Number >::real_type norm() const
#define AssertThrow(cond, exc)
virtual void reinit(const SparsityPattern &sparsity)
std::string get(const std::string &entry_string) const
void vmult(Vector< double > &dst, const Vector< double > &src) const
static void declare_parameters(ParameterHandler &prm, const unsigned int n_components=1)
virtual unsigned int n_dofs() const
Returns the number of degrees of freedom.
virtual unsigned int n_dofs() const
Returns the number of degrees of freedom.
void enter_subsection(const std::string &subsection)
void add(const std::vector< size_type > &indices, const std::vector< OtherNumber > &values)
void make_hanging_node_constraints(const DoFHandlerType &dof_handler, ConstraintMatrix &constraints)
void distribute_local_to_global(const InVector &local_vector, const std::vector< size_type > &local_dof_indices, OutVector &global_vector) const
virtual unsigned int n_dofs() const
Returns the number of degrees of freedom.
Vector< double > & get_diameters()
static::ExceptionBase & ExcMessage(std::string arg1)
DoFHandler< dim-1, dim >::active_cell_iterator cell_it
void enforce_partial_geometry_constraints(const double blend_factor)
static void reorder_cells(std::vector< CellData< dim > > &original_cells, const bool use_new_style_ordering=false)
#define Assert(cond, exc)
void compute_potential_gradients(Vector< double > &complete_potential_gradients, const Vector< double > &phi, const Vector< double > &dphi_dn)
Sacado::Fad::DFad< double > fad_double
void compute_keel_smoothing(Vector< double > &smoothing)
Triangulation< dim-1, dim >::active_cell_iterator tria_it
void declare_parameters(ParameterHandler &prm)
virtual bool solution_check(Vector< double > &solution, Vector< double > &solution_dot, const double t, const unsigned int step_number, const double h)
This function will check the behaviour of the solution.
std::map< types::boundary_id, const Function< dim, Number > * > type
virtual Vector< double > & differential_components()
And an identification of the differential components.
void block_write(std::ostream &out) const
virtual int jacobian_prec(const double t, Vector< double > &dst, const Vector< double > &src_yy, const Vector< double > &src_yp, const Vector< double > &src, const double alpha)
Jacobian inverse preconditioner vector product for dae.
void enforce_full_geometry_constraints()
std::string int_to_string(const unsigned int value, const unsigned int digits=numbers::invalid_unsigned_int)
std::map< unsigned int, unsigned int > indices_map
void print(const char *format=0) const DEAL_II_DEPRECATED
void compute_internal_velocities(const Vector< double > &phi, const Vector< double > &dphi_dn)
void dump_solution(const Vector< double > &y, const Vector< double > &yp, const std::string fname) const
const unsigned int dofs_per_cell
bool get_bool(const std::string &entry_name) const
void compute_pressure(Vector< double > &press, Vector< double > &comp_1, Vector< double > &comp_2, Vector< double > &comp_3, Vector< double > &comp_4, const double t, const Vector< double > &solution, const Vector< double > &solution_dot)
const unsigned int n_quadrature_points
numbers::NumberTraits< double >::real_type square() const
virtual int jacobian_prec_prod(Vector< double > &dst, const Vector< double > &src_yy, const Vector< double > &src)
Jacobian preconditioner vector product for newton solver.
const double & shape_value(const unsigned int function_no, const unsigned int point_no) const
double norm(const FEValuesBase< dim > &fe, const VectorSlice< const std::vector< std::vector< Tensor< 1, dim > > > > &Du)
dealii::Point< 3 > Pnt(const gp_Pnt &p)
Convert OpenCascade point into.
virtual int jacobian(const double t, Vector< double > &dst, const Vector< double > &src_yy, const Vector< double > &src_yp, const Vector< double > &src, const double alpha)
Jacobian vector product for dae.
void make_sparsity_pattern(const DoFHandlerType &dof_handler, SparsityPatternType &sparsity_pattern, const ConstraintMatrix &constraints=ConstraintMatrix(), const bool keep_constrained_dofs=true, const types::subdomain_id subdomain_id=numbers::invalid_subdomain_id)
void initialize(const SparsityPattern &sparsity_pattern)
unsigned int solve(Vector< double > &solution, const unsigned int max_steps)
Solve.
void make_edges_conformal(Vector< double > &solution, Vector< double > &solution_dot, const double t, const unsigned int step_number, const double h)
Method to enforce mesh conformity at edges at each restart.
int residual_and_jacobian(const double t, Vector< double > &dst, const Vector< double > &src_yy, const Vector< double > &src_yp, const Vector< double > &src, const double alpha, const bool is_jacobian)
This function computes either DAE residual or corrensponding Jacobian matrix vector product with vect...
void add(const doublea, const FullMatrix< number2 > &A)
double get_double(const std::string &entry_name) const
virtual void distribute_dofs(const FiniteElement< dim, spacedim > &fe)
virtual void reinit(const size_type N, const bool omit_zeroing_entries=false)
void compute_constraints(ConstraintMatrix &constraints, ConstraintMatrix &vector_constraints)
void declare_entry(const std::string &entry, const std::string &default_value, const Patterns::PatternBase &pattern=Patterns::Anything(), const std::string &documentation=std::string())
We collect in this namespace all utilities which operate on OpenCascade entities which don't need cla...
std::pair< double, unsigned int > mypair
Handle(Geom_Curve) NumericalTowingTank
void compute_DXDt_and_DphiDt(double time, const Vector< double > &phi, const Vector< double > &dphi_dn, const Vector< double > &nodes_velocities)
SparseMatrix< number > & copy_from(const SparseMatrix< somenumber > &source)
void restore_solution(Vector< double > &y, Vector< double > &yp, const std::string fname)
bool comparator(const mypair &l, const mypair &r)
void reinit(const TriaIterator< DoFCellAccessor< DoFHandlerType< dim, spacedim >, level_dof_access > > &cell)
static void estimate(const Mapping< dim, spacedim > &mapping, const DoFHandlerType &dof, const Quadrature< dim-1 > &quadrature, const typename FunctionMap< spacedim >::type &neumann_bc, const InputVector &solution, Vector< float > &error, const ComponentMask &component_mask=ComponentMask(), const Function< spacedim > *coefficients=0, const unsigned int n_threads=numbers::invalid_unsigned_int, const types::subdomain_id subdomain_id=numbers::invalid_subdomain_id, const types::material_id material_id=numbers::invalid_material_id, const Strategy strategy=cell_diameter_over_24)
double JxW(const unsigned int quadrature_point) const
virtual void create_triangulation_compatibility(const std::vector< Point< spacedim > > &vertices, const std::vector< CellData< dim > > &cells, const SubCellData &subcelldata)
void initial_conditions(Vector< double > &dst)
void parse_parameters(ParameterHandler &prm)
long int get_integer(const std::string &entry_string) const
void vmult(Vector< double > &dst, const Vector< double > &src) const
static::ExceptionBase & ExcInternalError()
std::map< unsigned int, unsigned int > indices_map