Skip to content

Commit

Permalink
gli: fix add_polyline bug for given IDs and add swap_axis; msh: add s…
Browse files Browse the repository at this point in the history
…wap_axis
  • Loading branch information
MuellerSeb committed Jul 5, 2019
1 parent d45d168 commit 3ec23af
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 1 deletion.
38 changes: 37 additions & 1 deletion ogs5py/fileclasses/gli/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,42 @@ def check(self, verbose=True):
"""
return check_gli_dict(self.__dict, verbose=verbose)

def swap_axis(self, axis1="y", axis2="z"):
"""
Swap axis of the coordinate system
Parameters
----------
axis1 : :class:`str` or :class:`int`, optional
First selected Axis.
Either in ["x", "y", "z"] or in [0, 1, 2]. Default: "y"
axis2 : :class:`str` or :class:`int`, optional
Second selected Axis.
Either in ["x", "y", "z"] or in [0, 1, 2]. Default: "z"
"""
axis = ["x", "y", "z"]
if axis1 in range(3):
axis1 = axis[axis1]
if axis2 in range(3):
axis2 = axis[axis2]
if axis1 not in axis or axis2 not in axis:
raise ValueError(
"GLI.swap_axis: axis need to be 'x', 'y' or 'z': "
+ str(axis1)
+ ", "
+ str(axis2)
)
if axis1 == axis2:
raise ValueError(
"GLI.swap_axis: please select distict axis: "
+ str(axis1)
+ " = "
+ str(axis2)
)
ax1 = axis.index(axis1)
ax2 = axis.index(axis2)
self.POINTS[:, [ax1, ax2]] = self.POINTS[:, [ax2, ax1]]

def rotate(
self,
angle,
Expand Down Expand Up @@ -616,7 +652,7 @@ def add_polyline(
"POINT_VECTOR": point_vector,
}
# add by name
if (
elif (
is_str_array(points)
and points.ndim == 1
and points.shape[0] >= 2
Expand Down
36 changes: 36 additions & 0 deletions ogs5py/fileclasses/msh/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,42 @@ def check(self, verbose=True):
"""
return check_mesh_list(self._meshlist, verbose=verbose)

def swap_axis(self, axis1="y", axis2="z"):
"""
Swap axis of the coordinate system
Parameters
----------
axis1 : :class:`str` or :class:`int`, optional
First selected Axis.
Either in ["x", "y", "z"] or in [0, 1, 2]. Default: "y"
axis2 : :class:`str` or :class:`int`, optional
Second selected Axis.
Either in ["x", "y", "z"] or in [0, 1, 2]. Default: "z"
"""
axis = ["x", "y", "z"]
if axis1 in range(3):
axis1 = axis[axis1]
if axis2 in range(3):
axis2 = axis[axis2]
if axis1 not in axis or axis2 not in axis:
raise ValueError(
"MSH.swap_axis: axis need to be 'x', 'y' or 'z': "
+ str(axis1)
+ ", "
+ str(axis2)
)
if axis1 == axis2:
raise ValueError(
"MSH.swap_axis: please select distict axis: "
+ str(axis1)
+ " = "
+ str(axis2)
)
ax1 = axis.index(axis1)
ax2 = axis.index(axis2)
self.NODES[:, [ax1, ax2]] = self.NODES[:, [ax2, ax1]]

def rotate(
self,
angle,
Expand Down

0 comments on commit 3ec23af

Please sign in to comment.