Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
hysop
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
particle_methods
hysop
Commits
6e0b20f5
Commit
6e0b20f5
authored
3 years ago
by
EXT Jean-Matthieu Etancelin
Browse files
Options
Downloads
Patches
Plain Diff
add tensor field to analytic operator
parent
a2eac9de
No related branches found
No related tags found
1 merge request
!34
Add custom opencl
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
hysop/backend/host/python/operator/analytic.py
+18
-17
18 additions, 17 deletions
hysop/backend/host/python/operator/analytic.py
with
18 additions
and
17 deletions
hysop/backend/host/python/operator/analytic.py
+
18
−
17
View file @
6e0b20f5
from
hysop.tools.types
import
check_instance
,
first_not_None
from
hysop.tools.types
import
check_instance
,
first_not_None
from
hysop.tools.decorators
import
debug
from
hysop.tools.decorators
import
debug
from
hysop.backend.host.host_operator
import
HostOperator
from
hysop.backend.host.host_operator
import
HostOperator
from
hysop.core.graph.graph
import
op_apply
from
hysop.core.graph.graph
import
op_apply
from
hysop.fields.continuous_field
import
Field
,
ScalarField
from
hysop.fields.continuous_field
import
Field
,
ScalarField
,
VectorField
from
hysop.parameters.parameter
import
Parameter
from
hysop.parameters.parameter
import
Parameter
from
hysop.topology.cartesian_descriptor
import
CartesianTopologyDescriptors
from
hysop.topology.cartesian_descriptor
import
CartesianTopologyDescriptors
class
PythonAnalyticField
(
HostOperator
):
class
PythonAnalyticField
(
HostOperator
):
"""
"""
Applies an analytic formula, given by user, on its field.
Applies an analytic formula, given by user, on its field.
...
@@ -15,15 +15,15 @@ class PythonAnalyticField(HostOperator):
...
@@ -15,15 +15,15 @@ class PythonAnalyticField(HostOperator):
@debug
@debug
def
__new__
(
cls
,
field
,
formula
,
variables
,
def
__new__
(
cls
,
field
,
formula
,
variables
,
extra_input_kwds
=
None
,
**
kwds
):
extra_input_kwds
=
None
,
**
kwds
):
return
super
(
PythonAnalyticField
,
cls
).
__new__
(
cls
,
return
super
(
PythonAnalyticField
,
cls
).
__new__
(
cls
,
input_fields
=
None
,
input_fields
=
None
,
output_fields
=
None
,
output_fields
=
None
,
input_params
=
None
,
**
kwds
)
input_params
=
None
,
**
kwds
)
@debug
@debug
def
__init__
(
self
,
field
,
formula
,
variables
,
def
__init__
(
self
,
field
,
formula
,
variables
,
extra_input_kwds
=
None
,
**
kwds
):
extra_input_kwds
=
None
,
**
kwds
):
"""
"""
Initialize a Analytic operator on the python backend.
Initialize a Analytic operator on the python backend.
...
@@ -52,18 +52,18 @@ class PythonAnalyticField(HostOperator):
...
@@ -52,18 +52,18 @@ class PythonAnalyticField(HostOperator):
"""
"""
extra_input_kwds
=
first_not_None
(
extra_input_kwds
,
{})
extra_input_kwds
=
first_not_None
(
extra_input_kwds
,
{})
check_instance
(
field
,
ScalarField
)
check_instance
(
field
,
(
ScalarField
,
VectorField
)
)
assert
callable
(
formula
),
type
(
formula
)
assert
callable
(
formula
),
type
(
formula
)
check_instance
(
variables
,
dict
,
keys
=
Field
,
values
=
CartesianTopologyDescriptors
)
check_instance
(
variables
,
dict
,
keys
=
Field
,
values
=
CartesianTopologyDescriptors
)
check_instance
(
extra_input_kwds
,
dict
,
keys
=
str
)
check_instance
(
extra_input_kwds
,
dict
,
keys
=
str
)
input_fields
=
{}
input_fields
=
{}
output_fields
=
{
field
:
self
.
get_topo_descriptor
(
variables
,
field
)
}
output_fields
=
{
field
:
self
.
get_topo_descriptor
(
variables
,
field
)}
input_params
=
{}
input_params
=
{}
extra_kwds
=
{}
extra_kwds
=
{}
map_fields
=
{}
map_fields
=
{}
for
(
k
,
v
)
in
extra_input_kwds
.
items
():
for
(
k
,
v
)
in
extra_input_kwds
.
items
():
if
isinstance
(
v
,
Field
):
if
isinstance
(
v
,
Field
):
input_fields
[
v
]
=
self
.
get_topo_descriptor
(
variables
,
v
)
input_fields
[
v
]
=
self
.
get_topo_descriptor
(
variables
,
v
)
map_fields
[
v
]
=
k
map_fields
[
v
]
=
k
...
@@ -74,8 +74,8 @@ class PythonAnalyticField(HostOperator):
...
@@ -74,8 +74,8 @@ class PythonAnalyticField(HostOperator):
extra_kwds
[
k
]
=
v
extra_kwds
[
k
]
=
v
super
(
PythonAnalyticField
,
self
).
__init__
(
input_fields
=
input_fields
,
super
(
PythonAnalyticField
,
self
).
__init__
(
input_fields
=
input_fields
,
output_fields
=
output_fields
,
output_fields
=
output_fields
,
input_params
=
input_params
,
**
kwds
)
input_params
=
input_params
,
**
kwds
)
self
.
field
=
field
self
.
field
=
field
self
.
formula
=
formula
self
.
formula
=
formula
...
@@ -90,9 +90,11 @@ class PythonAnalyticField(HostOperator):
...
@@ -90,9 +90,11 @@ class PythonAnalyticField(HostOperator):
dfield
=
self
.
get_output_discrete_field
(
self
.
field
)
dfield
=
self
.
get_output_discrete_field
(
self
.
field
)
extra_kwds
=
self
.
extra_kwds
extra_kwds
=
self
.
extra_kwds
map_fields
=
self
.
map_fields
map_fields
=
self
.
map_fields
assert
'
data
'
not
in
extra_kwds
assert
'
data
'
not
in
extra_kwds
assert
'
coords
'
not
in
extra_kwds
assert
'
coords
'
not
in
extra_kwds
extra_kwds
[
'
data
'
]
=
dfield
.
compute_data
[
0
]
extra_kwds
[
'
data
'
]
=
dfield
.
compute_data
[
0
]
if
len
(
dfield
.
compute_data
)
>
1
:
extra_kwds
[
'
data
'
]
=
dfield
.
compute_data
extra_kwds
[
'
coords
'
]
=
dfield
.
compute_mesh_coords
extra_kwds
[
'
coords
'
]
=
dfield
.
compute_mesh_coords
for
(
field
,
dfield
)
in
self
.
input_discrete_fields
.
items
():
for
(
field
,
dfield
)
in
self
.
input_discrete_fields
.
items
():
assert
field
.
name
not
in
extra_kwds
,
field
.
name
assert
field
.
name
not
in
extra_kwds
,
field
.
name
...
@@ -109,4 +111,3 @@ class PythonAnalyticField(HostOperator):
...
@@ -109,4 +111,3 @@ class PythonAnalyticField(HostOperator):
@classmethod
@classmethod
def
supports_mpi
(
cls
):
def
supports_mpi
(
cls
):
return
True
return
True
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment