Flow123d
Classes | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
FieldCommonBase Class Referenceabstract

Common abstract parent of all Field<...> classes. More...

#include <field.hh>

Inheritance diagram for FieldCommonBase:
Inheritance graph
[legend]

Classes

struct  SharedData
 

Public Member Functions

 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 fields descriptor:")
 
 DECLARE_EXCEPTION (ExcFieldMeshDifference,<< "Two copies of the field "<< EI_Field::qval<< "call set_mesh with different arguments.\n")
 
FieldCommonBasename (const string &name)
 
FieldCommonBasejust_copy ()
 
FieldCommonBasedesc (const string &desc)
 
FieldCommonBaseinput_default (const string &dflt)
 
FieldCommonBaseunits (const string &units)
 Set basic units of the field. More...
 
FieldCommonBaseinput_selection (const Input::Type::Selection *element_selection)
 
FieldCommonBaseoutput_type (OutputTime::DiscreteSpace rt)
 
void n_comp (unsigned int n_comp)
 
virtual void set_mesh (const Mesh &mesh)
 
void set_input_list (const Input::Array &list)
 
virtual void set_limit_side (LimitSide side)=0
 
const std::string & name () const
 
const std::string desc () const
 
const std::string & input_default () const
 
const std::string & units () const
 
OutputTime::DiscreteSpace output_type () const
 
bool is_bc () const
 
unsigned int n_comp () const
 
const Meshmesh () const
 
bool is_just_copy () const
 
double time () const
 
virtual IT::AbstractRecordget_input_type ()=0
 
void mark_input_times (TimeMark::Type mark_type)
 
virtual bool set_time (const TimeGovernor &time)=0
 
virtual void copy_from (const FieldCommonBase &other)=0
 
virtual void output (OutputTime *stream)=0
 
virtual bool is_constant (Region reg)=0
 
bool changed () const
 
virtual ~FieldCommonBase ()
 

Static Public Member Functions

static IT::Record field_descriptor_record (const string &record_name)
 

Protected Types

enum  TimeStatus { TimeStatus::changed, TimeStatus::constant, TimeStatus::unknown }
 

Protected Member Functions

 FieldCommonBase ()
 
 FieldCommonBase (const FieldCommonBase &other)
 
void set_history_changed ()
 

Protected Attributes

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
 
bool is_copy_ =false
 Flag field that has to be set as a copy of other field using copy_from method. More...
 

Static Protected Attributes

static const unsigned int history_length_limit_ =3
 

Detailed Description

Common abstract parent of all Field<...> classes.

We need common ancestor in order to keep a list of all fields in one EqData object and allow collective operations like set_time or init_from_input.

Definition at line 43 of file field.hh.

Member Enumeration Documentation

enum FieldCommonBase::TimeStatus
strongprotected

Result of last set time method

Enumerator
changed 
constant 
unknown 

Definition at line 381 of file field.hh.

Constructor & Destructor Documentation

FieldCommonBase::~FieldCommonBase ( )
virtual

Virtual destructor.

Definition at line 108 of file field.cc.

FieldCommonBase::FieldCommonBase ( )
protected

Private default constructor. Should be used only through Field<...>

Definition at line 21 of file field.cc.

FieldCommonBase::FieldCommonBase ( const FieldCommonBase other)
protected

Private copy constructor. Should be used only through Field<...>

Definition at line 36 of file field.cc.

Member Function Documentation

bool FieldCommonBase::changed ( ) const
inline

Returns true if set_time_result_ is not TimeStatus::constant. Returns the same value as last set_time method.

Definition at line 261 of file field.hh.

Here is the caller graph for this function:

virtual void FieldCommonBase::copy_from ( const FieldCommonBase other)
pure virtual
FieldCommonBase::DECLARE_EXCEPTION ( ExcFieldMeshDifference  ,
<< "Two copies of the field "<< EI_Field::qval<< "call set_mesh with different arguments.\n"   
)
FieldCommonBase::DECLARE_INPUT_EXCEPTION ( ExcNonascendingTime  ,
<< "Non-ascending time: "<< EI_Time::val<< " for field "<< EI_Field::qval<< ".\n"   
)
FieldCommonBase::DECLARE_INPUT_EXCEPTION ( ExcMissingDomain  ,
<< "Missing domain specification (region, r_id, or r_set) in fields descriptor:"   
)
FieldCommonBase& FieldCommonBase::desc ( const string &  desc)
inline

Set description of the field, used for description of corresponding key in documentation.

Definition at line 71 of file field.hh.

Here is the caller graph for this function:

