pygeon.discretizations.vec_discretization module
Module for the vector discretization class.
- class pygeon.discretizations.vec_discretization.VecDiscretization(keyword='unitary_data')[source]
Bases:
DiscretizationA class representing a vectorized discretization for a given base discretization. The base needs to be specified in the __init__ function.
- base_discr
The scalar discretization method.
- ndof(sd)[source]
Returns the number of degrees of freedom associated to the method. In this case, it returns the product of the number of nodes and the dimension of the grid.
- Parameters:
sd (pg.Grid) – The grid or a subclass.
- Returns:
The number of degrees of freedom.
- Return type:
- assemble_mass_matrix(sd, data=None)[source]
Assembles and returns the mass matrix.
- Parameters:
sd (pg.Grid) – The grid.
data (dict | None) – Optional data for the assembly.
- Returns:
The mass matrix obtained from the discretization.
- Return type:
sps.csc_array
- assemble_diff_matrix(sd)[source]
Assembles the matrix corresponding to the differential operator.
- Parameters:
sd (pg.Grid) – Grid object or a subclass.
- Returns:
The differential matrix.
- Return type:
sps.csc_array
- assemble_stiff_matrix(sd, data=None)[source]
Assembles the stiffness matrix.
- Parameters:
sd (pg.Grid) – Grid object or a subclass.
- Returns:
The differential matrix.
- Return type:
sps.csc_array
- assemble_lumped_matrix(sd, data=None)[source]
Assembles the lumped mass matrix given by the row sums on the diagonal.
- Parameters:
sd (pg.Grid) – Grid object or a subclass.
data (dict | None) – Dictionary with physical parameters for scaling.
- Returns:
The lumped mass matrix.
- Return type:
sps.csc_array
- proj_to_PwPolynomials(sd)[source]
Construct the matrix for projecting a vector function to a piecewise vector space.
- Parameters:
sd (pg.Grid) – The grid on which to construct the matrix.
- Returns:
The matrix representing the projection.
- Return type:
sps.csc_array
- interpolate(sd, func)[source]
Interpolates a function onto the finite element space
- Parameters:
sd (pg.Grid) – Grid, or a subclass.
func (Callable) – A function that returns the function values at coordinates.
- Returns:
The values of the degrees of freedom
- Return type:
np.ndarray
- eval_at_cell_centers(sd)[source]
Evaluate the finite element solution at the cell centers of the given grid.
- Parameters:
sd (pg.Grid) – The grid on which to evaluate the solution.
- Returns:
The finite element solution evaluated at the cell centers.
- Return type:
sps.csc_array
- assemble_nat_bc(sd, func, b_faces)[source]
Assembles the natural boundary condition vector, equal to zero.
- Parameters:
sd (pg.Grid) – The grid object.
func (Callable[[np.ndarray], np.ndarray]) – The function defining the natural boundary condition.
b_faces (np.ndarray) – The array of boundary faces.
- Returns:
The assembled natural boundary condition vector.
- Return type:
np.ndarray
- vectorize(dim, matrix)[source]
Vectorizes the given matrix by repeating it for each dimension of the grid.
- Parameters:
matrix (sps.csc_array) – The matrix to be vectorized.
- Returns:
The vectorized matrix.
- Return type:
sps.csc_array