

def _build_RHS_matrix(self, modified_RHS_pores=None, RHS_added_data=None, mode='overwrite'):
    '\n        This builds the right-hand-side matrix for the linear solver.\n        '
    if (mode == 'overwrite'):
        A_dim = self._coeff_dimension
        b = sp.zeros([A_dim, 1])
        if ('pore.Dirichlet' in self.labels()):
            Dir_pores = self.pores('Dirichlet')
            Dir_pores_vals = self['pore.bcval_Dirichlet'][Dir_pores]
            b[Dir_pores] = sp.reshape(Dir_pores_vals, [len(Dir_pores), 1])
        if ('pore.Neumann' in self.labels()):
            ind_Neu_pores = self.pores('Neumann')
            ind_Neu_pores_vals = self[(('pore.' + 'bcval_') + 'Neumann')][ind_Neu_pores]
            b[ind_Neu_pores] = sp.reshape(ind_Neu_pores_vals, [len(ind_Neu_pores), 1])
        if ('pore.Neumann_group' in self.labels()):
            pnum = self._net.Np
            NG_loc = sp.r_[pnum:(pnum + len(self._group_Neumann_vals))]
            NG_l = len(self._group_Neumann_vals)
            NG_arr = self._group_Neumann_vals[sp.r_[0:NG_l]]
            b[NG_loc] = sp.reshape(NG_arr, [NG_l, 1])
    if (mode == 'modify_RHS'):
        b = sp.copy(self.b)
    if (mode in ['overwrite', 'modify_RHS']):
        if ((modified_RHS_pores is not None) and (RHS_added_data is not None)):
            if (sp.size(modified_RHS_pores) == sp.size(RHS_added_data)):
                p = sp.in1d(modified_RHS_pores, self._non_Dir_diag)
                data = RHS_added_data[p]
                b[modified_RHS_pores[p]] = (b[modified_RHS_pores[p]] + data.reshape([len(data), 1]))
            else:
                raise Exception('Provided data and pores for modifying RHS matrix should have the same size!')
    return b

dataset/ETHPy150Open PMEAL/OpenPNM/OpenPNM/Algorithms/__GenericLinearTransport__.py GenericLinearTransport._build_RHS_matrix/original