18 #ifndef FIELD_COMMON_HH_ 19 #define FIELD_COMMON_HH_ 80 <<
"Non-ascending time: " << EI_Time::val <<
" for field " << EI_Field::qval <<
".\n");
82 <<
"Missing domain specification (region or r_id) in the field descriptor:");
84 <<
"Two copies of the field " << EI_Field::qval <<
"call set_mesh with different arguments.\n");
91 MessageData(std::string default_value, std::string field_name, std::string region_list)
92 : default_value_(default_value), field_name_(field_name), region_list_(region_list) {};
112 { name_=shared_->input_name_ = name;
119 { shared_->input_description_ = description;
return *
this;}
131 { shared_->input_default_ = input_default;
return *
this;}
144 { shared_->units_ = units;
return *
this;}
151 ASSERT(min < max)(min)(max).error(
"Invalid field limits!");
152 shared_->limits_ = std::make_pair(min, max);
164 shared_->input_element_selection_=element_selection;
189 { flags().add(mask);
return *
this; }
202 std::sort( cpy.begin(), cpy.end() );
203 cpy.erase( std::unique( cpy.begin(), cpy.end() ), cpy.end() );
204 if (names.size() != cpy.size()) {
205 THROW( Input::ExcInputMessage() << EI_Message(
"The field " + this->input_name()
206 +
" has set non-unique names of components.") );
208 shared_->n_comp_ = names.size();
210 shared_->n_comp_ = (shared_->n_comp_ ? names.size() : 0);
213 shared_->comp_names_ = names;
220 virtual void set_mesh(
const Mesh &mesh) = 0;
234 {
return shared_->input_name_;}
236 const std::string &
name()
const 240 {
return shared_->input_description_;}
243 {
return shared_->input_default_;}
247 ASSERT(shared_->units_.is_def())(name()).error(
"Getting undefined unit.\n");
248 return shared_->units_;
253 return shared_->limits_;
257 {
return type_of_output_data_; }
260 {
return shared_->bc_;}
263 {
return shared_->comp_names_.size();}
266 {
return shared_->mesh_;}
279 {
return last_time_; }
286 return is_jump_time_;
293 return shared_->input_list_.size();
307 virtual bool is_constant(
Region reg) =0;
336 virtual std::string get_value_attribute()
const =0;
344 ASSERT( set_time_result_ != TimeStatus::unknown ).error(
"Invalid time status.");
345 return ( (set_time_result_ == TimeStatus::changed) );
353 static IT::Record field_descriptor_record(
const string& record_name);
358 static const std::string field_descriptor_record_description(
const string& record_name);
370 virtual IT::Array get_multifield_input_type() =0;
412 virtual void copy_from(
const FieldCommon & other) =0;
419 virtual void field_output(std::shared_ptr<OutputTime> stream) =0;
426 virtual void observe_output(std::shared_ptr<Observe> observe) =0;
438 this->component_index_ = idx;
447 return this->multifield_;
453 virtual void cache_reallocate(
const ElementCacheMap &cache_map,
unsigned int region_idx)
const = 0;
458 virtual void cache_update(
ElementCacheMap &cache_map,
unsigned int region_patch_idx)
const = 0;
486 static bool print_message_table(ostream& stream, std::string equation_name);
520 last_time_ = -numeric_limits<double>::infinity();
524 if (n_cols==1) this->shape_ = { n_rows };
525 else this->shape_ = { n_rows, n_cols };
542 : list_idx_(0), limits_(
std::make_pair(-
std::numeric_limits<double>::max(),
std::numeric_limits<double>::max())) {};
645 double last_time_ = -numeric_limits<double>::infinity();
673 static const unsigned int history_length_limit_=3;
689 <<
"field name:" << field.
name()
690 <<
" n. comp.:" << field.
n_comp()
692 <<
" last limit side:" << limit_side_str[(
unsigned int) field.
last_limit_side_];
700 { set_time_result_ = TimeStatus::changed; }
std::string input_description_
Common abstract parent of all Field<...> classes.
Container for various descendants of FieldCommonBase.
std::pair< double, double > limits_
FieldCommon & input_selection(Input::Type::Selection element_selection)
static constexpr Mask allow_output
The field can output. Is part of generated output selection. (default on)
FieldFlag::Flags get_flags() const
FieldCommon & flags_add(FieldFlag::Flags::Mask mask)
OutputTime::DiscreteSpace get_output_type() const
#define DECLARE_EXCEPTION(ExcName, Format)
Macro for simple definition of exceptions.
unsigned int component_index_
std::pair< double, double > limits() const
Store data of one initialization message.
vector< Input::Record > input_list_
Directing class of FieldValueCache.
const std::string & input_default() const
#define ASSERT(expr)
Allow use shorter versions of macro names if these names is not used with external library...
Basic time management functionality for unsteady (and steady) solvers (class Equation).
FieldCommon & units(const UnitSI &units)
Set basic units of the field.
const std::string description() const
Basic time management class.
std::vector< uint > shape_
std::string default_value_
Default value of the field.
std::shared_ptr< SharedData > shared_
friend std::ostream & operator<<(std::ostream &stream, const FieldCommon &field)
std::string field_name_
Parameter name_ of the field.
const std::string & name() const
FieldFlag::Flags & flags()
FieldCommon & input_default(const string &input_default)
const UnitSI & units() const
void set_time_result_changed()
Manually mark flag that the field has been changed.
MessageData(std::string default_value, std::string field_name, std::string region_list)
Constructor.
virtual FieldCommon * get_component(FMT_UNUSED unsigned int idx)
unsigned int input_list_size() const
bool is_multifield() const
LimitSide last_limit_side_
void set_shape(uint n_rows, uint n_cols)
#define TYPEDEF_ERR_INFO(EI_Type, Type)
Macro to simplify declaration of error_info types.
std::vector< FieldEnum > no_check_values_
#define DECLARE_INPUT_EXCEPTION(ExcName, Format)
Macro for simple definition of input exceptions.
FieldCommon & description(const string &description)
Class holds local coordinations of evaluating points (bulk and sides) specified by element dimension...
static std::vector< MessageData > messages_data_
Vector of data of initialization messages.
void set_component_index(unsigned int idx)
IT::Selection input_element_selection_
const Mesh * mesh() const
FieldCommon & name(const string &name)
unsigned int n_comp() const
void set_components(const std::vector< string > &names)
void set_history_changed()
FieldCommon & set_limits(double min, double max=std::numeric_limits< double >::max())
FlagArray< FieldFlag > Flags
FieldCommon & flags(FieldFlag::Flags::Mask mask)
const std::string & input_name() const
static constexpr Mask equation_input
The field is data parameter of the owning equation. (default on)
Class for representation SI units of Fields.
#define THROW(whole_exception_expr)
Wrapper for throw. Saves the throwing point.
Representation of one time step..
TimeStatus set_time_result_
std::string region_list_
List of regions separated by comma.
FieldCommon & output_type(OutputTime::DiscreteSpace rt)
static constexpr Mask declare_input
The field can be set from input. The key in input field descriptor is declared. (default on) ...
std::vector< std::string > comp_names_
bool is_fully_initialized_