Flow123d  DF_profiler_memory_monitor-83fd579
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
FieldSet Class Reference

Container for various descendants of FieldCommonBase. More...

#include <field_set.hh>

Inheritance diagram for FieldSet:
Inheritance graph
[legend]
Collaboration diagram for FieldSet:
Collaboration graph
[legend]

Public Types

enum  UserFieldShape { scalar , vector , tensor }
 
- Public Types inherited from FieldFlag
typedef FlagArray< FieldFlagFlags
 
typedef Flags::Mask Mask
 

Public Member Functions

 TYPEDEF_ERR_INFO (EI_FieldType, std::string)
 
 DECLARE_INPUT_EXCEPTION (ExcUnknownField,<< "Unknown field "<< FieldCommon::EI_Field::qval<< " in the "<< EI_FieldType::val<< ": \n")
 
 DECLARE_INPUT_EXCEPTION (ExcFieldExists,<< "Field "<< FieldCommon::EI_Field::qval<< " exists in equation. You cannot set user field of same name.\n")
 
 FieldSet ()
 Default constructor. More...
 
Input::Type::Record make_field_descriptor_type (const std::string &equation_name) const
 
void set_field (const std::string &dest_field_name, FieldCommon &source)
 
FieldCommonfield (const std::string &field_name) const
 
FieldCommonoperator[] (const std::string &field_name) const
 
void set_components (const std::vector< string > &names)
 
void set_mesh (const Mesh &mesh)
 
void set_input_list (Input::Array input_list, const TimeGovernor &tg)
 
void flags_add (FieldFlag::Flags::Mask mask)
 
bool set_time (const TimeStep &time, LimitSide limit_side)
 
void output_type (OutputTime::DiscreteSpace rt)
 
void mark_input_times (const TimeGovernor &tg)
 
bool changed () const
 
bool is_constant (Region reg) const
 
bool is_jump_time () const
 
void cache_reallocate (const ElementCacheMap &cache_map, FieldSet &used_fieldset)
 
void cache_update (ElementCacheMap &cache_map)
 
void set_dependency (FieldSet &used_fieldset)
 
void add_coords_field ()
 
void set_surface_depth (std::shared_ptr< SurfaceDepth > surface_depth)
 Set surface depth object to "d" field. More...
 
Range< FieldListAccessorfields_range () const
 Returns range of Fields held in field_list. More...
 
const Meshmesh () const
 Returns pointer to mesh. More...
 
std::string print_dependency () const
 Return order of evaluated fields by dependency and region_idx. More...
 
void set_default_fieldset ()
 

Static Public Member Functions

static const Input::Type::Selectionget_user_field_shape_selection ()
 Input selection of user field shape. More...
 
static const Input::Type::Recordmake_user_field_type (const std::string &equation_name)
 Declare input record type of field defined by user. More...
 

Protected Member Functions

void topological_sort (const FieldCommon *f, unsigned int i_reg, std::unordered_set< const FieldCommon * > &used_fields)
 Helper method sort used fields by dependency. More...
 

Protected Attributes

std::vector< FieldCommon * > field_list
 List of all fields. More...
 
const Meshmesh_
 Pointer to the mesh. More...
 
std::map< unsigned int, std::vector< const FieldCommon * > > region_field_update_order_
 
FieldCoords X_
 Field holds coordinates for computing of FieldFormulas. More...
 
FieldDepth depth_
 Field holds surface depth for computing of FieldFormulas. More...
 

Friends

template<int dim, class Val >
class FieldFormula
 
std::ostream & operator<< (std::ostream &stream, const FieldSet &set)
 

Additional Inherited Members

- Static Public Attributes inherited from FieldFlag
static constexpr unsigned int flags_size_ = 3
 Number of bits used by Field itself. More...
 
static constexpr Mask equation_input {1 << 0}
 The field is data parameter of the owning equation. (default on) More...
 
static constexpr Mask declare_input {1 << 1}
 The field can be set from input. The key in input field descriptor is declared. (default on) More...
 
static constexpr Mask allow_output {1 << 2}
 The field can output. Is part of generated output selection. (default on) More...
 
static constexpr Mask input_copy = ~declare_input & equation_input
 
