Package esys :: Package escript :: Module linearPDEs :: Class LinearProblem
[hide private]
[frames] | no frames]

Class LinearProblem

object --+
         |
        LinearProblem
Known Subclasses:

This is the base class to define a general linear PDE-type problem for for an unknown function u on a given domain defined through a Domain object. The problem can be given as a single equation or as a system of equations.

The class assumes that some sort of assembling process is required to form a problem of the form

L u=f

where L is an operator and f is the right hand side. This operator problem will be solved to get the unknown u.

Instance Methods [hide private]
 
__init__(self, domain, numEquations=None, numSolutions=None, debug=False)
Initializes a linear problem.
str
__str__(self)
Returns a string representation of the PDE.
 
alteredCoefficient(self, name)
Announces that coefficient name has been changed.
bool
checkReciprocalSymmetry(self, name0, name1, verbose=True)
Tests two coefficients for reciprocal symmetry.
bool
checkSymmetricTensor(self, name, verbose=True)
Tests a coefficient for symmetry.
bool
checkSymmetry(self, verbose=True)
Tests the PDE for symmetry.
Data
createCoefficient(self, name)
Creates a Data object corresponding to coefficient name.
 
createOperator(self)
Returns an instance of a new operator.
 
createRightHandSide(self)
Returns an instance of a new right hand side.
 
createSolution(self)
Returns an instance of a new solution.
Data
getCoefficient(self, name)
Returns the value of the coefficient name.
 
getCurrentOperator(self)
Returns the operator in its current state.
 
getCurrentRightHandSide(self)
Returns the right hand side in its current state.
 
getCurrentSolution(self)
Returns the solution in its current state.
int
getDim(self)
Returns the spatial dimension of the PDE.
Domain
getDomain(self)
Returns the domain of the PDE.
FunctionSpace
getFunctionSpaceForCoefficient(self, name)
Returns the FunctionSpace to be used for coefficient name.
FunctionSpace
getFunctionSpaceForEquation(self)
Returns the FunctionSpace used to discretize the equation.
FunctionSpace
getFunctionSpaceForSolution(self)
Returns the FunctionSpace used to represent the solution.
int
getNumEquations(self)
Returns the number of equations.
int
getNumSolutions(self)
Returns the number of unknowns.
 
getOperator(self)
Returns the operator of the linear problem.
 
getRequiredSystemType(self)
Returns the system type which needs to be used by the current set up.
Data
getRightHandSide(self)
Returns the right hand side of the linear problem.
tuple of int
getShapeOfCoefficient(self, name)
Returns the shape of the coefficient name.
Data
getSolution(self, **options)
Returns the solution of the problem.
tuple of int
getSolverMethod(self)
Returns the solver method and preconditioner used.
string
getSolverMethodName(self)
Returns the name of the solver currently used.
int
getSolverPackage(self)
Returns the package of the solver.
tuple of Operator, and Data.
getSystem(self)
Returns the operator and right hand side of the PDE.
 
getSystemType(self)
Returns the current system type.
float
getTolerance(self)
Returns the tolerance currently set for the solution.
bool
hasCoefficient(self, name)
Returns True if name is the name of a coefficient.
 
initializeSystem(self)
Resets the system clearing the operator, right hand side and solution.
 
introduceCoefficients(self, **coeff)
Introduces new coefficients into the problem.
 
invalidateOperator(self)
Indicates the operator has to be rebuilt next time it is used.
 
invalidateRightHandSide(self)
Indicates the right hand side has to be rebuilt next time it is used.
 
invalidateSolution(self)
Indicates the PDE has to be resolved if the solution is requested.
 
invalidateSystem(self)
Announces that everything has to be rebuilt.
 
isOperatorValid(self)
Returns True if the operator is still valid.
 
isRightHandSideValid(self)
Returns True if the operator is still valid.
 
isSolutionValid(self)
Returns True if the solution is still valid.
bool
isSymmetric(self)
Checks if symmetry is indicated.
 
isSystemValid(self)
Returns True if the system (including solution) is still vaild.
bool
isUsingLumping(self)
Checks if matrix lumping is the current solver method.
bool
reduceEquationOrder(self)
Returns the status of order reduction for the equation.
bool
reduceSolutionOrder(self)
Returns the status of order reduction for the solution.
 
resetAllCoefficients(self)
Resets all coefficients to their default values.
 
