Skip to content
Merged
Changes from all commits
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
21 changes: 20 additions & 1 deletion pygem/ffd.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
except ImportError:
import ConfigParser as configparser
import os
import copy
import numpy as np
from scipy import special

Expand Down Expand Up @@ -477,7 +478,7 @@ def control_points(self, deformed=True):

return box_points.T

def reflect(self, axis=0):
def reflect(self, axis=0, in_place=True):
"""
Reflect the lattice of control points along the direction defined
by `axis`. In particular the origin point of the lattice is preserved.
Expand All @@ -492,6 +493,17 @@ def reflect(self, axis=0):
:param int axis: axis along which the reflection is performed.
Default is 0. Possible values are 0, 1, or 2, corresponding
to x, y, and z respectively.
:param bool in_place: if True, the object attributes are modified in
place; if False, a new object is return with the reflected lattice.
Default is True.
:return: a new object with the same parameters and the reflected
lattice if `in_place` is False, otherwise NoneType.

:Example:

>>> ffd.reflect(axis=0, in_place=True) # irreversible
>>> # or ...
>>> refle_ffd = ffd.reflect(axis=0, in_place=False)
"""
# check axis value
if axis not in (0, 1, 2):
Expand All @@ -508,6 +520,9 @@ def reflect(self, axis=0):
"points in the symmetry plane along that axis."
)

if in_place is False:
self = copy.deepcopy(self)

# double the control points in the given axis -1 (the symmetry plane)
self.n_control_points[axis] = 2 * self.n_control_points[axis] - 1
# double the box length
Expand Down Expand Up @@ -536,6 +551,10 @@ def reflect(self, axis=0):
reflection[2] *
np.flip(self.array_mu_z, axis)[indeces],
axis=axis)
if in_place is False:
return self



def __call__(self, src_pts):
"""
Expand Down