Flow123d
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
FieldSet Class Reference

#include <field_set.hh>

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

Public Member Functions

 DECLARE_EXCEPTION (ExcUnknownField,<< "Field set has no field with name: "<< FieldCommonBase::EI_Field::qval)
 
Input::Type::Record make_field_descriptor_type (const std::string &equation_name) const
 
Input::Type::Selection make_output_field_selection (const string &name, const string &desc="")
 
void set_field (const std::string &dest_field_name, FieldCommonBase &source)
 
FieldCommonBaseget_field (const std::string &field_name) const
 
void set_mesh (const Mesh &mesh)
 
void set_input_list (Input::Array input_list)
 
void set_limit_side (LimitSide side)
 
void mark_input_times (TimeMark::Type mark_type)
 
bool changed () const
 
bool is_constant (Region reg) const
 
void set_time (const TimeGovernor &time)
 
void output_type (OutputTime::DiscreteSpace rt)
 
void output (OutputTime *stream)
 
FieldCommonBaseadd_field (FieldCommonBase *field, const string &name, const string &desc, const string &d_val="")
 

Protected Member Functions

FieldCommonBasefield_by_name (const std::string &field_name) const
 

Protected Attributes

std::vector< FieldCommonBase * > field_list
 List of all fields. More...
 
const Meshmesh_ = nullptr
 value set by last set_mesh(); set the same to added fields More...
 
Input::Array input_list_
 value set by last set_input_list(); set the same to added fields More...
 
LimitSide side_ = LimitSide::unknown
 value set by last set_time_limit(); set the same to added fields More...
 

Detailed Description

TODO: implementation robust against destroying fields before the FieldSet.

Definition at line 20 of file field_set.hh.

Member Function Documentation

FieldCommonBase& FieldSet::add_field ( FieldCommonBase field,
const string &  name,
const string &  desc,
const string &  d_val = "" 
)
inline

Adds given field into list of fields for group operations on fields. Parameters are: field pointer, name of the key in the input, desc - description of the key, and optional parameter d_val with default value. This method is rather called through the macro ADD_FIELD

Definition at line 241 of file field_set.hh.

bool FieldSet::changed ( ) const
inline

Collective interface to FieldCommonBase::set_mesh().

Definition at line 198 of file field_set.hh.

Here is the caller graph for this function:

FieldSet::DECLARE_EXCEPTION ( ExcUnknownField  ,
<< "Field set has no field with name: "<< FieldCommonBase::EI_Field::qval   
)
FieldCommonBase* FieldSet::field_by_name ( const std::string &  field_name) const
inlineprotected

Return pointer to the field of given name. REturn nullptr if not found.

Definition at line 250 of file field_set.hh.

Here is the caller graph for this function:

FieldCommonBase& FieldSet::get_field ( const std::string &  field_name) const
inline

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

Definition at line 157 of file field_set.hh.

Here is the caller graph for this function:

bool FieldSet::is_constant ( Region  reg) const
inline

Collective interface to FieldCommonBase::set_mesh().

Definition at line 207 of file field_set.hh.

Here is the caller graph for this function:

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

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 +=(FieldCommonBase &field) {
FieldCommonBase *found_field = field_by_name(field.name());
if (found_field) {
ASSERT(&field==found_field, "Another field of the same name exists when adding field: %s\n", field.name().c_str());
} else {
field_list.push_back(&field);
if (mesh_) field.set_mesh(*mesh_);
}
return *this;
}
/**
Add other FieldSet to current one.
/
FieldSet &operator +=(const FieldSet &other) {
for(auto field_ptr : other.field_list) this->operator +=(*field_ptr);
return *this;
}
/**
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 {
FieldSet set;
for(auto name : names) set += this->get_field( name);
return set;
}
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 odf the field descriptor. 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()),"List of field descriptors.");

Definition at line 95 of file field_set.hh.

Input::Type::Selection FieldSet::make_output_field_selection ( const string &  name,
const string &  desc = "" 
)
inline

Make Selection with strings for all field names in the FieldSet.

Definition at line 118 of file field_set.hh.

Here is the caller graph for this function:

void FieldSet::mark_input_times ( TimeMark::Type  mark_type)
inline

Collective interface to FieldCommonBase::mar_input_times().

Definition at line 192 of file field_set.hh.

Here is the caller graph for this function:

void FieldSet::output ( OutputTime stream)
inline

Collective interface to FieldCommonBase::output().

Definition at line 231 of file field_set.hh.

Here is the caller graph for this function:

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 224 of file field_set.hh.

Here is the caller graph for this function:

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

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 same input descriptor list and same instances of FieldBase classes but each copy can be set to different time and different limit side.

Definition at line 147 of file field_set.hh.

Here is the caller graph for this function:

void FieldSet::set_input_list ( Input::Array  input_list)
inline

Collective interface to FieldCommonBase::set_mesh().

Definition at line 177 of file field_set.hh.

Here is the caller graph for this function:

void FieldSet::set_limit_side ( LimitSide  side)
inline

Collective interface to FieldCommonBase::set_mesh().

Definition at line 185 of file field_set.hh.

Here is the caller graph for this function:

void FieldSet::set_mesh ( const Mesh mesh)
inline

Collective interface to FieldCommonBase::set_mesh().

Definition at line 169 of file field_set.hh.

Here is the caller graph for this function:

void FieldSet::set_time ( const TimeGovernor time)
inline

Collective interface to FieldCommonBase::set_mesh().

Definition at line 216 of file field_set.hh.

Here is the caller graph for this function:

Member Data Documentation

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

List of all fields.

Definition at line 258 of file field_set.hh.

Input::Array FieldSet::input_list_
protected

value set by last set_input_list(); set the same to added fields

Definition at line 264 of file field_set.hh.

const Mesh* FieldSet::mesh_ = nullptr
protected

value set by last set_mesh(); set the same to added fields

Definition at line 261 of file field_set.hh.

LimitSide FieldSet::side_ = LimitSide::unknown
protected

value set by last set_time_limit(); set the same to added fields

Definition at line 267 of file field_set.hh.


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