Flow123d  jenkins-Flow123d-windows32-release-multijob-51
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | List of all members
Field< spacedim, Value > Class Template Reference

Class template representing a field with values dependent on: point, element, and region. More...

#include <field.hh>

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

Classes

struct  SharedData
 

Public Types

typedef FieldAlgorithmBase
< spacedim, Value > 
FieldBaseType
 
typedef std::shared_ptr
< FieldBaseType
FieldBasePtr
 
typedef FieldAlgorithmBase
< spacedim, Value >::Point 
Point
 

Public Member Functions

 Field ()
 
 Field (const string &name, bool bc=false)
 
 Field (const Field &other)
 
Fieldoperator= (const Field &other)
 
IT::AbstractRecordget_input_type () override
 
auto disable_where (const Field< spacedim, typename FieldValue< spacedim >::Enum > &control_field, const vector< FieldEnum > &value_list) -> Field &
 
void set_mesh (const Mesh &mesh) override
 
bool is_constant (Region reg) override
 
void set_field (const RegionSet &domain, FieldBasePtr field, double time=0.0)
 
void set_field (const RegionSet &domain, const Input::AbstractRecord &a_rec, double time=0.0)
 
void set_limit_side (LimitSide side) override
 
bool set_time (const TimeGovernor &time) override
 
void copy_from (const FieldCommon &other) override
 
void output (OutputTime *stream) override
 
FieldResult field_result (ElementAccessor< spacedim > &elm) const
 
virtual Value::return_type const & value (const Point &p, const ElementAccessor< spacedim > &elm) const
 
virtual void value_list (const std::vector< Point > &point_list, const ElementAccessor< spacedim > &elm, std::vector< typename Value::return_type > &value_list) const
 
