Exemplo n.º 1
0
    def _fill_VM( self, axis ):
        #Define self.UM
        for point in self.Get_V_Iterator(axis):
            dof = self.nvd(axis, point)
            # #ignore non-degrees of freedom
            # if dof < 0:
	    #     continue
            
            # The trace will be -2 * ndim
            center_val = -2 * self.ndim

            col = []
            val = []
            for pp in ndimed.perturb(point):
                test_dof = self.nvd(axis, pp)
                if   test_dof >= 0:
                    col.append(test_dof)
                    val.append(1)
                elif test_dof ==-3:
                    center_val -= 1

            # Add the center value in the list of stuff to add
            col.append(dof)
            val.append(center_val)

            # Populate the matrix
            for c, v in zip(col, val):
                self.VM[axis][dof,c] = v
Exemplo n.º 2
0
    def _fill_PM(self):
        # ndimed.iter_grid only gits points for each proc.
        for point in self.Get_P_Iterator():
            dof = self.pdp(point)
            
            # #ignore non-degrees of freedom (no longer necessary?)
            # if dof < 0:
            #     continue

            # Pin the solution to obtain
            # a unique (non-singular) solution
            if dof == 0:
                self.PM[dof,dof] = 1
                continue
            
            # The trace will be -2 * the number of dimensions
            center_value = -2 * self.ndim

            # The 'dof' is the row, and we gather the rows and cols to facilitate trilinos/scipy
            col = []
            val = []
            
            # Oscillate one in each direction
            for pp in ndimed.perturb(point):
                # Get the DOF number
                test_dof = self.pdp(pp)

                # If it is a dof . . .
                if test_dof != -1:
                    col.append(test_dof)
                    val.append(1)
                else:
                    center_value    += 1                

            # Stupid Warning, I don't think it is necessary any more . . .
            if center_value == 0:
                self.dbprint("Something bad probably just happened! %s" % str(point), 1)

            # Add the center point to the list . . .
            col.append(dof)
            val.append(center_value)

            # Populate the matrix
            for c, v in zip(col, val):
                self.PM[dof,c] = v