def __add_boundary_contrib_operator2(self, bc, b_idx): """ Appending contribution of boundary condition into operator 2. :param bc: boundary condition specifics. :param b_idx: index of boundary DoF. """ if bc is not None: if bc.boundary_condition_type is configuration.BoundaryConditionType.ROBIN: fe_op.add_value(self.operator2_u, -0.5 * (self.timestep ** 2) * bc.param, b_idx, b_idx) elif bc.boundary_condition_type is configuration.BoundaryConditionType.ABSORBING: fe_op.add_value(self.operator2_u, 0.5 * self.timestep * bc.param, b_idx, b_idx)
def __add_boundary_contrib_inv_operator(self, bc, b_idx): """ Appending contribution of boundary condition into inv operator. :param bc: boudnary condition specifics. :param b_idx: index of boundary DoF. """ if bc is not None: if bc.boundary_condition_type is configuration.BoundaryConditionType.DIRICHLET: fe_op.apply_pseudo_elimination(self.inv_operator_u, b_idx) elif bc.boundary_condition_type is configuration.BoundaryConditionType.ROBIN: fe_op.add_value(self.inv_operator_u, 0.5 * (self.timestep ** 2) * bc.param, b_idx, b_idx) elif bc.boundary_condition_type is configuration.BoundaryConditionType.ABSORBING: fe_op.add_value(self.inv_operator_u, 0.5 * self.timestep * bc.param, b_idx, b_idx)
def test_add_value(): """ Testing adding value at specific DoF index in finite element operator. """ # Testing assembled case. warnings.simplefilter('ignore', SparseEfficiencyWarning) op0 = fe_op.make_from_data(np.diag(np.array([1.0, 1.0])), fe_op.AssemblyType.ASSEMBLED) fe_op.add_value(op0, 666.0, 0, 1) np_test.assert_array_almost_equal(op0.data.todense(), np.array([[1.0, 666.0], [0.0, 1.0]])) warnings.resetwarnings() # Testing lumped case. op0 = fe_op.make_from_data(np.array([1.0, 1.0]), fe_op.AssemblyType.LUMPED) fe_op.add_value(op0, 665.0, 1, 1) np_test.assert_array_almost_equal(op0.data, np.array([1.0, 666.0]))