18 #ifndef MULTI_FIELD_IMPL_HH_ 19 #define MULTI_FIELD_IMPL_HH_ 37 template<
int spacedim,
class Value>
40 no_check_control_field_(nullptr)
45 this->
set_shape( Value::NRows_, Value::NCols_ );
50 template<
int spacedim,
class Value>
58 this->
set_shape( Value::NRows_, Value::NCols_ );
63 template<
int spacedim,
class Value>
69 .error(
"Assignment between multi fields with different meshes.\n");
70 ASSERT_GT_DBG(
shared_->comp_names_.size(), 0).error(
"Vector of component names can't be empty!\n");
72 .error(
"Both multi fields must have same size of vectors of component names.\n");
75 if (&other ==
this)
return *
this;
80 shared_->comp_names_ = comp_names;
81 shared_->is_fully_initialized_ =
false;
95 for (
unsigned int i=0; i<other.
size(); ++i) {
97 if (this->
shared_->comp_names_[i].length() == 0)
98 THROW( Input::ExcInputMessage() << EI_Message(
"The field " + this->
input_name()
99 +
" has set empty name of component.") );
105 THROW( ExcMessage() << EI_Message(
"Internal error. Assignment operator can't be used after call setup_component() method.") );
115 template<
int spacedim,
class Value>
117 ASSERT(
false).error(
"This method can't be used for MultiField");
125 template<
int spacedim,
class Value>
132 template<
int spacedim,
class Value>
138 shared_->no_check_values_=value_list;
143 template<
int spacedim,
class Value>
156 if (field.set_time(time, limit_side))
165 template<
int spacedim,
class Value>
169 THROW(ExcFieldMeshDifference() << EI_Field(
name()) );
176 template<
int spacedim,
class Value>
179 .error(
"Can not copy to the non-copy field.");
183 && this->
shared_->input_list_.size() != 0 )
return;
185 if (
typeid(other) ==
typeid(*this)) {
189 auto const &other_field =
dynamic_cast< SubFieldType const &
>(other);
197 template<
int spacedim,
class Value>
206 for (
unsigned long index=0; index < this->
size(); index++) {
207 sub_fields_[index].compute_field_data( type, stream );
214 template<
int spacedim,
class Value>
217 for(
auto &field :
sub_fields_) field.observe_output(observe);
223 template<
int spacedim,
class Value>
226 for(
auto &field :
sub_fields_) const_all = const_all && field.is_constant(reg);
230 template<
int spacedim,
class Value>
233 ASSERT_DBG(
true).error(
"Not used yet. Test it.");
237 FieldResult sub_result = field.field_result(region_set);
241 result_all = sub_result;
244 else if (sub_result != result_all)
253 template<
int spacedim,
class Value>
256 int nrows = Value::NRows_;
257 int ncols = Value::NCols_;
258 string type =
"Integer";
262 return fmt::format(
"{{ \"subfields\": true, \"shape\": [ {}, {} ], \"type\": \"{}\", \"limit\": [ {}, {} ] }}",
263 nrows, ncols, type, this->
limits().first, this->
limits().second);
267 template<
int spacedim,
class Value>
269 unsigned int comp_size = this->
shared_->comp_names_.size();
271 ASSERT_GT(comp_size, 0).error(
"Vector of component names is empty!\n");
275 for(
unsigned int i_comp=0; i_comp < comp_size; i_comp++)
277 if (this->
shared_->comp_names_[i_comp].length() == 0)
280 full_name = this->
shared_->comp_names_[i_comp] +
"_" +
name();
290 sub_fields_[i_comp].add_factory( std::make_shared<MultiFieldFactory>(i_comp) );
292 if (this->
shared_->input_default_!=
"") {
303 template<
int spacedim,
class Value>
312 if (
it->opt_val(this->input_name(), mf_array) ) {
313 unsigned int comp_size = this->
shared_->comp_names_.size();
314 if (mf_array.
size() != 1 && mf_array.
size() != comp_size)
315 THROW( Exc_InvalidMultiFieldSize() << EI_MultiFieldName(this->
input_name())
316 << EI_Size(mf_array.
size()) << EI_ExpectedSize(comp_size) << list.
ei_address() );
351 template<
int spacedim,
class Value>
358 unsigned int position = 0;
360 if (multifield_arr.
size() > 1)
361 while (index_ != position) {
367 field_algo_base->set_component_idx(index_);
368 return field_algo_base;
376 template<
int spacedim,
class Value>
382 template<
int spacedim,
class Value>
384 ASSERT(
false).error(
"Set dependency of MultiField should be performed by individual components!\n");
390 template<
int spacedim,
class Value>
393 ASSERT(
false).error(
"Cache reallocate of MultiField should be performed by individual components!\n");
397 template<
int spacedim,
class Value>
399 FMT_UNUSED unsigned int region_patch_idx)
const {
400 ASSERT(
false).error(
"Cache update of MultiField should be performed by individual components!\n");
404 template<
int spacedim,
class Value>
410 unsigned int comp_size = this->
shared_->comp_names_.size();
411 ASSERT_GT_DBG(comp_size, 0).error(
"Vector of component names is empty!\n");
416 for(
unsigned int i_comp=0; i_comp < comp_size; i_comp++)
421 sub_fields_[i_comp].set(field_vec[i_comp], time, region_set_names);
426 template<
int spacedim,
class Value>
432 ASSERT_EQ_DBG(this->
shared_->comp_names_.size(), 1).error(
"Size of component names vector must be 1!\n");
IT::Instance get_input_type() override
void cache_reallocate(const ElementCacheMap &cache_map, unsigned int region_idx) const override
Implements FieldCommon::cache_reallocate.
std::string get_value_attribute() const override
Common abstract parent of all Field<...> classes.
Container for various descendants of FieldCommonBase.
#define ASSERT_EQ_DBG(a, b)
Definition of comparative assert macro (EQual) only for debug mode.
std::vector< const FieldCommon * > set_dependency(FieldSet &field_set, unsigned int i_reg) const override
auto disable_where(const MultiField< spacedim, typename FieldValue< spacedim >::Enum > &control_field, const vector< FieldEnum > &value_list) -> MultiField &
unsigned int size() const
Number of subfields that compose the multi-field.
FieldFlag::Flags get_flags() const
static const Input::Type::Instance & get_input_type_instance(Input::Type::Selection value_selection=Input::Type::Selection())
bool is_active_field_descriptor(const Input::Record &in_rec, const std::string &input_name) override
OutputTime::DiscreteSpace get_output_type() const
void copy_from(const FieldCommon &other) override
Class template representing a field with values dependent on: point, element, and region...
std::string format(CStringRef format_str, ArgList args)
unsigned int component_index_
std::pair< double, double > limits() const
#define ASSERT_GT(a, b)
Definition of comparative assert macro (Greater Than)
Directing class of FieldValueCache.
Field< spacedim, Value > SubFieldType
const MultiField< spacedim, typename FieldValue< spacedim >::Enum > * no_check_control_field_
Helper struct stores data for initizalize descentants of FieldAlgorithmBase.
#define ASSERT(expr)
Allow use shorter versions of macro names if these names is not used with external library...
MultiField & operator=(const MultiField &other)
#define ASSERT_GT_DBG(a, b)
Definition of comparative assert macro (Greater Than) only for debug mode.
Basic time management functionality for unsteady (and steady) solvers (class Equation).
FieldCommon & units(const UnitSI &units)
Set basic units of the field.
void set(std::vector< typename Field< spacedim, Value >::FieldBasePtr > field_vec, double time, std::vector< std::string > region_set_names={"ALL"})
void set_input_list(const Input::Array &list, const TimeGovernor &tg) override
Input::Array full_input_list_
Full list of input field descriptors from which the subfields of MultiField are set.
static constexpr bool value
std::vector< uint > shape_
constexpr bool match(Mask mask) const
std::shared_ptr< SharedData > shared_
const std::string & name() const
std::vector< SubFieldType > sub_fields_
Subfields (items) of MultiField.
FieldFlag::Flags & flags()
virtual Field< spacedim, Value >::FieldBasePtr create_field(Input::Record rec, const FieldCommon &field)
const UnitSI & units() const
FieldFlag::Flags flags_
Field flags. Default setting is "an equation input field, that can read from user input...
static const unsigned int N_DISCRETE_SPACES
const TimeGovernor * tg_
TimeGovernor is necessary for set input list in setup_components method.
bool set_time(const TimeStep &time, LimitSide limit_side) override
LimitSide last_limit_side_
void set_shape(uint n_rows, uint n_cols)
FieldResult field_result(RegionSet region_set) const override
Indicates special field states.
MultiField(bool bc=false)
void cache_update(ElementCacheMap &cache_map, unsigned int region_patch_idx) const override
Implements FieldCommon::cache_update.
void field_output(std::shared_ptr< OutputTime > stream) override
static std::shared_ptr< FieldAlgorithmBase< spacedim, Value > > function_factory(const Input::AbstractRecord &rec, const struct FieldAlgoBaseInitData &init_data)
std::shared_ptr< FieldBaseType > FieldBasePtr
bool is_constant(Region reg) override
#define ASSERT_PTR(ptr)
Definition of assert macro checking non-null pointer (PTR)
IT::Array get_multifield_input_type() override
const Mesh * mesh() const
FieldCommon & name(const string &name)
unsigned int n_comp() const
Class for representation of a vector of fields of the same physical quantity.
const std::string & input_name() const
static constexpr Mask equation_input
The field is data parameter of the owning equation. (default on)
#define ASSERT_PTR_DBG(ptr)
Definition of assert macro checking non-null pointer (PTR) only for debug mode.
#define THROW(whole_exception_expr)
Wrapper for throw. Saves the throwing point.
Representation of one time step..
TimeStatus set_time_result_
void observe_output(std::shared_ptr< Observe > observe) override
void set_mesh(const Mesh &mesh) override
static constexpr Mask declare_input
The field can be set from input. The key in input field descriptor is declared. (default on) ...
#define ASSERT_LT_DBG(a, b)
Definition of comparative assert macro (Less Than) only for debug mode.