26 #include "../include/boat_model.h"
27 #include <gp_Trsf.hxx>
28 #include <BRepBuilderAPI_Transform.hxx>
29 #include <BRepBuilderAPI_GTransform.hxx>
31 #include <TopTools.hxx>
32 #include <Standard_Stream.hxx>
33 #include <TopoDS_Shape.hxx>
34 #include <TopoDS_Edge.hxx>
35 #include <GC_MakeSegment.hxx>
37 #include <IGESControl_Reader.hxx>
38 #include <IGESControl_Controller.hxx>
39 #include <IGESControl_Writer.hxx>
41 #include <TopoDS_Shape.hxx>
42 #include <TopoDS_Shell.hxx>
43 #include <TopoDS_Face.hxx>
44 #include <BRepTools.hxx>
45 #include <XSControl_Reader.hxx>
46 #include <TopTools_SequenceOfShape.hxx>
47 #include <Handle_Standard_Transient.hxx>
48 #include <TColStd_SequenceOfTransient.hxx>
49 #include <TColStd_HSequenceOfTransient.hxx>
50 #include <TopExp_Explorer.hxx>
53 #include <GeomAPI_ProjectPointOnSurf.hxx>
54 #include <GeomAPI_ProjectPointOnCurve.hxx>
55 #include <Standard_Real.hxx>
56 #include <Standard_Integer.hxx>
57 #include <BRep_Tool.hxx>
58 #include <Geom_Surface.hxx>
59 #include <Geom_Plane.hxx>
60 #include <Prs3d_ShapeTool.hxx>
61 #include <Bnd_Box.hxx>
64 #include <BRepBuilderAPI_MakeFace.hxx>
65 #include <GeomAPI_IntSS.hxx>
66 #include <TopoDS_Wire.hxx>
67 #include <BRepBuilderAPI_MakePolygon.hxx>
68 #include <Geom_Curve.hxx>
69 #include <Geom_BoundedCurve.hxx>
70 #include <Geom_TrimmedCurve.hxx>
71 #include <TColGeom_Array1OfCurve.hxx>
72 #include <GeomAPI_IntCS.hxx>
73 #include <BRepBuilderAPI_MakeEdge.hxx>
74 #include <GeomLib_Tool.hxx>
75 #include <GCPnts_AbscissaPoint.hxx>
76 #include <GeomConvert_CompCurveToBSplineCurve.hxx>
77 #include <GeomLProp_SLProps.hxx>
78 #include <BRepTools_ReShape.hxx>
79 #include <BRepBuilderAPI_MakePolygon.hxx>
80 #include <BRepBuilderAPI_NurbsConvert.hxx>
81 #include <BRepLib_FindSurface.hxx>
82 #include <TColStd_Array1OfReal.hxx>
83 #include <TColStd_Array1OfInteger.hxx>
84 #include <GeomConvert.hxx>
85 #include <Geom_BSplineSurface.hxx>
86 #include <BRepAdaptor_Curve.hxx>
87 #include <gp_Quaternion.hxx>
114 boat_surface_right(NULL),
115 boat_surface_left(NULL),
116 boat_water_line_right(NULL),
117 boat_water_line_left(NULL),
119 boat_keel_norm(NULL),
120 boat_transom_left(NULL),
121 boat_transom_right(NULL),
122 wake_line_left(NULL),
123 wake_line_right(NULL),
124 water_line_right(NULL),
125 water_line_left(NULL)
155 const TopoDS_Face &face)
157 Handle(BRepTools_ReShape) rebuild =
new BRepTools_ReShape();
158 rebuild->ModeConsiderOrientation() = Standard_True;
159 TopoDS_Shape newface = face.Complemented();
160 rebuild->Replace(face, newface, Standard_True );
161 TopoDS_Shape newshape = rebuild->Apply(shape, TopAbs_FACE );
169 double assigned_sink,
170 double assigned_trim,
171 double back_keel_length,
172 double front_keel_length,
173 double middle_keel_length,
174 unsigned int number_of_transom_edges)
201 TopExp_Explorer faceExplorer(
sh, TopAbs_FACE);
204 std::vector<bool> to_be_changed;
205 unsigned int face_count = 0;
206 while (faceExplorer.More())
208 face = TopoDS::Face(faceExplorer.Current());
209 Standard_Real umin, umax, vmin, vmax;
210 BRepTools::UVBounds(face, umin, umax, vmin, vmax);
211 Handle(Geom_Surface) surf=BRep_Tool::Surface(face);
212 GeomLProp_SLProps props(surf, (umin+umax)/2.0, (vmin+vmax)/2.0, 1, 0.01);
213 gp_Dir
norm=props.Normal();
216 to_be_changed.push_back(
true);
219 else if (norm.Y() == 0)
223 to_be_changed.push_back(
true);
227 to_be_changed.push_back(
false);
231 to_be_changed.push_back(
false);
236 TopoDS_Shape newShape;
237 for (
unsigned int i=0; i<face_count; ++i)
240 if (to_be_changed.at(i))
243 faceExplorer.Init(
sh,TopAbs_FACE);
244 for (
unsigned int j=0; j<i; ++j)
246 face = TopoDS::Face(faceExplorer.Current());
256 gp_Ax2 yAx(gp_Pnt(0.0,0.0,0.0), gp_Dir(0.0,1.0,0.0), gp_Dir(1.0,0.0,0.0));
259 y_mirroring.SetMirror(yAx);
261 BRepBuilderAPI_Transform boat_surface_transformation(
sh, y_mirroring);
263 refl_sh = boat_surface_transformation.Shape();
268 if (displacement > 0)
273 double weight = displacement*9.81;
278 TopoDS_Shape sh_copy(
sh);
279 TopoDS_Shape refl_sh_copy(
refl_sh);
280 gp_Vec vert_displ(0.0,0.0,-sink);
281 gp_Trsf vert_translation;
282 vert_translation.SetTranslation(vert_displ);
283 BRepBuilderAPI_Transform right_vert_transl(sh_copy, vert_translation);
284 sh = right_vert_transl.Shape();
285 BRepBuilderAPI_Transform left_vert_transl(refl_sh_copy, vert_translation);
286 refl_sh = left_vert_transl.Shape();
306 gp_Dir rot_dir(0.0,1.0,0.0);
307 gp_Ax1 rot_axis(rot_center, rot_dir);
311 rotation.SetRotation(rot_axis,-assigned_trim);
314 gp_Vec vrt_displ(0.0,0.0,-assigned_sink);
315 translation.SetTranslation(vrt_displ);
319 gp_Trsf Tcomp = translation*rotation;
321 BRepBuilderAPI_Transform right_transf(
sh, Tcomp);
322 sh = right_transf.Shape();
323 BRepBuilderAPI_Transform left_transf(
refl_sh, Tcomp);
328 cout<<
"The hull has been placed in the requested initial position"<<endl;
381 TopoDS_Edge edge1 = TopoDS::Edge(edge1Explorer.Current());
382 right_undisturbed_waterline_curve = BRep_Tool::Curve(edge1,L,First,Last);
386 Standard_Real First2;
389 TopoDS_Edge edge2 = TopoDS::Edge(edge2Explorer.Current());
390 left_undisturbed_waterline_curve = BRep_Tool::Curve(edge2,L2,First2,Last2);
396 left_undisturbed_waterline_curve->D1(First,P1,V1);
397 left_undisturbed_waterline_curve->D1(Last,P2,V2);
400 slope = fabs(V1.Y()/V1.X());
402 slope = fabs(V2.Y()/V2.X());
405 std::vector<gp_Pnt> intPoints(2);
407 Handle(Geom_Plane) xyPlane =
new Geom_Plane(0.,0.,1.,0.);
412 TopExp_Explorer edgeExplorer(
keel_edge, TopAbs_EDGE);
413 TopoDS_Edge
edge = TopoDS::Edge(edgeExplorer.Current());
417 BRepAdaptor_Curve gg_curve(edge);
418 equiv_keel_bspline = BRep_Tool::Curve(edge,L,First,Last);
419 gp_Trsf L_transformation = L.Transformation();
420 TopLoc_Location L_inv = L.Inverted();
421 gp_Trsf L_inv_transformation = L_inv.Transformation();
423 xyPlane->Transform(L_inv.Transformation());
426 TopoDS_Edge edge3 = TopoDS::Edge(edge3Explorer.Current());
427 left_transom_bspline = BRep_Tool::Curve(edge3,L,First,Last);
430 if (left_transom_bspline->Value(First).Z() > left_transom_bspline->Value(Last).Z())
431 pntCtrTrsm = left_transom_bspline->Value(Last);
433 pntCtrTrsm = left_transom_bspline->Value(First);
434 pntCtrTrsm.Transform(L_transformation);
441 TopoDS_Edge edge4 = TopoDS::Edge(edge4Explorer.Current());
442 right_transom_bspline = BRep_Tool::Curve(edge4,L,First,Last);
444 GeomAPI_IntCS Intersector(equiv_keel_bspline, xyPlane);
445 int npoints = Intersector.NbPoints();
447 gp_Pnt gpFront(0.0,0.0,0.0);
448 gp_Pnt gpBack(0.0,0.0,0.0);
449 gp_Pnt transomLeft(0.0,0.0,0.0);
450 gp_Pnt transomRight(0.0,0.0,0.0);
452 GeomAPI_IntCS IntersectorLeft(left_transom_bspline, xyPlane);
453 GeomAPI_IntCS IntersectorRight(right_transom_bspline, xyPlane);
456 cout<<
"Number of keel intersections with xy plane: "<<npoints<<endl;
461 gp_Pnt Point1 = Intersector.Point(1);
462 gp_Pnt Point2 = Intersector.Point(2);
463 Point1.Transform(L_transformation);
464 Point2.Transform(L_transformation);
465 if (Point1.X() < Point2.X())
477 GC_MakeSegment first_wake(
Pnt(far), gpBack);
478 left_wake_bspline = first_wake.Value();
479 right_wake_bspline = first_wake.Value();
481 else if (npoints == 1)
487 if ( (IntersectorLeft.NbPoints() != 1) || (IntersectorRight.NbPoints() != 1))
488 AssertThrow((IntersectorLeft.NbPoints() == 1) && (IntersectorRight.NbPoints() == 1),
489 ExcMessage(
"Transom edges don't possess a single intersection with horizontal plane!"));
490 cout<<
"Transom Point Left: "<<
Pnt(IntersectorLeft.Point(1))<<endl;
491 cout<<
"Transom Point Right: "<<
Pnt(IntersectorRight.Point(1))<<endl;
493 transomLeft = IntersectorLeft.
Point(1);
494 transomLeft.Transform(L_transformation);
495 transomRight = IntersectorRight.Point(1);
496 transomRight.Transform(L_transformation);
497 gpFront = Intersector.Point(1);
498 gpFront.Transform(L_transformation);
500 boatWetLength = fabs((transomLeft.X()+transomRight.X())/2.0-gpFront.X());
503 junction(0) +=
Pnt(transomLeft).distance(
Pnt(transomRight))/slope;
504 cout<<junction<<endl;
506 GC_MakeSegment first_wake(
Pnt(far),
Pnt(junction));
507 GC_MakeSegment second_wake_left(
Pnt(junction), transomLeft);
508 GC_MakeSegment second_wake_right(
Pnt(junction), transomRight);
509 Handle(Geom_Curve) first_wake_curve = first_wake.Value();
510 Handle(Geom_Curve) second_wake_left_curve = second_wake_left.Value();
511 Handle(Geom_Curve) second_wake_right_curve = second_wake_right.Value();
512 Handle(Geom_BoundedCurve) first_wake_bcurve =
Handle(Geom_BoundedCurve)::DownCast(first_wake_curve);
513 Handle(Geom_BoundedCurve) second_wake_left_bcurve =
Handle(Geom_BoundedCurve)::DownCast(second_wake_left_curve);
514 Handle(Geom_BoundedCurve) second_wake_right_bcurve =
Handle(Geom_BoundedCurve)::DownCast(second_wake_right_curve);
516 GeomConvert_CompCurveToBSplineCurve convert_left_wake_bspline(first_wake_bcurve,Convert_TgtThetaOver2);
517 GeomConvert_CompCurveToBSplineCurve convert_right_wake_bspline(first_wake_bcurve,Convert_TgtThetaOver2);
518 check = convert_left_wake_bspline.Add(second_wake_left_bcurve,1e-7,0,1,0);
520 cout<<
"Failed joining left wake line"<<endl;
521 left_wake_bspline = convert_left_wake_bspline.BSplineCurve();
522 check = convert_right_wake_bspline.Add(second_wake_right_bcurve,1e-7,0,1,0);
524 cout<<
"Failed joining left wake line"<<endl;
525 right_wake_bspline = convert_right_wake_bspline.BSplineCurve();
530 ExcMessage(
"Keel and has no intersection or too many intersections with horizontal plane!"));
536 cout<<
"gpFront: "<<
Pnt(gpFront)<<endl;
537 cout<<
"gpBack:"<<
Pnt(gpBack)<<endl;
549 BRepBuilderAPI_MakePolygon polygon;
550 polygon.Add(gp_Pnt(-xdim, -ydim, 0));
551 polygon.Add(gp_Pnt(xdim, -ydim, 0));
552 polygon.Add(gp_Pnt(xdim, ydim, 0));
553 polygon.Add(gp_Pnt(-xdim, ydim, 0));
556 TopoDS_Wire wire = polygon.Wire();
557 BRepBuilderAPI_MakeFace faceBuilder(wire);
578 1.0-front_keel_length);
599 double z_zero = sink;
600 Point<3> hydrostatic_force(0.0,0.0,0.0);
601 double wet_surface = 0.0;
605 TopExp_Explorer faceExplorer(
sh, TopAbs_FACE);
608 std::vector<bool> to_be_changed;
609 unsigned int face_count = 0;
610 while (faceExplorer.More())
612 face = TopoDS::Face(faceExplorer.Current());
613 Standard_Real umin, umax, vmin, vmax;
614 BRepTools::UVBounds(face, umin, umax, vmin, vmax);
615 Handle(Geom_Surface) surf=BRep_Tool::Surface(face);
619 std::vector<Point<2> > ref_vertices;
620 std::vector<CellData<2> > ref_cells;
623 ref_vertices.resize(4);
624 ref_vertices[0](0)=umin;
625 ref_vertices[0](1)=vmin;
626 ref_vertices[1](0)=umax;
627 ref_vertices[1](1)=vmin;
628 ref_vertices[2](0)=umin;
629 ref_vertices[2](1)=vmax;
630 ref_vertices[3](0)=umax;
631 ref_vertices[3](1)=vmax;
635 ref_cells[0].vertices[0]=0;
636 ref_cells[0].vertices[1]=1;
637 ref_cells[0].vertices[2]=3;
638 ref_cells[0].vertices[3]=2;
639 ref_cells[0].material_id = 1;
655 update_quadrature_points |
663 for (
unsigned int i=0; i<n_q_points; ++i)
666 gp_Vec Du, Dv, normal;
667 surf->D1(quad_nodes[i](0),quad_nodes[i](1), q, Du, Dv);
668 double jacobian = Du.CrossMagnitude(Dv);
669 normal = Du^ Dv/jacobian;
670 Point<3> Normal(normal.X(),normal.Y(),normal.Z());
672 if (face.Orientation()==TopAbs_REVERSED)
676 hydrostatic_force += (rho*g*fmax(z_zero-q.Z(),0.0))*Normal*jacobian*ref_fe_v.
JxW(i);
678 wet_surface += jacobian*ref_fe_v.
JxW(i);
745 TopExp_Explorer reflFaceExplorer(
refl_sh, TopAbs_FACE);
748 while (reflFaceExplorer.More())
751 face = TopoDS::Face(reflFaceExplorer.Current());
752 Standard_Real umin, umax, vmin, vmax;
753 BRepTools::UVBounds(face, umin, umax, vmin, vmax);
754 Handle(Geom_Surface) surf=BRep_Tool::Surface(face);
758 std::vector<Point<2> > ref_vertices;
759 std::vector<CellData<2> > ref_cells;
762 ref_vertices.resize(4);
763 ref_vertices[0](0)=umin;
764 ref_vertices[0](1)=vmin;
765 ref_vertices[1](0)=umax;
766 ref_vertices[1](1)=vmin;
767 ref_vertices[2](0)=umin;
768 ref_vertices[2](1)=vmax;
769 ref_vertices[3](0)=umax;
770 ref_vertices[3](1)=vmax;
774 ref_cells[0].vertices[0]=0;
775 ref_cells[0].vertices[1]=1;
776 ref_cells[0].vertices[2]=3;
777 ref_cells[0].vertices[3]=2;
778 ref_cells[0].material_id = 1;
794 update_quadrature_points |
802 for (
unsigned int i=0; i<n_q_points; ++i)
805 gp_Vec Du, Dv, normal;
806 surf->D1(quad_nodes[i](0),quad_nodes[i](1), q, Du, Dv);
807 double jacobian = Du.CrossMagnitude(Dv);
808 normal = (Du^Dv)/jacobian;
809 Point<3> Normal(normal.X(),normal.Y(),normal.Z());
811 if (face.Orientation()==TopAbs_REVERSED)
815 hydrostatic_force += (rho*g*fmax(z_zero-q.Z(),0.0))*Normal*jacobian*ref_fe_v.
JxW(i);
817 wet_surface += jacobian*ref_fe_v.
JxW(i);
825 reflFaceExplorer.Next();
831 cout<<
"Current hydrostatic force: "<<hydrostatic_force<<
" Current wet surface: "<<wet_surface<<endl;
833 return hydrostatic_force;
837 const double &quaternion_scalar,
842 gp_Quaternion rot_quaternion(quaternion_vect(0), quaternion_vect(1), quaternion_vect(2), quaternion_scalar);
844 rotation.SetRotation(rot_quaternion);
847 gp_Trsf prev_Transf = prev_L.Transformation();
852 gp_Trsf ref_hull_bar_translation;
853 ref_hull_bar_translation.SetTranslation(ref_hull_bar_displ);
857 gp_Vec curr_displ(translation_vect(0),translation_vect(1),translation_vect(2));
858 translation.SetTranslation(curr_displ);
861 gp_Trsf this_transf = translation*ref_hull_bar_translation*rotation*ref_hull_bar_translation.Inverted();
864 gp_Trsf new_Transf = this_transf*prev_Transf;
865 TopLoc_Location new_L(new_Transf);
878 cout<<
"Current Yaw Angle: "<<
yaw_angle<<endl;
880 cout<<
"Current Roll Angle: "<<-
roll_angle<<endl;
883 ref_hull_bar_pos.Transform(this_transf);
891 Handle(Geom_Plane) xyPlane =
new Geom_Plane(0.,0.,1.,0.);
898 if (left_transom_bspline->Value(left_transom_bspline->FirstParameter()).Z() >
899 left_transom_bspline->Value(left_transom_bspline->LastParameter()).Z())
900 pntCtrTrsm = left_transom_bspline->Value(left_transom_bspline->LastParameter());
902 pntCtrTrsm = left_transom_bspline->Value(left_transom_bspline->FirstParameter());
906 gp_Pnt transomLeft(0.0,0.0,0.0);
907 gp_Pnt transomRight(0.0,0.0,0.0);
909 GeomAPI_IntCS IntersectorLeft(left_transom_bspline, xyPlane);
910 GeomAPI_IntCS IntersectorRight(right_transom_bspline, xyPlane);
911 if ( (IntersectorLeft.NbPoints() != 1) || (IntersectorRight.NbPoints() != 1))
912 AssertThrow((IntersectorLeft.NbPoints() == 1) && (IntersectorRight.NbPoints() == 1),
913 ExcMessage(
"Transom edges don't possess a single intersection with horizontal plane: is transom not immersed any more?"));
914 transomLeft = IntersectorLeft.Point(1);
915 transomRight = IntersectorRight.Point(1);
921 IntersectorLeft.Parameters(1, u, v, param);
922 gp_Vec current_left_transom_tangent_vec = left_transom_bspline->DN(param,1);
923 gp_Dir current_left_transom_tangent_dir(current_left_transom_tangent_vec);
924 current_left_transom_tangent_dir.Transform(
current_loc);
926 current_left_transom_tangent_dir.Y(),
927 current_left_transom_tangent_dir.Z());
929 IntersectorRight.Parameters(1, u, v, param);
930 gp_Vec current_right_transom_tangent_vec = right_transom_bspline->DN(param,1);
931 gp_Dir current_right_transom_tangent_dir(current_right_transom_tangent_vec);
932 current_right_transom_tangent_dir.Transform(
current_loc);
934 current_right_transom_tangent_dir.X(),
935 current_right_transom_tangent_dir.Z());
963 double z_zero = sink;
964 Point<3> hydrostatic_moment(0.0,0.0,0.0);
965 Point<3> hydrostatic_force(0.0,0.0,0.0);
966 double wet_surface = 0.0;
970 TopExp_Explorer faceExplorer(
sh, TopAbs_FACE);
973 std::vector<bool> to_be_changed;
974 unsigned int face_count = 0;
975 while (faceExplorer.More())
977 face = TopoDS::Face(faceExplorer.Current());
978 Standard_Real umin, umax, vmin, vmax;
979 BRepTools::UVBounds(face, umin, umax, vmin, vmax);
980 Handle(Geom_Surface) surf=BRep_Tool::Surface(face);
984 std::vector<Point<2> > ref_vertices;
985 std::vector<CellData<2> > ref_cells;
988 ref_vertices.resize(4);
989 ref_vertices[0](0)=umin;
990 ref_vertices[0](1)=vmin;
991 ref_vertices[1](0)=umax;
992 ref_vertices[1](1)=vmin;
993 ref_vertices[2](0)=umin;
994 ref_vertices[2](1)=vmax;
995 ref_vertices[3](0)=umax;
996 ref_vertices[3](1)=vmax;
1000 ref_cells[0].vertices[0]=0;
1001 ref_cells[0].vertices[1]=1;
1002 ref_cells[0].vertices[2]=3;
1003 ref_cells[0].vertices[3]=2;
1004 ref_cells[0].material_id = 1;
1020 update_quadrature_points |
1028 for (
unsigned int i=0; i<n_q_points; ++i)
1031 gp_Vec Du, Dv, normal;
1032 surf->D1(quad_nodes[i](0),quad_nodes[i](1), q, Du, Dv);
1033 double jacobian = Du.CrossMagnitude(Dv);
1034 normal = Du^ Dv/jacobian;
1035 Point<3> Normal(normal.X(),normal.Y(),normal.Z());
1037 if (face.Orientation()==TopAbs_REVERSED)
1041 Point<3> Q(q.X()-moment_center(0),q.Y()-moment_center(1),q.Z()-moment_center(2));
1042 Point<3> Kross(Q(1)*Normal(2)-Q(2)*Normal(1),Q(2)*Normal(0)-Q(0)*Normal(2),Q(0)*Normal(1)-Q(1)*Normal(0));
1043 hydrostatic_moment += (rho*g*fmax(z_zero-q.Z(),0.0))*Kross*jacobian*ref_fe_v.
JxW(i);
1044 hydrostatic_force += (rho*g*fmax(z_zero-q.Z(),0.0))*Normal*jacobian*ref_fe_v.
JxW(i);
1053 faceExplorer.Next();
1059 TopExp_Explorer reflFaceExplorer(
refl_sh, TopAbs_FACE);
1062 while (reflFaceExplorer.More())
1065 face = TopoDS::Face(reflFaceExplorer.Current());
1066 Standard_Real umin, umax, vmin, vmax;
1067 BRepTools::UVBounds(face, umin, umax, vmin, vmax);
1068 Handle(Geom_Surface) surf=BRep_Tool::Surface(face);
1072 std::vector<Point<2> > ref_vertices;
1073 std::vector<CellData<2> > ref_cells;
1076 ref_vertices.resize(4);
1077 ref_vertices[0](0)=umin;
1078 ref_vertices[0](1)=vmin;
1079 ref_vertices[1](0)=umax;
1080 ref_vertices[1](1)=vmin;
1081 ref_vertices[2](0)=umin;
1082 ref_vertices[2](1)=vmax;
1083 ref_vertices[3](0)=umax;
1084 ref_vertices[3](1)=vmax;
1086 ref_cells.resize(1);
1088 ref_cells[0].vertices[0]=0;
1089 ref_cells[0].vertices[1]=1;
1090 ref_cells[0].vertices[2]=3;
1091 ref_cells[0].vertices[3]=2;
1092 ref_cells[0].material_id = 1;
1108 update_quadrature_points |
1116 for (
unsigned int i=0; i<n_q_points; ++i)
1119 gp_Vec Du, Dv, normal;
1120 surf->D1(quad_nodes[i](0),quad_nodes[i](1), q, Du, Dv);
1121 double jacobian = Du.CrossMagnitude(Dv);
1122 normal = (Du^Dv)/jacobian;
1123 Point<3> Normal(normal.X(),normal.Y(),normal.Z());
1126 if (face.Orientation()==TopAbs_REVERSED)
1130 Point<3> Q(q.X()-moment_center(0),q.Y()-moment_center(1),q.Z()-moment_center(2));
1131 Point<3> Kross(Q(1)*Normal(2)-Q(2)*Normal(1),Q(2)*Normal(0)-Q(0)*Normal(2),Q(0)*Normal(1)-Q(1)*Normal(0));
1132 hydrostatic_moment += (rho*g*fmax(z_zero-q.Z(),0.0))*Kross*jacobian*ref_fe_v.
JxW(i);
1133 hydrostatic_force += (rho*g*fmax(z_zero-q.Z(),0.0))*Normal*jacobian*ref_fe_v.
JxW(i);
1142 reflFaceExplorer.Next();
1148 cout<<
"Current hydrostatic moment: "<<hydrostatic_moment<<endl;
1149 cout<<
"(Force is): "<<hydrostatic_force<<endl;
1150 return hydrostatic_moment;
1156 double delta_sink = 0.001;
1162 double z_n_minus_1 = delta_sink;
1163 double z_n_minus_2 = 0.0;
1165 while (fabs(hydrostatic_force(2)-weight)/weight > 1e-7)
1167 double slope = (hydrostatic_force_n_minus_1(2)-hydrostatic_force_n_minus_2(2))/(z_n_minus_1-z_n_minus_2);
1168 z = z_n_minus_1 - (hydrostatic_force_n_minus_1(2)-weight)/slope;
1169 z_n_minus_2 = z_n_minus_1;
1172 hydrostatic_force_n_minus_2 = hydrostatic_force_n_minus_1;
1173 hydrostatic_force_n_minus_1 = hydrostatic_force;
1181 cout<<
"z: "<<z<<
" hydrostatic force (out): "<<hydrostatic_force<<
" (weight: "<<weight<<
")"<<endl;
Point< 3 > hydrostatic_hull_baricenter
Point< 3 > current_hull_baricenter
TopLoc_Location reference_loc
active_cell_iterator begin_active(const unsigned int level=0) const
Handle(Geom_Curve) equiv_keel_bspline
OpenCascade::ArclengthProjection * water_line_right
Point< 3 > CurrentPointCenterTransom
OpenCascade::NormalProjection< 2 > * boat_surface_left
Point< 3 > arclength_projection(const Point< 3 > &p0, const Point< 3 > &p1, const double distance=.5) const
OpenCascade::NormalProjection< 1 > * boat_keel_norm
#define AssertThrow(cond, exc)
OpenCascade::NormalProjection< 2 > * boat_surface_right
OpenCascade::ArclengthProjection * wake_line_right
Point< 3 > reference_hull_baricenter
Point< 3 > CurrentPointLeftTransom
Point< 3 > PointLeftTransom
static::ExceptionBase & ExcMessage(std::string arg1)
const std::vector< Point< spacedim > > & get_quadrature_points() const
Point< 3 > compute_hydrostatic_moment(const double &sink, const Point< 3 > moment_center)
static void reorder_cells(std::vector< CellData< dim > > &original_cells, const bool use_new_style_ordering=false)
TopoDS_Shape right_undist_water_line
OpenCascade::ArclengthProjection * boat_keel
OpenCascade::ArclengthProjection * boat_transom_right
Point< 3 > CurrentPointRightTransom
TopoDS_Shape undisturbed_water_surface_face
void start_iges_model(std::string igesFileName, double scale, double displacement, double assigned_sink, double assigned_trim, double back_keel_length=0.1, double front_keel_length=0.05, double middle_keel_length=.47, unsigned int number_of_transom_edges=1)
TopoDS_Shape left_transom_edge
OpenCascade::AxisProjection * boat_water_line_right
const unsigned int n_quadrature_points
gp_Trsf set_current_position(const Point< 3 > &translation_vect, const double &quaternion_scalar, const Point< 3 > &quaternion_vect)
double norm(const FEValuesBase< dim > &fe, const VectorSlice< const std::vector< std::vector< Tensor< 1, dim > > > > &Du)
OpenCascade::ArclengthProjection * boat_transom_left
dealii::Point< 3 > Pnt(const gp_Pnt &p)
Convert OpenCascade point into.
OpenCascade::ArclengthProjection * water_line_left
TopoDS_Shape right_transom_edge
Point< 3 > current_right_transom_tangent
virtual void distribute_dofs(const FiniteElement< dim, spacedim > &fe)
TopoDS_Shape extract_transom_edges(const TopoDS_Shape &in_shape, const unsigned int num_transom_edges, const double tolerance)
We collect in this namespace all utilities which operate on OpenCascade entities which don't need cla...
TopoDS_Shape read_IGES(string filename, double scale_factor)
Read IGES files and translate.
void compute_hydrostatic_sink(double &sink, const double &weight)
TopoDS_Shape left_undist_water_line
OpenCascade::AxisProjection * boat_water_line_left
Point< 3 > compute_hydrostatic_force(const double &sink)
TopoDS_Shape ReverseFaceOrientation(const TopoDS_Shape &shape, const TopoDS_Face &face)
void intersect_plane(const TopoDS_Shape &in_shape, TopoDS_Shape &out_shape, const double c_x, const double c_y, const double c_z, const double c, const double tolerance)
Perform the intersection of the.
TopLoc_Location current_loc
void reinit(const TriaIterator< DoFCellAccessor< DoFHandlerType< dim, spacedim >, level_dof_access > > &cell)
void L2(Vector< number > &result, const FEValuesBase< dim > &fe, const std::vector< double > &input, const double factor=1.)
Point< 3 > PointRightTransom
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)
TopoDS_Shape extract_xz_edges(const TopoDS_Shape &in_shape, const double tolerance, const unsigned int max_num_edges)
Point< 3 > PointCenterTransom
OpenCascade::AxisProjection * undist_water_surf
Point< 3 > current_left_transom_tangent
OpenCascade::ArclengthProjection * wake_line_left