Flow123d  JS_before_hm-883-gc471082
field_time_function.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_time_function.hh
15  * @brief
16  */
17 
18 #ifndef FIELD_TIME_FUNCTION_HH_
19 #define FIELD_TIME_FUNCTION_HH_
20 
21 #include <string.h> // for memcpy
22 #include <boost/exception/info.hpp> // for error_info::error_info<Tag...
23 #include <new> // for operator new[]
24 #include <ostream> // for operator<<
25 #include <string> // for operator<<, string
26 #include <utility> // for pair
27 #include <armadillo>
28 #include "fields/field_algo_base.hh" // for FieldAlgorithmBase
29 #include "fields/field_constant.hh" // for FieldConstant
30 #include "fields/field_values.hh" // for FieldValue<>::TensorFixed
31 #include "input/accessors.hh" // for ExcAccessorForNullStorage
32 #include "input/accessors_impl.hh" // for Record::val
33 #include "input/storage.hh" // for ExcStorageTypeMismatch
34 #include "input/type_record.hh" // for Record::ExcRecordKeyNotFound
35 #include "tools/time_governor.hh" // for TimeStep
36 class UnitSI;
37 
38 /**
39  * Class representing spatially fields defined by time-dependent function.
40  *
41  */
42 template <int spacedim, class Value>
43 class FieldTimeFunction : public FieldConstant<spacedim, Value>
44 {
45 public:
48 
49  /**
50  * Return Record for initialization of FieldTimeFunction that is derived from Abstract given by @p a_type
51  * and the individual elements of the possible Value (vector, tensor) in given times have Input::Type @p eit.
52  */
53  static const Input::Type::Record & get_input_type();
54 
55 
56  /**
57  * Default constructor, optionally we need number of components @p n_comp in the case of Vector valued fields.
58  */
59  FieldTimeFunction(unsigned int n_comp=0);
60 
61  /**
62  * This method initialize actual value of the field given from the given Input::Record @p rec.
63  *
64  * TODO: after removing support for vector valued FieldConstant we can merge this method
65  * with FieldConstant::init_from_input and move initizaliation of FieldConstant value
66  * to set_time method.
67  */
68  void init_from_input(const Input::Record &rec, const struct FieldAlgoBaseInitData& init_data) override;
69 
70  /**
71  * Set time and init value_.
72  */
73  bool set_time(const TimeStep &time) override;
74 
75 private:
76  /// Registrar of class to factory
77  static const int registrar;
78 
79  /// Accessor to Input::Record
81 
82  /**
83  * Initialization data of field. Necessary for check limits.
84  *
85  * TODO: Temporary solution will be replaced with shared_ptr to field data in FieldAlgoBase
86  */
87  std::string field_name_;
89  std::pair<double, double> limits_;
90 
91 
92 };
93 
94 #endif /* FIELD_TIME_FUNCTION_HH_ */
FieldTimeFunction(unsigned int n_comp=0)
static const int registrar
Registrar of class to factory.
static const Input::Type::Record & get_input_type()
void init_from_input(const Input::Record &rec, const struct FieldAlgoBaseInitData &init_data) override
bool set_time(const TimeStep &time) override
FieldAlgorithmBase< spacedim, Value > FactoryBaseType
Helper struct stores data for initizalize descentants of FieldAlgorithmBase.
FieldAlgorithmBase< spacedim, Value >::Point Point
Basic time management class.
std::pair< double, double > limits_
Accessor to the data with type Type::Record.
Definition: accessors.hh:292
Input::Record in_rec_
Accessor to Input::Record.
Space< spacedim >::Point Point
Record type proxy class.
Definition: type_record.hh:182
Class for representation SI units of Fields.
Definition: unit_si.hh:40
Representation of one time step..
unsigned int n_comp() const