Flow123d  master-f44eb46
Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | Static Private Attributes | List of all members
FieldPython< spacedim, Value > Class Template Reference

#include <field_python.hh>

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

Public Types

typedef FieldAlgorithmBase< spacedim, Value >::Point Point
 
typedef FieldAlgorithmBase< spacedim, ValueFactoryBaseType
 
- Public Types inherited from FieldAlgorithmBase< spacedim, Value >
typedef Space< spacedim >::Point Point
 

Public Member Functions

 TYPEDEF_ERR_INFO (EI_FuncName, std::string)
 
 TYPEDEF_ERR_INFO (EI_PModule, std::string)
 
 TYPEDEF_ERR_INFO (EI_Size, unsigned int)
 
 TYPEDEF_ERR_INFO (EI_ValueSize, unsigned int)
 
 DECLARE_EXCEPTION (ExcInvalidCompNumber,<< "Field "<< EI_FuncName::qval<< " from the python module: "<< EI_PModule::val<< " returns "<< EI_Size::val<< " components but should return "<< EI_ValueSize::val<< " components.\n")
 
 FieldPython (unsigned int n_comp=0)
 
virtual void init_from_input (const Input::Record &rec, const struct FieldAlgoBaseInitData &init_data)
 
void set_python_field_from_class (const string &file_name, const string &class_name)
 
void cache_reinit (const ElementCacheMap &cache_map) override
 
void cache_update (FieldValueCache< typename Value::element_type > &data_cache, ElementCacheMap &cache_map, unsigned int region_patch_idx) override
 
std::vector< const FieldCommon * > set_dependency (FieldSet &field_set) override
 
virtual ~FieldPython ()
 
- Public Member Functions inherited from FieldAlgorithmBase< spacedim, Value >
 TYPEDEF_ERR_INFO (EI_Field, std::string)
 
 DECLARE_EXCEPTION (ExcInputInitUnsupported,<< "The field "<< EI_Field::qval<< " do not support initialization from input.\n")
 
 FieldAlgorithmBase (unsigned int n_comp=0)
 
virtual bool set_time (const TimeStep &time)
 
virtual void set_mesh (const Mesh *mesh)
 
void set_component_idx (unsigned int idx)
 
unsigned int n_comp () const
 
FieldResult field_result () const
 
virtual double next_change_time ()
 
virtual void set_native_dh (std::shared_ptr< DOFHandlerMultiDim >)
 
bool is_constant_in_space () const
 
virtual std::vector< const FieldCommon * > set_dependency (FMT_UNUSED FieldSet &field_set)
 
virtual ~FieldAlgorithmBase ()
 

Static Public Member Functions

static const Input::Type::Recordget_input_type ()
 Implementation. More...
 
- Static Public Member Functions inherited from FieldAlgorithmBase< spacedim, Value >
static std::string template_name ()
 
static Input::Type::Abstractget_input_type ()
 
static const Input::Type::Instanceget_input_type_instance (Input::Type::Selection value_selection=Input::Type::Selection())
 
static const Input::Type::Recordget_field_algo_common_keys ()
 
static std::shared_ptr< FieldAlgorithmBase< spacedim, Value > > function_factory (const Input::AbstractRecord &rec, const struct FieldAlgoBaseInitData &init_data)
 

Private Attributes

Input::Record in_rec_
 Accessor to Input::Record. More...
 
std::string field_name_
 Field name is necessary for set result. More...
 
py::object user_class_instance_
 Holds python instance of user class. More...
 
std::vector< const FieldCommon * > required_fields_
 List of fields on which this field depends. More...
 
const FieldCommonself_field_ptr_
 Pointer to FieldCommon that holds this fields (stores in set_dependency and uses in cache_reinit) More...
 

Static Private Attributes

static const int registrar
 Registrar of class to factory. More...
 

Additional Inherited Members

- Static Public Attributes inherited from FieldAlgorithmBase< spacedim, Value >
static const unsigned int spacedim_ =spacedim
 
static constexpr bool is_enum_valued = std::is_same<typename Value::element_type, FieldEnum>::value
 
- Protected Member Functions inherited from FieldAlgorithmBase< spacedim, Value >
void init_unit_conversion_coefficient (const Input::Record &rec, const struct FieldAlgoBaseInitData &init_data)
 Init value of unit_conversion_coefficient_ from input. More...
 
- Protected Attributes inherited from FieldAlgorithmBase< spacedim, Value >
TimeStep time_
 Actual time level; initial value is -infinity. More...
 
Value value_
 Last value, prevents passing large values (vectors) by value. More...
 
Value::return_type r_value_
 
FieldResult field_result_
 Indicator of particular values (zero, one) constant over space. More...
 
unsigned int component_idx_
 Specify if the field is part of a MultiField and which component it is. More...
 
double unit_conversion_coefficient_
 Coeficient of conversion of user-defined unit. More...
 
bool is_constant_in_space_
 Flag detects that field is only dependent on time. More...
 

Detailed Description

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

This class assumes field python field with spacedim arguments containing coordinates of the given point. The field should return a tuple representing a vector value (possibly of size one for scalar fields)

TODO:

Definition at line 52 of file field_python.hh.

Member Typedef Documentation

◆ FactoryBaseType

