Go to the documentation of this file.
18 #ifndef FIELD_COMMON_HH_
19 #define FIELD_COMMON_HH_
87 <<
"Non-ascending time: " << EI_Time::val <<
" for field " << EI_Field::qval <<
".\n");
89 <<
"Missing domain specification (region or r_id) in the field descriptor:");
91 <<
"Two copies of the field " << EI_Field::qval <<
"call set_mesh with different arguments.\n");
93 <<
"Missing value of the input field " << EI_FieldInputName::qval <<
" (" << EI_FieldName::qval
94 <<
") on region ID: " << EI_RegId::val <<
" label: " << EI_RegLabel::qval <<
".\n");
101 MessageData(std::string default_value, std::string field_name, std::string region_list)
102 : default_value_(default_value), field_name_(field_name), region_list_(region_list) {};
104 std::string default_value_;
122 { name_=shared_->input_name_ = name;
129 { shared_->input_description_ = description;
return *
this;}
141 { shared_->input_default_ = input_default;
return *
this;}
154 { shared_->units_ = units;
return *
this;}
162 shared_->limits_ = std::make_pair(min, max);
174 shared_->input_element_selection_=element_selection;
199 { flags().add(mask);
return *
this; }
212 std::sort( cpy.begin(), cpy.end() );
213 cpy.erase( std::unique( cpy.begin(), cpy.end() ), cpy.end() );
214 if (names.size() != cpy.size()) {
215 THROW( Input::ExcInputMessage() << EI_Message(
"The field " + this->input_name()
216 +
" has set non-unique names of components.") );
218 shared_->n_comp_ = names.size();
220 shared_->n_comp_ = (shared_->n_comp_ ? names.size() : 0);
223 shared_->comp_names_ = names;
230 virtual void set_mesh(
const Mesh &mesh) = 0;
244 {
return shared_->input_name_;}
246 const std::string &
name()
const
250 {
return shared_->input_description_;}
253 {
return shared_->input_default_;}
257 ASSERT(shared_->units_.is_def())(name()).error(
"Getting undefined unit.\n");
258 return shared_->units_;
263 return shared_->limits_;
267 {
return default_output_data_; }
270 {
return shared_->bc_;}
273 {
return shared_->comp_names_.size();}
282 ASSERT_LT(i_comp, shared_->comp_names_.size());
283 return shared_->comp_names_[i_comp].empty() ? this->name()
284 : shared_->comp_names_[i_comp] +
"_" + this->name();
288 {
return shared_->mesh_;}
301 {
return last_time_; }
308 return is_jump_time_;
315 return shared_->input_list_.size();
329 virtual bool is_constant(
Region reg) =0;
358 virtual std::string get_value_attribute()
const =0;
366 ASSERT( set_time_result_ != TimeStatus::unknown ).error(
"Invalid time status.");
367 return ( (set_time_result_ == TimeStatus::changed) ||
368 (set_time_result_ == TimeStatus::changed_forced) );
376 static IT::Record field_descriptor_record(
const string& record_name);
381 static const std::string field_descriptor_record_description(
const string& record_name);
393 virtual IT::Array get_multifield_input_type() =0;
435 virtual void copy_from(
const FieldCommon & other) =0;
454 this->component_index_ = idx;
463 return this->multifield_;
469 virtual void cache_reallocate(
const ElementCacheMap &cache_map,
unsigned int region_idx)
const = 0;
474 virtual void cache_update(
ElementCacheMap &cache_map,
unsigned int region_patch_idx)
const = 0;
521 static bool print_message_table(ostream& stream, std::string equation_name);
530 if (shape_.size() == 1)
return shape_[0];
531 else return shape_[0] * shape_[1];
561 last_time_ = -numeric_limits<double>::infinity();
565 if (n_cols==1) this->shape_ = { n_rows };
566 else this->shape_ = { n_rows, n_cols };
583 : list_idx_(0), limits_(
std::make_pair(-
std::numeric_limits<double>::max(),
std::numeric_limits<double>::max())) {};
687 double last_time_ = -numeric_limits<double>::infinity();
715 static const unsigned int history_length_limit_=3;
731 <<
"field name:" << field.
name()
732 <<
" n. comp.:" << field.
n_comp()
734 <<
" last limit side:" << limit_side_str[(
unsigned int) field.
last_limit_side_];
742 { set_time_result_ = TimeStatus::changed_forced; }
FieldCommon & units(const UnitSI &units)
Set basic units of the field.
std::shared_ptr< SharedData > shared_
friend std::ostream & operator<<(std::ostream &stream, const FieldCommon &field)
LimitSide last_limit_side_
OutputTime::DiscreteSpace get_output_type() const
Basic time management class.
FieldCommon & output_type(OutputTime::DiscreteSpace rt)
FieldFlag::Flags & flags()
void set_shape(uint n_rows, uint n_cols)
static std::vector< MessageData > messages_data_
Vector of data of initialization messages.
#define ASSERT_PERMANENT_LT(a, b)
Definition of comparative assert macro (Less Than)
void set_component_index(unsigned int idx)
Directing class of FieldValueCache.
const Mesh * mesh() const
Base point accessor class.
#define THROW(whole_exception_expr)
Wrapper for throw. Saves the throwing point.
FieldCommon & set_limits(double min, double max=std::numeric_limits< double >::max())
FieldCommon & flags(FieldFlag::Flags::Mask mask)
static constexpr Mask allow_output
The field can output. Is part of generated output selection. (default on)
std::pair< double, double > limits_
void set_time_result_changed()
Manually mark flag that the field has been changed.
const std::string description() const
std::string field_name_
Parameter name_ of the field.
IT::Selection input_element_selection_
#define ASSERT_LT(a, b)
Definition of comparative assert macro (Less Than) only for debug mode.
std::vector< uint > shape_
FieldCommon & flags_add(FieldFlag::Flags::Mask mask)
const std::string & input_default() const
std::vector< std::string > comp_names_
#define ASSERT_PERMANENT(expr)
Allow use shorter versions of macro names if these names is not used with external library.
const UnitSI & units() const
MessageData(std::string default_value, std::string field_name, std::string region_list)
Constructor.
bool is_fully_initialized_
std::string input_description_
Representation of one time step..
Basic time management functionality for unsteady (and steady) solvers (class Equation).
Common abstract parent of all Field<...> classes.
Class for representation SI units of Fields.
std::string region_list_
List of regions separated by comma.
Container for various descendants of FieldCommonBase.
virtual void fill_data_value(FMT_UNUSED const std::vector< int > &offsets)
Fill data to ElementDataCache on given patch.
vector< Input::Record > input_list_
#define TYPEDEF_ERR_INFO(EI_Type, Type)
Macro to simplify declaration of error_info types.
bool is_multifield() const
void set_components(const std::vector< string > &names)
FieldCommon & input_default(const string &input_default)
virtual void fill_observe_value(FMT_UNUSED std::shared_ptr< ElementDataCacheBase > output_cache_base, FMT_UNUSED const std::vector< int > &offsets)
Fill data to ElementDataCache on given patch.
FlagArray< FieldFlag > Flags
#define DECLARE_INPUT_EXCEPTION(ExcName, Format)
Macro for simple definition of input exceptions.
static constexpr Mask equation_input
The field is data parameter of the owning equation. (default on)
FieldFlag::Flags get_flags() const
static constexpr Mask declare_input
The field can be set from input. The key in input field descriptor is declared. (default on)
const std::string & name() const
unsigned int n_comp() const
virtual void set_output_data_cache(FMT_UNUSED OutputTime::DiscreteSpace space_type, FMT_UNUSED std::shared_ptr< OutputTime > stream)
Create and set shared_ptr to ElementDataCache. Used only in descendant Field<>.
std::string full_comp_name(unsigned int i_comp) const
std::vector< FieldEnum > no_check_values_
uint n_shape() const
Return number of shape components.
const std::string & input_name() const
std::pair< double, double > limits() const
FieldCommon & input_selection(Input::Type::Selection element_selection)
FieldCommon & description(const string &description)
#define DECLARE_EXCEPTION(ExcName, Format)
Macro for simple definition of exceptions.
void set_history_changed()
Store data of one initialization message.
TimeStatus set_time_result_
unsigned int input_list_size() const
unsigned int component_index_
FieldCommon & name(const string &name)
virtual FieldCommon * get_component(FMT_UNUSED unsigned int idx)
Class holds local coordinations of evaluating points (bulk and sides) specified by element dimension.