resetOperator(self)
Makes sure that the operator is instantiated and returns it initialized with zeros.
 
resetRightHandSide(self)
Sets the right hand side to zero.
 
resetSolution(self)
Sets the solution to zero.
 
setDebug(self, flag)
Switches debug output on if flag is True otherwise it is switched off.
 
setDebugOff(self)
Switches debug output off.
 
setDebugOn(self)
Switches debug output on.
 
setReducedOrderForEquationOff(self)
Switches reduced order off for equation representation.
 
setReducedOrderForEquationOn(self)
Switches reduced order on for equation representation.
 
setReducedOrderForEquationTo(self, flag=False)
Sets order reduction state for equation representation according to flag.
 
setReducedOrderForSolutionOff(self)
Switches reduced order off for solution representation
 
setReducedOrderForSolutionOn(self)
Switches reduced order on for solution representation.
 
setReducedOrderForSolutionTo(self, flag=False)
Sets order reduction state for solution representation according to flag.
 
setReducedOrderOff(self)
Switches reduced order off for solution and equation representation
 
setReducedOrderOn(self)
Switches reduced order on for solution and equation representation.
 
setReducedOrderTo(self, flag=False)
Sets order reduction state for both solution and equation representation according to flag.
 
setSolution(self, u)
Sets the solution assuming that makes the system valid.
 
setSolverMethod(self, solver=None, preconditioner=None)
Sets a new solver method and/or preconditioner.
 
setSolverPackage(self, package=None)
Sets a new solver package.
 
setSymmetryOff(self)
Clears the symmetry flag.
 
setSymmetryOn(self)
Sets the symmetry flag.
 
setSymmetryTo(self, flag=False)
Sets the symmetry flag to flag.
 
setTolerance(self, tol=1e-08)
Resets the tolerance for the solver method to tol.
 
setValue(self, **coefficients)
Sets new values to coefficients.
 
trace(self, text)
Prints the text message if debug mode is switched on.
 
updateSystemType(self)
Reassesses the system type and, if a new matrix is needed, resets the system.
 
validOperator(self)
Marks the operator as valid.
 
validRightHandSide(self)
Marks the right hand side as valid.
 
validSolution(self)
Marks the solution as valid.

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__

Class Variables [hide private]
  AMG = 22
Algebraic Multi Grid
  BICGSTAB = 6
The stabilized BiConjugate Gradient method
  CGS = 5
The conjugate gradient square method
  CHOLEVSKY = 2
The direct solver based on LDLt factorization (can only be applied for symmetric PDEs)
  CR = 4
The conjugate residual method
  DEFAULT = 0
The default method used to solve the system of linear equations
  DIRECT = 1
The direct solver based on LDU factorization
  GMRES = 11
The Gram-Schmidt minimum residual method
  GS = 28
Gauss-Seidel solver
  ILU0 = 8
The incomplete LU factorization preconditioner with no fill-in
  ILUT = 9
The incomplete LU factorization preconditioner with fill-in
  ITERATIVE = 20
The default iterative solver
  JACOBI = 10
The Jacobi preconditioner
  LUMPING = 13
Matrix lumping
  METHOD_KEY = 'method'
  MINIMUM_FILL_IN = 18
Reorder matrix to reduce fill-in during factorization
  MINRES = 27
Minimum residual method
  MKL = 15
Intel's MKL solver library
  NESTED_DISSECTION = 19
Reorder matrix to improve load balancing during factorization
  NONLINEAR_GMRES = 25
  NO_REORDERING = 17
No matrix reordering allowed
  PACKAGE_KEY = 'package'
  PASO = 21
PASO solver package
  PCG = 3
The preconditioned conjugate gradient method (can only be applied for symmetric PDEs)
  PRECONDITIONER_KEY = 'preconditioner'
  PRES20 = 12
Special GMRES with restart after 20 steps and truncation after 5 residuals
  RILU = 23
Recursive ILU
  SCSL = 14
SGI SCSL solver library
  SMALL_TOLERANCE = 1e-13
  SSOR = 7
The symmetric overrelaxation method
  SYMMETRY_KEY = 'symmetric'
  TFQMR = 26
Transport Free Quasi Minimal Residual method
  TOLERANCE_KEY = 'tolerance'
  TRILINOS = 24
The TRILINOS parallel solver class library from Sandia Natl Labs
  UMFPACK = 16