template<int spacedim, class Value >
typedef FieldAlgorithmBase<spacedim, Value> FieldPython< spacedim, Value >::FactoryBaseType

Definition at line 56 of file field_python.hh.

◆ Point

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

Definition at line 55 of file field_python.hh.

Constructor & Destructor Documentation

◆ FieldPython()

template<int spacedim, class Value >
FieldPython< spacedim, Value >::FieldPython ( unsigned int  n_comp = 0)

Definition at line 67 of file field_python.impl.hh.

◆ ~FieldPython()

template<int spacedim, class Value >
FieldPython< spacedim, Value >::~FieldPython
virtual

Definition at line 167 of file field_python.impl.hh.

Member Function Documentation

◆ cache_reinit()

template<int spacedim, class Value >
void FieldPython< spacedim, Value >::cache_reinit ( const ElementCacheMap cache_map)
overridevirtual

Overload FieldAlgorithmBase::cache_reinit

Reinit dictionary of used fields and update result field to dictionary of resul fields.

Reimplemented from FieldAlgorithmBase< spacedim, Value >.

Definition at line 128 of file field_python.impl.hh.

◆ cache_update()

template<int spacedim, class Value >
void FieldPython< spacedim, Value >::cache_update ( FieldValueCache< typename Value::element_type > &  data_cache,
ElementCacheMap cache_map,
unsigned int  region_patch_idx 
)
overridevirtual

Reimplemented from FieldAlgorithmBase< spacedim, Value >.

Definition at line 151 of file field_python.impl.hh.

◆ DECLARE_EXCEPTION()

template<int spacedim, class Value >
FieldPython< spacedim, Value >::DECLARE_EXCEPTION ( ExcInvalidCompNumber  ,
<< "Field "<< EI_FuncName::qval<< " from the python module: "<< EI_PModule::val<< " returns "<< EI_Size::val<< " components but should return "<< EI_ValueSize::val<< " components.\n"   
)

◆ get_input_type()

template<int spacedim, class Value >
const Input::Type::Record & FieldPython< spacedim, Value >::get_input_type
static

Implementation.

Definition at line 41 of file field_python.impl.hh.

◆ init_from_input()

template<int spacedim, class Value >
void FieldPython< spacedim, Value >::init_from_input ( const Input::Record rec,
const struct FieldAlgoBaseInitData init_data 
)
virtual

Function can provide way to initialize itself from the input data.

TODO: make protected, should be called through function factory

Reimplemented from FieldAlgorithmBase< spacedim, Value >.

Definition at line 77 of file field_python.impl.hh.

◆ set_dependency()

template<int spacedim, class Value >
std::vector< const FieldCommon * > FieldPython< spacedim, Value >::set_dependency ( FieldSet field_set)
override

Returns list of fields on which this field depends.

Definition at line 107 of file field_python.impl.hh.

◆ set_python_field_from_class()

template<int spacedim, class Value >
void FieldPython< spacedim, Value >::set_python_field_from_class ( const string &  file_name,
const string &  class_name 
)

Set the source in a string and name of the field to be called.

Definition at line 93 of file field_python.impl.hh.

◆ TYPEDEF_ERR_INFO() [1/4]

template<int spacedim, class Value >
FieldPython< spacedim, Value >::TYPEDEF_ERR_INFO ( EI_FuncName  ,
std::string   
)

◆ TYPEDEF_ERR_INFO() [2/4]

template<int spacedim, class Value >
FieldPython< spacedim, Value >::TYPEDEF_ERR_INFO ( EI_PModule  ,
std::string   
)

◆ TYPEDEF_ERR_INFO() [3/4]

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

◆ TYPEDEF_ERR_INFO() [4/4]

template<int spacedim, class Value >
FieldPython< spacedim, Value >::TYPEDEF_ERR_INFO ( EI_ValueSize  ,
unsigned int   
)

Member Data Documentation

◆ field_name_

template<int spacedim, class Value >
std::string FieldPython< spacedim, Value >::field_name_
private

Field name is necessary for set result.

Definition at line 102 of file field_python.hh.

◆ in_rec_

template<int spacedim, class Value >
Input::Record FieldPython< spacedim, Value >::in_rec_
private

Accessor to Input::Record.

Definition at line 99 of file field_python.hh.

◆ registrar

template<int spacedim, class Value >
const int FieldPython< spacedim, Value >::registrar
staticprivate
Initial value:
=
Input::register_class< FieldPython<spacedim, Value>, unsigned int >("FieldPython") +

Registrar of class to factory.

Definition at line 96 of file field_python.hh.

◆ required_fields_

template<int spacedim, class Value >
std::vector<const FieldCommon * > FieldPython< spacedim, Value >::required_fields_
private

List of fields on which this field depends.

Definition at line 108 of file field_python.hh.

◆ self_field_ptr_

template<int spacedim, class Value >
const FieldCommon* FieldPython< spacedim, Value >::self_field_ptr_
private

Pointer to FieldCommon that holds this fields (stores in set_dependency and uses in cache_reinit)

Definition at line 111 of file field_python.hh.

◆ user_class_instance_

template<int spacedim, class Value >
py::object FieldPython< spacedim, Value >::user_class_instance_
private

Holds python instance of user class.

Definition at line 105 of file field_python.hh.


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