Skip to content

Commit 7994811

Browse files
committed
this version is working with an imposed (hard codes, as of now) vertical hull motion. the pressure patch for wet transom stern still has to be updated
git-svn-id: svn://svn.sissa.it/openship@558 958231e9-8e66-0410-a4a0-f664109d2741
1 parent afcc5d3 commit 7994811

7 files changed

Lines changed: 110 additions & 31 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 "Debug")
21+
set(CMAKE_BUILD_TYPE "Release")
2222

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

include/boat_model.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class BoatModel{
4343

4444
Point<3> compute_hydrostatic_moment(const double &sink);
4545

46-
void set_current_position(const double &sink);
46+
gp_Trsf set_current_position(const double &sink);
4747

4848
//private:
4949
// keel intersection with undisturbed free surface at bow

include/free_surface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ public NewtonArgument
453453
// won't be refined.
454454
double adaptive_ref_limit;
455455

456-
456+
TopLoc_Location restart_hull_location;
457457

458458

459459
};

include/numerical_towing_tank.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ std::vector<Handle(Geom_Curve)> curves;
253253
// call of smoothing routine. false for keel smoothings
254254
// true for water line smoothings
255255
std::vector<bool> on_curve_option;
256-
// locations are needed when reference configuration
256+
// locations are needed when current hull configuration
257257
// is roto-translated
258258
std::vector< TopLoc_Location *> smoothers_locations;
259259
// nodes flags on the scalar dof_handler
@@ -301,6 +301,9 @@ Vector<double> smoothing_map_points;
301301
Vector<double> initial_map_points;
302302
// the euler vector obtained right after each restart
303303
Vector<double> old_map_points;
304+
// the euler vector updated at each time step to account for rigid
305+
// motions of the hull
306+
Vector<double> rigid_motion_map_points;
304307
// x domain dimension
305308
double Lx_domain;
306309
// y domain dimension

source/boat_model.cc

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ cout<<"UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU"<<endl;
804804
return hydrostatic_force;
805805
}
806806

807-
void BoatModel::set_current_position(const double &sink)
807+
gp_Trsf BoatModel::set_current_position(const double &sink)
808808
{
809809

810810
//here we prepare the rotation of the boat of the requested trim angle
@@ -814,15 +814,19 @@ void BoatModel::set_current_position(const double &sink)
814814
//gp_Trsf rotation;
815815
//rotation.SetRotation(rot_axis,assigned_trim);
816816
//we first get the full transformation currently applied to the shape
817-
TopLoc_Location prev_L = sh.Location();
817+
TopLoc_Location prev_L = reference_loc;
818818
gp_Trsf prev_Transf = prev_L.Transformation();
819819

820820
//here we prepare the translation of the boat of the requested sink
821821
gp_Trsf translation;
822822
gp_Vec vrt_displ(0.0,0.0,sink);
823823
translation.SetTranslation(vrt_displ);
824+
825+
826+
gp_Trsf this_transf = translation;
827+
824828
//the rotation and translation are combined in a single transformation
825-
gp_Trsf new_Transf = translation*prev_Transf;
829+
gp_Trsf new_Transf = this_transf*prev_Transf;
826830
TopLoc_Location new_L(new_Transf);
827831

828832
//the transformation is applied to the two sides of the boat
@@ -833,7 +837,7 @@ void BoatModel::set_current_position(const double &sink)
833837
keel_edge.Location(new_L);
834838
current_loc = new_L;
835839

836-
840+
return current_loc.Transformation();
837841
}
838842

839843

source/free_surface.cc

Lines changed: 81 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,6 @@ 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);
283282

