8 #ifndef MULTI_FIELD_IMPL_HH_
9 #define MULTI_FIELD_IMPL_HH_
15 namespace it = Input::Type;
21 template<
int spacedim,
class Value>
30 template<
int spacedim,
class Value>
32 ASSERT(
false,
"This method can't be used for MultiField");
39 template<
int spacedim,
class Value>
44 "Names of MultiField components.")
46 "Supplied to components subtree.")
48 "Components of Multifield.");
54 template<
int spacedim,
class Value>
59 if (sub_fields_.size() == 0) {
66 if (field.set_time(time))
74 template<
int spacedim,
class Value>
77 if (shared_->mesh_ && shared_->mesh_ != &mesh) {
78 THROW(ExcFieldMeshDifference() << EI_Field(name()) );
81 shared_->mesh_ = &mesh;
85 template<
int spacedim,
class Value>
87 if (
typeid(other) ==
typeid(*
this)) {
89 this->operator=(other_field);
91 auto const &other_field =
dynamic_cast< SubFieldType const &
>(other);
92 sub_fields_.resize(1);
93 sub_fields_[0] = other_field;
99 template<
int spacedim,
class Value>
111 template<
int spacedim,
class Value>
113 bool const_all=
false;
114 for(
auto field : sub_fields_) const_all = const_all || field.is_constant(reg);
120 template<
int spacedim,
class Value>
122 ASSERT(this->shared_->comp_names_.size(),
"Vector of component names is empty!\n");
123 ASSERT(this->shared_->mesh_,
"Mesh is not set!\n");
125 sub_fields_.resize( this->shared_->comp_names_.size() );
126 for(
unsigned int i_comp=0; i_comp < size(); i_comp++)
128 sub_fields_[i_comp].units( units() );
129 sub_fields_[i_comp].set_mesh( *(shared_->mesh_) );
130 sub_fields_[i_comp].set_limit_side(this->limit_side_);
131 sub_fields_[i_comp].add_factory( std::make_shared<MultiFieldFactory>(i_comp) );
132 sub_fields_[i_comp].set_component_index(i_comp);
134 if (this->shared_->comp_names_[i_comp].length() == 0)
135 sub_fields_[i_comp].name( name() );
137 sub_fields_[i_comp].name_ = this->shared_->comp_names_[i_comp] +
"_" + name();
138 sub_fields_[i_comp].shared_->input_name_ = name();
141 sub_fields_[i_comp].set_input_list(this->shared_->input_list_);
147 template<
int spacedim,
class Value>
153 if (it_common && !it_components) {
154 it_common->transpose_to( multifield_rec,
"components", spacedim );
158 ASSERT(it_components,
"Failed to fill 'components' array of multifield: %s.", field.
input_name().c_str());
159 ASSERT(index_ < it_components->
size(),
"Index of MultiField component is out of range.\n");
161 unsigned int position = 0;
162 for (
auto it = it_components->begin<
Input::AbstractRecord>(); it != it_components->end(); ++it, ++position)
166 field_algo_base->set_component_idx(
index_);
167 return field_algo_base;
Common abstract parent of all Field<...> classes.
unsigned int size() const
Number of subfields that compose the multi-field.
IT::Record & get_multifield_input_type() override
void copy_from(const FieldCommon &other) override
Class template representing a field with values dependent on: point, element, and region...
bool set_time(const TimeStep &time) override
void register_data(const DiscreteSpace type, MultiField< spacedim, Value > &multi_field)
Generic method for registering output data stored in MultiField.
virtual Field< spacedim, Value >::FieldBasePtr create_field(Input::Record rec, const FieldCommon &field)
static std::shared_ptr< FieldAlgorithmBase< spacedim, Value > > function_factory(const Input::AbstractRecord &rec, unsigned int n_comp=0)
IT::AbstractRecord & get_input_type() override
The class for outputting data during time.
std::shared_ptr< FieldBaseType > FieldBasePtr
bool is_constant(Region reg) override
unsigned int n_comp() const
void output(OutputTime *stream) override
Class for representation of a vector of fields of the same physical quantity.
const std::string & input_name() const
#define THROW(whole_exception_expr)
Wrapper for throw. Saves the throwing point.
Representation of one time step.
void set_mesh(const Mesh &mesh) override