datahandler2
Two-Dimensional Data Handler Implementation for PDE Solvers.
This module implements data handling functionality for 2D PDE problems, focusing on efficient tensor conversions and management of finite element data structures. It provides methods for converting numpy arrays to tensorflow tensors and handling various aspects of the PDE solution process.
The implementation supports
- Shape function and gradient tensor management
- Dirichlet boundary data processing
- Test point generation and handling
- Sensor data management for inverse problems
- Bilinear parameter tensor conversion
- Forcing function data handling
Key classes
- DataHandler2D: Implementation for 2D PDE data handling
Dependencies
- tensorflow: For tensor operations
- numpy: For numerical arrays
- FESpace2D: For finite element space handling
- Domain2D: For domain management
Note
The implementation follows FastVPINNs methodology [1] for efficient handling of finite element data structures.
References
[1] FastVPINNs: Tensor-Driven Acceleration of VPINNs for Complex Geometries DOI: https://arxiv.org/abs/2404.12063
DataHandler2D
Bases: DataHandler
Handles data conversion and management for 2D PDE problems.
This class implements the DataHandler interface for 2D problems, providing methods for converting finite element data to tensorflow tensors and managing various aspects of the PDE solution process.
Attributes:
Name | Type | Description |
---|---|---|
fespace |
Finite element space object for mesh and element info |
|
domain |
Domain object for geometric information |
|
dtype |
TensorFlow data type for tensor conversion |
|
shape_val_mat_list |
Tensor of shape function values Shape: List of matrices of shape (n_test_functions, n_quad_points) with length n_elements |
|
grad_x_mat_list |
Tensor of x-derivatives Shape: List of matrices of shape (n_test_functions, n_quad_points) with length n_elements |
|
grad_y_mat_list |
Tensor of y-derivatives Shape: List of matrices of shape (n_test_functions, n_quad_points) with length n_elements |
|
x_pde_list |
Tensor of quadrature point coordinates |
|
forcing_function_list |
Tensor of forcing function values |
|
test_points |
Tensor of test point coordinates |
Example
fespace = FESpace2D(mesh, elements) domain = Domain2D(bounds) handler = DataHandler2D(fespace, domain, tf.float32) dirichlet_input, dirichlet_vals = handler.get_dirichlet_input() test_points = handler.get_test_points()
Note
All input numpy arrays are assumed to be float64. The class handles conversion to the specified tensorflow dtype (typically float32) for computational efficiency.
Source code in scirex/core/sciml/fastvpinns/data/datahandler2d.py
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 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
|
__init__(fespace, domain, dtype)
Constructor for the DataHandler2D 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/datahandler2d.py
get_bilinear_params_dict_as_tensors(function)
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 |
---|---|
The bilinear parameters dictionary with all the values converted to tensors |
Source code in scirex/core/sciml/fastvpinns/data/datahandler2d.py
get_dirichlet_input()
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/datahandler2d.py
get_inverse_params(inverse_params_dict_function)
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 |
---|---|
dict
|
The inverse parameters dictionary with all the values converted to tensors |
Source code in scirex/core/sciml/fastvpinns/data/datahandler2d.py
get_sensor_data(exact_sol, num_sensor_points, mesh_type, file_name=None)
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 |
---|---|
tuple
|
The sensor data as a tensor |
Raises:
Type | Description |
---|---|
ValueError
|
If the mesh type is not internal or external |
Source code in scirex/core/sciml/fastvpinns/data/datahandler2d.py
get_test_points()
Get the test points for the given domain.
Returns:
Type | Description |
---|---|
Tensor
|
The test points as a tensor |
Source code in scirex/core/sciml/fastvpinns/data/datahandler2d.py
FE2D_Cell
A class for managing finite element computations at the cell level.
This class handles the storage and computation of finite element values, including basis functions, quadrature rules, and transformations for a single cell in a 2D mesh.
Attributes:
Name | Type | Description |
---|---|---|
cell_coordinates |
ndarray
|
Physical coordinates of the cell vertices |
cell_type |
str
|
Type of the cell (e.g., 'quad', 'triangle') |
fe_order |
int
|
Order of the finite element approximation |
fe_type |
str
|
Type of finite element basis |
quad_order |
int
|
Order of quadrature rule |
quad_type |
str
|
Type of quadrature formula |
fe_transformation |
str
|
Type of geometric transformation |
forcing_function |
callable
|
Source term function |
basis_function |
BasisFunction2D
|
Basis function implementation |
quad_xi |
ndarray
|
Xi coordinates of quadrature points |
quad_eta |
ndarray
|
Eta coordinates of quadrature points |
quad_weight |
ndarray
|
Quadrature weights |
jacobian |
ndarray
|
Transformation Jacobian |
basis_at_quad |
ndarray
|
Basis values at quadrature points |
basis_gradx_at_quad |
ndarray
|
X-derivatives at quadrature points |
basis_grady_at_quad |
ndarray
|
Y-derivatives at quadrature points |
quad_actual_coordinates |
ndarray
|
Physical quadrature point coordinates |
Example
coords = np.array([[0,0], [1,0], [1,1], [0,1]]) cell = FE2D_Cell( ... cell_coordinates=coords, ... cell_type='quad', ... fe_order=2, ... fe_type='lagrange', ... quad_order=3, ... quad_type='gauss', ... fe_transformation_type='bilinear', ... forcing_function=lambda x, y: x*y ... ) cell.basis_at_quad # Get basis values at quadrature points
Notes
- All gradient and derivative values are stored in the reference domain
- Jacobian and quadrature weights are combined for efficiency
- Forcing function values are typically computed in the fespace class
- Supports multiple types of transformations and element types
Source code in scirex/core/sciml/fe/fe2d_cell.py
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 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 |
|
__init__(cell_coordinates, cell_type, fe_order, fe_type, quad_order, quad_type, fe_transformation_type, forcing_function)
Constructor for the FE2D_Cell class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cell_coordinates
|
ndarray
|
Physical coordinates of the cell vertices |
required |
cell_type
|
str
|
Type of the cell (e.g., 'quad', 'triangle') |
required |
fe_order
|
int
|
Order of the finite element approximation |
required |
fe_type
|
str
|
Type of finite element basis |
required |
quad_order
|
int
|
Order of quadrature rule |
required |
quad_type
|
str
|
Type of quadrature formula |
required |
fe_transformation_type
|
str
|
Type of geometric transformation |
required |
forcing_function
|
callable
|
Source term function |
required |
Returns:
Type | Description |
---|---|
None |
Source code in scirex/core/sciml/fe/fe2d_cell.py
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 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
|
assign_basis_function()
Assigns the basis function class based on the cell type and the FE order.
Returns:
Name | Type | Description |
---|---|---|
BasisFunction2D |
BasisFunction2D
|
The basis function class for the given cell type and FE order. |
Source code in scirex/core/sciml/fe/fe2d_cell.py
assign_basis_values_at_quadrature_points()
Assigns the basis function values at the quadrature points.
This method calculates the values of the basis functions and their gradients at the quadrature points.
The basis function values are stored in self.basis_at_quad
, while the gradients are stored in
self.basis_gradx_at_quad
, self.basis_grady_at_quad
, self.basis_gradxy_at_quad
,
self.basis_gradxx_at_quad
, and self.basis_gradyy_at_quad
.
Returns:
Type | Description |
---|---|
None
|
None |
Source code in scirex/core/sciml/fe/fe2d_cell.py
assign_fe_transformation()
Assigns the FE Transformation class based on the cell type and the FE order.
This method assigns the appropriate FE Transformation class based on the cell type and the FE order. It sets the cell coordinates for the FE Transformation and obtains the Jacobian of the transformation.
Returns:
Type | Description |
---|---|
None
|
None |
Source code in scirex/core/sciml/fe/fe2d_cell.py
assign_forcing_term(forcing_function)
Assigns the forcing function values at the quadrature points.
This function computes the values of the forcing function at the quadrature points
and assigns them to the forcing_at_quad
attribute of the FE2D_Cell object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
forcing_function
|
callable
|
The forcing function to be integrated |
required |
Returns:
Type | Description |
---|---|
None
|
None |
Notes
- The final shape of
forcing_at_quad
will be N_shape_functions x 1. - This function is for backward compatibility with old code and currently assigns the values as zeros. The actual calculation is performed in the fespace class.
Source code in scirex/core/sciml/fe/fe2d_cell.py
assign_quad_weights_and_jacobian()
Assigns the quadrature weights and the Jacobian of the transformation.
This method calculates and assigns the quadrature weights and the Jacobian of the transformation
for the current cell. The quadrature weights are multiplied by the flattened Jacobian array
and stored in the mult
attribute of the class.
Returns:
Type | Description |
---|---|
None
|
None |
Source code in scirex/core/sciml/fe/fe2d_cell.py
assign_quadrature()
Assigns the quadrature points and weights based on the cell type and the quadrature order.
Returns:
Type | Description |
---|---|
None
|
None |
Source code in scirex/core/sciml/fe/fe2d_cell.py
assign_quadrature_coordinates()
Assigns the actual coordinates of the quadrature points.
This method calculates the actual coordinates of the quadrature points based on the given Xi and Eta values.
The Xi and Eta values are obtained from the quad_xi
and quad_eta
attributes of the class.
The calculated coordinates are stored in the quad_actual_coordinates
attribute as a NumPy array.
Returns:
Type | Description |
---|---|
None
|
None |
Source code in scirex/core/sciml/fe/fe2d_cell.py
Fespace
Abstract base class defining the interface for finite element spaces.
This class provides the foundation for implementing finite element spaces, including mesh handling, element operations, and solution computations.
Attributes:
Name | Type | Description |
---|---|---|
mesh |
Mesh object containing geometric information |
|
cells |
ndarray
|
Array of cell indices |
boundary_points |
dict
|
Dictionary of boundary point information |
cell_type |
str
|
Type of finite element cell |
fe_order |
int
|
Order of finite element approximation |
fe_type |
str
|
Type of finite element basis |
quad_order |
int
|
Order of quadrature rule |
quad_type |
str
|
Type of quadrature formula |
fe_transformation_type |
str
|
Type of geometric transformation |
bound_function_dict |
dict
|
Dictionary of boundary condition functions |
bound_condition_dict |
dict
|
Dictionary of boundary condition types |
forcing_function |
callable
|
Source term function |
output_path |
str
|
Path for output files |
Example
class MyFespace(Fespace): ... def set_finite_elements(self): ... # Implementation ... pass ... def generate_dirichlet_boundary_data(self): ... # Implementation ... pass ... # Implement other abstract methods
Notes
- All coordinate transformations must be implemented
- Shape function values and gradients are available in both reference and physical spaces
- Supports both internal and external sensor data for inverse problems
- Boundary conditions must be properly specified through the boundary dictionaries
Source code in scirex/core/sciml/fe/fespace.py
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 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 |
|
__init__(mesh, cells, boundary_points, cell_type, fe_order, fe_type, quad_order, quad_type, fe_transformation_type, bound_function_dict, bound_condition_dict, forcing_function, output_path)
The constructor of the Fespace2D class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mesh
|
The mesh object. |
required | |
cells
|
The cells of the mesh. |
required | |
boundary_points
|
The boundary points of the mesh. |
required | |
cell_type
|
str
|
The type of the cell. |
required |
fe_order
|
int
|
The order of the finite element. |
required |
fe_type
|
str
|
The type of the finite element. |
required |
quad_order
|
int
|
The order of the quadrature. |
required |
quad_type
|
str
|
The type of the quadrature. |
required |
fe_transformation_type
|
str
|
The type of the finite element transformation. |
required |
bound_function_dict
|
dict
|
The dictionary of the boundary functions. |
required |
bound_condition_dict
|
dict
|
The dictionary of the boundary conditions. |
required |
forcing_function
|
The forcing function. |
required | |
output_path
|
str
|
The path to the output directory. |
required |
Returns:
Type | Description |
---|---|
None
|
None |
Source code in scirex/core/sciml/fe/fespace.py
generate_dirichlet_boundary_data()
abstractmethod
Generate Dirichlet boundary data.
This function returns the boundary points and their corresponding values.
Returns:
Type | Description |
---|---|
ndarray
|
np.ndarray: The boundary points and their values. |
Notes
The boundary points and values are stored in the boundary_points
attribute of the Fespace
object.
Source code in scirex/core/sciml/fe/fespace.py
get_forcing_function_values(cell_index)
abstractmethod
Get the forcing function values at the quadrature points.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cell_index
|
int
|
The index of the cell. |
required |
Returns:
Type | Description |
---|---|
ndarray
|
np.ndarray: An array containing the forcing function values at the quadrature points. |
Raises:
Type | Description |
---|---|
ValueError
|
If the cell_index is greater than the number of cells. |
Notes
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. The forcing function is evaluated using the forcing_function
method of the fe_cell
object.
Source code in scirex/core/sciml/fe/fespace.py
get_quadrature_actual_coordinates(cell_index)
abstractmethod
Get the actual coordinates of the quadrature points for a given cell.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cell_index
|
int
|
The index of the cell. |
required |
Returns:
Type | Description |
---|---|
ndarray
|
np.ndarray: An array containing the actual coordinates of the quadrature points. |
Raises:
Type | Description |
---|---|
ValueError
|
If the cell_index is greater than the number of cells. |
Source code in scirex/core/sciml/fe/fespace.py
get_sensor_data(exact_solution, num_points)
abstractmethod
Obtain sensor data (actual solution) at random points.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
exact_solution
|
ndarray
|
The exact solution values. |
required |
num_points
|
int
|
The number of points to sample from the domain. |
required |
Returns:
Type | Description |
---|---|
ndarray
|
np.ndarray: The sensor data at the given points. |
Notes
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.
Source code in scirex/core/sciml/fe/fespace.py
get_sensor_data_external(exact_sol, num_points, file_name)
abstractmethod
This method is used to obtain the sensor data from an external file when there is no analytical solution available.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
exact_sol
|
The exact solution values. |
required | |
num_points
|
int
|
The number of points to sample from the domain. |
required |
file_name
|
str
|
The name of the file containing the sensor data. |
required |
Returns:
Type | Description |
---|---|
ndarray
|
np.ndarray: The sensor data at the given points based on the external file. |
Source code in scirex/core/sciml/fe/fespace.py
get_shape_function_grad_x(cell_index)
abstractmethod
Get the gradient of the shape function with respect to the x-coordinate.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cell_index
|
int
|
The index of the cell. |
required |
Returns:
Type | Description |
---|---|
ndarray
|
np.ndarray: An array containing the gradient of the shape function with respect to the x-coordinate. |
Raises:
Type | Description |
---|---|
ValueError
|
If the cell_index is greater than the number of cells. |
Source code in scirex/core/sciml/fe/fespace.py
get_shape_function_grad_x_ref(cell_index)
abstractmethod
Get the gradient of the shape function with respect to the x-coordinate on the reference element.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cell_index
|
int
|
The index of the cell. |
required |
Returns:
Type | Description |
---|---|
ndarray
|
np.ndarray: An array containing the gradient of the shape function with respect to the x-coordinate on the reference element. |
Raises:
Type | Description |
---|---|
ValueError
|
If the cell_index is greater than the number of cells. |
Source code in scirex/core/sciml/fe/fespace.py
get_shape_function_grad_y(cell_index)
abstractmethod
Get the gradient of the shape function with respect to y at the given cell index.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cell_index
|
int
|
The index of the cell. |
required |
Returns:
Type | Description |
---|---|
ndarray
|
np.ndarray: An array containing the gradient of the shape function with respect to y. |
Raises:
Type | Description |
---|---|
ValueError
|
If the cell_index is greater than the number of cells. |
Source code in scirex/core/sciml/fe/fespace.py
get_shape_function_grad_y_ref(cell_index)
abstractmethod
Get the gradient of the shape function with respect to y at the reference element.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cell_index
|
int
|
The index of the cell. |
required |
Returns:
Type | Description |
---|---|
np.ndarray: An array containing the gradient of the shape function with respect to y at the reference element. |
Raises:
Type | Description |
---|---|
ValueError
|
If the cell_index is greater than the number of cells. |
Notes
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. The returned gradient values are copied from the basis_grady_at_quad_ref
array to ensure immutability.
Source code in scirex/core/sciml/fe/fespace.py
get_shape_function_val(cell_index)
abstractmethod
Get the actual values of the shape functions on a given cell.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cell_index
|
int
|
The index of the cell. |
required |
Returns:
Type | Description |
---|---|
ndarray
|
np.ndarray: An array containing the actual values of the shape functions. |
Raises:
Type | Description |
---|---|
ValueError
|
If the cell_index is greater than the number of cells. |
Source code in scirex/core/sciml/fe/fespace.py
set_finite_elements()
abstractmethod
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:
Type | Description |
---|---|
None
|
None |
Source code in scirex/core/sciml/fe/fespace.py
Fespace2D
Bases: Fespace
Represents a finite element space in 2D. This class provides functionality for handling 2D finite element spaces, including mesh generation, basis function evaluation, and boundary condition handling.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mesh
|
Mesh
|
The mesh object containing the mesh information. |
required |
cells
|
ndarray
|
The cell information from the mesh. |
required |
boundary_points
|
dict
|
The boundary points information from the mesh. |
required |
cell_type
|
str
|
The type of the cell (e.g., 'quadrilateral'). |
required |
fe_order
|
int
|
The order of the finite element basis functions. |
required |
fe_type
|
str
|
The type of the finite element basis functions (e.g., 'legendre'). |
required |
quad_order
|
int
|
The order of the quadrature rule. |
required |
quad_type
|
str
|
The type of the quadrature rule (e.g., 'gauss-legendre'). |
required |
fe_transformation_type
|
str
|
The type of the finite element transformation (e.g., 'affine'). |
required |
bound_function_dict
|
dict
|
A dictionary containing the boundary functions. |
required |
bound_condition_dict
|
dict
|
A dictionary containing the boundary conditions. |
required |
forcing_function
|
function
|
The forcing function for the problem. |
required |
output_path
|
str
|
The path to save the output files. |
required |
generate_mesh_plot
|
bool
|
Flag to generate the mesh plot (default: False). |
False
|
Raises:
Type | Description |
---|---|
ValueError
|
If the cell type is not supported. |
Returns:
Type | Description |
---|---|
None |
Source code in scirex/core/sciml/fe/fespace2d.py
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 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 |
|
__init__(mesh, cells, boundary_points, cell_type, fe_order, fe_type, quad_order, quad_type, fe_transformation_type, bound_function_dict, bound_condition_dict, forcing_function, output_path, generate_mesh_plot=False)
The constructor of the Fespace2D class.
Source code in scirex/core/sciml/fe/fespace2d.py
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 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 |
|
generate_dirichlet_boundary_data()
Generate Dirichlet boundary data. This function returns the boundary points and their corresponding values.
Returns:
Name | Type | Description |
---|---|---|
tuple |
ndarray
|
The boundary points and their values as numpy arrays. |
Source code in scirex/core/sciml/fe/fespace2d.py
generate_dirichlet_boundary_data_vector(component)
Generate the boundary data vector for the Dirichlet boundary condition. This function returns the boundary points and their corresponding values for a specific component.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
component
|
int
|
The component of the boundary data vector. |
required |
Returns:
Name | Type | Description |
---|---|---|
tuple |
ndarray
|
The boundary points and their values as numpy arrays. |
Source code in scirex/core/sciml/fe/fespace2d.py
generate_plot(output_path)
Generate a plot of the mesh.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
output_path
|
str
|
The path to save the output files. |
required |
Returns:
Type | Description |
---|---|
None
|
None |
Source code in scirex/core/sciml/fe/fespace2d.py
300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 |
|
get_forcing_function_values(cell_index)
Get the forcing function values at the quadrature points.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cell_index
|
int
|
The index of the cell. |
required |
Returns:
Type | Description |
---|---|
ndarray
|
np.ndarray: The forcing function values at the quadrature points. |
Raises:
Type | Description |
---|---|
ValueError
|
If the cell_index is greater than the number of cells. |
Note
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.
Source code in scirex/core/sciml/fe/fespace2d.py
get_forcing_function_values_vector(cell_index, component)
This function will return the forcing function values at the quadrature points based on the Component of the RHS Needed, for vector valued problems
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cell_index
|
int
|
The index of the cell. |
required |
component
|
int
|
The component of the forcing function. |
required |
Returns:
Type | Description |
---|---|
ndarray
|
np.ndarray: The forcing function values at the quadrature points. |
Raises:
Type | Description |
---|---|
ValueError
|
If the cell_index is greater than the number of cells. |
Source code in scirex/core/sciml/fe/fespace2d.py
get_quadrature_actual_coordinates(cell_index)
Get the actual coordinates of the quadrature points for a given cell.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cell_index
|
int
|
The index of the cell. |
required |
Returns:
Type | Description |
---|---|
ndarray
|
np.ndarray: An array containing the actual coordinates of the quadrature points. |
Raises:
Type | Description |
---|---|
ValueError
|
If the cell_index is greater than the number of cells. |
Source code in scirex/core/sciml/fe/fespace2d.py
get_quadrature_weights(cell_index)
Return the quadrature weights for a given cell.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cell_index
|
int
|
The index of the cell for which the quadrature weights are needed. |
required |
Returns:
Type | Description |
---|---|
ndarray
|
np.ndarray: The quadrature weights for the given cell of dimension (N_Quad_Points, 1). |
Raises:
Type | Description |
---|---|
ValueError
|
If cell_index is greater than the number of cells. |
Source code in scirex/core/sciml/fe/fespace2d.py
get_sensor_data(exact_solution, num_points)
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:
Name | Type | Description | Default |
---|---|---|---|
exact_solution
|
function
|
The exact solution function. |
required |
num_points
|
int
|
The number of points to sample. |
required |
Returns:
Name | Type | Description |
---|---|---|
Tuple |
A tuple containing two arrays: sensor points and the exact solution values. |
Source code in scirex/core/sciml/fe/fespace2d.py
get_sensor_data_external(exact_sol, num_points, file_name)
This method is used to obtain the sensor data from an external file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
exact_sol
|
function
|
The exact solution function. |
required |
num_points
|
int
|
The number of points to sample. |
required |
file_name
|
str
|
The name of the file containing the sensor data. |
required |
Returns:
Name | Type | Description |
---|---|---|
Tuple |
A tuple containing two arrays: sensor points and the exact solution values. |
Note
This method reads the sensor data from a file and samples num_points
from the data.
The sensor data is then returned as a tuple containing the sensor points and the exact solution values.
Source code in scirex/core/sciml/fe/fespace2d.py
get_shape_function_grad_x(cell_index)
Get the gradient of the shape function with respect to the x-coordinate.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cell_index
|
int
|
The index of the cell. |
required |
Returns:
Type | Description |
---|---|
ndarray
|
np.ndarray: The actual values of the shape functions on the given cell. |
Raises:
Type | Description |
---|---|
ValueError
|
If the cell_index is greater than the number of cells. |
Source code in scirex/core/sciml/fe/fespace2d.py
get_shape_function_grad_x_ref(cell_index)
Get the gradient of the shape function with respect to the x-coordinate on the reference element.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cell_index
|
int
|
The index of the cell. |
required |
Returns:
Type | Description |
---|---|
ndarray
|
np.ndarray: The actual values of the shape functions on the given cell. |
Raises:
Type | Description |
---|---|
ValueError
|
If the cell_index is greater than the number of cells. |
Source code in scirex/core/sciml/fe/fespace2d.py
get_shape_function_grad_y(cell_index)
Get the gradient of the shape function with respect to y at the given cell index.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cell_index
|
int
|
The index of the cell. |
required |
Returns:
Type | Description |
---|---|
ndarray
|
np.ndarray: The actual values of the shape functions on the given cell. |
Raises:
Type | Description |
---|---|
ValueError
|
If the cell_index is greater than the number of cells. |
Source code in scirex/core/sciml/fe/fespace2d.py
get_shape_function_grad_y_ref(cell_index)
Get the gradient of the shape function with respect to y at the reference element.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cell_index
|
int
|
The index of the cell. |
required |
Returns:
Type | Description |
---|---|
np.ndarray: The actual values of the shape functions on the given cell. |
Raises:
Type | Description |
---|---|
ValueError
|
If the cell_index is greater than the number of cells. |
Note
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. The returned gradient values are copied from the basis_grady_at_quad_ref
array to ensure immutability.
Source code in scirex/core/sciml/fe/fespace2d.py
get_shape_function_val(cell_index)
Get the actual values of the shape functions on a given cell.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cell_index
|
int
|
The index of the cell. |
required |
Returns:
Type | Description |
---|---|
ndarray
|
np.ndarray: The actual values of the shape functions on the given cell. |
Raises:
Type | Description |
---|---|
ValueError
|
If the cell_index is greater than the number of cells. |
Source code in scirex/core/sciml/fe/fespace2d.py
set_finite_elements()
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.
:return: None
Source code in scirex/core/sciml/fe/fespace2d.py
Geometry
Abstract base class for geometry and mesh operations.
This class defines the interface that all geometry implementations must follow, providing the basic structure for mesh handling operations in both 2D and 3D contexts.
Attributes:
Name | Type | Description |
---|---|---|
mesh_type |
Type of mesh elements (e.g., 'quadrilateral', 'triangle') |
|
mesh_generation_method |
Method for mesh generation ('internal'/'external') |
Example
class Geometry2D(Geometry): ... def init(self, mesh_type='quadrilateral', ... method='internal'): ... super().init(mesh_type, method) ... ... def read_mesh(self, mesh_file, boundary_level, ... sampling_method, refine_level): ... # Implementation ... pass ... ... def generate_vtk_for_test(self): ... # Implementation ... pass ... ... def get_test_points(self): ... # Implementation ... return points
Note
This is an abstract base class. Concrete implementations must override: - read_mesh() - generate_vtk_for_test() - get_test_points()
Each implementation should provide appropriate mesh handling for its specific dimensional and element type requirements.
Source code in scirex/core/sciml/geometry/geometry.py
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 |
|
__init__(mesh_type, mesh_generation_method)
Constructor for the Geometry class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mesh_type
|
str
|
Type of mesh elements (e.g., 'quadrilateral', 'triangle') |
required |
mesh_generation_method
|
str
|
Method for mesh generation ('internal'/'external') |
required |
Returns:
Type | Description |
---|---|
None |
Source code in scirex/core/sciml/geometry/geometry.py
generate_vtk_for_test()
abstractmethod
Generates a VTK from Mesh file (External) or using gmsh (for Internal).
Args: None
Returns: None
get_test_points()
abstractmethod
This function is used to extract the test points from the given mesh
Returns:
Name | Type | Description |
---|---|---|
points |
ndarray
|
Test points extracted from the mesh |
read_mesh(mesh_file, boundary_point_refinement_level, bd_sampling_method, refinement_level)
abstractmethod
Abstract method to read mesh from Gmsh. This method should be implemented by the derived classes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mesh_file
|
str
|
Path to the mesh file |
required |
boundary_point_refinement_level
|
int
|
Level of refinement for boundary points |
required |
bd_sampling_method
|
str
|
Sampling method for boundary points |
required |
refinement_level
|
int
|
Level of mesh refinement |
required |
Returns:
Type | Description |
---|---|
None |
Source code in scirex/core/sciml/geometry/geometry.py
Geometry_2D
Bases: Geometry
Implements 2D geometry and mesh handling capabilities.
This class provides comprehensive functionality for managing 2D meshes, including both internal generation and external mesh reading. It supports various mesh operations, boundary handling, and visualization capabilities.
Attributes:
Name | Type | Description |
---|---|---|
mesh_type |
Type of mesh elements ('quadrilateral') |
|
mesh_generation_method |
Method of mesh generation ('internal'/'external') |
|
n_test_points_x |
Number of test points in x-direction |
|
n_test_points_y |
Number of test points in y-direction |
|
output_folder |
Path for output files |
|
is_optimized |
Flag for mesh optimization |
|
n_cells_x |
Number of cells in x-direction (internal mesh) |
|
n_cells_y |
Number of cells in y-direction (internal mesh) |
|
x_limits |
Domain limits in x-direction |
|
y_limits |
Domain limits in y-direction |
|
mesh_file_name |
Name of external mesh file |
|
mesh |
MeshIO mesh object |
|
bd_dict |
Dictionary of boundary points |
|
cell_points |
Array of cell vertices |
|
test_points |
Array of test points |
Example
geometry = Geometry_2D( ... mesh_type='quadrilateral', ... mesh_generation_method='internal', ... n_test_points_x=10, ... n_test_points_y=10, ... output_folder='./output' ... ) cells, bounds = geometry.generate_quad_mesh_internal( ... x_limits=(0,1), ... y_limits=(0,1), ... n_cells_x=5, ... n_cells_y=5, ... num_boundary_points=40 ... )
Note
- Only supports quadrilateral elements
- Internal mesh generation is limited to rectangular domains
- External mesh reading requires Gmsh format
- Boundary points can be sampled uniformly or using LHS
Source code in scirex/core/sciml/geometry/geometry_2d.py
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 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 |
|
__init__(mesh_type, mesh_generation_method, n_test_points_x, n_test_points_y, output_folder, is_optimized=False)
Constructor for Geometry_2D class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mesh_type
|
str
|
Type of mesh elements ('quadrilateral') |
required |
mesh_generation_method
|
str
|
Method of mesh generation ('internal'/'external') |
required |
n_test_points_x
|
int
|
Number of test points in x-direction |
required |
n_test_points_y
|
int
|
Number of test points in y-direction |
required |
output_folder
|
str
|
Path for output files |
required |
is_optimized
|
bool
|
Flag for mesh optimization |
False
|
Raises:
Type | Description |
---|---|
ValueError
|
If mesh type or generation method is invalid |
Returns:
Type | Description |
---|---|
None |
Source code in scirex/core/sciml/geometry/geometry_2d.py
generate_quad_mesh_internal(x_limits, y_limits, n_cells_x, n_cells_y, num_boundary_points)
Generate and save a quadrilateral mesh with physical curves.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x_limits
|
tuple
|
Domain limits in x-direction |
required |
y_limits
|
tuple
|
Domain limits in y-direction |
required |
n_cells_x
|
int
|
Number of cells in x-direction |
required |
n_cells_y
|
int
|
Number of cells in y-direction |
required |
num_boundary_points
|
int
|
Number of boundary points |
required |
Returns:
Name | Type | Description |
---|---|---|
cell_points |
Array of cell vertices |
|
bd_dict |
Dictionary of boundary points |
Source code in scirex/core/sciml/geometry/geometry_2d.py
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 |
|
generate_vtk_for_test()
Generates a VTK from Mesh file (External) or using gmsh (for Internal).
Returns:
Type | Description |
---|---|
None |
Source code in scirex/core/sciml/geometry/geometry_2d.py
455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 |
|
get_test_points()
This function is used to extract the test points from the given mesh
Returns:
Name | Type | Description |
---|---|---|
test_points |
ndarray
|
Array of test points |
Source code in scirex/core/sciml/geometry/geometry_2d.py
plot_adaptive_mesh(cells_list, area_averaged_cell_loss_list, epoch, filename='cell_residual')
Plots the residuals in each cell of the mesh.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cells_list
|
List of cell vertices |
required | |
area_averaged_cell_loss_list
|
List of area averaged cell loss |
required | |
epoch
|
The epoch number |
required | |
filename
|
The output filename |
'cell_residual'
|
Returns:
Type | Description |
---|---|
None |
Source code in scirex/core/sciml/geometry/geometry_2d.py
read_mesh(mesh_file, boundary_point_refinement_level, bd_sampling_method, refinement_level)
Reads mesh from a Gmsh .msh file and extracts cell information.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mesh_file
|
str
|
Path to the mesh file |
required |
boundary_point_refinement_level
|
int
|
Level of boundary point refinement |
required |
bd_sampling_method
|
str
|
Method for boundary point sampling ('uniform'/'lhs') |
required |
refinement_level
|
int
|
Level of mesh refinement |
required |
Returns:
Name | Type | Description |
---|---|---|
cell_points |
Array of cell vertices |
|
bd_dict |
Dictionary of boundary points |
Raises:
Type | Description |
---|---|
ValueError
|
If mesh file format is invalid |
Source code in scirex/core/sciml/geometry/geometry_2d.py
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 |
|
write_vtk(solution, output_path, filename, data_names)
Writes the data to a VTK file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
solution
|
ndarray
|
The solution data to be written |
required |
output_path
|
str
|
The output path for the VTK file |
required |
filename
|
str
|
The name of the output file |
required |
data_names
|
list
|
List of data names |
required |
Returns:
Type | Description |
---|---|
None |
Source code in scirex/core/sciml/geometry/geometry_2d.py
print_table(title, columns, col_1_values, col_2_values)
This function prints a table with two columns to the console.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
title
|
str
|
str: Title of the table |
required |
columns
|
list
|
list: List of column names |
required |
col_1_values
|
list
|
list: List of values for column 1 |
required |
col_2_values
|
list
|
list: List of values for column |
required |
Returns:
Type | Description |
---|---|
None |