Flow123d  JS_before_hm-1016-g09ec2cb
field_values.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_values.hh
15  * @brief
16  */
17 
18 #ifndef FIELD_VALUES_HH_
19 #define FIELD_VALUES_HH_
20 
21 #include <string.h> // for memcpy
22 #include <boost/core/explicit_operator_bool.hpp> // for optional::oper...
23 #include <boost/optional/optional.hpp> // for get_pointer
24 #include <cmath> // for abs
25 #include <cstdlib> // for abs
26 #include <limits> // for numeric_limits
27 #include <new> // for operator new[]
28 #include <ostream> // for operator&, ope...
29 #include <string> // for basic_string
30 #include <system/exceptions.hh> // for THROW, ExcStream
31 #include <type_traits> // for is_floating_point
32 #include <vector> // for vector
33 #include <armadillo>
34 
35 #include "system/fmt/format.h"
36 #include "input/accessors.hh" // for Array, Iterator
37 #include "input/accessors_impl.hh" // for Array::size
38 #include "input/input_exception.hh" // for ExcFV_Input::~...
39 #include "input/type_base.hh" // for Array, String
40 #include "input/type_generic.hh" // for Parameter
41 #include "input/type_selection.hh" // for Selection
42 #include "system/armor.hh" // for Armor::Array
43 
44 namespace IT=Input::Type;
45 
46 /**
47  * @file
48  *
49  * This file contains various dispatch classes to simplify implementation of Fields. Essential is class template
50  * @p FieldValues_ which provides unified access and initialization to scalar, vector and matrix type object in Armadillo library
51  */
52 
53 TYPEDEF_ERR_INFO( EI_InputMsg, const string );
54 DECLARE_INPUT_EXCEPTION( ExcFV_Input, << "Wrong field value input: " << EI_InputMsg::val );
55 
56 typedef unsigned int FieldEnum;
57 
58 
59 
60 namespace internal {
61 
62 // Helper functions to get scalar type name
63 /*
64 std::string type_name_(double);
65 std::string type_name_(int);
66 std::string type_name_(FieldEnum);
67 */
68 
69 /**
70  * InputType dispatch from elementary type @p ET of FieldValues_ to elementary Input::Type, i.e. descendant of Input::Type::Scalar.
71  */
72 template <class ET>
73 struct InputType { typedef Input::Type::Double type; };
74 
75 template <>
76 struct InputType<int> { typedef Input::Type::Integer type; };
77 
78 template <>
80 
81 
82 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
83 // resolution of Value::return_type
84 
85 // general element type
86 template<int NRows, int NCols, class ET>
87 struct ReturnType { typedef typename arma::Mat<ET>::template fixed<NRows, NCols> return_type; };
88 
89 template<class ET>
90 struct ReturnType<1,1,ET> { typedef ET return_type; };
91 
92 template <class ET>
93 struct ReturnType<0,1,ET> { typedef arma::Col<ET> return_type; };
94 
95 template <int NRows, class ET>
96 struct ReturnType<NRows,1,ET> { typedef typename arma::Col<ET>::template fixed<NRows> return_type; };
97 
98 
99 // FiledEnum element type - this just returns types with ET=unsigned int, however input should be different
100 template<int NRows, int NCols>
101 struct ReturnType<NRows, NCols, FieldEnum> { typedef typename arma::Mat<unsigned int>::template fixed<NRows, NCols> return_type; };
102 
103 template<>
104 struct ReturnType<1,1, FieldEnum> { typedef unsigned int return_type; };
105 
106 template <>
107 struct ReturnType<0,1, FieldEnum> { typedef arma::Col<unsigned int> return_type; };
108 
109 template <int NRows>
110 struct ReturnType<NRows,1, FieldEnum> { typedef typename arma::Col<unsigned int>::template fixed<NRows> return_type; };
111 
112 
113 // Resolution of helper functions for raw constructor
114 template <class RT> inline RT & set_raw_scalar(RT &, double *raw_data) { return *raw_data;}
115 template <class RT> inline RT & set_raw_scalar(RT &, int *raw_data) { return *raw_data;}
116 template <class RT> inline RT & set_raw_scalar(RT &, FieldEnum *raw_data) { return *raw_data;}
117 
118 template <class RT> inline RT & set_raw_vec(RT &val, double *raw_data) { arma::access::rw(val.mem) = raw_data; return val;}
119 template <class RT> inline RT & set_raw_vec(RT &val, int *raw_data) { arma::access::rw(val.mem) = raw_data; return val;}
120 template <class RT> inline RT & set_raw_vec(RT &val, FieldEnum *raw_data) { arma::access::rw(val.mem) = raw_data; return val;}
121 
122 template <class RT> inline RT & set_raw_fix(RT &val, double *raw_data) { val = RT(raw_data); return val;}
123 template <class RT> inline RT & set_raw_fix(RT &val, int *raw_data) { val = RT(raw_data); return val;}
124 template <class RT> inline RT & set_raw_fix(RT &val, FieldEnum *raw_data) { val = RT(raw_data); return val;}
125 
126 
127 
128 // Resolution of input accessor for vector values of enums,
129 template <class ET>
130 struct AccessTypeDispatch { typedef ET type;};
131 template <>
132 struct AccessTypeDispatch<unsigned int> { typedef Input::Enum type; };
133 
134 
135 
136 
137 /**
138  * Initialize an Armadillo matrix from the input.
139  * Since only limited methods are used we can use this template to initialize StringTensor as well.
140  * Used methodas are: at(row,col), zeros()
141  */
142 template<class MatrixType>
143 void init_matrix_from_input( MatrixType &value, Input::Array rec ) {
144  typedef typename MatrixType::elem_type ET;
145  unsigned int nrows = value.n_rows;
146  unsigned int ncols = value.n_cols;
147 
149  if (it->size() == 1 && nrows == ncols) {
150  // square tensor
151  // input = 3 expands to [ [ 3 ] ]; init to 3 * (identity matrix)
152  // input = [1, 2, 3] expands to [[1], [2], [3]]; init to diag. matrix
153  // input = [1, 2, 3, .. , (N+1)*N/2], .... ; init to symmetric matrix [ [1 ,2 ,3], [2, 4, 5], [ 3, 5, 6] ]
154  if (rec.size() == 1) {// scalar times identity
155  value.zeros();
156  ET scalar=*(it->begin<ET>());
157  for(unsigned int i=0; i< nrows; i++) value.at(i,i)=scalar;
158  } else if (rec.size() == nrows) { // diagonal vector
159  value.zeros();
160  for(unsigned int i=0; i< nrows; i++, ++it) value.at(i,i)=*(it->begin<ET>());
161  } else if (rec.size() == (nrows+1)*nrows/2) { // symmetric part
162  for( unsigned int row=0; row<nrows; row++)
163  for( unsigned int col=0; col<ncols; col++)
164  if (row <= col) {
165  value.at(row,col) = *(it->begin<ET>());
166  ++it;
167  } else value.at(row,col) = value.at(col,row);
168  } else {
169  THROW( ExcFV_Input()
170  << EI_InputMsg(
171  fmt::format("Initializing symmetric matrix {:d}x{:d} by vector of wrong size {:d}, "
172  "should be 1, {:d}, or {:d}.",
173  nrows, ncols, rec.size(), nrows, (nrows+1)*nrows/2))
174  << rec.ei_address()
175 
176  );
177  }
178 
179  } else {
180  // accept only full tensor
181  if (rec.size() == nrows && it->size() == ncols) {
182 
183  for (unsigned int row = 0; row < nrows; row++, ++it) {
184  if (it->size() != ncols)
185  THROW( ExcFV_Input() << EI_InputMsg("Wrong number of columns.")
186  << rec.ei_address());
187  Input::Iterator<ET> col_it = it->begin<ET>();
188  for (unsigned int col = 0; col < ncols; col++, ++col_it)
189  value.at(row, col) = *col_it;
190  }
191  } else {
192  THROW( ExcFV_Input()
193  << EI_InputMsg(
194  fmt::format("Initializing symmetric matrix {:d}x{:d} by vector of wrong size {:d}x{:d}.",
195  nrows, ncols, rec.size(), it->size()))
196  << rec.ei_address()
197  );
198  }
199  }
200 }
201 
202 /**
203  * Initialize an Armadillo vector from the input.
204  * Since only limited methods are used we can use this template to initialize StringTensor as well.
205  * Used methodas are: at(row,col), zeros()
206  */
207 template<class VectorType>
208 void init_vector_from_input( VectorType &value, Input::Array rec ) {
209  typedef typename VectorType::elem_type ET;
210  unsigned int nrows = value.n_rows;
211 
212  typedef typename AccessTypeDispatch<ET>::type InnerType;
213  Input::Iterator<InnerType> it = rec.begin<InnerType>();
214 
215  if ( rec.size() == 1 ) {
216  for(unsigned int i=0; i< nrows; i++)
217  value.at(i)=ET(*it);
218  } else if ( rec.size() == nrows ) {
219  for(unsigned int i=0; i< nrows; i++, ++it) {
220  value.at(i)=ET(*it);
221  }
222  } else {
223  THROW( ExcFV_Input()
224  << EI_InputMsg(
225  fmt::format("Initializing vector of size {:d} by vector of size {%d.}",
226  nrows, rec.size()))
227  << rec.ei_address()
228  );
229  }
230 }
231 
232 
233 
234 } // namespace internal
235 
236 
237 
238 /**
239  * Template for class representing all possible Filed values. It is just common interface to
240  * scalar (double, int) values, vector and tensor values with fixed size and vector/tensor values with variable size.
241  *
242  * ET is type of elements, n_cols and n_rows gives fixed dimensions of the tensor value (nx1 is vector, 1x1 is scalar,
243  * 0x1 is variable size vector, 0x0 is variable size tensor (not implemented yet) )
244  *
245  *
246  */
247 template <int NRows, int NCols, class ET>
248 class FieldValue_ {
249 public:
250  typedef ET element_type;
254  const static int NRows_ = NRows;
255  const static int NCols_ = NCols;
256  const static int rank_ = 2;
257 
258  static std::string type_name() { return fmt::format("R[{:d},{:d}]", NRows, NCols); }
260  if (NRows == NCols) {
261  // for square tensors allow initialization by diagonal vector, etc.
262  return IT::Array( IT::Array( IT::Parameter("element_input_type"), 1), 1 );
263  }
264  else {
265  return IT::Array( IT::Array( IT::Parameter("element_input_type"), NCols, NCols), NRows, NRows );
266  }
267 
268  }
269  static constexpr bool is_scalable() {
271  }
272 
273 
274  inline FieldValue_(return_type &val) : value_(val) {}
275  inline static const return_type &from_raw(return_type &val, ET *raw_data) {return internal::set_raw_fix(val, raw_data);}
276  const ET * mem_ptr() const {
277  return value_.memptr();
278  }
279 
280  /// Casts value stored in Armor::Array to return type.
281  inline static return_type get_from_array(const Armor::Array<element_type> &arr, uint idx) {
282  return arr.template mat<NRows, NCols>(idx);
283  }
284 
285  void init_from_input( AccessType rec ) {
287  }
288 
289  void set_n_comp(unsigned int) {};
290  inline unsigned int n_cols() const
291  { return NCols; }
292  inline unsigned int n_rows() const
293  { return NRows; }
294  inline ET &operator() ( unsigned int i, unsigned int j)
295  { return value_.at(i,j); }
296  inline ET operator() ( unsigned int i, unsigned int j) const
297  { return value_.at(i,j); }
298  inline operator return_type() const
299  { return value_;}
300 
301  // Set value to matrix of zeros.
302  void zeros() {
303  value_.zeros();
304  }
305  // Set value to identity matrix.
306  void eye() {
307  value_.eye();
308  }
309  // Set value to matrix of ones.
310  void ones() {
311  value_.ones();
312  }
313  // Elementwise equivalence.
314  bool equal_to(const return_type &other) {
315  return arma::max(arma::max(arma::abs(value_ - other))) < 4*std::numeric_limits<ET>::epsilon();
316  }
317  // Multiplied value_ by double coefficient
318  void scale(double scale_coef) {
319  if (is_scalable())
320  for( unsigned int row=0; row<n_rows(); row++)
321  for( unsigned int col=0; col<n_cols(); col++)
322  value_.at(row,col) = scale_coef * value_.at(row,col);
323  }
324 
325 private:
326  return_type &value_;
327 };
328 
329 
330 
331 
332 
333 /// **********************************************************************
334 /// Specialization for scalars
335 template <class ET>
336 class FieldValue_<1,1,ET> {
337 public:
338  typedef ET element_type;
342  const static int NRows_ = 1;
343  const static int NCols_ = 1;
344  const static int rank_ = 0;
345 
346  static std::string type_name() { return "R"; }
348  {
349  return IT::Parameter("element_input_type");
350  }
351  static constexpr bool is_scalable() {
353  }
354 
355  inline FieldValue_(return_type &val) : value_(val) {}
356 
357  /**
358  * Returns reference to the return_type (i.e. double, or arma::vec or arma::mat); with data provided by the parameter @p raw_data.
359  * A reference to a work space @p val has to be provided for efficient work with vector and matrix values.
360  */
361  inline static const return_type &from_raw(return_type &val, ET *raw_data) {return internal::set_raw_scalar(val, raw_data);}
362  const ET * mem_ptr() const { return &(value_); }
363 
364  /// Casts value stored in Armor::Array to return type.
365  inline static return_type get_from_array(const Armor::Array<element_type> &arr, uint idx) {
366  return arr.scalar(idx);
367  }
368 
369  void init_from_input( AccessType val ) { value_ = return_type(val); }
370 
371  void set_n_comp(unsigned int) {};
372  inline unsigned int n_cols() const
373  { return 1; }
374  inline unsigned int n_rows() const
375  { return 1; }
376  inline ET &operator() ( unsigned int, unsigned int )
377  { return value_; }
378  inline ET operator() ( unsigned int, unsigned int) const
379  { return value_; }
380  inline operator return_type() const
381  { return value_;}
382 
383  // Set value to matrix of zeros.
384  void zeros() {
385  value_=0;
386  }
387  // Set value to identity matrix.
388  void eye() {
389  value_=1;
390  }
391  // Set value to matrix of ones.
392  void ones() {
393  value_=1;
394  }
395  bool equal_to(const return_type &other) {
396  return std::abs((double)value_ - other) < 4*std::numeric_limits<ET>::epsilon();
397  }
398  // Multiplied value_ by double coefficient
399  void scale(double scale_coef) {
400  if (is_scalable())
401  value_ = scale_coef * value_;
402  }
403 
404 private:
405  return_type &value_;
406 };
407 
408 
409 
410 
411 /// **********************************************************************
412 /// Specialization for variable size vectors
413 template <class ET>
414 class FieldValue_<0,1,ET> {
415 public:
416  typedef ET element_type;
420  const static int NRows_ = 0;
421  const static int NCols_ = 1;
422  const static int rank_ = 10;
423 
424 
425  static std::string type_name() { return "R[n]"; }
427  return IT::Array( IT::Parameter("element_input_type"), 1);
428  }
429  static constexpr bool is_scalable() {
431  }
432  inline static const return_type &from_raw(return_type &val, ET *raw_data) {return internal::set_raw_vec(val, raw_data);}
433  const ET * mem_ptr() const { return value_.memptr(); }
434 
435  /// Casts value stored in Armor::Array to return type.
436  inline static return_type get_from_array(const Armor::Array<element_type> &arr, uint idx) {
437  return arr.template vec<NRows_>(idx);
438  }
439 
440  inline FieldValue_(return_type &val) : value_(val) {}
441 
442 
443  void init_from_input( AccessType rec ) {
445  }
446 
447  void set_n_comp(unsigned int n_comp) { value_ = return_type(n_comp,1); };
448  inline unsigned int n_cols() const
449  { return 1; }
450  inline unsigned int n_rows() const
451  { return value_.n_rows; }
452  inline ET &operator() ( unsigned int i, unsigned int )
453  { return value_.at(i); }
454  inline ET operator() ( unsigned int i, unsigned int ) const
455  { return value_.at(i); }
456 
457  inline operator return_type() const
458  { return value_;}
459 
460  // Set value to matrix of zeros.
461  void zeros() {
462  value_.zeros();
463  }
464  // Set value to identity matrix.
465  void eye() {
466  value_.ones();
467  }
468  // Set value to matrix of ones.
469  void ones() {
470  value_.ones();
471  }
472  // Elementwise equivalence.
473  bool equal_to(const return_type &other) {
474  return arma::max(arma::abs(value_ - other)) < 4*std::numeric_limits<ET>::epsilon();
475  }
476  // Multiplied value_ by double coefficient
477  void scale(double scale_coef) {
478  if (is_scalable())
479  for(unsigned int i=0; i< n_rows(); i++) {
480  value_.at(i) = scale_coef * value_.at(i);
481  }
482  }
483 
484 
485 private:
486  return_type &value_;
487 };
488 
489 /// **********************************************************************
490 /// Specialization for fixed size vectors
491 template <int NRows, class ET>
492 class FieldValue_<NRows,1,ET> {
493 public:
494  typedef ET element_type;
498  const static int NRows_ = NRows;
499  const static int NCols_ = 1;
500  const static int rank_ = 1;
501 
502 
503  static std::string type_name() { return fmt::format("R[{:d}]", NRows); }
505  return IT::Array( IT::Parameter("element_input_type"), 1, NRows);
506  }
507  static constexpr bool is_scalable() {
509  }
510 
511  inline FieldValue_(return_type &val) : value_(val) {}
512  inline static const return_type &from_raw(return_type &val, ET *raw_data) {return internal::set_raw_fix(val, raw_data);}
513  const ET * mem_ptr() const { return value_.memptr(); }
514 
515  /// Casts value stored in Armor::Array to return type.
516  inline static return_type get_from_array(const Armor::Array<element_type> &arr, uint idx) {
517  return arr.template vec<NRows>(idx);
518  }
519 
520  void init_from_input( AccessType rec ) {
522  }
523 
524  void set_n_comp(unsigned int) {};
525  inline unsigned int n_cols() const
526  { return 1; }
527  inline unsigned int n_rows() const
528  { return NRows; }
529  inline ET &operator() ( unsigned int i, unsigned int )
530  { return value_.at(i); }
531  inline ET operator() ( unsigned int i, unsigned int ) const
532  { return value_.at(i); }
533 
534  inline operator return_type() const
535  { return value_;}
536 
537  // Set value to matrix of zeros.
538  void zeros() {
539  value_.zeros();
540  }
541  // Set value to identity matrix.
542  void eye() {
543  value_.ones();
544  }
545  // Set value to matrix of ones.
546  void ones() {
547  value_.ones();
548  }
549  // Elementwise equivalence.
550  bool equal_to(const return_type &other) {
551  return arma::max(arma::abs(value_ - other)) < 4*std::numeric_limits<ET>::epsilon();
552  }
553  // Multiplied value_ by double coefficient
554  void scale(double scale_coef) {
555  if (is_scalable())
556  for(unsigned int i=0; i< n_rows(); i++) {
557  value_.at(i) = scale_coef * value_.at(i);
558  }
559  }
560 
561 private:
562  return_type &value_;
563 };
564 
565 
566 
567 //****************************************************************************
568 // string tensor (for FieldFormula)
569 
570 
571 /**
572  * Mimics arma::mat<std::string>. Used in FieldFormula
573  */
575 public:
576  typedef std::string elem_type;
577 
578  StringTensor( unsigned int n_rows, unsigned int n_cols )
579  : n_rows(n_rows),n_cols(n_cols), values_(n_rows*n_cols) {}
580 
581  std::string & at(unsigned int row) { return at(row,0); }
582  std::string & at(unsigned int row, unsigned int col) { return values_[col*n_rows+row]; }
583 
584  void zeros() {
585  for( auto &elem: values_) elem = "0.0";
586  }
587  unsigned int n_rows;
588  unsigned int n_cols;
589 private:
591 
592 };
593 
594 
595 template<int NRows, int NCols>
597 {
600  if (NRows == NCols) {
601  // for square tensors allow initialization by diagonal vector, etc.
602  return IT::Array( IT::Array( IT::String(), 1), 1 );
603  }
604  else {
605  return IT::Array( IT::Array( IT::String(), NCols, NCols), NRows, NRows );
606  }
607 
608  }
609 
610  static void init_from_input(StringTensor &tensor, AccessType input) {
611  internal::init_matrix_from_input(tensor, input);
612  }
613 };
614 
615 template<>
616 struct StringTensorInput<1,1> {
617  typedef std::string AccessType;
618  static IT::String get_input_type() { return IT::String(); }
619  static void init_from_input(StringTensor &tensor, AccessType input) {
620  tensor.at(0,0) = input;
621  }
622 };
623 
624 template<int Nrows>
625 struct StringTensorInput<Nrows,1> {
628  return IT::Array( IT::String(), 1);
629  }
630  static void init_from_input(StringTensor &tensor, AccessType input) {
631  internal::init_vector_from_input(tensor, input);
632  }
633 };
634 
635 
636 
637 
638 /**
639  * Class that provides common template-less interface to all templated Field structes.
640  *
641  * Maybe we can delete this since common interface will be given by "Quantity".
642  */
643 
644 template <int spacedim>
645 struct FieldValue {
646  // typedefs for possible field values
655 };
656 
657 
658 
659 
660 
661 
662 
663 
664 
665 
666 #endif /* FIELD_VALUES_HH_ */
void init_from_input(AccessType val)
internal::ReturnType< 1, 1, ET >::return_type return_type
Iterator< ValueType > begin() const
internal::InputType< ET >::type ElementInputType
Accessor to input data conforming to declared Array.
Definition: accessors.hh:566
static const return_type & from_raw(return_type &val, ET *raw_data)
static IT::Array get_input_type()
EI_Address ei_address() const
Definition: accessors.cc:314
void set_n_comp(unsigned int)
unsigned int uint
arma::Col< unsigned int > return_type
std::vector< std::string > values_
static void init_from_input(StringTensor &tensor, AccessType input)
RT & set_raw_scalar(RT &, double *raw_data)
internal::InputType< ET >::type ElementInputType
static void init_from_input(StringTensor &tensor, AccessType input)
bool equal_to(const return_type &other)
FieldValue_< 0, 1, int > IntVector
static return_type get_from_array(const Armor::Array< element_type > &arr, uint idx)
Casts value stored in Armor::Array to return type.
static const return_type & from_raw(return_type &val, ET *raw_data)
void set_n_comp(unsigned int n_comp)
std::string format(CStringRef format_str, ArgList args)
Definition: format.h:3141
const ET * mem_ptr() const
void set_n_comp(unsigned int)
void init_from_input(AccessType rec)
void scale(double scale_coef)
Class for representing parametric types in IST.
Definition: type_generic.hh:53
static std::string type_name()
RT & set_raw_vec(RT &val, double *raw_data)
void set_n_comp(unsigned int)
unsigned int n_cols() const
internal::ReturnType< NRows, NCols, ET >::return_type return_type
FieldValue_(return_type &val)
void init_from_input(AccessType rec)
Input::Type::Selection type
Definition: field_values.hh:79
static return_type get_from_array(const Armor::Array< element_type > &arr, uint idx)
Casts value stored in Armor::Array to return type.
FieldValue_< 1, 1, FieldEnum > Enum
Class for declaration of the integral input data.
Definition: type_base.hh:483
void init_matrix_from_input(MatrixType &value, Input::Array rec)
void init_from_input(AccessType rec)
Class for declaration of inputs sequences.
Definition: type_base.hh:339
static constexpr bool value
Definition: json.hpp:87
arma::Col< unsigned int >::template fixed< NRows > return_type
StringTensor(unsigned int n_rows, unsigned int n_cols)
internal::InputType< ET >::type ElementInputType
static IT::Array get_input_type()
Type scalar(uint mat_index) const
Definition: armor.hh:814
Class for declaration of the input data that are floating point numbers.
Definition: type_base.hh:534
static std::string type_name()
FieldValue_< 0, 1, FieldEnum > EnumVector
std::string elem_type
unsigned int FieldEnum
Definition: field_values.hh:56
const ET * mem_ptr() const
static constexpr bool is_scalable()
unsigned int n_rows
internal::InputType< ET >::type ElementInputType
const ET * mem_ptr() const
internal::ReturnType< NRows, 1, ET >::return_type return_type
void scale(double scale_coef)
bool equal_to(const return_type &other)
static constexpr bool is_scalable()
return_type & value_
std::string & at(unsigned int row, unsigned int col)
FieldValue_< spacedim, 1, double > VectorFixed
bool equal_to(const return_type &other)
static IT::Array get_input_type()
void init_vector_from_input(VectorType &value, Input::Array rec)
static std::string type_name()
unsigned int n_rows() const
RT & set_raw_fix(RT &val, double *raw_data)
arma::Mat< ET >::template fixed< NRows, NCols > return_type
Definition: field_values.hh:87
static void init_from_input(StringTensor &tensor, AccessType input)
internal::ReturnType< 0, 1, ET >::return_type return_type
static constexpr bool is_scalable()
TYPEDEF_ERR_INFO(EI_InputMsg, const string)
std::string & at(unsigned int row)
unsigned int n_cols() const
static IT::Array get_input_type()
unsigned int n_rows() const
Input::Type::Integer type
Definition: field_values.hh:76
arma::Mat< unsigned int >::template fixed< NRows, NCols > return_type
unsigned int n_cols() const
void scale(double scale_coef)
Input::Type::Double type
Definition: field_values.hh:73
unsigned int n_cols
FieldValue_< 1, 1, int > Integer
FieldValue_(return_type &val)
FieldValue_< 0, 1, double > Vector
internal::AccessTypeDispatch< ET >::type AccessType
static std::string type_name()
DECLARE_INPUT_EXCEPTION(ExcFV_Input,<< "Wrong field value input: "<< EI_InputMsg::val)
static const return_type & from_raw(return_type &val, ET *raw_data)
FieldValue_(return_type &val)
static IT::Array get_input_type()
void scale(double scale_coef)
unsigned int size() const
Input::Array AccessType
static const return_type & from_raw(return_type &val, ET *raw_data)
FieldValue_< spacedim, spacedim, double > TensorFixed
unsigned int n_rows() const
Input::Array AccessType
unsigned int n_cols() const
arma::Col< ET >::template fixed< NRows > return_type
Definition: field_values.hh:96
Class for declaration of the input data that are in string format.
Definition: type_base.hh:582
#define THROW(whole_exception_expr)
Wrapper for throw. Saves the throwing point.
Definition: exceptions.hh:53
static return_type get_from_array(const Armor::Array< element_type > &arr, uint idx)
Casts value stored in Armor::Array to return type.
static return_type get_from_array(const Armor::Array< element_type > &arr, uint idx)
Casts value stored in Armor::Array to return type.
static IT::Parameter get_input_type()
Template for classes storing finite set of named values.
static IT::String get_input_type()
FieldValue_< 1, 1, double > Scalar
const ET * mem_ptr() const
bool equal_to(const return_type &other)
FieldValue_(return_type &val)
unsigned int n_rows() const
static constexpr bool is_scalable()