Flow123d  JS_before_hm-2111-g101b53ca4
Classes | Public Types | Public Member Functions | Private Attributes | List of all members
MultiField< spacedim, Value > Class Template Reference

Class for representation of a vector of fields of the same physical quantity. More...

#include <multi_field.hh>

Inheritance diagram for MultiField< spacedim, Value >:
Inheritance graph
[legend]
Collaboration diagram for MultiField< spacedim, Value >:
Collaboration graph
[legend]

Classes

class  MultiFieldFactory
 

Public Types

typedef FieldAlgorithmBase< spacedim, ValueSubFieldBaseType
 
typedef Field< spacedim, ValueSubFieldType
 
typedef FieldAlgorithmBase< spacedim, Value >::Point Point
 
typedef FieldValue_< 0, 1, typename Value::element_type > MultiFieldValue
 

Public Member Functions

 TYPEDEF_ERR_INFO (EI_MultiFieldName, const string)
 
 TYPEDEF_ERR_INFO (EI_Size, unsigned int)
 
 TYPEDEF_ERR_INFO (EI_ExpectedSize, unsigned int)
 
 DECLARE_INPUT_EXCEPTION (Exc_InvalidMultiFieldSize,<< "Invalid size "<< EI_Size::val<< "of the MultiField "<< EI_MultiFieldName::qval<< ", expected size: "<< EI_ExpectedSize::val)
 
 MultiField (bool bc=false)
 
 MultiField (const MultiField &other)
 
MultiFieldoperator= (const MultiField &other)
 
IT::Instance get_input_type () override
 
IT::Array get_multifield_input_type () override
 
auto disable_where (const MultiField< spacedim, typename FieldValue< spacedim >::Enum > &control_field, const vector< FieldEnum > &value_list) -> MultiField &
 
bool set_time (const TimeStep &time, LimitSide limit_side) override
 
void set_mesh (const Mesh &mesh) override
 
void copy_from (const FieldCommon &other) override
 
void field_output (std::shared_ptr< OutputTime > stream, OutputTime::DiscreteSpace type) override
 
void observe_output (std::shared_ptr< Observe > observe) override
 
bool is_constant (Region reg) override
 
FieldResult field_result (RegionSet region_set) const override
 Indicates special field states. More...
 
std::string get_value_attribute () const override
 
virtual ~MultiField ()
 
unsigned int size () const
 Number of subfields that compose the multi-field. More...
 
std::vector< const FieldCommon * > set_dependency (FieldSet &field_set, unsigned int i_reg) const override
 
SubFieldTypeoperator[] (unsigned int idx)
 
const SubFieldTypeoperator[] (unsigned int idx) const
 
FieldCommonget_component (unsigned int idx) override
 
void setup_components ()
 
void set_input_list (const Input::Array &list, const TimeGovernor &tg) override
 
void cache_reallocate (const ElementCacheMap &cache_map, unsigned int region_idx) const override
 Implements FieldCommon::cache_reallocate. More...
 
void cache_update (ElementCacheMap &cache_map, unsigned int region_patch_idx) const override
 Implements FieldCommon::cache_update. More...
 
void set (std::vector< typename Field< spacedim, Value >::FieldBasePtr > field_vec, double time, std::vector< std::string > region_set_names={"ALL"})
 
void set (typename Field< spacedim, Value >::FieldBasePtr field, double time, std::vector< std::string > region_set_names={"ALL"})
 
FieldValueCache< double > * value_cache () override
 Implements FieldCommon::value_cache. More...
 
const FieldValueCache< double > * value_cache () const override
 Implements FieldCommon::value_cache. More...
 
- Public Member Functions inherited from FieldCommon
 TYPEDEF_ERR_INFO (EI_Time, double)
 
 TYPEDEF_ERR_INFO (EI_Field, std::string)
 
 TYPEDEF_ERR_INFO (EI_FieldInputName, std::string)
 
 TYPEDEF_ERR_INFO (EI_FieldName, std::string)
 
 TYPEDEF_ERR_INFO (EI_RegId, unsigned int)
 
 TYPEDEF_ERR_INFO (EI_RegLabel, std::string)
 
 DECLARE_INPUT_EXCEPTION (ExcNonascendingTime,<< "Non-ascending time: "<< EI_Time::val<< " for field "<< EI_Field::qval<< ".\n")
 
 DECLARE_INPUT_EXCEPTION (ExcMissingDomain,<< "Missing domain specification (region or r_id) in the field descriptor:")
 
 DECLARE_EXCEPTION (ExcFieldMeshDifference,<< "Two copies of the field "<< EI_Field::qval<< "call set_mesh with different arguments.\n")
 
 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")
 
