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.
 
getDomainStatus(self)
Return the status indicator of the domain
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.
 
getOperatorType(self)
Returns the current system type.
 
getRequiredOperatorType(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.
SolverOptions
getSolverOptions(self)
Returns the solver options
tuple of Operator, and Data.
getSystem(self)
Returns the operator and right hand side of the PDE.
 
getSystemStatus(self)
Return the domain status used to build the current system
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 with the tolrance defined by the solver options
 
setSolverOptions(self, options=None)
Sets the solver options.
 
setSymmetry(self, flag=False)
Sets the symmetry flag to flag.
 
setSymmetryOff(self)
Clears the symmetry flag.
 
setSymmetryOn(self)
Sets the symmetry flag.
 
setSystemStatus(self, status=None)
Sets the system status to status if status is not present the current status of the domain is used.
 
setValue(self, **coefficients)
Sets new values to coefficients.
 
trace(self, text)
Prints the text message if debug mode is switched on.
 
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__

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

getRequiredOperatorType(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.

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.

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

Note: the method is equivalent to use getSolverOptions().isSymmetric()

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

setSolverOptions(self, options=None)

 

Sets the solver options.

Parameters:
  • options (SolverOptions or None) - the new solver options. If equal None, the solver options are set to the default.

Note: The symmetry flag of options is overwritten by the symmetry flag of the LinearProblem.

setSymmetry(self, flag=False)

 

Sets the symmetry flag to flag.

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

Note: The method overwrites the symmetry flag set by the solver options

setSymmetryOff(self)

 

Clears the symmetry flag.

Note: The method overwrites the symmetry flag set by the solver options

setSymmetryOn(self)

 

Sets the symmetry flag.

Note: The method overwrites the symmetry flag set by the solver options

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