Flow123d  3.9.1-60c7e5c
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.
282  return arr.template mat<NRows, NCols>(idx);
283  }
284 
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:
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.
366  return arr.scalar(idx);
367  }
368 
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:
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.
437  return arr.template vec<NRows_>(idx);
438  }
439 
440  inline FieldValue_(return_type &val) : value_(val) {}
441 
442 
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:
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.
517  return arr.template vec<NRows>(idx);
518  }
519 
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:
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 )
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_ */
internal::ReturnType< 0, 1, ET >::return_type
arma::Col< ET > return_type
Definition: field_values.hh:93
FieldValue::Scalar
FieldValue_< 1, 1, double > Scalar
Definition: field_values.hh:650
FieldValue_< 0, 1, ET >::value_
return_type & value_
Definition: field_values.hh:486
internal::InputType::type
Input::Type::Double type
Definition: field_values.hh:73
FieldValue_::init_from_input
void init_from_input(AccessType rec)
Definition: field_values.hh:285
StringTensor::zeros
void zeros()
Definition: field_values.hh:584
FieldValue_::operator()
ET & operator()(unsigned int i, unsigned int j)
Definition: field_values.hh:294
FieldValue_< NRows, 1, ET >::set_n_comp
void set_n_comp(unsigned int)
Definition: field_values.hh:524
armor.hh
FieldValue_::value_
return_type & value_
Definition: field_values.hh:326
StringTensorInput< Nrows, 1 >::get_input_type
static IT::Array get_input_type()
Definition: field_values.hh:627
FieldValue_::element_type
ET element_type
Definition: field_values.hh:250
StringTensorInput::get_input_type
static IT::Array get_input_type()
Definition: field_values.hh:599
StringTensorInput< Nrows, 1 >::AccessType
Input::Array AccessType
Definition: field_values.hh:626
internal::AccessTypeDispatch::type
ET type
Definition: field_values.hh:130
FieldValue_::AccessType
Input::Array AccessType
Definition: field_values.hh:253
FieldValue_< 0, 1, ET >::return_type
internal::ReturnType< 0, 1, ET >::return_type return_type
Definition: field_values.hh:417
FieldValue_< 1, 1, ET >::n_cols
unsigned int n_cols() const
Definition: field_values.hh:372
internal::ReturnType< 1, 1, FieldEnum >::return_type
unsigned int return_type
Definition: field_values.hh:104
StringTensorInput< 1, 1 >::get_input_type
static IT::String get_input_type()
Definition: field_values.hh:618
FieldValue_::from_raw
static const return_type & from_raw(return_type &val, ET *raw_data)
Definition: field_values.hh:275
FieldValue_< NRows, 1, ET >::is_scalable
static constexpr bool is_scalable()
Definition: field_values.hh:507
FieldValue_< 0, 1, ET >::init_from_input
void init_from_input(AccessType rec)
Definition: field_values.hh:443
string.h
FieldValue_< 1, 1, ET >::equal_to
bool equal_to(const return_type &other)
Definition: field_values.hh:395
format.h
Input::Type::Integer
Class for declaration of the integral input data.
Definition: type_base.hh:483
FieldEnum
unsigned int FieldEnum
Definition: field_values.hh:56
StringTensor::StringTensor
StringTensor(unsigned int n_rows, unsigned int n_cols)
Definition: field_values.hh:578
value
static constexpr bool value
Definition: json.hpp:87
FieldValue_< 0, 1, ET >::eye
void eye()
Definition: field_values.hh:465
Input::Type::Double
Class for declaration of the input data that are floating point numbers.
Definition: type_base.hh:534
FieldValue::IntVector
FieldValue_< 0, 1, int > IntVector
Definition: field_values.hh:653
FieldValue_< 1, 1, ET >::get_from_array
static return_type get_from_array(const Armor::Array< element_type > &arr, uint idx)
Casts value stored in Armor::Array to return type.
Definition: field_values.hh:365
FieldValue_< 0, 1, ET >::ElementInputType
internal::InputType< ET >::type ElementInputType
Definition: field_values.hh:418
THROW
#define THROW(whole_exception_expr)
Wrapper for throw. Saves the throwing point.
Definition: exceptions.hh:53
std::vector< std::string >
FieldValue::Enum
FieldValue_< 1, 1, FieldEnum > Enum
Definition: field_values.hh:648
FieldValue_< 1, 1, ET >::value_
return_type & value_
Definition: field_values.hh:405
FieldValue_< 0, 1, ET >::ones
void ones()
Definition: field_values.hh:469
FieldValue_< 0, 1, ET >::element_type
ET element_type
Definition: field_values.hh:416
internal::ReturnType
Definition: field_values.hh:87
FieldValue_< 0, 1, ET >::zeros
void zeros()
Definition: field_values.hh:461
StringTensorInput
Definition: field_values.hh:596
uint
unsigned int uint
Definition: mh_dofhandler.hh:101
internal::ReturnType::return_type
arma::Mat< ET >::template fixed< NRows, NCols > return_type
Definition: field_values.hh:87
FieldValue_< NRows, 1, ET >::from_raw
static const return_type & from_raw(return_type &val, ET *raw_data)
Definition: field_values.hh:512
type_base.hh
fmt::format
std::string format(CStringRef format_str, ArgList args)
Definition: format.h:3141
FieldValue_< 1, 1, ET >::AccessType
internal::AccessTypeDispatch< ET >::type AccessType
Definition: field_values.hh:341
internal::ReturnType< NRows, NCols, FieldEnum >::return_type
arma::Mat< unsigned int >::template fixed< NRows, NCols > return_type
Definition: field_values.hh:101
type_selection.hh
FieldValue::EnumVector
FieldValue_< 0, 1, FieldEnum > EnumVector
Definition: field_values.hh:649
internal::ReturnType< 1, 1, ET >::return_type
ET return_type
Definition: field_values.hh:90
Input::Array::begin
Iterator< ValueType > begin() const
Definition: accessors_impl.hh:145
internal::InputType< FieldEnum >::type
Input::Type::Selection type
Definition: field_values.hh:79
StringTensor::values_
std::vector< std::string > values_
Definition: field_values.hh:590
FieldValue_< 0, 1, ET >::get_from_array
static return_type get_from_array(const Armor::Array< element_type > &arr, uint idx)
Casts value stored in Armor::Array to return type.
Definition: field_values.hh:436
exceptions.hh
internal::set_raw_fix
RT & set_raw_fix(RT &val, double *raw_data)
Definition: field_values.hh:122
FieldValue_< 0, 1, ET >::FieldValue_
FieldValue_(return_type &val)
Definition: field_values.hh:440
FieldValue_::get_input_type
static IT::Array get_input_type()
Definition: field_values.hh:259
FieldValue_< 0, 1, ET >::n_rows
unsigned int n_rows() const
Definition: field_values.hh:450
StringTensorInput< 1, 1 >::AccessType
std::string AccessType
Definition: field_values.hh:617
FieldValue_< 1, 1, ET >::FieldValue_
FieldValue_(return_type &val)
Definition: field_values.hh:355
Input::Iterator
Definition: accessors.hh:143
FieldValue_< 0, 1, ET >::is_scalable
static constexpr bool is_scalable()
Definition: field_values.hh:429
FieldValue_::type_name
static std::string type_name()
Definition: field_values.hh:258
FieldValue_< 0, 1, ET >::n_cols
unsigned int n_cols() const
Definition: field_values.hh:448
internal::InputType
Definition: field_values.hh:73
FieldValue_::set_n_comp
void set_n_comp(unsigned int)
Definition: field_values.hh:289
DECLARE_INPUT_EXCEPTION
DECLARE_INPUT_EXCEPTION(ExcFV_Input,<< "Wrong field value input: "<< EI_InputMsg::val)
FieldValue_< NRows, 1, ET >::get_input_type
static IT::Array get_input_type()
Definition: field_values.hh:504
FieldValue_< NRows, 1, ET >::mem_ptr
const ET * mem_ptr() const
Definition: field_values.hh:513
type_generic.hh
StringTensor::at
std::string & at(unsigned int row)
Definition: field_values.hh:581
FieldValue_::n_rows
unsigned int n_rows() const
Definition: field_values.hh:292
accessors.hh
FieldValue_::equal_to
bool equal_to(const return_type &other)
Definition: field_values.hh:314
FieldValue_::scale
void scale(double scale_coef)
Definition: field_values.hh:318
FieldValue_< NRows, 1, ET >::ElementInputType
internal::InputType< ET >::type ElementInputType
Definition: field_values.hh:496
FieldValue_< 1, 1, ET >::type_name
static std::string type_name()
Definition: field_values.hh:346
FieldValue_::ElementInputType
internal::InputType< ET >::type ElementInputType
Definition: field_values.hh:252
internal::set_raw_vec
RT & set_raw_vec(RT &val, double *raw_data)
Definition: field_values.hh:118
internal::ReturnType< 0, 1, FieldEnum >::return_type
arma::Col< unsigned int > return_type
Definition: field_values.hh:107
FieldValue_::get_from_array
static return_type get_from_array(const Armor::Array< element_type > &arr, uint idx)
Casts value stored in Armor::Array to return type.
Definition: field_values.hh:281
FieldValue_< 0, 1, ET >::AccessType
Input::Array AccessType
Definition: field_values.hh:419
FieldValue::VectorFixed
FieldValue_< spacedim, 1, double > VectorFixed
Definition: field_values.hh:651
Input::Array::size
unsigned int size() const
Definition: accessors_impl.hh:163
FieldValue_::mem_ptr
const ET * mem_ptr() const
Definition: field_values.hh:276
input_exception.hh
FieldValue_< 1, 1, ET >::ones
void ones()
Definition: field_values.hh:392
FieldValue_< 0, 1, ET >::set_n_comp
void set_n_comp(unsigned int n_comp)
Definition: field_values.hh:447
FieldValue_< 1, 1, ET >::init_from_input
void init_from_input(AccessType val)
Definition: field_values.hh:369
FieldValue_::eye
void eye()
Definition: field_values.hh:306
internal::InputType< int >::type
Input::Type::Integer type
Definition: field_values.hh:76
Input::Type::Selection
Template for classes storing finite set of named values.
Definition: type_selection.hh:65
FieldValue_< 1, 1, ET >::from_raw
static const return_type & from_raw(return_type &val, ET *raw_data)
Definition: field_values.hh:361
FieldValue_
Definition: field_values.hh:248
FieldValue_< 1, 1, ET >::set_n_comp
void set_n_comp(unsigned int)
Definition: field_values.hh:371
FieldValue::Integer
FieldValue_< 1, 1, int > Integer
Definition: field_values.hh:647
FieldValue_< 0, 1, ET >::mem_ptr
const ET * mem_ptr() const
Definition: field_values.hh:433
Input::Type
Definition: balance.hh:41
internal::ReturnType< NRows, 1, FieldEnum >::return_type
arma::Col< unsigned int >::template fixed< NRows > return_type
Definition: field_values.hh:110
StringTensorInput::AccessType
Input::Array AccessType
Definition: field_values.hh:598
FieldValue_< 0, 1, ET >::from_raw
static const return_type & from_raw(return_type &val, ET *raw_data)
Definition: field_values.hh:432
FieldValue_::NRows_
const static int NRows_
Definition: field_values.hh:254
FieldValue_< 0, 1, ET >::scale
void scale(double scale_coef)
Definition: field_values.hh:477
FieldValue_< 0, 1, ET >::equal_to
bool equal_to(const return_type &other)
Definition: field_values.hh:473
FieldValue_< NRows, 1, ET >::n_cols
unsigned int n_cols() const
Definition: field_values.hh:525
FieldValue_< NRows, 1, ET >::ones
void ones()
Definition: field_values.hh:546
FieldValue_< NRows, 1, ET >::type_name
static std::string type_name()
Definition: field_values.hh:503
FieldValue_< NRows, 1, ET >::n_rows
unsigned int n_rows() const
Definition: field_values.hh:527
FieldValue_::zeros
void zeros()
Definition: field_values.hh:302
FieldValue::Vector
FieldValue_< 0, 1, double > Vector
Definition: field_values.hh:652
StringTensor::n_rows
unsigned int n_rows
Definition: field_values.hh:587
FieldValue_< NRows, 1, ET >::value_
return_type & value_
Definition: field_values.hh:562
StringTensor::elem_type
std::string elem_type
Definition: field_values.hh:576
Input::Type::Array
Class for declaration of inputs sequences.
Definition: type_base.hh:339
accessors_impl.hh
internal::AccessTypeDispatch
Definition: field_values.hh:130
Input::Type::String
Class for declaration of the input data that are in string format.
Definition: type_base.hh:582
StringTensorInput< Nrows, 1 >::init_from_input
static void init_from_input(StringTensor &tensor, AccessType input)
Definition: field_values.hh:630
FieldValue_::n_cols
unsigned int n_cols() const
Definition: field_values.hh:290
FieldValue_< 0, 1, ET >::get_input_type
static IT::Array get_input_type()
Definition: field_values.hh:426
Input::Array
Accessor to input data conforming to declared Array.
Definition: accessors.hh:566
internal::AccessTypeDispatch< unsigned int >::type
Input::Enum type
Definition: field_values.hh:132
FieldValue_::rank_
const static int rank_
Definition: field_values.hh:256
StringTensor::at
std::string & at(unsigned int row, unsigned int col)
Definition: field_values.hh:582
FieldValue_< NRows, 1, ET >::eye
void eye()
Definition: field_values.hh:542
Input::Enum
Definition: accessors.hh:119
internal::ReturnType< NRows, 1, ET >::return_type
arma::Col< ET >::template fixed< NRows > return_type
Definition: field_values.hh:96
TYPEDEF_ERR_INFO
TYPEDEF_ERR_INFO(EI_InputMsg, const string)
FieldValue_< 1, 1, ET >::ElementInputType
internal::InputType< ET >::type ElementInputType
Definition: field_values.hh:340
FieldValue_< 1, 1, ET >::mem_ptr
const ET * mem_ptr() const
Definition: field_values.hh:362
Armor::Array
Definition: armor.hh:597
internal::set_raw_scalar
RT & set_raw_scalar(RT &, double *raw_data)
Definition: field_values.hh:114
FieldValue_< 1, 1, ET >::scale
void scale(double scale_coef)
Definition: field_values.hh:399
FieldValue_< 0, 1, ET >::type_name
static std::string type_name()
Definition: field_values.hh:425
Input::Array::ei_address
EI_Address ei_address() const
Definition: accessors.cc:314
internal
Definition: field_values.cc:20
FieldValue_< 1, 1, ET >::get_input_type
static IT::Parameter get_input_type()
Definition: field_values.hh:347
FieldValue_< 1, 1, ET >::zeros
void zeros()
Definition: field_values.hh:384
FieldValue_< NRows, 1, ET >::init_from_input
void init_from_input(AccessType rec)
Definition: field_values.hh:520
FieldValue_< NRows, 1, ET >::scale
void scale(double scale_coef)
Definition: field_values.hh:554
FieldValue_::NCols_
const static int NCols_
Definition: field_values.hh:255
FieldValue_< NRows, 1, ET >::get_from_array
static return_type get_from_array(const Armor::Array< element_type > &arr, uint idx)
Casts value stored in Armor::Array to return type.
Definition: field_values.hh:516
Armor::Array::scalar
Type scalar(uint mat_index) const
Definition: armor.hh:831
FieldValue_< 1, 1, ET >::eye
void eye()
Definition: field_values.hh:388
Input::Type::Parameter
Class for representing parametric types in IST.
Definition: type_generic.hh:53
FieldValue_< 1, 1, ET >::element_type
ET element_type
Definition: field_values.hh:338
FieldValue_< NRows, 1, ET >::AccessType
Input::Array AccessType
Definition: field_values.hh:497
FieldValue_::is_scalable
static constexpr bool is_scalable()
Definition: field_values.hh:269
FieldValue_< NRows, 1, ET >::return_type
internal::ReturnType< NRows, 1, ET >::return_type return_type
Definition: field_values.hh:495
FieldValue_< NRows, 1, ET >::FieldValue_
FieldValue_(return_type &val)
Definition: field_values.hh:511
FieldValue::TensorFixed
FieldValue_< spacedim, spacedim, double > TensorFixed
Definition: field_values.hh:654
FieldValue_< NRows, 1, ET >::zeros
void zeros()
Definition: field_values.hh:538
StringTensorInput< 1, 1 >::init_from_input
static void init_from_input(StringTensor &tensor, AccessType input)
Definition: field_values.hh:619
FieldValue_::ones
void ones()
Definition: field_values.hh:310
FieldValue_< 1, 1, ET >::is_scalable
static constexpr bool is_scalable()
Definition: field_values.hh:351
FieldValue_< 1, 1, ET >::n_rows
unsigned int n_rows() const
Definition: field_values.hh:374
StringTensorInput::init_from_input
static void init_from_input(StringTensor &tensor, AccessType input)
Definition: field_values.hh:610
FieldValue_::FieldValue_
FieldValue_(return_type &val)
Definition: field_values.hh:274
internal::init_matrix_from_input
void init_matrix_from_input(MatrixType &value, Input::Array rec)
Definition: field_values.hh:143
FieldValue_< NRows, 1, ET >::equal_to
bool equal_to(const return_type &other)
Definition: field_values.hh:550
FieldValue_< NRows, 1, ET >::element_type
ET element_type
Definition: field_values.hh:494
StringTensor
Definition: field_values.hh:574
internal::init_vector_from_input
void init_vector_from_input(VectorType &value, Input::Array rec)
Definition: field_values.hh:208
FieldValue
Definition: field_values.hh:645
FieldValue_::return_type
internal::ReturnType< NRows, NCols, ET >::return_type return_type
Definition: field_values.hh:251
StringTensor::n_cols
unsigned int n_cols
Definition: field_values.hh:588
FieldValue_< 1, 1, ET >::return_type
internal::ReturnType< 1, 1, ET >::return_type return_type
Definition: field_values.hh:339