(self, filename='parameters.prm')
This method writes a parameters file (.prm) called `filename` and fills
        it with all the parameters class members.

        :param string filename: parameters file to be written out.
This method writes a parameters file (.prm) called `filename` and fills
        it with all the parameters class members.
This method writes a parameters file ( . prm ) called filename and fills it with all the parameters class members .
def write_parameters(self, filename='parameters.prm'):
        """
        This method writes a parameters file (.prm) called `filename` and fills
        it with all the parameters class members.

        :param string filename: parameters file to be written out.
        """
        if not isinstance(filename, str):
            raise TypeError("filename must be a string")

        output_string = ""
        output_string += '\n[Box info]\n'
        output_string += '# This section collects all the properties of the'
        output_string += ' FFD bounding box.\n'

        output_string += '\n# n control points indicates the number of control'
        output_string += ' points in each direction (x, y, z).\n'
        output_string += '# For example, to create a 2 x 3 x 2 grid, use the'
        output_string += ' following: n control points: 2, 3, 2\n'
        output_string += 'n control points x: ' + str(
            self.n_control_points[0]) + '\n'
        output_string += 'n control points y: ' + str(
            self.n_control_points[1]) + '\n'
        output_string += 'n control points z: ' + str(
            self.n_control_points[2]) + '\n'

        output_string += '\n# box length indicates the length of the FFD '
        output_string += 'bounding box along the three canonical directions '
        output_string += '(x, y, z).\n'

        output_string += '# It uses the local coordinate system.\n'
        output_string += '# For example to create a 2 x 1.5 x 3 meters box '
        output_string += 'use the following: box length: 2.0, 1.5, 3.0\n'

        output_string += 'box length x: ' + str(self.box_length[0]) + '\n'
        output_string += 'box length y: ' + str(self.box_length[1]) + '\n'
        output_string += 'box length z: ' + str(self.box_length[2]) + '\n'

        output_string += '\n# box origin indicates the x, y, and z coordinates '
        output_string += 'of the origin of the FFD bounding box. That is '
        output_string += 'center of\n'

        output_string += '# rotation of the bounding box. It corresponds to '
        output_string += 'the point coordinates with position [0][0][0].\n'

        output_string += '# See section "Parameters weights" for more '
        output_string += 'details.\n'
        output_string += '# For example, if the origin is equal to 0., 0., 0., '
        output_string += 'use the following: box origin: 0., 0., 0.\n'

        output_string += 'box origin x: ' + str(self.box_origin[0]) + '\n'
        output_string += 'box origin y: ' + str(self.box_origin[1]) + '\n'
        output_string += 'box origin z: ' + str(self.box_origin[2]) + '\n'

        output_string += '\n# rotation angle indicates the rotation angle '
        output_string += 'around the x, y, and z axis of the FFD bounding box '
        output_string += 'in degrees.\n'

        output_string += '# The rotation is done with respect to the box '
        output_string += 'origin.\n'
        output_string += '# For example, to rotate the box by 2 deg along '
        output_string += 'the z '
        output_string += 'direction, use the following: rotation angle: '
        output_string += '0., 0., 2.\n'

        output_string += 'rotation angle x: ' + str(self.rot_angle[0]) + '\n'
        output_string += 'rotation angle y: ' + str(self.rot_angle[1]) + '\n'
        output_string += 'rotation angle z: ' + str(self.rot_angle[2]) + '\n'

        output_string += '\n\n[Parameters weights]\n'
        output_string += '# This section describes the weights of the FFD '
        output_string += 'control points.\n'

        output_string += '# We adopt the following convention:\n'
        output_string += '# For example with a 2x2x2 grid of control points we '
        output_string += 'have to fill a 2x2x2 matrix of weights.\n'

        output_string += '# If a weight is equal to zero you can discard the '
        output_string += 'line since the default is zero.\n'

        output_string += '#\n'
        output_string += '# | x index | y index | z index | weight |\n'
        output_string += '#  --------------------------------------\n'
        output_string += '# |    0    |    0    |    0    |  1.0   |\n'
        output_string += '# |    0    |    1    |    1    |  0.0   | --> you '
        output_string += 'can erase this line without effects\n'
        output_string += '# |    0    |    1    |    0    | -2.1   |\n'
        output_string += '# |    0    |    0    |    1    |  3.4   |\n'

        output_string += '\n# parameter x collects the displacements along x, '
        output_string += 'normalized with the box length x.'

        output_string += '\nparameter x:'
        offset = 1
        for i in range(0, self.n_control_points[0]):
            for j in range(0, self.n_control_points[1]):
                for k in range(0, self.n_control_points[2]):
                    output_string += offset * ' ' + str(i) + '   ' + str(
                        j) + '   ' + str(k) + '   ' + str(
                            self.array_mu_x[i][j][k]) + '\n'
                    offset = 13

        output_string += '\n# parameter y collects the displacements along y, '
        output_string += 'normalized with the box length y.'

        output_string += '\nparameter y:'
        offset = 1
        for i in range(0, self.n_control_points[0]):
            for j in range(0, self.n_control_points[1]):
                for k in range(0, self.n_control_points[2]):
                    output_string += offset * ' ' + str(i) + '   ' + str(
                        j) + '   ' + str(k) + '   ' + str(
                            self.array_mu_y[i][j][k]) + '\n'
                    offset = 13

        output_string += '\n# parameter z collects the displacements along z, '
        output_string += 'normalized with the box length z.'

        output_string += '\nparameter z:'
        offset = 1
        for i in range(0, self.n_control_points[0]):
            for j in range(0, self.n_control_points[1]):
                for k in range(0, self.n_control_points[2]):
                    output_string += offset * ' ' + str(i) + '   ' + str(
                        j) + '   ' + str(k) + '   ' + str(
                            self.array_mu_z[i][j][k]) + '\n'
                    offset = 13

        with open(filename, 'w') as f:
            f.write(output_string)
