Python API#
Basic Python API of the Problem Class and Cell-Centered Uniform Mesh Class.
Problem Class#
- class Problem#
- initialCondition()#
Constructs and returns an instance of the initial condition for the target problem.
- Return type:
numpy array
- createRightHandSide()#
Constructs and returns an instance of the rhs.
- Return type:
numpy array
- createApplyJacobianResult(operand)#
Constructs and returns an instance of the action of the Jacobian applied to the operand. The result is constructed, and zeroed out before returning it.
- Parameters:
operand (numpy array) – rank-1 or rank-2 operand to apply the Jacobian to.
- Return type:
numpy array
- rightHandSide(y, time, rhs)#
Given a state \(y\) and time \(time\), evaluates the RHS of the system and stores it into \(v\).
- Parameters:
y (numpy array) – state vector
time (float) – evaluation time
rhs (numpy array) – rhs to overwrite
- applyJacobian(y, operand, time, result)#
Given a state \(y\) and time \(time\), this computes the action of the Jacobian applied to \(operand\).
- Parameters:
y (numpy array) – state vector
operand (numpy array) – rank-1 or rank-2 operand to apply the Jacobian to.
time (float) – evaluation time
result (numpy array) – rank-1 or rank-2 operand to apply the Jacobian to.
- totalDofSampleMesh()#
Returns the total number of degrees of freedom on the sample mesh. Note that, in general, this is not the same as the number of sample mesh cells. When you have multiple dofs/cell (for example Euler equations), then the total # of dofs on sample mesh = # dofs/cell times the # of sample mesh cells.
- Return type:
int
- totalDofStencilMesh()#
Returns the total number of degrees of freedom on the stencil mesh. Note that, in general, this is not the same as the number of stencil mesh cells. When you have multiple dofs/cell (for example Euler equations), then the total # of dofs on stencil mesh = # dofs/cell times the # of stencil mesh cells.
- Return type:
int
Note
Note how the Python interface only supports the Jacobian action. The main reason behind this is that Pybind11 does not yet allow view semantics for Python sparse matrices.
Cell-Centered Uniform Mesh Class#
A pressio-demoapps Python cell-centered mesh class meets the following API
- class CellCenteredUniformMesh#
- dimensionality()#
Returns the dimensionality of this mesh: returns 1 for 1d problem, 2 for 2d, etc.
- Return type:
int
- stencilSize()#
Returns the size of the stencil (connectivity) of this mesh object.
- Return type:
int
- stencilMeshSize()#
Returns the number of stencil cells in the mesh. This corresponds to all cells where the state is defined.
- Return type:
int
- sampleMeshSize()#
Returns the number of sample cells in the mesh. This corresponds to all cells where the RHS is defined.
- Return type:
int
- dx()#
Returns the cell size along the x axis.
- Return type:
float
- dy()#
Returns the cell size along the y axis. This is applicable only if the dimensionality is >= 2.
- Return type:
float
- dz()#
Returns the cell size along the z axis. This is applicable only if the dimensionality is == 3.
- Return type:
float
- viewX()#
Returns a reference to the vector of x-coordinates of all stencil mesh cells. The type of container returned by reference depends on the backend used.
- Return type:
numpy array
- viewY()#
Returns a reference to the vector of y-coordinates of all stencil mesh cells The type of container returned by reference depends on the backend used.
- Return type:
numpy array
- viewZ()#
Returns a reference to the vector of z-coordinates of all stencil mesh cells The type of container returned by reference depends on the backend used.
- Return type:
numpy array