- Public Member Functions inherited from FieldCommon
 TYPEDEF_ERR_INFO (EI_Time, double)
 
 TYPEDEF_ERR_INFO (EI_Field, 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, r_id, or r_set) in the field descriptor:")
 
 DECLARE_EXCEPTION (ExcFieldMeshDifference,<< "Two copies of the field "<< EI_Field::qval<< "call set_mesh with different arguments.\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...
 
FieldCommoninput_selection (const Input::Type::Selection *element_selection)
 
FieldCommonoutput_type (OutputTime::DiscreteSpace rt)
 
FieldCommonflags (FieldFlag::Flags::Mask mask)
 
FieldCommonflags_add (FieldFlag::Flags::Mask mask)
 
void set_n_components (unsigned int n_comp)
 
void set_input_list (const Input::Array &list)
 
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
 
OutputTime::DiscreteSpace output_type () const
 
bool is_bc () const
 
unsigned int n_comp () const
 
const Meshmesh () const
 
LimitSide limit_side () const
 
FieldFlag::Flagsflags ()
 
double time () const
 
void mark_input_times (TimeMark::Type mark_type)
 
bool changed () const
 
virtual ~FieldCommon ()
 

Static Public Member Functions

static FieldBasePtr read_field_descriptor (Input::Record rec, const FieldCommon &field)
 
- Static Public Member Functions inherited from FieldCommon
static IT::Record field_descriptor_record (const string &record_name)
 

Public Attributes

FieldBasePtr(* read_field_descriptor_hook )(Input::Record rec, const FieldCommon &field)
 

Static Public Attributes

static constexpr bool is_enum_valued = boost::is_same<typename Value::element_type, FieldEnum>::value
 
static const unsigned int space_dim = spacedim
 

Protected Types

typedef pair< double,
FieldBasePtr
HistoryPoint
 Pair: time, pointer to FieldBase instance. More...
 
typedef boost::circular_buffer
< HistoryPoint
RegionHistory
 Nearest history of one region. More...
 
typedef Field< spacedim,
typename FieldValue< spacedim >
::Enum > 
ControlField
 
- Protected Types inherited from FieldCommon
enum  TimeStatus { TimeStatus::changed, TimeStatus::constant, TimeStatus::unknown }
 

Protected Member Functions

IT::AbstractRecord make_input_tree ()
 -------— end helper function template More...
 
void update_history (const TimeGovernor &time)
 
void check_initialized_region_fields_ ()
 
- Protected Member Functions inherited from FieldCommon
 FieldCommon ()
 
 FieldCommon (const FieldCommon &other)
 
void set_history_changed ()
 

Protected Attributes

std::shared_ptr< SharedDatadata_
 
std::shared_ptr< ControlFieldno_check_control_field_
 
std::vector< FieldBasePtrregion_fields_
 
- Protected Attributes inherited from FieldCommon
std::string name_
 
std::shared_ptr< SharedDatashared_
 
LimitSide limit_side_
 
TimeStatus set_time_result_
 Status of history. More...
 
double last_time_ = -numeric_limits<double>::infinity()
 
OutputTime::DiscreteSpace type_of_output_data_ = OutputTime::ELEM_DATA
 
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...
 

Additional Inherited Members

- Static Protected Attributes inherited from FieldCommon
static const unsigned int history_length_limit_ =3
 

Detailed Description

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

Class template representing a field with values dependent on: point, element, and region.

By "field" we mean a mapping of a a pair (Point, Time) to a Value, where Point is from spacedim dimensional ambient space, Time is real number (set by set_time method), and Value type representing range of the field, which can be: real scalar, integer scalar (a discrete value), real vector of fixed (compile time) size, real vector of runtime size, or a matrix of fixed dimensions. Extensions to vectors or matrices of integers, or to variable tensors are possible. For vector and matrix values we use classes provided by Armadillo library for linear algebra.

This class assign particular fields (instances of descendants of FiledBase) to the regions. It keeps a table of pointers to fields for every possible bulk region index (very same functionality, but for boundary regions is provided by BCField class). This class has interface very similar to FiledBase, however key methods value, and value_list are not virtual in this class by contrast these methods are inlined to minimize overhead for simplest fields like FieldConstant.

TODO: currently it works only for spacedim==3 since we have only mesh in 3D ambient space.

Definition at line 48 of file field.hh.

Member Typedef Documentation

template<int spacedim, class Value>
typedef Field<spacedim, typename FieldValue<spacedim>::Enum > Field< spacedim, Value >::ControlField
protected

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 257 of file field.hh.

template<int spacedim, class Value>
typedef std::shared_ptr< FieldBaseType > Field< spacedim, Value >::FieldBasePtr

Definition at line 52 of file field.hh.

template<int spacedim, class Value>
typedef FieldAlgorithmBase<spacedim, Value> Field< spacedim, Value >::FieldBaseType

Definition at line 51 of file field.hh.

template<int spacedim, class Value>
typedef pair<double, FieldBasePtr> Field< spacedim, Value >::HistoryPoint
protected

Pair: time, pointer to FieldBase instance.

Definition at line 234 of file field.hh.

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

Definition at line 53 of file field.hh.

template<int spacedim, class Value>
typedef boost::circular_buffer<HistoryPoint> Field< spacedim, Value >::RegionHistory
protected

Nearest history of one region.

Definition at line 236 of file field.hh.

Constructor & Destructor Documentation

template<int spacedim, class Value >
Field< spacedim, Value >::Field ( )

Default constructor.

Definition at line 23 of file field.impl.hh.

template<int spacedim, class Value >
Field< spacedim, Value >::Field ( const string &  name,
bool  bc = false 
)

Definition at line 35 of file field.impl.hh.

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

Copy constructor. Keeps shared history, declaration data, mesh.

Definition at line 50 of file field.impl.hh.

Member Function Documentation

template<int spacedim, class Value >
void Field< spacedim, Value >::check_initialized_region_fields_ ( )
protected

Check that whole field list (region_fields_) is set, possibly use default values for unset regions.

Definition at line 405 of file field.impl.hh.

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

Check that other has same type and assign from it.

Implements FieldCommon.

Definition at line 311 of file field.impl.hh.

Here is the caller graph for this function:

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

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 149 of file field.impl.hh.

Here is the caller graph for this function:

template<int spacedim, class Value >
FieldResult Field< spacedim, Value >::field_result ( ElementAccessor< spacedim > &  elm) const
inline

Returns true, if field is currently set to a time in which it is discontinuous. Special field values spatially constant. Could allow optimization of tensor multiplication and tensor or vector addition. field_result_ should be set in constructor and in set_time method of particular Field implementation. We return value result_none, if the field is not initialized on the region of the given element accessor elm.

Definition at line 333 of file field.impl.hh.

template<int spacedim, class Value >
it::AbstractRecord & Field< spacedim, Value >::get_input_type ( )
overridevirtual

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

Implements FieldCommon.

Definition at line 98 of file field.impl.hh.

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

Direct read access to the table of Field pointers on regions. Implementation of FieldCommonBase::is_constant().

Implements FieldCommon.

Definition at line 189 of file field.impl.hh.

template<int spacedim, class Value >
it::AbstractRecord Field< spacedim, Value >::make_input_tree ( )
protected

-------— end helper function template

For fields returning "enum", i.e. with Value == FieldEnum, the input type (meaning whole input_Type tree of the field) depends on the Input::Type::Selection object that represents particular C enum type. Therefore, we have to create whole tree for the selection that was set through FieldBaseCommon::set_selection() method.

Definition at line 138 of file field.impl.hh.

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

Assignment operator. Same properties as copy constructor.

Question: do we really need this, isn't copy constructor enough?

Definition at line 66 of file field.impl.hh.

template<int spacedim, class Value >
void Field< spacedim, Value >::output ( OutputTime stream)
overridevirtual

Implementation of FieldCommonBase::output().

Implements FieldCommon.

Definition at line 323 of file field.impl.hh.

template<int spacedim, class Value >
auto Field< spacedim, Value >::read_field_descriptor ( Input::Record  rec,
const FieldCommon field 
)
static

Default implementation of read_field_descriptor_hook.

Reads key given by field_name and creates the field instance using FieldBase<...>::function_factory.

Definition at line 235 of file field.impl.hh.

template<int spacedim, class Value >
void Field< spacedim, Value >::set_field ( const RegionSet domain,
FieldBasePtr  field,
double  time = 0.0 
)

Assigns given field to all regions in given region set domain. 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.

Default time simplify setting steady fields.

Definition at line 197 of file field.impl.hh.

Here is the caller graph for this function:

template<int spacedim, class Value >
void Field< spacedim, Value >::set_field ( const RegionSet domain,
const Input::AbstractRecord a_rec,
double  time = 0.0 
)

Same as before but the field is first created using FieldBase::function_factory(), from given abstract record accessor a_rec.

Definition at line 224 of file field.impl.hh.

template<int spacedim, class Value>
void Field< spacedim, Value >::set_limit_side ( LimitSide  side)
inlineoverridevirtual

Set side of limit when calling set_time with jump time. This method invalidate result of changed() so it should be called just before set_time. Can be different for different field copies.

Implements FieldCommon.

Definition at line 158 of file field.hh.

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

Set mesh pointer and resize region arrays.

Implements abstract method.

Reimplemented from FieldCommon.

Definition at line 159 of file field.impl.hh.

Here is the caller graph for this function:

template<int spacedim, class Value >
bool Field< spacedim, Value >::set_time ( const TimeGovernor time)
overridevirtual

Check that whole field list is set, possibly use default values for unset regions and call set_time for every field in the field list.

Returns true if the field has been changed.

Implements FieldCommon.

Definition at line 248 of file field.impl.hh.

template<int spacedim, class Value >
void Field< spacedim, Value >::update_history ( const TimeGovernor time)
protected

Read input into regions_history_ possibly pop some old values from the history queue to keep its size less then history_length_limit_.

Definition at line 342 of file field.impl.hh.

template<int spacedim, class Value >
Value::return_type const & Field< spacedim, Value >::value ( const Point p,
const ElementAccessor< spacedim > &  elm 
) const
inlinevirtual

Returns one 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.

Definition at line 399 of file field.hh.

template<int spacedim, class Value>
void Field< spacedim, Value >::value_list ( const std::vector< Point > &  point_list,
const ElementAccessor< spacedim > &  elm,
std::vector< typename Value::return_type > &  value_list 
) const
inlinevirtual

Returns std::vector of scalar 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.

Definition at line 413 of file field.hh.

Here is the caller graph for this function:

Member Data Documentation

template<int spacedim, class Value>
std::shared_ptr<SharedData> Field< spacedim, Value >::data_
protected

Definition at line 248 of file field.hh.

template<int spacedim, class Value>
constexpr bool Field< spacedim, Value >::is_enum_valued = boost::is_same<typename Value::element_type, FieldEnum>::value
static

Definition at line 55 of file field.hh.

template<int spacedim, class Value>
std::shared_ptr<ControlField> Field< spacedim, Value >::no_check_control_field_
protected

Definition at line 258 of file field.hh.

template<int spacedim, class Value>
FieldBasePtr(* Field< spacedim, Value >::read_field_descriptor_hook)(Input::Record rec, const FieldCommon &field)

Pointer to function that creates an instance of FieldBase for field with name field_name based on data in field descriptor rec.

Default implementation in method read_field_descriptor just reads key given by field_name and creates instance using FieldBase<...>::function_factory. Function should return empty SharedField (that is shared_ptr to FieldBase).

Hooks are necessary to implement: 1) backward compatibility with old BCD input files 2) setting pressure values are piezometric head values

Definition at line 71 of file field.hh.

template<int spacedim, class Value>
std::vector< FieldBasePtr > Field< spacedim, Value >::region_fields_
protected

Table with pointers to fields on individual regions.

Definition at line 263 of file field.hh.

template<int spacedim, class Value>
const unsigned int Field< spacedim, Value >::space_dim = spacedim
static

Definition at line 56 of file field.hh.


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