/usr/include/deal.II/numerics/timestep_control.h is in libdeal.ii-dev 6.3.1-1.1.
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 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 | //---------------------------------------------------------------------------
// $Id: timestep_control.h 20360 2010-01-13 15:24:42Z kanschat $
//
// Copyright (C) 2010 by Guido Kanschat
//
// This file is subject to QPL and may not be distributed
// without copyright and license information. Please refer
// to the file deal.II/doc/license.html for the text and
// further information on this license.
//
//---------------------------------------------------------------------------
#ifndef __deal2__time_step_control_h
#define __deal2__time_step_control_h
#include <base/subscriptor.h>
#include <base/smartpointer.h>
#include <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 #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& param);
/**
* Read the control parameters
* from a parameter handler.
*/
void parse_parameters (ParameterHandler& param);
/**
* 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 size 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.
*/
void start_step (double);
/**
* 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
* #step_val, if we aimed at #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 (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
|