Flow123d  master-a4da60c
field_common.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_common.hh
15  * @brief
16  */
17 
18 #ifndef FIELD_COMMON_HH_
19 #define FIELD_COMMON_HH_
20 
21 #include <algorithm> // for sort, unique
22 #include <limits> // for numeric_limits
23 #include <memory> // for shared_ptr
24 #include <ostream> // for operator<<
25 #include <string> // for string, basic_...
26 #include <utility> // for make_pair, pair
27 #include <vector> // for vector, allocator
28 #include "fields/field_algo_base.hh" // for FieldResult
29 #include "fields/field_flag.hh" // for FieldFlag, Fie...
30 #include "fields/field_values.hh" // for FieldEnum
31 #include "tools/unit_si.hh" // for UnitSI
32 #include "input/accessors.hh" // for Record, Array ...
33 #include "input/input_exception.hh" // for ExcInputMessage
34 #include "input/type_base.hh" // for Array, Type
35 #include "input/type_generic.hh" // for Instance
36 #include "input/type_record.hh" // for Record
37 #include "input/type_selection.hh" // for Selection
38 #include "io/output_time.hh" // for OutputTime
39 #include "io/output_time_set.hh" // for OutputTimeSet
40 #include "mesh/region.hh" // for Region (ptr only)
41 #include "system/asserts.hh" // for Assert, ASSERT_PERMANENT
42 #include "system/exc_common.hh" // for EI_Message
43 #include "system/exceptions.hh" // for operator<<
44 #include "system/flag_array.hh" // for FlagArray<>::Mask
45 #include "tools/time_governor.hh" // for TimeGovernor (...
46 
47 class Mesh;
48 class Observe;
49 class EvalPoints;
50 class ElementCacheMap;
51 class FieldSet;
52 class BulkPoint;
54 struct AssemblyInternals;
55 
56 
57 using namespace std;
58 
59 namespace IT=Input::Type;
60 
61 /**
62  * Left and right time limit, used in the @p set_time() method.
63  * Assigned values allow to index an array.
64  */
65 enum class LimitSide {
66  left=0,
67  right=1
68 };
69 
70 
71 
72 /**
73  * @brief Common abstract parent of all Field<...> classes.
74  *
75  * We need common ancestor in order to keep a list of all fields in one EqData object and allow
76  * collective operations like @p set_time or @p init_from_input.
77  */
78 class FieldCommon {
79 
80 public:
81  TYPEDEF_ERR_INFO(EI_Time, double);
82  TYPEDEF_ERR_INFO(EI_Field, std::string);
83  TYPEDEF_ERR_INFO( EI_FieldInputName, std::string);
84  TYPEDEF_ERR_INFO( EI_FieldName, std::string);
85  TYPEDEF_ERR_INFO( EI_RegId, unsigned int);
86  TYPEDEF_ERR_INFO( EI_RegLabel, std::string);
87  DECLARE_INPUT_EXCEPTION(ExcNonascendingTime,
88  << "Non-ascending time: " << EI_Time::val << " for field " << EI_Field::qval << ".\n");
89  DECLARE_INPUT_EXCEPTION(ExcMissingDomain,
90  << "Missing domain specification (region or r_id) in the field descriptor:");
91  DECLARE_EXCEPTION(ExcFieldMeshDifference,
92  << "Two copies of the field " << EI_Field::qval << "call set_mesh with different arguments.\n");
93  DECLARE_INPUT_EXCEPTION(ExcMissingFieldValue,
94  << "Missing value of the input field " << EI_FieldInputName::qval << " (" << EI_FieldName::qval
95  << ") on region ID: " << EI_RegId::val << " label: " << EI_RegLabel::qval << ".\n");
96 
97 
98 
99  /// Store data of one initialization message.
100  struct MessageData {
101  /// Constructor
102  MessageData(std::string default_value, std::string field_name, std::string region_list)
103  : default_value_(default_value), field_name_(field_name), region_list_(region_list) {};
104 
105  std::string default_value_; ///< Default value of the field.
106  std::string field_name_; ///< Parameter name_ of the field.
107  std::string region_list_; ///< List of regions separated by comma.
108  };
109 
110  /**
111  * Set name of the field. In fact there are two attributes set by this method.
112  *
113  * The first is name used to identify the field as part of a FieldSet or MultiField objects.
114  * This name is permanent and can be set only by this method. Can be accessed by @p name() method.
115  * This name is also used at output.
116  *
117  * The second is @p input_name_ that determines appropriate key name in the input field descriptor.
118  * This name is also set by this method, but is stored in the internal shared space which
119  * is overwritten during call of copy_from method or assignment operator. Can be accessed by @p input_name() mathod.
120  *
121  */
122  FieldCommon &name(const string & name)
123  { name_=shared_->input_name_ = name;
124  return *this;
125  }
126  /**
127  * Set description of the field, used for description of corresponding key in documentation.
128  */
129  FieldCommon & description(const string & description)
130  { shared_->input_description_ = description; return *this;}
131  /**
132  * Set default value for the field's key from which the default constant valued field will be constructed.
133  *
134  * During the first call of the @p set_time method, we check that the field is defined on all regions.
135  * On regions where it is not set yet, we use given @p dflt string to get particular instance of
136  * FieldBase<> (see @p check_initialized_region_fields_).
137  * The default string is interpreted in the same way as if it appears in the input file
138  * as the value of the field. In particular it can be whole record with @p TYPE of the field etc.
139  * Most common choice is however mere constant.
140  */
141  FieldCommon & input_default(const string &input_default)
142  { shared_->input_default_ = input_default; return *this;}
143  /**
144  * @brief Set basic units of the field.
145  *
146  * Currently, we use it only during output and we represents units just by a string.
147  *
148  * TODO:
149  * Particular class for representing and conversion of various units would be more appropriate.
150  * This can allow specification of the units on the inptu, automatic conversion and the same on the output.
151  * Possibly this allow using Boost::Units library, however, it seems to introduce lot of boilerplate code.
152  * But can increase correctness of the calculations.
153  */
154  FieldCommon & units(const UnitSI & units)
155  { shared_->units_ = units; return *this;}
156 
157  /**
158  * Set limits of value of the field.
159  */
160  FieldCommon & set_limits(double min, double max = std::numeric_limits<double>::max())
161  {
162  ASSERT_PERMANENT_LT(min, max).error("Invalid field limits!");
163  shared_->limits_ = std::make_pair(min, max);
164  return *this;
165  }
166 
167  /**
168  * For the fields returning "Enum", we have to pass the Input::Type::Selection object to
169  * the field implementations.
170  *
171  * We must save raw pointer since selection may not be yet initialized (during static initialization phase).
172  */
174  {
175  shared_->input_element_selection_=element_selection;
176  return *this;
177  }
178 
179  /**
180  * Output discrete space used in the output() method. Can be different for different field copies.
181  * one can choose between:
182  * data constant on elements, linear data given in nodes, and discontinuous linear data.
183  *
184  * If not set explicitly by this method, the default value is OutputTime::ELEM_DATA
185  */
187  { if (rt!=OutputTime::UNDEFINED) default_output_data_ = rt; return *this; }
188 
189  /**
190  * Set given mask to the field flags, ignoring default setting.
191  * Default setting is declare_input & equation_input & allow_output.
192  */
193  FieldCommon & flags(FieldFlag::Flags::Mask mask)
194  { flags_ = FieldFlag::Flags(mask); return *this; }
195 
196  /**
197  * Add given mask to the field flags.
198  */
199  FieldCommon & flags_add(FieldFlag::Flags::Mask mask)
200  { flags().add(mask); return *this; }
201 
202  /**
203  * Set vector of component names.
204  * Set number of components for run-time sized vectors. This is used latter when we construct
205  * objects derived from FieldBase<...>.
206  *
207  * n_comp_ is constant zero for fixed values, this zero is set by Field<...> constructors
208  */
209  void set_components(const std::vector<string> &names) {
210  // Test of unique values in names vector for MultiField
211  if (multifield_) {
212  std::vector<string> cpy = names;
213  std::sort( cpy.begin(), cpy.end() );
214  cpy.erase( std::unique( cpy.begin(), cpy.end() ), cpy.end() );
215  if (names.size() != cpy.size()) {
216  THROW( Input::ExcInputMessage() << EI_Message("The field " + this->input_name()
217  + " has set non-unique names of components.") );
218  }
219  shared_->n_comp_ = names.size();
220  } else {
221  shared_->n_comp_ = (shared_->n_comp_ ? names.size() : 0);
222  }
223 
224  shared_->comp_names_ = names;
225  }
226 
227 
228  /**
229  * Set internal mesh pointer.
230  */
231  virtual void set_mesh(const Mesh &mesh) = 0;
232  /**
233  * Set the data list from which field will read its input. It is list of "field descriptors".
234  * When reading from the input list we consider only field descriptors containing key of
235  * named by the field name. These field descriptors has to have times forming ascending sequence.
236  *
237  * The list is used by set_time method to set field on individual regions to actual FieldBase descendants.
238  */
239  virtual void set_input_list(const Input::Array &list, const TimeGovernor &tg) =0;
240 
241  /**
242  * Getters.
243  */
244  const std::string &input_name() const
245  { return shared_->input_name_;}
246 
247  const std::string &name() const
248  { return name_;}
249 
250  const std::string description() const
251  {return shared_->input_description_;}
252 
253  const std::string &input_default() const
254  { return shared_->input_default_;}
255 
256  const UnitSI &units() const
257  {
258  ASSERT(shared_->units_.is_def())(name()).error("Getting undefined unit.\n");
259  return shared_->units_;
260  }
261 
262  std::pair<double, double> limits() const
263  {
264  return shared_->limits_;
265  }
266 
268  { return default_output_data_; }
269 
270  unsigned int n_comp() const
271  { return shared_->comp_names_.size();}
272 
273  /**
274  * Returns full name of subfield on \p i_comp position created from component name and field name.
275  *
276  * If component name is empty returns only field name.
277  */
278  inline std::string full_comp_name(unsigned int i_comp) const
279  {
280  ASSERT_LT(i_comp, shared_->comp_names_.size());
281  return shared_->comp_names_[i_comp].empty() ? this->name()
282  : shared_->comp_names_[i_comp] + "_" + this->name();
283  }
284 
285  const Mesh * mesh() const
286  { return shared_->mesh_;}
287 
289  { return flags_; }
290 
292  { return flags_; }
293 
294  /**
295  * Returns time set by last call of set_time method.
296  * Can be different for different field copies.
297  */
298  double time() const
299  { return last_time_; }
300 
301  /**
302  * Returns true if the field change algorithm for the current time set through the @p set_time method.
303  * This happen for all times in the field descriptors on the input of this particular field.
304  */
305  bool is_jump_time() {
306  return is_jump_time_;
307  }
308 
309  /**
310  * Returns number of field descriptors containing the field.
311  */
312  unsigned int input_list_size() const {
313  return shared_->input_list_.size();
314  }
315 
316  /**
317  * If the field on given region @p reg exists and is of type FieldConstant<...> the method method returns true
318  * otherwise it returns false.
319  * Then one can call ElementAccessor<spacedim>(mesh(), reg ) to construct an ElementAccessor @p elm
320  * pointing to "virtual" element on which Field::value returns constant value.
321  * Unlike the Field<>::field_result method, this one provides no value, so it have common header (arguments, return type) and
322  * could be part of FieldCommon and FieldSet which is useful in some applications.
323  *
324  * TODO:Current implementation use virtual functions and can be prohibitively slow if called for every element. If this
325  * becomes necessary it is possible to incorporate such test into set_time method and in this method just return precomputed result.
326  */
327  virtual bool is_constant(Region reg) =0;
328 
329 
330  /**
331  * @brief Indicates special field states.
332  *
333  * Extension of the previous method. Return possible values from the enum @p FieldResult, see description there.
334  * The initial state is @p field_none, if the field is correctly set on all regions of the @p region_set given as parameter
335  * we return state @p field_other or even more particular result.
336  *
337  * Special field values spatially constant. Could allow optimization of tensor multiplication and
338  * tensor or vector addition. field_result_ should be set in constructor and in set_time method of particular Field implementation.
339  * We return value @p result_none, if the field is not initialized on the region of the given element accessor @p elm.
340  * Other possible results are: result_zeros, result_eye, result_ones, result_constant, result_other
341  * see @p FieldResult for explanation.
342  *
343  * Multifield return most particular value that holds for all its subfields.
344  *
345  *
346  */
347  virtual FieldResult field_result( RegionSet region_set) const =0;
348 
349  /**
350  * Return specification of the field value type in form of the string:
351  * [ <element type>, NRows, NCols]
352  *
353  * Result is valid JSON (and/or flow style YAML).
354  * For multifields not implemented.
355  */
356  virtual std::string get_value_attribute() const =0;
357 
358  /**
359  * Returns true if set_time_result_ is not @p TimeStatus::constant.
360  * Returns the same value as last set_time method.
361  */
362  bool changed() const
363  {
364  ASSERT( set_time_result_ != TimeStatus::unknown ).error("Invalid time status.");
365  return ( (set_time_result_ == TimeStatus::changed) ||
366  (set_time_result_ == TimeStatus::changed_forced) );
367  }
368 
369  /**
370  * Common part of the field descriptor. To get finished record
371  * one has to add keys for individual fields. This is done automatically
372  * using FieldSet::get_input_type().
373  */
374  static IT::Record field_descriptor_record(const string& record_name);
375 
376  /**
377  * Create description of field descriptor record.
378  */
379  static const std::string field_descriptor_record_description(const string& record_name);
380 
381  /**
382  * Returns input type for particular field instance, this is reference to a static member input_type of the corresponding @p FieldBase
383  * class (i.e. with the same template parameters). This is used in FieldSet::make_field_descriptor_type.
384  */
386 
387  /**
388  * Returns input type for MultiField instance.
389  * TODO: temporary solution, see @p multifield_
390  */
392 
393  /**
394  * Pass through the input array @p input_list_, collect all times where the field could change and
395  * put appropriate time marks into global TimeMarks object.
396  * Introduced time marks have both given @p mark_type and @p type_input() type.
397  *
398  * Further development:
399  * - we have to distinguish "jump" times and "smooth" times
400  */
401  void mark_input_times(const TimeGovernor &tg);
402 
403  /**
404  * Abstract method to update field to the new time level.
405  * Implemented by in class template Field<...>.
406  *
407  * Return true if the value of the field was changed on some region.
408  * The returned value is also stored in @p changed_during_set_time data member.
409  *
410  * Default values helps when creating steady field. Note that default TimeGovernor constructor
411  * set time to 0.0.
412  *
413  * Different field copies can be set to different times.
414  *
415  * TODO: update following:
416  * Set side of limit when calling @p set_time
417  * with jump time, i.e. time where the field change implementation on some region.
418  * Wee assume that implementations prescribe only smooth fields.
419  * This method invalidate result of
420  * @p changed() so it should be called just before @p set_time.
421  * Can be different for different field copies.
422  */
423  virtual bool set_time(const TimeStep &time, LimitSide limit_side) =0;
424 
425  /**
426  * Check that @p other is instance of the same Field<..> class and
427  * perform assignment. Polymorphic copy.
428  *
429  * The copy is performed only if *this have set flag 'input_copy'.
430  * If *this have set also the flag 'decare_input' the copy is performed only if the
431  * input_list is empty.
432  */
433  virtual void copy_from(const FieldCommon & other) =0;
434 
435  /**
436  * Output the field.
437  * The parameter @p output_fields is checked for value named by the field name. If the key exists,
438  * then the output of the field is performed. If the key do not appear in the input, no output is done.
439  */
440  virtual void field_output(std::shared_ptr<OutputTime> stream, OutputTime::DiscreteSpace type) =0;
441 
442  /**
443  * Set reference of FieldSet to all instances of FieldFormula.
444  */
445  virtual std::vector<const FieldCommon *> set_dependency(unsigned int i_reg) const =0;
446 
447  /**
448  * Sets @p component_index_
449  */
450  void set_component_index(unsigned int idx)
451  {
452  this->component_index_ = idx;
453  }
454 
455  /**
456  * Return @p multifield_ flag.
457  * TODO: temporary solution
458  */
459  inline bool is_multifield() const
460  {
461  return this->multifield_;
462  }
463 
464  /**
465  * Reallocate field value cache of Field on given region.
466  */
467  virtual void cache_reallocate(AssemblyInternals &asm_internals, unsigned int region_idx) const = 0;
468 
469  /**
470  * Read data to cache for appropriate elements given by ElementCacheMap object.
471  */
472  virtual void cache_update(ElementCacheMap &cache_map, unsigned int region_patch_idx) const = 0;
473 
474 
475  /**
476  * Returns pointer to this (Field) or the sub-field component (MultiField).
477  */
478  virtual FieldCommon *get_component(FMT_UNUSED unsigned int idx) {
479  return this;
480  }
481 
482 
483  /**
484  * Returns FieldValueCache if element_type of field is double or nullptr for other element_types.
485  */
487 
488 
489  /**
490  * Same as previous but return const pointer
491  */
492  virtual const FieldValueCache<double> * value_cache() const =0;
493 
494  /// Create and set shared_ptr to ElementDataCache. Used only in descendant Field<>.
495  virtual void set_output_data_cache(FMT_UNUSED OutputTime::DiscreteSpace space_type, FMT_UNUSED std::shared_ptr<OutputTime> stream)
496  {
497  ASSERT_PERMANENT(false);
498  }
499 
500  /// Fill data to ElementDataCache on given patch.
501  virtual void fill_data_value(FMT_UNUSED const std::vector<int> &offsets)
502  {
503  ASSERT_PERMANENT(false);
504  }
505 
506 
507  /// Fill data to ElementDataCache on given patch.
508  virtual void fill_observe_value(FMT_UNUSED std::shared_ptr<ElementDataCacheBase> output_cache_base, FMT_UNUSED const std::vector<int> &offsets)
509  {
510  ASSERT_PERMANENT(false);
511  }
512 
513 
514  /**
515  * Print stored messages to table.
516  *
517  * Return true if messages_data_ vector is nonempty and clear its.
518  */
519  static bool print_message_table(ostream& stream, std::string equation_name);
520 
521  /**
522  * Setter of @p shared_->default_fieldset_
523  *
524  * Sets FieldSet which is default owner of Field. This FieldSet is used during evaluation
525  * of user field in FieldFormula.
526  */
527  inline void set_default_fieldset(FieldSet &default_fs) {
528  shared_->default_fieldset_ = &default_fs;
529  }
530 
531  /**
532  * Virtual destructor.
533  */
534  virtual ~FieldCommon();
535 
536  /// Return number of shape components
537  inline uint n_shape() const {
538  if (shape_.size() == 1) return shape_[0];
539  else return shape_[0] * shape_[1];
540  }
541 
542  /**
543  * Hold shape of Field.
544  *
545  * Value is set in constructor of descendant class.
546  */
548 
549 
550 protected:
551  /**
552  * Private default constructor. Should be used only through
553  * Field<...>
554  */
555  FieldCommon();
556 
557  /**
558  * Private copy constructor. Should be used only through
559  * Field<...>
560  */
561  FieldCommon(const FieldCommon & other);
562 
563  /**
564  * Invalidate last time in order to force set_time method
565  * update region_fields_.
566  */
568  {
569  last_time_ = -numeric_limits<double>::infinity();
570  }
571 
572  void set_shape(uint n_rows, uint n_cols) {
573  if (n_cols==1) this->shape_ = { n_rows };
574  else this->shape_ = { n_rows, n_cols };
575  }
576 
577  /**
578  * Setters for essential field properties.
579  */
580  /**
581  * Data shared among copies of the same field.
582  *
583  * This allow field copies in different equations with different time setting, but
584  * sharing common input field descriptor array and common history.
585  */
586  struct SharedData {
587  /**
588  * Empty constructor.
589  */
591  : list_idx_(0), limits_(std::make_pair(-std::numeric_limits<double>::max(), std::numeric_limits<double>::max())) {};
592 
593  /**
594  * Number of components for fields that return variable size vectors. Zero in other cases.
595  */
596  unsigned int n_comp_;
597  /**
598  * Names of field components.
599  */
601  /**
602  * Name of the particular field. Used to name the key in the Field list Record.
603  */
604  std::string input_name_;
605  /**
606  * Description of corresponding key in the Field list Record.
607  */
608  std::string input_description_;
609  /**
610  * Units of the field values. Currently just a string description.
611  */
613  /**
614  * For Enum valued fields this is the input type selection that should be used
615  * to read possible values of the field (e.g. for FieldConstant the key 'value' has this selection input type).
616  *
617  * Is empty selection for for non-enum values fields.
618  */
620  /**
621  * Possible default value of the field.
622  */
624  /**
625  * Pointer to the mesh on which the field lives.
626  */
627  const Mesh *mesh_;
628 
629  /**
630  * Vector of input field descriptors from which the field is set.
631  */
633 
634  /**
635  * Index to current position of input field descriptor.
636  */
637  unsigned int list_idx_;
638 
639  /**
640  * True after check_initialized_region_fields_ is called. That happen at first call of the set_time method.
641  */
643 
644  /**
645  * For which values of an enum valued field we do not
646  * check the field. User is responsible, that the value will not be called
647  * on such regions.
648  */
650 
651  /**
652  * Allow set minimal and maximal limit value of Field.
653  */
654  std::pair<double, double> limits_;
655 
656  /**
657  * Holds FieldSet which is default owner of Field.
658  *
659  * This data member is set in method FieldSet::make_field_descriptor_type and it is used during evaluation
660  * of user field in FieldFormula.
661  */
663 
664 
665  };
666 
667  /**
668  * Name that identifies the field in the field_set. By default this is same as
669  * shared_->input_name_.
670  */
671  std::string name_;
672 
673  /**
674  * Data shared among copies of the same input field.
675  */
676  std::shared_ptr<SharedData> shared_;
677 
678  /**
679  * Result of last set time method
680  */
681  enum class TimeStatus {
682  changed, //< Field changed during last set time call.
683  constant, //< Field doesn't change.
684  changed_forced, //< Field changed manually (reset during set_time() to changed).
685  unknown //< Before first call of set_time.
686  };
687 
688  // TODO: Merge time information: set_time_result_, last_time_, last_limit_side_, is_jump_time into
689  // a single structure with single getter.
690  /**
691  * Status of @p history.
692  */
694 
695  /**
696  * Last set time. Can be different for different field copies.
697  * Store also time limit, since the field may be discontinuous.
698  */
699  double last_time_ = -numeric_limits<double>::infinity();
700  LimitSide last_limit_side_ = LimitSide::left;
701 
702  /**
703  * Set to true by the @p set_time method the field algorithm change on any region.
704  * Accessible through the @p is_jump_time method.
705  */
707 
708  /**
709  * Default output data type used in the output() method. Can be different for different field copies.
710  */
712 
713  /**
714  * Specify if the field is part of a MultiField and which component it is
715  */
716  unsigned int component_index_;
717 
718  /**
719  * Flag determining if object is Multifield or Field.
720  * TODO: temporary solution, goal is to make these two classes to behave similarly
721  */
723 
724  /**
725  * Maximum number of FieldBase objects we store per one region.
726  */
727  static const unsigned int history_length_limit_=3;
728 
729  /// Field flags. Default setting is "an equation input field, that can read from user input, and can be written to output"
731 
732  /// Vector of data of initialization messages.
734 
735  /**
736  * Stream output operator
737  */
738  friend std::ostream &operator<<(std::ostream &stream, const FieldCommon &field) {
739 
740  vector<string> limit_side_str = {"left", "right"};
741 
742  stream
743  << "field name:" << field.name()
744  << " n. comp.:" << field.n_comp()
745  << " last time:" << field.last_time_
746  << " last limit side:" << limit_side_str[(unsigned int) field.last_limit_side_];
747  return stream;
748  }
749 
750 public:
751 
752  /// Manually mark flag that the field has been changed.
754  { set_time_result_ = TimeStatus::changed_forced; }
755 };
756 
757 
758 
759 
760 
761 
762 
763 #endif /* FIELD_COMMON_HH_ */
Definitions of ASSERTS.
#define ASSERT_PERMANENT_LT(a, b)
Definition of comparative assert macro (Less Than)
Definition: asserts.hh:297
#define ASSERT(expr)
Definition: asserts.hh:351
#define ASSERT_PERMANENT(expr)
Allow use shorter versions of macro names if these names is not used with external library.
Definition: asserts.hh:348
#define ASSERT_LT(a, b)
Definition of comparative assert macro (Less Than) only for debug mode.
Definition: asserts.hh:301
Base point accessor class.
Directing class of FieldValueCache.
Class holds local coordinations of evaluating points (bulk and sides) specified by element dimension.
Definition: eval_points.hh:54
Common abstract parent of all Field<...> classes.
Definition: field_common.hh:78
friend std::ostream & operator<<(std::ostream &stream, const FieldCommon &field)
TYPEDEF_ERR_INFO(EI_FieldName, std::string)
const std::string description() const
std::shared_ptr< SharedData > shared_
const UnitSI & units() const
virtual IT::Instance get_input_type()=0
DECLARE_INPUT_EXCEPTION(ExcMissingDomain,<< "Missing domain specification (region or r_id) in the field descriptor:")
bool changed() const
TimeStatus set_time_result_
TYPEDEF_ERR_INFO(EI_FieldInputName, std::string)
virtual void cache_reallocate(AssemblyInternals &asm_internals, unsigned int region_idx) const =0
FieldCommon & input_selection(Input::Type::Selection element_selection)
bool is_jump_time()
virtual bool set_time(const TimeStep &time, LimitSide limit_side)=0
unsigned int component_index_
const std::string & input_default() const
OutputTime::DiscreteSpace get_output_type() const
std::string full_comp_name(unsigned int i_comp) const
const std::string & input_name() const
virtual void set_mesh(const Mesh &mesh)=0
virtual bool is_constant(Region reg)=0
virtual FieldCommon * get_component(FMT_UNUSED unsigned int idx)
virtual std::string get_value_attribute() const =0
const std::string & name() const
virtual void cache_update(ElementCacheMap &cache_map, unsigned int region_patch_idx) const =0
LimitSide last_limit_side_
DECLARE_INPUT_EXCEPTION(ExcMissingFieldValue,<< "Missing value of the input field "<< EI_FieldInputName::qval<< " ("<< EI_FieldName::qval<< ") on region ID: "<< EI_RegId::val<< " label: "<< EI_RegLabel::qval<< ".\n")
TYPEDEF_ERR_INFO(EI_Field, std::string)
FieldCommon & description(const string &description)
std::vector< uint > shape_
virtual const FieldValueCache< double > * value_cache() const =0
virtual FieldResult field_result(RegionSet region_set) const =0
Indicates special field states.
virtual void field_output(std::shared_ptr< OutputTime > stream, OutputTime::DiscreteSpace type)=0
FieldCommon & flags_add(FieldFlag::Flags::Mask mask)
uint n_shape() const
Return number of shape components.
FieldCommon & flags(FieldFlag::Flags::Mask mask)
virtual std::vector< const FieldCommon * > set_dependency(unsigned int i_reg) const =0
std::string name_
virtual FieldValueCache< double > * value_cache()=0
double last_time_
void set_default_fieldset(FieldSet &default_fs)
FieldCommon & name(const string &name)
std::pair< double, double > limits() const
FieldFlag::Flags get_flags() const
TYPEDEF_ERR_INFO(EI_RegLabel, std::string)
void set_component_index(unsigned int idx)
TYPEDEF_ERR_INFO(EI_Time, double)
virtual void set_input_list(const Input::Array &list, const TimeGovernor &tg)=0
FieldCommon & set_limits(double min, double max=std::numeric_limits< double >::max())
virtual void fill_observe_value(FMT_UNUSED std::shared_ptr< ElementDataCacheBase > output_cache_base, FMT_UNUSED const std::vector< int > &offsets)
Fill data to ElementDataCache on given patch.
unsigned int input_list_size() const
TYPEDEF_ERR_INFO(EI_RegId, unsigned int)
FieldFlag::Flags & flags()
double time() const
void set_time_result_changed()
Manually mark flag that the field has been changed.
void set_shape(uint n_rows, uint n_cols)
FieldCommon & output_type(OutputTime::DiscreteSpace rt)
void set_components(const std::vector< string > &names)
bool is_multifield() const
bool is_jump_time_
virtual IT::Array get_multifield_input_type()=0
virtual void copy_from(const FieldCommon &other)=0
virtual void fill_data_value(FMT_UNUSED const std::vector< int > &offsets)
Fill data to ElementDataCache on given patch.
static std::vector< MessageData > messages_data_
Vector of data of initialization messages.
const Mesh * mesh() const
FieldCommon & units(const UnitSI &units)
Set basic units of the field.
FieldCommon & input_default(const string &input_default)
void set_history_changed()
virtual void set_output_data_cache(FMT_UNUSED OutputTime::DiscreteSpace space_type, FMT_UNUSED std::shared_ptr< OutputTime > stream)
Create and set shared_ptr to ElementDataCache. Used only in descendant Field<>.
DECLARE_EXCEPTION(ExcFieldMeshDifference,<< "Two copies of the field "<< EI_Field::qval<< "call set_mesh with different arguments.\n")
unsigned int n_comp() const
DECLARE_INPUT_EXCEPTION(ExcNonascendingTime,<< "Non-ascending time: "<< EI_Time::val<< " for field "<< EI_Field::qval<< ".\n")
static constexpr Mask allow_output
The field can output. Is part of generated output selection. (default on)
Definition: field_flag.hh:37
static constexpr Mask declare_input
The field can be set from input. The key in input field descriptor is declared. (default on)
Definition: field_flag.hh:35
static constexpr Mask equation_input
The field is data parameter of the owning equation. (default on)
Definition: field_flag.hh:33
FlagArray< FieldFlag > Flags
Definition: field_flag.hh:26
Container for various descendants of FieldCommonBase.
Definition: field_set.hh:161
Accessor to input data conforming to declared Array.
Definition: accessors.hh:566
Class for declaration of inputs sequences.
Definition: type_base.hh:339
Helper class that stores data of generic types.
Definition: type_generic.hh:89
Record type proxy class.
Definition: type_record.hh:182
Template for classes storing finite set of named values.
Definition: mesh.h:362
Basic time management functionality for unsteady (and steady) solvers (class Equation).
Representation of one time step..
Class for representation SI units of Fields.
Definition: unit_si.hh:40
FieldResult
LimitSide
Definition: field_common.hh:65
#define THROW(whole_exception_expr)
Wrapper for throw. Saves the throwing point.
Definition: exceptions.hh:53
unsigned int uint
#define FMT_UNUSED
Definition: posix.h:75
Holds common data shared between GenericAssemblz and Assembly<dim> classes.
Store data of one initialization message.
std::string field_name_
Parameter name_ of the field.
MessageData(std::string default_value, std::string field_name, std::string region_list)
Constructor.
std::string default_value_
Default value of the field.
std::string region_list_
List of regions separated by comma.
IT::Selection input_element_selection_
std::pair< double, double > limits_
std::string input_description_
std::vector< FieldEnum > no_check_values_
vector< Input::Record > input_list_
std::vector< std::string > comp_names_
Basic time management class.