fastvpinns.FE.fespace module
file: fespace.py description: Abstract class for the FEspace Routines authors: Thivin Anandh D changelog: 03-May-2024 known_issues: None dependencies: None specified.
- class fastvpinns.FE.fespace.Fespace(mesh, cells, boundary_points, cell_type: str, fe_order: int, fe_type: str, quad_order: int, quad_type: str, fe_transformation_type: str, bound_function_dict: dict, bound_condition_dict: dict, forcing_function, output_path: str)[source]
Bases:
object
Represents a finite element space.
- Parameters:
mesh (Mesh) – The mesh object.
cells (ndarray) – The array of cell indices.
boundary_points (dict) – The dictionary of boundary points.
cell_type (str) – The type of cell.
fe_order (int) – The order of the finite element.
fe_type (str) – The type of finite element.
quad_order (int) – The order of the quadrature.
quad_type (str) – The type of quadrature.
fe_transformation_type (str) – The type of finite element transformation.
bound_function_dict (dict) – The dictionary of boundary functions.
bound_condition_dict (dict) – The dictionary of boundary conditions.
forcing_function (function) – The forcing function.
output_path (str) – The output path.
generate_mesh_plot (bool, optional) – Whether to generate a plot of the mesh. Defaults to False.
- abstract generate_dirichlet_boundary_data() ndarray [source]
Generate Dirichlet boundary data.
This function returns the boundary points and their corresponding values.
- Returns:
A tuple containing two arrays: - The first array contains the boundary points as numpy arrays. - The second array contains the values of the boundary points as numpy arrays.
- Return type:
Tuple[np.ndarray, np.ndarray]
- abstract get_forcing_function_values(cell_index) ndarray [source]
Get the forcing function values at the quadrature points.
- Parameters:
cell_index (int) – The index of the cell.
- Returns:
The forcing function values at the quadrature points.
- Return type:
np.ndarray
- Raises:
ValueError – If cell_index is greater than the number of cells.
This function computes the forcing function values at the quadrature points for a given cell. It loops over all the basis functions and computes the integral using the actual coordinates and the basis functions at the quadrature points. The resulting values are stored in the forcing_at_quad attribute of the corresponding fe_cell object.
Note: The forcing function is evaluated using the forcing_function method of the fe_cell object.
- abstract get_quadrature_actual_coordinates(cell_index) ndarray [source]
Get the actual coordinates of the quadrature points for a given cell.
- Parameters:
cell_index (int) – The index of the cell.
- Returns:
An array containing the actual coordinates of the quadrature points.
- Return type:
np.ndarray
- Raises:
ValueError – If the cell_index is greater than the number of cells.
- abstract get_sensor_data(exact_solution, num_points)[source]
Obtain sensor data (actual solution) at random points.
This method is used in the inverse problem to obtain the sensor data at random points within the domain. Currently, it only works for problems with an analytical solution. Methodologies to obtain sensor data for problems from a file are not implemented yet. It is also not implemented for external or complex meshes.
- Parameters:
exact_solution (function) – A function that computes the exact solution at a given point.
num_points (int) – The number of random points to generate.
- Returns:
A tuple containing the generated points and the exact solution at those points.
- Return type:
tuple(numpy.ndarray, numpy.ndarray)
- abstract get_sensor_data_external(exact_sol, num_points, file_name)[source]
This method is used to obtain the sensor data from an external file.
- Parameters:
exact_sol (array-like) – The exact solution values.
num_points (int) – The number of points to sample from the data.
file_name (str) – The path to the file containing the sensor data.
- Returns:
A tuple containing two arrays: - points (ndarray): The sampled points from the data. - exact_sol (ndarray): The corresponding exact solution values.
- Return type:
tuple
- abstract get_shape_function_grad_x(cell_index) ndarray [source]
Get the gradient of the shape function with respect to the x-coordinate.
- Parameters:
cell_index (int) – The index of the cell.
- Returns:
An array containing the gradient of the shape function with respect to the x-coordinate.
- Return type:
np.ndarray
- Raises:
ValueError – If the cell_index is greater than the number of cells.
This function returns the actual values of the gradient of the shape function on a given cell.
- abstract get_shape_function_grad_x_ref(cell_index) ndarray [source]
Get the gradient of the shape function with respect to the x-coordinate on the reference element.
- Parameters:
cell_index (int) – The index of the cell.
- Returns:
An array containing the gradient of the shape function with respect to the x-coordinate.
- Return type:
np.ndarray
- Raises:
ValueError – If the cell_index is greater than the number of cells.
- abstract get_shape_function_grad_y(cell_index) ndarray [source]
Get the gradient of the shape function with respect to y at the given cell index.
- Parameters:
cell_index (int) – The index of the cell.
- Returns:
The gradient of the shape function with respect to y.
- Return type:
np.ndarray
- Raises:
ValueError – If the cell_index is greater than the total number of cells.
- abstract get_shape_function_grad_y_ref(cell_index)[source]
Get the gradient of the shape function with respect to y at the reference element.
- Parameters:
cell_index (int) – The index of the cell.
- Returns:
The gradient of the shape function with respect to y at the reference element.
- Return type:
np.ndarray
- Raises:
ValueError – If cell_index is greater than the number of cells.
This function returns the gradient of the shape function with respect to y at the reference element for a given cell. The shape function gradient values are stored in the basis_grady_at_quad_ref array of the corresponding finite element cell. The cell_index parameter specifies the index of the cell for which the shape function gradient is required. If the cell_index is greater than the total number of cells, a ValueError is raised.
Note
The returned gradient values are copied from the basis_grady_at_quad_ref array to ensure immutability.
- abstract get_shape_function_val(cell_index) ndarray [source]
Get the actual values of the shape functions on a given cell.
- Parameters:
cell_index (int) – The index of the cell.
- Returns:
An array containing the actual values of the shape functions.
- Return type:
np.ndarray
- Raises:
ValueError – If the cell_index is greater than the number of cells.
- abstract set_finite_elements() None [source]
Assigns the finite elements to each cell.
This method initializes the finite element objects for each cell in the mesh. It creates an instance of the FE2D_Cell class for each cell, passing the necessary parameters. The finite element objects store information about the basis functions, gradients, Jacobians, quadrature points, weights, actual coordinates, and forcing functions associated with each cell.
After initializing the finite element objects, this method prints the shape details of various matrices and updates the total number of degrees of freedom (dofs) for the entire mesh.
- Returns:
None