fastvpinns.Geometry.geometry_2d module

This module, geometry_2d.py, contains the Geometry_2D class which defines functions to read mesh from Gmsh and generate internal mesh for 2D problems. It supports different types of meshes and mesh generation methods. The class also allows for specifying the number of test points in the x and y directions, and the output folder for storing results.

Author: Thivin Anandh D

Date: 21/Sep/2023

class fastvpinns.Geometry.geometry_2d.Geometry_2D(mesh_type: str, mesh_generation_method: str, n_test_points_x: int, n_test_points_y: int, output_folder: str, is_optimized: bool = False)[source]

Bases: Geometry

Defines functions to read mesh from Gmsh and internal mesh for 2D problems.

Parameters:
  • mesh_type (str) – The type of mesh to be used.

  • mesh_generation_method (str) – The method used to generate the mesh.

  • n_test_points_x (int) – The number of test points in the x-direction.

  • n_test_points_y (int) – The number of test points in the y-direction.

  • output_folder (str) – The path to the output folder.

generate_quad_mesh_internal(x_limits: tuple, y_limits: tuple, n_cells_x: int, n_cells_y: int, num_boundary_points: int)[source]

Generate and save a quadrilateral mesh with physical curves.

Parameters:
  • x_limits (tuple) – The lower and upper limits in the x-direction (x_min, x_max).

  • y_limits (tuple) – The lower and upper limits in the y-direction (y_min, y_max).

  • n_cells_x (int) – The number of cells in the x-direction.

  • n_cells_y (int) – The number of cells in the y-direction.

  • num_boundary_points (int) – The number of boundary points.

Returns:

The cell points and the dictionary of boundary points.

Return type:

tuple[numpy.ndarray, dict]

generate_vtk_for_test()[source]

Generates a VTK from Mesh file (External) or using gmsh (for Internal).

Returns:

None

get_test_points()[source]

This function is used to extract the test points from the given mesh

Parameters: None

Returns: test_points (numpy.ndarray): The test points for the given domain

plot_adaptive_mesh(cells_list, area_averaged_cell_loss_list, epoch, filename='cell_residual')[source]

Plots the residuals in each cell of the mesh.

Parameters:
  • cells_list (list) – The list of cells.

  • area_averaged_cell_loss_list (list) – The list of area averaged cell residual (or the normal residual).

  • epoch (int) – The epoch number (for file name).

  • filename (str, optional) – The name of the output file, defaults to “cell_residual”.

Returns:

None

read_mesh(mesh_file: str, boundary_point_refinement_level: int, bd_sampling_method: str, refinement_level: int)[source]

Reads mesh from a Gmsh .msh file and extracts cell information.

Parameters:
  • mesh_file (str) – The path to the mesh file.

  • boundary_point_refinement_level (int) – The number of boundary points to be generated.

  • bd_sampling_method (str) – The method used to generate the boundary points.

  • refinement_level (int) – The number of times the mesh should be refined.

Returns:

The cell points and the dictionary of boundary points.

Return type:

tuple

write_vtk(solution, output_path, filename, data_names)[source]

Writes the data to a VTK file.

Parameters:
  • solution (numpy.ndarray) – The solution vector.

  • output_path (str) – The path to the output folder.

  • filename (str) – The name of the output file.

  • data_names (list) – The list of data names in the VTK file to be written as scalars.

Returns:

None