FieldCommonname (const string &name)
 
FieldCommondescription (const string &description)
 
FieldCommoninput_default (const string &input_default)
 
FieldCommonunits (const UnitSI &units)
 Set basic units of the field. More...
 
FieldCommonset_limits (double min, double max=std::numeric_limits< double >::max())
 
FieldCommoninput_selection (Input::Type::Selection element_selection)
 
FieldCommonoutput_type (OutputTime::DiscreteSpace rt)
 
FieldCommonflags (FieldFlag::Flags::Mask mask)
 
FieldCommonflags_add (FieldFlag::Flags::Mask mask)
 
void set_components (const std::vector< string > &names)
 
const std::string & input_name () const
 
const std::string & name () const
 
const std::string description () const
 
const std::string & input_default () const
 
const UnitSIunits () const
 
std::pair< double, double > limits () const
 
OutputTime::DiscreteSpace get_output_type () const
 
bool is_bc () const
 
unsigned int n_comp () const
 
std::string full_comp_name (unsigned int i_comp) const
 
const Meshmesh () const
 
FieldFlag::Flagsflags ()
 
FieldFlag::Flags get_flags () const
 
double time () const
 
bool is_jump_time ()
 
unsigned int input_list_size () const
 
bool changed () const
 
void mark_input_times (const TimeGovernor &tg)
 
void set_component_index (unsigned int idx)
 
bool is_multifield () const
 
virtual FieldCommonget_component (FMT_UNUSED unsigned int idx)
 
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<>. More...
 
virtual void fill_data_value (FMT_UNUSED const std::vector< int > &offsets)
 Fill data to ElementDataCache on given patch. More...
 
virtual ~FieldCommon ()
 
void set_time_result_changed ()
 Manually mark flag that the field has been changed. More...
 

Private Attributes

std::vector< SubFieldTypesub_fields_
 Subfields (items) of MultiField. More...
 
Input::Array full_input_list_
 Full list of input field descriptors from which the subfields of MultiField are set. More...
 
const TimeGovernortg_
 TimeGovernor is necessary for set input list in setup_components method. More...
 
const MultiField< spacedim, typename FieldValue< spacedim >::Enum > * no_check_control_field_
 

Additional Inherited Members

- Static Public Member Functions inherited from FieldCommon
static IT::Record field_descriptor_record (const string &record_name)
 
static const std::string field_descriptor_record_description (const string &record_name)
 
static bool print_message_table (ostream &stream, std::string equation_name)
 
- Public Attributes inherited from FieldCommon
std::vector< uintshape_
 
- Protected Types inherited from FieldCommon
enum  TimeStatus { TimeStatus::changed, TimeStatus::constant, TimeStatus::changed_forced, TimeStatus::unknown }
 
- Protected Member Functions inherited from FieldCommon
 FieldCommon ()
 
 FieldCommon (const FieldCommon &other)
 
void set_history_changed ()
 
void set_shape (uint n_rows, uint n_cols)
 
- Protected Attributes inherited from FieldCommon
std::string name_
 
std::shared_ptr< SharedDatashared_
 
TimeStatus set_time_result_
 
double last_time_ = -numeric_limits<double>::infinity()
 
LimitSide last_limit_side_ = LimitSide::left
 
bool is_jump_time_
 
OutputTime::DiscreteSpace default_output_data_ = OutputTime::ELEM_DATA
 
unsigned int component_index_
 
bool multifield_
 
FieldFlag::Flags flags_ = FieldFlag::declare_input & FieldFlag::equation_input & FieldFlag::allow_output
 Field flags. Default setting is "an equation input field, that can read from user input, and can be written to output". More...
 
- Static Protected Attributes inherited from FieldCommon
static const unsigned int history_length_limit_ =3
 
static std::vector< MessageDatamessages_data_ = std::vector<FieldCommon::MessageData>()
 Vector of data of initialization messages. More...
 

Detailed Description

template<int spacedim, class Value>
class MultiField< spacedim, Value >

Class for representation of a vector of fields of the same physical quantity.

When solving a system of same equations with the number of components given at runtime (as in the case of transport equation for runtime given number of substances) we need means how to work with the whole vector of fields at once. This is the aim of this class. It provides the interface given by the parent class FieldCommonBase, but principally it is just a vector of Field<Value,dim> objects. The sub-fields or components of a MultiField are independent objects, how ever the setters propagates the values from the MultiFields to the individual fields. The only exception is the set_name method which in conjunction with MultiField::set_subfield_names can set unique name to each component.