static constexpr Mask in_time_term {1 << 8}
 A field is part of time term of the equation. More...
 
static constexpr Mask in_main_matrix {1 << 9}
 A field is part of main "stiffness matrix" of the equation. More...
 
static constexpr Mask in_rhs {1 << 10}
 A field is part of the right hand side of the equation. More...
 
static constexpr Mask equation_result = allow_output & ~declare_input & ~equation_input
 Match result fields. These are never given by input or copy of input. More...
 
static constexpr Mask equation_external_output = allow_output & input_copy
 Match an output field, that can be also copy of other field. More...
 

Detailed Description

Container for various descendants of FieldCommonBase.

Provides various collective operations. Typical usage:

class EqData : public FieldSet { EqData() { *this += scalar_field .name("scalar_field") .description("Some description for input and output documentation.") .input_default("{0.0}") .units("m"); *this += vector_field .name("vector_field") .description("Some description for input and output documentation.") .units("m"); }

Field<3, FieldValue<3>::Scalar> scalar_field; Field<3, FieldValue<3>::VectorFixed> vector_field; };

This way the fields are destructed just before their pointers stored in the FieldSet.

TODO: Some set_XY functions set also to the fields added to the FieldSet in future. This behavior should be removed, since it is misleading in combination with mask subsets. If one set something to mask subset, it does not influence fields added to the original field set even if they match the mask of the subset.

Definition at line 159 of file field_set.hh.

Member Enumeration Documentation

◆ UserFieldShape

Possible shapes of user fields.

Enumerator
scalar 
vector 
tensor 

Definition at line 173 of file field_set.hh.

Constructor & Destructor Documentation

◆ FieldSet()

FieldSet::FieldSet ( )

Default constructor.

Definition at line 29 of file field_set.cc.

Member Function Documentation

◆ add_coords_field()

void FieldSet::add_coords_field ( )

Add coords field (X_) and depth field to field_list.

We can't add this field automatically in constructor, because there is problem in equation where we add one FieldSet to other.

Definition at line 253 of file field_set.cc.

Here is the caller graph for this function:

◆ cache_reallocate()

void FieldSet::cache_reallocate ( const ElementCacheMap cache_map,
FieldSet used_fieldset 
)
inline

Collective interface to FieldCommon::recache_allocate().

Definition at line 355 of file field_set.hh.

◆ cache_update()

void FieldSet::cache_update ( ElementCacheMap cache_map)

Collective interface to FieldCommon::cache_update().

Definition at line 220 of file field_set.cc.

◆ changed()

bool FieldSet::changed ( ) const

Collective interface to FieldCommonBase::set_mesh().

Definition at line 198 of file field_set.cc.

◆ DECLARE_INPUT_EXCEPTION() [1/2]

FieldSet::DECLARE_INPUT_EXCEPTION ( ExcFieldExists  ,
<< "Field "<< FieldCommon::EI_Field::qval<< " exists in equation. You cannot set user field of same name.\n"   
)

◆ DECLARE_INPUT_EXCEPTION() [2/2]

FieldSet::DECLARE_INPUT_EXCEPTION ( ExcUnknownField  ,
<< "Unknown field "<< FieldCommon::EI_Field::qval<< " in the "<< EI_FieldType::val<< ": \n"   
)

◆ field()

FieldCommon * FieldSet::field ( const std::string &  field_name) const

Return pointer to the field given by name field_name. Return nullptr if not found.

Definition at line 173 of file field_set.cc.

◆ fields_range()

Range< FieldListAccessor > FieldSet::fields_range ( ) const

Returns range of Fields held in field_list.

Definition at line 275 of file field_set.cc.

Here is the caller graph for this function:

◆ flags_add()

void FieldSet::flags_add ( FieldFlag::Flags::Mask  mask)
inline

Collective interface to FieldCommonBase::flags_add().

Parameters
maskmask to set for all fields in the field set.

Definition at line 313 of file field_set.hh.

◆ get_user_field_shape_selection()

const Input::Type::Selection & FieldSet::get_user_field_shape_selection ( )
static

Input selection of user field shape.

Definition at line 33 of file field_set.cc.

Here is the caller graph for this function:

◆ is_constant()

bool FieldSet::is_constant ( Region  reg) const