const std::string FieldCommonBase::desc ( ) const
inline

Definition at line 158 of file field.hh.

IT::Record FieldCommonBase::field_descriptor_record ( const string &  record_name)
static

Common part of the field descriptor. To get finished record one has to add keys for individual fields. This is done automatically using FieldSet::get_input_type().

Definition at line 45 of file field.cc.

Here is the caller graph for this function:

virtual IT::AbstractRecord& FieldCommonBase::get_input_type ( )
pure virtual
FieldCommonBase& FieldCommonBase::input_default ( const string &  dflt)
inline

Set default value for the field's key from which the default constant valued field will be constructed.

During the first call of the set_time method, we check that the field is defined on all regions. On regions where it is not set yet, we use given dflt string to get particular instance of FieldBase<> (see check_initialized_region_fields_). The default string is interpreted in the same way as if it appears in the input file as the value of the field. In particular it can be whole record with TYPE of the field etc. Most common choice is however mere constant.

Definition at line 83 of file field.hh.

Here is the caller graph for this function:

const std::string& FieldCommonBase::input_default ( ) const
inline

Definition at line 161 of file field.hh.

FieldCommonBase& FieldCommonBase::input_selection ( const Input::Type::Selection element_selection)
inline

For the fields returning "Enum", we have to pass the Input::Type::Selection object to the field implementations.

We must save raw pointer since selection may not be yet initialized (during static initialization phase).

Definition at line 105 of file field.hh.

Here is the caller graph for this function:

bool FieldCommonBase::is_bc ( ) const
inline

Definition at line 170 of file field.hh.

Here is the caller graph for this function:

virtual bool FieldCommonBase::is_constant ( Region  reg)
pure virtual

If the field on given region reg exists and is of type FieldConstant<...> the method method returns true otherwise it returns false. Then one call ElementAccessor<spacedim>(mesh(), reg ) to construct an ElementAccessor elm pointing to "virtual" element on which Field::value returns constant value.

Current implementation use virtual functions and can be prohibitively slow if called for every element. If this becomes necessary it is possible to incorporate such test into set_time method and in this method just return precomputed result.

Implemented in MultiField< spacedim, Value >, MultiField< 3, FieldValue< 3 >::Scalar >, Field< spacedim, Value >, Field< spacedim, FieldValue< 3 >::EnumVector >, Field< 3, FieldValue< 3 >::Vector >, Field< spacedim, FieldValue< 3 >::Vector >, Field< 3, FieldValue< 3 >::Scalar >, Field< 3, FieldValue< 3 >::VectorFixed >, Field< spacedim, FieldValue< 3 >::Scalar >, Field< spacedim, FieldValue< 3 >::Enum >, Field< 3, FieldValue< 3 >::Integer >, Field< 3, FieldValue< 3 >::TensorFixed >, and Field< 3, FieldValue< 3 >::EnumVector >.

Here is the caller graph for this function:

bool FieldCommonBase::is_just_copy ( ) const
inline

Definition at line 179 of file field.hh.

Here is the caller graph for this function:

FieldCommonBase& FieldCommonBase::just_copy ( )
inline

Mark field to be used only as a copy of other field (do not produce key in record, do not set input list).

Definition at line 66 of file field.hh.

Here is the caller graph for this function:

void FieldCommonBase::mark_input_times ( TimeMark::Type  mark_type)

Abstract method for initialization of the field on one region. Pass through the input array input_list_, collect all times where the field could change and put appropriate time marks into global TimeMarks object. Introduced time marks have both given mark_type and type_input() type.

Further development:

  • we have to distinguish "jump" times and "smooth" times

Definition at line 93 of file field.cc.

Here is the caller graph for this function:

const Mesh* FieldCommonBase::mesh ( ) const
inline

Definition at line 176 of file field.hh.

Here is the caller graph for this function:

void FieldCommonBase::n_comp ( unsigned int  n_comp)
inline

Set number of components for run-time sized vectors. This is used latter when we construct objects derived from FieldBase<...>.

n_comp_ is constant zero for fixed values, this zero is set by Field<...> constructors

Definition at line 127 of file field.hh.

Here is the caller graph for this function:

unsigned int FieldCommonBase::n_comp ( ) const
inline

Definition at line 173 of file field.hh.

FieldCommonBase& FieldCommonBase::name ( const string &  name)
inline

Set name of the field, used for naming the field's key in EqData record. It can also be used to name a corresponding output data set, e.g. when outut the field into a VTK file.

Definition at line 61 of file field.hh.

Here is the caller graph for this function:

const std::string& FieldCommonBase::name ( ) const
inline