def write_parameters ( self , filename = 'parameters.prm' ) : if not isinstance ( filename , str ) : raise TypeError ( "filename must be a string" ) output_string = "" output_string += '\n[Box info]\n' output_string += '# This section collects all the properties of the' output_string += ' FFD bounding box.\n' output_string += '\n# n control points indicates the number of control' output_string += ' points in each direction (x, y, z).\n' output_string += '# For example, to create a 2 x 3 x 2 grid, use the' output_string += ' following: n control points: 2, 3, 2\n' output_string += 'n control points x: ' + str ( self . n_control_points [ 0 ] ) + '\n' output_string += 'n control points y: ' + str ( self . n_control_points [ 1 ] ) + '\n' output_string += 'n control points z: ' + str ( self . n_control_points [ 2 ] ) + '\n' output_string += '\n# box length indicates the length of the FFD ' output_string += 'bounding box along the three canonical directions ' output_string += '(x, y, z).\n' output_string += '# It uses the local coordinate system.\n' output_string += '# For example to create a 2 x 1.5 x 3 meters box ' output_string += 'use the following: box length: 2.0, 1.5, 3.0\n' output_string += 'box length x: ' + str ( self . box_length [ 0 ] ) + '\n' output_string += 'box length y: ' + str ( self . box_length [ 1 ] ) + '\n' output_string += 'box length z: ' + str ( self . box_length [ 2 ] ) + '\n' output_string += '\n# box origin indicates the x, y, and z coordinates ' output_string += 'of the origin of the FFD bounding box. That is ' output_string += 'center of\n' output_string += '# rotation of the bounding box. It corresponds to ' output_string += 'the point coordinates with position [0][0][0].\n' output_string += '# See section "Parameters weights" for more ' output_string += 'details.\n' output_string += '# For example, if the origin is equal to 0., 0., 0., ' output_string += 'use the following: box origin: 0., 0., 0.\n' output_string += 'box origin x: ' + str ( self . box_origin [ 0 ] ) + '\n' output_string += 'box origin y: ' + str ( self . box_origin [ 1 ] ) + '\n' output_string += 'box origin z: ' + str ( self . box_origin [ 2 ] ) + '\n' output_string += '\n# rotation angle indicates the rotation angle ' output_string += 'around the x, y, and z axis of the FFD bounding box ' output_string += 'in degrees.\n' output_string += '# The rotation is done with respect to the box ' output_string += 'origin.\n' output_string += '# For example, to rotate the box by 2 deg along ' output_string += 'the z ' output_string += 'direction, use the following: rotation angle: ' output_string += '0., 0., 2.\n' output_string += 'rotation angle x: ' + str ( self . rot_angle [ 0 ] ) + '\n' output_string += 'rotation angle y: ' + str ( self . rot_angle [ 1 ] ) + '\n' output_string += 'rotation angle z: ' + str ( self . rot_angle [ 2 ] ) + '\n' output_string += '\n\n[Parameters weights]\n' output_string += '# This section describes the weights of the FFD ' output_string += 'control points.\n' output_string += '# We adopt the following convention:\n' output_string += '# For example with a 2x2x2 grid of control points we ' output_string += 'have to fill a 2x2x2 matrix of weights.\n' output_string += '# If a weight is equal to zero you can discard the ' output_string += 'line since the default is zero.\n' output_string += '#\n' output_string += '# | x index | y index | z index | weight |\n' output_string += '#  --------------------------------------\n' output_string += '# |    0    |    0    |    0    |  1.0   |\n' output_string += '# |    0    |    1    |    1    |  0.0   | --> you ' output_string += 'can erase this line without effects\n' output_string += '# |    0    |    1    |    0    | -2.1   |\n' output_string += '# |    0    |    0    |    1    |  3.4   |\n' output_string += '\n# parameter x collects the displacements along x, ' output_string += 'normalized with the box length x.' output_string += '\nparameter x:' offset = 1 for i in range ( 0 , self . n_control_points [ 0 ] ) : for j in range ( 0 , self . n_control_points [ 1 ] ) : for k in range ( 0 , self . n_control_points [ 2 ] ) : output_string += offset * ' ' + str ( i ) + '   ' + str ( j ) + '   ' + str ( k ) + '   ' + str ( self . array_mu_x [ i ] [ j ] [ k ] ) + '\n' offset = 13 output_string += '\n# parameter y collects the displacements along y, ' output_string += 'normalized with the box length y.' output_string += '\nparameter y:' offset = 1 for i in range ( 0 , self . n_control_points [ 0 ] ) : for j in range ( 0 , self . n_control_points [ 1 ] ) : for k in range ( 0 , self . n_control_points [ 2 ] ) : output_string += offset * ' ' + str ( i ) + '   ' + str ( j ) + '   ' + str ( k ) + '   ' + str ( self . array_mu_y [ i ] [ j ] [ k ] ) + '\n' offset = 13 output_string += '\n# parameter z collects the displacements along z, ' output_string += 'normalized with the box length z.' output_string += '\nparameter z:' offset = 1 for i in range ( 0 , self . n_control_points [ 0 ] ) : for j in range ( 0 , self . n_control_points [ 1 ] ) : for k in range ( 0 , self . n_control_points [ 2 ] ) : output_string += offset * ' ' + str ( i ) + '   ' + str ( j ) + '   ' + str ( k ) + '   ' + str ( self . array_mu_z [ i ] [ j ] [ k ] ) + '\n' offset = 13 with open ( filename , 'w' ) as f : f . write ( output_string )