Flow123d
field.cc
Go to the documentation of this file.
1 /*
2  * field.cc
3  *
4  * Created on: Feb 13, 2014
5  * Author: jb
6  */
7 
8 #include "system/exceptions.hh"
9 #include "mesh/mesh.h"
10 
11 #include "fields/field_base_impl.hh" // for instantiation macros
12 
13 #include "field.hh"
14 #include "fields/field_impl.hh"
15 
16 
17 /****************************************************************************
18  * Implementation of FieldCommon
19  */
20 
22 : shared_( std::make_shared<SharedData>() ),
23  limit_side_(LimitSide::unknown),
24  set_time_result_(TimeStatus::unknown),
25  is_copy_(false)
26 {
27  shared_->bc_=false;
28  shared_->default_="";
29  shared_->n_comp_ = 0;
30  shared_->mesh_ = nullptr;
31  shared_->is_fully_initialized_=false;
32 }
33 
34 
35 
37 : shared_(other.shared_),
38  set_time_result_(TimeStatus::unknown),
39  limit_side_(LimitSide::unknown),
40  is_copy_(true)
41 {}
42 
43 
44 
46  string rec_name, description;
47  description = "Record to set fields of the equation.\n"
48  "The fields are set only on the domain specified by one of the keys: 'region', 'rid', 'r_set'\n"
49  "and after the time given by the key 'time'. The field setting can be overridden by\n"
50  " any " + record_name + " record that comes later in the boundary data array.";
51 
52  IT::Record rec = IT::Record(record_name, description)
53  .declare_key("r_set", IT::String(), "Name of region set where to set fields.")
54  .declare_key("region", IT::String(), "Label of the region where to set fields. ")
55  .declare_key("rid", IT::Integer(0), "ID of the region where to set fields." )
56  .declare_key("time", IT::Double(0.0), IT::Default("0.0"),
57  "Apply field setting in this record after this time.\n"
58  "These times have to form an increasing sequence.");
59 
60  return rec;
61 }
62 
63 
65 {
66  if (is_copy_) return;
67  shared_->input_list_ = list;
68 
69  // check that times forms ascending sequence
70  double time,last_time=0.0;
71  if (list.size() == 0) return;
72  for( auto it = shared_->input_list_.begin<Input::Record>();
73  it != shared_->input_list_.end(); ++it)
74  if (it->find<Input::AbstractRecord>(name())) {
75  // field descriptor appropriate to the field
76  time = it->val<double>("time");
77  if (time < last_time) {
78  cout << shared_->input_list_.address_string();
79  THROW( ExcNonascendingTime()
80  << EI_Time(time)
81  << EI_Field(name())
82  << shared_->input_list_.ei_address());
83  }
84  last_time=time;
85 
86  }
87 
88  shared_->list_it_ = shared_->input_list_.begin<Input::Record>();
89 }
90 
91 
92 
94  ASSERT_LESS( 0, shared_->input_list_.size());
95 
96  // pass through field descriptors containing key matching field name.
97  double time,last_time=0.0;
98  for( auto it = shared_->input_list_.begin<Input::Record>();
99  it != shared_->input_list_.end(); ++it)
100  if (it->find<Input::AbstractRecord>(name())) {
101  time = it->val<double>("time"); // default time=0
102  TimeGovernor::marks().add( TimeMark(time, mark_type | TimeGovernor::marks().type_input() ));
103  }
104 }
105 
106 
107 
109 
110 /****************************************************************************
111  * Instances of field templates
112  */
113 
114 
115