-
Notifications
You must be signed in to change notification settings - Fork 59
Hide boundary points in figure #391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
f30cb6d
059272a
bae5f8e
ff4fac0
e2de8d0
0936eb9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -302,16 +302,27 @@ def calc_internal_energy(self, pressure, density): | |||||||||||
| def calc_entropy(self, pressure, density): | ||||||||||||
| return pressure / (density ** self.gamma) | ||||||||||||
|
|
||||||||||||
| def build_field(self, t, coord=None): | ||||||||||||
| def build_field(self, t, coord=None, keep_edge=False): | ||||||||||||
| """ | ||||||||||||
| Populate the field data using the analytical solution. | ||||||||||||
|
|
||||||||||||
| :param t: | ||||||||||||
| :param coord: If None, take the coordinate from the numerical solver. | ||||||||||||
| :return: None | ||||||||||||
| """ | ||||||||||||
|
|
||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This insertion of a blank line is not necessary. Do you introduce unnecessary/unrelated change of blank lines and whitespaces in a patch (i.e., checkins/PR). |
||||||||||||
| if None is coord: | ||||||||||||
| coord = self.svr.coord[::2] # Use the numerical solver. | ||||||||||||
| _ = self.svr.ncoord | ||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This 9 lines of code is mouthy. Please use the follow code instead (please make proper adjustment if needed because I didn't test it myself): _ = self.svr.ncoord
start = 0 if keep_edge else 2
stop = _ - stop - 1
num = # It makes more sense to calculate from start and stop
xindices = np.linspace(start, stop, num=num, dtype='int32') |
||||||||||||
| if keep_edge: | ||||||||||||
| self.svr.xindices = np.linspace( | ||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The modmesh/modmesh/onedim/euler1d.py Line 36 in 214b474
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do not add attributes outside the class. It will be very difficult for a maintainer to keep track of where attributes are added, if they are not created in an organized way.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
@yungyuc I agree that we shouldn't add attributes outside the class, but I failed to create the modmesh/modmesh/onedim/euler1d.py Line 38 in 214b474
I tried to add the xindices in
like m_coord in
but I'm confused how to add it because I cannot decide its size in the begining. Or, maybe I misunderstand what you want me to do? Can you give me some suggestion?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
modmesh/modmesh/onedim/euler1d.py Line 28 in 214b474
The code may be like: def __init__(self, xmin, xmax, ncoord, time_increment=0.05):
self._core = self.init_solver(xmin, xmax, ncoord, time_increment,
gamma=1.4)
self.xindices = ...
# gamma is 1.4 for air.You may consider to let |
||||||||||||
| 0, (_ - 1), num=((_ + 1) // 2), dtype=int | ||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It makes more sense to calculate |
||||||||||||
| ) | ||||||||||||
| else: | ||||||||||||
| self.svr.xindices = np.linspace( | ||||||||||||
| 2, (_ - 3), num=((_ - 3) // 2), dtype=int | ||||||||||||
| ) | ||||||||||||
| # Use the numerical solver. | ||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please be more specific about what you meant. "Use the numerical solver" is not a clear statement. |
||||||||||||
| coord = self.svr.coord[self.svr.xindices] | ||||||||||||
| self.coord = coord.copy() # Make a copy; no write back to argument. | ||||||||||||
|
|
||||||||||||
| # Determine the zone location and the Boolean selection arrays. | ||||||||||||
|
|
||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is redundant file, please remove. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| import modmesh.view as mv | ||
|
|
||
| mv.launch() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -105,7 +105,7 @@ def test_field_without_numerical(self): | |
| def test_field_with_numerical(self): | ||
| self.st.build_numerical(xmin=-1, xmax=1, ncoord=21, | ||
| time_increment=0.05) | ||
| self.st.build_field(t=0.0) | ||
| self.st.build_field(t=0.0, keep_edge=True) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The fix of the unit tests by the addition of the single argument is good. |
||
| self.assertIsInstance(self.st.svr, euler1d.Euler1DSolver) | ||
| self.assertEqual(len(self.st.coord), 11) | ||
| self._check_field_value_at_t0() | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please simplify the code like:
In this way, you do not change the original code by too much. It will be easier to keep track of the change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change of line breaking is not necessary for updating the slicing (from
[::2]to[_s]). Please revert it to the original style.That is, since the original style is:
instead of writing (with the different line breaking):
write
The unnecessary change will baffle future maintainers. Style matters. Don't change the style when changing the logic, and vice versa. Change of logic and that of style should not take place at the same time.