Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
VirtualFluids
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
iRMB
VirtualFluids
Commits
3729bd3b
Commit
3729bd3b
authored
1 year ago
by
Hkorb
Browse files
Options
Downloads
Patches
Plain Diff
simplify array conversion
parent
6aa693aa
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!245
Add new probe, Refactor File Writer
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pythonbindings/src/gpu/submodules/actuator_farm.cpp
+38
-30
38 additions, 30 deletions
pythonbindings/src/gpu/submodules/actuator_farm.cpp
with
38 additions
and
30 deletions
pythonbindings/src/gpu/submodules/actuator_farm.cpp
+
38
−
30
View file @
3729bd3b
...
...
@@ -34,6 +34,7 @@
#include
<pybind11/numpy.h>
#include
<gpu/VirtualFluids_GPU/PreCollisionInteractor/ActuatorFarm.h>
#include
<gpu/VirtualFluids_GPU/PreCollisionInteractor/PreCollisionInteractor.h>
class
PyActuatorFarm
:
public
ActuatorFarm
{
public:
...
...
@@ -43,13 +44,20 @@ public:
PYBIND11_OVERRIDE_NAME
(
void
,
ActuatorFarm
,
"calc_blade_forces"
,
calcBladeForces
);
}
};
namespace
actuator_farm
{
namespace
py
=
pybind11
;
template
<
class
dtype
>
dtype
*
np_to_arr
(
py
::
array_t
<
dtype
,
py
::
array
::
c_style
>
array
){
return
static_cast
<
dtype
*>
(
array
.
request
().
ptr
);
};
template
<
class
dtype
>
intptr_t
arr_to_cp
(
dtype
*
array
){
return
reinterpret_cast
<
intptr_t
>
(
array
);
};
void
makeModule
(
py
::
module_
&
parentModule
)
{
using
arr
=
py
::
array_t
<
float
,
py
::
array
::
c_style
>
;
using
arr
=
py
::
array_t
<
real
,
py
::
array
::
c_style
>
;
py
::
class_
<
ActuatorFarm
,
PreCollisionInteractor
,
PyActuatorFarm
,
std
::
shared_ptr
<
ActuatorFarm
>>
(
parentModule
,
"ActuatorFarm"
,
py
::
dynamic_attr
())
.
def
(
py
::
init
<
const
uint
,
...
...
@@ -112,31 +120,31 @@ namespace actuator_farm
.
def
(
"get_turbine_blade_forces_y"
,
[](
ActuatorFarm
&
al
,
uint
turbine
){
return
arr
({
al
.
getNumberOfBladesPerTurbine
(),
al
.
getNumberOfNodesPerBlade
()},
al
.
getTurbineBladeForcesYDevice
(
turbine
));
},
py
::
arg
(
"turbine"
)
)
.
def
(
"get_turbine_blade_forces_z"
,
[](
ActuatorFarm
&
al
,
uint
turbine
){
return
arr
({
al
.
getNumberOfBladesPerTurbine
(),
al
.
getNumberOfNodesPerBlade
()},
al
.
getTurbineBladeForcesZDevice
(
turbine
));
},
py
::
arg
(
"turbine"
)
)
.
def
(
"get_all_blade_radii_device"
,
[](
ActuatorFarm
&
al
)
->
intptr_t
{
return
reinterpret_cast
<
intptr_t
>
(
al
.
getAllBladeRadiiDevice
());
}
)
.
def
(
"get_all_blade_coords_x_device"
,
[](
ActuatorFarm
&
al
)
->
intptr_t
{
return
reinterpret_cast
<
intptr_t
>
(
al
.
getAllBladeCoordsXDevice
());
}
)
.
def
(
"get_all_blade_coords_y_device"
,
[](
ActuatorFarm
&
al
)
->
intptr_t
{
return
reinterpret_cast
<
intptr_t
>
(
al
.
getAllBladeCoordsYDevice
());
}
)
.
def
(
"get_all_blade_coords_z_device"
,
[](
ActuatorFarm
&
al
)
->
intptr_t
{
return
reinterpret_cast
<
intptr_t
>
(
al
.
getAllBladeCoordsZDevice
());
}
)
.
def
(
"get_all_blade_velocities_x_device"
,
[](
ActuatorFarm
&
al
)
->
intptr_t
{
return
reinterpret_cast
<
intptr_t
>
(
al
.
getAllBladeVelocitiesXDevice
());
}
)
.
def
(
"get_all_blade_velocities_y_device"
,
[](
ActuatorFarm
&
al
)
->
intptr_t
{
return
reinterpret_cast
<
intptr_t
>
(
al
.
getAllBladeVelocitiesYDevice
());
}
)
.
def
(
"get_all_blade_velocities_z_device"
,
[](
ActuatorFarm
&
al
)
->
intptr_t
{
return
reinterpret_cast
<
intptr_t
>
(
al
.
getAllBladeVelocitiesZDevice
());
}
)
.
def
(
"get_all_blade_forces_x_device"
,
[](
ActuatorFarm
&
al
)
->
intptr_t
{
return
reinterpret_cast
<
intptr_t
>
(
al
.
getAllBladeForcesXDevice
());
}
)
.
def
(
"get_all_blade_forces_y_device"
,
[](
ActuatorFarm
&
al
)
->
intptr_t
{
return
reinterpret_cast
<
intptr_t
>
(
al
.
getAllBladeForcesYDevice
());
}
)
.
def
(
"get_all_blade_forces_z_device"
,
[](
ActuatorFarm
&
al
)
->
intptr_t
{
return
reinterpret_cast
<
intptr_t
>
(
al
.
getAllBladeForcesZDevice
());
}
)
.
def
(
"get_all_blade_radii_device"
,
[](
ActuatorFarm
&
al
)
->
intptr_t
{
return
arr_to_cp
(
al
.
getAllBladeRadiiDevice
());
}
)
.
def
(
"get_all_blade_coords_x_device"
,
[](
ActuatorFarm
&
al
)
->
intptr_t
{
return
arr_to_cp
(
al
.
getAllBladeCoordsXDevice
());
}
)
.
def
(
"get_all_blade_coords_y_device"
,
[](
ActuatorFarm
&
al
)
->
intptr_t
{
return
arr_to_cp
(
al
.
getAllBladeCoordsYDevice
());
}
)
.
def
(
"get_all_blade_coords_z_device"
,
[](
ActuatorFarm
&
al
)
->
intptr_t
{
return
arr_to_cp
(
al
.
getAllBladeCoordsZDevice
());
}
)
.
def
(
"get_all_blade_velocities_x_device"
,
[](
ActuatorFarm
&
al
)
->
intptr_t
{
return
arr_to_cp
(
al
.
getAllBladeVelocitiesXDevice
());
}
)
.
def
(
"get_all_blade_velocities_y_device"
,
[](
ActuatorFarm
&
al
)
->
intptr_t
{
return
arr_to_cp
(
al
.
getAllBladeVelocitiesYDevice
());
}
)
.
def
(
"get_all_blade_velocities_z_device"
,
[](
ActuatorFarm
&
al
)
->
intptr_t
{
return
arr_to_cp
(
al
.
getAllBladeVelocitiesZDevice
());
}
)
.
def
(
"get_all_blade_forces_x_device"
,
[](
ActuatorFarm
&
al
)
->
intptr_t
{
return
arr_to_cp
(
al
.
getAllBladeForcesXDevice
());
}
)
.
def
(
"get_all_blade_forces_y_device"
,
[](
ActuatorFarm
&
al
)
->
intptr_t
{
return
arr_to_cp
(
al
.
getAllBladeForcesYDevice
());
}
)
.
def
(
"get_all_blade_forces_z_device"
,
[](
ActuatorFarm
&
al
)
->
intptr_t
{
return
arr_to_cp
(
al
.
getAllBladeForcesZDevice
());
}
)
.
def
(
"get_turbine_blade_radii_device"
,
[](
ActuatorFarm
&
al
,
uint
turbine
)
->
intptr_t
{
return
reinterpret_cast
<
intptr_t
>
(
al
.
getTurbineBladeRadiiDevice
(
turbine
));
},
py
::
arg
(
"turbine"
)
)
.
def
(
"get_turbine_blade_coords_x_device"
,
[](
ActuatorFarm
&
al
,
uint
turbine
)
->
intptr_t
{
return
reinterpret_cast
<
intptr_t
>
(
al
.
getTurbineBladeCoordsXDevice
(
turbine
));
},
py
::
arg
(
"turbine"
)
)
.
def
(
"get_turbine_blade_coords_y_device"
,
[](
ActuatorFarm
&
al
,
uint
turbine
)
->
intptr_t
{
return
reinterpret_cast
<
intptr_t
>
(
al
.
getTurbineBladeCoordsYDevice
(
turbine
));
},
py
::
arg
(
"turbine"
)
)
.
def
(
"get_turbine_blade_coords_z_device"
,
[](
ActuatorFarm
&
al
,
uint
turbine
)
->
intptr_t
{
return
reinterpret_cast
<
intptr_t
>
(
al
.
getTurbineBladeCoordsZDevice
(
turbine
));
},
py
::
arg
(
"turbine"
)
)
.
def
(
"get_turbine_blade_velocities_x_device"
,
[](
ActuatorFarm
&
al
,
uint
turbine
)
->
intptr_t
{
return
reinterpret_cast
<
intptr_t
>
(
al
.
getTurbineBladeVelocitiesXDevice
(
turbine
));
},
py
::
arg
(
"turbine"
)
)
.
def
(
"get_turbine_blade_velocities_y_device"
,
[](
ActuatorFarm
&
al
,
uint
turbine
)
->
intptr_t
{
return
reinterpret_cast
<
intptr_t
>
(
al
.
getTurbineBladeVelocitiesYDevice
(
turbine
));
},
py
::
arg
(
"turbine"
)
)
.
def
(
"get_turbine_blade_velocities_z_device"
,
[](
ActuatorFarm
&
al
,
uint
turbine
)
->
intptr_t
{
return
reinterpret_cast
<
intptr_t
>
(
al
.
getTurbineBladeVelocitiesZDevice
(
turbine
));
},
py
::
arg
(
"turbine"
)
)
.
def
(
"get_turbine_blade_forces_x_device"
,
[](
ActuatorFarm
&
al
,
uint
turbine
)
->
intptr_t
{
return
reinterpret_cast
<
intptr_t
>
(
al
.
getTurbineBladeForcesXDevice
(
turbine
));
},
py
::
arg
(
"turbine"
)
)
.
def
(
"get_turbine_blade_forces_y_device"
,
[](
ActuatorFarm
&
al
,
uint
turbine
)
->
intptr_t
{
return
reinterpret_cast
<
intptr_t
>
(
al
.
getTurbineBladeForcesYDevice
(
turbine
));
},
py
::
arg
(
"turbine"
)
)
.
def
(
"get_turbine_blade_forces_z_device"
,
[](
ActuatorFarm
&
al
,
uint
turbine
)
->
intptr_t
{
return
reinterpret_cast
<
intptr_t
>
(
al
.
getTurbineBladeForcesZDevice
(
turbine
));
},
py
::
arg
(
"turbine"
)
)
.
def
(
"get_turbine_blade_radii_device"
,
[](
ActuatorFarm
&
al
,
uint
turbine
)
->
intptr_t
{
return
arr_to_cp
(
al
.
getTurbineBladeRadiiDevice
(
turbine
));
},
py
::
arg
(
"turbine"
)
)
.
def
(
"get_turbine_blade_coords_x_device"
,
[](
ActuatorFarm
&
al
,
uint
turbine
)
->
intptr_t
{
return
arr_to_cp
(
al
.
getTurbineBladeCoordsXDevice
(
turbine
));
},
py
::
arg
(
"turbine"
)
)
.
def
(
"get_turbine_blade_coords_y_device"
,
[](
ActuatorFarm
&
al
,
uint
turbine
)
->
intptr_t
{
return
arr_to_cp
(
al
.
getTurbineBladeCoordsYDevice
(
turbine
));
},
py
::
arg
(
"turbine"
)
)
.
def
(
"get_turbine_blade_coords_z_device"
,
[](
ActuatorFarm
&
al
,
uint
turbine
)
->
intptr_t
{
return
arr_to_cp
(
al
.
getTurbineBladeCoordsZDevice
(
turbine
));
},
py
::
arg
(
"turbine"
)
)
.
def
(
"get_turbine_blade_velocities_x_device"
,
[](
ActuatorFarm
&
al
,
uint
turbine
)
->
intptr_t
{
return
arr_to_cp
(
al
.
getTurbineBladeVelocitiesXDevice
(
turbine
));
},
py
::
arg
(
"turbine"
)
)
.
def
(
"get_turbine_blade_velocities_y_device"
,
[](
ActuatorFarm
&
al
,
uint
turbine
)
->
intptr_t
{
return
arr_to_cp
(
al
.
getTurbineBladeVelocitiesYDevice
(
turbine
));
},
py
::
arg
(
"turbine"
)
)
.
def
(
"get_turbine_blade_velocities_z_device"
,
[](
ActuatorFarm
&
al
,
uint
turbine
)
->
intptr_t
{
return
arr_to_cp
(
al
.
getTurbineBladeVelocitiesZDevice
(
turbine
));
},
py
::
arg
(
"turbine"
)
)
.
def
(
"get_turbine_blade_forces_x_device"
,
[](
ActuatorFarm
&
al
,
uint
turbine
)
->
intptr_t
{
return
arr_to_cp
(
al
.
getTurbineBladeForcesXDevice
(
turbine
));
},
py
::
arg
(
"turbine"
)
)
.
def
(
"get_turbine_blade_forces_y_device"
,
[](
ActuatorFarm
&
al
,
uint
turbine
)
->
intptr_t
{
return
arr_to_cp
(
al
.
getTurbineBladeForcesYDevice
(
turbine
));
},
py
::
arg
(
"turbine"
)
)
.
def
(
"get_turbine_blade_forces_z_device"
,
[](
ActuatorFarm
&
al
,
uint
turbine
)
->
intptr_t
{
return
arr_to_cp
(
al
.
getTurbineBladeForcesZDevice
(
turbine
));
},
py
::
arg
(
"turbine"
)
)
.
def
(
"set_all_azimuths"
,
[](
ActuatorFarm
&
al
,
arr
azimuths
){
al
.
setAllAzimuths
(
static_cast
<
float
*>
(
azimuths
.
request
().
ptr
));
},
py
::
arg
(
"azimuths"
))
.
def
(
"set_all_yaws"
,
[](
ActuatorFarm
&
al
,
arr
yaws
){
al
.
setAllYaws
(
static_cast
<
float
*>
(
yaws
.
request
().
ptr
));
},
py
::
arg
(
"yaws"
))
.
def
(
"set_all_omegas"
,
[](
ActuatorFarm
&
al
,
arr
omegas
){
al
.
setAllOmegas
(
static_cast
<
float
*>
(
omegas
.
request
().
ptr
));
},
py
::
arg
(
"omegas"
))
.
def
(
"set_all_azimuths"
,
[](
ActuatorFarm
&
al
,
arr
azimuths
){
al
.
setAllAzimuths
(
np_to_arr
(
azimuths
));
},
py
::
arg
(
"azimuths"
))
.
def
(
"set_all_yaws"
,
[](
ActuatorFarm
&
al
,
arr
yaws
){
al
.
setAllYaws
(
np_to_arr
(
yaws
));
},
py
::
arg
(
"yaws"
))
.
def
(
"set_all_omegas"
,
[](
ActuatorFarm
&
al
,
arr
omegas
){
al
.
setAllOmegas
(
np_to_arr
(
omegas
));
},
py
::
arg
(
"omegas"
))
.
def
(
"set_turbine_azimuth"
,
&
ActuatorFarm
::
setTurbineAzimuth
,
py
::
arg
(
"turbine"
),
py
::
arg
(
"azimuth"
))
.
def
(
"set_turbine_yaw"
,
&
ActuatorFarm
::
setTurbineYaw
,
py
::
arg
(
"turbine"
),
py
::
arg
(
"yaw"
))
...
...
@@ -144,27 +152,27 @@ namespace actuator_farm
.
def
(
"set_all_blade_coords"
,
[](
ActuatorFarm
&
al
,
arr
coordsX
,
arr
coordsY
,
arr
coordsZ
)
{
al
.
setAllBladeCoords
(
static_cast
<
float
*>
(
coordsX
.
request
().
ptr
),
static_cast
<
float
*>
(
coordsY
.
request
().
ptr
),
static_cast
<
float
*>
(
coordsZ
.
request
().
ptr
));
al
.
setAllBladeCoords
(
np_to_arr
(
coordsX
),
np_to_arr
(
coordsY
),
np_to_arr
(
coordsZ
));
},
py
::
arg
(
"blade_coords_x"
),
py
::
arg
(
"blade_coords_y"
),
py
::
arg
(
"blade_coords_z"
)
)
.
def
(
"set_all_blade_velocities"
,
[](
ActuatorFarm
&
al
,
arr
velocitiesX
,
arr
velocitiesY
,
arr
velocitiesZ
)
{
al
.
setAllBladeVelocities
(
static_cast
<
float
*>
(
velocitiesX
.
request
().
ptr
),
static_cast
<
float
*>
(
velocitiesY
.
request
().
ptr
),
static_cast
<
float
*>
(
velocitiesZ
.
request
().
ptr
));
al
.
setAllBladeVelocities
(
np_to_arr
(
velocitiesX
),
np_to_arr
(
velocitiesY
),
np_to_arr
(
velocitiesZ
));
},
py
::
arg
(
"blade_velocities_x"
),
py
::
arg
(
"blade_velocities_y"
),
py
::
arg
(
"blade_velocities_z"
)
)
.
def
(
"set_all_blade_forces"
,
[](
ActuatorFarm
&
al
,
arr
forcesX
,
arr
forcesY
,
arr
forcesZ
)
{
al
.
setAllBladeForces
(
static_cast
<
float
*>
(
forcesX
.
request
().
ptr
),
static_cast
<
float
*>
(
forcesY
.
request
().
ptr
),
static_cast
<
float
*>
(
forcesZ
.
request
().
ptr
));
al
.
setAllBladeForces
(
np_to_arr
(
forcesX
),
np_to_arr
(
forcesY
),
np_to_arr
(
forcesZ
));
},
py
::
arg
(
"blade_forces_x"
),
py
::
arg
(
"blade_forces_y"
),
py
::
arg
(
"blade_forces_z"
)
)
.
def
(
"set_turbine_blade_coords"
,
[](
ActuatorFarm
&
al
,
uint
turbine
,
arr
coordsX
,
arr
coordsY
,
arr
coordsZ
)
{
al
.
setTurbineBladeCoords
(
turbine
,
static_cast
<
float
*>
(
coordsX
.
request
().
ptr
),
static_cast
<
float
*>
(
coordsY
.
request
().
ptr
),
static_cast
<
float
*>
(
coordsZ
.
request
().
ptr
));
al
.
setTurbineBladeCoords
(
turbine
,
np_to_arr
(
coordsX
),
np_to_arr
(
coordsY
),
np_to_arr
(
coordsZ
));
},
py
::
arg
(
"turbine"
),
py
::
arg
(
"blade_coords_x"
),
py
::
arg
(
"blade_coords_y"
),
py
::
arg
(
"blade_coords_z"
)
)
.
def
(
"set_turbine_blade_velocities"
,
[](
ActuatorFarm
&
al
,
uint
turbine
,
arr
velocitiesX
,
arr
velocitiesY
,
arr
velocitiesZ
)
{
al
.
setTurbineBladeVelocities
(
turbine
,
static_cast
<
float
*>
(
velocitiesX
.
request
().
ptr
),
static_cast
<
float
*>
(
velocitiesY
.
request
().
ptr
),
static_cast
<
float
*>
(
velocitiesZ
.
request
().
ptr
));
al
.
setTurbineBladeVelocities
(
turbine
,
np_to_arr
(
velocitiesX
),
np_to_arr
(
velocitiesY
),
np_to_arr
(
velocitiesZ
));
},
py
::
arg
(
"turbine"
),
py
::
arg
(
"blade_velocities_x"
),
py
::
arg
(
"blade_velocities_y"
),
py
::
arg
(
"blade_velocities_z"
)
)
.
def
(
"set_turbine_blade_forces"
,
[](
ActuatorFarm
&
al
,
uint
turbine
,
arr
forcesX
,
arr
forcesY
,
arr
forcesZ
)
{
al
.
setTurbineBladeForces
(
turbine
,
static_cast
<
float
*>
(
forcesX
.
request
().
ptr
),
static_cast
<
float
*>
(
forcesY
.
request
().
ptr
),
static_cast
<
float
*>
(
forcesZ
.
request
().
ptr
));
al
.
setTurbineBladeForces
(
turbine
,
np_to_arr
(
forcesX
),
np_to_arr
(
forcesY
),
np_to_arr
(
forcesZ
));
},
py
::
arg
(
"turbine"
),
py
::
arg
(
"blade_forces_x"
),
py
::
arg
(
"blade_forces_y"
),
py
::
arg
(
"blade_forces_z"
)
)
.
def
(
"calc_blade_forces"
,
&
ActuatorFarm
::
calcBladeForces
);
}
...
...
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