Collective interface to FieldCommonBase::set_mesh().

Definition at line 206 of file field_set.cc.

◆ is_jump_time()

bool FieldSet::is_jump_time ( ) const

Collective interface to FieldCommonBase::is_jump_time().

Definition at line 213 of file field_set.cc.

◆ make_field_descriptor_type()

Input::Type::Record FieldSet::make_field_descriptor_type ( const std::string &  equation_name) const

Add an existing Field to the list. It stores just pointer to the field. Be careful to not destroy passed Field before the FieldSet.

Using operator allows elegant setting and adding of a field to the field set:

Field<...> init_quantity; // member of a FieldSet descendant
field_set +=
some_field
.disable_where(type, {dirichlet, neumann}) // this must come first since it is not member of FieldCommonBase
.name("init_temperature")
.description("Initial temperature");
/
FieldSet &operator +=(FieldCommon &add_field);
/**
* Add other FieldSet to current one.
*/
FieldSet &operator +=(const FieldSet &other);
/**
* Make new FieldSet as a subset of *this. The new FieldSet contains fields with names given by the @p names parameter.
*/
FieldSet subset(std::vector<std::string> names) const;
/**
* Make new FieldSet as a subset of *this.
* The new FieldSet contains all fields that match given @p mask.
*/
FieldSet subset( FieldFlag::Flags::Mask mask) const;
/**
* Number of fields in the FieldSet.
*/
inline unsigned int size() const {
return field_list.size();
}
/**
* Returns input type for a field descriptor, that can contain any of the fields in the set.
* Typical usage is from derived class, where we add fields in the constructor
* and make auxiliary temporary instance
* to get the record of the field descriptor.
* The returned Record has name equation_name + "_Data".
*
* Simplest example:
*
* @code
* class EqData : public FieldSet {
* public:
* // fields
* Field<..> field_a;
* Field<..> field_b
* EqData() {
* add(field_a);
* add(field_b);
* }
* }
*
* Input::Type::Record SomEquation::input_type=
* Record("SomeEquation","equation's description")
* .declare_key("data",Input::Type::Array(
* EqData().make_field_descriptor_type("SomeEquation")),"List of field descriptors.");
*
Common abstract parent of all Field<...> classes.
Definition: field_common.hh:77
Container for various descendants of FieldCommonBase.
Definition: field_set.hh:159
std::vector< FieldCommon * > field_list
List of all fields.
Definition: field_set.hh:419
Class template representing a field with values dependent on: point, element, and region.
Definition: field.hh:92
auto disable_where(const Field< spacedim, typename FieldValue< spacedim >::Enum > &control_field, const vector< FieldEnum > &value_list) -> Field &
Definition: field.impl.hh:193

Definition at line 95 of file field_set.cc.

Here is the caller graph for this function:

◆ make_user_field_type()

const Input::Type::Record & FieldSet::make_user_field_type ( const std::string &  equation_name)
static

Declare input record type of field defined by user.

Definition at line 41 of file field_set.cc.

Here is the caller graph for this function:

◆ mark_input_times()

void FieldSet::mark_input_times ( const TimeGovernor tg)
inline

Collective interface to FieldCommonBase::mark_input_times().

Definition at line 333 of file field_set.hh.

◆ mesh()

const Mesh* FieldSet::mesh ( ) const
inline

Returns pointer to mesh.

Definition at line 393 of file field_set.hh.

Here is the caller graph for this function:

◆ operator[]()

FieldCommon & FieldSet::operator[] ( const std::string &  field_name) const

Returns reference to the field given by field_name. Throws if the field with given name is not found.

Definition at line 181 of file field_set.cc.

◆ output_type()

void FieldSet::output_type ( OutputTime::DiscreteSpace  rt)
inline

Collective interface to FieldCommonBase::output_type().

Parameters
rtDiscrete function space (element, node or corner data).

Definition at line 326 of file field_set.hh.

◆ print_dependency()

std::string FieldSet::print_dependency ( ) const

Return order of evaluated fields by dependency and region_idx.

Definition at line 282 of file field_set.cc.

◆ set_components()

void FieldSet::set_components ( const std::vector< string > &  names)
inline

Collective interface to FieldCommonBase::set_components(). It is safe to call this for field sets containing also fields with return value other then variable vector as long as all variable vector fields should be set to the same number of components.

Definition at line 291 of file field_set.hh.

◆ set_default_fieldset()

void FieldSet::set_default_fieldset ( )
inline

Collective interface to FieldCommon::set_default_fieldset().

Set data member default_fieldset_ to all fields of FieldSet. This data member holds pointer to primary FieldSet (equation) where field is defined and it is used during evaluation of field dependency in FieldSet (see method set_dependency). The goal is to allow the user to specify a dependency on other input fields or user defined fields in same equation where field is defined.

Definition at line 408 of file field_set.hh.

Here is the caller graph for this function:

◆ set_dependency()

void FieldSet::set_dependency ( FieldSet used_fieldset)

Set reference of FieldSet to all instances of FieldFormula.

Definition at line 229 of file field_set.cc.

Here is the caller graph for this function:

◆ set_field()

void FieldSet::set_field ( const std::string &  dest_field_name,
FieldCommon source 
)

Make Selection with strings for all field names in the FieldSet. Use FieldCommonBase::copy_from() to set field of the field set given by the first parameter dest_field_name. The source field is given as the second parameter source. The field copies share the same input descriptor list and the same instances of FieldBase classes but each copy can be set to different time and different limit side.

See FieldCommonBase::copy_from documentation for details.

Definition at line 165 of file field_set.cc.

◆ set_input_list()

void FieldSet::set_input_list ( Input::Array  input_list,
const TimeGovernor tg 
)
inline

Collective interface to FieldCommon::set_input_list().

Definition at line 305 of file field_set.hh.

Here is the caller graph for this function:

◆ set_mesh()

void FieldSet::set_mesh ( const Mesh mesh)
inline

Collective interface to FieldCommonBase::set_mesh().

Definition at line 297 of file field_set.hh.

Here is the caller graph for this function:

◆ set_surface_depth()

void FieldSet::set_surface_depth ( std::shared_ptr< SurfaceDepth surface_depth)
inline

Set surface depth object to "d" field.

Definition at line 385 of file field_set.hh.

Here is the caller graph for this function:

◆ set_time()

bool FieldSet::set_time ( const TimeStep time,
LimitSide  limit_side 
)

Collective interface to FieldCommonBase::set_mesh().

Definition at line 190 of file field_set.cc.

Here is the caller graph for this function:

◆ topological_sort()

void FieldSet::topological_sort ( const FieldCommon f,
unsigned int  i_reg,
std::unordered_set< const FieldCommon * > &  used_fields 
)
protected

Helper method sort used fields by dependency.

Definition at line 242 of file field_set.cc.

Here is the caller graph for this function:

◆ TYPEDEF_ERR_INFO()

FieldSet::TYPEDEF_ERR_INFO ( EI_FieldType  ,
std::string   
)

Friends And Related Function Documentation

◆ FieldFormula

template<int dim, class Val >
friend class FieldFormula
friend

Definition at line 447 of file field_set.hh.

◆ operator<<

std::ostream& operator<< ( std::ostream &  stream,
const FieldSet set 
)
friend

Stream output operator

Definition at line 295 of file field_set.cc.

Member Data Documentation

◆ depth_

FieldDepth FieldSet::depth_
protected

Field holds surface depth for computing of FieldFormulas.

Definition at line 439 of file field_set.hh.

◆ field_list

std::vector<FieldCommon *> FieldSet::field_list
protected

List of all fields.

Definition at line 419 of file field_set.hh.

◆ mesh_

const Mesh* FieldSet::mesh_
protected

Pointer to the mesh.

Definition at line 422 of file field_set.hh.

◆ region_field_update_order_

std::map<unsigned int, std::vector<const FieldCommon *> > FieldSet::region_field_update_order_
protected

Holds vector of indices of fields in field_list sorted by dependency for every region.

  • first: index of region
  • second: vector of indices of fields (corresponding to position in field_list vector)

Definition at line 430 of file field_set.hh.

◆ X_

FieldCoords FieldSet::X_
protected

Field holds coordinates for computing of FieldFormulas.

Definition at line 436 of file field_set.hh.


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