Flow123d  jenkins-Flow123d-windows32-release-multijob-51
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 {
13  shared_->bc_=false;
14  shared_->input_default_="";
15  shared_->n_comp_ = 0;
16  shared_->mesh_ = nullptr;
17  shared_->is_fully_initialized_=false;
18 }
19 
20 
21 
23 : shared_(other.shared_),
24  limit_side_(LimitSide::unknown),
25  set_time_result_(TimeStatus::unknown)
26 {
28 }
29 
30 
31 
33  string rec_name, description;
34  description = "Record to set fields of the equation.\n"
35  "The fields are set only on the domain specified by one of the keys: 'region', 'rid', 'r_set'\n"
36  "and after the time given by the key 'time'. The field setting can be overridden by\n"
37  " any " + record_name + " record that comes later in the boundary data array.";
38 
39  IT::Record rec = IT::Record(record_name, description)
40  .declare_key("r_set", IT::String(), "Name of region set where to set fields.")
41  .declare_key("region", IT::String(), "Label of the region where to set fields. ")
42  .declare_key("rid", IT::Integer(0), "ID of the region where to set fields." )
43  .declare_key("time", IT::Double(0.0), IT::Default("0.0"),
44  "Apply field setting in this record after this time.\n"
45  "These times have to form an increasing sequence.");
46 
47  return rec;
48 }
49 
50 
52 {
53  if (! flags().match(FieldFlag::declare_input)) return;
54 
55  shared_->input_list_ = list;
56 
57  // check that times forms ascending sequence
58  double time,last_time=0.0;
59  if (list.size() == 0) return;
60  for( auto it = shared_->input_list_.begin<Input::Record>();
61  it != shared_->input_list_.end(); ++it)
62  if (it->find<Input::AbstractRecord>(input_name())) {
63  // field descriptor appropriate to the field
64  time = it->val<double>("time");
65  if (time < last_time) {
66  cout << shared_->input_list_.address_string();
67  THROW( ExcNonascendingTime()
68  << EI_Time(time)
69  << EI_Field(input_name())
70  << shared_->input_list_.ei_address());
71  }
72  last_time=time;
73 
74  }
75 
76  shared_->list_it_ = shared_->input_list_.begin<Input::Record>();
77 }
78 
79 
80 
82  ASSERT_LESS( 0, shared_->input_list_.size());
83 
84  // pass through field descriptors containing key matching field name.
85  double time;
86  for( auto it = shared_->input_list_.begin<Input::Record>();
87  it != shared_->input_list_.end(); ++it)
88  if (it->find<Input::AbstractRecord>(input_name())) {
89  time = it->val<double>("time"); // default time=0
90  TimeGovernor::marks().add( TimeMark(time, mark_type | TimeGovernor::marks().type_input() ));
91  }
92 }
93 
94 
95 
void mark_input_times(TimeMark::Type mark_type)
Definition: field_common.cc:81
Common abstract parent of all Field<...> classes.
Definition: field_common.hh:45
unsigned long int Type
Definition: time_marks.hh:59
Accessor to input data conforming to declared Array.
Definition: accessors.hh:521
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:341
const std::string description() const
static TimeMarks & marks()
void set_input_list(const Input::Array &list)
Definition: field_common.cc:51
std::shared_ptr< SharedData > shared_
void add(const TimeMark &mark)
Definition: time_marks.cc:77
double time() const
Class for declaration of the input data that are floating point numbers.
Definition: type_base.hh:376
static constexpr Mask input_copy
A field that is input of its equation and cna not read from input, thus muzt be set by copy...
Definition: field_flag.hh:29
FieldFlag::Flags & flags()
FieldFlag::Flags flags_
Field flags. Default setting is "an equation input field, that can read from user input...
Accessor to the data with type Type::Record.
Definition: accessors.hh:308
static IT::Record field_descriptor_record(const string &record_name)
Definition: field_common.cc:32
#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:423
virtual ~FieldCommon()
Definition: field_common.cc:96
Class used for marking specified times at which some events occur.
Definition: time_marks.hh:44
unsigned int size() const
Record type proxy class.
Definition: type_record.hh:161
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:31
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:386