284283
// da trattare il caso di dumped solution (continuazione conto salvato)
285284
initial_time = 0.0;
@@ -645,6 +644,10 @@ void FreeSurface<dim>::initial_conditions(Vector<double> &dst) {
645644
output_results(filename, 0, dst, dummy_sol_dot);
646645

647646
comp_dom.old_map_points = comp_dom.map_points;
647+
comp_dom.rigid_motion_map_points = comp_dom.map_points;
648+
double rigid_vertical_displacement = 0.01*sin(2*dealii::numbers::PI*0.0);
649+
restart_hull_location = comp_dom.boat_model.set_current_position(rigid_vertical_displacement);
650+
648651

649652
last_remesh_time = 0;
650653

@@ -839,6 +842,7 @@ bool FreeSurface<dim>::solution_check(Vector<double> & solution,
839842
{
840843

841844

845+
842846
static unsigned int remeshing_counter = 1;
843847
static unsigned int dumping_counter = 1;
844848

@@ -855,6 +859,10 @@ bool FreeSurface<dim>::solution_check(Vector<double> & solution,
855859
++remeshing_counter;
856860
std::cout<<"Checking and updating mesh..."<<std::endl;
857861

862+
// first thing to do is update the geometry to the current positon
863+
double rigid_vertical_displacement = 0.01*sin(2*dealii::numbers::PI*t);
864+
restart_hull_location = comp_dom.boat_model.set_current_position(rigid_vertical_displacement);
865+
858866
//std::string filename1 = ( "preRemesh.vtu" );
859867
//output_results(filename1, t, solution, solution_dot);
860868

@@ -932,7 +940,7 @@ bool FreeSurface<dim>::solution_check(Vector<double> & solution,
932940
double max_other_error = 0;
933941
unsigned int counter=0;
934942
for (cell_it elem=dh.begin_active(); elem!= dh.end();++elem)
935-
{cout<<estimated_error_per_cell(counter)<<endl;
943+
{
936944
if ((elem->material_id() == comp_dom.wall_sur_ID1 ||
937945
elem->material_id() == comp_dom.wall_sur_ID2 ||
938946
elem->material_id() == comp_dom.wall_sur_ID3 ))
@@ -1169,6 +1177,7 @@ bool FreeSurface<dim>::solution_check(Vector<double> & solution,
11691177
comp_dom.map_points.reinit(vector_dh.n_dofs());
11701178
comp_dom.smoothing_map_points.reinit(vector_dh.n_dofs());
11711179
comp_dom.old_map_points.reinit(vector_dh.n_dofs());
1180+
comp_dom.rigid_motion_map_points.reinit(vector_dh.n_dofs());
11721181
comp_dom.initial_map_points.reinit(vector_dh.n_dofs());
11731182
comp_dom.ref_points.resize(vector_dh.n_dofs());
11741183
DoFTools::map_dofs_to_support_points<2,3>(StaticMappingQ1<2,3>::mapping,
@@ -1531,12 +1540,13 @@ bool FreeSurface<dim>::solution_check(Vector<double> & solution,
15311540
Point<dim> Vinf;
15321541
for (unsigned int i = 0; i < dim; i++)
15331542
Vinf(i) = instantWindValue(i);
1534-
1543+
Point<dim> Vh(0.0,0.0,0.01*2*dealii::numbers::PI*cos(2*dealii::numbers::PI*t));
1544+
15351545
for (unsigned int i=0; i<dh.n_dofs(); ++i)
15361546
{
15371547
if ( comp_dom.flags[i] & boat )
15381548
//solution(i+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()) = -comp_dom.iges_normals[i]*Vinf;
1539-
solution(i+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()) = -comp_dom.node_normals[i]*Vinf;
1549+
solution(i+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()) = comp_dom.node_normals[i]*(Vh-Vinf);
15401550
}
15411551

15421552
differential_components();
@@ -1546,6 +1556,10 @@ bool FreeSurface<dim>::solution_check(Vector<double> & solution,
15461556
current_sol_dot = solution_dot;
15471557
last_remesh_time = t;
15481558
comp_dom.old_map_points = comp_dom.map_points;
1559+
comp_dom.rigid_motion_map_points = comp_dom.map_points;
1560+
//double rigid_vertical_displacement = 0.01*sin(2*dealii::numbers::PI*t);
1561+
//restart_hull_location = comp_dom.boat_model.set_current_position(rigid_vertical_displacement);
1562+
15491563
prepare_restart(t, solution, solution_dot,true);
15501564
//std::string filename3 = ( "postPostRemesh.vtu" );
15511565
//output_results(filename3, t, solution, solution_dot);
@@ -1735,6 +1749,7 @@ bool FreeSurface<dim>::solution_check(Vector<double> & solution,
17351749
{
17361750
comp_dom.map_points(i) -= nodes_ref_surf_dist(i);
17371751
comp_dom.old_map_points(i) = comp_dom.map_points(i);
1752+
comp_dom.rigid_motion_map_points(i) = comp_dom.map_points(i);
17381753
solution(i) = comp_dom.map_points(i);
17391754
//cout<<i<<" "<<nodes_ref_surf_dist(i)<<endl;
17401755
}
@@ -1914,6 +1929,7 @@ std::cout<<"Restoring mesh conformity..."<<std::endl;
19141929
comp_dom.map_points.reinit(vector_dh.n_dofs());
19151930
comp_dom.smoothing_map_points.reinit(vector_dh.n_dofs());
19161931
comp_dom.old_map_points.reinit(vector_dh.n_dofs());
1932+
comp_dom.rigid_motion_map_points.reinit(vector_dh.n_dofs());
19171933
comp_dom.initial_map_points.reinit(vector_dh.n_dofs());
19181934
comp_dom.ref_points.resize(vector_dh.n_dofs());
19191935
DoFTools::map_dofs_to_support_points<2,3>(StaticMappingQ1<2,3>::mapping,
@@ -2224,6 +2240,7 @@ std::cout<<"Removing hanging nodes from transom stern..."<<std::endl;
22242240
comp_dom.map_points.reinit(vector_dh.n_dofs());
22252241
comp_dom.smoothing_map_points.reinit(vector_dh.n_dofs());
22262242
comp_dom.old_map_points.reinit(vector_dh.n_dofs());
2243+
comp_dom.rigid_motion_map_points.reinit(vector_dh.n_dofs());
22272244
comp_dom.initial_map_points.reinit(vector_dh.n_dofs());
22282245
comp_dom.ref_points.resize(vector_dh.n_dofs());
22292246
DoFTools::map_dofs_to_support_points<2,3>(StaticMappingQ1<2,3>::mapping,
@@ -3888,8 +3905,6 @@ int FreeSurface<dim>::residual_and_jacobian(const double t,
38883905

38893906

38903907

3891-
3892-
38933908
const VectorView<double> nodes_positions(comp_dom.vector_dh.n_dofs(),src_yy.begin());
38943909
const VectorView<double> nodes_velocities(comp_dom.vector_dh.n_dofs(),src_yp.begin());
38953910
const VectorView<double> phi(comp_dom.dh.n_dofs(),src_yy.begin()+comp_dom.vector_dh.n_dofs());
@@ -3975,6 +3990,7 @@ int FreeSurface<dim>::residual_and_jacobian(const double t,
39753990
// here we take care of the geometric part of the variables
39763991
//////////////////////////////////////////////////////////////////////
39773992

3993+
39783994
comp_dom.update_mapping(src_yy);
39793995
comp_dom.update_support_points();
39803996

@@ -3987,6 +4003,45 @@ int FreeSurface<dim>::residual_and_jacobian(const double t,
39874003
vector_constraints.distribute(working_map_points);
39884004

39894005

4006+
// these lines take care of the hull (and consequential hull internal grid nodes) displacement
4007+
// these lines will only act when the time step is new
4008+
4009+
if (new_time_step)
4010+
{
4011+
double rigid_vertical_displacement = 0.01*sin(2.0*dealii::numbers::PI*t);
4012+
//cout<<"Displacement: "<<rigid_vertical_displacement<<" "<<sin(2.0*(dealii::numbers::PI)*t)<<endl;
4013+
// this is the displacement of the hull geometry (all projectors and smoothers will adapt
4014+
// to the change)
4015+
gp_Trsf reference_to_current_transformation = comp_dom.boat_model.set_current_position(rigid_vertical_displacement);
4016+
4017+
// this moves the rigid_motion_map_points vector (target positions) for the internal nodes of the hull
4018+
// mesh (all nodes except for the free surface ones)
4019+
for (unsigned int i=0; i<comp_dom.dh.n_dofs(); ++i)
4020+
{
4021+
if ( ((comp_dom.flags[i] & boat) &&
4022+
!(comp_dom.flags[i] & near_water) ) ||
4023+
(comp_dom.flags[i] & transom_on_water) )
4024+
{
4025+
//cout<<"BEFORE: "<<comp_dom.ref_points[3*i](0)+comp_dom.old_map_points(3*i)<<" "
4026+
// <<comp_dom.ref_points[3*i](1)+comp_dom.old_map_points(3*i+1)<<" "
4027+
// <<comp_dom.ref_points[3*i](2)+comp_dom.old_map_points(3*i+2)<<endl;
4028+
gp_Pnt boat_mesh_point = Pnt(Point<3>(comp_dom.ref_points[3*i](0)+comp_dom.old_map_points(3*i),
4029+
comp_dom.ref_points[3*i](1)+comp_dom.old_map_points(3*i+1),
4030+
comp_dom.ref_points[3*i](2)+comp_dom.old_map_points(3*i+2)));
4031+
// we first take this point (which is in the RESTART hull location) and transform it to be in the
4032+
// REFERENCE configuration
4033+
boat_mesh_point.Transform(restart_hull_location.Inverted());
4034+
// now we have the point on the REFERENCE hull, and transform it to go onto the CURRENT hull
4035+
boat_mesh_point.Transform(reference_to_current_transformation);
4036+
comp_dom.rigid_motion_map_points(3*i) = boat_mesh_point.X() - comp_dom.ref_points[3*i](0);
4037+
comp_dom.rigid_motion_map_points(3*i+1) = boat_mesh_point.Y() - comp_dom.ref_points[3*i](1);
4038+
comp_dom.rigid_motion_map_points(3*i+2) = boat_mesh_point.Z() - comp_dom.ref_points[3*i](2);
4039+
//cout<<"AFTER: "<<Pnt(boat_mesh_point)<<endl;
4040+
}
4041+
}
4042+
4043+
}
4044+
39904045
// as for now x and y coordinates of nodes are not moved (no surface smoothing)
39914046
// so on x and y coordinates (except for water nodes) we only need to put a one
39924047
// on the matrix diagonal
@@ -3998,27 +4053,27 @@ int FreeSurface<dim>::residual_and_jacobian(const double t,
39984053
!(comp_dom.flags[i] & transom_on_water) &&
39994054
(!constraints.is_constrained(i)))
40004055
{
4001-
working_map_points(3*i) = comp_dom.old_map_points(3*i);
4002-
working_map_points(3*i+1) = comp_dom.old_map_points(3*i+1);
4056+
working_map_points(3*i) = comp_dom.rigid_motion_map_points(3*i);
4057+
working_map_points(3*i+1) = comp_dom.rigid_motion_map_points(3*i+1);
40034058
jacobian_matrix.add(3*i,3*i,1.0);
40044059
jacobian_matrix.add(3*i+1,3*i+1,1.0);
40054060
}
40064061
else if ( !(comp_dom.flags[i] & near_water) &&
40074062
!(comp_dom.flags[i] & water) &&
40084063
(!constraints.is_constrained(i)))
40094064
{
4010-
working_map_points(3*i) = comp_dom.old_map_points(3*i);
4011-
working_map_points(3*i+1) = comp_dom.old_map_points(3*i+1);
4012-
working_map_points(3*i+2) = comp_dom.old_map_points(3*i+2);
4065+
working_map_points(3*i) = comp_dom.rigid_motion_map_points(3*i);
4066+
working_map_points(3*i+1) = comp_dom.rigid_motion_map_points(3*i+1);
4067+
working_map_points(3*i+2) = comp_dom.rigid_motion_map_points(3*i+2);
40134068
jacobian_matrix.add(3*i,3*i,1.0);
40144069
jacobian_matrix.add(3*i+1,3*i+1,1.0);
40154070
jacobian_matrix.add(3*i+2,3*i+2,1.0);
40164071
}
40174072
else if ((comp_dom.flags[i] & transom_on_water) )
40184073
{
4019-
working_map_points(3*i) = comp_dom.old_map_points(3*i);
4020-
working_map_points(3*i+1) = comp_dom.old_map_points(3*i+1);
4021-
working_map_points(3*i+2) = comp_dom.old_map_points(3*i+2);
4074+
working_map_points(3*i) = comp_dom.rigid_motion_map_points(3*i);
4075+
working_map_points(3*i+1) = comp_dom.rigid_motion_map_points(3*i+1);
4076+
working_map_points(3*i+2) = comp_dom.rigid_motion_map_points(3*i+2);
40224077
jacobian_matrix.add(3*i,3*i,1.0);
40234078
jacobian_matrix.add(3*i+1,3*i+1,1.0);
40244079
jacobian_matrix.add(3*i+2,3*i+2,1.0);
@@ -4084,13 +4139,13 @@ int FreeSurface<dim>::residual_and_jacobian(const double t,
40844139
// comp_dom.support_points[i]); // y axis projection
40854140
if (fabs(comp_dom.old_iges_normals[i](0))<sqrt(3)/3*fabs(comp_dom.old_iges_normals[i](1)))
40864141
{
4087-
working_map_points(3*i) = comp_dom.old_map_points(3*i); // x of the node must not change
4142+
working_map_points(3*i) = comp_dom.rigid_motion_map_points(3*i); // x of the node must not change
40884143
working_map_points(3*i+1) = proj_node(1) - comp_dom.ref_points[3*i](1);
40894144
}
40904145
else
40914146
{
40924147
working_map_points(3*i) = proj_node(0) - comp_dom.ref_points[3*i](0);
4093-
working_map_points(3*i+1) = comp_dom.old_map_points(3*i+1); // y of the node must not change
4148+
working_map_points(3*i+1) = comp_dom.rigid_motion_map_points(3*i+1); // y of the node must not change
40944149
}
40954150
working_map_points(3*i+2) = proj_node(2) - comp_dom.ref_points[3*i](2);
40964151

@@ -4152,13 +4207,13 @@ int FreeSurface<dim>::residual_and_jacobian(const double t,
41524207
// comp_dom.support_points[i]); // y axis projection
41534208
if (fabs(comp_dom.old_iges_normals[i](0))<sqrt(3)/3*fabs(comp_dom.old_iges_normals[i](1)))
41544209
{
4155-
working_map_points(3*i) = comp_dom.old_map_points(3*i); // x of the node must not change
4210+
working_map_points(3*i) = comp_dom.rigid_motion_map_points(3*i); // x of the node must not change
41564211
working_map_points(3*i+1) = proj_node(1) - comp_dom.ref_points[3*i](1);
41574212
}
41584213
else
41594214
{
41604215
working_map_points(3*i) = proj_node(0) - comp_dom.ref_points[3*i](0);
4161-
working_map_points(3*i+1) = comp_dom.old_map_points(3*i+1); // y of the node must not change
4216+
working_map_points(3*i+1) = comp_dom.rigid_motion_map_points(3*i+1); // y of the node must not change
41624217
}
41634218
working_map_points(3*i+2) = proj_node(2) - comp_dom.ref_points[3*i](2);
41644219

@@ -5081,8 +5136,12 @@ int FreeSurface<dim>::residual_and_jacobian(const double t,
50815136
{
50825137
for (unsigned int i=0;i<dofs_per_cell;++i)
50835138
{
5084-
loc_dphi_dn_res[i] -= -(q_normal*Point<3,fad_double>(fad_double(Vinf(0)),fad_double(Vinf(1)),fad_double(Vinf(2))))*
5085-
fad_double(ref_fe_v.shape_value(i,q))*q_JxW[q];
5139+
Point<3,fad_double> VV_inf(fad_double(Vinf(0)),fad_double(Vinf(1)),fad_double(Vinf(2)));
5140+
Point<3,fad_double> VV_hull(fad_double(0),
5141+
fad_double(0),
5142+
fad_double(2*dealii::numbers::PI*0.01*cos(2*dealii::numbers::PI*t)));
5143+
loc_dphi_dn_res[i] -= (q_normal*(VV_hull-VV_inf))*
5144+
fad_double(ref_fe_v.shape_value(i,q))*q_JxW[q];
50865145
//cout<<q<<" "<<i<<" "<<-(q_normal*Point<3,fad_double>(fad_double(Vinf(0)),fad_double(Vinf(1)),fad_double(Vinf(2)))).val()<<" "<<cell->center()<<" "<<endl;
50875146
//cout<<q<<" "<<i<<" "<<N_i_surf_grad<<" "<<fluid_vel[q]/fluid_vel_norm<<" "<<cell->diameter()/sqrt(2)<<endl;
50885147
//cout<<q<<" "<<i<<" "<<N_i_supg.val()<<" "<<phi_dot_res_fun[q].val()<<" "<<q_JxW[q].val()<<endl;
@@ -5198,8 +5257,8 @@ int FreeSurface<dim>::residual_and_jacobian(const double t,
51985257
loc_eta_res[i] += loc_supg_mass_matrix[i][j]*coors_dot[3*j+2];
51995258
loc_phi_res[i] += loc_supg_mass_matrix[i][j]*phis_dot[j];
52005259
//if (fabs(t<0.005)<1e-4) {cout<<cell<<" "<<i<<" "<<phis_dot[j]<<endl;}
5201-
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]));
5202-
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));
5260+
loc_x_smooth_res[i] += loc_stiffness_matrix[i][j]*(x_displs[j]-(1-blend_factor)*comp_dom.rigid_motion_map_points(3*local_dof_indices[j]));
5261+
loc_y_smooth_res[i] += loc_stiffness_matrix[i][j]*(y_displs[j]-(1-blend_factor)*comp_dom.rigid_motion_map_points(3*local_dof_indices[j]+1));
52035262
}
52045263
if ( !constraints.is_constrained(local_dof_indices[i]) &&
52055264
!(comp_dom.flags[local_dof_indices[i]] & transom_on_water))

0 commit comments

Comments
 (0)