Flow123d
field_constant_impl.hh
Go to the documentation of this file.
1 /*
2  * field_constant_impl.hh
3  *
4  * Created on: Dec 15, 2012
5  * Author: jb
6  */
7 
8 #ifndef FIELD_CONSTANT_IMPL_HH_
9 #define FIELD_CONSTANT_IMPL_HH_
10 
11 #include "fields/field_constant.hh"
12 #include "input/input_type.hh"
13 
14 
15 //#include <boost/type_traits.hpp>
16 
17 /// Implementation.
18 
19 namespace it = Input::Type;
20 
21 template <int spacedim, class Value>
24 
25 
26 template <int spacedim, class Value>
28  Input::Type::AbstractRecord &a_type, const typename Value::ElementInputType *eit
29  )
30 {
31  it::Record type=
32  it::Record("FieldConstant", FieldBase<spacedim,Value>::template_name()+" Field constant in space.")
33  .derive_from(a_type)
34  .declare_key("value", Value::get_input_type(eit), it::Default::obligatory(),
35  "Value of the constant field.\n"
36  "For vector values, you can use scalar value to enter constant vector.\n"
37  "For square NxN-matrix values, you can use:\n"
38  "* vector of size N to enter diagonal matrix\n"
39  "* vector of size (N+1)*N/2 to enter symmetric matrix (upper triangle, row by row)\n"
40  "* scalar to enter multiple of the unit matrix." )
41  .allow_auto_conversion("value");
42 
43  return type;
44 }
45 
46 
47 
48 template <int spacedim, class Value>
50 : FieldBase<spacedim, Value>(n_comp)
51 {}
52 
53 
54 template <int spacedim, class Value>
56 {
57  this->r_value_ = val;
58 
59  return *this;
60 }
61 
62 
63 template <int spacedim, class Value>
65  this->value_.init_from_input( rec.val<typename Value::AccessType>("value") );
66 }
67 
68 
69 
70 /**
71  * Returns one value in one given point. ResultType can be used to avoid some costly calculation if the result is trivial.
72  */
73 template <int spacedim, class Value>
74 typename Value::return_type const & FieldConstant<spacedim, Value>::value(const Point &p, const ElementAccessor<spacedim> &elm)
75 {
76  return this->r_value_;
77 }
78 
79 
80 
81 /**
82  * Returns std::vector of scalar values in several points at once.
83  */
84 template <int spacedim, class Value>
87 {
88  ASSERT_EQUAL( point_list.size(), value_list.size() );
89  for(unsigned int i=0; i< point_list.size(); i++)
90  value_list[i]=this->r_value_;
91 }
92 
93 
94 
95 template <int spacedim, class Value>
97 }
98 
99 
100 
101 #endif /* FIELD_CONSTANT_IMPL_HH_ */