Skip to content

Commit a90b19a

Browse files
committed
fixed a bug on the version that imposes water height at inflow
git-svn-id: svn://svn.sissa.it/openship@567 958231e9-8e66-0410-a4a0-f664109d2741
1 parent dd4c4d0 commit a90b19a

File tree

3 files changed

+65
-56
lines changed

3 files changed

+65
-56
lines changed

include/restart_nonlinear_problem_diff.h

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public NewtonArgument
6868
if ( (comp_dom.flags[i] & water) &&
6969
(comp_dom.flags[i] & near_boat)==0 &&
7070
(comp_dom.flags[i] & transom_on_water)==0 &&
71+
(comp_dom.flags[i] & near_inflow)==0 &&
7172
(comp_dom.vector_constraints.is_constrained(3*i+2))==0 )
7273
{
7374
//cout<<"W "<<i<<" ("<<3*i+2<<")"<<endl;

source/free_surface.cc

+62-54
Original file line numberDiff line numberDiff line change
@@ -4411,15 +4411,17 @@ std::cout<<"Preparing interpolated solution for restart"<<std::endl;
44114411
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));
44124412
}
44134413
if ( !constraints.is_constrained(local_dof_indices[i]) &&
4414-
!(comp_dom.flags[local_dof_indices[i]] & transom_on_water) )
4414+
!(comp_dom.flags[local_dof_indices[i]] & transom_on_water) &&
4415+
!(comp_dom.flags[local_dof_indices[i]] & near_inflow))
44154416
{
44164417
unsigned int ii = local_dof_indices[i];
44174418
eta_res[ii] += loc_eta_res[i].val();
44184419
phi_res[ii] += loc_phi_res[i].val();
44194420

44204421
}
44214422
if ( !(constraints.is_constrained(local_dof_indices[i])) &&
4422-
!(comp_dom.flags[local_dof_indices[i]] & edge) )
4423+
!(comp_dom.flags[local_dof_indices[i]] & edge) &&
4424+
!(comp_dom.flags[local_dof_indices[i]] & near_inflow))
44234425
{
44244426
unsigned int ii = local_dof_indices[i];
44254427
x_smoothing_res[ii] += loc_x_smooth_res[i].val();
@@ -4619,10 +4621,10 @@ std::cout<<"Preparing interpolated solution for restart"<<std::endl;
46194621
RestartNonlinearProblemDiff rest_nonlin_prob_diff(*this,comp_dom,t,y,yp,jacobian_dot_matrix);
46204622
std::map<unsigned int,unsigned int> &map_diff = rest_nonlin_prob_diff.indices_map;
46214623

4622-
/*
4624+
46234625
// these lines test the correctness of the jacobian for the
46244626
// restart (reduced) nonlinear problem
4625-
4627+
/*
46264628
Vector<double> restart_prob_solution(rest_nonlin_prob_diff.n_dofs());
46274629
Vector<double> restart_prob_residual(rest_nonlin_prob_diff.n_dofs());
46284630
for (std::map<unsigned int, unsigned int>::iterator it = map_diff.begin(); it != map_diff.end(); ++it)
@@ -4646,7 +4648,7 @@ std::cout<<"Preparing interpolated solution for restart"<<std::endl;
46464648
rest_nonlin_prob_diff.residual(restart_prob_residual,restart_prob_solution);
46474649
cout<<"----------Test---------"<<endl;
46484650
for (unsigned int i=0; i<rest_nonlin_prob_diff.n_dofs(); ++i)
4649-
if (fabs(restart_prob_residual(i)-delta_res(i)) > 1e-10)
4651+
if (fabs(restart_prob_residual(i)-delta_res(i)) > 1e-15)
46504652
cout<<i<<" "<<delta_res(i)<<" vs "<<restart_prob_residual(i)<<" err "<<restart_prob_residual(i)-delta_res(i)<<" "<<sys_comp(i)<<endl;
46514653
delta_res*=-1;
46524654
delta_res.add(restart_prob_residual);
@@ -4681,9 +4683,9 @@ std::cout<<"Preparing interpolated solution for restart"<<std::endl;
46814683
//output_results(filename1, t, y, yp);
46824684

46834685

4684-
4686+
/*
46854687
// these lines test the jacobian of the DAE system
4686-
/*
4688+
46874689
Vector<double> delta_y(this->n_dofs());
46884690
Vector<double> delta_res(this->n_dofs());
46894691

@@ -4969,11 +4971,11 @@ int FreeSurface<dim>::jacobian(const double t,
49694971
bem.solve_system(bem_phi, bem_dphi_dn, bem_bc);
49704972

49714973
/*
4972-
cout<<"44!!!!!!"<<endl;
4973-
for (SparsityPattern::iterator col=jacobian_sparsity_pattern.begin(1484); col!=jacobian_sparsity_pattern.end(1484); ++col)
4974+
cout<<"JACOBIANO!!!!!!"<<endl;
4975+
for (SparsityPattern::iterator col=jacobian_sparsity_pattern.begin(80); col!=jacobian_sparsity_pattern.end(80); ++col)
49744976
{
49754977
unsigned int j = col->column();
4976-
cout<<j<<"("<<jacobian_matrix(1484,j)<<") ";
4978+
cout<<j<<"("<<jacobian_matrix(80,j)<<") ";
49774979
}
49784980
cout<<endl;
49794981
//*/
@@ -5304,7 +5306,7 @@ int FreeSurface<dim>::residual_and_jacobian(const double t,
53045306
if (comp_dom.flags[i] & near_inflow)
53055307
{
53065308
working_map_points(3*i+2) = comp_dom.old_map_points(3*i+2);
5307-
jacobian_matrix.add(3*i+2,3*i+2,1.0);
5309+
jacobian_matrix.set(3*i+2,3*i+2,1.0);
53085310
}
53095311
//cout<<"& "<<3*i<<" "<<3*i+1<<endl;
53105312
}
@@ -7035,26 +7037,29 @@ int FreeSurface<dim>::residual_and_jacobian(const double t,
70357037
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));
70367038
}
70377039
if ( !constraints.is_constrained(local_dof_indices[i]) &&
7038-
!(comp_dom.flags[local_dof_indices[i]] & transom_on_water))
7040+
!(comp_dom.flags[local_dof_indices[i]] & transom_on_water) )
70397041
{
70407042
unsigned int ii = local_dof_indices[i];
7041-
eta_res[ii] += loc_eta_res[i].val();
7043+
if (!(comp_dom.flags[local_dof_indices[i]] & near_inflow))
7044+
eta_res[ii] += loc_eta_res[i].val();
70427045
phi_res[ii] += loc_phi_res[i].val();
70437046
//cout<<"* "<<cell<<" "<<local_dof_indices[i]<<" "<<loc_phi_res[i]<<endl;
70447047
for (unsigned int j=0;j<dofs_per_cell;++j)
70457048
{
70467049
unsigned int jj = local_dof_indices[j];
7047-
for (unsigned int k=0; k<dim; ++k)
7048-
jacobian_matrix.add(3*ii+2,
7049-
3*jj+k,
7050-
loc_eta_res[i].fastAccessDx(3*j+k));
7051-
jacobian_matrix.add(3*ii+2,
7052-
jj+comp_dom.vector_dh.n_dofs(),
7053-
loc_eta_res[i].fastAccessDx(3*dofs_per_cell+j));
7054-
jacobian_matrix.add(3*ii+2,
7055-
jj+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs(),
7056-
loc_eta_res[i].fastAccessDx(4*dofs_per_cell+j));
7057-
7050+
if (!(comp_dom.flags[local_dof_indices[i]] & near_inflow))
7051+
{
7052+
for (unsigned int k=0; k<dim; ++k)
7053+
jacobian_matrix.add(3*ii+2,
7054+
3*jj+k,
7055+
loc_eta_res[i].fastAccessDx(3*j+k));
7056+
jacobian_matrix.add(3*ii+2,
7057+
jj+comp_dom.vector_dh.n_dofs(),
7058+
loc_eta_res[i].fastAccessDx(3*dofs_per_cell+j));
7059+
jacobian_matrix.add(3*ii+2,
7060+
jj+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs(),
7061+
loc_eta_res[i].fastAccessDx(4*dofs_per_cell+j));
7062+
}
70587063
for (unsigned int k=0; k<dim; ++k)
70597064
jacobian_matrix.add(ii+comp_dom.vector_dh.n_dofs(),
70607065
3*jj+k,
@@ -7065,17 +7070,19 @@ int FreeSurface<dim>::residual_and_jacobian(const double t,
70657070
jacobian_matrix.add(ii+comp_dom.vector_dh.n_dofs(),
70667071
jj+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs(),
70677072
loc_phi_res[i].fastAccessDx(4*dofs_per_cell+j));
7068-
7069-
for (unsigned int k=0; k<dim; ++k)
7070-
jacobian_dot_matrix.add(3*ii+2,
7071-
3*jj+k,
7072-
loc_eta_res[i].fastAccessDx(5*dofs_per_cell+3*j+k));
7073-
jacobian_dot_matrix.add(3*ii+2,
7074-
jj+comp_dom.vector_dh.n_dofs(),
7075-
loc_eta_res[i].fastAccessDx(8*dofs_per_cell+j));
7076-
jacobian_dot_matrix.add(3*ii+2,
7077-
jj+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs(),
7078-
loc_eta_res[i].fastAccessDx(9*dofs_per_cell+j));
7073+
if (!(comp_dom.flags[local_dof_indices[i]] & near_inflow))
7074+
{
7075+
for (unsigned int k=0; k<dim; ++k)
7076+
jacobian_dot_matrix.add(3*ii+2,
7077+
3*jj+k,
7078+
loc_eta_res[i].fastAccessDx(5*dofs_per_cell+3*j+k));
7079+
jacobian_dot_matrix.add(3*ii+2,
7080+
jj+comp_dom.vector_dh.n_dofs(),
7081+
loc_eta_res[i].fastAccessDx(8*dofs_per_cell+j));
7082+
jacobian_dot_matrix.add(3*ii+2,
7083+
jj+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs(),
7084+
loc_eta_res[i].fastAccessDx(9*dofs_per_cell+j));
7085+
}
70797086
for (unsigned int k=0; k<dim; ++k)
70807087
jacobian_dot_matrix.add(ii+comp_dom.vector_dh.n_dofs(),
70817088
3*jj+k,
@@ -7087,23 +7094,25 @@ int FreeSurface<dim>::residual_and_jacobian(const double t,
70877094
jj+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs(),
70887095
loc_phi_res[i].fastAccessDx(9*dofs_per_cell+j));
70897096
}
7090-
7091-
for (unsigned int k=0; k<dim; ++k)
7092-
jacobian_matrix.add(3*ii+2,
7093-
k+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7094-
loc_eta_res[i].fastAccessDx(k+10*dofs_per_cell));
7095-
for (unsigned int k=0; k<dim; ++k)
7096-
jacobian_matrix.add(3*ii+2,
7097-
k+3+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7098-
loc_eta_res[i].fastAccessDx(k+3+10*dofs_per_cell));
7099-
for (unsigned int k=0; k<dim; ++k)
7100-
jacobian_matrix.add(3*ii+2,
7101-
k+6+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7102-
loc_eta_res[i].fastAccessDx(k+6+10*dofs_per_cell));
7103-
for (unsigned int k=0; k<4; ++k)
7104-
jacobian_matrix.add(3*ii+2,
7105-
k+9+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7106-
loc_eta_res[i].fastAccessDx(k+9+10*dofs_per_cell));
7097+
if (!(comp_dom.flags[local_dof_indices[i]] & near_inflow))
7098+
{
7099+
for (unsigned int k=0; k<dim; ++k)
7100+
jacobian_matrix.add(3*ii+2,
7101+
k+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7102+
loc_eta_res[i].fastAccessDx(k+10*dofs_per_cell));
7103+
for (unsigned int k=0; k<dim; ++k)
7104+
jacobian_matrix.add(3*ii+2,
7105+
k+3+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7106+
loc_eta_res[i].fastAccessDx(k+3+10*dofs_per_cell));
7107+
for (unsigned int k=0; k<dim; ++k)
7108+
jacobian_matrix.add(3*ii+2,
7109+
k+6+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7110+
loc_eta_res[i].fastAccessDx(k+6+10*dofs_per_cell));
7111+
for (unsigned int k=0; k<4; ++k)
7112+
jacobian_matrix.add(3*ii+2,
7113+
k+9+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
7114+
loc_eta_res[i].fastAccessDx(k+9+10*dofs_per_cell));
7115+
}
71077116
for (unsigned int k=0; k<dim; ++k)
71087117
jacobian_matrix.add(ii+comp_dom.vector_dh.n_dofs(),
71097118
k+comp_dom.vector_dh.n_dofs()+comp_dom.dh.n_dofs()+comp_dom.dh.n_dofs(),
@@ -8112,8 +8121,7 @@ for (unsigned int i=0; i<this->n_dofs(); ++i)
81128121
{
81138122
unsigned int j = col->column();
81148123
//cout<<" "<<i<<" "<<j<<" "<<jacobian_matrix(i,j)+alpha*jacobian_dot_matrix(i,j)<<endl;
8115-
//if ( (j > (int)i-preconditioner_band) &&
8116-
// (j > (int)i+preconditioner_band) )
8124+
81178125
jacobian_preconditioner_matrix.set(i,j,jacobian_matrix(i,j)+alpha*jacobian_dot_matrix(i,j));
81188126
}
81198127

waveBem.prm

+2-2
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ subsection Boundary Conditions ID Numbers
156156
set Wall Surface 1 ID = 3
157157
set Wall Surface 2 ID = 4
158158
set Wall Surface 3 ID = 0
159-
set Inflow Surface 1 ID = 0
160-
set Inflow Surface 2 ID = 0
159+
set Inflow Surface 1 ID = 9
160+
set Inflow Surface 2 ID = 10
161161
set Inflow Surface 3 ID = 0
162162
set Pressure Surface ID = 0
163163
set Free Surface Edge On Boat ID = 20

0 commit comments

Comments
 (0)