The UMFPACK library
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, domain, numEquations=None, numSolutions=None, debug=False)
(Constructor)

 

Initializes a linear problem.

Parameters:
  • domain (Domain) - domain of the PDE
  • numEquations - number of equations. If None the number of equations is extracted from the coefficients.
  • numSolutions - number of solution components. If None the number of solution components is extracted from the coefficients.
  • debug - if True debug information is printed
Overrides: object.__init__

__str__(self)
(Informal representation operator)

 

Returns a string representation of the PDE.

Returns: str
a simple representation of the PDE
Overrides: object.__str__

alteredCoefficient(self, name)

 

Announces that coefficient name has been changed.

Parameters:
  • name (string) - name of the coefficient affected
Raises:

Note: if name is q or r, the method will not trigger a rebuild of the system as constraints are applied to the solved system.

checkReciprocalSymmetry(self, name0, name1, verbose=True)

 

Tests two coefficients for reciprocal symmetry.

Parameters:
  • name0 (str) - name of the first coefficient
  • name1 (str) - name of the second coefficient
  • verbose (bool) - if set to True or not present a report on coefficients which break the symmetry is printed
Returns: bool
True if coefficients name0 and name1 are reciprocally symmetric.

checkSymmetricTensor(self, name, verbose=True)

 

Tests a coefficient for symmetry.

Parameters:
  • name (str) - name of the coefficient
  • verbose (bool) - if set to True or not present a report on coefficients which break the symmetry is printed.
Returns: bool
True if coefficient name is symmetric

checkSymmetry(self, verbose=True)

 

Tests the PDE for symmetry.

Parameters:
  • verbose (bool) - if set to True or not present a report on coefficients which break the symmetry is printed
Returns: bool
True if the problem is symmetric

Note: Typically this method is overwritten when implementing a particular linear problem.

createCoefficient(self, name)

 

Creates a Data object corresponding to coefficient name.

Returns: Data
the coefficient name initialized to 0
Raises:

createOperator(self)

 

Returns an instance of a new operator.

Note: This method is overwritten when implementing a particular linear problem.

getCoefficient(self, name)

 

Returns the value of the coefficient name.

Parameters:
  • name (string) - name of the coefficient requested
Returns: Data
the value of the coefficient
Raises:

getDim(self)

 

Returns the spatial dimension of the PDE.

Returns: int
the spatial dimension of the PDE domain

getDomain(self)

 

Returns the domain of the PDE.

Returns: Domain
the domain of the PDE

getFunctionSpaceForCoefficient(self, name)

 

Returns the FunctionSpace to be used for coefficient name.

Parameters:
  • name (string) - name of the coefficient enquired
Returns: FunctionSpace
the function space to be used for coefficient name
Raises:

getFunctionSpaceForEquation(self)

 

Returns the FunctionSpace used to discretize the equation.

Returns: FunctionSpace
representation space of equation

getFunctionSpaceForSolution(self)

 

Returns the FunctionSpace used to represent the solution.

Returns: FunctionSpace
representation space of solution

getNumEquations(self)

 

Returns the number of equations.

Returns: int
the number of equations
Raises:

getNumSolutions(self)

 

Returns the number of unknowns.

Returns: int
the number of unknowns
Raises:

getOperator(self)

 

Returns the operator of the linear problem.

Returns:
the operator of the problem

getRequiredSystemType(self)

 

Returns the system type which needs to be used by the current set up.

Note: Typically this method is overwritten when implementing a particular linear problem.

getRightHandSide(self)

 

Returns the right hand side of the linear problem.

Returns: Data
the right hand side of the problem

getShapeOfCoefficient(self, name)

 

Returns the shape of the coefficient name.

Parameters:
  • name (string) - name of the coefficient enquired
Returns: tuple of int
the shape of the coefficient name
Raises:

getSolution(self, **options)

 

Returns the solution of the problem.

Returns: Data
the solution

Note: This method is overwritten when implementing a particular linear problem.

getSolverMethod(self)

 

Returns the solver method and preconditioner used.

Returns: tuple of int
the solver method currently used.

getSolverMethodName(self)

 

Returns the name of the solver currently used.

Returns: string
the name of the solver currently used

getSolverPackage(self)

 

Returns the package of the solver.

Returns: int
the solver package currently being used

getSystem(self)

 

