Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7ffb063

Browse files
CUDA Open ACC V2 no execution
1 parent 4cde649 commit 7ffb063

File tree

3 files changed

+104
-0
lines changed

3 files changed

+104
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CC=gcc
2+
CFLAGS=-O2 -lm -Wall
3+
OBJ=partis_seq
4+
5+
all:
6+
$(CC) $(OBJ).c -o $(OBJ) $(CFLAGS)
7+
8+
clean:
9+
rm $(OBJ)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
#SBATCH --job-name=ex1
4+
#SBATCH -p std
5+
#SBATCH --output=out_seq_%j.out
6+
#SBATCH --error=out_seq_%j.err
7+
#SBATCH --cpus-per-task=1
8+
#SBATCH --ntasks=1
9+
#SBATCH --nodes=1
10+
#SBATCH --time=00:05:00
11+
12+
### module load conda
13+
### conda create -n image_plotter
14+
### conda activate image_plotter
15+
### conda install matplotlib opencv
16+
### python plot.py
17+
18+
make >> make.out || exit 1
19+
20+
./partis_seq 50000 0
21+
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
from pathlib import Path
2+
import numpy as np
3+
import matplotlib.pyplot as plt
4+
import cv2
5+
6+
# Define cone parameters
7+
height = 2.5e-1
8+
radius = np.tan(np.pi / 6) * height
9+
num_points = 30 # Resolution of the cone
10+
11+
# mesh grid in polar coordinates
12+
theta = np.linspace(0, 2 * np.pi, num_points)
13+
z_cone = np.linspace(0, -height, num_points)
14+
theta, z_cone = np.meshgrid(theta, z_cone)
15+
16+
# Convert to Cartesian coordinates
17+
r = radius * z_cone / height # Linear increase of radius
18+
x_cone = r * np.cos(theta)
19+
y_cone = r * np.sin(theta)
20+
21+
# Create a VideoWriter object
22+
video_dir = Path("./video")
23+
video_dir.mkdir(exist_ok=True)
24+
25+
video_filename = video_dir.joinpath("video.mp4")
26+
frame_size = (640, 480)
27+
fps = 2
28+
fourcc = cv2.VideoWriter_fourcc(*"mp4v")
29+
out = cv2.VideoWriter(str(video_filename), fourcc, fps, frame_size)
30+
31+
for i, file in enumerate(sorted(Path(".").glob("out/*.csv"))):
32+
data = np.loadtxt(file, float, delimiter=",", skiprows=1)
33+
x = data[:, 0]
34+
y = data[:, 1]
35+
z = data[:, 2]
36+
37+
fig = plt.figure(figsize=(6, 6))
38+
ax = fig.add_subplot(projection="3d")
39+
fig.patch.set_alpha(0)
40+
41+
ax.plot_surface(x_cone, y_cone, z_cone, alpha=0.3)
42+
43+
# Axis
44+
ax.plot(
45+
[0, radius * 1.1], [0, 0], [0, 0], "b", linewidth=2, label="X-axis"
46+
) # X-axis
47+
ax.plot(
48+
[0, 0], [0, radius * 1.1], [0, 0], "g", linewidth=2, label="Y-axis"
49+
) # Y-axis
50+
ax.plot(
51+
[0, 0], [0, 0], [0, -height / 2], "r", linewidth=2, label="Z-axis"
52+
) # Z-axis
53+
54+
ax.set_xlabel("X-axis")
55+
ax.set_ylabel("Y-axis")
56+
ax.set_zlabel("Z-axis")
57+
58+
ax.scatter(x, y, z, c="b", marker="o")
59+
ax.set_xlim([-radius*1.2, radius*1.2])
60+
ax.set_ylim([-radius*1.2, radius*1.2])
61+
ax.set_zlim([-height*1.2, 0])
62+
63+
image_path = video_dir.joinpath(f"frame_{i}.png")
64+
plt.savefig(image_path)
65+
plt.close()
66+
67+
frame = cv2.imread(image_path) # Read the frame/image
68+
frame_resized = cv2.resize(
69+
frame, frame_size
70+
) # Resize to match the video resolution
71+
out.write(frame_resized) # Write the frame to the video
72+
73+
out.release()
74+
#cv2.destroyAllWindows()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /