Flow123d  release_1.8.2-1603-g0109a2b
field_common.cc
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.cc
15  * @brief
16  */
17 
18 #include "fields/field_common.hh"
19 
20 /****************************************************************************
21  * Implementation of FieldCommon
22  */
23 
24 
26 : shared_( std::make_shared<SharedData>() ),
27  set_time_result_(TimeStatus::unknown),
28  is_jump_time_(true),
29  component_index_(std::numeric_limits<unsigned int>::max())
30 {
31  shared_->bc_=false;
32  shared_->input_default_="";
33  shared_->n_comp_ = 0;
34  shared_->mesh_ = nullptr;
35  shared_->is_fully_initialized_=false;
36 }
37 
38 
39 
41 : name_(other.name_),
42  shared_(other.shared_),
44  last_time_(other.last_time_),
48 {
50 }
51 
52 
53 
55  return IT::Record(record_name, field_descriptor_record_description(record_name))
56  .declare_key("region", IT::Array( IT::String(), 1 ), "Labels of the regions where to set fields. ")
57  .declare_key("rid", IT::Integer(0), "ID of the region where to set fields." )
58  .declare_key("time", IT::Double(0.0), IT::Default("0.0"),
59  "Apply field setting in this record after this time.\n"
60  "These times have to form an increasing sequence.")
61  .close();
62 }
63 
64 const std::string FieldCommon::field_descriptor_record_description(const string& record_name) {
65  return "Record to set fields of the equation.\n"
66  "The fields are set only on the domain specified by one of the keys: 'region', 'rid'\n"
67  "and after the time given by the key 'time'. The field setting can be overridden by\n"
68  " any " + record_name + " record that comes later in the boundary data array.";
69 }
70 
71 
72 
74  if (! flags().match(FieldFlag::declare_input)) return;
75 
76  // pass through field descriptors containing key matching field name.
78  double time;
79  for( auto &item : shared_->input_list_) {
80  time = item.val<double>("time"); // default time=0
81  TimeGovernor::marks().add( TimeMark(time, mark_type | TimeGovernor::marks().type_input() ));
82  }
83 }
84 
85 
86 
Common abstract parent of all Field<...> classes.
Definition: field_common.hh:57
unsigned long int Type
Definition: time_marks.hh:51
bool is_jump_time_
Class Input::Type::Default specifies default value of keys of a Input::Type::Record.
Definition: type_record.hh:50
std::string name_
unsigned int component_index_
double last_time_
void mark_input_times(const TimeGovernor &tg)
Definition: field_common.cc:73
FlagArray & add(Mask mask)
Definition: flag_array.hh:170
static const std::string field_descriptor_record_description(const string &record_name)
Definition: field_common.cc:64
Class for declaration of the integral input data.
Definition: type_base.hh:460
Basic time management functionality for unsteady (and steady) solvers (class Equation).
static TimeMarks & marks()
Class for declaration of inputs sequences.
Definition: type_base.hh:316
std::shared_ptr< SharedData > shared_
void add(const TimeMark &mark)
Definition: time_marks.cc:74
double time() const
Class for declaration of the input data that are floating point numbers.
Definition: type_base.hh:513
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:39
FieldFlag::Flags & flags()
TimeMark::Type equation_fixed_mark_type() const
FieldFlag::Flags flags_
Field flags. Default setting is "an equation input field, that can read from user input...
static IT::Record field_descriptor_record(const string &record_name)
Definition: field_common.cc:54
Record & declare_key(const string &key, std::shared_ptr< TypeBase > type, const Default &default_value, const string &description, TypeBase::attribute_map key_attributes=TypeBase::attribute_map())
Declares a new key of the Record.
Definition: type_record.cc:459
LimitSide last_limit_side_
const Record & close() const
Close the Record for further declarations of keys.
Definition: type_record.cc:271
virtual ~FieldCommon()
Definition: field_common.cc:87
Class used for marking specified times at which some events occur.
Definition: time_marks.hh:36
Record type proxy class.
Definition: type_record.hh:171
Class for declaration of the input data that are in string format.
Definition: type_base.hh:563
TimeStatus set_time_result_
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