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) {};
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;
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_->comp_names_.size();}
279 ASSERT_LT(i_comp, shared_->comp_names_.size());
280 return shared_->comp_names_[i_comp].empty() ? this->name()
281 : shared_->comp_names_[i_comp] +
"_" + this->name();
285 {
return shared_->mesh_;}
298 {
return last_time_; }
305 return is_jump_time_;
312 return shared_->input_list_.size();
363 ASSERT( set_time_result_ != TimeStatus::unknown ).error(
"Invalid time status.");
364 return ( (set_time_result_ == TimeStatus::changed) ||
365 (set_time_result_ == TimeStatus::changed_forced) );
373 static IT::Record field_descriptor_record(
const string& record_name);
378 static const std::string field_descriptor_record_description(
const string& record_name);
451 this->component_index_ = idx;
460 return this->multifield_;
518 static bool print_message_table(ostream& stream, std::string equation_name);
527 shared_->default_fieldset_ = &default_fs;
537 if (shape_.size() == 1)
return shape_[0];
538 else return shape_[0] * shape_[1];
568 last_time_ = -numeric_limits<double>::infinity();
572 if (n_cols==1) this->shape_ = { n_rows };
573 else this->shape_ = { n_rows, n_cols };
590 : list_idx_(0), limits_(
std::make_pair(-
std::numeric_limits<double>::max(),
std::numeric_limits<double>::max())) {};
698 double last_time_ = -numeric_limits<double>::infinity();
726 static const unsigned int history_length_limit_=3;
742 <<
"field name:" << field.
name()
743 <<
" n. comp.:" << field.
n_comp()
745 <<
" last limit side:" << limit_side_str[(
unsigned int) field.
last_limit_side_];
753 { set_time_result_ = TimeStatus::changed_forced; }
#define ASSERT_PERMANENT_LT(a, b)
Definition of comparative assert macro (Less Than)
#define ASSERT_PERMANENT(expr)
Allow use shorter versions of macro names if these names is not used with external library.
#define ASSERT_LT(a, b)
Definition of comparative assert macro (Less Than) only for debug mode.
Base point accessor class.
Directing class of FieldValueCache.
Class holds local coordinations of evaluating points (bulk and sides) specified by element dimension.
Common abstract parent of all Field<...> classes.
friend std::ostream & operator<<(std::ostream &stream, const FieldCommon &field)
TYPEDEF_ERR_INFO(EI_FieldName, std::string)
const std::string description() const
std::shared_ptr< SharedData > shared_
const UnitSI & units() const
virtual IT::Instance get_input_type()=0
DECLARE_INPUT_EXCEPTION(ExcMissingDomain,<< "Missing domain specification (region or r_id) in the field descriptor:")
virtual void cache_reallocate(const ElementCacheMap &cache_map, unsigned int region_idx) const =0
TimeStatus set_time_result_
TYPEDEF_ERR_INFO(EI_FieldInputName, std::string)
FieldCommon & input_selection(Input::Type::Selection element_selection)
virtual bool set_time(const TimeStep &time, LimitSide limit_side)=0
unsigned int component_index_
const std::string & input_default() const
OutputTime::DiscreteSpace get_output_type() const
std::string full_comp_name(unsigned int i_comp) const
const std::string & input_name() const
virtual void set_mesh(const Mesh &mesh)=0
virtual bool is_constant(Region reg)=0
virtual FieldCommon * get_component(FMT_UNUSED unsigned int idx)
virtual std::string get_value_attribute() const =0
const std::string & name() const
virtual void cache_update(ElementCacheMap &cache_map, unsigned int region_patch_idx) const =0
LimitSide last_limit_side_
DECLARE_INPUT_EXCEPTION(ExcMissingFieldValue,<< "Missing value of the input field "<< EI_FieldInputName::qval<< " ("<< EI_FieldName::qval<< ") on region ID: "<< EI_RegId::val<< " label: "<< EI_RegLabel::qval<< ".\n")
TYPEDEF_ERR_INFO(EI_Field, std::string)
FieldCommon & description(const string &description)
std::vector< uint > shape_
virtual const FieldValueCache< double > * value_cache() const =0
virtual FieldResult field_result(RegionSet region_set) const =0
Indicates special field states.
virtual void field_output(std::shared_ptr< OutputTime > stream, OutputTime::DiscreteSpace type)=0
FieldCommon & flags_add(FieldFlag::Flags::Mask mask)
uint n_shape() const
Return number of shape components.
FieldCommon & flags(FieldFlag::Flags::Mask mask)
virtual std::vector< const FieldCommon * > set_dependency(unsigned int i_reg) const =0
virtual FieldValueCache< double > * value_cache()=0
void set_default_fieldset(FieldSet &default_fs)
FieldCommon & name(const string &name)
std::pair< double, double > limits() const
FieldFlag::Flags get_flags() const
TYPEDEF_ERR_INFO(EI_RegLabel, std::string)
void set_component_index(unsigned int idx)
TYPEDEF_ERR_INFO(EI_Time, double)
virtual void set_input_list(const Input::Array &list, const TimeGovernor &tg)=0
FieldCommon & set_limits(double min, double max=std::numeric_limits< double >::max())
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.
unsigned int input_list_size() const
TYPEDEF_ERR_INFO(EI_RegId, unsigned int)
FieldFlag::Flags & flags()
void set_time_result_changed()
Manually mark flag that the field has been changed.
void set_shape(uint n_rows, uint n_cols)
FieldCommon & output_type(OutputTime::DiscreteSpace rt)
void set_components(const std::vector< string > &names)
bool is_multifield() const
virtual IT::Array get_multifield_input_type()=0
virtual void copy_from(const FieldCommon &other)=0
virtual void fill_data_value(FMT_UNUSED const std::vector< int > &offsets)
Fill data to ElementDataCache on given patch.
static std::vector< MessageData > messages_data_
Vector of data of initialization messages.
const Mesh * mesh() const
FieldCommon & units(const UnitSI &units)
Set basic units of the field.
FieldCommon & input_default(const string &input_default)
void set_history_changed()
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<>.
DECLARE_EXCEPTION(ExcFieldMeshDifference,<< "Two copies of the field "<< EI_Field::qval<< "call set_mesh with different arguments.\n")
unsigned int n_comp() const
DECLARE_INPUT_EXCEPTION(ExcNonascendingTime,<< "Non-ascending time: "<< EI_Time::val<< " for field "<< EI_Field::qval<< ".\n")
static constexpr Mask allow_output
The field can output. Is part of generated output selection. (default on)
static constexpr Mask declare_input
The field can be set from input. The key in input field descriptor is declared. (default on)
static constexpr Mask equation_input
The field is data parameter of the owning equation. (default on)
FlagArray< FieldFlag > Flags
Container for various descendants of FieldCommonBase.
Basic time management functionality for unsteady (and steady) solvers (class Equation).
Representation of one time step..
Class for representation SI units of Fields.
#define THROW(whole_exception_expr)
Wrapper for throw. Saves the throwing point.
Store data of one initialization message.
std::string field_name_
Parameter name_ of the field.
MessageData(std::string default_value, std::string field_name, std::string region_list)
Constructor.
std::string default_value_
Default value of the field.
std::string region_list_
List of regions separated by comma.
FieldSet * default_fieldset_
IT::Selection input_element_selection_
std::pair< double, double > limits_
std::string input_description_
bool is_fully_initialized_
std::vector< FieldEnum > no_check_values_
vector< Input::Record > input_list_
std::vector< std::string > comp_names_
Basic time management class.