Template parameters are used for every subfield.

TODO:

Definition of MultiField must be in separate file. In other case source file field.cc is too big and compiler can throw compile error.

Definition at line 87 of file multi_field.hh.

Member Typedef Documentation

◆ MultiFieldValue

template<int spacedim, class Value >
typedef FieldValue_<0,1,typename Value::element_type> MultiField< spacedim, Value >::MultiFieldValue

Definition at line 92 of file multi_field.hh.

◆ Point

template<int spacedim, class Value >
typedef FieldAlgorithmBase<spacedim, Value>::Point MultiField< spacedim, Value >::Point

Definition at line 91 of file multi_field.hh.

◆ SubFieldBaseType

template<int spacedim, class Value >
typedef FieldAlgorithmBase<spacedim, Value> MultiField< spacedim, Value >::SubFieldBaseType

Definition at line 89 of file multi_field.hh.

◆ SubFieldType

template<int spacedim, class Value >
typedef Field<spacedim, Value> MultiField< spacedim, Value >::SubFieldType

Definition at line 90 of file multi_field.hh.

Constructor & Destructor Documentation

◆ MultiField() [1/2]

template<int spacedim, class Value >
MultiField< spacedim, Value >::MultiField ( bool  bc = false)

Default constructor. bc indicates boundary multifield.

Definition at line 38 of file multi_field.impl.hh.

◆ MultiField() [2/2]

template<int spacedim, class Value >
MultiField< spacedim, Value >::MultiField ( const MultiField< spacedim, Value > &  other)

Copy constructor.

Definition at line 51 of file multi_field.impl.hh.

◆ ~MultiField()

template<int spacedim, class Value >
virtual MultiField< spacedim, Value >::~MultiField ( )
inlinevirtual

Virtual destructor.

Definition at line 203 of file multi_field.hh.

Member Function Documentation

◆ cache_reallocate()

template<int spacedim, class Value >
void MultiField< spacedim, Value >::cache_reallocate ( const ElementCacheMap cache_map,
unsigned int  region_idx 
) const
overridevirtual

Implements FieldCommon::cache_reallocate.

Implements FieldCommon.

Definition at line 382 of file multi_field.impl.hh.

◆ cache_update()

template<int spacedim, class Value >
void MultiField< spacedim, Value >::cache_update ( ElementCacheMap cache_map,
unsigned int  region_patch_idx 
) const
overridevirtual

Implements FieldCommon::cache_update.

Implements FieldCommon.

Definition at line 389 of file multi_field.impl.hh.

◆ copy_from()

template<int spacedim, class Value >
void MultiField< spacedim, Value >::copy_from ( const FieldCommon other)
overridevirtual

Polymorphic copy. Check correct type, allows copy of MultiField or Field.

Implements FieldCommon.

Definition at line 177 of file multi_field.impl.hh.

◆ DECLARE_INPUT_EXCEPTION()

template<int spacedim, class Value >
MultiField< spacedim, Value >::DECLARE_INPUT_EXCEPTION ( Exc_InvalidMultiFieldSize  ,
<< "Invalid size "<< EI_Size::val<< "of the MultiField< spacedim, Value > "<< EI_MultiFieldName::qval<< "  ,
expected size:"<< EI_ExpectedSize::val   
)

◆ disable_where()

template<int spacedim, class Value >
auto MultiField< spacedim, Value >::disable_where ( const MultiField< spacedim, typename FieldValue< spacedim >::Enum > &  control_field,
const vector< FieldEnum > &  value_list 
) -> MultiField &

By this method you can allow that the field need not to be set on regions (and times) where the given control_field is FieldConstant and has value in given value_list. We check this in the set_time method. Through this mechanism we can switch of e.g. boundary data fields according to the type of the boundary condition.

Definition at line 133 of file multi_field.impl.hh.

Here is the caller graph for this function:

◆ field_output()

template<int spacedim, class Value >
void MultiField< spacedim, Value >::field_output ( std::shared_ptr< OutputTime stream,
OutputTime::DiscreteSpace  type 
)
overridevirtual

Implementation of FieldCommonBase::output().

Implements FieldCommon.

Definition at line 198 of file multi_field.impl.hh.

◆ field_result()

template<int spacedim, class Value >
FieldResult MultiField< spacedim, Value >::field_result ( RegionSet  region_set) const
overridevirtual

