Flow123d  release_2.2.0-20-gb8056ca
field_constant.hh
Go to the documentation of this file.
1 /*!
2  *
3  * Copyright (C) 2015 Technical University of Liberec. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU General Public License version 3 as published by the
7  * Free Software Foundation. (http://www.gnu.org/licenses/gpl-3.0.en.html)
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12  *
13  *
14  * @file field_constant.hh
15  * @brief
16  */
17 
18 #ifndef FIELD_CONSTANT_HH_
19 #define FIELD_CONSTANT_HH_
20 
21 #include "system/system.hh"
23 #include "input/factory.hh"
24 #include "mesh/point.hh"
25 
26 
27 /**
28  * Class representing spatially constant fields.
29  *
30  */
31 template <int spacedim, class Value>
32 class FieldConstant : public FieldAlgorithmBase<spacedim, Value>
33 {
34 public:
37 
38  /**
39  * Default constructor, optionally we need number of components @p n_comp in the case of Vector valued fields.
40  */
41  FieldConstant(unsigned int n_comp=0);
42 
43 
44  /**
45  * Return Record for initialization of FieldConstant that is derived from Abstract given by @p a_type
46  * and the individual elements of the possible Value (vector, tensor) have Input::Type @p eit.
47  */
48  static const Input::Type::Record & get_input_type();
49 
50  /**
51  * Smart setter from the given value to return.
52  */
53  FieldConstant<spacedim, Value> &set_value(const typename Value::return_type &val);
54 
55  /**
56  * This method initialize actual value of the field given from the given Input::Record @p rec.
57  */
58  virtual void init_from_input(const Input::Record &rec, const struct FieldAlgoBaseInitData& init_data);
59 
60 
61 
62  /**
63  * Returns one value in one given point. ResultType can be used to avoid some costly calculation if the result is trivial.
64  */
65  virtual typename Value::return_type const &value(const Point &p, const ElementAccessor<spacedim> &elm);
66 
67  /**
68  * Returns std::vector of scalar values in several points at once.
69  */
70  virtual void value_list (const std::vector< Point > &point_list, const ElementAccessor<spacedim> &elm,
72 
73 
74  virtual ~FieldConstant();
75 
76 protected:
77  /// Compare field value with given minimal and maximal limits.
78  void check_field_limits(const Input::Record &rec, const struct FieldAlgoBaseInitData& init_data);
79 
80 private:
81  /// Registrar of class to factory
82  static const int registrar;
83 
84 };
85 
86 
87 #endif /* FIELD_CONSTANT_HH_ */
static const Input::Type::Record & get_input_type()
Implementation.
void check_field_limits(const Input::Record &rec, const struct FieldAlgoBaseInitData &init_data)
Compare field value with given minimal and maximal limits.
FieldConstant< spacedim, Value > & set_value(const typename Value::return_type &val)
static const int registrar
Registrar of class to factory.
virtual void value_list(const std::vector< Point > &point_list, const ElementAccessor< spacedim > &elm, std::vector< typename Value::return_type > &value_list)
Helper struct stores data for initizalize descentants of FieldAlgorithmBase.
virtual Value::return_type const & value(const Point &p, const ElementAccessor< spacedim > &elm)
Accessor to the data with type Type::Record.
Definition: accessors.hh:292
FieldAlgorithmBase< spacedim, Value >::Point Point
FieldConstant(unsigned int n_comp=0)
FieldAlgorithmBase< spacedim, Value > FactoryBaseType
virtual void init_from_input(const Input::Record &rec, const struct FieldAlgoBaseInitData &init_data)
Space< spacedim >::Point Point
virtual ~FieldConstant()
Record type proxy class.
Definition: type_record.hh:182
unsigned int n_comp() const