Beispiel #1
0
    def setup(self):
        self.surface = surface = self.options['surface']

        mesh = surface['mesh']
        nx = self.nx = mesh.shape[0]
        ny = self.ny = mesh.shape[1]

        self.add_input('mesh', val=np.ones((self.nx, self.ny, 3)), units='m')
        self.add_input('disp', val=np.ones((self.ny, 6)), units='m')
        self.add_input('transformation_matrix', val=np.ones((self.ny, 3, 3)))
        self.add_input('nodes', val=np.ones((self.ny, 3)), units='m')

        self.add_output('def_mesh',
                        val=np.random.random_sample((self.nx, self.ny, 3)),
                        units='m')

        # Create index arrays for each relevant input and output.
        # This allows us to set up the rows and cols for the sparse Jacobians.
        disp_indices = get_array_indices(self.ny, 6)
        nodes_indices = get_array_indices(self.ny, 3)
        mesh_indices = get_array_indices(self.nx, self.ny, 3)
        transform_indices = get_array_indices(self.ny, 3, 3)
        mesh_disp_indices = get_array_indices(self.nx, self.ny, 3)

        # Set up the rows and cols for `def_mesh` wrt `disp`
        rows = mesh_disp_indices.flatten()
        cols = np.einsum('i,jk->ijk', np.ones(self.nx),
                         disp_indices[:, :3]).flatten()
        self.declare_partials('def_mesh', 'disp', val=1., rows=rows, cols=cols)

        # Set up the rows and cols for `def_mesh` wrt `nodes`
        rows = np.einsum('ijk,l->ijkl', mesh_disp_indices,
                         np.ones(3, int)).flatten()
        cols = np.einsum('ik,jl->ijkl', np.ones((self.nx, 3), int),
                         nodes_indices).flatten()
        self.declare_partials('def_mesh', 'nodes', rows=rows, cols=cols)

        # Set up the rows and cols for `def_mesh` wrt `mesh`
        rows = np.einsum('ijk,l->ijkl', mesh_disp_indices,
                         np.ones(3, int)).flatten()
        cols = np.einsum('ijl,k->ijkl', mesh_indices, np.ones(3,
                                                              int)).flatten()
        self.declare_partials('def_mesh', 'mesh', rows=rows, cols=cols)

        # Set up the rows and cols for `def_mesh` wrt `transformation_matrix`
        rows = np.einsum('ijl,k->ijkl', mesh_disp_indices,
                         np.ones(3, int)).flatten()
        cols = np.einsum('jlk,i->ijkl', transform_indices,
                         np.ones(self.nx, int)).flatten()
        self.declare_partials('def_mesh',
                              'transformation_matrix',
                              rows=rows,
                              cols=cols)
    def setup(self):
        self.surface = surface = self.options['surface']

        mesh=surface['mesh']
        nx = self.nx = mesh.shape[0]
        ny = self.ny = mesh.shape[1]

        self.add_input('mesh', val=np.ones((self.nx, self.ny, 3)), units='m')
        self.add_input('disp', val=np.ones((self.ny, 6)), units='m')
        self.add_input('transformation_matrix', val=np.ones((self.ny, 3, 3)))
        self.add_input('nodes', val=np.ones((self.ny, 3)), units='m')

        self.add_output('def_mesh', val=np.random.random_sample((self.nx, self.ny, 3)), units='m')

        # Create index arrays for each relevant input and output.
        # This allows us to set up the rows and cols for the sparse Jacobians.
        disp_indices = get_array_indices(self.ny, 6)
        nodes_indices = get_array_indices(self.ny, 3)
        mesh_indices = get_array_indices(self.nx, self.ny, 3)
        transform_indices = get_array_indices(self.ny, 3, 3)
        mesh_disp_indices = get_array_indices(self.nx, self.ny, 3)

        # Set up the rows and cols for `def_mesh` wrt `disp`
        rows = mesh_disp_indices.flatten()
        cols = np.einsum('i,jk->ijk', np.ones(self.nx), disp_indices[:, :3]).flatten()
        self.declare_partials('def_mesh', 'disp', val=1., rows=rows, cols=cols)

        # Set up the rows and cols for `def_mesh` wrt `nodes`
        rows = np.einsum('ijk,l->ijkl', mesh_disp_indices, np.ones(3, int)).flatten()
        cols = np.einsum('ik,jl->ijkl', np.ones((self.nx, 3), int), nodes_indices).flatten()
        self.declare_partials('def_mesh', 'nodes', rows=rows, cols=cols)

        # Set up the rows and cols for `def_mesh` wrt `mesh`
        rows = np.einsum('ijk,l->ijkl', mesh_disp_indices, np.ones(3, int)).flatten()
        cols = np.einsum('ijl,k->ijkl', mesh_indices, np.ones(3, int)).flatten()
        self.declare_partials('def_mesh', 'mesh', rows=rows, cols=cols)

        # Set up the rows and cols for `def_mesh` wrt `transformation_matrix`
        rows = np.einsum('ijl,k->ijkl', mesh_disp_indices, np.ones(3, int)).flatten()
        cols = np.einsum('jlk,i->ijkl', transform_indices, np.ones(self.nx, int)).flatten()
        self.declare_partials('def_mesh', 'transformation_matrix', rows=rows, cols=cols)
    def setup(self):
        self.surface = surface = self.options['surface']
        mesh=surface['mesh']
        self.nx = mesh.shape[0]
        self.ny = mesh.shape[1]

        self.add_input('disp', val=np.zeros((self.ny, 6)), units='m')
        self.add_output('transformation_matrix', shape=(self.ny, 3, 3))

        # Create index arrays for each relevant input and output.
        # This allows us to set up the rows and cols for the sparse Jacobians.
        disp_indices = get_array_indices(self.ny, 6)
        transform_indices = get_array_indices(self.ny, 3, 3)

        # Set up the rows and cols for `transformation_matrix` wrt `disp`
        rows = np.einsum('ijk,l->ijkl',
            transform_indices,
            np.ones(3, int)).flatten()
        cols = np.einsum('il,jk->ijkl',
            get_array_indices(self.ny, 6)[:, 3:],
            np.ones((3, 3), int)).flatten()
        self.declare_partials('transformation_matrix', 'disp', rows=rows, cols=cols)
Beispiel #4
0
    def setup(self):
        self.surface = surface = self.options['surface']
        mesh=surface['mesh']
        self.nx = mesh.shape[0]
        self.ny = mesh.shape[1]

        self.add_input('disp', val=np.zeros((self.ny, 6)), units='m')
        self.add_output('transformation_matrix', shape=(self.ny, 3, 3))

        # Create index arrays for each relevant input and output.
        # This allows us to set up the rows and cols for the sparse Jacobians.
        disp_indices = get_array_indices(self.ny, 6)
        transform_indices = get_array_indices(self.ny, 3, 3)

        # Set up the rows and cols for `transformation_matrix` wrt `disp`
        rows = np.einsum('ijk,l->ijkl',
            transform_indices,
            np.ones(3, int)).flatten()
        cols = np.einsum('il,jk->ijkl',
            get_array_indices(self.ny, 6)[:, 3:],
            np.ones((3, 3), int)).flatten()
        self.declare_partials('transformation_matrix', 'disp', rows=rows, cols=cols)