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
31605122
Commit
31605122
authored
4 years ago
by
EXT Jean-Matthieu Etancelin
Browse files
Options
Downloads
Patches
Plain Diff
fix python flowrate correction
parent
8e95d031
No related branches found
No related tags found
1 merge request
!16
MPI operators
Pipeline
#39993
failed
4 years ago
Stage: env
Stage: configure
Stage: build
Stage: install
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
hysop/backend/host/python/operator/flowrate_correction.py
+21
-18
21 additions, 18 deletions
hysop/backend/host/python/operator/flowrate_correction.py
with
21 additions
and
18 deletions
hysop/backend/host/python/operator/flowrate_correction.py
+
21
−
18
View file @
31605122
...
@@ -44,7 +44,7 @@ class PythonFlowRateCorrection(HostOperator):
...
@@ -44,7 +44,7 @@ class PythonFlowRateCorrection(HostOperator):
self
.
absorption_start
=
absorption_start
self
.
absorption_start
=
absorption_start
if
self
.
absorption_start
is
None
:
if
self
.
absorption_start
is
None
:
self
.
absorption_start
=
velocity
.
domain
.
end
[
-
1
]
self
.
absorption_start
=
velocity
.
domain
.
end
[
-
1
]
#
#
TODO: Correction is taking an absorption start (see absorption operator) only in X dir.
# TODO: Correction is taking an absorption start (see absorption operator) only in X dir.
super
(
PythonFlowRateCorrection
,
self
).
__init__
(
super
(
PythonFlowRateCorrection
,
self
).
__init__
(
input_fields
=
input_fields
,
output_fields
=
output_fields
,
input_fields
=
input_fields
,
output_fields
=
output_fields
,
input_params
=
input_params
,
**
kwds
)
input_params
=
input_params
,
**
kwds
)
...
@@ -63,35 +63,38 @@ class PythonFlowRateCorrection(HostOperator):
...
@@ -63,35 +63,38 @@ class PythonFlowRateCorrection(HostOperator):
super
(
PythonFlowRateCorrection
,
self
).
discretize
()
super
(
PythonFlowRateCorrection
,
self
).
discretize
()
self
.
dvelocity
=
self
.
input_discrete_tensor_fields
[
self
.
velocity
]
self
.
dvelocity
=
self
.
input_discrete_tensor_fields
[
self
.
velocity
]
self
.
dvorticity
=
self
.
input_discrete_tensor_fields
[
self
.
vorticity
]
self
.
dvorticity
=
self
.
input_discrete_tensor_fields
[
self
.
vorticity
]
topo
=
self
.
dvelocity
[
0
].
topology
vtopo
=
self
.
dvelocity
[
0
].
topology
mesh
=
topo
.
mesh
wtopo
=
self
.
dvorticity
[
0
].
topology
vmesh
=
vtopo
.
mesh
wmesh
=
wtopo
.
mesh
# Compute volume and surface integration coefficients
# Compute volume and surface integration coefficients
spaceStep
=
mesh
.
space_step
spaceStep
=
v
mesh
.
space_step
lengths
=
topo
.
domain
.
length
lengths
=
v
topo
.
domain
.
length
self
.
_inv_ds
=
1.
/
np
.
prod
(
lengths
[:
-
1
])
self
.
_inv_ds
=
1.
/
np
.
prod
(
lengths
[:
-
1
])
self
.
_inv_dvol
=
1.
/
(
lengths
[
0
]
*
lengths
[
1
]
*
(
self
.
absorption_start
-
topo
.
domain
.
origin
[
-
1
]))
self
.
_inv_dvol
=
1.
/
(
lengths
[
0
]
*
lengths
[
1
]
*
(
self
.
absorption_start
-
vtopo
.
domain
.
origin
[
-
1
]))
self
.
coeff_mean
=
np
.
prod
(
spaceStep
)
/
np
.
prod
(
lengths
)
self
.
coeff_mean
=
np
.
prod
(
spaceStep
)
/
np
.
prod
(
lengths
)
# Compute space coordinates from domain origin
# Compute space coordinates from domain origin
x0
=
mesh
.
global_origin
[
-
1
]
x0
=
v
mesh
.
global_origin
[
-
1
]
self
.
x_coord
=
mesh
.
local_mesh_coords
[
0
]
-
x0
self
.
x_coord
=
v
mesh
.
local_mesh_coords
[
0
]
-
x0
# Compute slices for volume and surface integration
# Compute slices for volume and surface integration
gstart
=
mesh
.
local_origin
.
copy
()
gstart
=
v
mesh
.
local_origin
.
copy
()
gstart
[
-
1
]
=
mesh
.
global_origin
[
-
1
]
gstart
[
-
1
]
=
v
mesh
.
global_origin
[
-
1
]
if
mesh
.
is_inside_local_domain
(
gstart
):
if
v
mesh
.
is_inside_local_domain
(
gstart
):
ind4integ_v
=
[
_
for
_
in
mesh
.
local_compute_slices
]
ind4integ_v
=
[
_
for
_
in
v
mesh
.
local_compute_slices
]
ind4integ_v
[
-
1
]
=
mesh
.
point_local_indices
(
gstart
)[
-
1
]
ind4integ_v
[
-
1
]
=
v
mesh
.
point_local_indices
(
gstart
)[
-
1
]
self
.
_ind4integ_v
=
tuple
(
ind4integ_v
)
self
.
_ind4integ_v
=
tuple
(
ind4integ_v
)
else
:
else
:
self
.
_ind4integ_v
=
None
self
.
_ind4integ_v
=
None
self
.
_ds_in
=
np
.
prod
(
spaceStep
[
0
:
2
])
self
.
_ds_in
=
np
.
prod
(
spaceStep
[
0
:
2
])
ind4integ_w
=
[
_
for
_
in
mesh
.
local_compute_slices
]
ind4integ_w
=
[
_
for
_
in
w
mesh
.
local_compute_slices
]
box_end
=
mesh
.
local_origin
.
copy
()
box_end
=
w
mesh
.
local_origin
.
copy
()
box_end
[
-
1
]
=
self
.
absorption_start
box_end
[
-
1
]
=
self
.
absorption_start
ind4integ_w
[
-
1
]
=
slice
(
ind4integ_w
[
-
1
].
start
,
ind4integ_w
[
-
1
]
=
slice
(
ind4integ_w
[
-
1
].
start
,
mesh
.
point_local_indices
(
box_end
)[
-
1
],
w
mesh
.
point_local_indices
(
box_end
)[
-
1
],
ind4integ_w
[
-
1
].
step
)
ind4integ_w
[
-
1
].
step
)
self
.
_ind4integ_w
=
tuple
(
ind4integ_w
)
self
.
_ind4integ_w
=
tuple
(
ind4integ_w
)
self
.
_ds_box
=
np
.
prod
(
spaceStep
)
self
.
_ds_box
=
np
.
prod
(
spaceStep
)
...
@@ -134,13 +137,13 @@ class PythonFlowRateCorrection(HostOperator):
...
@@ -134,13 +137,13 @@ class PythonFlowRateCorrection(HostOperator):
flowrate_req
=
self
.
flowrate
()
*
self
.
_inv_ds
flowrate_req
=
self
.
flowrate
()
*
self
.
_inv_ds
velo_shift
=
np
.
zeros
((
dv
.
dim
,
))
velo_shift
=
np
.
zeros
((
dv
.
dim
,
))
velo_shift
=
flowrate_req
-
self
.
rates
[
0
:
dv
.
dim
]
velo_shift
=
flowrate_req
-
self
.
rates
[
dv
.
dim
-
1
::
-
1
]
# Shift velocity Vx
# Shift velocity Vx
dv
.
data
[
0
][...]
+=
velo_shift
[
2
]
dv
.
data
[
0
][...]
+=
velo_shift
[
2
]
# Update Vy and Vz with mean vorticity
# Update Vy and Vz with mean vorticity
dv
.
data
[
1
][...]
+=
velo_shift
[
1
]
+
self
.
rates
[
dv
.
dim
]
*
self
.
x_coord
dv
.
data
[
1
][...]
+=
velo_shift
[
1
]
+
self
.
rates
[
dv
.
dim
+
2
]
*
self
.
x_coord
dv
.
data
[
2
][...]
+=
velo_shift
[
0
]
+
self
.
rates
[
dv
.
dim
+
1
]
*
self
.
x_coord
dv
.
data
[
2
][...]
+=
velo_shift
[
0
]
+
self
.
rates
[
dv
.
dim
+
1
]
*
self
.
x_coord
if
(
self
.
ghost_exchanger
is
not
None
):
if
(
self
.
ghost_exchanger
is
not
None
):
self
.
ghost_exchanger
()
self
.
ghost_exchanger
()
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