fastvpinns.data.datahandler2d module

This file datahandler2d.py is to handle data for 2D problems, convert them into tensors using custom tf functions and make them available for the model to train

Author : Thivin Anandh D

Date : 22/Sep/2023

History : 22/Sep/2023 - Initial implementation with basic data handling

class fastvpinns.data.datahandler2d.DataHandler2D(fespace, domain, dtype)[source]

Bases: DataHandler

This class is to handle data for 2D problems, convert them into tensors using custom tf functions. It is responsible for all type conversions and data handling.

Note

All inputs to these functions are generally numpy arrays with dtype np.float64. So we can either maintain the same dtype or convert them to tf.float32 ( for faster computation ).

Parameters:
  • fespace (FESpace2D) – The FESpace2D object.

  • domain (Domain2D) – The Domain2D object.

  • shape_val_mat_list (list) – List of shape function values for each cell.

  • grad_x_mat_list (list) – List of shape function derivatives with respect to x for each cell.

  • grad_y_mat_list (list) – List of shape function derivatives with respect to y for each cell.

  • x_pde_list (list) – List of actual coordinates of the quadrature points for each cell.

  • forcing_function_list (list) – List of forcing function values for each cell.

  • dtype (tf.DType) – The tensorflow dtype to be used for all the tensors.

get_bilinear_params_dict_as_tensors(function)[source]

Accepts a function from example file and converts all the values into tensors of the given dtype

Parameters: - function (function): The function from the example file which returns the bilinear parameters dictionary

Returns: - bilinear_params_dict (dict): The bilinear parameters dictionary with all the values converted to tensors

Parameters:

function (function) – The function from the example file which returns the bilinear parameters dictionary

Returns:

The bilinear parameters dictionary with all the values converted to tensors

Return type:

dict

get_dirichlet_input()[source]

This function will return the input for the Dirichlet boundary data

Returns:

  • input_dirichlet (tf.Tensor): The input for the Dirichlet boundary data

  • actual_dirichlet (tf.Tensor): The actual Dirichlet boundary data

get_inverse_params(inverse_params_dict_function)[source]

Accepts a function from example file and converts all the values into tensors of the given dtype

Parameters:

inverse_params_dict_function (function) – The function from the example file which returns the inverse parameters dictionary

Returns:

The inverse parameters dictionary with all the values converted to tensors

Return type:

dict

get_sensor_data(exact_sol, num_sensor_points, mesh_type, file_name=None)[source]

Accepts a function from example file and converts all the values into tensors of the given dtype

Parameters:
  • exact_sol (function) – The function from the example file which returns the exact solution

  • num_sensor_points (int) – The number of sensor points to be generated

  • mesh_type (str) – The type of mesh to be used for sensor data generation

  • file_name (str, optional) – The name of the file to be used for external mesh generation, defaults to None

Returns:

The sensor points and sensor values as tensors

Return type:

tuple[tf.Tensor, tf.Tensor]

get_test_points()[source]

Get the test points for the given domain.

Returns:

The test points for the given domain.

Return type:

tf.Tensor