Reference documentation for deal.II version 9.5.0
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Attributes | Static Private Attributes | List of all members
Patterns::Double Class Reference

#include <deal.II/base/patterns.h>

Inheritance diagram for Patterns::Double:
[legend]

Public Types

enum  OutputStyle { Machine , Text , LaTeX }
 

Public Member Functions

 Double (const double lower_bound=min_double_value, const double upper_bound=max_double_value)
 
virtual bool match (const std::string &test_string) const override
 
virtual std::string description (const OutputStyle style=Machine) const override
 
virtual std::unique_ptr< PatternBaseclone () const override
 
virtual std::size_t memory_consumption () const
 

Static Public Member Functions

static std::unique_ptr< Doublecreate (const std::string &description)
 

Static Public Attributes

static const double min_double_value = std::numeric_limits<double>::lowest()
 
static const double max_double_value = std::numeric_limits<double>::max()
 

Private Attributes

const double lower_bound
 
const double upper_bound
 

Static Private Attributes

static const char * description_init = "[Double"
 

Detailed Description

Test for the string being a double. If bounds are given to the constructor, then the integer given also needs to be within the interval specified by these bounds. Note that unlike common convention in the C++ standard library, both bounds of this interval are inclusive; the reason is that in practice in most cases, one needs closed intervals, but these can only be realized with inclusive bounds for non-integer values. We thus stay consistent by always using closed intervals.

If the upper bound given to the constructor is smaller than the lower bound, then every double precision number is allowed.

Giving bounds may be useful if for example a value can only be positive and less than a reasonable upper bound (for example damping parameters are frequently only reasonable if between zero and one), or in many other cases.

Definition at line 291 of file patterns.h.

Member Enumeration Documentation

◆ OutputStyle

List of possible description output formats.

Capitalization chosen for similarity to ParameterHandler::OutputStyle.

Enumerator
Machine 

Simple text suitable for machine parsing in the static public member functions for all of the built in inheriting classes.

Preferably human readable, but machine parsing is more critical.

Text 

Easily human readable plain text format suitable for plain text documentation.

LaTeX 

Easily human readable LaTeX format suitable for printing in manuals.

Definition at line 97 of file patterns.h.

Constructor & Destructor Documentation

◆ Double()

Patterns::Double::Double ( const double  lower_bound = min_double_value,
const double  upper_bound = max_double_value 
)

Constructor. Bounds can be specified within which a valid parameter has to be. If the upper bound is smaller than the lower bound, then the entire set of double precision numbers is implied. The default values are chosen such that no bounds are enforced on parameters.

Definition at line 350 of file patterns.cc.

Member Function Documentation

◆ match()

bool Patterns::Double::match ( const std::string &  test_string) const
overridevirtual

Return true if the string is a number and its value is within the specified range.

Implements Patterns::PatternBase.

Definition at line 358 of file patterns.cc.

◆ description()

std::string Patterns::Double::description ( const OutputStyle  style = Machine) const
overridevirtual

Return a description of the pattern that valid strings are expected to match. If bounds were specified to the constructor, then include them into this description.

Implements Patterns::PatternBase.

Definition at line 381 of file patterns.cc.

◆ clone()

std::unique_ptr< PatternBase > Patterns::Double::clone ( ) const
overridevirtual

Return a copy of the present object, which is newly allocated on the heap. Ownership of that object is transferred to the caller of this function.

Implements Patterns::PatternBase.

Definition at line 481 of file patterns.cc.

◆ create()

std::unique_ptr< Double > Patterns::Double::create ( const std::string &  description)
static

Creates a new object on the heap using new if the given description is a valid format (for example created by calling description() on an existing object), or nullptr otherwise. Ownership of the returned object is transferred to the caller of this function, which should be freed using delete.

Definition at line 489 of file patterns.cc.

◆ memory_consumption()

std::size_t Patterns::PatternBase::memory_consumption ( ) const
virtualinherited

Determine an estimate for the memory consumption (in bytes) of this object. To avoid unnecessary overhead, we do not force derived classes to provide this function as a virtual overloaded one, but rather try to cast the present object to one of the known derived classes and if that fails then take the size of this base class instead and add 32 byte (this value is arbitrary, it should account for virtual function tables, and some possible data elements). Since there are usually not many thousands of objects of this type around, and since the memory_consumption mechanism is used to find out where memory in the range of many megabytes is, this seems like a reasonable approximation.

On the other hand, if you know that your class deviates from this assumption significantly, you can still overload this function.

Reimplemented in Patterns::Selection, Patterns::List, Patterns::Map, Patterns::Tuple, and Patterns::MultipleSelection.

Definition at line 190 of file patterns.cc.

Member Data Documentation

◆ min_double_value

const double Patterns::Double::min_double_value = std::numeric_limits<double>::lowest()
static

Minimal double value used as default value, taken from std::numeric_limits.

Definition at line 298 of file patterns.h.

◆ max_double_value

const double Patterns::Double::max_double_value = std::numeric_limits<double>::max()
static

Maximal double value used as default value, taken from std::numeric_limits.

Definition at line 304 of file patterns.h.

◆ lower_bound

const double Patterns::Double::lower_bound
private

Value of the lower bound. A number that satisfies the match operation of this class must be equal to this value or larger, if the bounds of the interval form a valid range.

Definition at line 356 of file patterns.h.

◆ upper_bound

const double Patterns::Double::upper_bound
private

Value of the upper bound. A number that satisfies the match operation of this class must be equal to this value or less, if the bounds of the interval form a valid range.

Definition at line 364 of file patterns.h.

◆ description_init

const char * Patterns::Double::description_init = "[Double"
staticprivate

Initial part of description

Definition at line 369 of file patterns.h.


The documentation for this class was generated from the following files: