Flow123d  JS_before_hm-979-g397e552
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 <new> // for operator new[]
23 #include <ostream> // for operator<<
24 #include <string> // for operator<<, string
25 #include <utility> // for pair
26 #include <armadillo>
27 #include "fields/field_algo_base.hh" // for FieldAlgorithmBase
28 #include "fields/field_constant.hh" // for FieldConstant
29 #include "fields/field_values.hh" // for FieldValue<>::TensorFixed
30 #include "input/accessors.hh" // for ExcAccessorForNullStorage
31 #include "input/accessors_impl.hh" // for Record::val
32 #include "input/storage.hh" // for ExcStorageTypeMismatch
33 #include "input/type_record.hh" // for Record::ExcRecordKeyNotFound
34 #include "tools/time_governor.hh" // for TimeStep
35 class UnitSI;
36 
37 /**
38  * Class representing spatially fields defined by time-dependent function.
39  *
40  */
41 template <int spacedim, class Value>
42 class FieldTimeFunction : public FieldConstant<spacedim, Value>
43 {
44 public:
47 
48  /**
49  * Return Record for initialization of FieldTimeFunction that is derived from Abstract given by @p a_type
50  * and the individual elements of the possible Value (vector, tensor) in given times have Input::Type @p eit.
51  */
52  static const Input::Type::Record & get_input_type();
53 
54 
55  /**
56  * Default constructor, optionally we need number of components @p n_comp in the case of Vector valued fields.
57  */
58  FieldTimeFunction(unsigned int n_comp=0);
59 
60  /**
61  * This method initialize actual value of the field given from the given Input::Record @p rec.
62  *
63  * TODO: after removing support for vector valued FieldConstant we can merge this method
64  * with FieldConstant::init_from_input and move initizaliation of FieldConstant value
65  * to set_time method.
66  */
67  void init_from_input(const Input::Record &rec, const struct FieldAlgoBaseInitData& init_data) override;
68 
69  /**
70  * Set time and init value_.
71  */
72  bool set_time(const TimeStep &time) override;
73 
74 private:
75  /// Registrar of class to factory
76  static const int registrar;
77 
78  /// Accessor to Input::Record
80 
81  /**
82  * Initialization data of field. Necessary for check limits.
83  *
84  * TODO: Temporary solution will be replaced with shared_ptr to field data in FieldAlgoBase
85  */
86  std::string field_name_;
88  std::pair<double, double> limits_;
89 
90 
91 };
92 
93 #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:291
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