示例#1
0
    def __init__(self, tolerance=1e-10, iterations=5, MLOptions={}, testUnsupported = False):
        """
        :Parameters:
          - `tolerance`: The required error tolerance.
          - `iterations`: The maximum number of iterations to perform per test.
          - `MLOptions`: Options to pass to ML. A dictionary of {option:value} pairs. This will be passed to ML.SetParameterList. 
          - `testUnsupported`: test smoothers that are not currently implemented in preconditioner objects.

        For detailed information on the possible parameters for ML, see
        http://trilinos.sandia.gov/packages/ml/documentation.html

        Currently, passing options to Aztec through ML is not supported.
         """
                
        TrilinosSolver.__init__(self, tolerance=tolerance, 
                                iterations=iterations)

        self.MLOptions = MLOptions
        if "output" not in self.MLOptions:
            self.MLOptions["output"] = 0
            
        if "test: max iters" not in self.MLOptions:
            self.MLOptions["test: max iters"] = iterations
        
        if "test: tolerance" not in self.MLOptions:
            self.MLOptions["test: tolerance"] = tolerance

        
        unsupportedSmoothers = ["Jacobi", "Gauss-Seidel", "block Gauss-Seidel", "ParaSails", "IFPACK", "ML"]

        if not testUnsupported:
            for smoother in unsupportedSmoothers:
                if ("test: " + smoother) not in self.MLOptions:
                    self.MLOptions["test: " + smoother] = False
 def __init__(self, equation, jacobian=None, tolerance=1e-10, iterations=1000, 
              printingOptions=None, solverOptions=None, linearSolverOptions=None, 
              lineSearchOptions=None, directionOptions=None, newtonOptions=None):
     TrilinosSolver.__init__(self, tolerance=tolerance, iterations=iterations, precon=None)
     
     self.equation = equation
     self.jacobian = jacobian
     
     self.nlParams = NOX.Epetra.defaultNonlinearParameters(parallelComm.epetra_comm, 2)
     self.nlParams["Printing"] = printingOptions or {
         'Output Precision': 3, 
         'MyPID': 0, 
         'Output Information': NOX.Utils.OuterIteration, 
         'Output Processor': 0
     }
     self.nlParams["Solver Options"] =  solverOptions or {
         'Status Test Check Type': 'Complete', 
         'Rescue Bad Newton Solve': 'True'
     }
     self.nlParams["Linear Solver"] = linearSolverOptions or {
         'Aztec Solver': 'GMRES', 
         'Tolerance': 0.0001, 
         'Max Age Of Prec': 5, 
         'Max Iterations': 20, 
         'Preconditioner': 'Ifpack'
     }
     self.nlParams["Line Search"] = lineSearchOptions or {'Method': "Polynomial"}
     self.nlParams["Direction"] = directionOptions or {'Method': 'Newton'}
     self.nlParams["Newton"] = newtonOptions or {'Forcing Term Method': 'Type 2'}
     
     self.nox = _NOXInterface(solver=self)
示例#3
0
    def __init__(self, equation, jacobian=None, tolerance=1e-10, iterations=1000,
                 printingOptions=None, solverOptions=None, linearSolverOptions=None,
                 lineSearchOptions=None, directionOptions=None, newtonOptions=None):
        TrilinosSolver.__init__(self, tolerance=tolerance, iterations=iterations, precon=None)

        self.equation = equation
        self.jacobian = jacobian

        self.nlParams = NOX.Epetra.defaultNonlinearParameters(parallelComm.epetra_comm, 2)
        self.nlParams["Printing"] = printingOptions or {
            'Output Precision': 3,
            'MyPID': 0,
            'Output Information': NOX.Utils.OuterIteration,
            'Output Processor': 0
        }
        self.nlParams["Solver Options"] =  solverOptions or {
            'Status Test Check Type': 'Complete',
            'Rescue Bad Newton Solve': 'True'
        }
        self.nlParams["Linear Solver"] = linearSolverOptions or {
            'Aztec Solver': 'GMRES',
            'Tolerance': 0.0001,
            'Max Age Of Prec': 5,
            'Max Iterations': 20,
            'Preconditioner': 'Ifpack'
        }
        self.nlParams["Line Search"] = lineSearchOptions or {'Method': "Polynomial"}
        self.nlParams["Direction"] = directionOptions or {'Method': 'Newton'}
        self.nlParams["Newton"] = newtonOptions or {'Forcing Term Method': 'Type 2'}

        self.nox = _NOXInterface(solver=self)
示例#4
0
    def __init__(self,
                 tolerance=1e-10,
                 iterations=10,
                 precon=None,
                 maxIterations=10):
        """
        :Parameters:
          - `tolerance`: The required error tolerance.
          - `iterations`: The maximum number of iterative steps to perform.

        """

        iterations = min(iterations, maxIterations)

        TrilinosSolver.__init__(self,
                                tolerance=tolerance,
                                iterations=iterations,
                                precon=None)

        if precon is not None:
            import warnings
            warnings.warn(
                "Trilinos KLU solver does not accept preconditioners.",
                UserWarning,
                stacklevel=2)
        self.Factory = Amesos.Factory()
示例#5
0
    def __init__(self, tolerance=1e-10, iterations=1000, precon=JacobiPreconditioner()):
        """
        :Parameters:
          - `tolerance`: The required error tolerance.
          - `iterations`: The maximum number of iterative steps to perform.
          - `precon`: Preconditioner object to use. 

        """
        if self.__class__ is TrilinosAztecOOSolver:
            raise NotImplementedError, "can't instantiate abstract base class"
            
        TrilinosSolver.__init__(self, tolerance=tolerance,
                                iterations=iterations, precon=None)
        self.preconditioner = precon
示例#6
0
    def __init__(self, tolerance=1e-10, iterations=10, precon=None, maxIterations=10):
        """
        :Parameters:
          - `tolerance`: The required error tolerance.
          - `iterations`: The maximum number of iterative steps to perform.

        """

        iterations = min(iterations, maxIterations)
        
        TrilinosSolver.__init__(self, tolerance=tolerance, 
                                iterations=iterations, precon=None)

        if precon is not None:
            import warnings
            warnings.warn("Trilinos KLU solver does not accept preconditioners.",
                           UserWarning, stacklevel=2)
        self.Factory = Amesos.Factory()
示例#7
0
    def __init__(self,
                 tolerance=1e-10,
                 iterations=1000,
                 precon=JacobiPreconditioner()):
        """
        Parameters
        ----------
        tolerance : float
            Required error tolerance.
        iterations : int
            Maximum number of iterative steps to perform.
        precon : ~fipy.solvers.trilinos.preconditioners.preconditioner.Preconditioner
        """
        if self.__class__ is TrilinosAztecOOSolver:
            raise NotImplementedError("can't instantiate abstract base class")

        TrilinosSolver.__init__(self,
                                tolerance=tolerance,
                                iterations=iterations,
                                precon=None)
        self.preconditioner = precon