Indicates special field states.

Return possible values from the enum FieldResult, see description there.

Only difference to Field<>::field_result is meaning of result_constant. Here we return this value if all subfields are (possibly different) constants.

Not used yet. Possibly tune behavior after usage.

Implements FieldCommon.

Definition at line 229 of file multi_field.impl.hh.

◆ get_component()

template<int spacedim, class Value >
FieldCommon* MultiField< spacedim, Value >::get_component ( unsigned int  idx)
inlineoverride

Returns pointer to the sub-field (component, as FieldCommon) of given index idx.

Definition at line 235 of file multi_field.hh.

◆ get_input_type()

template<int spacedim, class Value >
it::Instance MultiField< spacedim, Value >::get_input_type
overridevirtual

Returns input type of particular field instance, this is usually static member input_type of the corresponding FieldBase class ( with same template parameters), however, for fields returning "Enum" we have to create whole unique Input::Type hierarchy for every instance since every such field use different Selection for initialization, even if all returns just unsigned int.

Implements FieldCommon.

Definition at line 116 of file multi_field.impl.hh.

◆ get_multifield_input_type()

template<int spacedim, class Value >
it::Array MultiField< spacedim, Value >::get_multifield_input_type ( )
overridevirtual

Returns input type for MultiField instance. TODO: temporary solution, see multifield_

Implements FieldCommon.

Definition at line 126 of file multi_field.impl.hh.

◆ get_value_attribute()

template<int spacedim, class Value >
std::string MultiField< spacedim, Value >::get_value_attribute ( ) const
overridevirtual

Return specification of the field value type in form of the string: [ <element type>, NRows, NCols]

Result is valid JSON (and/or flow style YAML). For multifields not implemented.

Implements FieldCommon.

Definition at line 252 of file multi_field.impl.hh.

◆ is_constant()

template<int spacedim, class Value >
bool MultiField< spacedim, Value >::is_constant ( Region  reg)
overridevirtual

Implementation of FieldCommonBase::is_constant().

Implements FieldCommon.

Definition at line 222 of file multi_field.impl.hh.

◆ observe_output()

template<int spacedim, class Value >
void MultiField< spacedim, Value >::observe_output ( std::shared_ptr< Observe observe)
overridevirtual

Implementation of FieldCommonBase::observe_output().

Implements FieldCommon.

Definition at line 213 of file multi_field.impl.hh.

◆ operator=()

template<int spacedim, class Value >
MultiField< spacedim, Value > & MultiField< spacedim, Value >::operator= ( const MultiField< spacedim, Value > &  other)

Assignment operator. Same properties as copy constructor, but class member name_ is not copied.

Definition at line 64 of file multi_field.impl.hh.

◆ operator[]() [1/2]

template<int spacedim, class Value >
SubFieldType& MultiField< spacedim, Value >::operator[] ( unsigned int  idx)
inline

Returns reference to the sub-field (component) of given index idx.

Definition at line 217 of file multi_field.hh.

◆ operator[]() [2/2]

template<int spacedim, class Value >
const SubFieldType& MultiField< spacedim, Value >::operator[] ( unsigned int  idx) const
inline

Returns constant reference to the sub-field (component) of given index idx.

Definition at line 226 of file multi_field.hh.

◆ set() [1/2]

template<int spacedim, class Value >
void MultiField< spacedim, Value >::set ( std::vector< typename Field< spacedim, Value >::FieldBasePtr >  field_vec,
double  time,
std::vector< std::string >  region_set_names = {"ALL"} 
)

Assigns fields from field_vec to individual components and all regions in region sets given by region_set_names. Field is added to the history with given time and possibly used in the next call of the set_time method. Caller is responsible for correct construction of given field.

Use this method only if necessary.

Definition at line 396 of file multi_field.impl.hh.

Here is the caller graph for this function:

◆ set() [2/2]

template<int spacedim, class Value >
void MultiField< spacedim, Value >::set ( typename Field< spacedim, Value >::FieldBasePtr  field,
double  time,
std::vector< std::string >  region_set_names = {"ALL"} 
)

Same as previous but only for one-component MultiField (simplification for HeatModel).

Definition at line 418 of file multi_field.impl.hh.

◆ set_dependency()

template<int spacedim, class Value >
std::vector< const FieldCommon * > MultiField< spacedim, Value >::set_dependency ( FieldSet field_set,
unsigned int  i_reg 
) const
overridevirtual

Implementation of FieldCommon::set_dependency().

Implements FieldCommon.

