Skip to content

Commit afcc5d3

Browse files
committed
another step towards the moving hull model. now boat_model class has a reference (hydrostatic) TopLoc_Location and a current location. A method has been added to change the current location which accounts for the boat rigid motions. All the projectors and smoothers will now act on the current hull configuration.
git-svn-id: svn://svn.sissa.it/openship@557 958231e9-8e66-0410-a4a0-f664109d2741
1 parent d437d1f commit afcc5d3

7 files changed

Lines changed: 110 additions & 64 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ FIND_PACKAGE(OpenCASCADE MODULE REQUIRED)
1818

1919

2020
SET(TARGET "waveBem")
21-
set(CMAKE_BUILD_TYPE "Release")
21+
set(CMAKE_BUILD_TYPE "Debug")
2222

2323
file(GLOB TARGET_SRC source/*cc)
2424
include_directories(

include/boat_model.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,12 @@ class BoatModel{
8585
TopoDS_Shape left_undist_water_line;
8686
// this is the undisturbed left water surface
8787
TopoDS_Shape undisturbed_water_surface_face;
88-
// location of the translated curves (for roto-translated hull)
88+
// location of the translated shapes (for hull roto-translated
89+
// in HYDROSTATIC position)
8990
TopLoc_Location reference_loc;
91+
// location of the translated curves (for hull roto-translated
92+
//in CURRENT position)
93+
TopLoc_Location current_loc;
9094
// surface normal projector on boat surface right side
9195
OpenCascade::NormalProjection<2> *boat_surface_right;
9296
// surface normal projector on boat surface left side

include/numerical_towing_tank.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ std::vector<Handle(Geom_Curve)> curves;
255255
std::vector<bool> on_curve_option;
256256
// locations are needed when reference configuration
257257
// is roto-translated
258-
std::vector<TopLoc_Location> ref_locations;
258+
std::vector< TopLoc_Location *> smoothers_locations;
259259
// nodes flags on the scalar dof_handler
260260
std::vector<GeometryFlags> flags;
261261
// nodes flags on the vector dof_handler

source/boat_model.cc

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ void BoatModel::start_iges_model(std::string igesFileName,
309309
sh = right_transf.Shape();
310310
BRepBuilderAPI_Transform left_transf(refl_sh, Tcomp);
311311
refl_sh = left_transf.Shape();
312-
312+
313313

314314

315315
cout<<"The hull has been placed in the correct position"<<endl;
@@ -398,6 +398,7 @@ Standard_Boolean OK = ICW.Write ("transom.igs");
398398
TopoDS_Edge edge = TopoDS::Edge(edgeExplorer.Current());
399399
edge.Location(keel_edge.Location());
400400
this->reference_loc = keel_edge.Location();
401+
this->current_loc = keel_edge.Location();
401402
BRepAdaptor_Curve gg_curve(edge);
402403
equiv_keel_bspline = BRep_Tool::Curve(edge,L,First,Last);
403404
gp_Trsf L_transformation = L.Transformation();
@@ -406,11 +407,6 @@ Standard_Boolean OK = ICW.Write ("transom.igs");
406407

407408
xyPlane->Transform(L_inv.Transformation());
408409

409-
cout<<First<<" "<<Last<<endl;
410-
cout<<"TTEESSTT1a: "<<Pnt(equiv_keel_bspline->Value(Last))<<endl;
411-
cout<<"TTEESSTT1b: "<<Pnt(gg_curve.Value(gg_curve.LastParameter()))<<endl;
412-
cout<<"TTEESSTT2a: "<<Pnt(equiv_keel_bspline->Value(First))<<endl;
413-
cout<<"TTEESSTT2b: "<<Pnt(gg_curve.Value(gg_curve.FirstParameter()))<<endl;
414410
TopExp_Explorer edge3Explorer(left_transom_edge, TopAbs_EDGE);
415411
TopoDS_Edge edge3 = TopoDS::Edge(edge3Explorer.Current());
416412
left_transom_bspline = BRep_Tool::Curve(edge3,L,First,Last);
@@ -811,6 +807,31 @@ cout<<"UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU"<<endl;
811807
void BoatModel::set_current_position(const double &sink)
812808
{
813809

810+
//here we prepare the rotation of the boat of the requested trim angle
811+
//gp_Pnt rot_center(0.0,0.0,0.0);
812+
//gp_Dir rot_dir(0.0,1.0,0.0);
813+
//gp_Ax1 rot_axis(rot_center, rot_dir);
814+
//gp_Trsf rotation;
815+
//rotation.SetRotation(rot_axis,assigned_trim);
816+
//we first get the full transformation currently applied to the shape
817+
TopLoc_Location prev_L = sh.Location();
818+
gp_Trsf prev_Transf = prev_L.Transformation();
819+
820+
//here we prepare the translation of the boat of the requested sink
821+
gp_Trsf translation;
822+
gp_Vec vrt_displ(0.0,0.0,sink);
823+
translation.SetTranslation(vrt_displ);
824+
//the rotation and translation are combined in a single transformation
825+
gp_Trsf new_Transf = translation*prev_Transf;
826+
TopLoc_Location new_L(new_Transf);
827+
828+
//the transformation is applied to the two sides of the boat
829+
sh.Location(new_L);
830+
refl_sh.Location(new_L);
831+
right_transom_edge.Location(new_L);
832+
left_transom_edge.Location(new_L);
833+
keel_edge.Location(new_L);
834+
current_loc = new_L;
814835

815836

816837
}

source/free_surface.cc

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,8 @@ void FreeSurface<dim>::reinit() {
279279
template <int dim>
280280
void FreeSurface<dim>::initial_conditions(Vector<double> &dst) {
281281

282+
comp_dom.boat_model.set_current_position(0.03);
283+
282284
// da trattare il caso di dumped solution (continuazione conto salvato)
283285
initial_time = 0.0;
284286
initial_wave_shape.set_time(initial_time);
@@ -295,8 +297,7 @@ void FreeSurface<dim>::initial_conditions(Vector<double> &dst) {
295297
Vinf(i) = instantWindValue(i);
296298
std::cout<<std::endl<<"Initial conditions: simulation time= "<<initial_time<<" Vinf= ";
297299
instantWindValue.print(std::cout,4,false,true);
298-
std::cout<<std::endl;
299-
cout<<"Check: "<<endl;
300+
300301
std::vector<Point<dim> > support_points(comp_dom.dh.n_dofs());
301302
DoFTools::map_dofs_to_support_points<dim-1, dim>( *comp_dom.mapping, comp_dom.dh, support_points);
302303
std::vector<Point<dim> > vector_support_points(comp_dom.vector_dh.n_dofs());
@@ -322,7 +323,7 @@ void FreeSurface<dim>::initial_conditions(Vector<double> &dst) {
322323
for(unsigned int i=0; i<comp_dom.vector_dh.n_dofs(); ++i)
323324
{
324325
comp_dom.map_points(i) -= geom_res(i);
325-
//std::cout<<i<<" "<<dst(i)<<std::endl;
326+
//std::cout<<i<<" "<<geom_res(i)<<" | "<<comp_dom.map_points(i)<<std::endl;
326327
}
327328

328329

@@ -2673,7 +2674,7 @@ setup_jacobian_prec(t,y,yp,0.0);
26732674
//this is the horizontal plane
26742675
Handle(Geom_Plane) horPlane = new Geom_Plane(0.,0.,1.,-dP0(2));
26752676
Handle(Geom_Curve) curve;
2676-
TopLoc_Location L = comp_dom.boat_model.reference_loc;
2677+
TopLoc_Location L = comp_dom.boat_model.current_loc;
26772678
TopLoc_Location L_inv = L.Inverted();
26782679
horPlane->Transform(L_inv.Transformation());
26792680
if (comp_dom.boat_model.is_transom)
@@ -4192,14 +4193,18 @@ int FreeSurface<dim>::residual_and_jacobian(const double t,
41924193
for (unsigned int k=3; k<7; ++k)
41934194
{
41944195
unsigned int i = comp_dom.moving_point_ids[k];
4196+
//cout<<"Moving point id: "<<i<<endl;
41954197
{
41964198
Point <3> dP0 = comp_dom.support_points[i];
41974199
Point <3> dP;
41984200
//this is the horizontal plane
41994201
Handle(Geom_Plane) horPlane = new Geom_Plane(0.,0.,1.,-dP0(2));
42004202
Handle(Geom_Curve) curve;
4201-
TopLoc_Location L = comp_dom.boat_model.reference_loc;
4203+
TopLoc_Location L = comp_dom.boat_model.current_loc;
42024204
TopLoc_Location L_inv = L.Inverted();
4205+
//gp_Pnt test_point(0.0,0.0,0.0);
4206+
//test_point.Transform(L_inv.Transformation());
4207+
//cout<<"####### "<<Pnt(test_point)<<endl;
42034208
horPlane->Transform(L_inv.Transformation());
42044209
if (comp_dom.boat_model.is_transom)
42054210
{

source/numerical_towing_tank.cc

Lines changed: 64 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "../include/boat_surface.h"
2121
#include <deal.II/numerics/matrix_tools.h>
2222
#include <deal.II/grid/grid_refinement.h>
23+
#include <BRepAdaptor_Curve.hxx>
2324

2425
using namespace dealii;
2526
using namespace OpenCascade;
@@ -1651,15 +1652,15 @@ void NumericalTowingTank::initialize_smoother()
16511652

16521653
curves.resize(7);
16531654
on_curve_option.resize(7);
1654-
ref_locations.resize(7);
1655+
smoothers_locations.resize(7,NULL);
16551656

16561657
// parameters for front keel smoothing
16571658
base_points[0] = boat_model.PointFrontBot;
16581659
moving_points[0] = boat_model.PointFrontTop;
16591660
curves[0] = boat_model.equiv_keel_bspline;
16601661
boundary_ids[0] = 30;
16611662
on_curve_option[0] = true;
1662-
ref_locations[0] = boat_model.reference_loc;
1663+
smoothers_locations[0] = &boat_model.current_loc;
16631664

16641665
// parameters for rear keel/left transom smoothing
16651666
if (boat_model.is_transom)
@@ -1669,7 +1670,7 @@ void NumericalTowingTank::initialize_smoother()
16691670
curves[1] = boat_model.left_transom_bspline;
16701671
boundary_ids[1] = 32;
16711672
on_curve_option[1] = true;
1672-
ref_locations[1] = boat_model.reference_loc;
1673+
smoothers_locations[1] = &boat_model.current_loc;
16731674
}
16741675
else
16751676
{
@@ -1678,7 +1679,7 @@ void NumericalTowingTank::initialize_smoother()
16781679
curves[1] = boat_model.equiv_keel_bspline;
16791680
boundary_ids[1] = 32;
16801681
on_curve_option[1] = true;
1681-
ref_locations[1] = boat_model.reference_loc;
1682+
smoothers_locations[1] = &boat_model.current_loc;
16821683
}
16831684

16841685
// parameters for rear keel/right transom smoothing
@@ -1689,7 +1690,7 @@ void NumericalTowingTank::initialize_smoother()
16891690
curves[2] = boat_model.right_transom_bspline;
16901691
boundary_ids[2] = 37;
16911692
on_curve_option[2] = true;
1692-
ref_locations[2] = boat_model.reference_loc;
1693+
smoothers_locations[2] = &boat_model.current_loc;
16931694
}
16941695
else
16951696
{
@@ -1698,7 +1699,7 @@ void NumericalTowingTank::initialize_smoother()
16981699
curves[2] = boat_model.equiv_keel_bspline;
16991700
boundary_ids[2] = 32;
17001701
on_curve_option[2] = true;
1701-
ref_locations[2] = boat_model.reference_loc;
1702+
smoothers_locations[2] = &boat_model.current_loc;
17021703
}
17031704

17041705
// parameters for front right water line smoothing
@@ -1764,7 +1765,7 @@ void NumericalTowingTank::initialize_smoother()
17641765
double smoother_tolerance = boat_model.boatWetLength*1e-3;
17651766
line_smoothers[i] = new LineSmoothing(smoothing_map_points,
17661767
curves[i],
1767-
ref_locations[i],
1768+
smoothers_locations[i],
17681769
vector_dh,
17691770
boundary_dofs[i],
17701771
base_point_ids[i],
@@ -1786,6 +1787,7 @@ void NumericalTowingTank::update_smoother()
17861787
curves[0] = boat_model.equiv_keel_bspline;
17871788
boundary_ids[0] = 30;
17881789
on_curve_option[0] = true;
1790+
smoothers_locations[0] = &boat_model.current_loc;
17891791

17901792
// parameters for rear keel/left transom smoothing
17911793
if (boat_model.is_transom)
@@ -1795,6 +1797,7 @@ void NumericalTowingTank::update_smoother()
17951797
curves[1] = boat_model.left_transom_bspline;
17961798
boundary_ids[1] = 32;
17971799
on_curve_option[1] = true;
1800+
smoothers_locations[1] = &boat_model.current_loc;
17981801
}
17991802
else
18001803
{
@@ -1803,6 +1806,7 @@ void NumericalTowingTank::update_smoother()
18031806
curves[1] = boat_model.equiv_keel_bspline;
18041807
boundary_ids[1] = 32;
18051808
on_curve_option[1] = true;
1809+
smoothers_locations[1] = &boat_model.current_loc;
18061810
}
18071811

18081812
// parameters for rear keel/right transom smoothing
@@ -1813,6 +1817,7 @@ void NumericalTowingTank::update_smoother()
18131817
curves[2] = boat_model.right_transom_bspline;
18141818
boundary_ids[2] = 37;
18151819
on_curve_option[2] = true;
1820+
smoothers_locations[2] = &boat_model.current_loc;
18161821
}
18171822
else
18181823
{
@@ -1821,6 +1826,7 @@ void NumericalTowingTank::update_smoother()
18211826
curves[2] = boat_model.equiv_keel_bspline;
18221827
boundary_ids[2] = 32;
18231828
on_curve_option[2] = true;
1829+
smoothers_locations[2] = &boat_model.current_loc;
18241830
}
18251831

18261832
// parameters for front right water line smoothing
@@ -2121,48 +2127,60 @@ vector_constraints.distribute(smoothing_map_points);
21212127
//this takes care of the bow and stern nodes
21222128
if (only_surf_smoothing == false)
21232129
for (unsigned int k=3; k<7; ++k)
2124-
{
2125-
unsigned int i = moving_point_ids[k];
2126-
//cout<<k<<" "<<i<<" "<<support_points[i]<<endl;
2127-
{
2128-
Point <3> dP0 = support_points[i];
2129-
Point <3> dP;
2130-
//this is the horizontal plane
2131-
Handle(Geom_Plane) horPlane = new Geom_Plane(0.,0.,1.,-dP0(2));
2132-
Handle(Geom_Curve) curve;
2133-
if (boat_model.is_transom)
2130+
{
2131+
unsigned int i = moving_point_ids[k];
21342132
{
2135-
if (k==3 || k==4)
2136-
curve = boat_model.equiv_keel_bspline;
2137-
else if (k == 6)
2138-
curve = boat_model.left_transom_bspline;
2133+
Point <3> dP0 = support_points[i];
2134+
Point <3> dP;
2135+
//this is the horizontal plane
2136+
Handle(Geom_Plane) horPlane = new Geom_Plane(0.,0.,1.,-dP0(2));
2137+
Handle(Geom_Curve) curve;
2138+
TopLoc_Location L = boat_model.current_loc;
2139+
TopLoc_Location L_inv = L.Inverted();
2140+
2141+
horPlane->Transform(L_inv.Transformation());
2142+
if (boat_model.is_transom)
2143+
{
2144+
if (k==3 || k==4)
2145+
curve = boat_model.equiv_keel_bspline;
2146+
else if (k == 6)
2147+
curve = boat_model.left_transom_bspline;
2148+
else
2149+
curve = boat_model.right_transom_bspline;
2150+
}
21392151
else
2140-
curve = boat_model.right_transom_bspline;
2141-
}
2142-
else
2143-
{
2144-
curve = boat_model.equiv_keel_bspline;
2145-
}
2146-
GeomAPI_IntCS Intersector(curve, horPlane);
2147-
int npoints = Intersector.NbPoints();
2148-
AssertThrow((npoints != 0), ExcMessage("Keel or transom curve is not intersecting with horizontal plane!"));
2149-
//cout<<"Number of intersections: "<<npoints<<endl;
2150-
double minDistance=1e7;
2151-
gp_Pnt P;
2152-
gp_Vec V1;
2153-
double t,u,v;
2154-
for (int j=0; j<npoints;++j)
2155-
{
2156-
Point<3> inters = Pnt(Intersector.Point(j+1));
2157-
Intersector.Parameters(j+1,u,v,t);
2152+
{
2153+
curve = boat_model.equiv_keel_bspline;
2154+
}
21582155

2159-
if (dP0.distance(inters) < minDistance)
2156+
TopoDS_Edge edge = BRepBuilderAPI_MakeEdge(curve);
2157+
edge.Location(L);
2158+
BRepAdaptor_Curve AC(edge);
2159+
gp_Pnt P;
2160+
gp_Vec V1;
2161+
GeomAPI_IntCS Intersector(curve, horPlane);
2162+
int npoints = Intersector.NbPoints();
2163+
2164+
AssertThrow((npoints != 0), ExcMessage("Keel or transom curve is not intersecting with horizontal plane!"));
2165+
double minDistance=1e7;
2166+
double t,u,v;
2167+
for (int j=0; j<npoints;++j)
21602168
{
2161-
minDistance = dP0.distance(inters);
2162-
dP = inters;
2163-
curve->D1(t,P,V1);
2169+
gp_Pnt int_point = Intersector.Point(j+1);
2170+
int_point.Transform(L.Transformation());
2171+
Point<3> inters = Pnt(int_point);
2172+
Intersector.Parameters(j+1,u,v,t);
2173+
if (dP0.distance(inters) < minDistance)
2174+
{
2175+
minDistance = dP0.distance(inters);
2176+
dP = inters;
2177+
AC.D1(t,P,V1);
2178+
}
21642179
}
2165-
}
2180+
//cout<<"Check plane-curve intersection:"<<endl;
2181+
//cout<<"Origin: "<<dP0<<" Proj: "<<dP<<" dist: "<<minDistance<<endl;
2182+
//cout<<Pnt(P)<<endl;
2183+
/*
21662184
// here temporarily for kcs hull tests
21672185
if (minDistance > 0.5*boat_model.boatWetLength)
21682186
{
@@ -2189,12 +2207,12 @@ for (unsigned int k=3; k<7; ++k)
21892207
}
21902208
cout<<"New part two: "<<dP<<" | "<<V1.X()<<" "<<V1.Y()<<" "<<V1.Z()<<" | "<<dP0<<endl;
21912209
}
2192-
2210+
*/
21932211
std::set<unsigned int> duplicates = double_nodes_set[i];
21942212
//duplicates.erase(i);
21952213
for (std::set<unsigned int>::iterator pos = duplicates.begin(); pos !=duplicates.end(); pos++)
21962214
{
2197-
smoothing_map_points(3*(*pos)) = dP(0)-ref_points[3*(*pos)](0);
2215+
smoothing_map_points(3*(*pos)) = dP(0)-ref_points[3*(*pos)](0);
21982216
smoothing_map_points(3*(*pos)+1) = dP(1)-ref_points[3*(*pos)](1);
21992217
smoothing_map_points(3*(*pos)+2) = dP(2)-ref_points[3*(*pos)](2);
22002218
edges_tangents[3*(*pos)] = V1.X();
@@ -2225,7 +2243,6 @@ for (unsigned int i=0; i<vector_dh.n_dofs(); ++i)
22252243
}
22262244

22272245
//////////////////////////////////////////
2228-
22292246
// line smoothing on keel/transom is performed here and modifies smoothing_map_points
22302247
// it ONLY moves nodes on the LEFT side of the keel
22312248
for(unsigned int i=0; i<3; ++i)
@@ -2249,7 +2266,6 @@ for(unsigned int i=0; i<3; ++i)
22492266

22502267
}
22512268
}
2252-
22532269
// line smoothing on water_lines is performed here and modifies smoothing_map_points
22542270
// it ONLY moves nodes on the water that are also near_boat
22552271
if (only_surf_smoothing == false)

0 commit comments

Comments
 (0)