Getters.

Definition at line 155 of file field.hh.

Here is the caller graph for this function:

virtual void FieldCommonBase::output ( OutputTime stream)
pure virtual
FieldCommonBase& FieldCommonBase::output_type ( OutputTime::DiscreteSpace  rt)
inline

Output discrete space used in the output() method. Can be different for different field copies. one can choose between: data constant on elements, linear data given in nodes, and discontinuous linear data.

If not set explicitly by this method, the default value is OutputTime::ELEM_DATA

Definition at line 118 of file field.hh.

Here is the caller graph for this function:

OutputTime::DiscreteSpace FieldCommonBase::output_type ( ) const
inline

Definition at line 167 of file field.hh.

void FieldCommonBase::set_history_changed ( )
inlineprotected

Invalidate last time in order to force set_time method update region_fields_.

Definition at line 292 of file field.hh.

void FieldCommonBase::set_input_list ( const Input::Array list)

Set the data list from which field will read its input. It is list of "field descriptors". When reading from the input list we consider only field descriptors containing key of named by the field name. These field descriptors has to have times forming ascending sequence.

The list is used by set_time method to set field on individual regions to actual FieldBase descendants.

Definition at line 64 of file field.cc.

Here is the caller graph for this function:

virtual void FieldCommonBase::set_limit_side ( LimitSide  side)
pure virtual
virtual void FieldCommonBase::set_mesh ( const Mesh mesh)
inlinevirtual
virtual bool FieldCommonBase::set_time ( const TimeGovernor time)
pure virtual

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.

Default values helps when creating steady field. Note that default TimeGovernor constructor set time to 0.0.

Different field copies can be set to different times.

Implemented in MultiField< spacedim, Value >, MultiField< 3, FieldValue< 3 >::Scalar >, Field< spacedim, Value >, Field< spacedim, FieldValue< 3 >::EnumVector >, Field< 3, FieldValue< 3 >::Vector >, Field< spacedim, FieldValue< 3 >::Vector >, Field< 3, FieldValue< 3 >::Scalar >, Field< 3, FieldValue< 3 >::VectorFixed >, Field< spacedim, FieldValue< 3 >::Scalar >, Field< spacedim, FieldValue< 3 >::Enum >, Field< 3, FieldValue< 3 >::Integer >, Field< 3, FieldValue< 3 >::TensorFixed >, and Field< 3, FieldValue< 3 >::EnumVector >.

Here is the caller graph for this function:

double FieldCommonBase::time ( ) const
inline

Returns time set by last call of set_time method. Can be different for different field copies.

Definition at line 186 of file field.hh.

Here is the caller graph for this function:

FieldCommonBase::TYPEDEF_ERR_INFO ( EI_Time  ,
double   
)
FieldCommonBase::TYPEDEF_ERR_INFO ( EI_Field  ,
std::string   
)
FieldCommonBase& FieldCommonBase::units ( const string &  units)
inline

Set basic units of the field.

Currently, we use it only during output and we represents units just by a string.

TODO: Particular class for representing and conversion of various units would be more appropriate. This can allow specification of the units on the inptu, automatic conversion and the same on the output. Possibly this allow using Boost::Units library, however, it seems to introduce lot of boilerplate code. But can increase correctness of the calculations.

Definition at line 96 of file field.hh.

Here is the caller graph for this function:

const std::string& FieldCommonBase::units ( ) const
inline

Definition at line 164 of file field.hh.

Member Data Documentation

const unsigned int FieldCommonBase::history_length_limit_ =3
staticprotected

Maximum number of FieldBase objects we store per one region.

Definition at line 403 of file field.hh.

bool FieldCommonBase::is_copy_ =false
protected

Flag field that has to be set as a copy of other field using copy_from method.

Definition at line 406 of file field.hh.

double FieldCommonBase::last_time_ = -numeric_limits<double>::infinity()
protected

Last set time. Can be different for different field copies.

Definition at line 393 of file field.hh.

LimitSide FieldCommonBase::limit_side_
protected

Which value is returned for times where field is discontinuous.

Definition at line 376 of file field.hh.

TimeStatus FieldCommonBase::set_time_result_
protected

Status of history.

Definition at line 388 of file field.hh.

std::shared_ptr<SharedData> FieldCommonBase::shared_
protected

Definition at line 371 of file field.hh.

OutputTime::DiscreteSpace FieldCommonBase::type_of_output_data_ = OutputTime::ELEM_DATA
protected

Output data type used in the output() method. Can be different for different field copies.

Definition at line 398 of file field.hh.


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