Definition at line 374 of file multi_field.impl.hh.

◆ set_input_list()

template<int spacedim, class Value >
void MultiField< spacedim, Value >::set_input_list ( const Input::Array list,
const TimeGovernor tg 
)
overridevirtual

Returns vector of value in one given point on an element given by ElementAccessor elm. It returns reference to he actual value in order to avoid temporaries for vector and tensor values. Returns std::vector of vector values in several points at once. The base class implements trivial implementation using the value(,,) method. This is not optimal as it involves lot of virtual calls, but this overhead can be negligible for more complex fields as Python of Formula.

Implements FieldCommon.

Definition at line 295 of file multi_field.impl.hh.

◆ set_mesh()

template<int spacedim, class Value >
void MultiField< spacedim, Value >::set_mesh ( const Mesh mesh)
overridevirtual

We have to override the set_mesh method in order to call set_mesh method for subfields.

Implements FieldCommon.

Definition at line 166 of file multi_field.impl.hh.

◆ set_time()

template<int spacedim, class Value >
bool MultiField< spacedim, Value >::set_time ( const TimeStep time,
LimitSide  limit_side 
)
overridevirtual

Abstract method to update field to the new time level. Implemented by in class template Field<...>.

Return true if the value of the field was changed on some region. The returned value is also stored in changed_during_set_time data member.

In first call initialize MultiField to the number of components given by the size of names and use this vector to name individual components. Should be called after the setters derived from FieldCommonBase.

Implements FieldCommon.

Definition at line 144 of file multi_field.impl.hh.

◆ setup_components()

template<int spacedim, class Value >
void MultiField< spacedim, Value >::setup_components

Initialize components of MultiField.

Must be call after setting components, mesh and limit side.

Definition at line 266 of file multi_field.impl.hh.

Here is the caller graph for this function:

◆ size()

template<int spacedim, class Value >
unsigned int MultiField< spacedim, Value >::size ( ) const
inline

Number of subfields that compose the multi-field.

Definition at line 206 of file multi_field.hh.

Here is the caller graph for this function:

◆ TYPEDEF_ERR_INFO() [1/3]

template<int spacedim, class Value >
MultiField< spacedim, Value >::TYPEDEF_ERR_INFO ( EI_ExpectedSize  ,
unsigned int   
)

◆ TYPEDEF_ERR_INFO() [2/3]

template<int spacedim, class Value >
MultiField< spacedim, Value >::TYPEDEF_ERR_INFO ( EI_MultiFieldName  ,
const  string 
)

◆ TYPEDEF_ERR_INFO() [3/3]

template<int spacedim, class Value >
MultiField< spacedim, Value >::TYPEDEF_ERR_INFO ( EI_Size  ,
unsigned int   
)

◆ value_cache() [1/2]

template<int spacedim, class Value >
const FieldValueCache<double>* MultiField< spacedim, Value >::value_cache ( ) const
inlineoverridevirtual

Implements FieldCommon::value_cache.

Implements FieldCommon.

Definition at line 294 of file multi_field.hh.

◆ value_cache() [2/2]

template<int spacedim, class Value >
FieldValueCache<double>* MultiField< spacedim, Value >::value_cache ( )
inlineoverridevirtual

Implements FieldCommon::value_cache.

Implements FieldCommon.

Definition at line 289 of file multi_field.hh.

Member Data Documentation

◆ full_input_list_

template<int spacedim, class Value >
Input::Array MultiField< spacedim, Value >::full_input_list_
private

Full list of input field descriptors from which the subfields of MultiField are set.

Definition at line 304 of file multi_field.hh.

◆ no_check_control_field_

template<int spacedim, class Value >
const MultiField<spacedim, typename FieldValue<spacedim>::Enum >* MultiField< spacedim, Value >::no_check_control_field_
private

If this pointer is set, turn off check of initialization in the set_time method on the regions where the method get_constant_enum_value of the control field returns value from no_check_values_. This field is private copy, its set_time method is called from the set_Time method of actual object.

Definition at line 316 of file multi_field.hh.

◆ sub_fields_

template<int spacedim, class Value >
std::vector< SubFieldType > MultiField< spacedim, Value >::sub_fields_
private

Subfields (items) of MultiField.

Definition at line 301 of file multi_field.hh.

◆ tg_

template<int spacedim, class Value >
const TimeGovernor* MultiField< spacedim, Value >::tg_
private

TimeGovernor is necessary for set input list in setup_components method.

Definition at line 307 of file multi_field.hh.


The documentation for this class was generated from the following files: