Flow123d  3.9.0-91c6c0b35
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 <stdio.h> // for sprintf
22 #include <string.h> // for memcpy
23 #include <new> // for operator new[]
24 #include <string> // for operator<<
25 #include <vector> // for vector
26 #include <armadillo>
27 #include "fields/field_algo_base.hh" // for FieldAlgorithmBase
28 #include "fields/field_values.hh" // for FieldValue<>::TensorFixed
29 #include "tools/unit_converter.hh" // for ExcInvalidUnit, ExcNonc...
30 #include "input/accessors.hh" // for ExcTypeMismatch, ExcAcc...
31 #include "input/accessors_impl.hh" // for Record::val, Iterator::...
32 #include "input/storage.hh" // for ExcStorageTypeMismatch
33 #include "input/type_record.hh" // for Record::ExcRecordKeyNot...
34 #include "system/exceptions.hh" // for ExcAssertMsg::~ExcAsser...
35 template <int spacedim> class ElementAccessor;
36 
37 
38 /**
39  * Class representing spatially constant fields.
40  *
41  */
42 template <int spacedim, class Value>
43 class FieldConstant : public FieldAlgorithmBase<spacedim, Value>
44 {
45 public:
48 
49  /**
50  * Default constructor, optionally we need number of components @p n_comp in the case of Vector valued fields.
51  */
52  FieldConstant(unsigned int n_comp=0);
53 
54 
55  /**
56  * Return Record for initialization of FieldConstant that is derived from Abstract given by @p a_type
57  * and the individual elements of the possible Value (vector, tensor) have Input::Type @p eit.
58  */
59  static const Input::Type::Record & get_input_type();
60 
61  /**
62  * Smart setter from the given value to return.
63  */
64  FieldConstant<spacedim, Value> &set_value(const typename Value::return_type &val);
65 
66  /**
67  * This method initialize actual value of the field given from the given Input::Record @p rec.
68  */
69  virtual void init_from_input(const Input::Record &rec, const struct FieldAlgoBaseInitData& init_data) override;
70 
71 
72 
73  /**
74  * Returns one value in one given point. ResultType can be used to avoid some costly calculation if the result is trivial.
75  */
76  virtual typename Value::return_type const &value(const Point &p, const ElementAccessor<spacedim> &elm) override;
77 
78  /**
79  * Returns std::vector of scalar values in several points at once.
80  */
81  virtual void value_list (const Armor::array &point_list, const ElementAccessor<spacedim> &elm,
83 
85  ElementCacheMap &cache_map, unsigned int region_patch_idx) override;
86 
87 
88  virtual ~FieldConstant();
89 
90 protected:
91  /// Compare field value with given minimal and maximal limits.
92  void check_field_limits(const Input::Record &rec, const struct FieldAlgoBaseInitData& init_data);
93 
94 private:
95  /// Registrar of class to factory
96  static const int registrar;
97 
98 };
99 
100 
101 #endif /* FIELD_CONSTANT_HH_ */
FieldAlgorithmBase::n_comp
unsigned int n_comp() const
Definition: field_algo_base.impl.hh:133
FieldConstant::FactoryBaseType
FieldAlgorithmBase< spacedim, Value > FactoryBaseType
Definition: field_constant.hh:47
field_algo_base.hh
FieldConstant::cache_update
void cache_update(FieldValueCache< typename Value::element_type > &data_cache, ElementCacheMap &cache_map, unsigned int region_patch_idx) override
Definition: field_constant.cc:146
string.h
ElementCacheMap
Directing class of FieldValueCache.
Definition: field_value_cache.hh:151
FieldConstant
Definition: field_constant.hh:43
std::vector
Definition: doxy_dummy_defs.hh:7
ElementAccessor
Definition: dh_cell_accessor.hh:32
FieldConstant::Point
FieldAlgorithmBase< spacedim, Value >::Point Point
Definition: field_constant.hh:46
FieldAlgorithmBase::Point
Space< spacedim >::Point Point
Definition: field_algo_base.hh:115
storage.hh
exceptions.hh
type_record.hh
FieldConstant::init_from_input
virtual void init_from_input(const Input::Record &rec, const struct FieldAlgoBaseInitData &init_data) override
Definition: field_constant.cc:75
FieldConstant::registrar
static const int registrar
Registrar of class to factory.
Definition: field_constant.hh:96
Input::Record
Accessor to the data with type Type::Record.
Definition: accessors.hh:291
FieldAlgoBaseInitData
Helper struct stores data for initizalize descentants of FieldAlgorithmBase.
Definition: field_algo_base.hh:81
accessors.hh
field_values.hh
FieldConstant::FieldConstant
FieldConstant(unsigned int n_comp=0)
Definition: field_constant.cc:58
FieldConstant::value_list
virtual void value_list(const Armor::array &point_list, const ElementAccessor< spacedim > &elm, std::vector< typename Value::return_type > &value_list) override
Definition: field_constant.cc:129
Input::Type::Record
Record type proxy class.
Definition: type_record.hh:182
FieldAlgorithmBase
Definition: field_algo_base.hh:112
accessors_impl.hh
FieldConstant::get_input_type
static const Input::Type::Record & get_input_type()
Implementation.
Definition: field_constant.cc:33
unit_converter.hh
FieldConstant::check_field_limits
void check_field_limits(const Input::Record &rec, const struct FieldAlgoBaseInitData &init_data)
Compare field value with given minimal and maximal limits.
Definition: field_constant.cc:158
Armor::Array< double >
FieldConstant::set_value
FieldConstant< spacedim, Value > & set_value(const typename Value::return_type &val)
Definition: field_constant.cc:66
FieldConstant::~FieldConstant
virtual ~FieldConstant()
Definition: field_constant.cc:174
FieldConstant::value
virtual const Value::return_type & value(const Point &p, const ElementAccessor< spacedim > &elm) override
Definition: field_constant.cc:118