@@ -279,7 +279,6 @@ void FreeSurface<dim>::reinit() {
279279template <int dim>
280280void 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