def _assemble_and_evaluate(self, x0, d0, active_nodes, fixed_and_handle_nodes, no_of_fixed_and_handle_nodes, delta_d_handler, delta_d): # 2. Assemble m logging.info('Assemble interpolation matrix...') m = assemble(self._rbffunc, x0[fixed_and_handle_nodes, :] + d0[fixed_and_handle_nodes, :], self._polynomial_order) logging.info('Solve weights for interpolation...') if self._extra_columns == 0: gamma = solve(m, delta_d_handler[fixed_and_handle_nodes, :]) else: gamma = solve(m, np.concatenate( (delta_d_handler[fixed_and_handle_nodes, :], np.zeros((self._extra_columns, 3), dtype=np.float64)), axis=0)) # 3. Evaluate logging.info('Evaluate interpolation...') s = evaluate(self._rbffunc, x0[active_nodes, :] + d0[active_nodes, :], x0[fixed_and_handle_nodes, :] + d0[fixed_and_handle_nodes, :], gamma[:no_of_fixed_and_handle_nodes], gamma[no_of_fixed_and_handle_nodes:]) delta_d[active_nodes, :] = s
def test_assembly_with_polynomial_order_1(): """ Test assembly with polynomial order = 1 """ s = r'r**3' # Define two nodes x = np.array([[1.0, 0.0, 0.0], [0.0, 2.0, 0.0], [0.2, 0.5, 0.6]]) actual = assemble(s, x, 1) desired = np.array([[ 0.0, np.sqrt(5.0)**3, np.sqrt(0.8**2 + 0.5**2 + 0.6**2)**3, 1.0, 1.0, 0.0, 0.0 ], [ np.sqrt(5.0)**3, 0.0, np.sqrt(0.2**2 + 1.5**2 + 0.6**2)**3, 1.0, 0.0, 2.0, 0.0 ], [ np.sqrt(0.8**2 + 0.5**2 + 0.6**2)**3, np.sqrt(0.2**2 + 1.5**2 + 0.6**2)**3, 0.0, 1.0, 0.2, 0.5, 0.6 ], [1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0], [1.0, 0.0, 0.2, 0.0, 0.0, 0.0, 0.0], [0.0, 2.0, 0.5, 0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.6, 0.0, 0.0, 0.0, 0.0]]) assert_allclose(actual, desired)
def test_assembly(): """ Test assembly with simple rbf function f(r) = r**3 """ s = r'r**3' # Define two nodes x = np.array([[1.0, 0.0, 0.0], [0.0, 1.0, 0.0]]) actual = assemble(s, x) desired = np.array([[0.0, np.sqrt(2.0)**3], [np.sqrt(2.0)**3, 0.0]]) assert_allclose(actual, desired)
def test_assembly_with_polynomial_order_0_2d(): """ Test assembly with polynomial order = 0 """ s = r'r**3' # Define two nodes x = np.array([[1.0, 0.0], [0.0, 1.0]]) actual = assemble(s, x, 0) desired = np.array([[0.0, np.sqrt(2.0)**3, 1.0], [np.sqrt(2.0)**3, 0.0, 1.0], [1.0, 1.0, 0.0]]) assert_allclose(actual, desired)