Flow123d  release_3.0.0-1152-gdb4be9b
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/exception/detail/error_info_impl.hpp> // for error_info
24 #include <boost/exception/info.hpp> // for operator<<
25 #include <boost/format.hpp> // for str
26 #include <boost/optional/optional.hpp> // for get_pointer
27 #include <cmath> // for abs
28 #include <cstdlib> // for abs
29 #include <limits> // for numeric_limits
30 #include <new> // for operator new[]
31 #include <ostream> // for operator&, ope...
32 #include <string> // for basic_string
33 #include <system/exceptions.hh> // for THROW, ExcStream
34 #include <type_traits> // for is_floating_point
35 #include <vector> // for vector
36 #include <armadillo>
37 #include "input/accessors.hh" // for Array, Iterator
38 #include "input/accessors_impl.hh" // for Array::size
39 #include "input/input_exception.hh" // for ExcFV_Input::~...
40 #include "input/type_base.hh" // for Array, String
41 #include "input/type_generic.hh" // for Parameter
42 #include "input/type_selection.hh" // for Selection
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 &val, double *raw_data) { return *raw_data;}
115 template <class RT> inline RT & set_raw_scalar(RT &val, int *raw_data) { return *raw_data;}
116 template <class RT> inline RT & set_raw_scalar(RT &val, 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  boost::str(boost::format("Initializing symmetric matrix %dx%d by vector of wrong size %d, 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  boost::str(boost::format("Initializing matrix %dx%d by matrix of wrong size %dx%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  boost::str(boost::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 boost::str(boost::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 
279  void init_from_input( AccessType rec ) {
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:
320  return_type &value_;
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 
358  void init_from_input( AccessType val ) { value_ = return_type(val); }
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:
394  return_type &value_;
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 
427  void init_from_input( AccessType rec ) {
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:
470  return_type &value_;
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 boost::str(boost::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 
499  void init_from_input( AccessType rec ) {
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:
541  return_type &value_;
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 )
558  : n_rows(n_rows),n_cols(n_cols), values_(n_rows*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_ */
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:567
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)
arma::Col< unsigned int > return_type
std::vector< std::string > values_
static void init_from_input(StringTensor &tensor, AccessType input)
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 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
FieldValue_< 1, 1, FieldEnum > Enum
Class for declaration of the integral input data.
Definition: type_base.hh:490
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:346
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()
Class for declaration of the input data that are floating point numbers.
Definition: type_base.hh:541
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
RT & set_raw_scalar(RT &val, double *raw_data)
Class for declaration of the input data that are in string format.
Definition: type_base.hh:589
#define THROW(whole_exception_expr)
Wrapper for throw. Saves the throwing point.
Definition: exceptions.hh:53
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()