Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions modmesh/app/euler1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,8 @@ def set_solver_config(self):
self.interval = self.solver_config.get_var("timer_interval", "value")
self.max_steps = self.solver_config.get_var("max_steps", "value")
self.profiling = self.solver_config.get_var("profiling", "value")
ncoord = self.solver_config.get_var("ncoord", "value")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@j8xixo12 With this PR I realized that self.solver_config.get_var() is too wordy. The lengthy API makes it hard to quickly write and understand code.

Please propose a new design of SolverConfig and PlotConfig in the discussions. We can probably consider __getattr__() or __getitem__()


@Gene0315 please provide an option to keep existing behavior.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Gene0315 You can use the inline comment for focused discussions.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@j8xixo12 Any comments?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I will create a discussion and propose a new design in the discussion.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I will create a discussion and propose a new design in the discussion.

Thanks, @j8xixo12 . Maybe creating an issue describing what we know and may be done can help.

self.plot_point = np.linspace(2, (ncoord - 3), num=((ncoord - 3) // 2), dtype=int)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A convention of short-living temporary variables is _. The two lines can be changed to:

_ = self.solver_config.get_var("ncoord", "value")
self.xindices = np.linspace(2, (_ - 3), num=((_ - 3) // 2), dtype=int)

plot_point is not a good attribute name because the content is not points but indices of the coordinate (1D point) arrays.


def setup_timer(self):
"""
Expand All @@ -530,7 +532,7 @@ def build_grid_figure(self):

:return: FigureCanvas
"""
x = self.st.svr.coord[::2]
x = self.st.svr.coord[self.plot_point]
fig = Figure()
canvas = FigureCanvas(fig)
ax = canvas.figure.subplots(3, 2)
Expand Down Expand Up @@ -574,7 +576,7 @@ def build_single_figure(self):

:return: FigureCanvas
"""
x = self.st.svr.coord[::2]
x = self.st.svr.coord[self.plot_point]
fig = Figure()
canvas = FigureCanvas(fig)
ax = canvas.figure.subplots()
Expand Down Expand Up @@ -744,23 +746,23 @@ def update_lines(self):
"""
if self.use_grid_layout:
self.density.update(adata=self.st.density_field,
ndata=self.st.svr.density[::2])
ndata=self.st.svr.density[self.plot_point])
self.pressure.update(adata=self.st.pressure_field,
ndata=self.st.svr.pressure[::2])
ndata=self.st.svr.pressure[self.plot_point])
self.velocity.update(adata=self.st.velocity_field,
ndata=self.st.svr.velocity[::2])
ndata=self.st.svr.velocity[self.plot_point])
self.temperature.update(adata=self.st.temperature_field,
ndata=self.st.svr.temperature[::2])
ndata=self.st.svr.temperature[self.plot_point])
self.internal_energy.update(adata=(self.st.internal_energy_field),
ndata=(self.st.svr.
internal_energy[::2]))
internal_energy[self.plot_point]))
self.entropy.update(adata=self.st.entropy_field,
ndata=self.st.svr.entropy[::2])
ndata=self.st.svr.entropy[self.plot_point])
else:
for name, is_selected, *_ in self.plot_config.state:
if is_selected:
eval(f'(self.{name}.update(adata=self.st.{name}_field,'
f' ndata=self.st.svr.{name}[::2]))')
f' ndata=self.st.svr.{name}[self.plot_point]))')


class PlotArea(PuiInQt):
Expand Down
3 changes: 2 additions & 1 deletion modmesh/onedim/euler1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,8 @@ def build_field(self, t, coord=None):
:return: None
"""
if None is coord:
coord = self.svr.coord[::2] # Use the numerical solver.
plot_point = np.linspace(2, (self.svr.ncoord - 3), num=((self.svr.ncoord - 3) // 2), dtype=int)
coord = self.svr.coord[plot_point] # Use the numerical solver.
self.coord = coord.copy() # Make a copy; no write back to argument.

# Determine the zone location and the Boolean selection arrays.
Expand Down