Flow123d  jenkins-Flow123d-linux-release-multijob-282
field_common.cc
Go to the documentation of this file.
1 #include "fields/field_common.hh"
2 
3 /****************************************************************************
4  * Implementation of FieldCommon
5  */
6 
7 
9 : shared_( std::make_shared<SharedData>() ),
10  limit_side_(LimitSide::unknown),
11  set_time_result_(TimeStatus::unknown),
12  component_index_(std::numeric_limits<unsigned int>::max())
13 {
14  shared_->bc_=false;
15  shared_->input_default_="";
16  shared_->n_comp_ = 0;
17  shared_->mesh_ = nullptr;
18  shared_->is_fully_initialized_=false;
19 }
20 
21 
22 
24 : shared_(other.shared_),
25  limit_side_(LimitSide::unknown),
26  set_time_result_(TimeStatus::unknown),
27  component_index_(other.component_index_)
28 {
30 }
31 
32 
33 
35  string rec_name, description;
36  description = "Record to set fields of the equation.\n"
37  "The fields are set only on the domain specified by one of the keys: 'region', 'rid', 'r_set'\n"
38  "and after the time given by the key 'time'. The field setting can be overridden by\n"
39  " any " + record_name + " record that comes later in the boundary data array.";
40 
41  IT::Record rec = IT::Record(record_name, description)
42  .declare_key("r_set", IT::String(), "Name of region set where to set fields.")
43  .declare_key("region", IT::String(), "Label of the region where to set fields. ")
44  .declare_key("rid", IT::Integer(0), "ID of the region where to set fields." )
45  .declare_key("time", IT::Double(0.0), IT::Default("0.0"),
46  "Apply field setting in this record after this time.\n"
47  "These times have to form an increasing sequence.");
48 
49  return rec;
50 }
51 
52 
54 {
55  if (! flags().match(FieldFlag::declare_input)) return;
56 
57  shared_->input_list_ = list;
58 
59  // check that times forms ascending sequence
60  double time,last_time=0.0;
61 
62  if (list.size() == 0) return;
63  for( auto it = list.begin<Input::Record>();
64  it != list.end(); ++it) {
65 // Interleaving of field time sequences can not be done by just filtering
66 // fields by name. There is some problem in update_history.
67 // So we require correct ordering of whole list.
68 /*
69  bool found;
70  if (this->multifield_) {
71  found = it->find<Input::Record>(input_name());
72  }
73  else if (this->component_index_ == std::numeric_limits<unsigned int>::max()) {
74  found = it->find<Input::AbstractRecord>(input_name());
75  }
76  else {
77  Input::Record mutlifield_rec;
78  if (it->opt_val(input_name(), mutlifield_rec)) {
79  found = mutlifield_rec.find<Input::Array>("components");
80  }
81  else found = false;
82  }*/
83 
84  bool found =true;
85  if (found) {
86  // field descriptor appropriate to the field
87 
88  time = it->val<double>("time");
89  if (time < last_time) {
90  THROW( ExcNonascendingTime()
91  << EI_Time(time)
92  << EI_Field(input_name())
93  << it->ei_address());
94  }
95  last_time=time;
96  }
97  }
98  shared_->list_it_ = shared_->input_list_.begin<Input::Record>();
99 }
100 
101 
102 
104  if (! flags().match(FieldFlag::declare_input)) return;
105  ASSERT_LESS( 0, shared_->input_list_.size());
106 
107  // pass through field descriptors containing key matching field name.
108  double time;
109  for( auto it = shared_->input_list_.begin<Input::Record>();
110  it != shared_->input_list_.end(); ++it)
111  if (it->find<Input::AbstractRecord>(input_name())) {
112  time = it->val<double>("time"); // default time=0
113  TimeGovernor::marks().add( TimeMark(time, mark_type | TimeGovernor::marks().type_input() ));
114  }
115 }
116 
117 
118 
Iterator< ValueType > begin() const
void mark_input_times(TimeMark::Type mark_type)
Common abstract parent of all Field&lt;...&gt; classes.
Definition: field_common.hh:47
unsigned long int Type
Definition: time_marks.hh:64
Accessor to input data conforming to declared Array.
Definition: accessors.hh:558
Class Input::Type::Default specifies default value of keys of a Input::Type::Record.
Definition: type_record.hh:39
FlagArray & add(Mask mask)
Definition: flag_array.hh:160
Class for declaration of the integral input data.
Definition: type_base.hh:355
const std::string description() const
static TimeMarks & marks()
void set_input_list(const Input::Array &list)
Definition: field_common.cc:53
std::shared_ptr< SharedData > shared_
IteratorBase end() const
void add(const TimeMark &mark)
Definition: time_marks.cc:88
double time() const
Class for declaration of the input data that are floating point numbers.
Definition: type_base.hh:392
static constexpr Mask input_copy
A field that is input of its equation and can not read from input, thus must be set by copy...
Definition: field_flag.hh:29
FieldFlag::Flags & flags()
FieldFlag::Flags flags_
Field flags. Default setting is &quot;an equation input field, that can read from user input...
Accessor to the data with type Type::Record.
Definition: accessors.hh:327
static IT::Record field_descriptor_record(const string &record_name)
Definition: field_common.cc:34
#define ASSERT_LESS(a, b)
Definition: global_defs.h:164
Accessor to the polymorphic input data of a type given by an AbstracRecord object.
Definition: accessors.hh:448
virtual ~FieldCommon()
Class used for marking specified times at which some events occur.
Definition: time_marks.hh:49
unsigned int size() const
Record type proxy class.
Definition: type_record.hh:169
const std::string & input_name() const
#define THROW(whole_exception_expr)
Wrapper for throw. Saves the throwing point.
Definition: exceptions.hh:34
LimitSide
Definition: field_common.hh:33
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:25
Record & declare_key(const string &key, const KeyType &type, const Default &default_value, const string &description)
Definition: type_record.cc:430