Flow123d
release_3.0.0-968-gc87a28e79
Main Page
Related Pages
Modules
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
u
v
w
y
Functions
_
a
b
c
d
e
f
g
h
i
m
n
o
p
r
s
t
u
w
Variables
Typedefs
Enumerations
Enumerator
a
b
c
d
f
g
h
i
m
n
o
p
r
s
u
w
y
Classes
Class List
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
x
Enumerations
a
b
c
d
f
h
i
m
n
o
p
r
s
t
u
v
Enumerator
a
b
c
d
e
f
g
i
k
l
m
n
o
p
r
s
t
u
v
w
x
y
z
Related Functions
a
b
c
d
e
f
i
l
m
n
o
p
r
s
t
Files
File List
File Members
All
_
a
b
c
d
e
f
g
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Functions
_
a
b
c
d
e
f
i
k
m
n
o
p
r
s
t
u
v
w
x
z
Variables
_
a
c
d
g
m
n
p
q
r
s
v
x
Typedefs
a
d
e
f
i
j
l
m
n
o
q
r
s
u
x
Enumerations
Enumerator
a
c
d
e
f
i
k
m
n
o
p
r
s
u
v
w
Macros
_
a
b
c
d
e
f
g
i
j
k
l
m
n
o
p
q
r
s
t
v
w
x
z
flow123d
src
fields
field_python.hh
Go to the documentation of this file.
1
/*!
2
*
3
* Copyright (C) 2015 Technical University of Liberec. All rights reserved.
4
*
5
* This program is free software; you can redistribute it and/or modify it under
6
* the terms of the GNU General Public License version 3 as published by the
7
* Free Software Foundation. (http://www.gnu.org/licenses/gpl-3.0.en.html)
8
*
9
* This program is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
*
13
*
14
* @file field_python.hh
15
* @brief
16
* @todo make FieldPython dummy class if we do not have python, so that we
17
* need not optional code elsewhere
18
*/
19
20
#ifndef FIELD_PYTHON_HH_
21
#define FIELD_PYTHON_HH_
22
23
24
#include "
system/system.hh
"
25
#include "
system/python_loader.hh
"
26
#include "
fields/field_algo_base.hh
"
27
#include "
mesh/point.hh
"
28
#include "
input/factory.hh
"
29
30
#include <string>
31
using namespace
std
;
32
33
/**
34
*
35
* This class assumes field python field with @p spacedim arguments containing coordinates of the given point.
36
* The field should return a tuple representing a vector value (possibly of size one for scalar fields)
37
*
38
* TODO:
39
* - use rather only one argument - tuple representing the whole point
40
* - time fields
41
* - set some parameter in the python module
42
* - for fields with one component allow python fields returning the value directly
43
*
44
*/
45
template
<
int
spacedim,
class
Value>
46
class
FieldPython
:
public
FieldAlgorithmBase
<spacedim, Value>
47
{
48
public
:
49
typedef
typename
FieldAlgorithmBase<spacedim, Value>::Point
Point
;
50
typedef
FieldAlgorithmBase<spacedim, Value>
FactoryBaseType
;
51
52
FieldPython
(
unsigned
int
n_comp=0);
53
54
virtual
void
init_from_input(
const
Input::Record
&rec,
const
struct
FieldAlgoBaseInitData
& init_data);
55
56
static
const
Input::Type::Record
& get_input_type();
57
58
/**
59
* Set the file and field to be called.
60
* TODO: use FilePath
61
*/
62
void
set_python_field_from_file(
const
FilePath
&file_name,
const
string
&func_name);
63
64
/**
65
* Set the source in a string and name of the field to be called.
66
*/
67
void
set_python_field_from_string(
const
string
&python_source,
const
string
&func_name);
68
69
/**
70
* Returns one value in one given point. ResultType can be used to avoid some costly calculation if the result is trivial.
71
*/
72
virtual
typename
Value::return_type
const
&
value
(
const
Point
&p,
const
ElementAccessor<spacedim>
&elm);
73
74
/**
75
* Returns std::vector of scalar values in several points at once.
76
*/
77
virtual
void
value_list (
const
std::vector< Point >
&point_list,
const
ElementAccessor<spacedim>
&elm,
78
std::vector<typename Value::return_type>
&value_list);
79
80
81
virtual
~
FieldPython
();
82
83
private
:
84
/// Registrar of class to factory
85
static
const
int
registrar
;
86
87
/**
88
* Common part of set_python_field_from_* methods
89
*/
90
void
set_func(
const
string
&func_name);
91
92
/**
93
* Implementation.
94
*/
95
inline
void
set_value(
const
Point
&p,
const
ElementAccessor<spacedim>
&elm,
Value
&
value
);
96
97
#ifdef FLOW123D_HAVE_PYTHON
98
PyObject *p_func_;
99
PyObject *p_module_;
100
mutable
PyObject *p_args_;
101
mutable
PyObject *p_value_;
102
#endif // FLOW123D_HAVE_PYTHON
103
104
};
105
106
107
108
#endif
/* FUNCTION_PYTHON_HH_ */
factory.hh
python_loader.hh
field_algo_base.hh
point.hh
value
static constexpr bool value
Definition:
json.hpp:87
FilePath
Dedicated class for storing path to input and output files.
Definition:
file_path.hh:54
std::vector
Definition:
doxy_dummy_defs.hh:7
ElementAccessor
Definition:
fe_value_handler.hh:29
system.hh
FieldAlgorithmBase::Point
Space< spacedim >::Point Point
Definition:
field_algo_base.hh:113
Input::Record
Accessor to the data with type Type::Record.
Definition:
accessors.hh:291
FieldAlgoBaseInitData
Helper struct stores data for initizalize descentants of FieldAlgorithmBase.
Definition:
field_algo_base.hh:79
FieldPython::registrar
static const int registrar
Registrar of class to factory.
Definition:
field_python.hh:85
Input::Type::Record
Record type proxy class.
Definition:
type_record.hh:182
Value
@ Value
Definition:
finite_element.hh:47
FieldPython
Definition:
field_python.hh:46
FieldAlgorithmBase
Definition:
field_algo_base.hh:110
std
Definition:
doxy_dummy_defs.hh:5
FieldPython::FactoryBaseType
FieldAlgorithmBase< spacedim, Value > FactoryBaseType
Definition:
field_python.hh:50
FieldPython::Point
FieldAlgorithmBase< spacedim, Value >::Point Point
Definition:
field_python.hh:49
Generated by
1.8.17