2
2
from dolfinx .plot import vtk_mesh as compute_topology
3
3
import matplotlib .tri as tri
4
4
import matplotlib .pyplot as plt
5
- from pyvista .plotting .utilities import xvfbimport pyvista
5
+ from pyvista .plotting .utilities import xvfb
6
+ import pyvista
6
7
from mpi4py import MPI
7
8
import logging
8
9
import sys
24
25
# Start Xvfb for PyVista (for offscreen rendering)
25
26
# xvfb.start_xvfb(wait=0.05)
26
27
28
+
27
29
def plot_vector (u , plotter , subplot = None , scale = 1.0 ):
28
30
"""
29
31
Plots a vector field using PyVista with glyph representation.
@@ -64,6 +66,7 @@ def plot_vector(u, plotter, subplot=None, scale=1.0):
64
66
plotter .set_background ("white" )
65
67
return plotter
66
68
69
+
67
70
def plot_scalar (u , plotter , subplot = None , lineproperties = {}):
68
71
"""
69
72
Plots a scalar field using PyVista.
@@ -98,7 +101,17 @@ def plot_scalar(u, plotter, subplot=None, lineproperties={}):
98
101
plotter .set_background ("white" )
99
102
return plotter
100
103
101
- def plot_profile (u , points , plotter , subplot = None , lineproperties = {}, fig = None , ax = None , subplotnumber = 1 ):
104
+
105
+ def plot_profile (
106
+ u ,
107
+ points ,
108
+ plotter ,
109
+ subplot = None ,
110
+ lineproperties = {},
111
+ fig = None ,
112
+ ax = None ,
113
+ subplotnumber = 1 ,
114
+ ):
102
115
"""
103
116
Plots a profile of the solution at given points.
104
117
@@ -131,6 +144,7 @@ def plot_profile(u, points, plotter, subplot=None, lineproperties={}, fig=None,
131
144
plt .legend ()
132
145
return plt , (points_on_proc [:, 0 ], u_values )
133
146
147
+
134
148
def plot_mesh (mesh , ax = None ):
135
149
"""
136
150
Plots the mesh using Matplotlib.
@@ -151,6 +165,7 @@ def plot_mesh(mesh, ax=None):
151
165
ax .triplot (tria , color = "k" )
152
166
return ax
153
167
168
+
154
169
def get_datapoints (u , points ):
155
170
"""
156
171
Retrieves data points for a given solution field evaluated at specific points.
@@ -182,6 +197,7 @@ def get_datapoints(u, points):
182
197
183
198
return points_on_proc , u_values
184
199
200
+
185
201
def plot_perturbations (comm , Lx , prefix , β , v , bifurcation , stability , i_t ):
186
202
"""
187
203
Plots the perturbations using PyVista.
@@ -249,6 +265,7 @@ def plot_perturbations(comm, Lx, prefix, β, v, bifurcation, stability, i_t):
249
265
250
266
return plotter
251
267
268
+
252
269
def plot_matrix (M ):
253
270
"""
254
271
Plots the matrix as a heatmap using Matplotlib.
@@ -269,4 +286,4 @@ def plot_matrix(M):
269
286
c = _M [j , i ]
270
287
ax .text (i , j , f"{ c :.3f} " , va = "center" , ha = "center" )
271
288
272
- return fig
289
+ return fig
0 commit comments