time dependent problem with time dependent dirichlet boundary conditions

93 views
Skip to first unread message

Bhanu Teja

unread,
Dec 4, 2017, 5:38:45 AM12/4/17
to deal.II User Group
Dear deal.II developers/users,
I am solving a time dependent problem (parabolic) with time dependent dirichlet boundary conditions(at a particular boundary). So I apply dirichlet boundary values at the beginning of each time step to the system matrix(assembled only once outside the time loop) and solve. I am using 
      VectorTools::interpolate_boundary_values(move_dof_handler, 106, move_boundary_values_function, move_boundary_values);
      MatrixTools::apply_boundary_values(move_boundary_values, move_system_matrix, move_solution, move_system_rhs);

instead of 'constraints'. 
Now, I have to add the current time step dirichlet values to the 'previous cumulative dirichlet values at this boundary' in my 'move_boundary_values_function' object of type  'template <int dim> class MoveBoundaryValues106 : public Function<dim>'. How can I accomplish this in my member function

  template <int dim>
  void  MoveBoundaryValues106<dim>::vector_value(const Point<dim> &p, Vector<double> &values) const
  {
    // std::vector<Tensor<1,dim>> previouscumulative(n_boundary_dofs_of_type_106);
      const double time = this->get_time();
      previuouscumulative += get_function_values();

      values[0] = previouscumulative[];
      values[1] = previouscumulative[];
      values[2] = previouscumulative[];
      values[3] = previouscumulative[]; 
  }


Please suggest/ direct me to any documentation or tutorial.

Thanks,
Bhanu.

Daniel Arndt

unread,
Dec 4, 2017, 6:24:11 AM12/4/17
to deal.II User Group
Bhanu,

[...]

      VectorTools::interpolate_boundary_values(move_dof_handler, 106, move_boundary_values_function, move_boundary_values);
      MatrixTools::apply_boundary_values(move_boundary_values, move_system_matrix, move_solution, move_system_rhs);

instead of 'constraints'. 
Now, I have to add the current time step dirichlet values to the 'previous cumulative dirichlet values at this boundary' in my 'move_boundary_values_function' object of type  'template <int dim> class MoveBoundaryValues106 : public Function<dim>'. How can I accomplish this in my member function

  template <int dim>
  void  MoveBoundaryValues106<dim>::vector_value(const Point<dim> &p, Vector<double> &values) const
  {
    // std::vector<Tensor<1,dim>> previouscumulative(n_boundary_dofs_of_type_106);
      const double time = this->get_time();
      previuouscumulative += get_function_values();

      values[0] = previouscumulative[];
      values[1] = previouscumulative[];
      values[2] = previouscumulative[];
      values[3] = previouscumulative[]; 
  }
So you have a time-dependent Function class that only returns an update instead of the new value?
In this case, I would still call

   VectorTools::interpolate_boundary_values(move_dof_handler, 106, move_boundary_values_function, move_boundary_values_update);

and add to the previous vector

for (auto& it=move_boundary_values.begin(); it!=move_boundary_values.end(); ++it)
  it->second += move_boundary_values_update[it->first];

Since move_boundary_values are also just the boundary values for your previous solution, you could also compute move_boundary_values on the fly
by extracting the boundary DoFs using DoFTools::extract_boundary_dofs and accessing the respective values in the solution vector, i.e.

for (const IndexSet::ElementIterator& it=boundary_dofs.begin(); it!=boundary_dofs.end(); ++it)
  move_boundary_values[*it] = solution(*it) + move_boundary_values_update[*it];

This is also the approach you would need to use if you want to refine your mesh between time steps.

All of this would of course be much simpler if your Function class would simply return the actual values and not just an update.

Best,
Daniel

Bhanu Teja

unread,
Dec 4, 2017, 8:20:10 AM12/4/17
to deal.II User Group
Thanks Daniel.

I will try the first approach. My time dependent Function class returns an update and not a new value. Actually, I am trying to solve a free surface flow problem with moving mesh(for very small displacements). I am implementing the flow and mesh movement in a decoupled way. So at the end of every time step I get the flow solution(velocity and pressure). So I advect(displace) the free surface vertices as (U_{t_n} + U_{t_{n+1}})*time_step/2. This is the incremental displacement which I want to add to previous displacements. I use this free surface boundary displacements to solve for the interior vertices displacements using a simple 'laplacian'(which is linear and thus laplacian_system_matrix is assembled only once). And finally apply these displacements to the entire (initial)mesh. 
Of course all this can be done using just incremental displacements instead of cumulative displacement(as I am moving the mesh anyway at every time step), I just want to try with cumulative.

I will revert for any further clarifications. 

Thanks,
Bhanu.
Reply all
Reply to author
Forward
0 new messages