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