phaseflow
FEM solver for the Navier-Stokes-Boussinesq equations coupled with enthalpy-based phase change
 All Classes Namespaces Files Functions Variables Macros Pages
pf_step_time.h
Go to the documentation of this file.
1 #ifndef _pf_step_time_h_
2 #define _pf_step_time_h_
3 
4 template<int dim>
5 void Phaseflow<dim>::set_time_step_size(const double _new_size)
6 {
7  double new_size = _new_size;
8 
9  if (new_size < this->params.time.min_step_size)
10  {
11  new_size = this->params.time.min_step_size;
12  }
13  else if(new_size > this->params.time.max_step_size)
14  {
15  new_size = this->params.time.max_step_size;
16  }
17 
18  if ((this->time + new_size) > this->params.time.end)
19  {
20  new_size = this->params.time.end - this->time;
21  }
22 
23  if (numbers::NumberTraits<double>::abs(new_size - this->time_step_size) > EPSILON)
24  {
25  std::cout << "Set time step to deltat = " << new_size << std::endl;
26  }
27 
28  this->time_step_size = new_size;
29 
30 }
31 
32 
39 template <int dim>
40 void Phaseflow<dim>::step_time()
41 {
42  this->old_solution = this->solution;
43 
44  bool converged;
45 
46  do
47  {
48  this->new_time = this->time + this->time_step_size;
49 
50  converged = this->solve_nonlinear_problem();
51 
52  if (!converged)
53  {
54  this->set_time_step_size(this->time_step_size/TIME_GROWTH_RATE);
55  }
56 
57  } while (!converged);
58 
59  this->time = this->new_time;
60 
61  std::cout << "Reached time t = " << this->time << std::endl;
62 
63  if (this->time >= (this->params.time.end - EPSILON))
64  {
65  return;
66  }
67 
68  if (converged)
69  {
70  this->set_time_step_size(TIME_GROWTH_RATE*this->time_step_size);
71  }
72 
73 }
74 
75 #endif
const double EPSILON
Definition: pf_global_parameters.h:24
const double TIME_GROWTH_RATE
Definition: pf_global_parameters.h:28