/usr/include/deal.II/algorithms/timestep_control.h is in libdeal.ii-dev 8.4.2-2+b1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 | // ---------------------------------------------------------------------
//
// Copyright (C) 2010 - 2016 by the deal.II authors
//
// This file is part of the deal.II library.
//
// The deal.II library is free software; you can use it, redistribute
// it, and/or modify it under the terms of the GNU Lesser General
// Public License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
// The full text of the license can be found in the file LICENSE at
// the top level of the deal.II distribution.
//
// ---------------------------------------------------------------------
#ifndef dealii__time_step_control_h
#define dealii__time_step_control_h
#include <deal.II/base/subscriptor.h>
#include <deal.II/base/smartpointer.h>
#include <deal.II/lac/vector_memory.h>
#include <cstdio>
DEAL_II_NAMESPACE_OPEN
class ParameterHandler;
namespace Algorithms
{
/**
* Control class for timestepping schemes. Its main task is determining the
* size of the next time step and the according point in the time interval.
* Additionally, it controls writing the solution to a file.
*
* The size of the next time step is determined as follows:
* <ol>
* <li> According to the strategy, the step size is tentatively added to the
* current time.
* <li> If the resulting time exceeds the final time of the interval, the
* step size is reduced in order to meet this time.
* <li> If the resulting time is below the final time by just a fraction of
* the step size, the step size is increased in order to meet this time.
* <li> The resulting step size is used from the current time.
* </ol>
*
* The variable @p print_step can be used to control the amount of output
* generated by the timestepping scheme.
*/
class TimestepControl : public Subscriptor
{
public:
/**
* The time stepping strategies. These are controlled by the value of
* tolerance() and start_step().
*/
enum Strategy
{
/**
* Choose a uniform time step size. The step size is determined by
* start_step(), tolerance() is ignored.
*/
uniform,
/**
* Start with the time step size given by start_step() and double it in
* every step. tolerance() is ignored.
*
* This strategy is intended for pseudo-timestepping schemes computing a
* stationary limit.
*/
doubling
};
/**
* Constructor setting default values
*/
TimestepControl (double start = 0.,
double final = 1.,
double tolerance = 1.e-2,
double start_step = 1.e-2,
double print_step = -1.,
double max_step = 1.);
/**
* Declare the control parameters for parameter handler.
*/
static void declare_parameters (ParameterHandler ¶m);
/**
* Read the control parameters from a parameter handler.
*/
void parse_parameters (ParameterHandler ¶m);
/**
* The left end of the time interval.
*/
double start () const;
/**
* The right end of the time interval. The control mechanism ensures that
* the final time step ends at this point.
*/
double final () const;
/**
* The tolerance value controlling the time steps.
*/
double tolerance () const;
/**
* The size of the current time step.
*/
double step () const;
/**
* The current time.
*/
double now () const;
/**
* Compute the size of the next step and return true if it differs from
* the current step size. Advance the current time by the new step size.
*/
bool advance ();
/**
* Set start value.
*/
void start (double);
/**
* Set final time value.
*/
void final (double);
/**
* Set tolerance
*/
void tolerance (double);
/**
* Set strategy.
*/
void strategy (Strategy);
/**
* Set size of the first step. This may be overwritten by the time
* stepping strategy.
*
* @param[in] step The size of the first step, which may be overwritten by
* the time stepping strategy.
*/
void start_step (const double step);
/**
* Set size of the maximum step size.
*/
void max_step (double);
/**
* Set now() equal to start(). Initialize step() and print() to their
* initial values.
*/
void restart ();
/**
* Return true if this timestep should be written to disk.
*/
bool print ();
/**
* Set the output name template.
*/
void file_name_format (const char *);
const char *file_name_format ();
private:
double start_val;
double final_val;
double tolerance_val;
Strategy strategy_val;
double start_step_val;
double max_step_val;
double min_step_val;
/**
* The size of the current time step. This may differ from @p step_val, if
* we aimed at @p final_val.
*/
double current_step_val;
double step_val;
double now_val;
double print_step;
double next_print_val;
char format[30];
};
inline double
TimestepControl::start () const
{
return start_val;
}
inline double
TimestepControl::final () const
{
return final_val;
}
inline double
TimestepControl::step () const
{
return current_step_val;
}
inline double
TimestepControl::tolerance () const
{
return tolerance_val;
}
inline double
TimestepControl::now () const
{
return now_val;
}
inline void
TimestepControl::start (double t)
{
start_val = t;
}
inline void
TimestepControl::final (double t)
{
final_val = t;
}
inline void
TimestepControl::tolerance (double t)
{
tolerance_val = t;
}
inline void
TimestepControl::strategy (Strategy t)
{
strategy_val = t;
}
inline void
TimestepControl::start_step (const double t)
{
start_step_val = t;
}
inline void
TimestepControl::max_step (double t)
{
max_step_val = t;
}
inline void
TimestepControl::restart ()
{
now_val = start_val;
step_val = start_step_val;
current_step_val = step_val;
if (print_step > 0.)
next_print_val = now_val + print_step;
else
next_print_val = now_val - 1.;
}
inline void
TimestepControl::file_name_format (const char *fmt)
{
strcpy(format, fmt);
}
inline const char *
TimestepControl::file_name_format ()
{
return format;
}
}
DEAL_II_NAMESPACE_CLOSE
#endif
|