Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F80612206
multicomponents_3d.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Sep 1, 16:14
Size
686 B
Mime Type
text/x-python
Expires
Tue, Sep 3, 16:14 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
20404544
Attached To
rUVW UVW
multicomponents_3d.py
View Options
import
numpy
as
np
from
uvw
import
RectilinearGrid
,
DataArray
# Creating coordinates
x
=
np
.
linspace
(
-
0.5
,
0.5
,
10
)
y
=
np
.
linspace
(
-
0.5
,
0.5
,
20
)
z
=
np
.
linspace
(
-
0.9
,
0.9
,
30
)
# Creating the file
grid
=
RectilinearGrid
(
'grid.vtr'
,
(
x
,
y
,
z
))
# A centered ball
x
,
y
,
z
=
np
.
meshgrid
(
x
,
y
,
z
,
indexing
=
'ij'
)
r
=
np
.
sqrt
(
x
**
2
+
y
**
2
+
z
**
2
)
ball
=
r
<
0.3
# Some multi-component multi-dimensional data
data
=
np
.
zeros
([
10
,
20
,
30
,
3
,
3
])
data
[
ball
,
...
]
=
np
.
array
([[
0
,
1
,
0
],
[
1
,
0
,
0
],
[
0
,
1
,
1
]])
# Adding the point data (see help(DataArray) for more info)
grid
.
addPointData
(
DataArray
(
data
,
range
(
3
),
'data'
))
grid
.
write
()
Event Timeline
Log In to Comment