datahandler
Abstract Base Interface for Neural Network Data Handling in PDEs.
This module provides the base interface for handling data transformations and tensor conversions required for neural network-based PDE solvers. It defines the essential structure for managing various data types involved in finite element computations.
The implementation supports
- Finite element data processing
- Dirichlet boundary condition handling
- Test point generation and management
- Bilinear parameter tensor conversion
- Sensor data generation and handling
- Parameter management for inverse problems
Key classes
- DataHandler: Abstract base class for PDE data handling
Note
All implementations assume double precision (float64) numpy arrays as inputs, with optional conversion to float32 for computational efficiency.
Dependencies
- abc: For abstract base class functionality
- tensorflow: For tensor operations
- numpy: For numerical arrays
Versions
- 27-Dec-2024 (Version 0.1): Initial Implementation
DataHandler
Abstract base class for PDE solution data handling and tensor conversion.
This class defines the interface for managing and converting various data types required in neural network-based PDE solvers. It handles transformation between numpy arrays and tensorflow tensors, and manages different aspects of the finite element computation data.
Attributes:
Name | Type | Description |
---|---|---|
fespace |
Finite element space object containing mesh and element info |
|
domain |
Domain object containing geometric and boundary information |
|
dtype |
TensorFlow data type for tensor conversion (float32/float64) |
Example
class MyDataHandler(DataHandler): ... def init(self, fespace, domain): ... super().init(fespace, domain, tf.float32) ... ... def get_dirichlet_input(self): ... # Implementation ... pass ... ... def get_test_points(self): ... # Implementation ... pass
Note
Concrete implementations must override: - get_dirichlet_input() - get_test_points() - get_bilinear_params_dict_as_tensors() - get_sensor_data() - get_inverse_params()
All methods should handle type conversion between numpy arrays and tensorflow tensors consistently.
Source code in scirex/core/sciml/fastvpinns/data/datahandler.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
|
__init__(fespace, domain, dtype)
Constructor for the DataHandler class
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fespace
|
FESpace2D
|
The FESpace2D object. |
required |
domain
|
Domain2D
|
The Domain2D object. |
required |
dtype
|
DType
|
The tensorflow dtype to be used for all the tensors. |
required |
Returns:
Type | Description |
---|---|
None |
Source code in scirex/core/sciml/fastvpinns/data/datahandler.py
get_bilinear_params_dict_as_tensors(function)
abstractmethod
Accepts a function from example file and converts all the values into tensors of the given dtype
Parameters:
Name | Type | Description | Default |
---|---|---|---|
function
|
function
|
The function from the example file which returns the bilinear parameters dictionary |
required |
Returns:
Type | Description |
---|---|
dict
|
The bilinear parameters dictionary with all the values converted to tensors |
Source code in scirex/core/sciml/fastvpinns/data/datahandler.py
get_dirichlet_input()
abstractmethod
This function will return the input for the Dirichlet boundary data
Returns:
Type | Description |
---|---|
tuple
|
The Dirichlet boundary data as a tuple of tensors |
Source code in scirex/core/sciml/fastvpinns/data/datahandler.py
get_inverse_params(inverse_params_dict_function)
abstractmethod
Accepts a function from example file and converts all the values into tensors of the given dtype
Parameters:
Name | Type | Description | Default |
---|---|---|---|
inverse_params_dict_function
|
function
|
The function from the example file which returns the inverse parameters dictionary |
required |
Returns:
Type | Description |
---|---|
The inverse parameters dictionary with all the values converted to tensors |
Source code in scirex/core/sciml/fastvpinns/data/datahandler.py
get_sensor_data(exact_sol, num_sensor_points, mesh_type, file_name=None)
abstractmethod
Accepts a function from example file and converts all the values into tensors of the given dtype
Parameters:
Name | Type | Description | Default |
---|---|---|---|
exact_sol
|
function
|
The exact solution function |
required |
num_sensor_points
|
int
|
The number of sensor points |
required |
mesh_type
|
str
|
The type of mesh |
required |
file_name
|
str
|
The file name to save the sensor data |
None
|
Returns:
Type | Description |
---|---|
The sensor data as a tensor |
Source code in scirex/core/sciml/fastvpinns/data/datahandler.py
get_test_points()
abstractmethod
Get the test points for the given domain.
Returns:
Type | Description |
---|---|
The test points as a tensor |