Returns the operator and right hand side of the PDE.

Returns: tuple of Operator, and Data.
the discrete version of the PDE

Note: This method is overwritten when implementing a particular linear problem.

getTolerance(self)

 

Returns the tolerance currently set for the solution.

Returns: float
tolerance currently used

hasCoefficient(self, name)

 

Returns True if name is the name of a coefficient.

Parameters:
  • name (string) - name of the coefficient enquired
Returns: bool
True if name is the name of a coefficient of the general PDE, False otherwise

introduceCoefficients(self, **coeff)

 

Introduces new coefficients into the problem.

Use:


p.introduceCoefficients(A=PDECoef(...), B=PDECoef(...))

to introduce the coefficients A ans B.

isSymmetric(self)

 

Checks if symmetry is indicated.

Returns: bool
True if a symmetric PDE is indicated, False otherwise

isUsingLumping(self)

 

Checks if matrix lumping is the current solver method.

Returns: bool
True if the current solver method is lumping

reduceEquationOrder(self)

 

Returns the status of order reduction for the equation.

Returns: bool
True if reduced interpolation order is used for the representation of the equation, False otherwise

reduceSolutionOrder(self)

 

Returns the status of order reduction for the solution.

Returns: bool
True if reduced interpolation order is used for the representation of the solution, False otherwise

setDebug(self, flag)

 

Switches debug output on if flag is True otherwise it is switched off.

Parameters:
  • flag (bool) - desired debug status

setReducedOrderForEquationOff(self)

 

Switches reduced order off for equation representation.

Raises:
  • RuntimeError - if order reduction is altered after a coefficient has been set

setReducedOrderForEquationOn(self)

 

Switches reduced order on for equation representation.

Raises:
  • RuntimeError - if order reduction is altered after a coefficient has been set

setReducedOrderForEquationTo(self, flag=False)

 

Sets order reduction state for equation representation according to flag.

Parameters:
  • flag (bool) - if flag is True, the order reduction is switched on for equation representation, otherwise or if flag is not present order reduction is switched off
Raises:
  • RuntimeError - if order reduction is altered after a coefficient has been set

setReducedOrderForSolutionOff(self)

 

Switches reduced order off for solution representation

Raises:
  • RuntimeError - if order reduction is altered after a coefficient has been set.

setReducedOrderForSolutionOn(self)

 

Switches reduced order on for solution representation.

Raises:
  • RuntimeError - if order reduction is altered after a coefficient has been set

setReducedOrderForSolutionTo(self, flag=False)

 

Sets order reduction state for solution representation according to flag.

Parameters:
  • flag (bool) - if flag is True, the order reduction is switched on for solution representation, otherwise or if flag is not present order reduction is switched off
Raises:
  • RuntimeError - if order reduction is altered after a coefficient has been set

setReducedOrderOff(self)

 

Switches reduced order off for solution and equation representation

Raises:
  • RuntimeError - if order reduction is altered after a coefficient has been set

setReducedOrderOn(self)

 

Switches reduced order on for solution and equation representation.

Raises:
  • RuntimeError - if order reduction is altered after a coefficient has been set

setReducedOrderTo(self, flag=False)

 

Sets order reduction state for both solution and equation representation according to flag.

Parameters:
  • flag (bool) - if True, the order reduction is switched on for both solution and equation representation, otherwise or if flag is not present order reduction is switched off
Raises:
  • RuntimeError - if order reduction is altered after a coefficient has been set

setSolverMethod(self, solver=None, preconditioner=None)

 

Sets a new solver method and/or preconditioner.

Parameters:

Note: the solver method chosen may not be available by the selected package.

setSolverPackage(self, package=None)

 

Sets a new solver package.

Parameters:

setSymmetryTo(self, flag=False)

 

Sets the symmetry flag to flag.

Parameters:
  • flag (bool) - If True, the symmetry flag is set otherwise reset.

setTolerance(self, tol=1e-08)

 

Resets the tolerance for the solver method to tol.

Parameters:
  • tol (positive float) - new tolerance for the solver. If tol is lower than the current tolerence the system will be resolved.
Raises:
  • ValueError - if tolerance is not positive

setValue(self, **coefficients)

 

Sets new values to coefficients.

Raises:

trace(self, text)

 

Prints the text message if debug mode is switched on.

Parameters:
  • text (string) - message to be printed